本文整理汇总了PHP中ITSEC_Lib::set_minimum_memory_limit方法的典型用法代码示例。如果您正苦于以下问题:PHP ITSEC_Lib::set_minimum_memory_limit方法的具体用法?PHP ITSEC_Lib::set_minimum_memory_limit怎么用?PHP ITSEC_Lib::set_minimum_memory_limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITSEC_Lib
的用法示例。
在下文中一共展示了ITSEC_Lib::set_minimum_memory_limit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_backup
/**
* Public function to get lock and call backup.
*
* Attempts to get a lock to prevent concurrant backups and calls the backup function itself.
*
* @since 4.0.0
*
* @param boolean $one_time whether this is a one time backup
*
* @return mixed false on error or nothing
*/
public function do_backup($one_time = false)
{
ITSEC_Lib::set_minimum_memory_limit('256M');
$itsec_files = ITSEC_Core::get_itsec_files();
if ($itsec_files->get_file_lock('backup')) {
$this->execute_backup($one_time);
$itsec_files->release_file_lock('backup');
switch ($this->settings['method']) {
case 0:
return __('Backup complete. The backup was sent to the selected email recipients and was saved locally.', 'better-wp-security');
case 1:
return __('Backup complete. The backup was sent to the selected email recipients.', 'better-wp-security');
default:
return __('Backup complete. The backup was saved locally.', 'better-wp-security');
}
} else {
return new WP_Error('itsec-backup-do-backup-already-running', __('Unable to create a backup at this time since a backup is currently being created. If you wish to create an additional backup, please wait a few minutes before trying again.', 'better-wp-security'));
}
}
示例2: do_backup
/**
* Public function to get lock and call backup.
*
* Attempts to get a lock to prevent concurrant backups and calls the backup function itself.
*
* @since 4.0.0
*
* @param boolean $one_time whether this is a one time backup
*
* @return mixed false on error or nothing
*/
public function do_backup($one_time = false)
{
global $itsec_files;
ITSEC_Lib::set_minimum_memory_limit('128M');
if ($itsec_files->get_file_lock('backup')) {
$this->execute_backup($one_time);
$itsec_files->release_file_lock('backup');
if (true === $one_time) {
switch ($this->settings['method']) {
case 0:
$details = __('emailed to backup recipients and saved locally.', 'it-l10n-better-wp-security');
break;
case 1:
$details = __('emailed to backup recipients.', 'it-l10n-better-wp-security');
break;
default:
$details = __('saved locally.', 'it-l10n-better-wp-security');
break;
}
$type = 'updated';
$message = __('Backup Completed and ' . $details, 'it-l10n-better-wp-security');
}
$success = true;
} else {
if (true === $one_time) {
$type = 'error';
$message = __('Something went wrong with your backup. It looks like another process might already be trying to backup your database. Please try again in a few minutes. If the problem persists please contact support.', 'it-l10n-better-wp-security');
}
$success = false;
}
if (true === $one_time) {
if (is_multisite()) {
$error_handler = new WP_Error();
$error_handler->add($type, $message);
$this->core->show_network_admin_notice($error_handler);
} else {
add_settings_error('itsec', esc_attr('settings_updated'), $message, $type);
}
}
return $success;
}
示例3: execute_file_check
/**
* Executes file checking
*
* @param bool $scheduled_call [optional] is this an automatic check
*
* @return mixed
**/
public function execute_file_check($scheduled_call = true)
{
global $itsec_files, $itsec_logger, $itsec_globals;
if ($this->running === false) {
$this->running = true;
$send_email = true;
ITSEC_Lib::set_minimum_memory_limit('128M');
if ($itsec_files->get_file_lock('file_change', 300)) {
//make sure it isn't already running
define('ITSEC_DOING_FILE_CHECK', true);
//figure out what chunk we're on
if (isset($this->settings['split']) && $this->settings['split'] === true) {
if (isset($this->settings['last_chunk']) && $this->settings['last_chunk'] !== false && $this->settings['last_chunk'] < 6) {
$chunk = $this->settings['last_chunk'] + 1;
} else {
$chunk = 0;
}
} else {
$chunk = false;
}
if ($chunk !== false) {
$db_field = 'itsec_local_file_list_' . $chunk;
} else {
$db_field = 'itsec_local_file_list';
}
//set base memory
$memory_used = @memory_get_peak_usage();
$logged_files = get_site_option($db_field);
//if there are no old files old file list is an empty array
if ($logged_files === false) {
$send_email = false;
$logged_files = array();
if (is_multisite()) {
add_site_option($db_field, $logged_files);
} else {
add_option($db_field, $logged_files, '', 'no');
}
}
$current_files = $this->scan_files('', $scheduled_call, $chunk);
//scan current files
$itsec_files->release_file_lock('file_change');
$files_added = @array_diff_assoc($current_files, $logged_files);
//files added
$files_removed = @array_diff_assoc($logged_files, $current_files);
//files deleted
$current_minus_added = @array_diff_key($current_files, $files_added);
//remove all added files from current filelist
$logged_minus_deleted = @array_diff_key($logged_files, $files_removed);
//remove all deleted files from old file list
$files_changed = array();
//array of changed files
//compare file hashes and mod dates
foreach ($current_minus_added as $current_file => $current_attr) {
if (array_key_exists($current_file, $logged_minus_deleted)) {
//if attributes differ added to changed files array
if (isset($current_attr['mod_date']) && strcmp($current_attr['mod_date'], $logged_minus_deleted[$current_file]['mod_date']) != 0 || strcmp($current_attr['d'], $logged_minus_deleted[$current_file]['d']) != 0 || (isset($current_attr['hash']) && strcmp($current_attr['hash'], $logged_minus_deleted[$current_file]['hash']) != 0 || strcmp($current_attr['h'], $logged_minus_deleted[$current_file]['h']) != 0)) {
$remote_check = apply_filters('itsec_process_changed_file', true, $current_file, $current_attr['h']);
//hook to run actions on a changed file at time of discovery
if ($remote_check === true) {
//don't list the file if it matches the WordPress.org hash
$files_changed[$current_file]['h'] = isset($current_attr['hash']) ? $current_attr['hash'] : $current_attr['h'];
$files_changed[$current_file]['d'] = isset($current_attr['mod_date']) ? $current_attr['mod_date'] : $current_attr['d'];
}
}
}
}
//get count of changes
$files_added_count = sizeof($files_added);
$files_deleted_count = sizeof($files_removed);
$files_changed_count = sizeof($files_changed);
if ($files_added_count > 0) {
$files_added = apply_filters('itsec_process_added_files', $files_added);
//hook to run actions on all files added
$files_added_count = sizeof($files_added);
}
if ($files_deleted_count > 0) {
do_action('itsec_process_removed_files', $files_removed);
//hook to run actions on all files removed
}
//create single array of all changes
$full_change_list = array('added' => $files_added, 'removed' => $files_removed, 'changed' => $files_changed);
update_site_option($db_field, $current_files);
//Cleanup variables when we're done with them
unset($files_added);
unset($files_removed);
unset($files_changed);
unset($current_files);
$this->settings['last_run'] = $itsec_globals['current_time'];
$this->settings['last_chunk'] = $chunk;
update_site_option('itsec_file_change', $this->settings);
//get new max memory
$check_memory = @memory_get_peak_usage();
if ($check_memory > $memory_used) {
//.........这里部分代码省略.........