function backwpup_jobedit_metabox_save($jobvalue) { ?> <div class="submitbox" id="submitjobedit"> <div id="minor-publishing"> <div id="minor-publishing-actions"> <div id="preview-action"> </div> <div class="clear"></div> </div> <div id="misc-publishing-actions"> <div class="misc-pub-section misc-pub-section-last"> <?php foreach (backwpup_backup_types() as $type) { echo "<input class=\"jobtype-select checkbox\" id=\"jobtype-select-" . $type . "\" type=\"checkbox\"" . checked(true, in_array($type, explode('+', $jobvalue['type'])), false) . " name=\"type[]\" value=\"" . $type . "\"/> " . backwpup_backup_types($type); } if (!function_exists('curl_init')) { echo '<br /><strong style="color:red;">' . __('PHP curl functions not available! Most backup destinations deaktivated!', 'backwpup') . '</strong>'; } ?> </div> </div> </div> <div id="major-publishing-actions"> <div id="delete-action"> <a class="submitdelete deletion" href="<?php echo wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpup&action=delete&jobs[]=' . $jobvalue['jobid'], 'bulk-jobs'); ?> " onclick="if ( confirm('<?php echo esc_js(__("You are about to delete this Job. \n 'Cancel' to stop, 'OK' to delete.", "backwpup")); ?> ') ) { return true;}return false;"><?php _e('Delete', 'backwpup'); ?> </a> </div> <div id="publishing-action"> <?php submit_button(__('Save Changes', 'backwpup'), 'primary', 'savebackwpup', false, array('tabindex' => '2', 'accesskey' => 'p')); ?> </div> <div class="clear"></div> </div> </div> <?php }
function single_row($logfile, $logdata, $style = '') { list($columns, $hidden, $sortable) = $this->get_column_info(); $r = "<tr id='" . basename($logfile) . "'{$style}>"; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= '<th scope="row" class="check-column"><input type="checkbox" name="logfiles[]" value="' . esc_attr(basename($logfile)) . '" /></th>'; break; case 'id': $r .= "<td {$attributes}>" . $logdata['jobid'] . "</td>"; break; case 'type': $r .= "<td {$attributes}>"; $r .= backwpup_backup_types($logdata['type'], false); $r .= "</td>"; break; case 'log': $r .= "<td {$attributes}><strong><a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupworking&logfile=' . $logfile, 'view-log_' . basename($logfile)) . "\" title=\"" . __('View log', 'backwpup') . "\">" . backwpup_date_i18n(get_option('date_format') . " @ " . get_option('time_format'), $logdata['logtime']) . ": <i>" . $logdata['name'] . "</i></a></strong>"; $actions = array(); $actions['view'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupworking&logfile=' . $logfile, 'view-log_' . basename($logfile)) . "\">" . __('View', 'backwpup') . "</a>"; $actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpuplogs&action=delete&paged=' . $this->get_pagenum() . '&logfiles[]=' . basename($logfile), 'bulk-logs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete') . "</a>"; $actions['download'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpuplogs&action=download&file=' . $logfile, 'download-backup_' . basename($logfile)) . "\">" . __('Download', 'backwpup') . "</a>"; $r .= $this->row_actions($actions); $r .= "</td>"; break; case 'status': $r .= "<td {$attributes}>"; if ($logdata['errors'] > 0) { $r .= str_replace('%d', $logdata['errors'], '<span style="color:red;font-weight:bold;">' . _n("%d ERROR", "%d ERRORS", $logdata['errors'], 'backwpup') . '</span><br />'); } if ($logdata['warnings'] > 0) { $r .= str_replace('%d', $logdata['warnings'], '<span style="color:#e66f00;font-weight:bold;">' . _n("%d WARNING", "%d WARNINGS", $logdata['warnings'], 'backwpup') . '</span><br />'); } if ($logdata['errors'] == 0 and $logdata['warnings'] == 0) { $r .= '<span style="color:green;font-weight:bold;">' . __('O.K.', 'backwpup') . '</span>'; } $r .= "</td>"; break; case 'size': $r .= "<td {$attributes}>"; if (!empty($logdata['backupfilesize'])) { $r .= backwpup_formatBytes($logdata['backupfilesize']); } else { $r .= __('only Log', 'backwpup'); } $r .= "</td>"; break; case 'runtime': $r .= "<td {$attributes}>"; $r .= $logdata['runtime'] . ' ' . __('sec.', 'backwpup'); $r .= "</td>"; break; } } $r .= '</tr>'; return $r; }
function backwpup_jobstart($jobid = '', $cronstart = false) { global $wpdb, $wp_version; $jobid = (int) trim($jobid); if (empty($jobid) or !is_integer($jobid)) { return false; } //check if a job running if ($infile = backwpup_get_working_file()) { trigger_error(__("A job already running!", "backwpup"), E_USER_WARNING); return false; } //clean var $backwpup_static = array(); $backwpup_working = array(); //get temp dir $backwpup_static['TEMPDIR'] = backwpup_get_temp(); if (!is_writable($backwpup_static['TEMPDIR'])) { trigger_error(__("Temp dir not writeable", "backwpup"), E_USER_ERROR); return false; } else { //clean up old temp files if ($dir = opendir($backwpup_static['TEMPDIR'])) { while (($file = readdir($dir)) !== false) { if (is_readable($backwpup_static['TEMPDIR'] . $file) and is_file($backwpup_static['TEMPDIR'] . $file)) { if ($file != '.' and $file != '..') { unlink($backwpup_static['TEMPDIR'] . $file); } } } closedir($dir); } //create .htaccess for apache and index.php for folder security if (!is_file($backwpup_static['TEMPDIR'] . '.htaccess')) { file_put_contents($backwpup_static['TEMPDIR'] . '.htaccess', "<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>"); } if (!is_file($backwpup_static['TEMPDIR'] . 'index.php')) { file_put_contents($backwpup_static['TEMPDIR'] . 'index.php', "\n"); } } //Write running file to prevent dobble runnging file_put_contents($backwpup_static['TEMPDIR'] . '.running', serialize(array('timestamp' => time(), 'JOBID' => $jobid, 'LOGFILE' => '', 'STEPSPERSENT' => 0, 'STEPPERSENT' => 0, 'WORKING' => array('PID' => 0)))); //Set needed WP vars $backwpup_static['WP']['DB_NAME'] = DB_NAME; $backwpup_static['WP']['DB_USER'] = DB_USER; $backwpup_static['WP']['DB_PASSWORD'] = DB_PASSWORD; $backwpup_static['WP']['DB_HOST'] = DB_HOST; $backwpup_static['WP']['DB_CHARSET'] = DB_CHARSET; $backwpup_static['WP']['DB_COLLATE'] = DB_COLLATE; $backwpup_static['WP']['OPTIONS_TABLE'] = $wpdb->options; $backwpup_static['WP']['TABLE_PREFIX'] = $wpdb->prefix; $backwpup_static['WP']['BLOGNAME'] = get_bloginfo('name'); if (defined('WP_SITEURL')) { $backwpup_static['WP']['SITEURL'] = trailingslashit(WP_SITEURL); } else { $backwpup_static['WP']['SITEURL'] = trailingslashit(get_option('siteurl')); } $backwpup_static['WP']['TIMEDIFF'] = get_option('gmt_offset') * 3600; $backwpup_static['WP']['WPLANG'] = WPLANG; $backwpup_static['WP']['VERSION'] = $wp_version; $backwpup_static['WP']['CHARSET'] = get_option('blog_charset'); $backwpup_static['WP']['MEMORY_LIMIT'] = WP_MEMORY_LIMIT; if (defined('ALTERNATE_WP_CRON')) { $backwpup_static['WP']['ALTERNATE_CRON'] = ALTERNATE_WP_CRON; } else { $backwpup_static['WP']['ALTERNATE_CRON'] = false; } //WP folder $backwpup_static['WP']['ABSPATH'] = rtrim(str_replace('\\', '/', ABSPATH), '/') . '/'; $backwpup_static['WP']['WP_CONTENT_DIR'] = rtrim(str_replace('\\', '/', WP_CONTENT_DIR), '/') . '/'; $backwpup_static['WP']['WP_PLUGIN_DIR'] = rtrim(str_replace('\\', '/', WP_PLUGIN_DIR), '/') . '/'; $backwpup_static['WP']['WP_THEMES_DIR'] = rtrim(str_replace('\\', '/', trailingslashit(WP_CONTENT_DIR) . 'themes/'), '/') . '/'; $backwpup_static['WP']['WP_UPLOAD_DIR'] = backwpup_get_upload_dir(); $backwpup_static['WP']['WPINC'] = WPINC; $backwpup_static['WP']['MULTISITE'] = is_multisite(); $backwpup_static['WP']['ADMINURL'] = backwpup_admin_url('admin.php'); //Set plugin data $backwpup_static['BACKWPUP']['PLUGIN_BASEDIR'] = BACKWPUP_PLUGIN_BASEDIR; $backwpup_static['BACKWPUP']['VERSION'] = BACKWPUP_VERSION; $backwpup_static['BACKWPUP']['BACKWPUP_DESTS'] = BACKWPUP_DESTS; //Set config data $backwpup_static['CFG'] = get_option('backwpup'); //check exists gzip functions if (!function_exists('gzopen')) { $backwpup_static['CFG']['gzlogs'] = false; } if (!class_exists('ZipArchive')) { $backwpup_static['CFG']['phpzip'] = false; } //Check working times if (empty($backwpup_static['CFG']['jobstepretry']) or !is_int($backwpup_static['CFG']['jobstepretry']) or $backwpup_static['CFG']['jobstepretry'] > 100) { $backwpup_static['CFG']['jobstepretry'] = 3; } if (empty($backwpup_static['CFG']['jobscriptretry']) or !is_int($backwpup_static['CFG']['jobscriptretry']) or $backwpup_static['CFG']['jobscriptretry'] > 100) { $backwpup_static['CFG']['jobscriptretry'] = 5; } if (empty($backwpup_static['CFG']['jobscriptruntime']) or !is_int($backwpup_static['CFG']['jobscriptruntime']) or $backwpup_static['CFG']['jobscriptruntime'] > 100) { $backwpup_static['CFG']['jobscriptruntime'] = ini_get('max_execution_time'); } if (empty($backwpup_static['CFG']['jobscriptruntimelong']) or !is_int($backwpup_static['CFG']['jobscriptruntimelong']) or $backwpup_static['CFG']['jobscriptruntimelong'] > 1000) { $backwpup_static['CFG']['jobscriptruntimelong'] = 300; } //Set job data $backwpup_static['JOB'] = backwpup_get_job_vars($jobid); //STATIC data $backwpup_static['JOBRUNURL'] = BACKWPUP_PLUGIN_BASEURL . '/job/job_run.php'; //Setup Logs dir $backwpup_static['CFG']['dirlogs'] = rtrim(str_replace('\\', '/', $backwpup_static['CFG']['dirlogs']), '/') . '/'; if (!is_dir($backwpup_static['CFG']['dirlogs'])) { if (!mkdir(rtrim($backwpup_static['CFG']['dirlogs'], '/'), 0777, true)) { trigger_error(printf(__('Can not create folder for log files: %s', 'backwpup'), $backwpup_static['CFG']['dirlogs']), E_USER_ERROR); return false; } } //create .htaccess for apache and index.php for folder security if (!is_file($backwpup_static['CFG']['dirlogs'] . '.htaccess')) { file_put_contents($backwpup_static['CFG']['dirlogs'] . '.htaccess', "<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>"); } if (!is_file($backwpup_static['CFG']['dirlogs'] . 'index.php')) { file_put_contents($backwpup_static['CFG']['dirlogs'] . 'index.php', "\n"); } if (!is_writable($backwpup_static['CFG']['dirlogs'])) { trigger_error(__("Log folder not writeable!", "backwpup"), E_USER_ERROR); return false; } //set Logfile $backwpup_static['LOGFILE'] = $backwpup_static['CFG']['dirlogs'] . 'backwpup_log_' . backwpup_date_i18n('Y-m-d_H-i-s') . '.html'; //create log file $fd = fopen($backwpup_static['LOGFILE'], 'w'); //Create log file header fwrite($fd, "<html>\n<head>\n"); fwrite($fd, "<meta name=\"robots\" content=\"noindex, nofollow\" />\n"); fwrite($fd, "<meta name=\"backwpup_version\" content=\"" . BACKWPUP_VERSION . "\" />\n"); fwrite($fd, "<meta name=\"backwpup_logtime\" content=\"" . time() . "\" />\n"); fwrite($fd, str_pad("<meta name=\"backwpup_errors\" content=\"0\" />", 100) . "\n"); fwrite($fd, str_pad("<meta name=\"backwpup_warnings\" content=\"0\" />", 100) . "\n"); fwrite($fd, "<meta name=\"backwpup_jobid\" content=\"" . $backwpup_static['JOB']['jobid'] . "\" />\n"); fwrite($fd, "<meta name=\"backwpup_jobname\" content=\"" . $backwpup_static['JOB']['name'] . "\" />\n"); fwrite($fd, "<meta name=\"backwpup_jobtype\" content=\"" . $backwpup_static['JOB']['type'] . "\" />\n"); fwrite($fd, str_pad("<meta name=\"backwpup_backupfilesize\" content=\"0\" />", 100) . "\n"); fwrite($fd, str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />", 100) . "\n"); fwrite($fd, "<style type=\"text/css\">\n"); fwrite($fd, ".timestamp {background-color:grey;}\n"); fwrite($fd, ".warning {background-color:yellow;}\n"); fwrite($fd, ".error {background-color:red;}\n"); fwrite($fd, "#body {font-family:monospace;font-size:12px;white-space:nowrap;}\n"); fwrite($fd, "</style>\n"); fwrite($fd, "<title>" . sprintf(__('BackWPup log for %1$s from %2$s at %3$s', 'backwpup'), $backwpup_static['JOB']['name'], backwpup_date_i18n(get_option('date_format')), backwpup_date_i18n(get_option('time_format'))) . "</title>\n</head>\n<body id=\"body\">\n"); fclose($fd); //Set job start settings $jobs = get_option('backwpup_jobs'); $jobs[$backwpup_static['JOB']['jobid']]['starttime'] = time(); //set start time for job $backwpup_static['JOB']['starttime'] = $jobs[$backwpup_static['JOB']['jobid']]['starttime']; $jobs[$backwpup_static['JOB']['jobid']]['logfile'] = $backwpup_static['LOGFILE']; //Set current logfile $jobs[$backwpup_static['JOB']['jobid']]['cronnextrun'] = backwpup_cron_next($jobs[$backwpup_static['JOB']['jobid']]['cron']); //set next run $backwpup_static['JOB']['cronnextrun'] = $jobs[$backwpup_static['JOB']['jobid']]['cronnextrun']; $jobs[$backwpup_static['JOB']['jobid']]['lastbackupdownloadurl'] = ''; $backwpup_static['JOB']['lastbackupdownloadurl'] = ''; update_option('backwpup_jobs', $jobs); //Save job Settings //Set todo $backwpup_static['TODO'] = explode('+', $backwpup_static['JOB']['type']); //only for jos that makes backups if (in_array('FILE', $backwpup_static['TODO']) or in_array('DB', $backwpup_static['TODO']) or in_array('WPEXP', $backwpup_static['TODO'])) { //make emty file list $backwpup_working['FILELIST'] = array(); $backwpup_working['ALLFILESIZE'] = 0; //set Backup Dir if not set if (empty($backwpup_static['JOB']['backupdir'])) { $backwpup_static['JOB']['backupdir'] = $backwpup_static['TEMPDIR']; } else { //clear path $backwpup_static['JOB']['backupdir'] = rtrim(str_replace('\\', '/', $backwpup_static['JOB']['backupdir']), '/') . '/'; //create backup dir if it not exists if (!is_dir($backwpup_static['JOB']['backupdir'])) { if (!mkdir(rtrim($backwpup_static['JOB']['backupdir'], '/'), 0777, true)) { trigger_error(sprintf(__('Can not create folder for backups: %1$s', 'backwpup'), $backwpup_static['JOB']['backupdir']), E_USER_ERROR); return false; } } //create .htaccess and index.php for folder security if (!is_file($backwpup_static['JOB']['backupdir'] . '.htaccess')) { file_put_contents($backwpup_static['JOB']['backupdir'] . '.htaccess', "<Files \"*\">\n<IfModule mod_access.c>\nDeny from all\n</IfModule>\n<IfModule !mod_access_compat>\n<IfModule mod_authz_host.c>\nDeny from all\n</IfModule>\n</IfModule>\n<IfModule mod_access_compat>\nDeny from all\n</IfModule>\n</Files>"); } if (!is_file($backwpup_static['JOB']['backupdir'] . 'index.php')) { file_put_contents($backwpup_static['JOB']['backupdir'] . 'index.php', "\n"); } } //check backup dir if (!is_writable($backwpup_static['JOB']['backupdir'])) { trigger_error(__("Backup folder not writeable!", "backwpup"), E_USER_ERROR); return false; } //set Backup file Name $backwpup_static['backupfile'] = $backwpup_static['JOB']['fileprefix'] . backwpup_date_i18n('Y-m-d_H-i-s') . $backwpup_static['JOB']['fileformart']; } $backwpup_static['CRONSTART'] = $cronstart; $backwpup_working['NONCE'] = wp_create_nonce('BackWPupJob'); $backwpup_working['PID'] = 0; $backwpup_working['WARNING'] = 0; $backwpup_working['ERROR'] = 0; $backwpup_working['RESTART'] = 0; $backwpup_working['STEPSDONE'] = array(); $backwpup_working['STEPTODO'] = 0; $backwpup_working['STEPDONE'] = 0; //build working steps $backwpup_working['STEPS'] = array(); //setup job steps if (in_array('DB', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'DB_DUMP'; } if (in_array('WPEXP', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'WP_EXPORT'; } if (in_array('FILE', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'FILE_LIST'; } if (in_array('DB', $backwpup_static['TODO']) or in_array('WPEXP', $backwpup_static['TODO']) or in_array('FILE', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'BACKUP_CREATE'; //ADD Destinations if (!empty($backwpup_static['JOB']['backupdir']) and $backwpup_static['JOB']['backupdir'] != '/' and $backwpup_static['JOB']['backupdir'] != $backwpup_static['TEMPDIR']) { $backwpup_working['STEPS'][] = 'DEST_FOLDER'; } if (!empty($backwpup_static['JOB']['mailaddress'])) { $backwpup_working['STEPS'][] = 'DEST_MAIL'; } if (!empty($backwpup_static['JOB']['ftphost']) and !empty($backwpup_static['JOB']['ftpuser']) and !empty($backwpup_static['JOB']['ftppass']) and in_array('FTP', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_FTP'; } if (!empty($backwpup_static['JOB']['dropetoken']) and !empty($backwpup_static['JOB']['dropesecret']) and in_array('DROPBOX', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_DROPBOX'; } if (!empty($backwpup_static['JOB']['sugarrefreshtoken']) and !empty($backwpup_static['JOB']['sugarroot']) and in_array('SUGARSYNC', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_SUGARSYNC'; } if (!empty($backwpup_static['JOB']['awsAccessKey']) and !empty($backwpup_static['JOB']['awsSecretKey']) and !empty($backwpup_static['JOB']['awsBucket']) and in_array('S3', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_S3'; } if (!empty($backwpup_static['JOB']['GStorageAccessKey']) and !empty($backwpup_static['JOB']['GStorageSecret']) and !empty($backwpup_static['JOB']['GStorageBucket']) and in_array('GSTORAGE', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_GSTORAGE'; } if (!empty($backwpup_static['JOB']['rscUsername']) and !empty($backwpup_static['JOB']['rscAPIKey']) and !empty($backwpup_static['JOB']['rscContainer']) and in_array('RSC', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_RSC'; } if (!empty($backwpup_static['JOB']['msazureHost']) and !empty($backwpup_static['JOB']['msazureAccName']) and !empty($backwpup_static['JOB']['msazureKey']) and !empty($backwpup_static['JOB']['msazureContainer']) and in_array('MSAZURE', explode(',', strtoupper(BACKWPUP_DESTS)))) { $backwpup_working['STEPS'][] = 'DEST_MSAZURE'; } } if (in_array('CHECK', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'DB_CHECK'; } if (in_array('OPTIMIZE', $backwpup_static['TODO'])) { $backwpup_working['STEPS'][] = 'DB_OPTIMIZE'; } $backwpup_working['STEPS'][] = 'JOB_END'; //mark all as not done foreach ($backwpup_working['STEPS'] as $step) { $backwpup_working[$step]['DONE'] = false; } //write working file file_put_contents($backwpup_static['TEMPDIR'] . '.running', serialize(array('timestamp' => time(), 'JOBID' => $backwpup_static['JOB']['jobid'], 'LOGFILE' => $backwpup_static['LOGFILE'], 'STEPSPERSENT' => 0, 'STEPPERSENT' => 0, 'WORKING' => $backwpup_working))); //write static file file_put_contents($backwpup_static['TEMPDIR'] . '.static', serialize($backwpup_static)); //Run job $httpauthheader = ''; if (!empty($backwpup_static['CFG']['httpauthuser']) and !empty($backwpup_static['CFG']['httpauthpassword'])) { $httpauthheader = array('Authorization' => 'Basic ' . base64_encode($backwpup_static['CFG']['httpauthuser'] . ':' . backwpup_base64($backwpup_static['CFG']['httpauthpassword']))); } if (!$backwpup_static['WP']['ALTERNATE_CRON']) { wp_remote_post($backwpup_static['JOBRUNURL'], array('timeout' => 3, 'blocking' => false, 'sslverify' => false, 'headers' => $httpauthheader, 'body' => array('nonce' => $backwpup_working['NONCE'], 'type' => 'start'), 'user-agent' => 'BackWPup')); } return $backwpup_static['LOGFILE']; }
$activejobs = true; } } if ($activejobs and false === wp_next_scheduled('backwpup_cron')) { wp_schedule_event(time(), 'backwpup_int', 'backwpup_cron'); } if (!$activejobs and false !== wp_next_scheduled('backwpup_cron')) { wp_clear_scheduled_hook('backwpup_cron'); } //get dropbox auth if (isset($_POST['dropboxauth']) and !empty($_POST['dropboxauth'])) { require_once dirname(__FILE__) . '/../libs/dropbox.php'; $dropbox = new backwpup_Dropbox('dropbox'); // let the user authorize (user will be redirected) $response = $dropbox->oAuthAuthorize(backwpup_admin_url('admin.php') . '?page=backwpupeditjob&jobid=' . $jobvalues['jobid'] . '&dropboxauth=AccessToken&_wpnonce=' . wp_create_nonce('edit-job')); // save oauth_token_secret set_transient('backwpup_dropboxrequest', array('oAuthRequestToken' => $response['oauth_token'], 'oAuthRequestTokenSecret' => $response['oauth_token_secret']), 600); //forward to auth page wp_redirect($response['authurl']); } $_POST['jobid'] = $jobvalues['jobid']; $backwpup_message .= str_replace('%1', $jobvalues['name'], __('Job \'%1\' changes saved.', 'backwpup')) . ' <a href="' . backwpup_admin_url('admin.php') . '?page=backwpup">' . __('Jobs overview.', 'backwpup') . '</a>'; } //load java wp_enqueue_script('common'); wp_enqueue_script('wp-lists'); wp_enqueue_script('postbox'); //add columns add_screen_option('layout_columns', array('max' => 2, 'default' => 2)); //add Help backwpup_contextual_help();
function single_row($jobvalue, $runningfile, $style = '') { global $mode; list($columns, $hidden, $sortable) = $this->get_column_info(); $r = "<tr id=\"jodid-" . $jobvalue["jobid"] . "\"" . $style . ">"; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= '<th scope="row" class="check-column"><input type="checkbox" name="jobs[]" value="' . esc_attr($jobvalue["jobid"]) . '" /></th>'; break; case 'id': $r .= "<td {$attributes}>" . $jobvalue["jobid"] . "</td>"; break; case 'jobname': $r .= "<td {$attributes}><strong><a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupeditjob&jobid=' . $jobvalue["jobid"], 'edit-job') . "\" title=\"" . __('Edit:', 'backwpup') . esc_html($jobvalue['name']) . "\">" . esc_html($jobvalue['name']) . "</a></strong>"; $actions = array(); if ($runningfile == false) { $actions['edit'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupeditjob&jobid=' . $jobvalue["jobid"], 'edit-job') . "\">" . __('Edit', 'backwpup') . "</a>"; $actions['copy'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpup&action=copy&jobid=' . $jobvalue["jobid"], 'copy-job_' . $jobvalue["jobid"]) . "\">" . __('Copy', 'backwpup') . "</a>"; $actions['export'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpup&action=export&jobs[]=' . $jobvalue["jobid"], 'bulk-jobs') . "\">" . __('Export', 'backwpup') . "</a>"; $actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpup&action=delete&jobs[]=' . $jobvalue["jobid"], 'bulk-jobs') . "\" onclick=\"return showNotice.warn();\">" . __('Delete', 'backwpup') . "</a>"; $actions['runnow'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupworking&action=runnow&jobid=' . $jobvalue["jobid"], 'runnow-job_' . $jobvalue["jobid"]) . "\">" . __('Run Now', 'backwpup') . "</a>"; } else { if ($runningfile['JOBID'] == $jobvalue["jobid"]) { $actions['working'] = "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupworking', '') . "\">" . __('View!', 'backwpup') . "</a>"; $actions['abort'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpup&action=abort', 'abort-job') . "\">" . __('Abort!', 'backwpup') . "</a>"; } } $r .= $this->row_actions($actions); $r .= '</td>'; break; case 'type': $r .= "<td {$attributes}>"; $r .= backwpup_backup_types($jobvalue['type'], false); $r .= "</td>"; break; case 'info': $r .= "<td {$attributes}>"; $r .= "<img class=\"waiting\" src=\"" . esc_url(backwpup_admin_url('images/wpspin_light.gif')) . "\" id=\"image-wait-" . $jobvalue["jobid"] . "\" />"; $r .= "</td>"; break; case 'next': $r .= "<td {$attributes}>"; if ($runningfile['JOBID'] == $jobvalue["jobid"] and $runningfile != false) { $runtime = time() - $jobvalue['starttime']; $r .= __('Running since:', 'backwpup') . ' ' . $runtime . ' ' . __('sec.', 'backwpup'); } elseif ($jobvalue['activated']) { $r .= date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $jobvalue['cronnextrun']); } else { $r .= __('Inactive', 'backwpup'); } if ('excerpt' == $mode) { $r .= '<br />' . __('<a href="http://wikipedia.org/wiki/Cron" target="_blank">Cron</a>:', 'backwpup') . ' ' . $jobvalue['cron']; } $r .= "</td>"; break; case 'last': $r .= "<td {$attributes}>"; if (isset($jobvalue['lastrun']) && $jobvalue['lastrun']) { $r .= backwpup_date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), $jobvalue['lastrun']); if (isset($jobvalue['lastruntime'])) { $r .= '<br />' . __('Runtime:', 'backwpup') . ' ' . $jobvalue['lastruntime'] . ' ' . __('sec.', 'backwpup') . '<br />'; } } else { $r .= __('None', 'backwpup'); } if (!empty($jobvalue['lastbackupdownloadurl'])) { $r .= "<a href=\"" . wp_nonce_url($jobvalue['lastbackupdownloadurl'], 'download-backup') . "\" title=\"" . __('Download last Backup', 'backwpup') . "\">" . __('Download', 'backwpup') . "</a> | "; } if (!empty($jobvalue['logfile'])) { $r .= "<a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupworking&logfile=' . $jobvalue['logfile'], 'view-log_' . basename($jobvalue['logfile'])) . "\" title=\"" . __('View last Log', 'backwpup') . "\">" . __('Log', 'backwpup') . "</a><br />"; } $r .= "</td>"; break; } } $r .= '</tr>'; return $r; }
echo "<h2>" . esc_html(__('BackWPup Job Settings', 'backwpup')) . " <a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupeditjob', 'edit-job') . "\" class=\"add-new-h2\">" . esc_html__('Add New', 'backwpup') . "</a></h2>"; ?> <?php if (isset($backwpup_message) and !empty($backwpup_message)) { ?> <div id="message" class="updated"><p><?php echo $backwpup_message; ?> </p></div> <?php } ?> <form name="editjob" id="editjob" method="post" action="<?php echo backwpup_admin_url('admin.php') . '?page=backwpupeditjob'; ?> "> <input type="hidden" name="jobid" value="<?php echo $jobvalue['jobid']; ?> " /> <?php wp_nonce_field('edit-job'); wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); wp_nonce_field('backwpupeditjob_ajax_nonce', 'backwpupeditjobajaxnonce', false); ?> <div id="poststuff" class="metabox-holder<?php echo 2 == $screen_layout_columns ? ' has-right-sidebar' : ''; ?>
function backwpup_add_adminbar() { global $wp_admin_bar; $cfg = get_option('backwpup'); //Load Settings if (!$cfg['showadminbar'] || !current_user_can(BACKWPUP_USER_CAPABILITY) || !is_super_admin() || !is_admin_bar_showing()) { return; } /* Add the main siteadmin menu item */ $wp_admin_bar->add_menu(array('id' => 'backwpup', 'title' => __('BackWPup', 'textdomain'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpup')); if (backwpup_get_working_file()) { $wp_admin_bar->add_menu(array('parent' => 'backwpup', 'title' => __('See Working!', 'backwpup'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpupworking')); } $wp_admin_bar->add_menu(array('parent' => 'backwpup', 'title' => __('Jobs', 'backwpup'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpup')); $wp_admin_bar->add_menu(array('parent' => 'backwpup', 'title' => __('Logs', 'backwpup'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpuplogs')); $wp_admin_bar->add_menu(array('parent' => 'backwpup', 'title' => __('Backups', 'backwpup'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpupbackups')); $wp_admin_bar->add_menu(array('parent' => 'new-content', 'title' => __('BackWPup Job', 'backwpup'), 'href' => backwpup_admin_url('admin.php') . '?page=backwpupeditjob')); }
function single_row($backup, $jobvalue, $style = '') { list($columns, $hidden, $sortable) = $this->get_column_info(); $r = "<tr {$style}>"; foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= '<th scope="row" class="check-column"><input type="checkbox" name="backupfiles[]" value="' . esc_attr($backup['file']) . '" /></th>'; break; case 'file': $r .= "<td {$attributes}><strong>" . $backup['filename'] . "</strong>"; $actions = array(); $actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupbackups&action=delete&jobdest=' . $this->jobid . ',' . $this->dest . '&paged=' . $this->get_pagenum() . '&backupfiles[]=' . esc_attr($backup['file']), 'bulk-backups') . "\" onclick=\"if ( confirm('" . esc_js(__("You are about to delete this Backup Archive. \n 'Cancel' to stop, 'OK' to delete.", "backwpup")) . "') ) { return true;}return false;\">" . __('Delete', 'backwpup') . "</a>"; $actions['download'] = "<a href=\"" . wp_nonce_url($backup['downloadurl'], 'download-backup') . "\">" . __('Download', 'backwpup') . "</a>"; $r .= $this->row_actions($actions); $r .= "</td>"; break; case 'folder': $r .= "<td {$attributes}>"; $r .= $backup['folder']; $r .= "</td>"; break; case 'size': $r .= "<td {$attributes}>"; if (!empty($backup['filesize']) and $backup['filesize'] != -1) { $r .= backwpup_formatBytes($backup['filesize']); } else { $r .= __('?', 'backwpup'); } $r .= "</td>"; break; case 'time': $r .= "<td {$attributes}>"; $r .= backwpup_date_i18n(get_option('date_format'), $backup['time']) . '<br />' . backwpup_date_i18n(get_option('time_format'), $backup['time']); $r .= "</td>"; break; } } $r .= '</tr>'; return $r; }
<?php if (!defined('ABSPATH')) { die; } echo "<div class=\"wrap\">"; screen_icon(); echo "<h2>" . esc_html(__('BackWPup Jobs', 'backwpup')) . " <a href=\"" . wp_nonce_url(backwpup_admin_url('admin.php') . '?page=backwpupeditjob', 'edit-job') . "\" class=\"add-new-h2\">" . esc_html__('Add New', 'backwpup') . "</a></h2>"; if (isset($backwpup_message) and !empty($backwpup_message)) { echo "<div id=\"message\" class=\"updated\"><p>" . $backwpup_message . "</p></div>"; } echo "<form id=\"posts-filter\" action=\"\" method=\"get\">"; echo "<input type=\"hidden\" name=\"page\" value=\"backwpup\" />"; wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', false); $backwpup_listtable->display(); echo "<div id=\"ajax-response\"></div>"; echo "</form>"; echo "</div>";
<?php if (!defined('ABSPATH')) { die; } $cfg = get_option('backwpup'); echo "<div class=\"wrap\">"; screen_icon(); echo "<h2>" . esc_html(__('BackWPup Settings', 'backwpup')) . "</h2>"; if (isset($backwpup_message) and !empty($backwpup_message)) { echo "<div id=\"message\" class=\"updated\"><p>" . $backwpup_message . "</p></div>"; } echo "<form id=\"posts-filter\" action=\"" . backwpup_admin_url('admin.php') . "?page=backwpupsettings\" method=\"post\">"; wp_nonce_field('backwpup-cfg'); ?> <input type="hidden" name="action" value="update" /> <h3><?php _e('Send Mail', 'backwpup'); ?> </h3> <p><?php _e('Here you can set the options for email sending. The settings will be used in jobs for sending backups via email or for sending log files.', 'backwpup'); ?> </p> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="mailsndemail"><?php _e('Sender email', 'backwpup'); ?> </label></th> <td><input name="mailsndemail" type="text" id="mailsndemail" value="<?php
<?php if (!defined('ABSPATH')) { die; } echo "<div class=\"wrap\">"; screen_icon(); echo "<h2>" . esc_html(__('BackWPup Tools', 'backwpup')) . "</h2>"; if (isset($backwpup_message) and !empty($backwpup_message)) { echo "<div id=\"message\" class=\"updated\"><p>" . $backwpup_message . "</p></div>"; } echo "<form id=\"posts-filter\" enctype=\"multipart/form-data\" action=\"" . backwpup_admin_url('admin.php') . "?page=backwpuptools\" method=\"post\">"; wp_nonce_field('backwpup-tools'); ?> <input type="hidden" name="action" value="update" /> <h3><?php _e('Database restore', 'backwpup'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><label for="mailsndemail"><?php _e('DB Restore', 'backwpup'); ?> </label></th> <td> <?php if (isset($_POST['dbrestore']) and $_POST['dbrestore'] == __('Restore', 'backwpup') and is_file(trim($_POST['sqlfile']))) { check_admin_referer('backwpup-tools'); $sqlfile = trim($_POST['sqlfile']); require dirname(__FILE__) . '/tools/db_restore.php';