/** * Save settings form data */ public static function save_post_form() { if (!current_user_can('backwpup_settings')) { return; } //set default options if button clicked if (isset($_POST['default_settings']) && $_POST['default_settings']) { delete_site_option('backwpup_cfg_showadminbar'); delete_site_option('backwpup_cfg_showfoldersize'); delete_site_option('backwpup_cfg_jobsteprestart'); delete_site_option('backwpup_cfg_jobstepretry'); delete_site_option('backwpup_cfg_jobmaxexecutiontime'); delete_site_option('backwpup_cfg_jobziparchivemethod'); delete_site_option('backwpup_cfg_jobnotranslate'); delete_site_option('backwpup_cfg_jobwaittimems'); delete_site_option('backwpup_cfg_maxlogs'); delete_site_option('backwpup_cfg_gzlogs'); delete_site_option('backwpup_cfg_protectfolders'); delete_site_option('backwpup_cfg_httpauthuser'); delete_site_option('backwpup_cfg_httpauthpassword'); delete_site_option('backwpup_cfg_logfolder'); BackWPup_Admin::message(__('Settings reset to default', 'backwpup')); return; } update_site_option('backwpup_cfg_showadminbar', isset($_POST['showadminbar']) ? 1 : 0); update_site_option('backwpup_cfg_showfoldersize', isset($_POST['showfoldersize']) ? 1 : 0); update_site_option('backwpup_cfg_jobsteprestart', isset($_POST['jobsteprestart']) ? 1 : 0); if (100 > $_POST['jobstepretry'] && 0 < $_POST['jobstepretry']) { $_POST['jobstepretry'] = abs((int) $_POST['jobstepretry']); } if (empty($_POST['jobstepretry']) or !is_int($_POST['jobstepretry'])) { $_POST['jobstepretry'] = 3; } update_site_option('backwpup_cfg_jobstepretry', $_POST['jobstepretry']); update_site_option('backwpup_cfg_jobmaxexecutiontime', abs((int) $_POST['jobmaxexecutiontime'])); update_site_option('backwpup_cfg_jobziparchivemethod', $_POST['jobziparchivemethod'] == '' || $_POST['jobziparchivemethod'] == 'PclZip' || $_POST['jobziparchivemethod'] == 'ZipArchive' ? $_POST['jobziparchivemethod'] : ''); update_site_option('backwpup_cfg_jobnotranslate', isset($_POST['jobnotranslate']) ? 1 : 0); update_site_option('backwpup_cfg_jobwaittimems', $_POST['jobwaittimems']); update_site_option('backwpup_cfg_maxlogs', abs((int) $_POST['maxlogs'])); update_site_option('backwpup_cfg_gzlogs', isset($_POST['gzlogs']) ? 1 : 0); update_site_option('backwpup_cfg_protectfolders', isset($_POST['protectfolders']) ? 1 : 0); update_site_option('backwpup_cfg_httpauthuser', $_POST['httpauthuser']); update_site_option('backwpup_cfg_httpauthpassword', BackWPup_Encryption::encrypt($_POST['httpauthpassword'])); $_POST['jobrunauthkey'] = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['jobrunauthkey'])); update_site_option('backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey']); $_POST['logfolder'] = trailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['logfolder'])))); if ($_POST['logfolder'][0] == '.' || $_POST['logfolder'][0] != '/' && !preg_match('#^[a-zA-Z]:/#', $_POST['logfolder'])) { $_POST['logfolder'] = trailingslashit(str_replace('\\', '/', ABSPATH)) . $_POST['logfolder']; } //set def. folders if (empty($_POST['logfolder']) || $_POST['logfolder'] == '/') { delete_site_option('backwpup_cfg_logfolder'); } else { update_site_option('backwpup_cfg_logfolder', $_POST['logfolder']); } do_action('backwpup_page_settings_save'); BackWPup_Admin::message(__('Settings saved', 'backwpup')); }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest), FALSE); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 'msazureaccname') && BackWPup_Option::get($jobid, 'msazurekey') && BackWPup_Option::get($jobid, 'msazurecontainer')) { try { set_include_path(get_include_path() . PATH_SEPARATOR . BackWPup::get_plugin_data('plugindir') . '/vendor/PEAR/'); $blobRestProxy = WindowsAzure\Common\ServicesBuilder::getInstance()->createBlobService('DefaultEndpointsProtocol=https;AccountName=' . BackWPup_Option::get($jobid, 'msazureaccname') . ';AccountKey=' . BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'msazurekey'))); $blobRestProxy->deleteBlob(BackWPup_Option::get($jobid, 'msazurecontainer'), $backupfile); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } } catch (Exception $e) { BackWPup_Admin::message('MS AZURE: ' . $e->getMessage(), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, 60 * 60 * 24 * 7); }
/** * Save Form data */ public static function save_post_form($tab, $jobid) { if (!current_user_can('backwpup_jobs_edit')) { return __('Sorry, you don\'t have permissions to do that.', 'backwpup'); } $destinations = BackWPup::get_registered_destinations(); $job_types = BackWPup::get_job_types(); switch ($tab) { case 'job': BackWPup_Option::update($jobid, 'jobid', $jobid); if (isset($_POST['type']) && is_array($_POST['type'])) { foreach ((array) $_POST['type'] as $typeid) { if (empty($job_types[$typeid])) { unset($_POST['type'][$typeid]); } } if (is_array($_POST['type'])) { sort($_POST['type']); } } else { $_POST['type'] = array(); } //test if job type makes backup /* @var BackWPup_JobTypes $job_type */ $makes_file = FALSE; foreach ($job_types as $type_id => $job_type) { if (in_array($type_id, $_POST['type'])) { if ($job_type->creates_file()) { $makes_file = TRUE; break; } } } if (!$makes_file) { $_POST['destinations'] = array(); } BackWPup_Option::update($jobid, 'type', $_POST['type']); if (isset($_POST['destinations']) && is_array($_POST['destinations'])) { foreach ((array) $_POST['destinations'] as $key => $destid) { if (empty($destinations[$destid])) { //remove all destinations that not exists unset($_POST['destinations'][$key]); } if (class_exists('BackWPup_Pro', FALSE) && $_POST['backuptype'] == 'sync') { //if sync remove all not sync destinations if (!$destinations[$destid]['can_sync']) { unset($_POST['destinations'][$key]); } } } if (is_array($_POST['destinations'])) { sort($_POST['destinations']); } } else { $_POST['destinations'] = array(); } BackWPup_Option::update($jobid, 'destinations', $_POST['destinations']); $name = esc_html(trim($_POST['name'])); if (empty($name) || $_POST['name'] == __('New Job', 'backwpup')) { $name = sprintf(__('Job with ID %d', 'backwpup'), $jobid); } BackWPup_Option::update($jobid, 'name', $name); $emails = explode(',', $_POST['mailaddresslog']); foreach ($emails as $key => $email) { $emails[$key] = sanitize_email(trim($email)); if (!is_email($emails[$key])) { unset($emails[$key]); } } $mailaddresslog = implode(', ', $emails); BackWPup_Option::update($jobid, 'mailaddresslog', $mailaddresslog); $_POST['mailaddresssenderlog'] = trim($_POST['mailaddresssenderlog']); if (empty($_POST['mailaddresssenderlog'])) { BackWPup_Option::delete($jobid, 'mailaddresssenderlog'); } else { BackWPup_Option::update($jobid, 'mailaddresssenderlog', $_POST['mailaddresssenderlog']); } BackWPup_Option::update($jobid, 'mailerroronly', isset($_POST['mailerroronly']) && $_POST['mailerroronly'] == 1 ? TRUE : FALSE); if (class_exists('BackWPup_Pro', FALSE)) { BackWPup_Option::update($jobid, 'backuptype', esc_html($_POST['backuptype'])); } else { BackWPup_Option::update($jobid, 'backuptype', 'archive'); } BackWPup_Option::update($jobid, 'archiveformat', esc_html($_POST['archiveformat'])); BackWPup_Option::update($jobid, 'archivename', BackWPup_Job::sanitize_file_name($_POST['archivename'])); break; case 'cron': if ($_POST['activetype'] == '' || $_POST['activetype'] == 'wpcron' || $_POST['activetype'] == 'easycron' || $_POST['activetype'] == 'link') { BackWPup_Option::update($jobid, 'activetype', $_POST['activetype']); } BackWPup_Option::update($jobid, 'cronselect', $_POST['cronselect'] == 'advanced' ? 'advanced' : 'basic'); if (isset($_POST['cronselect']) && $_POST['cronselect'] == 'advanced') { //save advanced if (empty($_POST['cronminutes']) || $_POST['cronminutes'][0] == '*') { if (!empty($_POST['cronminutes'][1])) { $_POST['cronminutes'] = array('*/' . $_POST['cronminutes'][1]); } else { $_POST['cronminutes'] = array('*'); } } if (empty($_POST['cronhours']) || $_POST['cronhours'][0] == '*') { if (!empty($_POST['cronhours'][1])) { $_POST['cronhours'] = array('*/' . $_POST['cronhours'][1]); } else { $_POST['cronhours'] = array('*'); } } if (empty($_POST['cronmday']) || $_POST['cronmday'][0] == '*') { if (!empty($_POST['cronmday'][1])) { $_POST['cronmday'] = array('*/' . $_POST['cronmday'][1]); } else { $_POST['cronmday'] = array('*'); } } if (empty($_POST['cronmon']) || $_POST['cronmon'][0] == '*') { if (!empty($_POST['cronmon'][1])) { $_POST['cronmon'] = array('*/' . $_POST['cronmon'][1]); } else { $_POST['cronmon'] = array('*'); } } if (empty($_POST['cronwday']) || $_POST['cronwday'][0] == '*') { if (!empty($_POST['cronwday'][1])) { $_POST['cronwday'] = array('*/' . $_POST['cronwday'][1]); } else { $_POST['cronwday'] = array('*'); } } $cron = implode(",", $_POST['cronminutes']) . ' ' . implode(",", $_POST['cronhours']) . ' ' . implode(",", $_POST['cronmday']) . ' ' . implode(",", $_POST['cronmon']) . ' ' . implode(",", $_POST['cronwday']); BackWPup_Option::update($jobid, 'cron', $cron); } else { //Save basic if ($_POST['cronbtype'] == 'mon') { BackWPup_Option::update($jobid, 'cron', $_POST['moncronminutes'] . ' ' . $_POST['moncronhours'] . ' ' . $_POST['moncronmday'] . ' * *'); } if ($_POST['cronbtype'] == 'week') { BackWPup_Option::update($jobid, 'cron', $_POST['weekcronminutes'] . ' ' . $_POST['weekcronhours'] . ' * * ' . $_POST['weekcronwday']); } if ($_POST['cronbtype'] == 'day') { BackWPup_Option::update($jobid, 'cron', $_POST['daycronminutes'] . ' ' . $_POST['daycronhours'] . ' * * *'); } if ($_POST['cronbtype'] == 'hour') { BackWPup_Option::update($jobid, 'cron', $_POST['hourcronminutes'] . ' * * * *'); } } //reschedule wp_clear_scheduled_hook('backwpup_cron', array('id' => $jobid)); if (BackWPup_Option::get($jobid, 'activetype') == 'wpcron') { $cron_next = BackWPup_Cron::cron_next(BackWPup_Option::get($jobid, 'cron')); wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $jobid)); } $easy_cron_job_id = BackWPup_Option::get($jobid, 'easycronjobid'); if (BackWPup_Option::get($jobid, 'activetype') == 'easycron') { BackWPup_EasyCron::update($jobid); } elseif (!empty($easy_cron_job_id)) { BackWPup_EasyCron::delete($jobid); } break; default: if (strstr($tab, 'dest-')) { $dest_class = BackWPup::get_destination(str_replace('dest-', '', $tab)); $dest_class->edit_form_post_save($jobid); } if (strstr($tab, 'jobtype-')) { $id = strtoupper(str_replace('jobtype-', '', $tab)); $job_types[$id]->edit_form_post_save($jobid); } } //saved message $messages = BackWPup_Admin::get_messages(); if (empty($messages['error'])) { $url = BackWPup_Job::get_jobrun_url('runnowlink', $jobid); BackWPup_Admin::message(sprintf(__('Changes for job <i>%s</i> saved.', 'backwpup'), BackWPup_Option::get($jobid, 'name')) . ' <a href="' . network_admin_url('admin.php') . '?page=backwpupjobs">' . __('Jobs overview', 'backwpup') . '</a> | <a href="' . $url['url'] . '">' . __('Run now', 'backwpup') . '</a>'); } }
/** * */ public static function start_http($starttype, $jobid = 0) { //load text domain $log_level = get_site_option('backwpup_cfg_loglevel', 'normal_translated'); if (strstr($log_level, 'translated')) { BackWPup::load_text_domain(); } else { add_filter('override_load_textdomain', '__return_true'); $GLOBALS['l10n'] = array(); } if ($starttype !== 'restart') { //check job id exists if ($jobid !== BackWPup_Option::get($jobid, 'jobid')) { return false; } //check folders $log_folder = get_site_option('backwpup_cfg_logfolder'); $folder_message_log = BackWPup_File::check_folder(BackWPup_File::get_absolute_path($log_folder)); $folder_message_temp = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), true); if (!empty($folder_message_log) || !empty($folder_message_temp)) { BackWPup_Admin::message($folder_message_log, true); BackWPup_Admin::message($folder_message_temp, true); return false; } } // redirect if ($starttype === 'runnowalt') { ob_start(); wp_redirect(add_query_arg(array('page' => 'backwpupjobs'), network_admin_url('admin.php'))); echo ' '; flush(); if ($level = ob_get_level()) { for ($i = 0; $i < $level; $i++) { ob_end_clean(); } } } // Should be preventing doubled running job's on http requests $random = mt_rand(10, 90) * 10000; usleep($random); //check running job $backwpup_job_object = self::get_working_data(); //start class if (!$backwpup_job_object && in_array($starttype, array('runnow', 'runnowalt', 'runext', 'cronrun'), true) && $jobid) { //schedule restart event wp_schedule_single_event(time() + 60, 'backwpup_cron', array('id' => 'restart')); //start job $backwpup_job_object = new self(); $backwpup_job_object->create($starttype, $jobid); } if ($backwpup_job_object) { $backwpup_job_object->run(); } }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest)); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 'sugarrefreshtoken')) { try { $sugarsync = new BackWPup_Destination_SugarSync_API(BackWPup_Option::get($jobid, 'sugarrefreshtoken')); $sugarsync->delete(urldecode($backupfile)); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } unset($sugarsync); } catch (Exception $e) { BackWPup_Admin::message('SUGARSYNC: ' . $e->getMessage(), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, 60 * 60 * 24 * 7); }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest)); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 'ftphost') && BackWPup_Option::get($jobid, 'ftpuser') && BackWPup_Option::get($jobid, 'ftppass') && function_exists('ftp_connect')) { $ftp_conn_id = FALSE; if (function_exists('ftp_ssl_connect') && BackWPup_Option::get($jobid, 'ftpssl')) { //make SSL FTP connection $ftp_conn_id = ftp_ssl_connect(BackWPup_Option::get($jobid, 'ftphost'), BackWPup_Option::get($jobid, 'ftphostport'), BackWPup_Option::get($jobid, 'ftptimeout')); } elseif (!BackWPup_Option::get($jobid, 'ftpssl')) { //make normal FTP conection if SSL not work $ftp_conn_id = ftp_connect(BackWPup_Option::get($jobid, 'ftphost'), BackWPup_Option::get($jobid, 'ftphostport'), BackWPup_Option::get($jobid, 'ftptimeout')); } $loginok = FALSE; if ($ftp_conn_id) { //FTP Login if (@ftp_login($ftp_conn_id, BackWPup_Option::get($jobid, 'ftpuser'), BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'ftppass')))) { $loginok = TRUE; } else { //if PHP ftp login don't work use raw login ftp_raw($ftp_conn_id, 'USER ' . BackWPup_Option::get($jobid, 'ftpuser')); $return = ftp_raw($ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'ftppass'))); if (substr(trim($return[0]), 0, 3) <= 400) { $loginok = TRUE; } } } if ($loginok) { ftp_pasv($ftp_conn_id, BackWPup_Option::get($jobid, 'ftppasv')); ftp_delete($ftp_conn_id, $backupfile); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } } else { BackWPup_Admin::message(__('FTP: Login failure!', 'backwpup'), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, YEAR_IN_SECONDS); }
private static function query_api($endpoint, array $params) { $message = array('status' => 'error', 'error' => array('code' => 0, 'message' => 'Please setup EasyCron auth api key in settings')); $params['token'] = get_site_option('backwpup_cfg_easycronapikey'); if (empty($params['token'])) { return $message; } $result = wp_remote_get('https://www.easycron.com/rest/' . $endpoint . '?' . http_build_query($params)); if (wp_remote_retrieve_response_code($result) != 200) { $message['error']['code'] = wp_remote_retrieve_response_code($result); $message['error']['message'] = wp_remote_retrieve_response_message($result); } else { $json = wp_remote_retrieve_body($result); $message = json_decode($json, TRUE); } if ($message['status'] != 'success') { BackWPup_Admin::message(sprintf(__('EasyCron.com API returns (%s): %s', 'backwpup'), esc_attr($message['error']['code']), esc_attr($message['error']['message'])), TRUE); } return $message; }
/** * * Check is folder readable and exists create it if not * add .htaccess or index.html file in folder to prevent directory listing * * @param string $folder the folder to check * @param bool $donotbackup Create a file that the folder will not backuped * @return bool ok or not */ public static function check_folder($folder, $donotbackup = FALSE) { $folder = untrailingslashit(str_replace('\\', '/', $folder)); if (empty($folder)) { return FALSE; } //check that is not home of WP if ($folder == untrailingslashit(str_replace('\\', '/', ABSPATH)) || $folder == untrailingslashit(str_replace('\\', '/', WP_PLUGIN_DIR)) || $folder == untrailingslashit(str_replace('\\', '/', WP_CONTENT_DIR))) { BackWPup_Admin::message(sprintf(__('Folder %1$s not allowed, please use another folder.', 'backwpup'), $folder), TRUE); return FALSE; } //create folder if it not exists if (!is_dir($folder)) { if (!wp_mkdir_p($folder)) { BackWPup_Admin::message(sprintf(__('Cannot create folder: %1$s', 'backwpup'), $folder), TRUE); return FALSE; } } //check is writable dir if (!is_writable($folder)) { BackWPup_Admin::message(sprintf(__('Folder "%1$s" is not writable', 'backwpup'), $folder), TRUE); return FALSE; } //create .htaccess for apache and index.php for folder security if (get_site_option('backwpup_cfg_protectfolders') && !file_exists($folder . '/.htaccess')) { file_put_contents($folder . '/.htaccess', "<Files \"*\">" . PHP_EOL . "<IfModule mod_access.c>" . PHP_EOL . "Deny from all" . PHP_EOL . "</IfModule>" . PHP_EOL . "<IfModule !mod_access_compat>" . PHP_EOL . "<IfModule mod_authz_host.c>" . PHP_EOL . "Deny from all" . PHP_EOL . "</IfModule>" . PHP_EOL . "</IfModule>" . PHP_EOL . "<IfModule mod_access_compat>" . PHP_EOL . "Deny from all" . PHP_EOL . "</IfModule>" . PHP_EOL . "</Files>"); } if (get_site_option('backwpup_cfg_protectfolders') && !file_exists($folder . '/index.php')) { file_put_contents($folder . '/index.php', "<?php" . PHP_EOL . "header( \$_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found' );" . PHP_EOL . "header( 'Status: 404 Not Found' );" . PHP_EOL); } //Create do not backup file for this folder if ($donotbackup && !file_exists($folder . '/.donotbackup')) { file_put_contents($folder . '/.donotbackup', __('BackWPup will not backup folders and subfolders when this file is inside.', 'backwpup')); } return TRUE; }
/** * @param int $jobid */ public static function start_wp_cron($jobid = 0) { if (!defined('DOING_CRON') || !DOING_CRON) { return; } //load text domain $log_level = get_site_option('backwpup_cfg_loglevel'); if (strstr($log_level, 'translated')) { BackWPup::load_text_domain(); } if (!empty($jobid)) { //check folders $log_folder = get_site_option('backwpup_cfg_logfolder'); $folder_message_log = BackWPup_File::check_folder(BackWPup_File::get_absolute_path($log_folder)); $folder_message_temp = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE); if (!empty($folder_message_log) || !empty($folder_message_temp)) { BackWPup_Admin::message($folder_message_log, TRUE); BackWPup_Admin::message($folder_message_temp, TRUE); return; } } // Should be preventing doubled running job's on http requests $random = rand(1, 9) * 100000; usleep($random); //get running job $backwpup_job_object = self::get_working_data(); //start/restart class if (empty($backwpup_job_object) && !empty($jobid)) { //schedule restart event wp_schedule_single_event(time() + 60, 'backwpup_cron', array('id' => 'restart')); //start job $backwpup_job_object = new self(); $backwpup_job_object->create('cronrun', (int) $jobid); } if (is_object($backwpup_job_object) && $backwpup_job_object instanceof BackWPup_Job) { $backwpup_job_object->run(); } }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest)); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 'rscusername') && BackWPup_Option::get($jobid, 'rscapikey') && BackWPup_Option::get($jobid, 'rsccontainer')) { try { $conn = new OpenCloud\Rackspace(self::get_auth_url_by_region(BackWPup_Option::get($jobid, 'rscregion')), array('username' => BackWPup_Option::get($jobid, 'rscusername'), 'apiKey' => BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'rscapikey')))); $conn->{$ostore} = $conn->objectStoreService('cloudFiles', BackWPup_Option::get($jobid, 'rscregion'), 'publicURL'); $container = $ostore->getContainer(BackWPup_Option::get($jobid, 'rsccontainer')); $fileobject = $container->getObject($backupfile); $fileobject->delete(); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } } catch (Exception $e) { BackWPup_Admin::message('RSC: ' . $e->getMessage(), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, 60 * 60 * 24 * 7); }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest)); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 's3accesskey') && BackWPup_Option::get($jobid, 's3secretkey') && BackWPup_Option::get($jobid, 's3bucket')) { try { $s3 = Aws\S3\S3Client::factory(array('key' => BackWPup_Option::get($jobid, 's3accesskey'), 'secret' => BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 's3secretkey')), 'region' => BackWPup_Option::get($jobid, 's3region'), 'base_url' => $this->get_s3_base_url(BackWPup_Option::get($jobid, 's3region'), BackWPup_Option::get($jobid, 's3base_url')), 'scheme' => 'https', 'ssl.certificate_authority' => BackWPup::get_plugin_data('cacert'))); $s3->deleteObject(array('Bucket' => BackWPup_Option::get($jobid, 's3bucket'), 'Key' => $backupfile)); //update file list foreach ((array) $files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } unset($s3); } catch (Exception $e) { BackWPup_Admin::message(sprintf(__('S3 Service API: %s', 'backwpup'), $e->getMessage()), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, YEAR_IN_SECONDS); }
/** * */ 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 'runnow': $_GET['jobid'] = (int) $_GET['jobid']; 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 $temp_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE); BackWPup_Admin::message($temp_folder_message, TRUE); //check log folder $log_folder = get_site_option('backwpup_cfg_logfolder'); $log_folder = BackWPup_File::get_absolute_path($log_folder); $log_folder_message = BackWPup_File::check_folder($log_folder); BackWPup_Admin::message($log_folder_message, TRUE); //check backup destinations $job_types = BackWPup::get_job_types(); $job_conf_types = BackWPup_Option::get($_GET['jobid'], 'type'); $creates_file = FALSE; foreach ($job_types as $id => $job_type_class) { if (in_array($id, $job_conf_types) && $job_type_class->creates_file()) { $creates_file = TRUE; break; } } if ($creates_file) { $job_conf_dests = BackWPup_Option::get($_GET['jobid'], 'destinations'); $destinations = 0; /* @var BackWPup_Destinations $dest_class */ foreach (BackWPup::get_registered_destinations() as $id => $dest) { if (!in_array($id, $job_conf_dests) || empty($dest['class'])) { continue; } $dest_class = BackWPup::get_destination($id); $job_settings = BackWPup_Option::get_job($_GET['jobid']); if (!$dest_class->can_run($job_settings)) { BackWPup_Admin::message(sprintf(__('The job "%s" destination "%s" is not configured properly', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name')), $id), TRUE); } $destinations++; } if ($destinations < 1) { BackWPup_Admin::message(sprintf(__('The job "%s" needs properly configured destinations to run!', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))), TRUE); } } //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()); } $response_code = wp_remote_retrieve_response_code($raw_response); if ($response_code < 200 && $response_code > 204) { $test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response)); } else { $response_body = wp_remote_retrieve_body($raw_response); if (FALSE === strstr($response_body, 'BackWPup Test')) { $test_result .= sprintf(__('Not expected HTTP response body: %s', 'backwpup'), esc_attr(strip_tags($response_body))); } } if (!empty($test_result)) { BackWPup_Admin::message($test_result, TRUE); } //only start job if messages empty $log_messages = BackWPup_Admin::get_messages(); if (empty($log_messages)) { $old_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile'); BackWPup_Job::get_jobrun_url('runnow', $_GET['jobid']); usleep(250000); //wait a quarter second $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE); //sleep as long as job not started $i = 0; while ($old_log_file == $new_log_file) { usleep(250000); //wait a quarter second for next try $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE); //wait maximal 10 sec. if ($i >= 40) { BackWPup_Admin::message(sprintf(__('Job “%s” has started, but not responded for 10 seconds.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))), TRUE); break 2; } $i++; } BackWPup_Admin::message(sprintf(__('Job "%s" started.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name')))); } } break; case 'abort': //Abort Job if (!current_user_can('backwpup_jobs_start')) { break; } check_admin_referer('abort-job'); if (!file_exists(BackWPup::get_plugin_data('running_file'))) { break; } //abort BackWPup_Job::user_abort(); BackWPup_Admin::message(__('Job will be terminated.', 'backwpup')); break; default: do_action('backwpup_page_jobs_load', self::$listtable->current_action()); break; } self::$listtable->prepare_items(); }
/** * Save settings form data */ public static function save_post_form() { if (!current_user_can('backwpup_settings')) { return; } //set default options if button clicked if (isset($_POST['default_settings']) && $_POST['default_settings']) { delete_site_option('backwpup_cfg_showadminbar'); delete_site_option('backwpup_cfg_showfoldersize'); delete_site_option('backwpup_cfg_jobstepretry'); delete_site_option('backwpup_cfg_jobmaxexecutiontime'); delete_site_option('backwpup_cfg_jobziparchivemethod'); delete_site_option('backwpup_cfg_loglevel'); delete_site_option('backwpup_cfg_jobwaittimems'); delete_site_option('backwpup_cfg_jobrunauthkey'); delete_site_option('backwpup_cfg_jobdooutput'); delete_site_option('backwpup_cfg_maxlogs'); delete_site_option('backwpup_cfg_gzlogs'); delete_site_option('backwpup_cfg_protectfolders'); delete_site_option('backwpup_cfg_authentication'); delete_site_option('backwpup_cfg_logfolder'); delete_site_option('backwpup_cfg_dropboxappkey'); delete_site_option('backwpup_cfg_dropboxappsecret'); delete_site_option('backwpup_cfg_dropboxsandboxappkey'); delete_site_option('backwpup_cfg_dropboxsandboxappsecret'); delete_site_option('backwpup_cfg_sugarsynckey'); delete_site_option('backwpup_cfg_sugarsyncsecret'); delete_site_option('backwpup_cfg_sugarsyncappid'); BackWPup_Option::default_site_options(); BackWPup_Admin::message(__('Settings reset to default', 'backwpup')); return; } update_site_option('backwpup_cfg_showadminbar', isset($_POST['showadminbar']) ? 1 : 0); update_site_option('backwpup_cfg_showfoldersize', isset($_POST['showfoldersize']) ? 1 : 0); if (100 > $_POST['jobstepretry'] && 0 < $_POST['jobstepretry']) { $_POST['jobstepretry'] = abs((int) $_POST['jobstepretry']); } if (empty($_POST['jobstepretry']) or !is_int($_POST['jobstepretry'])) { $_POST['jobstepretry'] = 3; } update_site_option('backwpup_cfg_jobstepretry', $_POST['jobstepretry']); $max_exe_time = abs((int) $_POST['jobmaxexecutiontime']); if (!is_int($max_exe_time) || $max_exe_time < 0) { $max_exe_time = 0; } elseif ($max_exe_time > 300) { $max_exe_time = 300; } update_site_option('backwpup_cfg_jobmaxexecutiontime', $max_exe_time); update_site_option('backwpup_cfg_jobziparchivemethod', $_POST['jobziparchivemethod'] == '' || $_POST['jobziparchivemethod'] == 'PclZip' || $_POST['jobziparchivemethod'] == 'ZipArchive' ? $_POST['jobziparchivemethod'] : ''); update_site_option('backwpup_cfg_loglevel', in_array($_POST['loglevel'], array('normal_translated', 'normal', 'debug_translated', 'debug')) ? $_POST['loglevel'] : 'normal_translated'); update_site_option('backwpup_cfg_jobwaittimems', $_POST['jobwaittimems']); update_site_option('backwpup_cfg_jobdooutput', isset($_POST['jobdooutput']) ? 1 : 0); update_site_option('backwpup_cfg_maxlogs', abs((int) $_POST['maxlogs'])); update_site_option('backwpup_cfg_gzlogs', isset($_POST['gzlogs']) ? 1 : 0); update_site_option('backwpup_cfg_protectfolders', isset($_POST['protectfolders']) ? 1 : 0); $_POST['jobrunauthkey'] = preg_replace('/[^a-zA-Z0-9]/', '', trim($_POST['jobrunauthkey'])); update_site_option('backwpup_cfg_jobrunauthkey', $_POST['jobrunauthkey']); $_POST['logfolder'] = trailingslashit(str_replace('\\', '/', trim(stripslashes($_POST['logfolder'])))); //set def. folders if (empty($_POST['logfolder']) || $_POST['logfolder'] === '/') { delete_site_option('backwpup_cfg_logfolder'); BackWPup_Option::default_site_options(); } else { update_site_option('backwpup_cfg_logfolder', $_POST['logfolder']); } $authentication = get_site_option('backwpup_cfg_authentication', array('method' => '', 'basic_user' => '', 'basic_password' => '', 'user_id' => 0, 'query_arg' => '')); $authentication['method'] = in_array($_POST['authentication_method'], array('user', 'basic', 'query_arg')) ? $_POST['authentication_method'] : ''; $authentication['basic_user'] = $_POST['authentication_basic_user']; $authentication['basic_password'] = BackWPup_Encryption::encrypt($_POST['authentication_basic_password']); $authentication['query_arg'] = $_POST['authentication_query_arg']; $authentication['user_id'] = (int) $_POST['authentication_user_id']; update_site_option('backwpup_cfg_authentication', $authentication); delete_site_transient('backwpup_cookies'); do_action('backwpup_page_settings_save'); BackWPup_Admin::message(__('Settings saved', 'backwpup')); }
/** * */ 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)); } if (!empty($test_result)) { BackWPup_Admin::message($test_result, TRUE); } //only start job if messages empty $log_messages = BackWPup_Admin::get_messages(); if (empty($log_messages)) { $old_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile'); BackWPup_Job::get_jobrun_url('runnow', $_GET['jobid']); usleep(250000); //wait a quarter second $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE); //sleep as long as job not started $i = 0; while ($old_log_file == $new_log_file) { usleep(250000); //wait a quarter second for next try $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE); //wait maximal 10 sec. if ($i >= 40) { BackWPup_Admin::message(sprintf(__('Job start for "%s" not answered after 10 seconds.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))), TRUE); break 2; } $i++; } BackWPup_Admin::message(sprintf(__('Job "%s" started.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name')))); } } break; case 'abort': //Abort Job if (!current_user_can('backwpup_jobs_start')) { break; } check_admin_referer('abort-job'); if (!file_exists(BackWPup::get_plugin_data('running_file'))) { break; } //abort BackWPup_Job::user_abort(); BackWPup_Admin::message(__('Job will be terminated.', 'backwpup')); break; default: do_action('backwpup_page_jobs_load', self::$listtable->current_action()); break; } self::$listtable->prepare_items(); }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest), array()); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 's3accesskey') && BackWPup_Option::get($jobid, 's3secretkey') && BackWPup_Option::get($jobid, 's3bucket')) { try { $s3 = new AmazonS3(array('key' => BackWPup_Option::get($jobid, 's3accesskey'), 'secret' => BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 's3secretkey')), 'certificate_authority' => TRUE)); $base_url = $this->get_s3_base_url(BackWPup_Option::get($jobid, 's3region'), BackWPup_Option::get($jobid, 's3base_url')); if (stristr($base_url, 'amazonaws.com')) { $s3->set_region(str_replace(array('http://', 'https://'), '', $base_url)); } else { $s3->set_hostname(str_replace(array('http://', 'https://'), '', $base_url)); $s3->allow_hostname_override(FALSE); if (substr($base_url, -1) == '/') { $s3->enable_path_style(TRUE); } } if (stristr($base_url, 'http://')) { $s3->disable_ssl(); } $s3->delete_object(BackWPup_Option::get($jobid, 's3bucket'), $backupfile); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } unset($s3); } catch (Exception $e) { BackWPup_Admin::message(sprintf(__('S3 Service API: %s', 'backwpup'), $e->getMessage()), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, 60 * 60 * 24 * 7); }
/** * @param $jobdest * @param $backupfile */ public function file_delete($jobdest, $backupfile) { $files = get_site_transient('backwpup_' . strtolower($jobdest)); list($jobid, $dest) = explode('_', $jobdest); if (BackWPup_Option::get($jobid, 'dropboxtoken') && BackWPup_Option::get($jobid, 'dropboxsecret')) { try { $dropbox = new BackWPup_Destination_Dropbox_API(BackWPup_Option::get($jobid, 'dropboxroot')); $dropbox->setOAuthTokens(BackWPup_Option::get($jobid, 'dropboxtoken'), BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'dropboxsecret'))); $dropbox->fileopsDelete($backupfile); //update file list foreach ($files as $key => $file) { if (is_array($file) && $file['file'] == $backupfile) { unset($files[$key]); } } unset($dropbox); } catch (Exception $e) { BackWPup_Admin::message('DROPBOX: ' . $e->getMessage(), TRUE); } } set_site_transient('backwpup_' . strtolower($jobdest), $files, 60 * 60 * 24 * 7); }
/** * */ 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' => absint($jobid))); BackWPup_Option::delete_job(absint($jobid)); } } break; case 'copy': //Copy Job if (!current_user_can('backwpup_jobs_edit')) { break; } $old_job_id = absint($_GET['jobid']); check_admin_referer('copy-job_' . $old_job_id); //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($old_job_id, $newjobid, $option); } if ($key === "logfile" || $key === "lastbackupdownloadurl" || $key === "lastruntime" || $key === "lastrun") { continue; } BackWPup_Option::update($newjobid, $key, $option); } break; case 'runnow': $jobid = absint($_GET['jobid']); if ($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 $temp_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE); BackWPup_Admin::message($temp_folder_message, TRUE); //check log folder $log_folder = get_site_option('backwpup_cfg_logfolder'); $log_folder = BackWPup_File::get_absolute_path($log_folder); $log_folder_message = BackWPup_File::check_folder($log_folder); BackWPup_Admin::message($log_folder_message, TRUE); //check backup destinations $job_types = BackWPup::get_job_types(); $job_conf_types = BackWPup_Option::get($jobid, 'type'); $creates_file = FALSE; foreach ($job_types as $id => $job_type_class) { if (in_array($id, $job_conf_types, true) && $job_type_class->creates_file()) { $creates_file = TRUE; break; } } if ($creates_file) { $job_conf_dests = BackWPup_Option::get($jobid, 'destinations'); $destinations = 0; /* @var BackWPup_Destinations $dest_class */ foreach (BackWPup::get_registered_destinations() as $id => $dest) { if (!in_array($id, $job_conf_dests, true) || empty($dest['class'])) { continue; } $dest_class = BackWPup::get_destination($id); $job_settings = BackWPup_Option::get_job($jobid); if (!$dest_class->can_run($job_settings)) { BackWPup_Admin::message(sprintf(__('The job "%s" destination "%s" is not configured properly', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name')), $id), TRUE); } $destinations++; } if ($destinations < 1) { BackWPup_Admin::message(sprintf(__('The job "%s" needs properly configured destinations to run!', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name'))), TRUE); } } //only start job if messages empty $log_messages = BackWPup_Admin::get_messages(); if (empty($log_messages)) { $old_log_file = BackWPup_Option::get($jobid, 'logfile'); BackWPup_Job::get_jobrun_url('runnow', $jobid); usleep(250000); //wait a quarter second $new_log_file = BackWPup_Option::get($jobid, 'logfile', null, false); //sleep as long as job not started $i = 0; while ($old_log_file === $new_log_file) { usleep(250000); //wait a quarter second for next try $new_log_file = BackWPup_Option::get($jobid, 'logfile', null, false); //wait maximal 10 sec. if ($i >= 40) { BackWPup_Admin::message(sprintf(__('Job "%s" has started, but not responded for 10 seconds. Please check <a href="%s">information</a>.', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name')), network_admin_url('admin.php') . '?page=backwpupsettings#backwpup-tab-information'), true); break 2; } $i++; } BackWPup_Admin::message(sprintf(__('Job "%s" started.', 'backwpup'), esc_attr(BackWPup_Option::get($jobid, 'name')))); } } break; case 'abort': //Abort Job if (!current_user_can('backwpup_jobs_start')) { break; } check_admin_referer('abort-job'); if (!file_exists(BackWPup::get_plugin_data('running_file'))) { break; } //abort BackWPup_Job::user_abort(); BackWPup_Admin::message(__('Job will be terminated.', 'backwpup')); break; default: do_action('backwpup_page_jobs_load', self::$listtable->current_action()); break; } self::$listtable->prepare_items(); }