Beispiel #1
0
 /**
  * Display a List of Jobs
  *
  * @synopsis jobs
  */
 public function jobs($args, $assoc_args)
 {
     $jobids = BackWPup_Option::get_job_ids();
     WP_CLI::line(__('List of jobs', 'backwpup'));
     WP_CLI::line('----------------------------------------------------------------------');
     foreach ($jobids as $jobid) {
         WP_CLI::line(sprintf(__('ID: %1$d Name: %2$s', 'backwpup'), $jobid, BackWPup_Option::get($jobid, 'name')));
     }
 }
Beispiel #2
0
 /**
  * Display a List of Jobs
  *
  */
 public function jobs($args, $assoc_args)
 {
     $formatter_args = array('format' => 'table', 'fields' => array('Job ID', 'Name'), 'field' => NULL);
     $items = array();
     $formatter = new WP_CLI\Formatter($formatter_args);
     $jobids = BackWPup_Option::get_job_ids();
     foreach ($jobids as $jobid) {
         $items[] = array('Job ID' => $jobid, 'Name' => BackWPup_Option::get($jobid, 'name'));
     }
     $formatter->display_items($items);
 }
    /**
     * @param $jobid
     */
    public function edit_tab($jobid)
    {
        ?>
		<h3 class="title"><?php 
        _e('Settings for database check', 'backwpup');
        ?>
</h3>
		<p></p>
		<table class="form-table">
			<tr>
				<th scope="row"><?php 
        _e('WordPress tables only', 'backwpup');
        ?>
</th>
				<td>
					<label for="iddbcheckwponly">
					<input class="checkbox" value="1" id="iddbcheckwponly"
						   type="checkbox" <?php 
        checked(BackWPup_Option::get($jobid, 'dbcheckwponly'), TRUE);
        ?>
						   name="dbcheckwponly"/> <?php 
        _e('Check WordPress database tables only', 'backwpup');
        ?>
                    </label>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('Repair', 'backwpup');
        ?>
</th>
				<td>
                    <label for="iddbcheckrepair">
					<input class="checkbox" value="1" id="iddbcheckrepair"
						   type="checkbox" <?php 
        checked(BackWPup_Option::get($jobid, 'dbcheckrepair'), TRUE);
        ?>
						   name="dbcheckrepair" /> <?php 
        _e('Try to repair defect table', 'backwpup');
        ?>
					</label>
				</td>
			</tr>
		</table>
		<?php 
    }
    /**
     * @param $jobid
     * @return void
     */
    public function edit_tab($jobid)
    {
        ?>
		<table class="form-table">
			<tr>
				<th scope="row"><label for="idpluginlistfile"><?php 
        _e('Plugin list file name', 'backwpup');
        ?>
</label></th>
				<td>
					<input name="pluginlistfile" type="text" id="idpluginlistfile"
						   value="<?php 
        echo BackWPup_Option::get($jobid, 'pluginlistfile');
        ?>
"
						   class="medium-text code"/>.txt
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('File compression', 'backwpup');
        ?>
</th>
				<td>
					<fieldset>
						<?php 
        echo '<label for="idpluginlistfilecompression"><input class="radio" type="radio"' . checked('', BackWPup_Option::get($jobid, 'pluginlistfilecompression'), FALSE) . ' name="pluginlistfilecompression"  id="idpluginlistfilecompression" value="" /> ' . __('none', 'backwpup') . '</label><br />';
        if (function_exists('gzopen')) {
            echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'pluginlistfilecompression'), FALSE) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" /> ' . __('GZip', 'backwpup') . '</label><br />';
        } else {
            echo '<label for="idpluginlistfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'pluginlistfilecompression'), FALSE) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-gz" value=".gz" disabled="disabled" /> ' . __('GZip', 'backwpup') . '</label><br />';
        }
        if (function_exists('bzopen')) {
            echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked('.bz2', BackWPup_Option::get($jobid, 'pluginlistfilecompression'), FALSE) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" /> ' . __('BZip2', 'backwpup') . '</label><br />';
        } else {
            echo '<label for="idpluginlistfilecompression-bz2"><input class="radio" type="radio"' . checked('.bz2', BackWPup_Option::get($jobid, 'pluginlistfilecompression'), FALSE) . ' name="pluginlistfilecompression" id="idpluginlistfilecompression-bz2" value=".bz2" disabled="disabled" /> ' . __('BZip2', 'backwpup') . '</label><br />';
        }
        ?>
					</fieldset>
				</td>
			</tr>
		</table>
	<?php 
    }
 /**
  * @global $wp_admin_bar WP_Admin_Bar
  */
 public function adminbar()
 {
     global $wp_admin_bar;
     /* @var WP_Admin_Bar $wp_admin_bar */
     $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data('name') . '</span>';
     $menu_herf = network_admin_url('admin.php') . '?page=backwpup';
     if (file_exists(BackWPup::get_plugin_data('running_file')) && current_user_can('backwpup_jobs_start')) {
         $menu_title = '<span class="ab-icon"></span><span class="ab-label">' . BackWPup::get_plugin_data('name') . ' <span id="backwpup-adminbar-running">' . __('running', 'backwpup') . '</span></span>';
         $menu_herf = network_admin_url('admin.php') . '?page=backwpupjobs';
     }
     if (current_user_can('backwpup')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup', 'title' => $menu_title, 'href' => $menu_herf, 'meta' => array('title' => BackWPup::get_plugin_data('name'))));
     }
     if (file_exists(BackWPup::get_plugin_data('running_file')) && current_user_can('backwpup_jobs_start')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup_working', 'parent' => 'backwpup_jobs', 'title' => __('Now Running', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupjobs'));
         $wp_admin_bar->add_menu(array('id' => 'backwpup_working_abort', 'parent' => 'backwpup_working', 'title' => __('Abort!', 'backwpup'), 'href' => wp_nonce_url(network_admin_url('admin.php') . '?page=backwpup&action=abort', 'abort-job')));
     }
     if (current_user_can('backwpup_jobs')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup_jobs', 'parent' => 'backwpup', 'title' => __('Jobs', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupjobs'));
     }
     if (current_user_can('backwpup_jobs_edit')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_new', 'parent' => 'backwpup_jobs', 'title' => __('Add new', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupeditjob&tab=job'));
     }
     if (current_user_can('backwpup_logs')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup_logs', 'parent' => 'backwpup', 'title' => __('Logs', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpuplogs'));
     }
     if (current_user_can('backwpup_backups')) {
         $wp_admin_bar->add_menu(array('id' => 'backwpup_backups', 'parent' => 'backwpup', 'title' => __('Backups', 'backwpup'), 'href' => network_admin_url('admin.php') . '?page=backwpupbackups'));
     }
     //add jobs
     $jobs = (array) BackWPup_Option::get_job_ids();
     foreach ($jobs as $jobid) {
         if (current_user_can('backwpup_jobs_edit')) {
             $name = BackWPup_Option::get($jobid, 'name');
             $wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_' . $jobid, 'parent' => 'backwpup_jobs', 'title' => $name, 'href' => wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&tab=job&jobid=' . $jobid, 'edit-job')));
         }
         if (current_user_can('backwpup_jobs_start')) {
             $url = BackWPup_Job::get_jobrun_url('runnowlink', $jobid);
             $wp_admin_bar->add_menu(array('id' => 'backwpup_jobs_runnow_' . $jobid, 'parent' => 'backwpup_jobs_' . $jobid, 'title' => __('Run Now', 'backwpup'), 'href' => $url['url']));
         }
     }
 }
    public function edit_tab($jobid)
    {
        ?>
        <table class="form-table">
            <tr>
                <th scope="row"><label for="idwidgetlistfile"><?php 
        _e('Widget list file name', 'backwpup');
        ?>
</label></th>
                <td>
                    <input name="widgetlistfile" type="text" id="idwidgetlistfile"
                           value="<?php 
        echo BackWPup_Option::get($jobid, 'widgetlistfile');
        ?>
"
                           class="medium-text code"/>.sql
                </td>
            </tr>
        </table>
        <?php 
    }
    /**
     * @param $jobid
     * @internal param $main
     */
    public function edit_tab($jobid)
    {
        ?>
		<table class="form-table">
			<tr>
				<th scope="row"><?php 
        _e('Items to export', 'backwpup');
        ?>
</th>
				<td>
					<fieldset>
						<label for="idwpexportcontent-all"><input type="radio" name="wpexportcontent" id="idwpexportcontent-all" value="all" <?php 
        checked(BackWPup_Option::get($jobid, 'wpexportcontent'), 'all');
        ?>
 /> <?php 
        _e('All content', 'backwpup');
        ?>
</label><br />
						<label for="idwpexportcontent-post"><input type="radio" name="wpexportcontent" id="idwpexportcontent-post" value="post" <?php 
        checked(BackWPup_Option::get($jobid, 'wpexportcontent'), 'post');
        ?>
 /> <?php 
        _e('Posts', 'backwpup');
        ?>
</label><br />
						<label for="idwpexportcontent-page"><input type="radio" name="wpexportcontent" id="idwpexportcontent-page" value="page" <?php 
        checked(BackWPup_Option::get($jobid, 'wpexportcontent'), 'page');
        ?>
 /> <?php 
        _e('Pages', 'backwpup');
        ?>
</label><br />
						<?php 
        foreach (get_post_types(array('_builtin' => FALSE, 'can_export' => TRUE), 'objects') as $post_type) {
            ?>
							<label for="idwpexportcontent-<?php 
            echo esc_attr($post_type->name);
            ?>
"><input type="radio" name="wpexportcontent" id="idwpexportcontent-<?php 
            echo esc_attr($post_type->name);
            ?>
" value="<?php 
            echo esc_attr($post_type->name);
            ?>
" <?php 
            checked(BackWPup_Option::get($jobid, 'wpexportcontent'), esc_attr($post_type->name));
            ?>
 /> <?php 
            echo esc_html($post_type->label);
            ?>
</label><br />
						<?php 
        }
        ?>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="idwpexportfile"><?php 
        _e('XML Export file name', 'backwpup');
        ?>
</label></th>
				<td>
					<input name="wpexportfile" type="text" id="idwpexportfile"
						   value="<?php 
        echo BackWPup_Option::get($jobid, 'wpexportfile');
        ?>
"
						   class="medium-text code"/>.xml
				</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        _e('File compression', 'backwpup');
        ?>
</th>
				<td>
					<fieldset>
						<?php 
        echo '<label for="idwpexportfilecompression"><input class="radio" type="radio"' . checked('', BackWPup_Option::get($jobid, 'wpexportfilecompression'), FALSE) . ' name="wpexportfilecompression" id="idwpexportfilecompression" value="" /> ' . __('none', 'backwpup') . '</label><br />';
        if (function_exists('gzopen')) {
            echo '<label for="idwpexportfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'wpexportfilecompression'), FALSE) . ' name="wpexportfilecompression" id="idwpexportfilecompression-gz" value=".gz" /> ' . __('GZip', 'backwpup') . '</label><br />';
        } else {
            echo '<label for="idwpexportfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'wpexportfilecompression'), FALSE) . ' name="wpexportfilecompression" id="idwpexportfilecompression-gz" value=".gz" disabled="disabled" /> ' . __('GZip', 'backwpup') . '</label><br />';
        }
        if (function_exists('bzopen')) {
            echo '<label for="idwpexportfilecompression-bz2"><input class="radio" type="radio"' . checked('.bz2', BackWPup_Option::get($jobid, 'wpexportfilecompression'), FALSE) . ' name="wpexportfilecompression" id="idwpexportfilecompression-bz2" value=".bz2" /> ' . __('BZip2', 'backwpup') . '</label><br />';
        } else {
            echo '<label for="idwpexportfilecompression-bz2"><input class="radio" type="radio"' . checked('.bz2', BackWPup_Option::get($jobid, 'wpexportfilecompression'), FALSE) . ' name="wpexportfilecompression" id="idwpexportfilecompression-bz2" value=".bz2" disabled="disabled" /> ' . __('BZip2', 'backwpup') . '</label><br />';
        }
        ?>
					</fieldset>
				</td>
			</tr>
		</table>
		<?php 
    }
 /**
  * @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);
 }
Beispiel #9
0
 public static function status($backwpup_jobid)
 {
     if (empty($backwpup_jobid)) {
         $id = get_site_option('backwpup_cfg_easycronjobid');
     } else {
         $id = BackWPup_Option::get($backwpup_jobid, 'easycronjobid');
     }
     if (empty($id)) {
         return array();
     }
     $cron_job = get_site_transient('backwpup_easycron_' . $id);
     if (!empty($cron_job)) {
         return $cron_job;
     }
     $message = self::query_api('detail', array('id' => $id));
     if ($message['status'] == 'success' && !empty($message['cron_job'])) {
         set_site_transient('backwpup_easycron_' . $id, $message['cron_job'], 3600 - 30);
         return $message['cron_job'];
     } else {
         if ($message['error']['code'] == 25) {
             if (empty($backwpup_jobid)) {
                 delete_site_option('backwpup_cfg_easycronjobid');
             } else {
                 BackWPup_Option::delete($backwpup_jobid, 'easycronjobid');
             }
         }
     }
     return array();
 }
 /**
  * @return array
  */
 function get_destinations_list()
 {
     $jobdest = array();
     $jobids = BackWPup_Option::get_job_ids();
     if (!empty($jobids)) {
         foreach ($jobids as $jobid) {
             if (BackWPup_Option::get($jobid, 'backuptype') == 'sync') {
                 // jump over sync
                 continue;
             }
             $dests = BackWPup_Option::get($jobid, 'destinations');
             foreach ($dests as $dest) {
                 if (empty($this->destinations[$dest]['class'])) {
                     continue;
                 }
                 $dest_class = BackWPup::get_destination($dest);
                 $can_do_dest = $dest_class->file_get_list($jobid . '_' . $dest);
                 if (!empty($can_do_dest)) {
                     $jobdest[] = $jobid . '_' . $dest;
                 }
             }
         }
     }
     return $jobdest;
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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();
         }
         $s3file = $s3->get_object(BackWPup_Option::get($jobid, 's3bucket'), $get_file);
     } catch (Exception $e) {
         die($e->getMessage());
     }
     if ($s3file->status == 200) {
         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=" . basename($get_file) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $s3file->header->_info->size_download);
         @set_time_limit(0);
         echo $s3file->body;
         die;
     }
 }
    /**
     * Displaying next jobs
     */
    private static function mb_next_jobs()
    {
        if (!current_user_can('backwpup_jobs')) {
            return;
        }
        ?>
		<table class="wp-list-table widefat" cellspacing="0">
			<caption><?php 
        _e('Next scheduled jobs', 'backwpup');
        ?>
</caption>
			<thead>
			<tr>
				<th style="width: 30%"><?php 
        _e('Time', 'backwpup');
        ?>
</th>
				<th style="width: 70%"><?php 
        _e('Job', 'backwpup');
        ?>
</th>
			</tr>
			</thead>
			<?php 
        //get next jobs
        $mainsactive = BackWPup_Option::get_job_ids('activetype', 'wpcron');
        sort($mainsactive);
        $alternate = TRUE;
        // add working job if it not in active jobs
        $job_object = BackWPup_Job::get_working_data();
        if (!empty($job_object) && !empty($job_object->job['jobid']) && !in_array($job_object->job['jobid'], $mainsactive)) {
            $mainsactive[] = $job_object->job['jobid'];
        }
        foreach ($mainsactive as $jobid) {
            $name = BackWPup_Option::get($jobid, 'name');
            if (!empty($job_object) && $job_object->job['jobid'] == $jobid) {
                $runtime = current_time('timestamp') - $job_object->job['lastrun'];
                if (!$alternate) {
                    echo '<tr>';
                    $alternate = TRUE;
                } else {
                    echo '<tr class="alternate">';
                    $alternate = FALSE;
                }
                echo '<td>' . sprintf('<span style="color:#e66f00;">' . __('working since %d seconds', 'backwpup') . '</span>', $runtime) . '</td>';
                echo '<td><span style="font-weight:bold;">' . esc_html($job_object->job['name']) . '</span><br />';
                echo "<a style=\"color:red;\" href=\"" . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupjobs&action=abort', 'abort-job') . "\">" . __('Abort', 'backwpup') . "</a>";
                echo "</td></tr>";
            } else {
                if (!$alternate) {
                    echo '<tr>';
                    $alternate = TRUE;
                } else {
                    echo '<tr class="alternate">';
                    $alternate = FALSE;
                }
                if ($nextrun = wp_next_scheduled('backwpup_cron', array('id' => $jobid)) + get_option('gmt_offset') * 3600) {
                    echo '<td>' . sprintf(__('%1$s at %2$s', 'backwpup'), date_i18n(get_option('date_format'), $nextrun, TRUE), date_i18n(get_option('time_format'), $nextrun, TRUE)) . '</td>';
                } else {
                    echo '<td><em>' . __('Not scheduled!', 'backwpup') . '</em></td>';
                }
                echo '<td><a href="' . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&jobid=' . $jobid, 'edit-job') . '" title="' . esc_attr(__('Edit Job', 'backwpup')) . '">' . $name . '</a></td></tr>';
            }
        }
        if (empty($mainsactive) and !empty($job_object)) {
            echo '<tr><td colspan="2"><i>' . __('none', 'backwpup') . '</i></td></tr>';
        }
        ?>
		</table>
		<?php 
    }
 /**
  * @param $jobdest
  * @return mixed
  */
 public function file_get_list($jobdest)
 {
     list($jobid, $dest) = explode('_', $jobdest, 2);
     $filecounter = 0;
     $files = array();
     $backup_folder = BackWPup_Option::get($jobid, 'backupdir');
     $backup_folder = BackWPup_File::get_absolute_path($backup_folder);
     if (is_dir($backup_folder) && ($dir = opendir($backup_folder))) {
         //make file list
         while (FALSE !== ($file = readdir($dir))) {
             if (in_array($file, array('.', '..', 'index.php', '.htaccess', '.donotbackup')) || is_dir($backup_folder . $file) || is_link($backup_folder . $file)) {
                 continue;
             }
             if (is_readable($backup_folder . $file)) {
                 //file list for backups
                 $files[$filecounter]['folder'] = $backup_folder;
                 $files[$filecounter]['file'] = $backup_folder . $file;
                 $files[$filecounter]['filename'] = $file;
                 $files[$filecounter]['downloadurl'] = add_query_arg(array('page' => 'backwpupbackups', 'action' => 'downloadfolder', 'file' => $file, 'jobid' => $jobid), network_admin_url('admin.php'));
                 $files[$filecounter]['filesize'] = filesize($backup_folder . $file);
                 $files[$filecounter]['time'] = filemtime($backup_folder . $file);
                 $filecounter++;
             }
         }
         closedir($dir);
     }
     return $files;
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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'))));
         $ostore = $conn->objectStoreService('cloudFiles', BackWPup_Option::get($jobid, 'rscregion'), 'publicURL');
         $container = $ostore->getContainer(BackWPup_Option::get($jobid, 'rsccontainer'));
         $backupfile = $container->getObject($get_file);
         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=" . basename($get_file) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $backupfile->getContentLength());
         @set_time_limit(300);
         echo $backupfile->getContent();
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
    /**
     * @param $jobid
     */
    public function edit_tab($jobid)
    {
        global $wpdb;
        /* @var wpdb $wpdb */
        ?>

        <input name="dbdumpwpony" type="hidden" value="1" />

        <h3 class="title"><?php 
        _e('Settings for database backup', 'backwpup');
        ?>
</h3>

        <p></p>

        <table class="form-table">

            <tr>

                <th scope="row"><?php 
        _e('Tables to backup', 'backwpup');
        ?>
</th>

                <td>

                    <input type="button" class="button-secondary" id="dball" value="<?php 
        _e('all', 'backwpup');
        ?>
">&nbsp;

					<input type="button" class="button-secondary" id="dbnone" value="<?php 
        _e('none', 'backwpup');
        ?>
">&nbsp;

                    <input type="button" class="button-secondary" id="dbwp" value="<?php 
        echo $wpdb->prefix;
        ?>
">

					<?php 
        $tables = $wpdb->get_results('SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N);
        echo '<fieldset id="dbtables"><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
        $next_row = ceil(count($tables) / 3);
        $counter = 0;
        foreach ($tables as $table) {
            $tabletype = '';
            if ($table[1] != 'BASE TABLE') {
                $tabletype = ' <i>(' . strtolower($table[1]) . ')</i>';
            }
            echo '<label for="idtabledb-' . rawurlencode($table[0]) . '""><input class="checkbox" type="checkbox"' . checked(!in_array($table[0], BackWPup_Option::get($jobid, 'dbdumpexclude')), TRUE, FALSE) . ' name="tabledb[]" id="idtabledb-' . rawurlencode($table[0]) . '" value="' . rawurlencode($table[0]) . '"/> ' . $table[0] . $tabletype . '</label><br />';
            $counter++;
            if ($next_row <= $counter) {
                echo '</div><div style="width: 30%; float:left; min-width: 250px; margin-right: 10px;">';
                $counter = 0;
            }
        }
        echo '</div></fieldset>';
        ?>

                </td>

            </tr>

            <tr>

                <th scope="row"><label for="iddbdumpfile"><?php 
        _e('Backup file name', 'backwpup');
        ?>
</label></th>

                <td>

                    <input id="iddbdumpfile" name="dbdumpfile" type="text"

                           value="<?php 
        echo BackWPup_Option::get($jobid, 'dbdumpfile');
        ?>
"

                           class="medium-text code"/>.sql

                </td>

            </tr>

			<tr>

				<th scope="row"><?php 
        _e('Backup file compression', 'backwpup');
        ?>
</th>

				<td>

					<fieldset>

						<?php 
        echo '<label for="iddbdumpfilecompression"><input class="radio" type="radio"' . checked('', BackWPup_Option::get($jobid, 'dbdumpfilecompression'), FALSE) . ' name="dbdumpfilecompression"  id="iddbdumpfilecompression" value="" /> ' . __('none', 'backwpup') . '</label><br />';
        if (function_exists('gzopen')) {
            echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'dbdumpfilecompression'), FALSE) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" /> ' . __('GZip', 'backwpup') . '</label><br />';
        } else {
            echo '<label for="iddbdumpfilecompression-gz"><input class="radio" type="radio"' . checked('.gz', BackWPup_Option::get($jobid, 'dbdumpfilecompression'), FALSE) . ' name="dbdumpfilecompression" id="iddbdumpfilecompression-gz" value=".gz" disabled="disabled" /> ' . __('GZip', 'backwpup') . '</label><br />';
        }
        ?>

					</fieldset>

				</td>

			</tr>

        </table>

		<?php 
    }
