Merge pull request #140 from mainwp/bogdan01-cf-autofix

Apply fixes from CodeFactor
This commit is contained in:
Thang Hoang Van 2020-05-13 18:49:46 +07:00 committed by GitHub
commit 80ecd440d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 14 deletions

View file

@ -1448,7 +1448,7 @@ class MainWP_Child_Server_Information {
// we will always have a fragment of a non-complete line.
// keep this in here till we have our next entire line.
$leftover = '';
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom read file.
$fh = fopen( $path, 'r' );
// go to the end of the file.
@ -1487,9 +1487,9 @@ class MainWP_Child_Server_Information {
}
fclose( $fh );
// phpcs:enable
// Usually, we will read too many lines, correct that here.
return array_slice( $lines, 0, $line_count );
}

View file

@ -188,7 +188,7 @@ class MainWP_Child_Vulnerability_Checker {
public function vulnche_get_content( $url ) {
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
@ -202,7 +202,7 @@ class MainWP_Child_Vulnerability_Checker {
curl_close( $ch );
// phpcs:enable
if ( false === $output || 200 != $info ) {
$output = null;
}

View file

@ -623,7 +623,7 @@ class MainWP_Helper {
}
$postdata['json_result'] = true; // forced all response in json format.
// phpcs:disable WordPress.WP.AlternativeFunctions -- to custom.
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );

View file

@ -46,11 +46,11 @@ class MainWP_Security {
}
public static function prevent_listing_ok() {
global $wp_filesystem;
MainWP_Helper::get_wp_filesystem();
self::init_listing_directories();
self::init_listing_directories();
foreach ( self::$listingDirectories as $directory ) {
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
if ( ! $wp_filesystem->exists( $file ) ) {
@ -62,16 +62,16 @@ class MainWP_Security {
public static function prevent_listing() {
self::init_listing_directories();
global $wp_filesystem;
MainWP_Helper::get_wp_filesystem();
foreach ( self::$listingDirectories as $directory ) {
$file = $directory . DIRECTORY_SEPARATOR . 'index.php';
if ( ! $wp_filesystem->exists( $file ) ) {
$wp_filesystem->put_contents( $file, "<?php \n" );
$wp_filesystem->put_contents( $file, "header(\$_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden' );\n" );
$wp_filesystem->put_contents( $file, "die( '403 Forbidden' );\n" );
$wp_filesystem->put_contents( $file, "die( '403 Forbidden' );\n" );
}
}
}
@ -214,10 +214,10 @@ class MainWP_Security {
return true;
}
MainWP_Helper::get_wp_filesystem();
global $wp_filesystem;
global $wp_filesystem;
if ( $force || self::get_security_option( 'readme' ) ) {
if ( $wp_filesystem->exists( ABSPATH . 'readme.html' ) ) {
if ( ! unlink( ABSPATH . 'readme.html' ) ) {
if ( ! unlink( ABSPATH . 'readme.html' ) ) {
$wp_filesystem->delete( ABSPATH . 'readme.html' );
if ( $wp_filesystem->exists( ABSPATH . 'readme.html' ) ) {
// prevent repeat delete.