Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-conte.../plugins/protect-.../admin
File: class-protect-uploads-admin.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class Alti_ProtectUploads_Admin
[2] Fix | Delete
{
[3] Fix | Delete
[4] Fix | Delete
private $plugin_name;
[5] Fix | Delete
private $version;
[6] Fix | Delete
private $messages = array();
[7] Fix | Delete
[8] Fix | Delete
public function __construct($plugin_name, $version)
[9] Fix | Delete
{
[10] Fix | Delete
$this->plugin_name = $plugin_name;
[11] Fix | Delete
$this->version = $version;
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
public function get_plugin_name()
[15] Fix | Delete
{
[16] Fix | Delete
return $this->plugin_name;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
public function add_submenu_page()
[20] Fix | Delete
{
[21] Fix | Delete
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'));
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
public function verify_settings_page() {
[25] Fix | Delete
if(!isset($_POST['protect-uploads_nonce'])) {
[26] Fix | Delete
return;
[27] Fix | Delete
}
[28] Fix | Delete
if(!wp_verify_nonce($_POST['protect-uploads_nonce'], 'submit_form')) {
[29] Fix | Delete
return;
[30] Fix | Delete
}
[31] Fix | Delete
if(!current_user_can('manage_options')) {
[32] Fix | Delete
return;
[33] Fix | Delete
}
[34] Fix | Delete
if(!check_admin_referer('submit_form', 'protect-uploads_nonce')) {
[35] Fix | Delete
return;
[36] Fix | Delete
}
[37] Fix | Delete
if (isset($_POST['submit']) && isset($_POST['protection'])) {
[38] Fix | Delete
$this->save_form(sanitize_text_field($_POST['protection']));
[39] Fix | Delete
}
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
public function render_settings_page()
[43] Fix | Delete
{
[44] Fix | Delete
?>
[45] Fix | Delete
<div class="wrap <?php echo $this->plugin_name ?>">
[46] Fix | Delete
<?php
[47] Fix | Delete
echo $this->display_messages();
[48] Fix | Delete
?>
[49] Fix | Delete
<h1>Protect Uploads</h1>
[50] Fix | Delete
<div class="protect-uploads-main-container">
[51] Fix | Delete
<form method="POST" action="">
[52] Fix | Delete
<?php wp_nonce_field('submit_form', 'protect-uploads_nonce'); ?>
[53] Fix | Delete
[54] Fix | Delete
<table class="form-table">
[55] Fix | Delete
<tbody>
[56] Fix | Delete
<tr>
[57] Fix | Delete
<th scope="row">
[58] Fix | Delete
<label for=""><?php _e('Status', $this->plugin_name); ?></label>
[59] Fix | Delete
</th>
[60] Fix | Delete
<td>
[61] Fix | Delete
<fieldset>
[62] Fix | Delete
<p>
[63] Fix | Delete
<strong>
[64] Fix | Delete
<?php if ($this->check_uploads_is_protected() === true) { ?>
[65] Fix | Delete
<span class="dashicons dashicons-yes-alt" style="color:#46b450"></span> <?php _e('Uploads directory is protected.', $this->plugin_name); ?>
[66] Fix | Delete
<?php } else { ?>
[67] Fix | Delete
<span style="color:#dc3232" class="dashicons dashicons-dismiss"></span> <?php _e('Uploads directory is not protected!', $this->plugin_name); ?>
[68] Fix | Delete
<?php } ?>
[69] Fix | Delete
</strong>
[70] Fix | Delete
</p>
[71] Fix | Delete
<p>
[72] Fix | Delete
<?php
[73] Fix | Delete
$file_messages = $this->get_uploads_protection_message_array();
[74] Fix | Delete
foreach ($file_messages as $file_message) {
[75] Fix | Delete
?>
[76] Fix | Delete
<?php echo $file_message; ?> <br />
[77] Fix | Delete
<?php
[78] Fix | Delete
} ?>
[79] Fix | Delete
</p>
[80] Fix | Delete
</fieldset>
[81] Fix | Delete
</td>
[82] Fix | Delete
</tr>
[83] Fix | Delete
<tr>
[84] Fix | Delete
<th scope="row">
[85] Fix | Delete
<label for="size"><?php _e('Protection', $this->plugin_name); ?></label>
[86] Fix | Delete
</th>
[87] Fix | Delete
<td>
[88] Fix | Delete
<fieldset>
[89] Fix | Delete
<legend class="screen-reader-text">
[90] Fix | Delete
<span><?php _e('Protection', $this->plugin_name); ?></span>
[91] Fix | Delete
</legend>
[92] Fix | Delete
<?php if ($this->check_uploads_is_protected() === false) { ?>
[93] Fix | Delete
<!-- -->
[94] Fix | Delete
<label for="protection_1">
[95] Fix | Delete
<input type="radio" value="index_php" name="protection" id="protection_1">
[96] Fix | Delete
<strong><?php _e('Protect with index.php files', $this->plugin_name); ?></strong>
[97] Fix | Delete
<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>
[98] Fix | Delete
</label><br />
[99] Fix | Delete
<!-- -->
[100] Fix | Delete
<label for="protection_2">
[101] Fix | Delete
<input type="radio" value="htaccess" name="protection" id="protection_2">
[102] Fix | Delete
<strong><?php _e('Protect with .htaccess file', $this->plugin_name); ?></strong>
[103] Fix | Delete
<p class="description"><?php _e('Create .htaccess file at root level of uploads directory and returns 403 code (Forbidden Access).', $this->plugin_name); ?></p>
[104] Fix | Delete
</label><br />
[105] Fix | Delete
<?php } ?>
[106] Fix | Delete
<!-- -->
[107] Fix | Delete
<?php if ( $this->check_protective_file_removable() && $this->check_uploads_is_protected() ) { ?>
[108] Fix | Delete
<label for="protection_3">
[109] Fix | Delete
<input type="radio" value="remove" name="protection" id="protection_3">
[110] Fix | Delete
<strong><?php _e('Remove protection files', $this->plugin_name); ?></strong>
[111] Fix | Delete
<p>
[112] Fix | Delete
<?php if ($this->check_protective_file('index.php') === true) {
[113] Fix | Delete
echo '<span class="dashicons dashicons-flag"></span> index.php ';
[114] Fix | Delete
_e('will be removed', $this->plugin_name);
[115] Fix | Delete
} ?>
[116] Fix | Delete
<?php if ($this->check_protective_file('.htaccess') === true) {
[117] Fix | Delete
echo '<span class="dashicons dashicons-flag"></span> .htaccess ';
[118] Fix | Delete
_e('will be removed', $this->plugin_name);
[119] Fix | Delete
} ?>
[120] Fix | Delete
</p>
[121] Fix | Delete
</label><br />
[122] Fix | Delete
<?php } ?>
[123] Fix | Delete
<?php if ($this->check_protective_file('index.html') === true) { ?>
[124] Fix | Delete
<p class="description">
[125] Fix | Delete
<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) ?>
[126] Fix | Delete
</p>
[127] Fix | Delete
<?php } ?>
[128] Fix | Delete
</fieldset>
[129] Fix | Delete
[130] Fix | Delete
</td>
[131] Fix | Delete
</tr>
[132] Fix | Delete
<tr>
[133] Fix | Delete
<th scope="row">
[134] Fix | Delete
<label for=""><?php _e('Check', $this->plugin_name); ?></label>
[135] Fix | Delete
</th>
[136] Fix | Delete
<td>
[137] Fix | Delete
<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>
[138] Fix | Delete
</td>
[139] Fix | Delete
</tr>
[140] Fix | Delete
<tr>
[141] Fix | Delete
<th scope="row">
[142] Fix | Delete
<label for=""><?php _e('Support', $this->plugin_name); ?></label>
[143] Fix | Delete
</th>
[144] Fix | Delete
<td>
[145] Fix | Delete
<p><?php _e('Protect Uploads Plugin <a href="https://wordpress.org/support/plugin/protect-uploads/" target="_blank">support page</a>.', $this->plugin_name); ?></p>
[146] Fix | Delete
</td>
[147] Fix | Delete
</tr>
[148] Fix | Delete
<tr>
[149] Fix | Delete
<th scope="row">
[150] Fix | Delete
</th>
[151] Fix | Delete
<td>
[152] Fix | Delete
<?php submit_button(__('Update', $this->plugin_name), 'primary') ?>
[153] Fix | Delete
</td>
[154] Fix | Delete
</tr>
[155] Fix | Delete
</tbody>
[156] Fix | Delete
</table>
[157] Fix | Delete
[158] Fix | Delete
</form>
[159] Fix | Delete
[160] Fix | Delete
</div>
[161] Fix | Delete
<div class="alti-watermark-sidebar">
[162] Fix | Delete
<div class="alti_promote_widget">
[163] Fix | Delete
<div class="alti_promote_title">Like this plugin?</div>
[164] Fix | Delete
<p><a target="_blank" class="alti_promote_btn" href="https://wordpress.org/support/view/plugin-reviews/<?php echo $this->plugin_name; ?>?rate=5#postform"><strong>Rate it</strong></a> to show your support!</p>
[165] Fix | Delete
</div>
[166] Fix | Delete
</div>
[167] Fix | Delete
[168] Fix | Delete
</div>
[169] Fix | Delete
[170] Fix | Delete
<style>
[171] Fix | Delete
.protect-uploads-error {
[172] Fix | Delete
border: 2px solid #dc3232;
[173] Fix | Delete
display: inline-block;
[174] Fix | Delete
padding: 10px;
[175] Fix | Delete
}
[176] Fix | Delete
.protect-uploads-success {
[177] Fix | Delete
border: 1px solid #46b450;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/* container left and right */
[181] Fix | Delete
.protect-uploads .protect-uploads-main-container {
[182] Fix | Delete
float: left;
[183] Fix | Delete
width: 66%;
[184] Fix | Delete
}
[185] Fix | Delete
.protect-uploads .protect-uploads-sidebar {
[186] Fix | Delete
float: left;
[187] Fix | Delete
width: 31%;
[188] Fix | Delete
margin-left: 2%;
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
.protect-uploads-disabled {
[192] Fix | Delete
opacity: 0.75 !important;
[193] Fix | Delete
}
[194] Fix | Delete
.alti_promote_widget {
[195] Fix | Delete
background-color: #fff;
[196] Fix | Delete
padding: 10px;
[197] Fix | Delete
margin: 15px 0;
[198] Fix | Delete
border: 1px solid #E5E5E5;
[199] Fix | Delete
position: relative;
[200] Fix | Delete
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
[201] Fix | Delete
overflow: hidden;
[202] Fix | Delete
}
[203] Fix | Delete
[204] Fix | Delete
.alti_promote_widget .dashicons {
[205] Fix | Delete
color: #238ECB !important;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
.alti_promote_plugin {
[209] Fix | Delete
margin: 5px 0 5px -5px;
[210] Fix | Delete
clear: both;
[211] Fix | Delete
overflow: hidden;
[212] Fix | Delete
font-size: 14px;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
.alti_promote_plugin a {
[216] Fix | Delete
position: relative;
[217] Fix | Delete
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
[218] Fix | Delete
float: left;
[219] Fix | Delete
display: block;
[220] Fix | Delete
margin-right: 5px;
[221] Fix | Delete
width: 100%;
[222] Fix | Delete
text-decoration: none;
[223] Fix | Delete
border: 5px solid transparent;
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
.alti_promote_plugin a:hover {
[227] Fix | Delete
background-color: #eee;
[228] Fix | Delete
border: 5px solid #eee;
[229] Fix | Delete
}
[230] Fix | Delete
[231] Fix | Delete
.alti_promote_plugin img {
[232] Fix | Delete
width: 50px;
[233] Fix | Delete
height: 50px;
[234] Fix | Delete
margin-right: 10px;
[235] Fix | Delete
display: block;
[236] Fix | Delete
float: left;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
.alti_promote_plugin .alti_promote_copy {
[240] Fix | Delete
color: #555;
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
.alti_promote_plugin .alti_promote_copy strong {
[244] Fix | Delete
display: block;
[245] Fix | Delete
color: #333;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
.alti_promote_title {
[249] Fix | Delete
font-size: 1.2em;
[250] Fix | Delete
font-weight: bold;
[251] Fix | Delete
color: #222;
[252] Fix | Delete
margin-bottom: 12.5px;
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
.alti_promote_title span:before {
[256] Fix | Delete
color: #222;
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
.alti_promote_btn {
[260] Fix | Delete
background: rgba(35, 142, 203, 0.3);
[261] Fix | Delete
display: inline-block;
[262] Fix | Delete
padding: 2.5px 5px;
[263] Fix | Delete
border-radius: 2.5px;
[264] Fix | Delete
text-decoration: none;
[265] Fix | Delete
color: #333;
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
.alti_promote_paypal {
[269] Fix | Delete
color: #021E73;
[270] Fix | Delete
font-weight: bold;
[271] Fix | Delete
text-shadow: 2px 2px 0 #1189D6;
[272] Fix | Delete
display: inline-block;
[273] Fix | Delete
background-color: #fff;
[274] Fix | Delete
padding: 0 5px;
[275] Fix | Delete
border-radius: 15px;
[276] Fix | Delete
font-size: 1.2em;
[277] Fix | Delete
line-height: 1.3em;
[278] Fix | Delete
font-family: sans-serif;
[279] Fix | Delete
border: 1px solid #ccc;
[280] Fix | Delete
}
[281] Fix | Delete
[282] Fix | Delete
.alti_promote_paypal_svg svg {
[283] Fix | Delete
height: 15px;
[284] Fix | Delete
width: 65px;
[285] Fix | Delete
vertical-align: middle;
[286] Fix | Delete
}
[287] Fix | Delete
</style>
[288] Fix | Delete
<?php
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
public function enqueue_styles()
[292] Fix | Delete
{
[293] Fix | Delete
wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'assets/css/protect-uploads-admin.css', array(), $this->version, 'all');
[294] Fix | Delete
}
[295] Fix | Delete
[296] Fix | Delete
public function add_settings_link($links)
[297] Fix | Delete
{
[298] Fix | Delete
$settings_link = '<a href="upload.php?page=' . $this->plugin_name . '-settings-page">' . __('Settings') . '</a>';
[299] Fix | Delete
array_unshift($links, $settings_link);
[300] Fix | Delete
return $links;
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
public function get_uploads_dir()
[304] Fix | Delete
{
[305] Fix | Delete
$uploads_dir = wp_upload_dir();
[306] Fix | Delete
return $uploads_dir['basedir'];
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
public function get_uploads_url()
[310] Fix | Delete
{
[311] Fix | Delete
$uploads_dir = wp_upload_dir();
[312] Fix | Delete
return $uploads_dir['baseurl'];
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
public function get_uploads_subdirectories()
[316] Fix | Delete
{
[317] Fix | Delete
[318] Fix | Delete
return [self::get_uploads_dir()];
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
public function save_form($protection)
[322] Fix | Delete
{
[323] Fix | Delete
if ($protection == 'index_php') {
[324] Fix | Delete
$this->create_index();
[325] Fix | Delete
}
[326] Fix | Delete
if ($protection == 'htaccess') {
[327] Fix | Delete
$this->create_htaccess();
[328] Fix | Delete
}
[329] Fix | Delete
if ($protection == 'remove') {
[330] Fix | Delete
$this->remove_index();
[331] Fix | Delete
$this->remove_htaccess();
[332] Fix | Delete
}
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
// used to check if the current htaccess has been generated by the plugin
[336] Fix | Delete
public function get_htaccess_identifier()
[337] Fix | Delete
{
[338] Fix | Delete
return "[plugin_name=" . $this->plugin_name . "]";
[339] Fix | Delete
}
[340] Fix | Delete
[341] Fix | Delete
public function create_index()
[342] Fix | Delete
{
[343] Fix | Delete
// check if index php does not exists
[344] Fix | Delete
if (self::check_protective_file('index.php') === false) {
[345] Fix | Delete
[346] Fix | Delete
$indexContent = "<?php // Silence is golden \n // " . self::get_htaccess_identifier() . " \n // protect-uploads \n // date:" . date('d/m/Y') . "\n // .";
[347] Fix | Delete
$i = 0;
[348] Fix | Delete
foreach (self::get_uploads_subdirectories() as $subDirectory) {
[349] Fix | Delete
[350] Fix | Delete
if (!file_put_contents($subDirectory . '/' . 'index.php', $indexContent)) {
[351] Fix | Delete
self::register_message('Impossible to create or modified the index.php file in ' . $subDirectory, 'error');
[352] Fix | Delete
} else {
[353] Fix | Delete
$i++;
[354] Fix | Delete
}
[355] Fix | Delete
}
[356] Fix | Delete
[357] Fix | Delete
if ($i == count(self::get_uploads_subdirectories())) {
[358] Fix | Delete
self::register_message('The index.php file has been created in main folder and subfolders (two levels max).');
[359] Fix | Delete
}
[360] Fix | Delete
}
[361] Fix | Delete
// if index php already exists
[362] Fix | Delete
else {
[363] Fix | Delete
self::register_message('The index.php file already exists', 'error');
[364] Fix | Delete
}
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
public function create_htaccess()
[368] Fix | Delete
{
[369] Fix | Delete
// Content for htaccess file
[370] Fix | Delete
$date = date('Y-m-d H:i.s');
[371] Fix | Delete
$phpv = phpversion();
[372] Fix | Delete
[373] Fix | Delete
$htaccessContent = "\n# BEGIN " . $this->get_plugin_name() . " Plugin\n";
[374] Fix | Delete
$htaccessContent .= "\tOptions -Indexes\n";
[375] Fix | Delete
$htaccessContent .= "# [date={$date}] [php={$phpv}] " . self::get_htaccess_identifier() . " [version={$this->version}]\n";
[376] Fix | Delete
$htaccessContent .= "# END " . $this->get_plugin_name() . " Plugin\n";
[377] Fix | Delete
[378] Fix | Delete
// if htaccess does NOT exist yet
[379] Fix | Delete
if (self::check_protective_file('.htaccess') === false) {
[380] Fix | Delete
// try to create and save the new htaccess file
[381] Fix | Delete
if (!file_put_contents(self::get_uploads_dir() . '/' . '.htaccess', $htaccessContent)) {
[382] Fix | Delete
self::register_message('Impossible to create or modified the htaccess file.', 'error');
[383] Fix | Delete
} else {
[384] Fix | Delete
self::register_message('The htaccess file has been created.');
[385] Fix | Delete
}
[386] Fix | Delete
}
[387] Fix | Delete
else {
[388] Fix | Delete
// if content added to existing htaccess
[389] Fix | Delete
if (file_put_contents(self::get_uploads_dir() . '/.htaccess', $htaccessContent, FILE_APPEND | LOCK_EX)) {
[390] Fix | Delete
self::register_message('The htaccess file has been updated.');
[391] Fix | Delete
} else {
[392] Fix | Delete
self::register_message('The existing htaccess file couldn\'t be updated. Please check file permissions.', 'error');
[393] Fix | Delete
}
[394] Fix | Delete
}
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
public function remove_index()
[398] Fix | Delete
{
[399] Fix | Delete
$i = 0;
[400] Fix | Delete
foreach (self::get_uploads_subdirectories() as $subDirectory) {
[401] Fix | Delete
if (file_exists($subDirectory . '/index.php')) {
[402] Fix | Delete
unlink($subDirectory . '/index.php');
[403] Fix | Delete
$i++;
[404] Fix | Delete
}
[405] Fix | Delete
}
[406] Fix | Delete
if ($i == count(self::get_uploads_subdirectories())) {
[407] Fix | Delete
self::register_message('The index.php file(s) have(has) been deleted.');
[408] Fix | Delete
}
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
public function remove_htaccess()
[412] Fix | Delete
{
[413] Fix | Delete
if (file_exists(self::get_uploads_dir() . '/.htaccess')) {
[414] Fix | Delete
[415] Fix | Delete
$htaccessContent = file_get_contents(self::get_uploads_dir() . '/.htaccess');
[416] Fix | Delete
$htaccessContent = preg_replace('/(# BEGIN protect-uploads Plugin)(.*?)(# END protect-uploads Plugin)/is', '', $htaccessContent);
[417] Fix | Delete
file_put_contents(self::get_uploads_dir() . '/.htaccess', $htaccessContent, LOCK_EX);
[418] Fix | Delete
[419] Fix | Delete
// if htaccess is empty, we remove it.
[420] Fix | Delete
if (strlen(preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "", file_get_contents(self::get_uploads_dir() . '/.htaccess'))) == 0) {
[421] Fix | Delete
unlink(self::get_uploads_dir() . '/.htaccess');
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
[425] Fix | Delete
//
[426] Fix | Delete
self::register_message('The htaccess file has been updated.');
[427] Fix | Delete
}
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
public function get_protective_files_array()
[431] Fix | Delete
{
[432] Fix | Delete
$uploads_files = ['index.php', 'index.html', '.htaccess'];
[433] Fix | Delete
$response = [];
[434] Fix | Delete
foreach ($uploads_files as $file) {
[435] Fix | Delete
if (file_exists(self::get_uploads_dir() . '/' . $file)) {
[436] Fix | Delete
$response[] = $file;
[437] Fix | Delete
}
[438] Fix | Delete
}
[439] Fix | Delete
return $response;
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
public function check_protective_file($file)
[443] Fix | Delete
{
[444] Fix | Delete
if (in_array($file, self::get_protective_files_array())) {
[445] Fix | Delete
return true;
[446] Fix | Delete
} else {
[447] Fix | Delete
return false;
[448] Fix | Delete
}
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
public function get_uploads_root_response_code()
[452] Fix | Delete
{
[453] Fix | Delete
$response = wp_remote_get( self::get_uploads_url() );
[454] Fix | Delete
$code = wp_remote_retrieve_response_code($response);
[455] Fix | Delete
return $code;
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
public function get_htaccess_content()
[459] Fix | Delete
{
[460] Fix | Delete
return file_get_contents(self::get_uploads_dir() . '/.htaccess');
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
public function check_htaccess_is_self_generated()
[464] Fix | Delete
{
[465] Fix | Delete
if (self::check_protective_file('.htaccess') && preg_match('/' . self::get_htaccess_identifier() . '/', self::get_htaccess_content())) {
[466] Fix | Delete
return true;
[467] Fix | Delete
} else {
[468] Fix | Delete
return false;
[469] Fix | Delete
}
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
// heart? <3
[473] Fix | Delete
public function check_uploads_is_protected()
[474] Fix | Delete
{
[475] Fix | Delete
foreach (self::get_protective_files_array() as $file) {
[476] Fix | Delete
if ($file === 'index.html') {
[477] Fix | Delete
return true;
[478] Fix | Delete
break;
[479] Fix | Delete
}
[480] Fix | Delete
if ($file === 'index.php') {
[481] Fix | Delete
return true;
[482] Fix | Delete
break;
[483] Fix | Delete
}
[484] Fix | Delete
if ($file === '.htaccess' && self::get_uploads_root_response_code() === 200) {
[485] Fix | Delete
return false;
[486] Fix | Delete
break;
[487] Fix | Delete
}
[488] Fix | Delete
}
[489] Fix | Delete
if (self::get_uploads_root_response_code() === 403) {
[490] Fix | Delete
return true;
[491] Fix | Delete
}
[492] Fix | Delete
else {
[493] Fix | Delete
return false;
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
public function check_protective_file_removable() {
[498] Fix | Delete
if( self::check_protective_file('index.html') ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function