From 049dab6b5571dcddba94f835e1ecd4151ee0798e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogdan=20Rapai=C4=87?= Date: Thu, 23 Apr 2020 19:53:22 +0200 Subject: [PATCH] Fixed: CodeFactor issues --- class/class-mainwp-backup.php | 64 +++---- class/class-mainwp-child-back-up-buddy.php | 14 +- .../class-mainwp-child-back-up-wordpress.php | 8 +- class/class-mainwp-child-back-wp-up.php | 8 +- class/class-mainwp-child-branding.php | 6 +- .../class-mainwp-child-server-information.php | 12 +- class/class-mainwp-child-staging.php | 2 +- class/class-mainwp-child-timecapsule.php | 2 +- ...lass-mainwp-child-updraft-plus-backups.php | 48 ++--- class/class-mainwp-child-wordfence.php | 10 +- class/class-mainwp-child-wp-rocket.php | 2 +- class/class-mainwp-clone-install.php | 24 +-- class/class-mainwp-clone.php | 18 +- class/class-mainwp-helper.php | 40 ++--- class/class-mainwp-security.php | 12 +- class/class-mainwp-wordpress-seo.php | 8 +- class/class-tar-archiver.php | 168 +++++++++--------- 17 files changed, 223 insertions(+), 223 deletions(-) diff --git a/class/class-mainwp-backup.php b/class/class-mainwp-backup.php index c6475b4..aea002f 100644 --- a/class/class-mainwp-backup.php +++ b/class/class-mainwp-backup.php @@ -87,9 +87,9 @@ class MainWP_Backup { $this->timeout = 20 * 60 * 60; $mem = '512M'; // phpcs:disable - @ini_set( 'memory_limit', $mem ); - @set_time_limit( $this->timeout ); - @ini_set( 'max_execution_time', $this->timeout ); + ini_set( 'memory_limit', $mem ); + set_time_limit( $this->timeout ); + ini_set( 'max_execution_time', $this->timeout ); // phpcs:enable if ( null !== $this->archiver ) { @@ -113,9 +113,9 @@ class MainWP_Backup { $this->timeout = 20 * 60 * 60; $mem = '512M'; // phpcs:disable - @ini_set( 'memory_limit', $mem ); - @set_time_limit( $this->timeout ); - @ini_set( 'max_execution_time', $this->timeout ); + ini_set( 'memory_limit', $mem ); + set_time_limit( $this->timeout ); + ini_set( 'max_execution_time', $this->timeout ); // phpcs:enable if ( ! is_array( $files ) ) { @@ -276,9 +276,9 @@ class MainWP_Backup { $plugins = array(); $dir = WP_CONTENT_DIR . '/plugins/'; // phpcs:disable - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { - if ( ! @is_dir( $dir . $entry ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { + if ( ! is_dir( $dir . $entry ) ) { continue; } if ( ( '.' == $entry ) || ( '..' == $entry ) ) { @@ -286,15 +286,15 @@ class MainWP_Backup { } $plugins[] = $entry; } - @closedir( $fh ); + closedir( $fh ); // phpcs:enable $themes = array(); $dir = WP_CONTENT_DIR . '/themes/'; // phpcs:disable - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { - if ( ! @is_dir( $dir . $entry ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { + if ( ! is_dir( $dir . $entry ) ) { continue; } if ( ( '.' == $entry ) || ( '..' == $entry ) ) { @@ -302,7 +302,7 @@ class MainWP_Backup { } $themes[] = $entry; } - @closedir( $fh ); + closedir( $fh ); // phpcs:enable $string = base64_encode( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. @@ -324,7 +324,7 @@ class MainWP_Backup { $return = $this->zip->close(); foreach ( $db_files as $db_file ) { - @unlink( $db_file ); + unlink( $db_file ); } return true; @@ -394,7 +394,7 @@ class MainWP_Backup { } foreach ( $db_files as $db_file ) { - @unlink( $db_file ); + unlink( $db_file ); } if ( ! $error ) { foreach ( $nodes as $node ) { @@ -433,7 +433,7 @@ class MainWP_Backup { } if ( $error ) { - @unlink( $filepath ); // phpcs:ignore + unlink( $filepath ); // phpcs:ignore return false; } @@ -456,7 +456,7 @@ class MainWP_Backup { if ( ! MainWP_Helper::inExcludes( $excludes, str_replace( ABSPATH, '', $node ) ) ) { if ( is_dir( $node ) ) { if ( ! file_exists( str_replace( ABSPATH, $backupfolder, $node ) ) ) { - @mkdir( str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore + mkdir( str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore } $newnodes = glob( $node . DIRECTORY_SEPARATOR . '*' ); @@ -467,7 +467,7 @@ class MainWP_Backup { continue; } - @copy( $node, str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore + copy( $node, str_replace( ABSPATH, $backupfolder, $node ) ); // phpcs:ignore } } } @@ -477,7 +477,7 @@ class MainWP_Backup { // Create backup folder. $backupFolder = dirname( $filepath ) . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR; - @mkdir( $backupFolder ); // phpcs:ignore + mkdir( $backupFolder ); // phpcs:ignore // Create DB backup. $db_files = $this->createBackupDB( $backupFolder . 'dbBackup' ); @@ -526,8 +526,8 @@ class MainWP_Backup { $this->copy_dir( $nodes, $excludes, $backupFolder, $excludenonwp, true ); foreach ( $db_files as $db_file ) { - @copy( $db_file, $backupFolder . basename( WP_CONTENT_DIR ) . '/' . basename( $db_file ) ); // phpcs:ignore - @unlink( $db_file ); // phpcs:ignore + copy( $db_file, $backupFolder . basename( WP_CONTENT_DIR ) . '/' . basename( $db_file ) ); // phpcs:ignore + unlink( $db_file ); // phpcs:ignore } unset( $nodes ); @@ -649,7 +649,7 @@ class MainWP_Backup { public function addFileToZip( $path, $zipEntryName ) { if ( time() - $this->lastRun > 20 ) { - @set_time_limit( $this->timeout ); // phpcs:ignore + set_time_limit( $this->timeout ); // phpcs:ignore $this->lastRun = time(); } @@ -675,10 +675,10 @@ class MainWP_Backup { if ( $this->gcCnt > 20 ) { if ( function_exists( 'gc_enable' ) ) { - @gc_enable(); // phpcs:ignore + gc_enable(); } if ( function_exists( 'gc_collect_cycles' ) ) { - @gc_collect_cycles(); // phpcs:ignore + gc_collect_cycles(); } $this->gcCnt = 0; } @@ -688,10 +688,10 @@ class MainWP_Backup { $this->zip = null; unset( $this->zip ); if ( function_exists( 'gc_enable' ) ) { - @gc_enable(); // phpcs:ignore + gc_enable(); } if ( function_exists( 'gc_collect_cycles' ) ) { - @gc_collect_cycles(); // phpcs:ignore + gc_collect_cycles(); } $this->zip = new ZipArchive(); $this->zip->open( $this->zipArchiveFileName ); @@ -708,10 +708,10 @@ class MainWP_Backup { public function createBackupDB( $filepath_prefix, $archiveExt = false, &$archiver = null ) { $timeout = 20 * 60 * 60; - @set_time_limit( $timeout ); // phpcs:ignore - @ini_set( 'max_execution_time', $timeout ); // phpcs:ignore + set_time_limit( $timeout ); + ini_set( 'max_execution_time', $timeout ); $mem = '512M'; - @ini_set( 'memory_limit', $mem ); // phpcs:ignore + ini_set( 'memory_limit', $mem ); /** @var $wpdb wpdb */ global $wpdb; @@ -736,7 +736,7 @@ class MainWP_Backup { $table_create = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); fwrite( $fh, "\n" . $table_create[1] . ";\n\n" ); - $rows = @MainWP_Child_DB::_query( 'SELECT * FROM ' . $table, $wpdb->dbh ); // phpcs:ignore + $rows = MainWP_Child_DB::_query( 'SELECT * FROM ' . $table, $wpdb->dbh ); if ( $rows ) { $i = 0; @@ -788,7 +788,7 @@ class MainWP_Backup { if ( $this->zipFile( $db_files, $archivefilePath ) && file_exists( $archivefilePath ) ) { foreach ( $db_files as $db_file ) { - @unlink( $db_file ); + unlink( $db_file ); } } else { // todo: throw exception! diff --git a/class/class-mainwp-child-back-up-buddy.php b/class/class-mainwp-child-back-up-buddy.php index 2c9de3c..580c5e4 100644 --- a/class/class-mainwp-child-back-up-buddy.php +++ b/class/class-mainwp-child-back-up-buddy.php @@ -709,7 +709,7 @@ class MainWP_Child_Back_Up_Buddy { $deleted_files = array(); foreach ( $item_ids as $item ) { if ( file_exists( backupbuddy_core::getBackupDirectory() . $item ) ) { - if ( @unlink( backupbuddy_core::getBackupDirectory() . $item ) === true ) { + if ( unlink( backupbuddy_core::getBackupDirectory() . $item ) === true ) { $deleted_files[] = $item; // Cleanup any related fileoptions files. @@ -723,10 +723,10 @@ class MainWP_Child_Back_Up_Buddy { $this_serial = backupbuddy_core::get_serial_from_file( $item ); $fileoptions_file = backupbuddy_core::getLogDirectory() . 'fileoptions/' . $this_serial . '.txt'; if ( file_exists( $fileoptions_file ) ) { - @unlink( $fileoptions_file ); + unlink( $fileoptions_file ); } if ( file_exists( $fileoptions_file . '.lock' ) ) { - @unlink( $fileoptions_file . '.lock' ); + unlink( $fileoptions_file . '.lock' ); } $needs_save = true; } @@ -1784,7 +1784,7 @@ class MainWP_Child_Back_Up_Buddy { if ( '1' == pb_backupbuddy::$options['lock_archives_directory'] ) { if ( file_exists( backupbuddy_core::getBackupDirectory() . '.htaccess' ) ) { - $unlink_status = @unlink( backupbuddy_core::getBackupDirectory() . '.htaccess' ); + $unlink_status = unlink( backupbuddy_core::getBackupDirectory() . '.htaccess' ); if ( false === $unlink_status ) { die( 'Error #844594. Unable to temporarily remove .htaccess security protection on archives directory to allow downloading. Please verify permissions of the BackupBuddy archives directory or manually download via FTP.' ); } @@ -1795,7 +1795,7 @@ class MainWP_Child_Back_Up_Buddy { flush(); sleep( 8 ); - $htaccess_creation_status = @file_put_contents( backupbuddy_core::getBackupDirectory() . '.htaccess', 'deny from all' ); + $htaccess_creation_status = file_put_contents( backupbuddy_core::getBackupDirectory() . '.htaccess', 'deny from all' ); if ( false === $htaccess_creation_status ) { die( 'Error #344894545. Security Warning! Unable to create security file (.htaccess) in backups archive directory. This file prevents unauthorized downloading of backups should someone be able to guess the backup location and filenames. This is unlikely but for best security should be in place. Please verify permissions on the backups directory.' ); } @@ -2059,7 +2059,7 @@ class MainWP_Child_Back_Up_Buddy { } elseif ( 'reset_log' == $other_action ) { $log_file = backupbuddy_core::getLogDirectory() . 'log-' . pb_backupbuddy::$options['log_serial'] . '.txt'; if ( file_exists( $log_file ) ) { - @unlink( $log_file ); + unlink( $log_file ); } if ( file_exists( $log_file ) ) { // Didnt unlink. $error = 'Unable to clear log file. Please verify permissions on file `' . $log_file . '`.'; @@ -2624,7 +2624,7 @@ class MainWP_Child_Back_Up_Buddy { if ( 'clear_log' == $action ) { $sumLogFile = backupbuddy_core::getLogDirectory() . 'status-live_periodic_' . pb_backupbuddy::$options['log_serial'] . '.txt'; - @unlink( $sumLogFile ); + unlink( $sumLogFile ); if ( file_exists( $sumLogFile ) ) { $error = 'Error #893489322: Unable to clear log file `' . $sumLogFile . '`. Check permissions or manually delete.'; } else { diff --git a/class/class-mainwp-child-back-up-wordpress.php b/class/class-mainwp-child-back-up-wordpress.php index 0f1f086..558f6e0 100644 --- a/class/class-mainwp-child-back-up-wordpress.php +++ b/class/class-mainwp-child-back-up-wordpress.php @@ -222,7 +222,7 @@ class MainWP_Child_Back_Up_Wordpress { $message = 'BackupWordpres backup ' . $backup_type . ' finished'; $destination = 'N/A'; if ( file_exists( $file ) ) { - $date = @filemtime( $file ); + $date = filemtime( $file ); if ( ! empty( $date ) ) { do_action( 'mainwp_reports_backupwordpress_backup', $destination, $message, 'finished', $backup_type, $date ); MainWP_Helper::update_lasttime_backup( 'backupwordpress', $date ); // to support backup before update feature. @@ -494,10 +494,10 @@ class MainWP_Child_Back_Up_Wordpress { ?> - + - + @@ -696,7 +696,7 @@ class MainWP_Child_Back_Up_Wordpress { } } // Skip unreadable files. - if ( ! @realpath( $file->getPathname() ) || ! $file->isReadable() ) { + if ( ! realpath( $file->getPathname() ) || ! $file->isReadable() ) { $is_unreadable = true; } ?> diff --git a/class/class-mainwp-child-back-wp-up.php b/class/class-mainwp-child-back-wp-up.php index a78a426..3c73e62 100644 --- a/class/class-mainwp-child-back-wp-up.php +++ b/class/class-mainwp-child-back-wp-up.php @@ -509,7 +509,7 @@ class MainWP_Child_Back_WP_Up { echo '' . __( 'PHP Memory limit', 'mainwp-child' ) . '' . esc_html( ini_get( 'memory_limit' ) ) . ''; echo '' . __( 'WP memory limit', 'mainwp-child' ) . '' . esc_html( WP_MEMORY_LIMIT ) . ''; echo '' . __( 'WP maximum memory limit', 'mainwp-child' ) . '' . esc_html( WP_MAX_MEMORY_LIMIT ) . ''; - echo '' . __( 'Memory in use', 'mainwp-child' ) . '' . esc_html( size_format( @memory_get_usage( true ), 2 ) ) . ''; + echo '' . __( 'Memory in use', 'mainwp-child' ) . '' . esc_html( size_format( memory_get_usage( true ), 2 ) ) . ''; $disabled = ini_get( 'disable_functions' ); if ( ! empty( $disabled ) ) { @@ -1159,7 +1159,7 @@ class MainWP_Child_Back_WP_Up { $main_folder_name = untrailingslashit( str_replace( '\\', '/', $main_folder_name ) ); $main_folder_size = '(' . size_format( BackWPup_File::get_folder_size( $main_folder_name, false ), 2 ) . ')'; - $dir = @opendir( $main_folder_name ); + $dir = opendir( $main_folder_name ); if ( $dir ) { while ( false !== ( $file = readdir( $dir ) ) ) { if ( ! in_array( $file, array( '.', '..' ) ) && is_dir( $main_folder_name . '/' . $file ) && ! in_array( trailingslashit( $main_folder_name . '/' . $file ), mainwp_backwpup_get_exclude_dirs( $main_folder_name ) ) ) { @@ -1172,7 +1172,7 @@ class MainWP_Child_Back_WP_Up { } } - @closedir( $dir ); + closedir( $dir ); } $return[ $key ] = array( @@ -1197,7 +1197,7 @@ class MainWP_Child_Back_WP_Up { $settings = $_POST['settings']; if ( ! empty( $settings['dbhost'] ) && ! empty( $settings['dbuser'] ) ) { - $mysqli = @new mysqli( $settings['dbhost'], $settings['dbuser'], ( isset( $settings['dbpassword'] ) ? $settings['dbpassword'] : '' ) ); + $mysqli = new mysqli( $settings['dbhost'], $settings['dbuser'], ( isset( $settings['dbpassword'] ) ? $settings['dbpassword'] : '' ) ); if ( $mysqli->connect_error ) { $return['message'] = $mysqli->connect_error; diff --git a/class/class-mainwp-child-branding.php b/class/class-mainwp-child-branding.php index 6af46d7..36cebb1 100644 --- a/class/class-mainwp-child-branding.php +++ b/class/class-mainwp-child-branding.php @@ -253,7 +253,7 @@ class MainWP_Child_Branding { if ( isset( $current_extra_setting['login_image']['path'] ) ) { $old_file = $current_extra_setting['login_image']['path']; if ( ! empty( $old_file ) && file_exists( $old_file ) ) { - @unlink( $old_file ); + unlink( $old_file ); } } } @@ -279,7 +279,7 @@ class MainWP_Child_Branding { if ( isset( $current_extra_setting['favico_image']['path'] ) ) { $old_file = $current_extra_setting['favico_image']['path']; if ( ! empty( $old_file ) && file_exists( $old_file ) ) { - @unlink( $old_file ); + unlink( $old_file ); } } } @@ -325,7 +325,7 @@ class MainWP_Child_Branding { $local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); $local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) ); $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); - $moved = @rename( $temporary_file, $local_img_path ); + $moved = rename( $temporary_file, $local_img_path ); if ( $moved ) { return array( 'path' => $local_img_path, diff --git a/class/class-mainwp-child-server-information.php b/class/class-mainwp-child-server-information.php index e13ef79..7e3bbfb 100644 --- a/class/class-mainwp-child-server-information.php +++ b/class/class-mainwp-child-server-information.php @@ -1097,8 +1097,8 @@ class MainWP_Child_Server_Information { $conf = array( 'private_key_bits' => 2048 ); $str = ''; if ( function_exists( 'openssl_pkey_new' ) ) { - $res = @openssl_pkey_new( $conf ); - @openssl_pkey_export( $res, $privkey ); + $res = openssl_pkey_new( $conf ); + openssl_pkey_export( $res, $privkey ); $str = openssl_error_string(); } @@ -1537,15 +1537,15 @@ class MainWP_Child_Server_Information {

-
+
false, diff --git a/class/class-mainwp-child-timecapsule.php b/class/class-mainwp-child-timecapsule.php index dcf299c..893ee7f 100644 --- a/class/class-mainwp-child-timecapsule.php +++ b/class/class-mainwp-child-timecapsule.php @@ -1181,7 +1181,7 @@ class MainWP_Child_Timecapsule { echo '' . __( 'PHP Memory limit', 'wp-time-capsule' ) . '' . esc_html( ini_get( 'memory_limit' ) ) . ''; echo '' . __( 'WP memory limit', 'wp-time-capsule' ) . '' . esc_html( WP_MEMORY_LIMIT ) . ''; echo '' . __( 'WP maximum memory limit', 'wp-time-capsule' ) . '' . esc_html( WP_MAX_MEMORY_LIMIT ) . ''; - echo '' . __( 'Memory in use', 'wp-time-capsule' ) . '' . size_format( @memory_get_usage( true ), 2 ) . ''; + echo '' . __( 'Memory in use', 'wp-time-capsule' ) . '' . size_format( memory_get_usage( true ), 2 ) . ''; // disabled PHP functions. $disabled = esc_html( ini_get( 'disable_functions' ) ); diff --git a/class/class-mainwp-child-updraft-plus-backups.php b/class/class-mainwp-child-updraft-plus-backups.php index 3b01f02..403ad12 100644 --- a/class/class-mainwp-child-updraft-plus-backups.php +++ b/class/class-mainwp-child-updraft-plus-backups.php @@ -1271,7 +1271,7 @@ class MainWP_Child_Updraft_Plus_Backups { } foreach ( $files as $file ) { if ( is_file( $updraft_dir . '/' . $file ) ) { - if ( @unlink( $updraft_dir . '/' . $file ) ) { + if ( unlink( $updraft_dir . '/' . $file ) ) { $local_deleted ++; } } @@ -1379,7 +1379,7 @@ class MainWP_Child_Updraft_Plus_Backups { public function updraft_download_backup() { - @set_time_limit( 900 ); + set_time_limit( 900 ); global $updraftplus; @@ -1442,7 +1442,7 @@ class MainWP_Child_Updraft_Plus_Backups { } if ( isset( $_POST['stage'] ) && 'delete' == $_POST['stage'] ) { - @unlink( $fullpath ); + unlink( $fullpath ); $updraftplus->log( 'The file has been deleted' ); return 'deleted'; @@ -1502,8 +1502,8 @@ class MainWP_Child_Updraft_Plus_Backups { $is_downloaded = true; } else { clearstatcache(); - if ( 0 === @filesize( $fullpath ) ) { - @unlink( $fullpath ); + if ( 0 === filesize( $fullpath ) ) { + unlink( $fullpath ); } $updraftplus->log( 'Remote fetch failed' ); } @@ -1525,9 +1525,9 @@ class MainWP_Child_Updraft_Plus_Backups { restore_error_handler(); - @fclose( $updraftplus->logfile_handle ); + fclose( $updraftplus->logfile_handle ); if ( ! $debug_mode ) { - @unlink( $updraftplus->logfile_name ); + unlink( $updraftplus->logfile_name ); } return array( 'result' => 'OK' ); @@ -1538,7 +1538,7 @@ class MainWP_Child_Updraft_Plus_Backups { global $updraftplus; - @set_time_limit( 900 ); + set_time_limit( 900 ); $updraftplus->log( "Requested file from remote service: $service: $file" ); @@ -1604,8 +1604,8 @@ class MainWP_Child_Updraft_Plus_Backups { $warn = array(); $err = array(); - @set_time_limit( 900 ); - $max_execution_time = (int) @ini_get( 'max_execution_time' ); + set_time_limit( 900 ); + $max_execution_time = (int) ini_get( 'max_execution_time' ); if ( $max_execution_time > 0 && $max_execution_time < 61 ) { $warn[] = sprintf( __( 'The PHP setup on this webserver allows only %s seconds for PHP to run, and does not allow this limit to be raised. If you have a lot of data to import, and if the restore operation times out, then you will need to ask your web hosting company for ways to raise this limit (or attempt the restoration piece-by-piece).', 'updraftplus' ), $max_execution_time ); @@ -1784,7 +1784,7 @@ class MainWP_Child_Updraft_Plus_Backups { // not used. private function restore_backup( $timestamp ) { - @set_time_limit( 900 ); + set_time_limit( 900 ); global $wp_filesystem, $updraftplus; $backup_history = UpdraftPlus_Backup_History::get_history(); @@ -1963,7 +1963,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( isset( $backup_history[ $timestamp ][ $type . $index . '-size' ] ) ) { $fs = $backup_history[ $timestamp ][ $type . $index . '-size' ]; echo esc_html__( 'Archive is expected to be size:', 'updraftplus' ) . ' ' . esc_html( round( $fs / 1024, 1 ) ) . ' Kb: '; - $as = @filesize( $fullpath ); + $as = filesize( $fullpath ); if ( $as === $fs ) { echo esc_html__( 'OK', 'updraftplus' ) . '
'; } else { @@ -2372,7 +2372,7 @@ class MainWP_Child_Updraft_Plus_Backups { $migration_warning = false; // Don't set too high - we want a timely response returned to the browser. - @set_time_limit( 90 ); + set_time_limit( 90 ); $count_wanted_tables = count( $wanted_tables ); @@ -2466,9 +2466,9 @@ class MainWP_Child_Updraft_Plus_Backups { } if ( $is_plain ) { - @fclose( $dbhandle ); + fclose( $dbhandle ); } else { - @gzclose( $dbhandle ); + gzclose( $dbhandle ); } $missing_tables = array(); @@ -2583,7 +2583,7 @@ class MainWP_Child_Updraft_Plus_Backups { $default_dbscan_timeout = ( filesize( $db_file ) < 31457280 ) ? 120 : 240; $dbscan_timeout = ( defined( 'UPDRAFTPLUS_DBSCAN_TIMEOUT' ) && is_numeric( UPDRAFTPLUS_DBSCAN_TIMEOUT ) ) ? UPDRAFTPLUS_DBSCAN_TIMEOUT : $default_dbscan_timeout; - @set_time_limit( $dbscan_timeout ); + set_time_limit( $dbscan_timeout ); // We limit the time that we spend scanning the file for character sets. $db_charset_collate_scan_timeout = ( defined( 'UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT' ) && is_numeric( UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT ) ) ? UPDRAFTPLUS_DB_CHARSET_COLLATE_SCAN_TIMEOUT : 10; @@ -2765,9 +2765,9 @@ class MainWP_Child_Updraft_Plus_Backups { } } if ( $is_plain ) { - @fclose( $dbhandle ); + fclose( $dbhandle ); } else { - @gzclose( $dbhandle ); + gzclose( $dbhandle ); } if ( ! empty( $db_supported_character_sets ) ) { $db_charsets_found_unique = array_unique( $db_charsets_found ); @@ -2936,7 +2936,7 @@ class MainWP_Child_Updraft_Plus_Backups { if ( 0 === gzseek( $dbhandle, 0 ) ) { return $dbhandle; } else { - @gzclose( $dbhandle ); + gzclose( $dbhandle ); return gzopen( $file, 'r' ); } @@ -2950,15 +2950,15 @@ class MainWP_Child_Updraft_Plus_Backups { $fnew = fopen( $file . '.tmp', 'w' ); if ( false === ( $fnew ) || ! is_resource( $fnew ) ) { - @gzclose( $dbhandle ); + gzclose( $dbhandle ); $err_msg = __( 'The attempt to undo the double-compression failed.', 'updraftplus' ); } else { - @fwrite( $fnew, $bytes ); + fwrite( $fnew, $bytes ); $emptimes = 0; while ( ! gzeof( $dbhandle ) ) { - $bytes = @gzread( $dbhandle, 131072 ); + $bytes = gzread( $dbhandle, 131072 ); if ( empty( $bytes ) ) { global $updraftplus; $emptimes ++; @@ -2967,7 +2967,7 @@ class MainWP_Child_Updraft_Plus_Backups { break; } } else { - @fwrite( $fnew, $bytes ); + fwrite( $fnew, $bytes ); } } @@ -3406,7 +3406,7 @@ ENDHERE; foreach ( $directories as $dir ) { if ( is_file( $dir ) ) { - $size += @filesize( $dir ); + $size += filesize( $dir ); } else { $suffix = ( '' !== $basedir ) ? ( ( 0 === strpos( $dir, $basedir . '/' ) ) ? substr( $dir, 1 + strlen( $basedir ) ) : '' ) : ''; $size += $this->recursive_directory_size_raw( $basedir, $exclude, $suffix ); diff --git a/class/class-mainwp-child-wordfence.php b/class/class-mainwp-child-wordfence.php index d955d30..399df99 100644 --- a/class/class-mainwp-child-wordfence.php +++ b/class/class-mainwp-child-wordfence.php @@ -921,7 +921,7 @@ class MainWP_Child_Wordfence { continue; } if ( 'del' === $op ) { - if ( @unlink( $localFile ) ) { + if ( unlink( $localFile ) ) { $issues->updateIssue( $id, 'delete' ); $filesWorkedOn ++; } else { @@ -1014,7 +1014,7 @@ class MainWP_Child_Wordfence { if ( strpos( $localFile, ABSPATH ) !== 0 ) { return array( 'errorMsg' => 'An invalid file was requested for deletion.' ); } - if ( @unlink( $localFile ) ) { + if ( unlink( $localFile ) ) { $wfIssues->updateIssue( $issueID, 'delete' ); return array( @@ -1560,7 +1560,7 @@ class MainWP_Child_Wordfence { $res = $api->call( 'import_options', array(), array( 'token' => $token ) ); if ( $res['ok'] && $res['export'] ) { $totalSet = 0; - $import = @json_decode( $res['export'], true ); + $import = json_decode( $res['export'], true ); if ( ! is_array( $import ) ) { return array( 'errorImport' => __( 'An error occurred: Invalid options format received.', 'wordfence' ) ); } @@ -2118,7 +2118,7 @@ class MainWP_Child_Wordfence { 'code' => wfCache::getHtaccessCode(), ); } - $fh = @fopen( $file, 'r+' ); + $fh = fopen( $file, 'r+' ); if ( ! $fh ) { $err = error_get_last(); return array( @@ -2141,7 +2141,7 @@ class MainWP_Child_Wordfence { if ( ! $file ) { return array( 'err' => 'We could not find your .htaccess file to modify it.' ); } - $fh = @fopen( $file, 'r+' ); + $fh = fopen( $file, 'r+' ); if ( ! $fh ) { $err = error_get_last(); return array( 'err' => 'We found your .htaccess file but could not open it for writing: ' . $err['message'] ); diff --git a/class/class-mainwp-child-wp-rocket.php b/class/class-mainwp-child-wp-rocket.php index 206bb41..6a3da08 100644 --- a/class/class-mainwp-child-wp-rocket.php +++ b/class/class-mainwp-child-wp-rocket.php @@ -286,7 +286,7 @@ class MainWP_Child_WP_Rocket { public function do_admin_post_rocket_purge_opcache() { if ( function_exists( 'opcache_reset' ) ) { - @opcache_reset(); + opcache_reset(); } else { return array( 'error' => 'The host do not support the function reset opcache.' ); } diff --git a/class/class-mainwp-clone-install.php b/class/class-mainwp-clone-install.php index 0b00206..d2dd418 100644 --- a/class/class-mainwp-clone-install.php +++ b/class/class-mainwp-clone-install.php @@ -150,12 +150,12 @@ class MainWP_Clone_Install { } public function testDatabase() { - $link = @MainWP_Child_DB::connect( $this->config['dbHost'], $this->config['dbUser'], $this->config['dbPass'] ); + $link = MainWP_Child_DB::connect( $this->config['dbHost'], $this->config['dbUser'], $this->config['dbPass'] ); if ( ! $link ) { throw new Exception( __( 'Invalid database host or user/password.', 'mainwp-child' ) ); } - $db_selected = @MainWP_Child_DB::select_db( $this->config['dbName'], $link ); + $db_selected = MainWP_Child_DB::select_db( $this->config['dbName'], $link ); if ( ! $db_selected ) { throw new Exception( __( 'Invalid database name.', 'mainwp-child' ) ); } @@ -164,13 +164,13 @@ class MainWP_Clone_Install { public function clean() { $files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' ); foreach ( $files as $file ) { - @unlink( $file ); + unlink( $file ); } if ( file_exists( ABSPATH . 'clone/config.txt' ) ) { - @unlink( ABSPATH . 'clone/config.txt' ); + unlink( ABSPATH . 'clone/config.txt' ); } if ( MainWP_Helper::is_dir_empty( ABSPATH . 'clone' ) ) { - @rmdir( ABSPATH . 'clone' ); + rmdir( ABSPATH . 'clone' ); } try { @@ -180,7 +180,7 @@ class MainWP_Clone_Install { $files = glob( $backupdir . '*' ); foreach ( $files as $file ) { if ( MainWP_Helper::isArchive( $file ) ) { - @unlink( $file ); + unlink( $file ); } } } catch ( Exception $e ) { @@ -225,14 +225,14 @@ class MainWP_Clone_Install { $files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' ); foreach ( $files as $file ) { - $handle = @fopen( $file, 'r' ); + $handle = fopen( $file, 'r' ); $lastRun = 0; if ( $handle ) { $readline = ''; while ( ( $line = fgets( $handle, 81920 ) ) !== false ) { if ( time() - $lastRun > 20 ) { - @set_time_limit( 0 ); // reset timer.. + set_time_limit( 0 ); // reset timer.. $lastRun = time(); } @@ -350,7 +350,7 @@ class MainWP_Clone_Install { // Clean up! $files = glob( '../dbBackup*.sql' ); foreach ( $files as $file ) { - @unlink( $file ); + unlink( $file ); } } @@ -434,7 +434,7 @@ class MainWP_Clone_Install { $zip = new ZipArchive(); $zipRes = $zip->open( $this->file ); if ( $zipRes ) { - @$zip->extractTo( ABSPATH ); + $zip->extractTo( ABSPATH ); $zip->close(); return true; @@ -643,7 +643,7 @@ class MainWP_Clone_Install { // some unseriliased data cannot be re-serialised eg. SimpleXMLElements. try { - $unserialized = @unserialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. + $unserialized = unserialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. if ( is_string( $data ) && is_serialized( $data ) && ! is_serialized_string( $data ) && false !== $unserialized ) { $data = $this->recursive_unserialize_replace( $from, $to, $unserialized, true ); } elseif ( is_array( $data ) ) { @@ -663,7 +663,7 @@ class MainWP_Clone_Install { $data = $_tmp; unset( $_tmp ); } elseif ( is_serialized_string( $data ) && is_serialized( $data ) ) { - $data = @unserialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. + $data = unserialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. if ( false !== $data ) { $data = str_replace( $from, $to, $data ); $data = serialize( $data ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. diff --git a/class/class-mainwp-clone.php b/class/class-mainwp-clone.php index 8cb5ea6..5d8ac73 100644 --- a/class/class-mainwp-clone.php +++ b/class/class-mainwp-clone.php @@ -1161,7 +1161,7 @@ class MainWP_Clone { if ( ! $result['backup'] ) { throw new Exception( __( 'Could not create backupfile on child', 'mainwp-child' ) ); } - @session_start(); + session_start(); MainWP_Helper::update_option( 'mainwp_temp_clone_plugins', $result['plugins'] ); MainWP_Helper::update_option( 'mainwp_temp_clone_themes', $result['themes'] ); @@ -1257,7 +1257,7 @@ class MainWP_Clone { $file = readdir( $dh ); while ( false !== $file ) { if ( '.' !== $file && '..' !== $file && MainWP_Helper::isArchive( $file, 'download-' ) ) { - @unlink( $backupdir . $file ); + unlink( $backupdir . $file ); } } closedir( $dh ); @@ -1427,8 +1427,8 @@ class MainWP_Clone { $out = array(); if ( is_array( $plugins ) ) { $dir = WP_CONTENT_DIR . '/plugins/'; - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { if ( ! is_dir( $dir . $entry ) ) { continue; } @@ -1439,7 +1439,7 @@ class MainWP_Clone { MainWP_Helper::delete_dir( $dir . $entry ); } } - @closedir( $fh ); + closedir( $fh ); } delete_option( 'mainwp_temp_clone_plugins' ); @@ -1448,8 +1448,8 @@ class MainWP_Clone { $out = array(); if ( is_array( $themes ) ) { $dir = WP_CONTENT_DIR . '/themes/'; - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { if ( ! is_dir( $dir . $entry ) ) { continue; } @@ -1460,7 +1460,7 @@ class MainWP_Clone { MainWP_Helper::delete_dir( $dir . $entry ); } } - @closedir( $fh ); + closedir( $fh ); } delete_option( 'mainwp_temp_clone_themes' ); } @@ -1515,7 +1515,7 @@ class MainWP_Clone { public static function renderRestore() { if ( '' === session_id() ) { - @session_start(); + session_start(); } $file = null; $size = null; diff --git a/class/class-mainwp-helper.php b/class/class-mainwp-helper.php index 1f99b8e..10fe1b0 100644 --- a/class/class-mainwp-helper.php +++ b/class/class-mainwp-helper.php @@ -68,9 +68,9 @@ class MainWP_Helper { } public static function safe_json_encode( $value, $options = 0, $depth = 512 ) { - $encoded = @json_encode( $value, $options, $depth ); + $encoded = json_encode( $value, $options, $depth ); if ( false === $encoded && ! empty( $value ) && JSON_ERROR_UTF8 == json_last_error() ) { - $encoded = @json_encode( self::json_valid_check( $value ), $options, $depth ); + $encoded = json_encode( self::json_valid_check( $value ), $options, $depth ); } return $encoded; } @@ -262,7 +262,7 @@ class MainWP_Helper { $local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path ); } - $moved = @rename( $temporary_file, $local_img_path ); + $moved = rename( $temporary_file, $local_img_path ); if ( $moved ) { $wp_filetype = wp_check_filetype( basename( $img_url ), null ); // Get the filetype to set the mimetype. @@ -331,22 +331,22 @@ class MainWP_Helper { ); if ( is_wp_error( $response ) ) { - @unlink( $full_file_name ); + unlink( $full_file_name ); throw new Exception( 'Error: ' . $response->get_error_message() ); } if ( 200 !== (int) wp_remote_retrieve_response_code( $response ) ) { - @unlink( $full_file_name ); + unlink( $full_file_name ); throw new Exception( 'Error 404: ' . trim( wp_remote_retrieve_response_message( $response ) ) ); } if ( '.phpfile.txt' === substr( $file_name, - 12 ) ) { $new_file_name = substr( $file_name, 0, - 12 ) . '.php'; $new_file_name = $path . DIRECTORY_SEPARATOR . $new_file_name; - $moved = @rename( $full_file_name, $new_file_name ); + $moved = rename( $full_file_name, $new_file_name ); if ( $moved ) { return array( 'path' => $new_file_name ); } else { - @unlink( $full_file_name ); + unlink( $full_file_name ); throw new Exception( 'Error: Copy file.' ); } } @@ -877,7 +877,7 @@ class MainWP_Helper { $dir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'mainwp' . DIRECTORY_SEPARATOR; self::checkDir( $dir, $dieOnError ); if ( ! file_exists( $dir . 'index.php' ) ) { - @touch( $dir . 'index.php' ); + touch( $dir . 'index.php' ); } $url = $upload_dir['baseurl'] . '/mainwp/'; @@ -885,14 +885,14 @@ class MainWP_Helper { $dir .= 'backup' . DIRECTORY_SEPARATOR; self::checkDir( $dir, $dieOnError ); if ( ! file_exists( $dir . 'index.php' ) ) { - @touch( $dir . 'index.php' ); + touch( $dir . 'index.php' ); } $another_name = '.htaccess'; if ( ! file_exists( $dir . $another_name ) ) { - $file = @fopen( $dir . $another_name, 'w+' ); - @fwrite( $file, 'deny from all' ); - @fclose( $file ); + $file = fopen( $dir . $another_name, 'w+' ); + fwrite( $file, 'deny from all' ); + fclose( $file ); } $url .= 'backup/'; } @@ -905,7 +905,7 @@ class MainWP_Helper { global $wp_filesystem; if ( ! file_exists( $dir ) ) { if ( empty( $wp_filesystem ) ) { - @mkdir( $dir, $chmod, true ); + mkdir( $dir, $chmod, true ); } else { if ( ( 'ftpext' === $wp_filesystem->method ) && defined( 'FTP_BASE' ) ) { $ftpBase = FTP_BASE; @@ -948,7 +948,7 @@ class MainWP_Helper { if ( ! $done ) { if ( ! file_exists( $dir ) ) { - @mkdirs( $dir ); + mkdirs( $dir ); } if ( is_writable( $dir ) ) { $done = true; @@ -1061,8 +1061,8 @@ class MainWP_Helper { } public static function endSession() { - @session_write_close(); - @ob_end_flush(); + session_write_close(); + ob_end_flush(); } public static function fetchUrl( $url, $postdata ) { @@ -1151,7 +1151,7 @@ class MainWP_Helper { $size = array( 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ); $factor = floor( ( strlen( $bytes ) - 1 ) / 3 ); - return sprintf( "%.{$decimals}f", $bytes / pow( 1024, $factor ) ) . @$size[ $factor ]; + return sprintf( "%.{$decimals}f", $bytes / pow( 1024, $factor ) ) . $size[ $factor ]; } public static function is_dir_empty( $dir ) { @@ -1170,11 +1170,11 @@ class MainWP_Helper { if ( is_dir( $node ) ) { self::delete_dir( $node . DIRECTORY_SEPARATOR ); } else { - @unlink( $node ); + unlink( $node ); } } } - @rmdir( $dir ); + rmdir( $dir ); } public static function function_exists( $func ) { @@ -1183,7 +1183,7 @@ class MainWP_Helper { } if ( extension_loaded( 'suhosin' ) ) { - $suhosin = @ini_get( 'suhosin.executor.func.blacklist' ); + $suhosin = ini_get( 'suhosin.executor.func.blacklist' ); if ( ! empty( $suhosin ) ) { $suhosin = explode( ',', $suhosin ); $suhosin = array_map( 'trim', $suhosin ); diff --git a/class/class-mainwp-security.php b/class/class-mainwp-security.php index df76f3d..979f6d1 100644 --- a/class/class-mainwp-security.php +++ b/class/class-mainwp-security.php @@ -137,9 +137,9 @@ class MainWP_Security { 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 ); + error_reporting( 0 ); + ini_set( 'display_errors', 'off' ); + ini_set( 'display_startup_errors', 0 ); } } @@ -216,13 +216,13 @@ class MainWP_Security { } if ( $force || self::get_security_option( 'readme' ) ) { - if ( @file_exists( ABSPATH . 'readme.html' ) ) { - if ( ! @unlink( ABSPATH . 'readme.html' ) ) { + 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' ) ) { + if ( file_exists( ABSPATH . 'readme.html' ) ) { // prevent repeat delete. self::update_security_option( 'readme', false ); } diff --git a/class/class-mainwp-wordpress-seo.php b/class/class-mainwp-wordpress-seo.php index 5ff9a1b..94b98df 100644 --- a/class/class-mainwp-wordpress-seo.php +++ b/class/class-mainwp-wordpress-seo.php @@ -121,7 +121,7 @@ class MainWP_Wordpress_SEO { $unzipped = unzip_file( $file, $p_path ); if ( ! is_wp_error( $unzipped ) ) { $filename = $p_path . 'settings.ini'; - if ( @is_file( $filename ) && is_readable( $filename ) ) { + if ( is_file( $filename ) && is_readable( $filename ) ) { $options = parse_ini_file( $filename, true ); if ( is_array( $options ) && array() !== $options ) { @@ -147,13 +147,13 @@ class MainWP_Wordpress_SEO { } else { throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) ); } - @unlink( $filename ); - @unlink( $p_path ); + unlink( $filename ); + unlink( $p_path ); } else { throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . sprintf( __( 'Unzipping failed with error "%s".', 'mainwp-child' ), $unzipped->get_error_message() ) ); } unset( $zip, $unzipped ); - @unlink( $file ); + unlink( $file ); } else { throw new Exception( __( 'Settings could not be imported:', 'mainwp-child' ) . ' ' . __( 'Upload failed.', 'mainwp-child' ) ); } diff --git a/class/class-tar-archiver.php b/class/class-tar-archiver.php index 28e6fbd..f401204 100644 --- a/class/class-tar-archiver.php +++ b/class/class-tar-archiver.php @@ -131,7 +131,7 @@ class Tar_Archiver { $this->archivePath = $filepath; - if ( $append && @file_exists( $filepath ) ) { + if ( $append && file_exists( $filepath ) ) { $this->mode = self::APPEND; $this->prepareAppend( $filepath ); } else { @@ -211,9 +211,9 @@ class Tar_Archiver { global $wpdb; $plugins = array(); $dir = WP_CONTENT_DIR . '/plugins/'; - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { - if ( ! @is_dir( $dir . $entry ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { + if ( ! is_dir( $dir . $entry ) ) { continue; } if ( ( '.' === $entry ) || ( '..' === $entry ) ) { @@ -221,13 +221,13 @@ class Tar_Archiver { } $plugins[] = $entry; } - @closedir( $fh ); + closedir( $fh ); $themes = array(); $dir = WP_CONTENT_DIR . '/themes/'; - $fh = @opendir( $dir ); - while ( $entry = @readdir( $fh ) ) { - if ( ! @is_dir( $dir . $entry ) ) { + $fh = opendir( $dir ); + while ( $entry = readdir( $fh ) ) { + if ( ! is_dir( $dir . $entry ) ) { continue; } if ( ( '.' == $entry ) || ( '..' == $entry ) ) { @@ -235,7 +235,7 @@ class Tar_Archiver { } $themes[] = $entry; } - @closedir( $fh ); + closedir( $fh ); $string = base64_encode( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons. serialize( // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions. @@ -258,7 +258,7 @@ class Tar_Archiver { $this->addData( pack( 'a1024', '' ) ); $this->close(); foreach ( $db_files as $db_file ) { - @unlink( $db_file ); + unlink( $db_file ); } $this->completePidFile(); @@ -320,18 +320,18 @@ class Tar_Archiver { } if ( 'tar.gz' == $this->type ) { - if ( false === @gzwrite( $this->archive, $data, strlen( $data ) ) ) { + if ( false === gzwrite( $this->archive, $data, strlen( $data ) ) ) { throw new Exception( 'Could not write to archive' ); } } elseif ( 'tar.bz2' == $this->type ) { - if ( false === @bzwrite( $this->archive, $data, strlen( $data ) ) ) { + if ( false === bzwrite( $this->archive, $data, strlen( $data ) ) ) { throw new Exception( 'Could not write to archive' ); } } else { - if ( false === @fwrite( $this->archive, $data, strlen( $data ) ) ) { + if ( false === fwrite( $this->archive, $data, strlen( $data ) ) ) { throw new Exception( 'Could not write to archive' ); } - @fflush( $this->archive ); + fflush( $this->archive ); } } @@ -344,26 +344,26 @@ class Tar_Archiver { if ( 'tar.gz' == $this->type ) { $this->log( 'writing & flushing ' . $len ); $this->chunk = gzencode( $this->chunk ); - if ( false === @fwrite( $this->archive, $this->chunk, strlen( $this->chunk ) ) ) { + if ( false === fwrite( $this->archive, $this->chunk, strlen( $this->chunk ) ) ) { throw new Exception( 'Could not write to archive' ); } - @fflush( $this->archive ); + fflush( $this->archive ); } elseif ( 'tar.bz2' == $this->type ) { - if ( false === @bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) { + if ( false === bzwrite( $this->archive, $this->chunk, strlen( $len ) ) ) { throw new Exception( 'Could not write to archive' ); } } else { - if ( false === @fwrite( $this->archive, $len, strlen( $len ) ) ) { + if ( false === fwrite( $this->archive, $len, strlen( $len ) ) ) { throw new Exception( 'Could not write to archive' ); } - @fflush( $this->archive ); + fflush( $this->archive ); } $this->chunk = ''; } private function addEmptyDir( $path, $entryName ) { - $stat = @stat( $path ); + $stat = stat( $path ); $this->addEmptyDirectory( $entryName, $stat['mode'], $stat['uid'], $stat['gid'], $stat['mtime'] ); } @@ -479,23 +479,23 @@ class Tar_Archiver { } if ( time() - $this->lastRun > 60 ) { - @set_time_limit( 20 * 60 * 60 ); + set_time_limit( 20 * 60 * 60 ); $this->lastRun = time(); } $this->gcCnt ++; if ( $this->gcCnt > 20 ) { if ( function_exists( 'gc_enable' ) ) { - @gc_enable(); + gc_enable(); } if ( function_exists( 'gc_collect_cycles' ) ) { - @gc_collect_cycles(); + gc_collect_cycles(); } $this->gcCnt = 0; } - $stat = @stat( $path ); - $fp = @fopen( $path, 'rb' ); + $stat = stat( $path ); + $fp = fopen( $path, 'rb' ); if ( ! $fp ) { return; } @@ -579,7 +579,7 @@ class Tar_Archiver { } if ( isset( $rslt['bytesRead'] ) ) { - @fseek( $fp, $rslt['bytesRead'] ); + fseek( $fp, $rslt['bytesRead'] ); $alreadyRead = ( $rslt['bytesRead'] % 512 ); $toRead = 512 - $alreadyRead; @@ -611,7 +611,7 @@ class Tar_Archiver { $this->updatePidFile(); } - @fclose( $fp ); + fclose( $fp ); return true; } @@ -719,8 +719,8 @@ class Tar_Archiver { if ( is_array( $rslt ) ) { if ( 'tar' == $this->type ) { $startOffset = $rslt['startOffset']; - @fseek( $this->archive, $startOffset ); - @ftruncate( $this->archive, $startOffset ); + fseek( $this->archive, $startOffset ); + ftruncate( $this->archive, $startOffset ); } elseif ( 'tar.gz' == $this->type ) { $readOffset = $rslt['readOffset']; $bytesRead = $rslt['bytesRead']; @@ -729,11 +729,11 @@ class Tar_Archiver { } } elseif ( false === $rslt ) { if ( 'tar' == $this->type ) { - @fseek( $this->archive, 0, SEEK_END ); + fseek( $this->archive, 0, SEEK_END ); } } else { - @fseek( $this->archive, $rslt ); - @ftruncate( $this->archive, $rslt ); + fseek( $this->archive, $rslt ); + ftruncate( $this->archive, $rslt ); } $this->mode = self::CREATE; @@ -754,10 +754,10 @@ class Tar_Archiver { * @throws Exception */ private function isNextFile( $entryName ) { - $currentOffset = @ftell( $this->archive ); + $currentOffset = ftell( $this->archive ); $rslt = array( 'startOffset' => $currentOffset ); try { - $block = @fread( $this->archive, 512 ); + $block = fread( $this->archive, 512 ); if ( false === $block || 0 == strlen( $block ) ) { return $rslt; @@ -769,8 +769,8 @@ class Tar_Archiver { $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); if ( 'L' == $temp['type'] ) { - $fname = trim( @fread( $this->archive, 512 ) ); - $block = @fread( $this->archive, 512 ); + $fname = trim( fread( $this->archive, 512 ) ); + $block = fread( $this->archive, 512 ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp['prefix'] = ''; $temp['name'] = $fname; @@ -799,15 +799,15 @@ class Tar_Archiver { } } elseif ( 0 == $file['type'] ) { if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) { - $previousFtell = @ftell( $this->archive ); + $previousFtell = ftell( $this->archive ); $bytes = $file['stat'][7] + ( 512 == ( 512 - $file['stat'][7] % 512 ) ? 0 : ( 512 - $file['stat'][7] % 512 ) ); - @fseek( $this->archive, @ftell( $this->archive ) + $bytes ); + fseek( $this->archive, ftell( $this->archive ) + $bytes ); - $ftell = @ftell( $this->archive ); + $ftell = ftell( $this->archive ); if ( 'tar.gz' == $this->type ) { if ( ( false === $ftell ) || ( -1 == $ftell ) ) { - @fseek( $this->archive, $previousFtell ); + fseek( $this->archive, $previousFtell ); $bytesRead = 0; $bytesToRead = $file['stat'][7]; @@ -864,7 +864,7 @@ class Tar_Archiver { public function log( $text ) { if ( $this->logHandle ) { - @fwrite( $this->logHandle, $text . "\n" ); + fwrite( $this->logHandle, $text . "\n" ); } } @@ -872,20 +872,20 @@ class Tar_Archiver { $this->log( 'Creating ' . $filepath ); if ( $this->debug ) { if ( 'tar.bz2' == $this->type ) { - $this->archive = @bzopen( $filepath, 'w' ); + $this->archive = bzopen( $filepath, 'w' ); } else { - $this->archive = @fopen( $filepath, 'wb+' ); + $this->archive = fopen( $filepath, 'wb+' ); } return; } if ( 'tar.gz' == $this->type ) { - $this->archive = @gzopen( $filepath, 'wb' ); + $this->archive = gzopen( $filepath, 'wb' ); } elseif ( 'tar.bz2' == $this->type ) { - $this->archive = @bzopen( $filepath, 'w' ); + $this->archive = bzopen( $filepath, 'w' ); } else { - $this->archive = @fopen( $filepath, 'wb+' ); + $this->archive = fopen( $filepath, 'wb+' ); } } @@ -893,20 +893,20 @@ class Tar_Archiver { $this->log( 'Appending to ' . $filepath ); if ( $this->debug ) { if ( 'tar.bz2' == $this->type ) { - $this->archive = @bzopen( $filepath, 'a' ); + $this->archive = bzopen( $filepath, 'a' ); } else { - $this->archive = @fopen( $filepath, 'ab+' ); + $this->archive = fopen( $filepath, 'ab+' ); } return; } if ( 'tar.gz' == $this->type ) { - $this->archive = @gzopen( $filepath, 'ab' ); + $this->archive = gzopen( $filepath, 'ab' ); } elseif ( 'tar.bz2' == $this->type ) { - $this->archive = @bzopen( $filepath, 'a' ); + $this->archive = bzopen( $filepath, 'a' ); } else { - $this->archive = @fopen( $filepath, 'ab+' ); + $this->archive = fopen( $filepath, 'ab+' ); } } @@ -918,7 +918,7 @@ class Tar_Archiver { if ( $this->debug ) { if ( 'tar.gz' == substr( $filepath, - 6 ) ) { $text = chr( 31 ) . chr( 139 ) . chr( 8 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ) . chr( 0 ); - $fh = @fopen( $filepath, 'rb' ); + $fh = fopen( $filepath, 'rb' ); $read = ''; $lastCorrect = 0; try { @@ -942,13 +942,13 @@ class Tar_Archiver { throw new Exception( 'invalid!' ); } - @fclose( $fh ); + fclose( $fh ); } catch ( Exception $e ) { - @fclose( $fh ); - $fh = @fopen( $filepath, 'ab+' ); - @fseek( $fh, $lastCorrect ); - @ftruncate( $fh, $lastCorrect ); - @fclose( $fh ); + fclose( $fh ); + $fh = fopen( $filepath, 'ab+' ); + fseek( $fh, $lastCorrect ); + ftruncate( $fh, $lastCorrect ); + fclose( $fh ); } } } @@ -962,20 +962,20 @@ class Tar_Archiver { if ( 'tar.gz' == substr( $filepath, - 6 ) ) { $this->type = 'tar.gz'; - $this->archive = @gzopen( $filepath, 'r' ); + $this->archive = gzopen( $filepath, 'r' ); } elseif ( 'tar.bz2' == substr( $filepath, - 7 ) ) { $this->type = 'tar.bz2'; - $this->archive = @bzopen( $filepath, 'r' ); + $this->archive = bzopen( $filepath, 'r' ); } else { - $currentPos = @ftell( $this->archive ); - @fseek( $this->archive, 0, SEEK_END ); - $lastPos = @ftell( $this->archive ); - @fseek( $this->archive, $currentPos ); + $currentPos = ftell( $this->archive ); + fseek( $this->archive, 0, SEEK_END ); + $lastPos = ftell( $this->archive ); + fseek( $this->archive, $currentPos ); $this->archiveSize = $lastPos; $this->type = 'tar'; - $this->archive = @fopen( $filepath, 'rb' ); + $this->archive = fopen( $filepath, 'rb' ); } } @@ -984,16 +984,16 @@ class Tar_Archiver { $this->log( 'Closing archive' ); if ( $closeLog && $this->logHandle ) { - @fclose( $this->logHandle ); + fclose( $this->logHandle ); } if ( $this->archive ) { if ( 'tar.gz' == $this->type ) { - @gzclose( $this->archive ); + gzclose( $this->archive ); } elseif ( 'tar.bz2' == $this->type ) { - @bzclose( $this->archive ); + bzclose( $this->archive ); } else { - @fclose( $this->archive ); + fclose( $this->archive ); } } } @@ -1006,12 +1006,12 @@ class Tar_Archiver { return false; } $content = false; - @fseek( $this->archive, 0 ); - while ( $block = @fread( $this->archive, 512 ) ) { + fseek( $this->archive, 0 ); + while ( $block = fread( $this->archive, 512 ) ) { $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); if ( 'L' == $temp['type'] ) { - $fname = trim( @fread( $this->archive, 512 ) ); - $block = @fread( $this->archive, 512 ); + $fname = trim( fread( $this->archive, 512 ) ); + $block = fread( $this->archive, 512 ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp['prefix'] = ''; $temp['name'] = $fname; @@ -1052,7 +1052,7 @@ class Tar_Archiver { break; } else { $bytes = $file['stat'][7] + ( ( 512 - $file['stat'][7] % 512 ) == 512 ? 0 : ( 512 - $file['stat'][7] % 512 ) ); - @fseek( $this->archive, ftell( $this->archive ) + $bytes ); + fseek( $this->archive, ftell( $this->archive ) + $bytes ); } } @@ -1070,12 +1070,12 @@ class Tar_Archiver { if ( empty( $entryName ) ) { return false; } - @fseek( $this->archive, 0 ); - while ( $block = @fread( $this->archive, 512 ) ) { + fseek( $this->archive, 0 ); + while ( $block = fread( $this->archive, 512 ) ) { $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); if ( 'L' == $temp['type'] ) { - $fname = trim( @fread( $this->archive, 512 ) ); - $block = @fread( $this->archive, 512 ); + $fname = trim( fread( $this->archive, 512 ) ); + $block = fread( $this->archive, 512 ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp['prefix'] = ''; $temp['name'] = $fname; @@ -1115,7 +1115,7 @@ class Tar_Archiver { return true; } else { $bytes = $file['stat'][7] + ( ( 512 - $file['stat'][7] % 512 ) == 512 ? 0 : ( 512 - $file['stat'][7] % 512 ) ); - @fseek( $this->archive, ftell( $this->archive ) + $bytes ); + fseek( $this->archive, ftell( $this->archive ) + $bytes ); } } @@ -1130,12 +1130,12 @@ class Tar_Archiver { global $wp_filesystem; $to = trailingslashit( $to ); - @fseek( $this->archive, 0 ); + fseek( $this->archive, 0 ); while ( $block = fread( $this->archive, 512 ) ) { $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); if ( 'L' == $temp['type'] ) { - $fname = trim( @fread( $this->archive, 512 ) ); - $block = @fread( $this->archive, 512 ); + $fname = trim( fread( $this->archive, 512 ) ); + $block = fread( $this->archive, 512 ); $temp = unpack( 'a100name/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100symlink/a6magic/a2temp/a32temp/a32temp/a8temp/a8temp/a155prefix/a12temp', $block ); $temp['prefix'] = ''; $temp['name'] = $fname; @@ -1200,7 +1200,7 @@ class Tar_Archiver { } } else { if ( 'wp-config.php' != $file['name'] ) { - $new = @fopen( $to . $file['name'], 'wb+' ); + $new = fopen( $to . $file['name'], 'wb+' ); } else { $new = false; } @@ -1231,7 +1231,7 @@ class Tar_Archiver { } public function isValidBlock( $block ) { - $test = @gzinflate( $block ); + $test = gzinflate( $block ); if ( false === $test ) { return false; }