=> 'no',
'sanitize_type' => array('sanitize_title', 'strtolower'),
'processing_order' => 55
);
$this->module_settings[] = array(
'id' => 'block_default_wp_register_php',
'label' => __('Block wp-register.php', 'wp-hide-security-enhancer'),
'description' => __('Block default wp-register.php file.', 'wp-hide-security-enhancer'),
'help' => array(
'title' => __('Help', 'wp-hide-security-enhancer') . ' - ' . __('Block wp-register.php', 'wp-hide-security-enhancer'),
'description' => __("This is a deprecated file but still present in many WordPress installs. When called the user is redirected to /register page. Is safe to block the wp-register.php.", 'wp-hide-security-enhancer'),
'option_documentation_url' => 'https://www.wp-hide.com/documentation/rewrite-root-files/'
),
'input_type' => 'radio',
'options' => array(
'no' => __('No', 'wp-hide-security-enhancer'),
'yes' => __('Yes', 'wp-hide-security-enhancer'),
),
'default_value' => 'no',
'sanitize_type' => array('sanitize_title', 'strtolower'),
'processing_order' => 55
);
$this->module_settings[] = array(
'id' => 'block_other_wp_files',
'label' => __('Block other wp-*.php files', 'wp-hide-security-enhancer'),
'description' => __('Block other wp-*.php files in the root.', 'wp-hide-security-enhancer'),
'help' => array(
'title' => __('Help', 'wp-hide-security-enhancer') . ' - ' . __('Block other wp-*.php files', 'wp-hide-security-enhancer'),
'description' => __("Block other wp-*.php files. E.g. wp-blog-header.php, wp-config.php, wp-cron.php. Those files are used internally, blocking those will not affect any functionality. Other root files (wp-activate.php, wp-login.php, wp-signup.php) are ignored, they can be controlled through own setting.", 'wp-hide-security-enhancer'),
'option_documentation_url' => 'https://www.wp-hide.com/documentation/rewrite-root-files/'
),
'input_type' => 'radio',
'options' => array(
'no' => __('No', 'wp-hide-security-enhancer'),
'yes' => __('Yes', 'wp-hide-security-enhancer'),
),
'default_value' => 'no',
'sanitize_type' => array('sanitize_title', 'strtolower'),
'processing_order' => 55
);
return $this->module_settings;
}
function _callback_saved_block_license_txt($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return FALSE;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'license.txt', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_readme_html($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return FALSE;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'readme.html', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_wp_activate_php($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return FALSE;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-activate.php', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_wp_cron_php($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return FALSE;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-cron.php', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
$local_ip = $this->domain_get_ip();
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
if ( $local_ip !== FALSE )
{
$text .= "RewriteCond %{REMOTE_ADDR} !^". str_replace(".",'\.', $local_ip ) ."$\n";
}
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
{
$text = '
';
if ( $local_ip !== FALSE )
{
$text .= '
';
}
$text .= '
';
}
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_default_wp_signup_php($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return $processing_response;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-signup.php', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_default_wp_register_php( $saved_field_data )
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return $processing_response;
$rewrite_base = $this->wph->functions->get_rewrite_base( 'wp-register.php', FALSE, FALSE );
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteRule ^" . $rewrite_base ." ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
function _callback_saved_block_other_wp_files($saved_field_data)
{
$processing_response = array();
if(empty($saved_field_data) || $saved_field_data == 'no')
return $processing_response;
$rewrite_conditional = $this->wph->functions->get_rewrite_base( '', FALSE );
$rewrite_base = $this->wph->functions->get_rewrite_base( '', FALSE);
$rewrite_to = $this->wph->functions->get_rewrite_to_base( 'index.php', TRUE, FALSE, 'site_path' );
$text = '';
if($this->wph->server_htaccess_config === TRUE)
{
$text = "RewriteCond %{ENV:REDIRECT_STATUS} ^$\n";
$text .= "RewriteCond %{REQUEST_FILENAME} -f\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-activate.php [NC]\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-cron.php [NC]\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-signup.php [NC]\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-register.php [NC]\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-comments-post.php [NC]\n";
$text .= "RewriteCond %{REQUEST_FILENAME} !".$rewrite_conditional."wp-login.php [NC]\n";
$text .= "RewriteRule ^" . $rewrite_base . "wp-([a-z-])+.php ". $rewrite_to ."?wph-throw-404 [L]";
}
if($this->wph->server_web_config === TRUE)
$text = '
';
$processing_response['rewrite'] = $text;
return $processing_response;
}
/**
* Return curent domain reversed ip
*
*/
function domain_get_ip()
{
$local_ip = FALSE;
$site_domain_parsed = parse_url( home_url() );
if ( $site_domain_parsed !== FALSE && function_exists('gethostbyname') && function_exists('ip2long') )
{
$site_domain_is_ip = ip2long( $site_domain_parsed['host'] ) === FALSE ? FALSE : TRUE;
$local_ip = gethostbyname( $site_domain_parsed['host'] );
if ( $site_domain_is_ip === FALSE && $local_ip == $site_domain_parsed['host'] )
$local_ip = FALSE;
}
return $local_ip;
}
}
?>