'0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-includes' => '0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../.htaccess' => '0644', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'index.php' => '0644', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'js/' => '0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'themes' => '0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'plugins' => '0755', WP_CONTENT_DIR . DIRECTORY_SEPARATOR . '../wp-admin' => '0755', WP_CONTENT_DIR => '0755', ); } } // public static function fix_file_permissions_ok() // { // MainWP_Security::init_permission_checks(); // // $perms_issues = 0; // // foreach (MainWP_Security::$permission_checks as $dir => $needed_perms) // { // if (!file_exists($dir)) continue; // // $perms = substr(sprintf('%o', fileperms($dir)), -4); // if ($perms != $needed_perms) // { // $perms_issues++; // } // } // return ($perms_issues == 0); // } // public static function fix_file_permissions() // { // MainWP_Security::init_permission_checks(); // $success = true; // foreach (MainWP_Security::$permission_checks as $dir => $needed_perms) // { // if (!file_exists($dir)) continue; // $success == $success && chmod($dir, $needed_perms); // } // return $success; // } //Database error reporting turned on/off public static function remove_database_reporting_ok() { global $wpdb; return ( false === $wpdb->show_errors ); } public static function remove_database_reporting() { global $wpdb; $wpdb->hide_errors(); $wpdb->suppress_errors(); } //PHP error reporting turned on/off public static function remove_php_reporting_ok() { return ! ( ( ( 0 != ini_get( 'display_errors' ) ) && ( 'off' != ini_get( 'display_errors' ) ) ) || ( ( 0 != ini_get( 'display_startup_errors' ) ) && ( 'off' != ini_get( 'display_startup_errors' ) ) ) ); } public static function remove_php_reporting( $force = false ) { if ( $force || self::get_security_option( 'php_reporting' ) ) { @error_reporting( 0 ); @ini_set( 'display_errors', 'off' ); @ini_set( 'display_startup_errors', 0 ); } } //Removed version information for scripts/stylesheets public static function remove_scripts_version_ok() { return self::get_security_option( 'scripts_version' ); // global $wp_scripts; // if (!is_a($wp_scripts, 'WP_Scripts')) // { // return true; // } // foreach ($wp_scripts->registered as $handle => $script) // { // if ($wp_scripts->registered[$handle]->ver != null) // { // return false; // } // } // return true; } public static function remove_script_versions( $src ) { if ( self::get_security_option( 'scripts_version' ) ) { if ( strpos( $src, '?ver=' ) ) { $src = remove_query_arg( 'ver', $src ); } return $src; } // else if ( false === strpos( $src, '?ver=' ) ) { // self::update_security_option('scripts_version', true); // } return $src; } public static function remove_generator_version_ok() { return self::get_security_option( 'generator_version' ); } public static function remove_generator_version( $force = false ) { if ( $force || self::get_security_option( 'generator_version' ) ) { $types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' ); foreach ( $types as $type ) { add_filter( 'get_the_generator_' . $type, array( 'MainWP_Security', 'custom_the_generator' ), 10, 2 ); } } } public static function custom_the_generator( $generator, $type = '' ) { return ''; } public static function remove_theme_versions( $src ) { if ( self::get_security_option( 'styles_version' ) ) { if ( strpos( $src, '?ver=' ) ) { $src = remove_query_arg( 'ver', $src ); } return $src; } // else if ( false === strpos( $src, '?ver=' ) ) { // self::update_security_option('styles_version', true); // } return $src; } public static function remove_scripts_version( $force = false ) { if ( $force || self::get_security_option( 'scripts_version' ) ) { global $wp_scripts; if ( !( $wp_scripts instanceof WP_Scripts ) ) { return; } foreach ( $wp_scripts->registered as $handle => $script ) { $wp_scripts->registered[ $handle ]->ver = null; } } } public static function remove_readme( $force = false ) { if ( $force || self::get_security_option( 'readme' ) ) { if ( @file_exists( ABSPATH . 'readme.html' ) ) { if ( ! @unlink( ABSPATH . 'readme.html' ) ) { MainWP_Helper::getWPFilesystem(); global $wp_filesystem; if ( ! empty( $wp_filesystem ) ) { $wp_filesystem->delete( ABSPATH . 'readme.html' ); if ( @file_exists( ABSPATH . 'readme.html' ) ) { // prevent repeat delete self::update_security_option('readme', false); } } } } } } public static function remove_readme_ok() { return ! file_exists( ABSPATH . 'readme.html' ); } public static function remove_styles_version_ok() { return self::get_security_option( 'styles_version' ); // global $wp_styles; // if (!is_a($wp_styles, 'WP_Styles')) // { // return true; // } // // foreach ($wp_styles->registered as $handle => $style) // { // if ($wp_styles->registered[$handle]->ver != null) // { // return false; // } // } // return true; } public static function remove_styles_version( $force = true ) { if ( $force || self::get_security_option( 'styles_version' ) ) { global $wp_styles; if ( !( $wp_styles instanceof WP_Styles ) ) { return; } foreach ( $wp_styles->registered as $handle => $style ) { $wp_styles->registered[ $handle ]->ver = null; } } } //Admin user name is not admin public static function admin_user_ok() { $user = get_user_by( 'login', 'admin' ); if ( ! $user ) return true; if ( 10 !== $user->wp_user_level && ( ! isset( $user->user_level ) || 10 !== $user->user_level ) && ! user_can( $user, 'level_10' ) ) { return true; } return false; } public static function update_security_option( $key, $value ) { $security = get_option( 'mainwp_security' ); if ( !empty($key) ) $security[$key] = $value; MainWP_Helper::update_option( 'mainwp_security', $security, 'yes' ); } }