Beispiel #16
0
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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')));
         $s3file = $s3->getObject(array('Bucket' => BackWPup_Option::get($jobid, 's3bucket'), 'Key' => $get_file));
     } catch (Exception $e) {
         die($e->getMessage());
     }
     if ($s3file['ContentLength'] > 0 && !empty($s3file['ContentType'])) {
         if ($level = ob_get_level()) {
             for ($i = 0; $i < $level; $i++) {
                 ob_end_clean();
             }
         }
         @set_time_limit(300);
         nocache_headers();
         header('Content-Description: File Transfer');
         header('Content-Type: ' . BackWPup_Job::get_mime_type($get_file));
         header('Content-Disposition: attachment; filename="' . basename($get_file) . '"');
         header('Content-Transfer-Encoding: binary');
         header('Content-Length: ' . $s3file['ContentLength']);
         $body = $s3file->get('Body');
         $body->rewind();
         while ($filedata = $body->read(1024)) {
             echo $filedata;
         }
         die;
     }
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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')));
         $s3file = $s3->getObject(array('Bucket' => BackWPup_Option::get($jobid, 's3bucket'), 'Key' => $get_file));
     } catch (Exception $e) {
         die($e->getMessage());
     }
     if ($s3file['ContentLength'] > 0 && !empty($s3file['ContentType'])) {
         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=" . basename($get_file) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $s3file['ContentLength']);
         @set_time_limit(0);
         $body = $s3file->get('Body');
         $body->rewind();
         while ($filedata = $body->read(1024)) {
             echo $filedata;
         }
         die;
     }
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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')));
         $blob = $blobRestProxy->getBlob(BackWPup_Option::get($jobid, 'msazurecontainer'), $get_file);
         if ($level = ob_get_level()) {
             for ($i = 0; $i < $level; $i++) {
                 ob_end_clean();
             }
         }
         @set_time_limit(300);
         nocache_headers();
         header('Content-Description: File Transfer');
         header('Content-Type: ' . BackWPup_Job::get_mime_type($get_file));
         header('Content-Disposition: attachment; filename="' . basename($get_file) . '"');
         header('Content-Transfer-Encoding: binary');
         header('Content-Length: ' . $blob->getProperties()->getContentLength());
         fpassthru($blob->getContentStream());
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Beispiel #19
0
 /**
  * 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 3.2
     $no_translation = get_site_option('backwpup_cfg_jobnotranslate');
     if ($no_translation) {
         update_site_option('backwpup_cfg_loglevel', 'normal');
         delete_site_option('backwpup_cfg_jobnotranslate');
     }
     //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));
         }
     }
     $activejobs = BackWPup_Option::get_job_ids('activetype', 'easycron');
     if (!empty($activejobs)) {
         foreach ($activejobs as $id) {
             BackWPup_EasyCron::update($id);
         }
     }
     //add check Cleanup schedule
     wp_clear_scheduled_hook('backwpup_check_cleanup');
     wp_schedule_event(time(), 'twicedaily', 'backwpup_check_cleanup');
     //add capabilities to administrator role
     $role = get_role('administrator');
     if (is_object($role) && method_exists($role, 'add_cap')) {
         $role->add_cap('backwpup');
         $role->add_cap('backwpup_jobs');
         $role->add_cap('backwpup_jobs_edit');
         $role->add_cap('backwpup_jobs_start');
         $role->add_cap('backwpup_backups');
         $role->add_cap('backwpup_backups_download');
         $role->add_cap('backwpup_backups_delete');
         $role->add_cap('backwpup_logs');
         $role->add_cap('backwpup_logs_delete');
         $role->add_cap('backwpup_settings');
     }
     //add/overwrite roles
     add_role('backwpup_admin', __('BackWPup Admin', 'backwpup'), array('read' => TRUE, '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('read' => TRUE, '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('read' => TRUE, '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 default options
     BackWPup_Option::default_site_options();
     //update version
     update_site_option('backwpup_version', BackWPup::get_plugin_data('Version'));
 }
    /**
     *
     */
    public static function page()
    {
        if (!empty($_GET['jobid'])) {
            $jobid = (int) $_GET['jobid'];
        } else {
            //generate jobid if not exists
            $newjobid = BackWPup_Option::get_job_ids();
            sort($newjobid);
            $jobid = end($newjobid) + 1;
        }
        $destinations = BackWPup::get_registered_destinations();
        $job_types = BackWPup::get_job_types();
        ?>
    <div class="wrap" id="backwpup-page">
		<?php 
        echo '<h2><span id="backwpup-page-icon">&nbsp;</span>' . sprintf(__('%1$s Job: %2$s', 'backwpup'), BackWPup::get_plugin_data('name'), '<span id="h2jobtitle">' . esc_html(BackWPup_Option::get($jobid, 'name')) . '</span>') . '</h2>';
        //default tabs
        $tabs = array('job' => array('name' => __('General', 'backwpup'), 'display' => TRUE), 'cron' => array('name' => __('Schedule', 'backwpup'), 'display' => TRUE));
        //add jobtypes to tabs
        $job_job_types = BackWPup_Option::get($jobid, 'type');
        foreach ($job_types as $typeid => $typeclass) {
            $tabid = 'jobtype-' . strtolower($typeid);
            $tabs[$tabid]['name'] = $typeclass->info['name'];
            $tabs[$tabid]['display'] = TRUE;
            if (!in_array($typeid, $job_job_types)) {
                $tabs[$tabid]['display'] = FALSE;
            }
        }
        //add destinations to tabs
        $jobdests = BackWPup_Option::get($jobid, 'destinations');
        foreach ($destinations as $destid => $dest) {
            $tabid = 'dest-' . strtolower($destid);
            $tabs[$tabid]['name'] = sprintf(__('To: %s', 'backwpup'), $dest['info']['name']);
            $tabs[$tabid]['display'] = TRUE;
            if (!in_array($destid, $jobdests)) {
                $tabs[$tabid]['display'] = FALSE;
            }
        }
        //display tabs
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($tabs as $id => $tab) {
            $addclass = '';
            if ($id == $_GET['tab']) {
                $addclass = ' nav-tab-active';
            }
            $display = '';
            if (!$tab['display']) {
                $display = ' style="display:none;"';
            }
            echo '<a href="' . wp_nonce_url(network_admin_url('admin.php') . '?page=backwpupeditjob&tab=' . $id . '&jobid=' . $jobid, 'edit-job') . '" class="nav-tab' . $addclass . '" id="tab-' . $id . '" data-nexttab="' . $id . '" ' . $display . '>' . $tab['name'] . '</a>';
        }
        echo '</h2>';
        //display messages
        BackWPup_Admin::display_messages();
        echo '<form name="editjob" id="editjob" method="post" action="' . admin_url('admin-post.php') . '">';
        echo '<input type="hidden" id="jobid" name="jobid" value="' . $jobid . '" />';
        echo '<input type="hidden" name="tab" value="' . $_GET['tab'] . '" />';
        echo '<input type="hidden" name="nexttab" value="' . $_GET['tab'] . '" />';
        echo '<input type="hidden" name="page" value="backwpupeditjob" />';
        echo '<input type="hidden" name="action" value="backwpup" />';
        echo '<input type="hidden" name="anchor" value="" />';
        wp_nonce_field('backwpupeditjob_page');
        wp_nonce_field('backwpup_ajax_nonce', 'backwpupajaxnonce', FALSE);
        switch ($_GET['tab']) {
            case 'job':
                echo '<div class="table" id="info-tab-job">';
                ?>
				<h3 class="title"><?php 
                _e('Job Name', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><label for="name"><?php 
                _e('Please name this job.', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="name" type="text" id="name" data-empty="<?php 
                _e('New Job', 'backwpup');
                ?>
"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'name');
                ?>
" class="regular-text" />
						</td>
					</tr>
				</table>

				<h3 class="title"><?php 
                _e('Job Tasks', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><?php 
                _e('This job is a&#160;&hellip;', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Job tasks', 'backwpup');
                ?>
</span>
								</legend><?php 
                foreach ($job_types as $id => $typeclass) {
                    $addclass = '';
                    if ($typeclass->creates_file()) {
                        $addclass .= ' filetype';
                    }
                    $title = '';
                    if (!empty($typeclass->info['help'])) {
                        $title = ' title="' . esc_attr($typeclass->info['help']) . '"';
                        $addclass .= ' help-tip';
                    }
                    echo '<label for="jobtype-select-' . strtolower($id) . '"><input class="jobtype-select checkbox' . $addclass . '"' . $title . '  id="jobtype-select-' . strtolower($id) . '" type="checkbox" ' . checked(TRUE, in_array($id, BackWPup_Option::get($jobid, 'type')), FALSE) . ' name="type[]" value="' . $id . '" /> ' . $typeclass->info['description'] . '</label><br />';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title hasdests"><?php 
                _e('Backup File Creation', 'backwpup');
                ?>
</h3>
				<p class="hasdests"></p>
				<table class="form-table hasdests">
					<?php 
                if (class_exists('BackWPup_Pro', FALSE)) {
                    ?>
					<tr>
						<th scope="row"><?php 
                    _e('Backup type', 'backwpup');
                    ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text">	<span><?php 
                    _e('Backup type', 'backwpup');
                    ?>
</span></legend>
								<label for="idbackuptype-sync"><input class="radio"
									   type="radio"<?php 
                    checked('sync', BackWPup_Option::get($jobid, 'backuptype'), TRUE);
                    ?>
									   name="backuptype" id="idbackuptype-sync"
									   value="sync"/> <?php 
                    _e('Synchronize file by file to destination', 'backwpup');
                    ?>
</label><br/>
                                <label for="idbackuptype-archive"><input class="radio"
									   type="radio"<?php 
                    checked('archive', BackWPup_Option::get($jobid, 'backuptype'), TRUE);
                    ?>
									   name="backuptype" id="idbackuptype-archive"
									   value="archive"/> <?php 
                    _e('Create a backup archive', 'backwpup');
                    ?>
</label><br/>
							</fieldset>
						</td>
					</tr>
					<?php 
                }
                ?>
					<tr class="nosync">
						<th scope="row"><label for="archivename"><?php 
                _e('Archive name', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="archivename" type="text" id="archivename"
								value="<?php 
                echo BackWPup_Option::get($jobid, 'archivename');
                ?>
"
								class="regular-text code help-tip" title="<?php 
                echo "<strong>" . esc_attr__('Replacement patterns:', 'backwpup') . "</strong><br />";
                echo esc_attr__('%d = Two digit day of the month, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%j = Day of the month, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%m = Day of the month, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%n = Representation of the month (without leading zeros)', 'backwpup') . '<br />';
                echo esc_attr__('%Y = Four digit representation for the year', 'backwpup') . '<br />';
                echo esc_attr__('%y = Two digit representation of the year', 'backwpup') . '<br />';
                echo esc_attr__('%a = Lowercase ante meridiem (am) and post meridiem (pm)', 'backwpup') . '<br />';
                echo esc_attr__('%A = Uppercase ante meridiem (AM) and post meridiem (PM)', 'backwpup') . '<br />';
                echo esc_attr__('%B = Swatch Internet Time', 'backwpup') . '<br />';
                echo esc_attr__('%g = Hour in 12-hour format, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%G = Hour in 24-hour format, without leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%h = Hour in 12-hour format, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%H = Hour in 24-hour format, with leading zeros', 'backwpup') . '<br />';
                echo esc_attr__('%i = Two digit representation of the minute', 'backwpup') . '<br />';
                echo esc_attr__('%s = Two digit representation of the second', 'backwpup') . '<br />';
                ?>
" />
							<?php 
                $current_time = current_time('timestamp');
                $datevars = array('%d', '%j', '%m', '%n', '%Y', '%y', '%a', '%A', '%B', '%g', '%G', '%h', '%H', '%i', '%s');
                $datevalues = array(date('d', $current_time), date('j', $current_time), date('m', $current_time), date('n', $current_time), date('Y', $current_time), date('y', $current_time), date('a', $current_time), date('A', $current_time), date('B', $current_time), date('g', $current_time), date('G', $current_time), date('h', $current_time), date('H', $current_time), date('i', $current_time), date('s', $current_time));
                $archivename = str_replace($datevars, $datevalues, BackWPup_Job::sanitize_file_name(BackWPup_Option::get($jobid, 'archivename')));
                echo '<p>Preview: <code><span id="archivefilename">' . $archivename . '</span><span id="archiveformat">' . BackWPup_Option::get($jobid, 'archiveformat') . '</span></code></p>';
                ?>
						</td>
					</tr>
					<tr class="nosync">
						<th scope="row"><?php 
                _e('Archive Format', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Archive Format', 'backwpup');
                ?>
</span></legend>
								<?php 
                if (function_exists('gzopen') || class_exists('ZipArchive')) {
                    echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __('PHP Zip functions will be used if available (needs less memory). Otherwise the PCLZip class will be used.', 'backwpup') . '" type="radio"' . checked('.zip', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" /> ' . __('Zip', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-zip"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.zip', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-zip" value=".zip" disabled="disabled" /> ' . __('Zip', 'backwpup') . '</label><br />';
                }
                echo '<label for="idarchiveformat-tar"><input class="radio help-tip" title="' . __('A tarballed, not compressed archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tar" value=".tar" /> ' . __('Tar', 'backwpup') . '</label><br />';
                if (function_exists('gzopen')) {
                    echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __('A tarballed, GZipped archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar.gz', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" /> ' . __('Tar GZip', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-targz"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.tar.gz', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-targz" value=".tar.gz" disabled="disabled" /> ' . __('Tar GZip', 'backwpup') . '</label><br />';
                }
                if (function_exists('bzopen')) {
                    echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __('A tarballed, BZipped archive (fast and less memory)', 'backwpup') . '" type="radio"' . checked('.tar.bz2', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" /> ' . __('Tar BZip2', 'backwpup') . '</label><br />';
                } else {
                    echo '<label for="idarchiveformat-tarbz2"><input class="radio help-tip" title="' . __('Disabled due to missing PHP function.', 'backwpup') . '" type="radio"' . checked('.tar.bz2', BackWPup_Option::get($jobid, 'archiveformat'), FALSE) . ' name="archiveformat" id="idarchiveformat-tarbz2" value=".tar.bz2" disabled="disabled" /> ' . __('Tar BZip2', 'backwpup') . '</label><br />';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title hasdests"><?php 
                _e('Job Destination', 'backwpup');
                ?>
</h3>
				<p class="hasdests"></p>
				<table class="form-table hasdests">
					<tr>
						<th scope="row"><?php 
                _e('Where should your backup file be stored?', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Where should your backup file be stored?', 'backwpup');
                ?>
</span>
								</legend><?php 
                foreach ($destinations as $id => $dest) {
                    $syncclass = '';
                    if (!$dest['can_sync']) {
                        $syncclass = 'nosync';
                    }
                    $title = '';
                    $helpclass = '';
                    if (!empty($dest['info']['help'])) {
                        $title = ' title="' . esc_attr($dest['info']['help']) . '"';
                        $helpclass = ' help-tip';
                    }
                    echo '<span class="' . $syncclass . '"><label for="dest-select-' . strtolower($id) . '"><input class="checkbox' . $helpclass . '"' . $title . ' id="dest-select-' . strtolower($id) . '" type="checkbox" ' . checked(TRUE, in_array($id, BackWPup_Option::get($jobid, 'destinations')), FALSE) . ' name="destinations[]" value="' . $id . '" ' . disabled(!empty($dest['error']), TRUE, FALSE) . ' /> ' . $dest['info']['description'];
                    if (!empty($dest['error'])) {
                        echo '<br /><span class="description">' . $dest['error'] . '</span>';
                    }
                    echo '</label><br /></span>';
                }
                ?>
</fieldset>
						</td>
					</tr>
				</table>

				<h3 class="title"><?php 
                _e('Log Files', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
						<th scope="row"><label for="mailaddresslog"><?php 
                _e('Send log to email address', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="mailaddresslog" type="text" id="mailaddresslog"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'mailaddresslog');
                ?>
"
								   class="regular-text help-tip" title="<?php 
                esc_attr_e('Leave empty to not have log sent. Or separate with , for more than one receiver.', 'backwpup');
                ?>
" />
						</td>
					</tr>
					<tr>
						<th scope="row"><label for="mailaddresssenderlog"><?php 
                _e('Email FROM field', 'backwpup');
                ?>
</label></th>
						<td>
							<input name="mailaddresssenderlog" type="text" id="mailaddresssenderlog"
								   value="<?php 
                echo BackWPup_Option::get($jobid, 'mailaddresssenderlog');
                ?>
"
								   class="regular-text help-tip" title="<?php 
                esc_attr_e('Email "From" field (Name &lt;&#160;you@your-email-address.tld&#160;&gt;)', 'backwpup');
                ?>
" />
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
                _e('Errors only', 'backwpup');
                ?>
</th>
						<td>
                            <label for="idmailerroronly">
							<input class="checkbox" value="1" id="idmailerroronly"
								   type="checkbox" <?php 
                checked(BackWPup_Option::get($jobid, 'mailerroronly'), TRUE);
                ?>
								   name="mailerroronly" /> <?php 
                _e('Send email with log only when errors occur during job execution.', 'backwpup');
                ?>
							</label>
						</td>
					</tr>
				</table>
				<?php 
                echo '</div>';
                break;
            case 'cron':
                echo '<div class="table" id="info-tab-cron">';
                ?>
				<h3 class="title"><?php 
                _e('Job Schedule', 'backwpup');
                ?>
</h3>
				<p></p>
				<table class="form-table">
					<tr>
                        <th scope="row"><?php 
                _e('Start job', 'backwpup');
                ?>
</th>
                        <td>
                            <fieldset>
                                <legend class="screen-reader-text"><span><?php 
                _e('Start job', 'backwpup');
                ?>
</span></legend>
                                <label for="idactivetype"><input class="radio"
                                       type="radio"<?php 
                checked('', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
                                       name="activetype" id="idactivetype"
                                       value="" /> <?php 
                _e('manually only', 'backwpup');
                ?>
</label><br/>
                                <label for="idactivetype-wpcron"><input class="radio"
                                       type="radio"<?php 
                checked('wpcron', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
                                       name="activetype" id="idactivetype-wpcron"
                                       value="wpcron" /> <?php 
                _e('with WordPress cron', 'backwpup');
                ?>
</label><br/>
	                            <?php 
                $disabled = '';
                $easycron_api = get_site_option('backwpup_cfg_easycronapikey');
                if (empty($easycron_api)) {
                    $disabled = ' disabled="disabled"';
                }
                ?>
	                            <label for="idactivetype-easycron"><input class="radio help-tip"
			                            type="radio"<?php 
                checked('easycron', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
			                            name="activetype" id="idactivetype-easycron"<?php 
                echo $disabled;
                ?>
			                            value="easycron" title="<?php 
                _e('Use EasyCron.com Cron jobs.');
                ?>
" /> <?php 
                _e('with <a href="https://www.easycron.com?ref=36673" class="help-tip" title="Affiliate Link!">EasyCron.com</a>', 'backwpup');
                ?>
	                            <?php 
                if (empty($easycron_api)) {
                    echo ' <strong>' . sprintf(__('Setup <a href="https://www.easycron.com?ref=36673" class="help-tip" title="Affiliate Link!">Account</a> / <a href="%s">API Key</a> first.', 'backwpup'), network_admin_url('admin.php') . '?page=backwpupsettings#backwpup-tab-apikey') . '</strong>';
                }
                ?>
	                            </label><br/>
	                            <?php 
                $url = BackWPup_Job::get_jobrun_url('runext', BackWPup_Option::get($jobid, 'jobid'));
                ?>
                                <label for="idactivetype-link"><input class="radio help-tip"
									   type="radio"<?php 
                checked('link', BackWPup_Option::get($jobid, 'activetype'), TRUE);
                ?>
									   name="activetype" id="idactivetype-link"
									   value="link" title="<?php 
                esc_attr_e('Copy the link for an external start. This option has to be activated to make the link work.', 'backwpup');
                ?>
" /> <?php 
                _e('with a link', 'backwpup');
                ?>
 <code><a href="<?php 
                echo $url['url'];
                ?>
" target="_blank"><?php 
                echo $url['url'];
                ?>
</a></code></label>
								<br />
                            </fieldset>
                        </td>
                    </tr>
                    <tr>
						<th scope="row"><?php 
                _e('Start job with CLI', 'backwpup');
                ?>
</th>
						<td class="help-tip" title="<?php 
                esc_attr_e('Use WP-CLI commands to let the job start with the server’s cron on command line interface.', 'backwpup');
                ?>
">
							<?php 
                _e('Use <a href="http://wp-cli.org/">WP-CLI</a> to run jobs from commandline.', 'backwpup');
                ?>
						</td>
                    </tr>
				</table>
				<h3 class="title wpcron"><?php 
                _e('Schedule execution time', 'backwpup');
                ?>
</h3>
				<?php 
                BackWPup_Page_Editjob::ajax_cron_text(array('cronstamp' => BackWPup_Option::get($jobid, 'cron'), 'crontype' => BackWPup_Option::get($jobid, 'cronselect')));
                ?>
				<table class="form-table wpcron">
					<tr>
						<th scope="row"><?php 
                _e('Scheduler type', 'backwpup');
                ?>
</th>
						<td>
							<fieldset>
								<legend class="screen-reader-text"><span><?php 
                _e('Scheduler type', 'backwpup');
                ?>
</span></legend>
                                <label for="idcronselect-basic"><input class="radio"
									   type="radio"<?php 
                checked('basic', BackWPup_Option::get($jobid, 'cronselect'), TRUE);
                ?>
									   name="cronselect" id="idcronselect-basic"
									   value="basic" /> <?php 
                _e('basic', 'backwpup');
                ?>
</label><br/>
                                <label for="idcronselect-advanced"><input class="radio"
									   type="radio"<?php 
                checked('advanced', BackWPup_Option::get($jobid, 'cronselect'), TRUE);
                ?>
									   name="cronselect" id="idcronselect-advanced"
									   value="advanced" /> <?php 
                _e('advanced', 'backwpup');
                ?>
</label><br/>
							</fieldset>
						</td>
					</tr>
					<?php 
                list($cronstr['minutes'], $cronstr['hours'], $cronstr['mday'], $cronstr['mon'], $cronstr['wday']) = explode(' ', BackWPup_Option::get($jobid, 'cron'), 5);
                if (strstr($cronstr['minutes'], '*/')) {
                    $minutes = explode('/', $cronstr['minutes']);
                } else {
                    $minutes = explode(',', $cronstr['minutes']);
                }
                if (strstr($cronstr['hours'], '*/')) {
                    $hours = explode('/', $cronstr['hours']);
                } else {
                    $hours = explode(',', $cronstr['hours']);
                }
                if (strstr($cronstr['mday'], '*/')) {
                    $mday = explode('/', $cronstr['mday']);
                } else {
                    $mday = explode(',', $cronstr['mday']);
                }
                if (strstr($cronstr['mon'], '*/')) {
                    $mon = explode('/', $cronstr['mon']);
                } else {
                    $mon = explode(',', $cronstr['mon']);
                }
                if (strstr($cronstr['wday'], '*/')) {
                    $wday = explode('/', $cronstr['wday']);
                } else {
                    $wday = explode(',', $cronstr['wday']);
                }
                ?>
                    <tr class="wpcronbasic"<?php 
                if (BackWPup_Option::get($jobid, 'cronselect') != 'basic') {
                    echo ' style="display:none;"';
                }
                ?>
>
                        <th scope="row"><?php 
                _e('Scheduler', 'backwpup');
                ?>
</th>
                        <td>
                            <table id="wpcronbasic">
                                <tr>
                                    <th>
										<?php 
                _e('Type', 'backwpup');
                ?>
                                    </th>
                                    <th>
                                    </th>
                                    <th>
										<?php 
                _e('Hour', 'backwpup');
                ?>
                                    </th>
                                    <th>
										<?php 
                _e('Minute', 'backwpup');
                ?>
                                    </th>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-mon"><?php 
                echo '<input class="radio" type="radio"' . checked(TRUE, is_numeric($mday[0]), FALSE) . ' name="cronbtype" id="idcronbtype-mon" value="mon" /> ' . __('monthly', 'backwpup');
                ?>
</label></td>
                                    <td><select name="moncronmday"><?php 
                for ($i = 1; $i <= 31; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $mday, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . __('on', 'backwpup') . ' ' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="moncronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="moncronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-week"><?php 
                echo '<input class="radio" type="radio"' . checked(TRUE, is_numeric($wday[0]), FALSE) . ' name="cronbtype" id="idcronbtype-week" value="week" /> ' . __('weekly', 'backwpup');
                ?>
</label></td>
                                    <td><select name="weekcronwday">
										<?php 
                echo '<option ' . selected(in_array("0", $wday, TRUE), TRUE, FALSE) . '  value="0" />' . __('Sunday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("1", $wday, TRUE), TRUE, FALSE) . '  value="1" />' . __('Monday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("2", $wday, TRUE), TRUE, FALSE) . '  value="2" />' . __('Tuesday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("3", $wday, TRUE), TRUE, FALSE) . '  value="3" />' . __('Wednesday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("4", $wday, TRUE), TRUE, FALSE) . '  value="4" />' . __('Thursday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("5", $wday, TRUE), TRUE, FALSE) . '  value="5" />' . __('Friday', 'backwpup') . '</option>';
                echo '<option ' . selected(in_array("6", $wday, TRUE), TRUE, FALSE) . '  value="6" />' . __('Saturday', 'backwpup') . '</option>';
                ?>
                                    </select></td>
                                    <td><select name="weekcronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="weekcronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-day"><?php 
                echo '<input class="radio" type="radio"' . checked("**", $mday[0] . $wday[0], FALSE) . ' name="cronbtype" id="idcronbtype-day" value="day" /> ' . __('daily', 'backwpup');
                ?>
</label></td>
                                    <td></td>
                                    <td><select name="daycronhours"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<option ' . selected(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                    <td><select name="daycronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                                <tr>
                                    <td><label for="idcronbtype-hour"><?php 
                echo '<input class="radio" type="radio"' . checked("*", $hours[0], FALSE, FALSE) . ' name="cronbtype" id="idcronbtype-hour" value="hour" /> ' . __('hourly', 'backwpup');
                ?>
</label></td>
                                    <td></td>
                                    <td></td>
                                    <td><select name="hourcronminutes"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<option ' . selected(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . '  value="' . $i . '" />' . $i . '</option>';
                }
                ?>
</select></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
					<tr class="wpcronadvanced"<?php 
                if (BackWPup_Option::get($jobid, 'cronselect') != 'advanced') {
                    echo ' style="display:none;"';
                }
                ?>
>
						<th scope="row"><?php 
                _e('Scheduler', 'backwpup');
                ?>
</th>
						<td>
                            <div id="cron-min-box">
                                <b><?php 
                _e('Minutes:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronminutes"><input class="checkbox" type="checkbox"' . checked(in_array("*", $minutes, TRUE), TRUE, FALSE) . ' name="cronminutes[]" id="idcronminutes" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-min"><?php 
                for ($i = 0; $i < 60; $i = $i + 5) {
                    echo '<label for="idcronminutes-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $minutes, TRUE), TRUE, FALSE) . ' name="cronminutes[]" id="idcronminutes-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-hour-box">
                                <b><?php 
                _e('Hours:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronhours"><input class="checkbox" type="checkbox"' . checked(in_array("*", $hours, TRUE), TRUE, FALSE) . ' name="cronhours[]" for="idcronhours" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-hour"><?php 
                for ($i = 0; $i < 24; $i++) {
                    echo '<label for="idcronhours-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $hours, TRUE), TRUE, FALSE) . ' name="cronhours[]" id="idcronhours-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-day-box">
                                <b><?php 
                _e('Day of Month:', 'backwpup');
                ?>
</b><br/>
                                <label for="idcronmday"><input class="checkbox" type="checkbox"<?php 
                checked(in_array("*", $mday, TRUE), TRUE, TRUE);
                ?>
                                       name="cronmday[]" id="idcronmday" value="*"/> <?php 
                _e('Any (*)', 'backwpup');
                ?>
</label>
                                <br/>

                                <div id="cron-day">
									<?php 
                for ($i = 1; $i <= 31; $i++) {
                    echo '<label for="idcronmday-' . $i . '"><input class="checkbox" type="checkbox"' . checked(in_array("{$i}", $mday, TRUE), TRUE, FALSE) . ' name="cronmday[]" id="idcronmday-' . $i . '" value="' . $i . '" /> ' . $i . '</label><br />';
                }
                ?>
                                </div>
                            </div>
                            <div id="cron-month-box">
                                <b><?php 
                _e('Month:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronmon"><input class="checkbox" type="checkbox"' . checked(in_array("*", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-month">
									<?php 
                echo '<label for="idcronmon-1"><input class="checkbox" type="checkbox"' . checked(in_array("1", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-1" value="1" /> ' . __('January', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-2"><input class="checkbox" type="checkbox"' . checked(in_array("2", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-2" value="2" /> ' . __('February', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-3"><input class="checkbox" type="checkbox"' . checked(in_array("3", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-3" value="3" /> ' . __('March', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-4"><input class="checkbox" type="checkbox"' . checked(in_array("4", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-4" value="4" /> ' . __('April', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-5"><input class="checkbox" type="checkbox"' . checked(in_array("5", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-5" value="5" /> ' . __('May', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-6"><input class="checkbox" type="checkbox"' . checked(in_array("6", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-6" value="6" /> ' . __('June', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-7"><input class="checkbox" type="checkbox"' . checked(in_array("7", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-7" value="7" /> ' . __('July', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-8"><input class="checkbox" type="checkbox"' . checked(in_array("8", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-8" value="8" /> ' . __('August', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-9"><input class="checkbox" type="checkbox"' . checked(in_array("9", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-9" value="9" /> ' . __('September', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-10"><input class="checkbox" type="checkbox"' . checked(in_array("10", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-10" value="10" /> ' . __('October', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-11"><input class="checkbox" type="checkbox"' . checked(in_array("11", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-11" value="11" /> ' . __('November', 'backwpup') . '</label><br />';
                echo '<label for="idcronmon-12"><input class="checkbox" type="checkbox"' . checked(in_array("12", $mon, TRUE), TRUE, FALSE) . ' name="cronmon[]" id="idcronmon-12" value="12" /> ' . __('December', 'backwpup') . '</label><br />';
                ?>
                                </div>
                            </div>
                            <div id="cron-weekday-box">
                                <b><?php 
                _e('Day of Week:', 'backwpup');
                ?>
</b><br/>
								<?php 
                echo '<label for="idcronwday"><input class="checkbox" type="checkbox"' . checked(in_array("*", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday" value="*" /> ' . __('Any (*)', 'backwpup') . '</label><br />';
                ?>
                                <div id="cron-weekday">
									<?php 
                echo '<label for="idcronwday-0"><input class="checkbox" type="checkbox"' . checked(in_array("0", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-0" value="0" /> ' . __('Sunday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-1"><input class="checkbox" type="checkbox"' . checked(in_array("1", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-1" value="1" /> ' . __('Monday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-2"><input class="checkbox" type="checkbox"' . checked(in_array("2", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-2" value="2" /> ' . __('Tuesday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-3"><input class="checkbox" type="checkbox"' . checked(in_array("3", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-3" value="3" /> ' . __('Wednesday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-4"><input class="checkbox" type="checkbox"' . checked(in_array("4", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-4" value="4" /> ' . __('Thursday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-5"><input class="checkbox" type="checkbox"' . checked(in_array("5", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-5" value="5" /> ' . __('Friday', 'backwpup') . '</label><br />';
                echo '<label for="idcronwday-6"><input class="checkbox" type="checkbox"' . checked(in_array("6", $wday, TRUE), TRUE, FALSE) . ' name="cronwday[]" id="idcronwday-6" value="6" /> ' . __('Saturday', 'backwpup') . '</label><br />';
                ?>
                                </div>
                            </div>
                            <br class="clear"/>
						</td>
					</tr>
				</table>
				<?php 
                echo '</div>';
                break;
            default:
                echo '<div class="table" id="info-tab-' . $_GET['tab'] . '">';
                if (strstr($_GET['tab'], 'dest-')) {
                    $dest_object = BackWPup::get_destination(str_replace('dest-', '', $_GET['tab']));
                    $dest_object->edit_tab($jobid);
                }
                if (strstr($_GET['tab'], 'jobtype-')) {
                    $id = strtoupper(str_replace('jobtype-', '', $_GET['tab']));
                    $job_types[$id]->edit_tab($jobid);
                }
                echo '</div>';
        }
        echo '<p class="submit">';
        submit_button(__('Save changes', 'backwpup'), 'primary', 'save', FALSE, array('tabindex' => '2', 'accesskey' => 'p'));
        echo '</p></form>';
        ?>
    </div>

    <script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function ($) {
        // auto post if things changed
        var changed = false;
        $( '#editjob' ).change( function () {
            changed = true;
        });
		$( '.nav-tab' ).click( function () {
			if ( changed ) {
				$( 'input[name="nexttab"]' ).val( $(this).data( "nexttab" ) );
				$( '#editjob' ).submit();
				return false;
            }
		});
		<?php 
        //add inline js
        if (strstr($_GET['tab'], 'dest-')) {
            $dest_object = BackWPup::get_destination(str_replace('dest-', '', $_GET['tab']));
            $dest_object->edit_inline_js();
        }
        if (strstr($_GET['tab'], 'jobtype-')) {
            $id = strtoupper(str_replace('jobtype-', '', $_GET['tab']));
            $job_types[$id]->edit_inline_js();
        }
        ?>
    });
    //]]>
    </script>
	<?php 
    }
    /**
     * @param $jobid
     */
    public function edit_tab($jobid)
    {
        ?>

		<h3 class="title"><?php 
        _e('Email address', 'backwpup');
        ?>
</h3>

		<table class="form-table">

            <tr>

                <th scope="row"><label for="emailaddress"><?php 
        _e('Email address', 'backwpup');
        ?>
</label></th>

                <td>

                    <input name="emailaddress" id="emailaddress" type="text" title="<?php 
        esc_attr_e('Email address to which Backups are sent.', 'backwpup');
        ?>
"

                           value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailaddress'));
        ?>
" class="regular-text help-tip" />

                </td>

            </tr>

            <tr>

                <th scope="row"><label for="sendemailtest"><?php 
        _e('Send test email', 'backwpup');
        ?>
</label></th>

                <td>

                    <button id="sendemailtest" class="button secondary"><?php 
        _e('Send test email', 'backwpup');
        ?>
</button>

                </td>

            </tr>

		</table>



		<h3 class="title"><?php 
        _e('Send email settings', 'backwpup');
        ?>
</h3>

		<table class="form-table">

			<tr>

				<th scope="row"><label for="idemailefilesize"><?php 
        _e('Maximum file size', 'backwpup');
        ?>
</label></th>

				<td><input id="idemailefilesize" name="emailefilesize" type="text" value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailefilesize'));
        ?>
" class="small-text help-tip" title="<?php 
        esc_attr_e('Maximum file size to be included in an email. 0 = unlimited', 'backwpup');
        ?>
" /><?php 
        _e('MB', 'backwpup');
        ?>

				</td>

			</tr>

			<tr>

				<th scope="row"><label for="emailsndemail"><?php 
        _e('Sender email address', 'backwpup');
        ?>
</label></th>

				<td><input name="emailsndemail" type="text" id="emailsndemail" title="<?php 
        esc_attr_e('Sender email address', 'backwpup');
        ?>
"

						   value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailsndemail'));
        ?>
"

						   class="regular-text help-tip" />

				</td>

			</tr>

			<tr>

				<th scope="row"><label for="emailsndemailname"><?php 
        _e('Sender name', 'backwpup');
        ?>
</label></th>

				<td><input name="emailsndemailname" type="text" id="emailsndemailname" title="<?php 
        esc_attr_e('Name of email sender', 'backwpup');
        ?>
"

						   value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailsndemailname'));
        ?>
"

						   class="regular-text help-tip" />

				</td>

			</tr>

			<tr>

				<th scope="row"><label for="emailmethod"><?php 
        _e('Sending method', 'backwpup');
        ?>
</label></th>

				<td>

					<select id="emailmethod" name="emailmethod" class="help-tip" title="<?php 
        esc_attr_e('- Use site settings: retrieve the email settings of your site.<br />-PHP mail(): needs more PHP memory', 'backwpup');
        ?>
">

						<?php 
        echo '<option value=""' . selected('', BackWPup_Option::get($jobid, 'emailmethod'), FALSE) . '>' . __('Use site settings', 'backwpup') . '</option>';
        echo '<option value="mail"' . selected('mail', BackWPup_Option::get($jobid, 'emailmethod'), FALSE) . '>' . __('PHP: mail()', 'backwpup') . '</option>';
        echo '<option value="sendmail"' . selected('sendmail', BackWPup_Option::get($jobid, 'emailmethod'), FALSE) . '>' . __('Sendmail', 'backwpup') . '</option>';
        echo '<option value="smtp"' . selected('smtp', BackWPup_Option::get($jobid, 'emailmethod'), FALSE) . '>' . __('SMTP', 'backwpup') . '</option>';
        ?>

					</select>



				</td>

			</tr>

			<tr id="emailsendmail" <?php 
        if (BackWPup_Option::get($jobid, 'emailmethod') != 'sendmail') {
            echo 'style="display:none;"';
        }
        ?>
>

				<th scope="row"><label for="emailsendmail"><?php 
        _e('Sendmail path', 'backwpup');
        ?>
</label></th>

				<td>

					<input name="emailsendmail" id="emailsendmail" type="text"

						   value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailsendmail'));
        ?>
"

						   class="regular-text code" />

				</td>

			</tr>

			<tr class="emailsmtp" <?php 
        if (BackWPup_Option::get($jobid, 'emailmethod') != 'smtp') {
            echo 'style="display:none;"';
        }
        ?>
>

				<th scope="row"><label for="emailhost"><?php 
        _e('SMTP host name', 'backwpup');
        ?>
</label></th>

				<td>

					<input name="emailhost" id="emailhost" type="text"

						   value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailhost'));
        ?>
"

						   class="regular-text code"/>&nbsp;

					<label for="emailhostport"><?php 
        _e('Port:', 'backwpup');
        ?>
<input name="emailhostport" id="emailhostport" type="text"

															  value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailhostport'));
        ?>
"

															  class="small-text code" /></label>

				</td>

			</tr>

			<tr class="emailsmtp" <?php 
        if (BackWPup_Option::get($jobid, 'emailmethod') != 'smtp') {
            echo 'style="display:none;"';
        }
        ?>
>

				<th scope="row"><label for="emailsecure"><?php 
        _e('SMTP secure connection', 'backwpup');
        ?>
</label>

				</th>

				<td>

					<select id="emailsecure" name="emailsecure">

						<option value=""<?php 
        selected('', BackWPup_Option::get($jobid, 'emailsecure'), TRUE);
        ?>
><?php 
        _e('none', 'backwpup');
        ?>
</option>

						<option value="ssl"<?php 
        selected('ssl', BackWPup_Option::get($jobid, 'emailsecure'), TRUE);
        ?>
><?php 
        _e('SSL', 'backwpup');
        ?>
</option>

						<option value="tls"<?php 
        selected('tls', BackWPup_Option::get($jobid, 'emailsecure'), TRUE);
        ?>
><?php 
        _e('TLS', 'backwpup');
        ?>
</option>

					</select>

				</td>

			</tr>

			<tr class="emailsmtp" <?php 
        if (BackWPup_Option::get($jobid, 'emailmethod') != 'smtp') {
            echo 'style="display:none;"';
        }
        ?>
>

				<th scope="row"><label for="emailuser"><?php 
        _e('SMTP username', 'backwpup');
        ?>
</label></th>

				<td>

					<input name="emailuser" id="emailuser" type="text"

						   value="<?php 
        echo esc_attr(BackWPup_Option::get($jobid, 'emailuser'));
        ?>
" class="regular-text" autocomplete="off" />

				</td>

			</tr>

			<tr class="emailsmtp" <?php 
        if (BackWPup_Option::get($jobid, 'emailmethod') != 'smtp') {
            echo 'style="display:none;"';
        }
        ?>
>

				<th scope="row"><label for="emailpass"><?php 
        _e('SMTP password', 'backwpup');
        ?>
</label></th>

				<td>

					<input name="emailpass" id="emailpass" type="password"

						   value="<?php 
        echo esc_attr(BackWPup_Encryption::decrypt(BackWPup_Option::get($jobid, 'emailpass')));
        ?>
"

						   class="regular-text" autocomplete="off" />

				</td>

			</tr>

		</table>

		<?php 
    }
 /**
  *
  */
 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();
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     try {
         $sugarsync = new BackWPup_Destination_SugarSync_API(BackWPup_Option::get($jobid, 'sugarrefreshtoken'));
         $response = $sugarsync->get(urldecode($get_file));
         if ($level = ob_get_level()) {
             for ($i = 0; $i < $level; $i++) {
                 ob_end_clean();
             }
         }
         @set_time_limit(300);
         nocache_headers();
         header('Content-Description: File Transfer');
         header('Content-Type: ' . BackWPup_Job::get_mime_type((string) $response->displayName));
         header('Content-Disposition: attachment; filename="' . (string) $response->displayName . '"');
         header('Content-Transfer-Encoding: binary');
         header('Content-Length: ' . (int) $response->size);
         echo $sugarsync->download(urldecode($get_file));
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     try {
         $sugarsync = new BackWPup_Destination_SugarSync_API(BackWPup_Option::get($jobid, 'sugarrefreshtoken'));
         $response = $sugarsync->get(urldecode($get_file));
         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=" . (string) $response->displayName . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . (int) $response->size);
         @set_time_limit(0);
         echo $sugarsync->download(urldecode($get_file));
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Beispiel #25
0
 /**
  *
  */
 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();
     }
 }
Beispiel #26
0
 /**
  *
  */
 public static function start_http($starttype)
 {
     //load text domain
     $log_level = get_site_option('backwpup_cfg_loglevel');
     if (strstr($log_level, 'translated')) {
         BackWPup::load_text_domain();
     }
     if ($starttype != 'restart') {
         //check get vars
         if (isset($_GET['jobid'])) {
             $jobid = (int) $_GET['jobid'];
         } else {
             $jobid = 0;
         }
         //check job id exists
         if ($jobid != BackWPup_Option::get($jobid, 'jobid')) {
             die('-1');
         }
         //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);
             die('-2');
         }
     }
     // redirect
     if ($starttype == 'runnowalt') {
         ob_start();
         wp_redirect(add_query_arg(array('page' => 'backwpupjobs'), network_admin_url('admin.php')));
         echo ' ';
         while (@ob_end_flush()) {
         }
         flush();
     }
     // Should be preventing doubled running job's on http requests
     $random = rand(1, 9) * 100000;
     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')) && !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($starttype, (int) $jobid);
     }
     if (is_object($backwpup_job_object) && $backwpup_job_object instanceof BackWPup_Job) {
         $backwpup_job_object->run();
     }
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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')));
         $blob = $blobRestProxy->getBlob(BackWPup_Option::get($jobid, 'msazurecontainer'), $get_file);
         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=" . basename($get_file) . ";");
         header("Content-Transfer-Encoding: binary");
         header("Content-Length: " . $blob->getProperties()->getContentLength());
         @set_time_limit(300);
         fpassthru($blob->getContentStream());
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Beispiel #28
0
 /**
  * Check Jobs worked and Cleanup logs and so on
  */
 public static function check_cleanup()
 {
     $job_object = BackWPup_Job::get_working_data();
     // check aborted jobs for longer than a tow hours, abort them courtly and send mail
     if (is_object($job_object) && !empty($job_object->logfile)) {
         $not_worked_time = microtime(TRUE) - $job_object->timestamp_last_update;
         if ($not_worked_time > 3600) {
             $job_object->log(E_USER_ERROR, __('Aborted, because no progress for one hour!', 'backwpup'), __FILE__, __LINE__);
             $job_object->end();
         }
     }
     //Compress not compressed logs
     if (function_exists('gzopen') && get_site_option('backwpup_cfg_gzlogs') && !is_object($job_object)) {
         //Compress old not compressed logs
         if ($dir = opendir(get_site_option('backwpup_cfg_logfolder'))) {
             $jobids = BackWPup_Option::get_job_ids();
             while (FALSE !== ($file = readdir($dir))) {
                 if (is_writeable(get_site_option('backwpup_cfg_logfolder') . $file) && '.html' == substr($file, -5)) {
                     $compress = new BackWPup_Create_Archive(get_site_option('backwpup_cfg_logfolder') . $file . '.gz');
                     if ($compress->add_file(get_site_option('backwpup_cfg_logfolder') . $file)) {
                         unlink(get_site_option('backwpup_cfg_logfolder') . $file);
                         //change last logfile in jobs
                         foreach ($jobids as $jobid) {
                             $job_logfile = BackWPup_Option::get($jobid, 'logfile');
                             if (!empty($job_logfile) && $job_logfile == get_site_option('backwpup_cfg_logfolder') . $file) {
                                 BackWPup_Option::update($jobid, 'logfile', get_site_option('backwpup_cfg_logfolder') . $file . '.gz');
                             }
                         }
                     }
                     unset($compress);
                 }
             }
             closedir($dir);
         }
     }
     //Jobs cleanings
     if (!is_object($job_object)) {
         //remove restart cron
         wp_clear_scheduled_hook('backwpup_cron', array('id' => 'restart'));
         //temp cleanup
         BackWPup_Job::clean_temp_folder();
     }
     //check scheduling jobs that not found will removed because there are single scheduled
     $activejobs = BackWPup_Option::get_job_ids('activetype', 'wpcron');
     if (!empty($activejobs)) {
         foreach ($activejobs as $jobid) {
             $cron_next = wp_next_scheduled('backwpup_cron', array('id' => $jobid));
             if (!$cron_next || $cron_next < time()) {
                 wp_unschedule_event($cron_next, 'backwpup_cron', array('id' => $jobid));
                 $cron_next = BackWPup_Cron::cron_next(BackWPup_Option::get($jobid, 'cron'));
                 wp_schedule_single_event($cron_next, 'backwpup_cron', array('id' => $jobid));
             }
         }
     }
 }
 /**
  * @param $jobid
  * @param $get_file
  */
 public function file_download($jobid, $get_file)
 {
     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')));
         $media = $dropbox->media($get_file);
         if (!empty($media['url'])) {
             header("Location: " . $media['url']);
         }
         die;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Beispiel #30
0
 /**
  *
  */
 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();
 }