本文整理汇总了PHP中BackWPup_Job::check_folder方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Job::check_folder方法的具体用法?PHP BackWPup_Job::check_folder怎么用?PHP BackWPup_Job::check_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup_Job
的用法示例。
在下文中一共展示了BackWPup_Job::check_folder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
/**
* Creates DB und updates settings
*/
public static function activate()
{
//convert inactive version to active
if ($incative_version = get_site_option('backwpup_version')) {
update_site_option('backwpup_version', str_replace('-inactive', '', $incative_version));
}
//changes for version before 3.0.0
if (!get_site_option('backwpup_version') && get_option('backwpup') && get_option('backwpup_jobs')) {
self::upgrade_from_version_two();
}
//changes for version before 3.0.14
if (version_compare('3.0.13', get_site_option('backwpup_version'), '>') && version_compare('3.0', get_site_option('backwpup_version'), '<')) {
$upload_dir = wp_upload_dir();
$logfolder = get_site_option('backwpup_cfg_logfolder');
if (empty($logfolder)) {
$old_log_folder = trailingslashit(str_replace('\\', '/', $upload_dir['basedir'])) . 'backwpup-' . substr(md5(md5(SECURE_AUTH_KEY)), 9, 5) . '-logs/';
update_site_option('backwpup_cfg_logfolder', $old_log_folder);
}
}
//changes for version before 3.1.2
if (version_compare('3.1.2', get_site_option('backwpup_version'), '>')) {
BackWPup_Job::check_folder(get_site_option('backwpup_cfg_logfolder'), TRUE);
}
//create new options
if (is_multisite()) {
add_site_option('backwpup_jobs', array());
} else {
add_option('backwpup_jobs', array(), NULL, 'no');
}
//remove old schedule
wp_clear_scheduled_hook('backwpup_cron');
//make new schedule
$activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
if (!empty($activejobs)) {
foreach ($activejobs as $id) {
$cron_next = BackWPup_Cron::cron_next(BackWPup_Option::get($id, 'cron'));
wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $id));
}
}
//add check Cleanup schedule
wp_clear_scheduled_hook('backwpup_check_cleanup');
wp_schedule_event(time(), 'twicedaily', 'backwpup_check_cleanup');
//remove old roles pre v.3.0.9
$role = get_role('administrator');
$role->remove_cap('backwpup');
$role->remove_cap('backwpup_jobs');
$role->remove_cap('backwpup_jobs_edit');
$role->remove_cap('backwpup_jobs_start');
$role->remove_cap('backwpup_backups');
$role->remove_cap('backwpup_backups_download');
$role->remove_cap('backwpup_backups_delete');
$role->remove_cap('backwpup_logs');
$role->remove_cap('backwpup_logs_delete');
$role->remove_cap('backwpup_settings');
//add/overwrite roles
add_role('backwpup_admin', __('BackWPup Admin', 'backwpup'), array('backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => TRUE, 'backwpup_jobs_start' => TRUE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => TRUE, 'backwpup_backups_delete' => TRUE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => TRUE, 'backwpup_settings' => TRUE));
add_role('backwpup_check', __('BackWPup jobs checker', 'backwpup'), array('backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => FALSE, 'backwpup_jobs_start' => FALSE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => FALSE, 'backwpup_backups_delete' => FALSE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => FALSE, 'backwpup_settings' => FALSE));
add_role('backwpup_helper', __('BackWPup jobs helper', 'backwpup'), array('backwpup' => TRUE, 'backwpup_jobs' => TRUE, 'backwpup_jobs_edit' => FALSE, 'backwpup_jobs_start' => TRUE, 'backwpup_backups' => TRUE, 'backwpup_backups_download' => TRUE, 'backwpup_backups_delete' => TRUE, 'backwpup_logs' => TRUE, 'backwpup_logs_delete' => TRUE, 'backwpup_settings' => FALSE));
//add role to admin user if no one
$users_backwpup = get_users(array('blog_id' => 1, 'role' => 'backwpup_admin'));
if (empty($users_backwpup)) {
/* @var WP_User $user */
$users = get_users(array('blog_id' => 1, 'role' => 'administrator', 'fields' => 'all_with_meta'));
foreach ($users as $user) {
$user->add_role('backwpup_admin');
}
}
//add default options
BackWPup_Option::default_site_options();
//update version
update_site_option('backwpup_version', BackWPup::get_plugin_data('Version'));
}
示例2: load
/**
*
*/
public static function load()
{
//Create Table
self::$listtable = new self();
switch (self::$listtable->current_action()) {
case 'delete':
//Delete Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
if (is_array($_GET['jobs'])) {
check_admin_referer('bulk-jobs');
foreach ($_GET['jobs'] as $jobid) {
wp_clear_scheduled_hook('backwpup_cron', array('id' => $jobid));
BackWPup_Option::delete_job($jobid);
}
}
break;
case 'copy':
//Copy Job
if (!current_user_can('backwpup_jobs_edit')) {
break;
}
$old_job_id = (int) $_GET['jobid'];
check_admin_referer('copy-job_' . $_GET['jobid']);
//create new
$newjobid = BackWPup_Option::get_job_ids();
sort($newjobid);
$newjobid = end($newjobid) + 1;
$old_options = BackWPup_Option::get_job($old_job_id);
foreach ($old_options as $key => $option) {
if ($key == "jobid") {
$option = $newjobid;
}
if ($key == "name") {
$option = __('Copy of', 'backwpup') . ' ' . $option;
}
if ($key == "activetype") {
$option = '';
}
if ($key == "archivename") {
$option = str_replace($_GET['jobid'], $newjobid, $option);
}
if ($key == "logfile" || $key == "lastbackupdownloadurl" || $key == "lastruntime" || $key == "lastrun") {
continue;
}
BackWPup_Option::update($newjobid, $key, $option);
}
break;
case 'start_cli':
//Get cmd start file
if (!current_user_can('backwpup_jobs_start')) {
break;
}
check_admin_referer('start_cli');
if (empty($_GET['jobid'])) {
break;
}
if (FALSE === strpos(PHP_OS, "WIN")) {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".sh;");
if (defined('PHP_BINDIR')) {
echo "#!/bin/sh" . PHP_EOL;
}
echo "@\$1php -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
die;
} else {
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".cmd;");
echo "@%1php.exe -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
die;
}
break;
case 'runnow':
if (!empty($_GET['jobid'])) {
if (!current_user_can('backwpup_jobs_start')) {
wp_die(__('Sorry, you don\'t have permissions to do that.', 'backwpup'));
}
check_admin_referer('backwpup_job_run-runnowlink');
//check temp folder
BackWPup_Job::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE);
//check log folder
BackWPup_Job::check_folder(get_site_option('backwpup_cfg_logfolder'));
//check server callback
$raw_response = BackWPup_Job::get_jobrun_url('test');
$test_result = '';
if (is_wp_error($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), $raw_response->get_error_message());
} elseif (200 != wp_remote_retrieve_response_code($raw_response) && 204 != wp_remote_retrieve_response_code($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response));
}
//.........这里部分代码省略.........
示例3: page
//.........这里部分代码省略.........
} else {
echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . '</td></tr>';
}
echo '<tr title=">=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . PHP_VERSION . '</td></tr>';
echo '<tr title=">=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . $wpdb->get_var("SELECT VERSION() AS version") . '</td></tr>';
if (function_exists('curl_version')) {
$curlversion = curl_version();
echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . $curlversion['version'] . '</td></tr>';
echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . $curlversion['ssl_version'] . '</td></tr>';
} else {
echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . __('unavailable', 'backwpup') . '</td></tr>';
}
echo '<tr title=""><td>' . __('WP-Cron url:', 'backwpup') . '</td><td>' . site_url('wp-cron.php') . '</td></tr>';
//response test
echo '<tr><td>' . __('Server self connect:', 'backwpup') . '</td><td>';
$raw_response = BackWPup_Job::get_jobrun_url('test');
$test_result = '';
if (is_wp_error($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), $raw_response->get_error_message());
} elseif (200 != wp_remote_retrieve_response_code($raw_response) && 204 != wp_remote_retrieve_response_code($raw_response)) {
$test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response));
}
$headers = wp_remote_retrieve_headers($raw_response);
if (isset($headers['x-backwpup-ver']) && $headers['x-backwpup-ver'] != BackWPup::get_plugin_data('version')) {
$test_result .= sprintf(__('The BackWPup HTTP response header returns a false value: "%s"', 'backwpup'), $headers['x-backwpup-ver']);
}
if (empty($test_result)) {
_e('Response Test O.K.', 'backwpup');
} else {
echo $test_result;
}
echo '</td></tr>';
//folder test
BackWPup_Job::check_folder(BackWPup::get_plugin_data('TEMP'));
echo '<tr><td>' . __('Temp folder:', 'backwpup') . '</td><td>';
if (!is_dir(BackWPup::get_plugin_data('TEMP'))) {
echo sprintf(__('Temp folder %s doesn\'t exist and can\'t be created.', 'backwpup'), BackWPup::get_plugin_data('TEMP'));
} elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), BackWPup::get_plugin_data('TEMP'));
} else {
echo BackWPup::get_plugin_data('TEMP');
}
echo '</td></tr>';
BackWPup_Job::check_folder(get_site_option('backwpup_cfg_logfolder'));
echo '<tr><td>' . __('Log folder:', 'backwpup') . '</td><td>';
if (!is_dir(get_site_option('backwpup_cfg_logfolder'))) {
echo sprintf(__('Logs folder %s not exist and can\'t created.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
} elseif (!is_writable(get_site_option('backwpup_cfg_logfolder'))) {
echo sprintf(__('Log folder %s is not writable.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
} else {
echo get_site_option('backwpup_cfg_logfolder');
}
echo '</td></tr>';
echo '<tr title=""><td>' . __('Server', 'backwpup') . '</td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>';
echo '<tr title=""><td>' . __('Operating System', 'backwpup') . '</td><td>' . PHP_OS . '</td></tr>';
echo '<tr title=""><td>' . __('PHP SAPI', 'backwpup') . '</td><td>' . PHP_SAPI . '</td></tr>';
echo '<tr title=""><td>' . __('Current PHP user', 'backwpup') . '</td><td>' . get_current_user() . '</td></tr>';
$text = (bool) ini_get('safe_mode') ? __('On', 'backwpup') : __('Off', 'backwpup');
echo '<tr title=""><td>' . __('Safe Mode', 'backwpup') . '</td><td>' . $text . '</td></tr>';
echo '<tr title=">=30"><td>' . __('Maximum execution time', 'backwpup') . '</td><td>' . ini_get('max_execution_time') . ' ' . __('seconds', 'backwpup') . '</td></tr>';
if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
} else {
echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
}
if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {