• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP AIOWPSecurity_Utility_File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中AIOWPSecurity_Utility_File的典型用法代码示例。如果您正苦于以下问题:PHP AIOWPSecurity_Utility_File类的具体用法?PHP AIOWPSecurity_Utility_File怎么用?PHP AIOWPSecurity_Utility_File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AIOWPSecurity_Utility_File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: write_to_htaccess

 /**
  * Write all active rules to .htaccess file.
  *
  * @return boolean True on success, false on failure.
  */
 static function write_to_htaccess()
 {
     global $aio_wp_security;
     //figure out what server is being used
     if (AIOWPSecurity_Utility::get_server_type() == -1) {
         $aio_wp_security->debug_logger->log_debug("Unable to write to .htaccess - server type not supported!", 4);
         return false;
         //unable to write to the file
     }
     //clean up old rules first
     if (AIOWPSecurity_Utility_Htaccess::delete_from_htaccess() == -1) {
         $aio_wp_security->debug_logger->log_debug("Delete operation of .htaccess file failed!", 4);
         return false;
         //unable to write to the file
     }
     $htaccess = ABSPATH . '.htaccess';
     if (!($f = @fopen($htaccess, 'a+'))) {
         @chmod($htaccess, 0644);
         if (!($f = @fopen($htaccess, 'a+'))) {
             $aio_wp_security->debug_logger->log_debug("chmod operation on .htaccess failed!", 4);
             return false;
         }
     }
     AIOWPSecurity_Utility_File::backup_and_rename_htaccess($htaccess);
     //TODO - we dont want to continually be backing up the htaccess file
     @ini_set('auto_detect_line_endings', true);
     $ht = explode(PHP_EOL, implode('', file($htaccess)));
     //parse each line of file into array
     $rules = AIOWPSecurity_Utility_Htaccess::getrules();
     $rulesarray = explode(PHP_EOL, $rules);
     $rulesarray = apply_filters('aiowps_htaccess_rules_before_writing', $rulesarray);
     $contents = array_merge($rulesarray, $ht);
     if (!($f = @fopen($htaccess, 'w+'))) {
         $aio_wp_security->debug_logger->log_debug("Write operation on .htaccess failed!", 4);
         return false;
         //we can't write to the file
     }
     $blank = false;
     //write each line to file
     foreach ($contents as $insertline) {
         if (trim($insertline) == '') {
             if ($blank == false) {
                 fwrite($f, PHP_EOL . trim($insertline));
             }
             $blank = true;
         } else {
             $blank = false;
             fwrite($f, PHP_EOL . trim($insertline));
         }
     }
     @fclose($f);
     return true;
     //success
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:59,代码来源:wp-security-utility-htaccess.php


示例2: run_deactivation_tasks

 static function run_deactivation_tasks()
 {
     global $wpdb;
     if (function_exists('is_multisite') && is_multisite()) {
         // check if it is a network activation - if so, run the activation function for each blog id
         if (isset($_GET['networkwide']) && $_GET['networkwide'] == 1) {
             $old_blog = $wpdb->blogid;
             // Get all blog ids
             $blogids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
             foreach ($blogids as $blog_id) {
                 switch_to_blog($blog_id);
             }
             switch_to_blog($old_blog);
             return;
         }
     }
     //Let's backup .htaccess contents when AIOWPS was active
     $ht_file = ABSPATH . '.htaccess';
     $key_desc_ht_backup = 'aiowps_htaccess_backup';
     //This will be the key to decribe the entry we are inserting into the global_meta table
     AIOWPSecurity_Utility_File::backup_file_contents_to_db($ht_file, $key_desc_ht_backup);
     //Store the original htaccess contents in our global_meta table (ie, before AIOWPS was active)
     //Let's backup wp_config.php contents
     $wp_config_file = ABSPATH . 'wp-config.php';
     $key_desc_wp_config_backup = 'aiowps_wp_config_php_backup';
     //This will be the key to decribe the entry we are inserting into the global_meta table
     AIOWPSecurity_Utility_File::backup_file_contents_to_db($wp_config_file, $key_desc_wp_config_backup);
     //Store the original htaccess contents in our global_meta table (ie, before AIOWPS was active)
     //Restore original contents of .htaccess file upon deactivation
     $htaccess_file_contents = AIOWPSecurity_Deactivation::get_original_file_contents('original_htaccess_backup');
     if ($htaccess_file_contents) {
         if (file_put_contents($ht_file, $htaccess_file_contents) === false) {
             //File write failed
             $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Deactivation::run_deactivation_tasks() - Failed to write to .htaccess file", 4);
         }
     }
     //Restore original contents of wp-config.php file upon deactivation
     $wp_config_file_contents = AIOWPSecurity_Deactivation::get_original_file_contents('original_wp_config_php_backup');
     if ($wp_config_file_contents) {
         if (file_put_contents($wp_config_file, $wp_config_file_contents) === false) {
             //File write failed
             $aio_wp_security->debug_logger->log_debug("AIOWPSecurity_Deactivation::run_deactivation_tasks() - Failed to write to wp-config.php file", 4);
         }
     }
 }
开发者ID:roycocup,项目名称:enclothed,代码行数:45,代码来源:wp-security-deactivation-tasks.php


示例3: recursive_file_search

 static function recursive_file_search($pattern = '*', $flags = 0, $path = '')
 {
     $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
     if ($paths === FALSE) {
         return FALSE;
     }
     $files = glob($path . $pattern, $flags);
     if ($files === FALSE) {
         return FALSE;
     }
     foreach ($paths as $path) {
         $files = array_merge($files, AIOWPSecurity_Utility_File::recursive_file_search($pattern, $flags, $path));
     }
     return $files;
 }
开发者ID:roycocup,项目名称:enclothed,代码行数:15,代码来源:wp-security-utility-file.php


示例4: do_other_admin_side_init_tasks

 function do_other_admin_side_init_tasks()
 {
     global $aio_wp_security;
     //***New Feature improvement for Cookie Based Brute Force Protection***//
     //The old "test cookie" used to be too easy to guess because someone could just read the code and get the value.
     //So now we will drop a more secure test cookie using a 10 digit random string
     if ($aio_wp_security->configs->get_value('aiowps_enable_brute_force_attack_prevention') == '1') {
         // This code is for users who had this feature saved using an older release. This will drop the new more secure test cookie to the browser and will write it to the .htaccess file too
         $test_cookie = $aio_wp_security->configs->get_value('aiowps_cookie_brute_test');
         if (empty($test_cookie)) {
             $random_suffix = AIOWPSecurity_Utility::generate_alpha_numeric_random_string(10);
             $test_cookie_name = 'aiowps_cookie_test_' . $random_suffix;
             $aio_wp_security->configs->set_value('aiowps_cookie_brute_test', $test_cookie_name);
             $aio_wp_security->configs->save_config();
             //save the value
             AIOWPSecurity_Utility::set_cookie_value($test_cookie_name, "1");
             //Write this new cookie to the .htaccess file
             $res = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
             if ($res == -1) {
                 $aio_wp_security->debug_logger->log_debug("Error writing new test cookie with random suffix to .htaccess file!", 4);
             }
         }
     }
     //For cookie test form submission case
     if (isset($_GET['page']) && $_GET['page'] == AIOWPSEC_BRUTE_FORCE_MENU_SLUG && isset($_GET['tab']) && $_GET['tab'] == 'tab2') {
         global $aio_wp_security;
         if (isset($_POST['aiowps_do_cookie_test_for_bfla'])) {
             $random_suffix = AIOWPSecurity_Utility::generate_alpha_numeric_random_string(10);
             $test_cookie_name = 'aiowps_cookie_test_' . $random_suffix;
             $aio_wp_security->configs->set_value('aiowps_cookie_brute_test', $test_cookie_name);
             $aio_wp_security->configs->save_config();
             //save the value
             AIOWPSecurity_Utility::set_cookie_value($test_cookie_name, "1");
             $cur_url = "admin.php?page=" . AIOWPSEC_BRUTE_FORCE_MENU_SLUG . "&tab=tab2";
             $redirect_url = AIOWPSecurity_Utility::add_query_data_to_url($cur_url, 'aiowps_cookie_test', "1");
             AIOWPSecurity_Utility::redirect_to_url($redirect_url);
         }
         if (isset($_POST['aiowps_enable_brute_force_attack_prevention'])) {
             $brute_force_feature_secret_word = sanitize_text_field($_POST['aiowps_brute_force_secret_word']);
             if (empty($brute_force_feature_secret_word)) {
                 $brute_force_feature_secret_word = "aiowps_secret";
             }
             AIOWPSecurity_Utility::set_cookie_value($brute_force_feature_secret_word, "1");
         }
         if (isset($_REQUEST['aiowps_cookie_test'])) {
             $test_cookie = $aio_wp_security->configs->get_value('aiowps_cookie_brute_test');
             $cookie_val = AIOWPSecurity_Utility::get_cookie_value($test_cookie);
             if (empty($cookie_val)) {
                 $aio_wp_security->configs->set_value('aiowps_cookie_test_success', '');
             } else {
                 $aio_wp_security->configs->set_value('aiowps_cookie_test_success', '1');
             }
             $aio_wp_security->configs->save_config();
             //save the value
         }
     }
     if (isset($_POST['aiowps_save_wp_config'])) {
         $nonce = $_REQUEST['_wpnonce'];
         if (!wp_verify_nonce($nonce, 'aiowpsec-save-wp-config-nonce')) {
             $aio_wp_security->debug_logger->log_debug("Nonce check failed on wp_config file save!", 4);
             die("Nonce check failed on wp_config file save!");
         }
         $wp_config_path = AIOWPSecurity_Utility_File::get_wp_config_file_path();
         $result = AIOWPSecurity_Utility_File::backup_and_rename_wp_config($wp_config_path);
         //Backup the wp_config.php file
         AIOWPSecurity_Utility_File::download_a_file_option1($wp_config_path, "wp-config-backup.txt");
     }
     //Handle export settings
     if (isset($_POST['aiowps_export_settings'])) {
         $nonce = $_REQUEST['_wpnonce'];
         if (!wp_verify_nonce($nonce, 'aiowpsec-export-settings-nonce')) {
             $aio_wp_security->debug_logger->log_debug("Nonce check failed on export AIOWPS settings!", 4);
             die("Nonce check failed on export AIOWPS settings!");
         }
         $config_data = get_option('aio_wp_security_configs');
         $output = json_encode($config_data);
         AIOWPSecurity_Utility_File::download_content_to_a_file($output);
     }
 }
开发者ID:Bakerpedia,项目名称:Development_Site5,代码行数:79,代码来源:wp-security-admin-init.php


示例5: change_db_prefix

 function change_db_prefix($table_old_prefix, $table_new_prefix)
 {
     global $wpdb, $aio_wp_security;
     $old_prefix_length = strlen($table_old_prefix);
     $error = 0;
     //Config file path
     $config_file = AIOWPSecurity_Utility_File::get_wp_config_file_path();
     //Get the table resource
     //$result = mysql_list_tables(DB_NAME);
     $result = $this->get_mysql_tables(DB_NAME);
     //Fix for deprecated php mysql_list_tables function
     //Count the number of tables
     if (is_array($result) && count($result) > 0) {
         $num_rows = count($result);
     } else {
         echo '<div class="aio_red_box"><p>' . __('Error - Could not get tables or no tables found!', 'all-in-one-wp-security-and-firewall') . '</p></div>';
         return;
     }
     $table_count = 0;
     $info_msg_string = '<p class="aio_info_with_icon">' . __('Starting DB prefix change operations.....', 'all-in-one-wp-security-and-firewall') . '</p>';
     $info_msg_string .= '<p class="aio_info_with_icon">' . sprintf(__('Your WordPress system has a total of %s tables and your new DB prefix will be: %s', 'all-in-one-wp-security-and-firewall'), '<strong>' . $num_rows . '</strong>', '<strong>' . $table_new_prefix . '</strong>') . '</p>';
     echo $info_msg_string;
     //Do a back of the config file
     if (!AIOWPSecurity_Utility_File::backup_and_rename_wp_config($config_file)) {
         echo '<div class="aio_red_box"><p>' . __('Failed to make a backup of the wp-config.php file. This operation will not go ahead.', 'all-in-one-wp-security-and-firewall') . '</p></div>';
         return;
     } else {
         echo '<p class="aio_success_with_icon">' . __('A backup copy of your wp-config.php file was created successfully!', 'all-in-one-wp-security-and-firewall') . '</p>';
     }
     //Get multisite blog_ids if applicable
     if (AIOWPSecurity_Utility::is_multisite_install()) {
         $blog_ids = AIOWPSecurity_Utility::get_blog_ids();
     }
     //Rename all the table names
     foreach ($result as $db_table) {
         //Get table name with old prefix
         $table_old_name = $db_table;
         if (strpos($table_old_name, $table_old_prefix) === 0) {
             //Get table name with new prefix
             $table_new_name = $table_new_prefix . substr($table_old_name, $old_prefix_length);
             //Write query to rename tables name
             $sql = "RENAME TABLE `" . $table_old_name . "` TO `" . $table_new_name . "`";
             //$sql = "RENAME TABLE %s TO %s";
             //Execute the query
             if (false === $wpdb->query($sql)) {
                 $error = 1;
                 echo '<p class="aio_error_with_icon">' . sprintf(__('%s table name update failed', 'all-in-one-wp-security-and-firewall'), '<strong>' . $table_old_name . '</strong>') . '</p>';
                 $aio_wp_security->debug_logger->log_debug("DB Security Feature - Unable to change prefix of table " . $table_old_name, 4);
             } else {
                 $table_count++;
             }
         } else {
             continue;
         }
     }
     if ($error == 1) {
         echo '<p class="aio_error_with_icon">' . sprintf(__('Please change the prefix manually for the above tables to: %s', 'all-in-one-wp-security-and-firewall'), '<strong>' . $table_new_prefix . '</strong>') . '</p>';
     } else {
         echo '<p class="aio_success_with_icon">' . sprintf(__('%s tables had their prefix updated successfully!', 'all-in-one-wp-security-and-firewall'), '<strong>' . $table_count . '</strong>') . '</p>';
     }
     //Get wp-config.php file contents and modify it with new info
     $config_contents = file($config_file);
     $prefix_match_string = '$table_prefix=';
     //this is our search string for the wp-config.php file
     foreach ($config_contents as $line_num => $line) {
         $no_ws_line = preg_replace('/\\s+/', '', $line);
         //Strip white spaces
         if (strpos($no_ws_line, $prefix_match_string) !== FALSE) {
             $config_contents[$line_num] = str_replace($table_old_prefix, $table_new_prefix, $line);
             break;
         }
     }
     //Now let's modify the wp-config.php file
     if (AIOWPSecurity_Utility_File::write_content_to_file($config_file, $config_contents)) {
         echo '<p class="aio_success_with_icon">' . __('wp-config.php file was updated successfully!', 'all-in-one-wp-security-and-firewall') . '</p>';
     } else {
         echo '<p class="aio_error_with_icon">' . sprintf(__('The "wp-config.php" file was not able to be modified. Please modify this file manually using your favourite editor and search 
                 for variable "$table_prefix" and assign the following value to that variable: %s', 'all-in-one-wp-security-and-firewall'), '<strong>' . $table_new_prefix . '</strong>') . '</p>';
         $aio_wp_security->debug_logger->log_debug("DB Security Feature - Unable to modify wp-config.php", 4);
     }
     //Now let's update the options table
     $update_option_table_query = "UPDATE " . $table_new_prefix . "options \r\r\n                                                                  SET option_name = '" . $table_new_prefix . "user_roles' \r\r\n                                                                  WHERE option_name = '" . $table_old_prefix . "user_roles' \r\r\n                                                                  LIMIT 1";
     if (false === $wpdb->query($update_option_table_query)) {
         echo '<p class="aio_error_with_icon">' . sprintf(__('Update of table %s failed: unable to change %s to %s', 'all-in-one-wp-security-and-firewall'), $table_new_prefix . 'options', $table_old_prefix . 'user_roles', $table_new_prefix . 'user_roles') . '</p>';
         $aio_wp_security->debug_logger->log_debug("DB Security Feature - Error when updating the options table", 4);
         //Log the highly unlikely event of DB error
     } else {
         echo '<p class="aio_success_with_icon">' . sprintf(__('The options table records which had references to the old DB prefix were updated successfully!', 'all-in-one-wp-security-and-firewall')) . '</p>';
     }
     //Now let's update the options tables for the multisite subsites if applicable
     if (AIOWPSecurity_Utility::is_multisite_install()) {
         if (!empty($blog_ids)) {
             foreach ($blog_ids as $blog_id) {
                 if ($blog_id == 1) {
                     continue;
                 }
                 //skip main site
                 $new_pref_and_site_id = $table_new_prefix . $blog_id . '_';
                 $old_pref_and_site_id = $table_old_prefix . $blog_id . '_';
                 $update_ms_option_table_query = "UPDATE " . $new_pref_and_site_id . "options\r\r\n                                                                            SET option_name = '" . $new_pref_and_site_id . "user_roles'\r\r\n                                                                            WHERE option_name = '" . $old_pref_and_site_id . "user_roles'\r\r\n                                                                            LIMIT 1";
//.........这里部分代码省略.........
开发者ID:yarylo,项目名称:cerkva.pp.ua,代码行数:101,代码来源:wp-security-database-menu.php


示例6: aiowps_delete_backup_files

 function aiowps_delete_backup_files()
 {
     global $aio_wp_security;
     if ($aio_wp_security->configs->get_value('aiowps_backup_files_stored') > 0) {
         $path_parts = pathinfo($this->last_backup_file_path);
         $backups_path = $path_parts['dirname'];
         $files = AIOWPSecurity_Utility_File::scan_dir_sort_date($backups_path);
         $count = 0;
         foreach ($files as $file) {
             if (strpos($file, 'database-backup') !== false) {
                 if ($count >= $aio_wp_security->configs->get_value('aiowps_backup_files_stored')) {
                     @unlink($backups_path . '/' . $file);
                 }
                 $count++;
             }
         }
     }
 }
开发者ID:crazyyy,项目名称:bessarabia,代码行数:18,代码来源:wp-security-backup.php


示例7: show_wp_filesystem_permission_status

 function show_wp_filesystem_permission_status($name, $path, $recommended)
 {
     $fix = false;
     $configmod = AIOWPSecurity_Utility_File::get_file_permission($path);
     if ($configmod == "0777") {
         $trclass = "aio_table_row_red";
         //Display a red background if permissions are set as least secure ("777")
         $fix = true;
     } else {
         if ($configmod != $recommended) {
             //$res = $this->is_file_permission_secure($recommended, $configmod);
             $res = AIOWPSecurity_Utility_File::is_file_permission_secure($recommended, $configmod);
             if ($res) {
                 $trclass = "aio_table_row_green";
                 //If the current permissions are even tighter than recommended then display a green row
                 $fix = true;
             } else {
                 $trclass = "aio_table_row_yellow";
                 //Display a yellow background if permissions are set to something different than recommended
                 $fix = true;
             }
         } else {
             $trclass = "aio_table_row_green";
         }
     }
     echo "<tr class=" . $trclass . ">";
     echo '<td>' . $name . "</td>";
     echo '<td>' . $path . "</td>";
     echo '<td>' . $configmod . '</td>';
     echo '<td>' . $recommended . '</td>';
     if ($fix) {
         echo '<td>
                 <input type="submit" name="aiowps_fix_permissions" value="' . __('Set Recommended Permissions', 'aiowpsecurity') . '" class="button-secondary" />
                 <input type="hidden" name="aiowps_permission_chg_file" value="' . $path . '"/>
                 <input type="hidden" name="aiowps_recommended_permissions" value="' . $recommended . '"/>                        
                 </td>';
     } else {
         echo '<td>' . __('No Action Required', 'aiowpsecurity') . '</td>';
     }
     echo "</tr>";
 }
开发者ID:Rudchyk,项目名称:wp-framework,代码行数:41,代码来源:wp-security-filesystem-menu.php


示例8: execute_backup

 /**
  * This function will perform a database backup
  */
 function execute_backup()
 {
     global $wpdb, $aio_wp_security;
     $is_multi_site = false;
     @ini_set('auto_detect_line_endings', true);
     if (function_exists('is_multisite') && is_multisite()) {
         //Let's get the current site's table prefix
         $site_pref = esc_sql($wpdb->prefix);
         $db_query = "SHOW TABLES LIKE '" . $site_pref . "%'";
         $tables = $wpdb->get_results($db_query, ARRAY_N);
         $is_multi_site = true;
     } else {
         //get all of the tables
         $tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
     }
     $return = '';
     //cycle through each table
     foreach ($tables as $table) {
         $result = $wpdb->get_results('SELECT * FROM `' . $table[0] . '`;', ARRAY_N);
         $num_fields = sizeof($wpdb->get_results('DESCRIBE `' . $table[0] . '`;'));
         $return .= 'DROP TABLE IF EXISTS `' . $table[0] . '`;';
         $row2 = $wpdb->get_row('SHOW CREATE TABLE `' . $table[0] . '`;', ARRAY_N);
         $return .= PHP_EOL . PHP_EOL . $row2[1] . ";" . PHP_EOL . PHP_EOL;
         foreach ($result as $row) {
             $return .= 'INSERT INTO `' . $table[0] . '` VALUES(';
             for ($j = 0; $j < $num_fields; $j++) {
                 $row[$j] = addslashes($row[$j]);
                 //$row[$j] = ereg_replace( PHP_EOL, "\n", $row[$j] ); //deprecated!
                 $row[$j] = preg_replace("/" . PHP_EOL . "/", "\n", $row[$j]);
                 if (isset($row[$j])) {
                     $return .= '"' . $row[$j] . '"';
                 } else {
                     $return .= '""';
                 }
                 if ($j < $num_fields - 1) {
                     $return .= ',';
                 }
             }
             $return .= ");" . PHP_EOL;
         }
         $return .= PHP_EOL . PHP_EOL;
     }
     $return .= PHP_EOL . PHP_EOL;
     //Check to see if the main "backups" directory exists - create it otherwise
     $aiowps_backup_dir = WP_CONTENT_DIR . '/' . AIO_WP_SECURITY_BACKUPS_DIR_NAME;
     $aiowps_backup_url = content_url() . '/' . AIO_WP_SECURITY_BACKUPS_DIR_NAME;
     if (!AIOWPSecurity_Utility_File::create_dir($aiowps_backup_dir)) {
         $aio_wp_security->debug_logger->log_debug("Creation of DB backup directory failed!", 4);
         return false;
     }
     //Generate a random prefix for more secure filenames
     $random_prefix = $random_prefix = AIOWPSecurity_Utility::generate_alpha_numeric_random_string(14);
     if ($is_multi_site) {
         global $current_blog;
         $blog_id = $current_blog->blog_id;
         //Get the current site name string for use later
         $site_name = get_bloginfo('name');
         $site_name = strtolower($site_name);
         //make alphaunermic
         $site_name = preg_replace("/[^a-z0-9_\\s-]/", "", $site_name);
         //Cleanup multiple instances of dashes or whitespaces
         $site_name = preg_replace("/[\\s-]+/", " ", $site_name);
         //Convert whitespaces and underscore to dash
         $site_name = preg_replace("/[\\s_]/", "-", $site_name);
         $file = $random_prefix . '-database-backup-site-name-' . $site_name . '-' . current_time('timestamp');
         //We will create a sub dir for the blog using its blog id
         $dirpath = $aiowps_backup_dir . '/blogid_' . $blog_id . '/';
         //Create a subdirectory for this blog_id
         if (!AIOWPSecurity_Utility_File::create_dir($dirpath)) {
             $aio_wp_security->debug_logger->log_debug("Creation failed of DB backup directory for the following multisite blog ID: " . $blog_details->blog_id, 4);
             return false;
         }
         $fileName = $dirpath . '/' . $file . '.sql';
         $handle = @fopen($fileName, 'w+');
     } else {
         $dirpath = $aiowps_backup_dir;
         $file = $random_prefix . '-database-backup-' . current_time('timestamp');
         $fileName = $dirpath . '/' . $file . '.sql';
         $handle = @fopen($fileName, 'w+');
     }
     /*** Try upping the memory limit before gzipping */
     if (function_exists('memory_get_usage') && (int) @ini_get('memory_limit') < 64) {
         @ini_set('memory_limit', '64M');
     }
     if (!file_exists($fileName)) {
         echo "FILE DOES NOT EXISTS";
         exit;
         $handle = @fopen($fileName, 'w+');
     }
     $fw_res = @fwrite($handle, $return);
     if (!$fw_res) {
         return false;
     }
     @fclose($handle);
     //zip the file
     /*if ( class_exists( 'ZipArchive' ) ) 
             {
//.........这里部分代码省略.........
开发者ID:CarterNelms,项目名称:www.engineeredcomfort.net,代码行数:101,代码来源:wp-security-backup.php


示例9: check_filesystem_permissions_feature

 function check_filesystem_permissions_feature($item)
 {
     //TODO
     $is_secure = 1;
     $util = new AIOWPSecurity_Utility_File();
     $files_dirs_to_check = $util->files_and_dirs_to_check;
     foreach ($files_dirs_to_check as $file_or_dir) {
         $actual_perm = AIOWPSecurity_Utility_File::get_file_permission($file_or_dir['path']);
         $is_secure = $is_secure * AIOWPSecurity_Utility_File::is_file_permission_secure($file_or_dir['permissions'], $actual_perm);
     }
     //Only if all of the files' permissions are deemed secure give this a thumbs up
     if ($is_secure == 1) {
         $item->set_feature_status($this->feature_active);
     } else {
         $item->set_feature_status($this->feature_inactive);
     }
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:17,代码来源:wp-security-feature-item-manager.php


示例10: enable_file_edits

 static function enable_file_edits()
 {
     global $aio_wp_security;
     $edit_file_config_entry_exists = false;
     //Config file path
     $config_file = AIOWPSecurity_Utility_File::get_wp_config_file_path();
     //Get wp-config.php file contents
     $config_contents = file($config_file);
     foreach ($config_contents as $line_num => $line) {
         if (strpos($line, "'DISALLOW_FILE_EDIT', true")) {
             $config_contents[$line_num] = str_replace('true', 'false', $line);
             $edit_file_config_entry_exists = true;
         } else {
             if (strpos($line, "'DISALLOW_FILE_EDIT', false")) {
                 $edit_file_config_entry_exists = true;
                 //$this->show_msg_updated(__('Your system config file is already configured to allow PHP file editing.', 'all-in-one-wp-security-and-firewall'));
                 return true;
             }
         }
     }
     if (!$edit_file_config_entry_exists) {
         //if the DISALLOW_FILE_EDIT settings don't exist in wp-config.php then we don't need to do anything
         //$this->show_msg_updated(__('Your system config file is already configured to allow PHP file editing.', 'all-in-one-wp-security-and-firewall'));
         return true;
     } else {
         //Now let's modify the wp-config.php file
         if (AIOWPSecurity_Utility_File::write_content_to_file($config_file, $config_contents)) {
             //$this->show_msg_updated(__('Settings Saved - Your system is now configured to allow PHP file editing.', 'all-in-one-wp-security-and-firewall'));
             return true;
         } else {
             //$this->show_msg_error(__('Operation failed! Unable to modify wp-config.php file!', 'all-in-one-wp-security-and-firewall'));
             //$aio_wp_security->debug_logger->log_debug("Disable PHP File Edit - Unable to modify wp-config.php",4);
             return false;
         }
     }
 }
开发者ID:treydonovan,项目名称:mymexicotours,代码行数:36,代码来源:wp-security-utility.php


示例11: render_tab5

    function render_tab5()
    {
        global $aio_wp_security;
        global $wpdb;
        $events_table_name = AIOWPSEC_TBL_EVENTS;
        AIOWPSecurity_Utility::cleanup_table($events_table_name, 500);
        if (isset($_POST['aiowps_import_settings'])) {
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'aiowpsec-import-settings-nonce')) {
                $aio_wp_security->debug_logger->log_debug("Nonce check failed on import AIOWPS settings!", 4);
                die("Nonce check failed on import AIOWPS settings!");
            }
            if (empty($_POST['aiowps_import_settings_file']) && empty($_POST['aiowps_import_settings_text'])) {
                $this->show_msg_error(__('Please choose a file to import your settings from.', 'aiowpsecurity'));
            } else {
                if (empty($_POST['aiowps_import_settings_file'])) {
                    $import_from = "text";
                } else {
                    $import_from = "file";
                }
                if ($import_from == "file") {
                    //Let's get the uploaded import file path
                    $submitted_import_file_path = trim($_POST['aiowps_import_settings_file']);
                    $attachment_id = AIOWPSecurity_Utility_File::get_attachment_id_from_url($submitted_import_file_path);
                    //we'll need this later for deleting
                    //Verify that file chosen has valid AIOWPS settings contents
                    $aiowps_settings_file_contents = $this->check_if_valid_aiowps_settings_file($submitted_import_file_path);
                } else {
                    //Get the string right from the textarea. Still confirm it's in the expected format.
                    $aiowps_settings_file_contents = $this->check_if_valid_aiowps_settings_text($_POST['aiowps_import_settings_text']);
                }
                if ($aiowps_settings_file_contents != -1) {
                    //Apply the settings and delete the file (if applicable)
                    $settings_array = json_decode($aiowps_settings_file_contents, true);
                    $aiowps_settings_applied = update_option('aio_wp_security_configs', $settings_array);
                    if (!$aiowps_settings_applied) {
                        //Failed to import settings
                        $aio_wp_security->debug_logger->log_debug("Import AIOWPS settings from " . $import_from . " operation failed!", 4);
                        $this->show_msg_error(__('Import AIOWPS settings from ' . $import_from . ' operation failed!', 'aiowpsecurity'));
                        if ($import_from == "file") {
                            //Delete the uploaded settings file for security purposes
                            wp_delete_attachment($attachment_id, true);
                            if (false === wp_delete_attachment($attachment_id, true)) {
                                $this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes.', 'aiowpsecurity'));
                            } else {
                                $this->show_msg_updated(__('The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
                            }
                        }
                    } else {
                        $aio_wp_security->configs->configs = $settings_array;
                        //Refresh the configs global variable
                        //Just in case user submits partial config settings
                        //Run add_option_values to make sure any missing config items are at least set to default
                        AIOWPSecurity_Configure_Settings::add_option_values();
                        if ($import_from == "file") {
                            //Delete the uploaded settings file for security purposes
                            wp_delete_attachment($attachment_id, true);
                            if (false === wp_delete_attachment($attachment_id, true)) {
                                $this->show_msg_updated(__('Your AIOWPS settings were successfully imported via file input.', 'aiowpsecurity'));
                                $this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes because it contains security settings details.', 'aiowpsecurity'));
                            } else {
                                $this->show_msg_updated(__('Your AIOWPS settings were successfully imported. The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
                            }
                        } else {
                            $this->show_msg_updated(__('Your AIOWPS settings were successfully imported via text entry.', 'aiowpsecurity'));
                        }
                        //Now let's refresh the .htaccess file with any modified rules if applicable
                        $res = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
                        if ($res == -1) {
                            $this->show_msg_error(__('Could not write to the .htaccess file. Please check the file permissions.', 'aiowpsecurity'));
                        }
                    }
                } else {
                    //Invalid settings file
                    $aio_wp_security->debug_logger->log_debug("The contents of your settings file appear invalid!", 4);
                    $this->show_msg_error(__('The contents of your settings file appear invalid. Please check the contents of the file you are trying to import settings from.', 'aiowpsecurity'));
                    if ($import_from == "file") {
                        //Let's also delete the uploaded settings file for security purposes
                        wp_delete_attachment($attachment_id, true);
                        if (false === wp_delete_attachment($attachment_id, true)) {
                            $this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes.', 'aiowpsecurity'));
                        } else {
                            $this->show_msg_updated(__('The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
                        }
                    }
                }
            }
        }
        ?>
        <h2><?php 
        _e('Export or Import Your AIOWPS Settings', 'aiowpsecurity');
        ?>
</h2>
        <div class="aio_blue_box">
            <?php 
        echo '<p>' . __('This section allows you to export or import your All In One WP Security & Firewall settings.', 'aiowpsecurity');
        echo '<br />' . __('This can be handy if you wanted to save time by applying the settings from one site to another site.', 'aiowpsecurity') . '
            <br />' . __('NOTE: Before importing, it is your responsibility to know what settings you are trying to import. Importing settings blindly can cause you to be locked out of your site.', 'aiowpsecurity') . '
            <br />' . __('For Example: If a settings item relies on the domain URL then it may not work correctly when imported into a site with a different domain.', 'aiowpsecurity') . '
            </p>';
//.........这里部分代码省略.........
开发者ID:pankajsinghjarial,项目名称:SYLC-AMERICAN,代码行数:101,代码来源:wp-security-settings-menu.php


示例12: render_tab4

    function render_tab4()
    {
        global $wpdb;
        $file_selected = isset($_POST["aiowps_log_file"]) ? $_POST["aiowps_log_file"] : '';
        ?>

        <div class="postbox">
        <h3 class="hndle"><label for="title"><?php 
        _e('View Logs for All In WP Security & Firewall Plugin', 'all-in-one-wp-security-and-firewall');
        ?>
</label></h3>
        <div class="inside">
        <form action="" method="POST">
        <?php 
        wp_nonce_field('aiowpsec-dashboard-logs-nonce');
        ?>

        <table class="form-table">
            <tr valign="top">
                <th scope="row"><?php 
        _e('Log File', 'all-in-one-wp-security-and-firewall');
        ?>
:</th>
                <td>
                    <select id="aiowps_log_file" name="aiowps_log_file">
                        <option value=""><?php 
        _e('--Select a file--', 'all-in-one-wp-security-and-firewall');
        ?>
</option>
                        <option value="wp-security-log.txt" <?php 
        selected($file_selected, 'wp-security-log.txt');
        ?>
>wp-security-log</option>
                        <option value="wp-security-log-cron-job.txt" <?php 
        selected($file_selected, 'wp-security-log-cron-job.txt');
        ?>
>wp-security-log-cron-job</option>
                    </select>
                <span class="description"><?php 
        _e('Select one of the log files to view the contents', 'all-in-one-wp-security-and-firewall');
        ?>
</span>
                </td> 
            </tr>
        </table>
        <input type="submit" name="aiowps_view_logs" value="<?php 
        _e('View Logs', 'all-in-one-wp-security-and-firewall');
        ?>
" class="button-primary" />
        </form>
            
        </div></div>
        <?php 
        if (isset($_POST['aiowps_view_logs'])) {
            $error = '';
            $nonce = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce, 'aiowpsec-dashboard-logs-nonce')) {
                $aio_wp_security->debug_logger->log_debug("Nonce check failed on dashboard view logs!", 4);
                die("Nonce check failed on dashboard view logs!");
            }
            if (!empty($file_selected)) {
                ?>

        <div class="postbox">
        <h3 class="hndle"><label for="title"><?php 
                echo __('Log File Contents For', 'all-in-one-wp-security-and-firewall') . ': ' . $file_selected;
                ?>
</label></h3>
        <div class="inside">
            <?php 
                $aiowps_log_dir = AIO_WP_SECURITY_PATH . '/logs';
                $log_file = $aiowps_log_dir . '/' . $file_selected;
                if (file_exists($log_file)) {
                    $log_contents = AIOWPSecurity_Utility_File::get_file_contents($log_file);
                } else {
                    $log_contents = '';
                }
                if (empty($log_contents)) {
                    $log_contents = $file_selected . ': ' . __('Log file is empty!', 'all-in-one-wp-security-and-firewall');
                }
                ?>

            <textarea class="aio_text_area_file_output aio_half_width aio_spacer_10_tb" rows="15" readonly><?php 
                echo $log_contents;
                ?>
</textarea>
            
        </div>
        </div>
            
        <?php 
            }
        }
        ?>



        
        <?php 
    }
开发者ID:yarylo,项目名称:cerkva.pp.ua,代码行数:100,代码来源:wp-security-dashboard-menu.php


示例13: change_db_prefix

 function change_db_prefix($table_old_prefix, $table_new_prefix)
 {
     global $wpdb, $aio_wp_security;
     $old_prefix_length = strlen($table_old_prefix);
     //Config file path
     $config_file = ABSPATH . 'wp-config.php';
     //Get the table resource
     //$result = mysql_list_tables(DB_NAME);
     $result = $this->get_mysql_tables(DB_NAME);
     //Fix for deprecated php mysql_list_tables function
     //Count the number of tables
     //$num_rows = mysql_num_rows( $result );
     if (is_array($result) && count($result) > 0) {
         $num_rows = count($result);
     } else {
         echo '<div class="aio_red_box"><p>' . __('Error - Could not get tables or no tables found!', 'aiowpsecurity') . '</p></div>';
         return;
     }
     $table_count = 0;
     //TODO - after reading up on internationalization mixed with html code I found that the WP experts say to do it as below. We will need to clean up other areas where we haven't used the following convention
     $info_msg_string = '<p class="aio_info_with_icon">' . __('Starting DB prefix change operations.....', 'aiowpsecurity') . '</p>';
     $info_msg_string .= '<p class="aio_info_with_icon">' . sprintf(__('Your WordPress system has a total of %s tables and your new DB prefix will be: %s', 'aiowpsecurity'), '<strong>' . $num_rows . '</strong>', '<strong>' . $table_new_prefix . '</strong>') . '</p>';
     echo $info_msg_string;
     //Do a back of the config file
     if (!AIOWPSecurity_Utility_File::backup_and_rename_wp_config($config_file)) {
         echo '<div class="aio_red_box"><p>' . __('Failed to make a backup of the wp-config.php file. This operation will not go ahead.', 'aiowpsecurity') . '</p></div>';
         return;
     } else {
         echo '<p class="aio_success_with_icon">' . __('A backup copy of your wp-config.php file was created successfully!', 'aiowpsecurity') . '</p>';
     }
     //Rename all the table names
     foreach ($result as $db_table) {
         //Get table name with old prefix
         $table_old_name = $db_table;
         if (strpos($table_old_name, $table_old_prefix) === 0) {
             //Get table name with new prefix
             $table_new_name = $table_new_prefix . substr($table_old_name, $old_prefix_length);
             //Write query to rename tables name
             $sql = "RENAME TABLE `" . $table_old_name . "` TO `" . $table_new_name . "`";
             //$sql = "RENAME TABLE %s TO %s";
             //Execute the query
             if (false === $wpdb->query($sql)) {
                 $error = 1;
                 echo '<p class="aio_error_with_icon">' . sprintf(__('%s table name update failed', 'aiowpsecurity'), '<strong>' . $table_old_name . '</strong>') . '</p>';
                 $aio_wp_security->debug_logger->log_debug("DB Security Feature - Unable to change prefix of table " . $table_old_name, 4);
             } else {
                 $table_count++;
             }
         } else {
             continue;
         }
     }
     if (@$error == 1) {
         echo '<p class="aio_error_with_icon">' . sprintf(__('Please change the prefix manually for the above tables to: %s', 'aiowpsecurity'), '<strong>' . $table_new_prefix . '</strong>') . '</p>';
     } else {
         echo '<p class="aio_success_with_icon">' . sprintf(__('%s tables had their prefix updated successfully!', 'aiowpsecurity'), '<strong>' . $table_count . '</strong>') . '</p>';
     }
     //Get wp-config.php file contents and modify it with new info
     $config_contents = file($config_file);
     foreach ($config_contents as $line_num => $line) {
         switch (substr($line, 0, 16)) {
             case '$table_prefix  =':
                 $config_contents[$line_num] = str_replace($table_old_prefix, $table_new_prefix, $line);
                 break;
         }
     }
     //Now let's modify the wp-config.php file
     if (AIOWPSecurity_Utility_File::write_content_to_file($config_file, $config_contents)) {
         echo '<p class="aio_success_with_icon">' . __('wp-config.php file was updated successfully!', 'aiowpsecurity') . '</p>';
     } else {
         echo '<p class="aio_error_with_icon">' . sprintf(__('The "wp-config.php" file was not able to be modified. Please modify this file manually using your favourite editor and search 
                 for variable "$table_prefix" and assign the following value to that variable: %s', 'aiowpsecurity'), '<strong>' . $table_new_prefix . '</strong>') . '</p>';
         $aio_wp_security->debug_logger->log_debug("DB Security Feature - Unable to modify wp-config.php", 4);
     }
     //Now let's update the options table
     $update_option_table_query = "UPDATE " . $table_new_prefix . "options \r\n                                                                  SET option_name = '" . 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP AIOWPSecurity_Utility_Htaccess类代码示例发布时间:2022-05-23
下一篇:
PHP AIOWPSecurity_Utility类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap