Exemplo n.º 1
0
 public static function update($backwpup_jobid)
 {
     $params = array('id' => NULL, 'email_me' => 0, 'log_output_length' => 0, 'testfirst' => 0);
     if (empty($backwpup_jobid)) {
         $params['id'] = get_site_option('backwpup_cfg_easycronjobid');
         $params['cron_job_name'] = sprintf('WordPress on %s', home_url());
         $params['cron_expression'] = '*/5 * * * *';
         $url = BackWPup_Job::get_jobrun_url('runext', 0);
         $url = remove_query_arg('_nonce', $url['url']);
         $url = remove_query_arg('doing_wp_cron', $url);
         $url = remove_query_arg('backwpup_run', $url);
         $url = add_query_arg(array('doing_wp_cron' => ''), $url);
         $cookies = get_site_transient('backwpup_cookies');
         $params['url'] = $url;
         if (!empty($cookies)) {
             $params['cookies'] = http_build_query($cookies);
         }
     } else {
         $params['id'] = BackWPup_Option::get($backwpup_jobid, 'easycronjobid');
         if (empty($params['id'])) {
             $params['id'] = NULL;
         }
         $params['cron_job_name'] = sprintf('BackWPup %s on %s', BackWPup_Option::get($backwpup_jobid, 'name'), home_url());
         $params['cron_expression'] = BackWPup_Option::get($backwpup_jobid, 'cron');
         $url = BackWPup_Job::get_jobrun_url('runext', $backwpup_jobid);
         $cookies = get_site_transient('backwpup_cookies');
         $params['url'] = $url['url'];
         if (!empty($cookies)) {
             $params['cookies'] = http_build_query($cookies);
         }
     }
     if (empty($params['id'])) {
         $message = self::query_api('add', $params);
     } else {
         $message = self::query_api('edit', $params);
     }
     delete_site_transient('backwpup_easycron_' . $params['id']);
     if ($message['status'] == 'success' && !empty($message['cron_job_id'])) {
         if (empty($backwpup_jobid)) {
             update_site_option('backwpup_cfg_easycronjobid', $message['cron_job_id']);
         } else {
             BackWPup_Option::update($backwpup_jobid, 'easycronjobid', $message['cron_job_id']);
         }
         return TRUE;
     } else {
         if ($message['error']['code'] == 25) {
             if (empty($backwpup_jobid)) {
                 delete_site_option('backwpup_cfg_easycronjobid');
             } else {
                 BackWPup_Option::delete($backwpup_jobid, 'easycronjobid');
             }
         }
     }
     return FALSE;
 }
Exemplo n.º 2
0
 /**
  * @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 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 
    }
Exemplo n.º 4
0
 /**
  *
  * Function to generate json data
  *
  */
 public static function ajax_working()
 {
     check_ajax_referer('backwpupworking_ajax_nonce');
     if (!current_user_can('backwpup_jobs_start')) {
         die('-1');
     }
     $log_folder = get_site_option('backwpup_cfg_logfolder');
     $log_folder = BackWPup_File::get_absolute_path($log_folder);
     $logfile = isset($_GET['logfile']) ? $log_folder . basename(trim($_GET['logfile'])) : NULL;
     $logpos = isset($_GET['logpos']) ? absint($_GET['logpos']) : 0;
     $restart_url = '';
     //check if logfile renamed
     if (file_exists($logfile . '.gz')) {
         $logfile .= '.gz';
     }
     if (!is_readable($logfile) || strstr($_GET['logfile'], 'backwpup_log_') === false) {
         die('0');
     }
     $job_object = BackWPup_Job::get_working_data();
     $done = 0;
     if (is_object($job_object)) {
         $warnings = $job_object->warnings;
         $errors = $job_object->errors;
         $step_percent = $job_object->step_percent;
         $substep_percent = $job_object->substep_percent;
         $runtime = current_time('timestamp') - $job_object->start_time;
         $onstep = $job_object->steps_data[$job_object->step_working]['NAME'];
         $lastmsg = $job_object->lastmsg;
         $lasterrormsg = $job_object->lasterrormsg;
     } else {
         $logheader = BackWPup_Job::read_logheader($logfile);
         $warnings = $logheader['warnings'];
         $runtime = $logheader['runtime'];
         $errors = $logheader['errors'];
         $step_percent = 100;
         $substep_percent = 100;
         $onstep = '<div class="backwpup-message backwpup-info"><p>' . esc_html__('Job completed', 'backwpup') . '</p></div>';
         if ($errors > 0) {
             $lastmsg = '<div class="error"><p>' . esc_html__('ERROR:', 'backwpup') . ' ' . sprintf(esc_html__('Job has ended with errors in %s seconds. You must resolve the errors for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
         } elseif ($warnings > 0) {
             $lastmsg = '<div class="backwpup-message backwpup-warning"><p>' . esc_html__('WARNING:', 'backwpup') . ' ' . sprintf(esc_html__('Job has done with warnings in %s seconds. Please resolve them for correct execution.', 'backwpup'), $logheader['runtime']) . '</p></div>';
         } else {
             $lastmsg = '<div class="updated"><p>' . sprintf(esc_html__('Job done in %s seconds.', 'backwpup'), $logheader['runtime']) . '</p></div>';
         }
         $lasterrormsg = '';
         $done = 1;
     }
     if ('.gz' == substr($logfile, -3)) {
         $logfiledata = file_get_contents('compress.zlib://' . $logfile, FALSE, NULL, $logpos);
     } else {
         $logfiledata = file_get_contents($logfile, FALSE, NULL, $logpos);
     }
     preg_match('/<body[^>]*>/si', $logfiledata, $match);
     if (!empty($match[0])) {
         $startpos = strpos($logfiledata, $match[0]) + strlen($match[0]);
     } else {
         $startpos = 0;
     }
     $endpos = stripos($logfiledata, '</body>');
     if (FALSE === $endpos) {
         $endpos = strlen($logfiledata);
     }
     $length = strlen($logfiledata) - (strlen($logfiledata) - $endpos) - $startpos;
     //check if restart must done on ALTERNATE_WP_CRON
     if (is_object($job_object) && defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
         $restart = BackWPup_Job::get_jobrun_url('restartalt');
         if ($job_object->pid === 0 && $job_object->uniqid === '') {
             $restart_url = $restart['url'];
         }
         $last_update = microtime(TRUE) - $job_object->timestamp_last_update;
         if (empty($job_object->pid) && $last_update > 10) {
             $restart_url = $restart['url'];
         }
     }
     wp_send_json(array('log_pos' => strlen($logfiledata) + $logpos, 'log_text' => substr($logfiledata, $startpos, $length), 'warning_count' => $warnings, 'error_count' => $errors, 'running_time' => $runtime, 'step_percent' => $step_percent, 'on_step' => $onstep, 'last_msg' => $lastmsg, 'last_error_msg' => $lasterrormsg, 'sub_step_percent' => $substep_percent, 'restart_url' => $restart_url, 'job_done' => $done));
 }
Exemplo n.º 5
0
    /**
     * Page Output
     */
    public static function page()
    {
        global $wpdb;
        ?>
    <div class="wrap" id="backwpup-page">
		<h2><span id="backwpup-page-icon">&nbsp;</span><?php 
        echo sprintf(__('%s Settings', 'backwpup'), BackWPup::get_plugin_data('name'));
        ?>
</h2>
		<?php 
        $tabs = array('general' => __('General', 'backwpup'), 'job' => __('Jobs', 'backwpup'), 'log' => __('Logs', 'backwpup'), 'net' => __('Network', 'backwpup'), 'apikey' => __('API Keys', 'backwpup'), 'information' => __('Information', 'backwpup'));
        $tabs = apply_filters('backwpup_page_settings_tab', $tabs);
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($tabs as $id => $name) {
            echo '<a href="#backwpup-tab-' . $id . '" class="nav-tab">' . $name . '</a>';
        }
        echo '</h2>';
        BackWPup_Admin::display_messages();
        ?>

    <form id="settingsform" action="<?php 
        echo admin_url('admin-post.php?action=backwpup');
        ?>
" method="post">
		<?php 
        wp_nonce_field('backwpupsettings_page');
        ?>
        <input type="hidden" name="page" value="backwpupsettings" />
    	<input type="hidden" name="anchor" value="#backwpup-tab-general" />

		<div class="table ui-tabs-hide" id="backwpup-tab-general">

			<h3 class="title"><?php 
        _e('Display Settings', 'backwpup');
        ?>
</h3>
            <p><?php 
        _e('Do you want to see BackWPup in the WordPress admin bar?', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Admin bar', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Admin Bar', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="showadminbar">
                                <input name="showadminbar" type="checkbox" id="showadminbar"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_showadminbar'), TRUE);
        ?>
 />
								<?php 
        _e('Show BackWPup links in admin bar.', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="showfoldersize">
                                <input name="showfoldersize" type="checkbox" id="showfoldersize"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_showfoldersize'), TRUE);
        ?>
 />
								<?php 
        _e('Display folder sizes in the files tab when editing a job. (Might increase loading time of files tab.)', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
            </table>
			<h3 class="title"><?php 
        _e('Security', 'backwpup');
        ?>
</h3>
			<p><?php 
        _e('Security option for BackWPup', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Protect folders', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Protect folders', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="protectfolders">
                                <input name="protectfolders" type="checkbox" id="protectfolders"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_protectfolders'), TRUE);
        ?>
 />
								<?php 
        _e('Protect BackWPup folders ( Temp, Log and Backups ) with <code>.htaccess</code> and <code>index.php</code>', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>

			<?php 
        do_action('backwpup_page_settings_tab_generel');
        ?>

		</div>

        <div class="table ui-tabs-hide" id="backwpup-tab-log">

            <p><?php 
        _e('Every time BackWPup runs a backup job, a log file is being generated. Choose where to store your log files and how many of them.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="logfolder"><?php 
        _e('Log file folder', 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="logfolder" type="text" id="logfolder"
                               value="<?php 
        echo get_site_option('backwpup_cfg_logfolder');
        ?>
"
                               class="regular-text code"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="maxlogs"><?php 
        _e('Maximum number of log files in folder', 'backwpup');
        ?>
</label>
                    </th>
                    <td>
                        <input name="maxlogs" type="text" id="maxlogs" title="<?php 
        esc_attr_e('Oldest files will be deleted first.', 'backwpup');
        ?>
"
                               value="<?php 
        echo get_site_option('backwpup_cfg_maxlogs');
        ?>
" class="small-text code help-tip"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Compression', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Compression', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="gzlogs">
                                <input name="gzlogs" type="checkbox" id="gzlogs"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_gzlogs'), TRUE);
        if (!function_exists('gzopen')) {
            echo " disabled=\"disabled\"";
        }
        ?>
 />
								<?php 
        _e('Compress log files with GZip.', 'backwpup');
        ?>
</label>
                        </fieldset>
                    </td>
                </tr>
            </table>

        </div>
        <div class="table ui-tabs-hide" id="backwpup-tab-job">

            <p><?php 
        _e('There are a couple of general options for backup jobs. Set them here.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row">
                        <label for="jobstepretry"><?php 
        _e("Maximum number of retries for job steps", 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="jobstepretry" type="text" id="jobstepretry"
                               value="<?php 
        echo get_site_option('backwpup_cfg_jobstepretry');
        ?>
"
                               class="small-text code" />
                    </td>
                </tr>
				<tr>
                    <th scope="row"><?php 
        _e('Maximum script execution time', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Maximum PHP Script execution time', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobmaxexecutiontime">
                                <input name="jobmaxexecutiontime" type="text" id="jobmaxexecutiontime" size="3" title="<?php 
        esc_attr_e('Job will restart before hitting maximum execution time. It will not work with CLI and not on every step during execution. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used.', 'backwpup');
        ?>
"
                                       value="<?php 
        echo get_site_option('backwpup_cfg_jobmaxexecutiontime');
        ?>
" class="help-tip" />
								<?php 
        _e('seconds. 0 = disabled.', 'backwpup');
        ?>
							</label>
                        </fieldset>
                    </td>
                </tr>
				<tr>
                    <th scope="row"><?php 
        _e('Method for creating ZIP-file archives', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Method for creating ZIP-file archives', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobziparchivemethod">
								<select name="jobziparchivemethod" size="1" class="help-tip" title="<?php 
        esc_attr_e('Auto = Uses PHP class ZipArchive if available; otherwise uses PclZip.<br />ZipArchive = Uses less memory, but many open files at a time.<br />PclZip = Uses more memory, but only 2 open files at a time.', 'backwpup');
        ?>
">
									<option value="" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), '');
        ?>
><?php 
        _e('Auto', 'backwpup');
        ?>
</option>
                                    <option value="ZipArchive" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), 'ZipArchive');
        disabled(function_exists('ZipArchive'), TRUE);
        ?>
><?php 
        _e('ZipArchive', 'backwpup');
        ?>
</option>
                                    <option value="PclZip" <?php 
        selected(get_site_option('backwpup_cfg_jobziparchivemethod'), 'PclZip');
        ?>
><?php 
        _e('PclZip', 'backwpup');
        ?>
</option>
                                </select>
                            </label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row">
                        <label for="jobrunauthkey"><?php 
        _e('Key to start jobs externally with an URL', 'backwpup');
        ?>
</label>
                    </th>
                    <td>
                        <input name="jobrunauthkey" type="text" id="jobrunauthkey" title="<?php 
        esc_attr_e('empty = deactivated. Will be used to protect job starts from unauthorized person.', 'backwpup');
        ?>
"
                               value="<?php 
        echo get_site_option('backwpup_cfg_jobrunauthkey');
        ?>
" class="text code help-tip"/>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('No translation', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('No Translation', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobnotranslate">
                                <input name="jobnotranslate" type="checkbox" id="jobnotranslate"
                                       value="1" <?php 
        checked(get_site_option('backwpup_cfg_jobnotranslate'), TRUE);
        ?>
 />
								<?php 
        _e('No translation for the job, the log will be written in English', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</span>
                            </legend>
                            <label for="jobwaittimems">
								<select name="jobwaittimems" size="1" class="help-tip" title="<?php 
        esc_attr_e('This adds short pauses to the process. Can be used to reduce the CPU load.<br /> Disabled = off<br /> minimum = shortest sleep<br /> medium = middle between minimum and maximum<br /> maximum = longest sleep<br />', 'backwpup');
        ?>
">
									<option value="0" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 0);
        ?>
><?php 
        _e('disabled', 'backwpup');
        ?>
</option>
                                    <option value="10000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 10000);
        ?>
><?php 
        _e('minimum', 'backwpup');
        ?>
</option>
                                    <option value="30000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 30000);
        ?>
><?php 
        _e('medium', 'backwpup');
        ?>
</option>
                                    <option value="90000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 90000);
        ?>
><?php 
        _e('maximum', 'backwpup');
        ?>
</option>
                                </select>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-net">

			<h3 class="title"><?php 
        _e('Authentication', 'backwpup');
        ?>
</h3>
            <p><?php 
        _e('Is your blog protected with HTTP basic authentication (.htaccess)? If yes, please set the username and password for authentication here.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="httpauthuser"><?php 
        _e('Username:'******'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="httpauthuser" type="text" id="httpauthuser"
                               value="<?php 
        echo get_site_option('backwpup_cfg_httpauthuser');
        ?>
"
                               class="regular-text" autocomplete="off" />
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="httpauthpassword"><?php 
        _e('Password:'******'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="httpauthpassword" type="password" id="httpauthpassword"
                               value="<?php 
        echo BackWPup_Encryption::decrypt(get_site_option('backwpup_cfg_httpauthpassword'));
        ?>
"
                               class="regular-text" autocomplete="off" />
                </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-apikey">

			<?php 
        do_action('backwpup_page_settings_tab_apikey');
        ?>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-information">
			<br />
			<?php 
        echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width: 85%;margin-left:auto;;margin-right:auto;">';
        echo '<thead><tr><th width="35%">' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></thead>';
        echo '<tfoot><tr><th>' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></tfoot>';
        echo '<tr title="&gt;=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('wp_version') . '</td></tr>';
        if (!class_exists('BackWPup_Pro', FALSE)) {
            echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . ' <a href="' . translate(BackWPup::get_plugin_data('pluginuri'), 'backwpup') . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
        } else {
            echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . BackWPup::get_plugin_data('Version') . '</td></tr>';
        }
        echo '<tr title="&gt;=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . PHP_VERSION . '</td></tr>';
        echo '<tr title="&gt;=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . $wpdb->get_var("SELECT VERSION() AS version") . '</td></tr>';
        if (function_exists('curl_version')) {
            $curlversion = curl_version();
            echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . $curlversion['version'] . '</td></tr>';
            echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . $curlversion['ssl_version'] . '</td></tr>';
        } else {
            echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . __('unavailable', 'backwpup') . '</td></tr>';
        }
        echo '<tr title=""><td>' . __('WP-Cron url:', 'backwpup') . '</td><td>' . site_url('wp-cron.php') . '</td></tr>';
        //response test
        echo '<tr><td>' . __('Server self connect:', 'backwpup') . '</td><td>';
        $raw_response = BackWPup_Job::get_jobrun_url('test');
        $test_result = '';
        if (is_wp_error($raw_response)) {
            $test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), $raw_response->get_error_message());
        } elseif (200 != wp_remote_retrieve_response_code($raw_response) && 204 != wp_remote_retrieve_response_code($raw_response)) {
            $test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response));
        }
        $headers = wp_remote_retrieve_headers($raw_response);
        if (isset($headers['x-backwpup-ver']) && $headers['x-backwpup-ver'] != BackWPup::get_plugin_data('version')) {
            $test_result .= sprintf(__('The BackWPup HTTP response header returns a false value: "%s"', 'backwpup'), $headers['x-backwpup-ver']);
        }
        if (empty($test_result)) {
            _e('Response Test O.K.', 'backwpup');
        } else {
            echo $test_result;
        }
        echo '</td></tr>';
        //folder test
        echo '<tr><td>' . __('Temp folder:', 'backwpup') . '</td><td>';
        if (!is_dir(BackWPup::get_plugin_data('TEMP'))) {
            echo sprintf(__('Temp folder %s doesn\'t exist.', 'backwpup'), BackWPup::get_plugin_data('TEMP'));
        } elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
            echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), BackWPup::get_plugin_data('TEMP'));
        } else {
            echo BackWPup::get_plugin_data('TEMP');
        }
        echo '</td></tr>';
        echo '<tr><td>' . __('Log folder:', 'backwpup') . '</td><td>';
        if (!is_dir(get_site_option('backwpup_cfg_logfolder'))) {
            echo sprintf(__('Logs folder %s not exist.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
        } elseif (!is_writable(get_site_option('backwpup_cfg_logfolder'))) {
            echo sprintf(__('Log folder %s is not writable.', 'backwpup'), get_site_option('backwpup_cfg_logfolder'));
        } else {
            echo get_site_option('backwpup_cfg_logfolder');
        }
        echo '</td></tr>';
        echo '<tr title=""><td>' . __('Server', 'backwpup') . '</td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>';
        echo '<tr title=""><td>' . __('Operating System', 'backwpup') . '</td><td>' . PHP_OS . '</td></tr>';
        echo '<tr title=""><td>' . __('PHP SAPI', 'backwpup') . '</td><td>' . PHP_SAPI . '</td></tr>';
        echo '<tr title=""><td>' . __('Current PHP user', 'backwpup') . '</td><td>' . get_current_user() . '</td></tr>';
        $text = (bool) ini_get('safe_mode') ? __('On', 'backwpup') : __('Off', 'backwpup');
        echo '<tr title=""><td>' . __('Safe Mode', 'backwpup') . '</td><td>' . $text . '</td></tr>';
        echo '<tr title="&gt;=30"><td>' . __('Maximum execution time', 'backwpup') . '</td><td>' . ini_get('max_execution_time') . ' ' . __('seconds', 'backwpup') . '</td></tr>';
        if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('FS_CHMOD_DIR')) {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>' . FS_CHMOD_DIR . '</td></tr>';
        } else {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>0755</td></tr>';
        }
        $now = localtime(time(), TRUE);
        echo '<tr title=""><td>' . __('Server Time', 'backwpup') . '</td><td>' . $now['tm_hour'] . ':' . $now['tm_min'] . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time', 'backwpup') . '</td><td>' . date_i18n('H:i') . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Timezone', 'backwpup') . '</td><td>' . get_option('timezone_string') . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time offset', 'backwpup') . '</td><td>' . sprintf(__('%s hours', 'backwpup'), get_option('gmt_offset')) . '</td></tr>';
        echo '<tr title="WPLANG"><td>' . __('Blog language', 'backwpup') . '</td><td>' . get_bloginfo('language') . '</td></tr>';
        echo '<tr title="utf8"><td>' . __('MySQL Client encoding', 'backwpup') . '</td><td>';
        echo defined('DB_CHARSET') ? DB_CHARSET : '';
        echo '</td></tr>';
        echo '<tr title="URF-8"><td>' . __('Blog charset', 'backwpup') . '</td><td>' . get_bloginfo('charset') . '</td></tr>';
        echo '<tr title="&gt;=128M"><td>' . __('PHP Memory limit', 'backwpup') . '</td><td>' . ini_get('memory_limit') . '</td></tr>';
        echo '<tr title="WP_MEMORY_LIMIT"><td>' . __('WP memory limit', 'backwpup') . '</td><td>' . WP_MEMORY_LIMIT . '</td></tr>';
        echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __('WP maximum memory limit', 'backwpup') . '</td><td>' . WP_MAX_MEMORY_LIMIT . '</td></tr>';
        echo '<tr title=""><td>' . __('Memory in use', 'backwpup') . '</td><td>' . size_format(@memory_get_usage(TRUE), 2) . '</td></tr>';
        //disabled PHP functions
        $disabled = ini_get('disable_functions');
        if (!empty($disabled)) {
            $disabledarry = explode(',', $disabled);
            echo '<tr title=""><td>' . __('Disabled PHP Functions:', 'backwpup') . '</td><td>';
            echo implode(', ', $disabledarry);
            echo '</td></tr>';
        }
        //Loaded PHP Extensions
        echo '<tr title=""><td>' . __('Loaded PHP Extensions:', 'backwpup') . '</td><td>';
        $extensions = get_loaded_extensions();
        sort($extensions);
        echo implode(', ', $extensions);
        echo '</td></tr>';
        echo '</table>';
        ?>
        </div>

		<?php 
        do_action('backwpup_page_settings_tab_content');
        ?>

        <p class="submit">
            <input type="submit" name="submit" id="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'backwpup');
        ?>
" />
			&nbsp;
			<input type="submit" name="default_settings" id="default_settings" class="button-secondary" value="<?php 
        _e('Reset all settings to default', 'backwpup');
        ?>
" />
        </p>
    </form>
    </div>
	<?php 
    }
Exemplo n.º 6
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' => $jobid));
                     BackWPup_Option::delete_job($jobid);
                 }
             }
             break;
         case 'copy':
             //Copy Job
             if (!current_user_can('backwpup_jobs_edit')) {
                 break;
             }
             $old_job_id = (int) $_GET['jobid'];
             check_admin_referer('copy-job_' . $_GET['jobid']);
             //create new
             $newjobid = BackWPup_Option::get_job_ids();
             sort($newjobid);
             $newjobid = end($newjobid) + 1;
             $old_options = BackWPup_Option::get_job($old_job_id);
             foreach ($old_options as $key => $option) {
                 if ($key == "jobid") {
                     $option = $newjobid;
                 }
                 if ($key == "name") {
                     $option = __('Copy of', 'backwpup') . ' ' . $option;
                 }
                 if ($key == "activetype") {
                     $option = '';
                 }
                 if ($key == "archivename") {
                     $option = str_replace($_GET['jobid'], $newjobid, $option);
                 }
                 if ($key == "logfile" || $key == "lastbackupdownloadurl" || $key == "lastruntime" || $key == "lastrun") {
                     continue;
                 }
                 BackWPup_Option::update($newjobid, $key, $option);
             }
             break;
         case 'start_cli':
             //Get cmd start file
             if (!current_user_can('backwpup_jobs_start')) {
                 break;
             }
             check_admin_referer('start_cli');
             if (empty($_GET['jobid'])) {
                 break;
             }
             if (FALSE === strpos(PHP_OS, "WIN")) {
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: application/octet-stream");
                 header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".sh;");
                 if (defined('PHP_BINDIR')) {
                     echo "#!/bin/sh" . PHP_EOL;
                 }
                 echo "@\$1php -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
                 die;
             } else {
                 header("Pragma: public");
                 header("Expires: 0");
                 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                 header("Content-Type: application/octet-stream");
                 header("Content-Disposition: attachment; filename=BackWPup_cmd_start_job_" . $_GET['jobid'] . ".cmd;");
                 echo "@%1php.exe -c \"" . php_ini_loaded_file() . "\" -r \"\$_SERVER[ 'SERVER_ADDR' ] = '" . $_SERVER['SERVER_ADDR'] . "'; \$_SERVER[ 'REMOTE_ADDR' ] = '" . $_SERVER['REMOTE_ADDR'] . "'; \$_SERVER[ 'HTTP_HOST' ] = '" . $_SERVER['HTTP_HOST'] . "'; \$_SERVER[ 'HTTP_USER_AGENT' ] = '" . BackWPup::get_plugin_data('name') . "'; define( 'DOING_CRON', TRUE ); require '" . ABSPATH . "wp-load.php'; if( class_exists( 'BackWPup_Job' ) ) BackWPup_Job::start_cli( " . $_GET['jobid'] . " );\"";
                 die;
             }
             break;
         case 'runnow':
             if (!empty($_GET['jobid'])) {
                 if (!current_user_can('backwpup_jobs_start')) {
                     wp_die(__('Sorry, you don\'t have permissions to do that.', 'backwpup'));
                 }
                 check_admin_referer('backwpup_job_run-runnowlink');
                 //check temp folder
                 BackWPup_Job::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE);
                 //check log folder
                 BackWPup_Job::check_folder(get_site_option('backwpup_cfg_logfolder'));
                 //check server callback
                 $raw_response = BackWPup_Job::get_jobrun_url('test');
                 $test_result = '';
                 if (is_wp_error($raw_response)) {
                     $test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), $raw_response->get_error_message());
                 } elseif (200 != wp_remote_retrieve_response_code($raw_response) && 204 != wp_remote_retrieve_response_code($raw_response)) {
                     $test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), wp_remote_retrieve_response_code($raw_response));
                 }
                 if (!empty($test_result)) {
                     BackWPup_Admin::message($test_result, TRUE);
                 }
                 //only start job if messages empty
                 $log_messages = BackWPup_Admin::get_messages();
                 if (empty($log_messages)) {
                     $old_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile');
                     BackWPup_Job::get_jobrun_url('runnow', $_GET['jobid']);
                     usleep(250000);
                     //wait a quarter second
                     $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE);
                     //sleep as long as job not started
                     $i = 0;
                     while ($old_log_file == $new_log_file) {
                         usleep(250000);
                         //wait a quarter second for next try
                         $new_log_file = BackWPup_Option::get($_GET['jobid'], 'logfile', NULL, FALSE);
                         //wait maximal 10 sec.
                         if ($i >= 40) {
                             BackWPup_Admin::message(sprintf(__('Job start for "%s" not answered after 10 seconds.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))), TRUE);
                             break 2;
                         }
                         $i++;
                     }
                     BackWPup_Admin::message(sprintf(__('Job "%s" started.', 'backwpup'), esc_attr(BackWPup_Option::get($_GET['jobid'], 'name'))));
                 }
             }
             break;
         case 'abort':
             //Abort Job
             if (!current_user_can('backwpup_jobs_start')) {
                 break;
             }
             check_admin_referer('abort-job');
             if (!file_exists(BackWPup::get_plugin_data('running_file'))) {
                 break;
             }
             //abort
             BackWPup_Job::user_abort();
             BackWPup_Admin::message(__('Job will be terminated.', 'backwpup'));
             break;
         default:
             do_action('backwpup_page_jobs_load', self::$listtable->current_action());
             break;
     }
     self::$listtable->prepare_items();
 }
    /**
     * Page Output
     */
    public static function page()
    {
        global $wpdb;
        ?>
    <div class="wrap" id="backwpup-page">
		<h1><?php 
        echo sprintf(__('%s &rsaquo; Settings', 'backwpup'), BackWPup::get_plugin_data('name'));
        ?>
</h1>
		<?php 
        $tabs = array('general' => __('General', 'backwpup'), 'job' => __('Jobs', 'backwpup'), 'log' => __('Logs', 'backwpup'), 'net' => __('Network', 'backwpup'), 'apikey' => __('API Keys', 'backwpup'), 'information' => __('Information', 'backwpup'));
        $tabs = apply_filters('backwpup_page_settings_tab', $tabs);
        echo '<h2 class="nav-tab-wrapper">';
        foreach ($tabs as $id => $name) {
            echo '<a href="#backwpup-tab-' . esc_attr($id) . '" class="nav-tab">' . esc_attr($name) . '</a>';
        }
        echo '</h2>';
        BackWPup_Admin::display_messages();
        ?>

    <form id="settingsform" action="<?php 
        echo admin_url('admin-post.php');
        ?>
" method="post">
		<?php 
        wp_nonce_field('backwpupsettings_page');
        ?>
        <input type="hidden" name="page" value="backwpupsettings" />
	    <input type="hidden" name="action" value="backwpup" />
    	<input type="hidden" name="anchor" value="#backwpup-tab-general" />

		<div class="table ui-tabs-hide" id="backwpup-tab-general">

			<h3 class="title"><?php 
        _e('Display Settings', 'backwpup');
        ?>
</h3>
            <p><?php 
        _e('Do you want to see BackWPup in the WordPress admin bar?', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Admin bar', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Admin Bar', 'backwpup');
        ?>
</span></legend>
                            <label for="showadminbarmenu">
                                <input name="showadminbarmenu" type="checkbox" id="showadminbarmenu" value="1" <?php 
        checked(get_site_option('backwpup_cfg_showadminbar'), TRUE);
        ?>
 />
								<?php 
        _e('Show BackWPup links in admin bar.', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Folder sizes', 'backwpup');
        ?>
</span></legend>
                            <label for="showfoldersize">
                                <input name="showfoldersize" type="checkbox" id="showfoldersize" value="1" <?php 
        checked(get_site_option('backwpup_cfg_showfoldersize'), TRUE);
        ?>
 />
								<?php 
        _e('Display folder sizes in the files tab when editing a job. (Might increase loading time of files tab.)', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>
			<h3 class="title"><?php 
        _e('Security', 'backwpup');
        ?>
</h3>
			<p><?php 
        _e('Security option for BackWPup', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><?php 
        _e('Protect folders', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Protect folders', 'backwpup');
        ?>
</span></legend>
                            <label for="protectfolders">
                                <input name="protectfolders" type="checkbox" id="protectfolders" value="1" <?php 
        checked(get_site_option('backwpup_cfg_protectfolders'), TRUE);
        ?>
 />
								<?php 
        _e('Protect BackWPup folders ( Temp, Log and Backups ) with <code>.htaccess</code> and <code>index.php</code>', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
            </table>

			<?php 
        do_action('backwpup_page_settings_tab_generel');
        ?>

		</div>

        <div class="table ui-tabs-hide" id="backwpup-tab-log">

            <p><?php 
        _e('Every time BackWPup runs a backup job, a log file is being generated. Choose where to store your log files and how many of them.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="logfolder"><?php 
        _e('Log file folder', 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="logfolder" type="text" id="logfolder" value="<?php 
        echo esc_attr(get_site_option('backwpup_cfg_logfolder'));
        ?>
" class="regular-text code"/>
	                    <p class="description"><?php 
        echo sprintf(__('You can use absolute or relative path! Relative path is relative to %s.', 'backwpup'), '<code>' . trailingslashit(str_replace('\\', '/', WP_CONTENT_DIR)) . '</code>');
        ?>
</p>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="maxlogs"><?php 
        _e('Maximum log files', 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="maxlogs" type="number" min="0" step="1" id="maxlogs" value="<?php 
        echo absint(get_site_option('backwpup_cfg_maxlogs'));
        ?>
" class="small-text"/>
	                    <?php 
        _e('Maximum log files in folder.', 'backwpup');
        ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Compression', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Compression', 'backwpup');
        ?>
</span></legend>
                            <label for="gzlogs">
                                <input name="gzlogs" type="checkbox" id="gzlogs" value="1" <?php 
        checked(get_site_option('backwpup_cfg_gzlogs'), TRUE);
        if (!function_exists('gzopen')) {
            echo ' disabled="disabled"';
        }
        ?>
 />
								<?php 
        _e('Compress log files with GZip.', 'backwpup');
        ?>
                            </label>
                        </fieldset>
                    </td>
                </tr>
	            <tr>
		            <th scope="row"><?php 
        _e('Logging Level', 'backwpup');
        ?>
</th>
		            <td>
			            <fieldset>
				            <legend class="screen-reader-text"><span><?php 
        _e('Logging Level', 'backwpup');
        ?>
</span></legend>
				            <label for="loglevel">
					            <select name="loglevel" size="1">
						            <option value="normal_translated" <?php 
        selected(get_site_option('backwpup_cfg_loglevel', 'normal_translated'), 'normal_translated');
        ?>
><?php 
        _e('Normal (translated)', 'backwpup');
        ?>
</option>
						            <option value="normal" <?php 
        selected(get_site_option('backwpup_cfg_loglevel'), 'normal');
        ?>
><?php 
        _e('Normal (not translated)', 'backwpup');
        ?>
</option>
						            <option value="debug_translated" <?php 
        selected(get_site_option('backwpup_cfg_loglevel'), 'debug_translated');
        ?>
><?php 
        _e('Debug (translated)', 'backwpup');
        ?>
</option>
						            <option value="debug" <?php 
        selected(get_site_option('backwpup_cfg_loglevel'), 'debug');
        ?>
><?php 
        _e('Debug (not translated)', 'backwpup');
        ?>
</option>
					            </select>
				            </label>
				            <p class="description"><?php 
        esc_attr_e('Debug log has much more informations than normal logs. It is for support and should be handled carefully. For support is the best to use a not translated log file. Usage of not translated logs can reduce the PHP memory usage too.', 'backwpup');
        ?>
</p>
			            </fieldset>
		            </td>
	            </tr>
            </table>

        </div>
        <div class="table ui-tabs-hide" id="backwpup-tab-job">

            <p><?php 
        _e('There are a couple of general options for backup jobs. Set them here.', 'backwpup');
        ?>
</p>
            <table class="form-table">
                <tr>
                    <th scope="row"><label for="jobstepretry"><?php 
        _e("Maximum number of retries for job steps", 'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="jobstepretry" type="number" min="1" step="1" max="99" id="jobstepretry" value="<?php 
        echo absint(get_site_option('backwpup_cfg_jobstepretry'));
        ?>
" class="small-text" />
                    </td>
                </tr>
				<tr>
                    <th scope="row"><?php 
        _e('Maximum script execution time', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Maximum PHP Script execution time', 'backwpup');
        ?>
</span></legend>
                            <label for="jobmaxexecutiontime">
                                <input name="jobmaxexecutiontime" type="number" min="0" step="1" max="300" id="jobmaxexecutiontime" value="<?php 
        echo absint(get_site_option('backwpup_cfg_jobmaxexecutiontime'));
        ?>
" class="small-text" />
								<?php 
        _e('seconds.', 'backwpup');
        ?>
	                            <p class="description"><?php 
        _e('Job will restart before hitting maximum execution time. Restarts will be disabled on CLI usage. If <code>ALTERNATE_WP_CRON</code> has been defined, WordPress Cron will be used for restarts, so it can take a while. 0 means no maximum.', 'backwpup');
        ?>
</p>
							</label>
                        </fieldset>
                    </td>
                </tr>
                <tr>
                    <th scope="row">
                        <label for="jobrunauthkey"><?php 
        _e('Key to start jobs externally with an URL', 'backwpup');
        ?>
</label>
                    </th>
                    <td>
                        <input name="jobrunauthkey" type="text" id="jobrunauthkey" value="<?php 
        echo esc_attr(get_site_option('backwpup_cfg_jobrunauthkey'));
        ?>
" class="text code"/>
	                    <p class="description"><?php 
        _e('Will be used to protect job starts from unauthorized person.', 'backwpup');
        ?>
</p>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</th>
                    <td>
                        <fieldset>
                            <legend class="screen-reader-text"><span><?php 
        _e('Reduce server load', 'backwpup');
        ?>
</span></legend>
                            <label for="jobwaittimems">
								<select name="jobwaittimems" size="1">
									<option value="0" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 0);
        ?>
><?php 
        _e('disabled', 'backwpup');
        ?>
</option>
                                    <option value="10000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 10000);
        ?>
><?php 
        _e('minimum', 'backwpup');
        ?>
</option>
                                    <option value="30000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 30000);
        ?>
><?php 
        _e('medium', 'backwpup');
        ?>
</option>
                                    <option value="90000" <?php 
        selected(get_site_option('backwpup_cfg_jobwaittimems'), 90000);
        ?>
><?php 
        _e('maximum', 'backwpup');
        ?>
</option>
                                </select>
                            </label>
	                        <p class="description"><?php 
        _e('This adds short pauses to the process. Can be used to reduce the CPU load.', 'backwpup');
        ?>
</p>
                        </fieldset>
                    </td>
                </tr>
	            <tr>
		            <th scope="row"><?php 
        _e('Empty output on working', 'backwpup');
        ?>
</th>
		            <td>
			            <fieldset>
				            <legend class="screen-reader-text"><span><?php 
        _e('Enable an empty Output on backup working.', 'backwpup');
        ?>
</span></legend>
				            <label for="jobdooutput">
					            <input name="jobdooutput" type="checkbox" id="jobdooutput" value="1" <?php 
        checked(get_site_option('backwpup_cfg_jobdooutput'), TRUE);
        ?>
 />
					            <?php 
        _e('Enable an empty Output on backup working.', 'backwpup');
        ?>
				            </label>
				            <p class="description"><?php 
        _e('This do an empty output on job working. This can help in some situations or can brake the working. You must test it.', 'backwpup');
        ?>
</p>
			            </fieldset>
		            </td>
	            </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-net">

			<h3><?php 
        echo sprintf(__('Authentication for <code>%s</code>', 'backwpup'), site_url('wp-cron.php'));
        ?>
</h3>
            <p><?php 
        _e('If you protected your blog with HTTP basic authentication (.htaccess), or you use a Plugin to secure wp-cron.php, then use the authentication methods below.', 'backwpup');
        ?>
</p>
            <?php 
        $authentication = get_site_option('backwpup_cfg_authentication', array('method' => '', 'basic_user' => '', 'basic_password' => '', 'user_id' => 0, 'query_arg' => ''));
        ?>
	        <table class="form-table">
	            <tr>
		            <th scope="row"><?php 
        _e('Authentication method', 'backwpup');
        ?>
</th>
		            <td>
			            <fieldset>
				            <legend class="screen-reader-text"><span><?php 
        _e('Authentication method', 'backwpup');
        ?>
</span></legend>
				            <label for="authentication_method">
					            <select name="authentication_method" id="authentication_method" size="1" >
						            <option value="" <?php 
        selected($authentication['method'], '');
        ?>
><?php 
        _e('none', 'backwpup');
        ?>
</option>
						            <option value="basic" <?php 
        selected($authentication['method'], 'basic');
        ?>
><?php 
        _e('Basic auth', 'backwpup');
        ?>
</option>
						            <option value="user" <?php 
        selected($authentication['method'], 'user');
        ?>
><?php 
        _e('WordPress User', 'backwpup');
        ?>
</option>
						            <option value="query_arg" <?php 
        selected($authentication['method'], 'query_arg');
        ?>
><?php 
        _e('Query argument', 'backwpup');
        ?>
</option>
					            </select>
				            </label>
			            </fieldset>
		            </td>
	            </tr>
                <tr class="authentication_basic" <?php 
        if ($authentication['method'] !== 'basic') {
            echo 'style="display:none"';
        }
        ?>
>
                    <th scope="row"><label for="authentication_basic_user"><?php 
        _e('Basic Auth Username:'******'backwpup');
        ?>
</label></th>
                    <td>
                        <input name="authentication_basic_user" type="text" id="authentication_basic_user" value="<?php 
        echo esc_attr($authentication['basic_user']);
        ?>
" class="regular-text" autocomplete="off" />
                    </td>
                </tr>
                <tr class="authentication_basic" <?php 
        if ($authentication['method'] !== 'basic') {
            echo 'style="display:none"';
        }
        ?>
>
			        <th scope="row"><label for="authentication_basic_password"><?php 
        _e('Basic Auth Password:'******'backwpup');
        ?>
</label></th>
			        <td>
				        <input name="authentication_basic_password" type="password" id="authentication_basic_password" value="<?php 
        echo esc_attr(BackWPup_Encryption::decrypt($authentication['basic_password']));
        ?>
" class="regular-text" autocomplete="off" />
		        </tr>
		        <tr class="authentication_user" <?php 
        if ($authentication['method'] !== 'user') {
            echo 'style="display:none"';
        }
        ?>
>
			        <th scope="row"><?php 
        _e('Select WordPress User', 'backwpup');
        ?>
</th>
			        <td>
				        <fieldset>
					        <legend class="screen-reader-text"><span><?php 
        _e('Select WordPress User', 'backwpup');
        ?>
</span>
					        </legend>
					        <label for="authentication_user_id">
						        <select name="authentication_user_id" size="1" >
							        <?php 
        $users = get_users(array('who' => 'administrators', 'number' => 99, 'orderby' => 'display_name'));
        foreach ($users as $user) {
            echo '<option value="' . $user->ID . '" ' . selected($authentication['user_id'], $user->ID, FALSE) . '>' . esc_attr($user->display_name) . '</option>';
        }
        ?>
						        </select>
					        </label>
				        </fieldset>
			        </td>
		        </tr>
		        <tr class="authentication_query_arg" <?php 
        if ($authentication['method'] != 'query_arg') {
            echo 'style="display:none"';
        }
        ?>
>
			        <th scope="row"><label for="authentication_query_arg"><?php 
        _e('Query arg key=value:', 'backwpup');
        ?>
</label></th>
			        <td>
				        ?<input name="authentication_query_arg" type="text" id="authentication_query_arg" value="<?php 
        echo esc_attr($authentication['query_arg']);
        ?>
" class="regular-text" />
			        </td>
		        </tr>
            </table>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-apikey">

			<?php 
        do_action('backwpup_page_settings_tab_apikey');
        ?>

        </div>

        <div class="table ui-tabs-hide" id="backwpup-tab-information">
			<br />
			<?php 
        echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width:85%;margin-left:auto;margin-right:auto;">';
        echo '<thead><tr><th width="35%">' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></thead>';
        echo '<tfoot><tr><th>' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></tfoot>';
        echo '<tr title="&gt;=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('wp_version')) . '</td></tr>';
        if (!class_exists('BackWPup_Pro', FALSE)) {
            echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . ' <a href="' . __('http://backwpup.com', 'backwpup') . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
        } else {
            echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . '</td></tr>';
        }
        $bit = '';
        if (PHP_INT_SIZE === 4) {
            $bit = ' (32bit)';
        }
        if (PHP_INT_SIZE === 8) {
            $bit = ' (64bit)';
        }
        echo '<tr title="&gt;=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . esc_html(PHP_VERSION . ' ' . $bit) . '</td></tr>';
        echo '<tr title="&gt;=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . esc_html($wpdb->get_var("SELECT VERSION() AS version")) . '</td></tr>';
        if (function_exists('curl_version')) {
            $curlversion = curl_version();
            echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . esc_html($curlversion['version']) . '</td></tr>';
            echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . esc_html($curlversion['ssl_version']) . '</td></tr>';
        } else {
            echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . __('unavailable', 'backwpup') . '</td></tr>';
        }
        echo '<tr title=""><td>' . __('WP-Cron url:', 'backwpup') . '</td><td>' . site_url('wp-cron.php') . '</td></tr>';
        //response test
        echo '<tr><td>' . __('Server self connect:', 'backwpup') . '</td><td>';
        $raw_response = BackWPup_Job::get_jobrun_url('test');
        $response_code = wp_remote_retrieve_response_code($raw_response);
        $response_body = wp_remote_retrieve_body($raw_response);
        if (strstr($response_body, 'BackWPup test request') === false) {
            $test_result = __('<strong>Not expected HTTP response:</strong><br>', 'backwpup');
            if (!$response_code) {
                $test_result .= sprintf(__('WP Http Error: <code>%s</code>', 'backwpup'), esc_html($raw_response->get_error_message())) . '<br>';
            } else {
                $test_result .= sprintf(__('Status-Code: <code>%d</code>', 'backwpup'), esc_html($response_code)) . '<br>';
            }
            $response_headers = wp_remote_retrieve_headers($raw_response);
            foreach ($response_headers as $key => $value) {
                $test_result .= esc_html(ucfirst($key)) . ': <code>' . esc_html($value) . '</code><br>';
            }
            $content = esc_html(wp_remote_retrieve_body($raw_response));
            if ($content) {
                $test_result .= sprintf(__('Content: <code>%s</code>', 'backwpup'), $content);
            }
            echo $test_result;
        } else {
            _e('Response Test O.K.', 'backwpup');
        }
        echo '</td></tr>';
        //folder test
        echo '<tr><td>' . __('Temp folder:', 'backwpup') . '</td><td>';
        if (!is_dir(BackWPup::get_plugin_data('TEMP'))) {
            echo sprintf(__('Temp folder %s doesn\'t exist.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
        } elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
            echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
        } else {
            echo esc_html(BackWPup::get_plugin_data('TEMP'));
        }
        echo '</td></tr>';
        $log_folder = esc_html(get_site_option('backwpup_cfg_logfolder'));
        $log_folder = BackWPup_File::get_absolute_path($log_folder);
        echo '<tr><td>' . __('Log folder:', 'backwpup') . '</td><td>';
        if (!is_dir($log_folder)) {
            echo sprintf(__('Logs folder %s not exist.', 'backwpup'), $log_folder);
        } elseif (!is_writable($log_folder)) {
            echo sprintf(__('Log folder %s is not writable.', 'backwpup'), $log_folder);
        } else {
            echo $log_folder;
        }
        echo '</td></tr>';
        echo '<tr title=""><td>' . __('Server', 'backwpup') . '</td><td>' . esc_html($_SERVER['SERVER_SOFTWARE']) . '</td></tr>';
        echo '<tr title=""><td>' . __('Operating System', 'backwpup') . '</td><td>' . esc_html(PHP_OS) . '</td></tr>';
        echo '<tr title=""><td>' . __('PHP SAPI', 'backwpup') . '</td><td>' . esc_html(PHP_SAPI) . '</td></tr>';
        $php_user = __('Function Disabled', 'backwpup');
        if (function_exists('get_current_user')) {
            $php_user = get_current_user();
        }
        echo '<tr title=""><td>' . __('Current PHP user', 'backwpup') . '</td><td>' . esc_html($php_user) . '</td></tr>';
        echo '<tr title="&gt;=30"><td>' . __('Maximum execution time', 'backwpup') . '</td><td>' . esc_html(ini_get('max_execution_time')) . ' ' . __('seconds', 'backwpup') . '</td></tr>';
        if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
        } else {
            echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
        }
        if (defined('FS_CHMOD_DIR')) {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>' . esc_html(FS_CHMOD_DIR) . '</td></tr>';
        } else {
            echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>0755</td></tr>';
        }
        $now = localtime(time(), TRUE);
        echo '<tr title=""><td>' . __('Server Time', 'backwpup') . '</td><td>' . esc_html($now['tm_hour'] . ':' . $now['tm_min']) . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time', 'backwpup') . '</td><td>' . date('H:i', current_time('timestamp')) . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Timezone', 'backwpup') . '</td><td>' . esc_html(get_option('timezone_string')) . '</td></tr>';
        echo '<tr title=""><td>' . __('Blog Time offset', 'backwpup') . '</td><td>' . sprintf(__('%s hours', 'backwpup'), (int) get_option('gmt_offset')) . '</td></tr>';
        echo '<tr title="WPLANG"><td>' . __('Blog language', 'backwpup') . '</td><td>' . get_bloginfo('language') . '</td></tr>';
        echo '<tr title="utf8"><td>' . __('MySQL Client encoding', 'backwpup') . '</td><td>';
        echo defined('DB_CHARSET') ? DB_CHARSET : '';
        echo '</td></tr>';
        echo '<tr title="URF-8"><td>' . __('Blog charset', 'backwpup') . '</td><td>' . get_bloginfo('charset') . '</td></tr>';
        echo '<tr title="&gt;=128M"><td>' . __('PHP Memory limit', 'backwpup') . '</td><td>' . esc_html(ini_get('memory_limit')) . '</td></tr>';
        echo '<tr title="WP_MEMORY_LIMIT"><td>' . __('WP memory limit', 'backwpup') . '</td><td>' . esc_html(WP_MEMORY_LIMIT) . '</td></tr>';
        echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __('WP maximum memory limit', 'backwpup') . '</td><td>' . esc_html(WP_MAX_MEMORY_LIMIT) . '</td></tr>';
        echo '<tr title=""><td>' . __('Memory in use', 'backwpup') . '</td><td>' . size_format(@memory_get_usage(TRUE), 2) . '</td></tr>';
        //disabled PHP functions
        $disabled = esc_html(ini_get('disable_functions'));
        if (!empty($disabled)) {
            $disabledarry = explode(',', $disabled);
            echo '<tr title=""><td>' . __('Disabled PHP Functions:', 'backwpup') . '</td><td>';
            echo implode(', ', $disabledarry);
            echo '</td></tr>';
        }
        //Loaded PHP Extensions
        echo '<tr title=""><td>' . __('Loaded PHP Extensions:', 'backwpup') . '</td><td>';
        $extensions = get_loaded_extensions();
        sort($extensions);
        echo esc_html(implode(', ', $extensions));
        echo '</td></tr>';
        echo '</table>';
        ?>
        </div>

		<?php 
        do_action('backwpup_page_settings_tab_content');
        ?>

        <p class="submit">
            <input type="submit" name="submit" id="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'backwpup');
        ?>
" />
			&nbsp;
			<input type="submit" name="default_settings" id="default_settings" class="button-secondary" value="<?php 
        _e('Reset all settings to default', 'backwpup');
        ?>
" />
        </p>
    </form>
    </div>
	<?php 
    }
 protected function information()
 {
     global $wpdb;
     // Copied from BackWPup_Page_Settings
     ob_start();
     echo '<table class="wp-list-table widefat fixed" cellspacing="0" style="width: 85%;margin-left:auto;;margin-right:auto;">';
     echo '<thead><tr><th width="35%">' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></thead>';
     echo '<tfoot><tr><th>' . __('Setting', 'backwpup') . '</th><th>' . __('Value', 'backwpup') . '</th></tr></tfoot>';
     echo '<tr title="&gt;=3.2"><td>' . __('WordPress version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('wp_version')) . '</td></tr>';
     if (!class_exists('BackWPup_Pro', false)) {
         echo '<tr title=""><td>' . __('BackWPup version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . ' <a href="' . esc_url(translate(BackWPup::get_plugin_data('pluginuri'), 'backwpup')) . '">' . __('Get pro.', 'backwpup') . '</a></td></tr>';
     } else {
         echo '<tr title=""><td>' . __('BackWPup Pro version', 'backwpup') . '</td><td>' . esc_html(BackWPup::get_plugin_data('Version')) . '</td></tr>';
     }
     echo '<tr title="&gt;=5.3.3"><td>' . __('PHP version', 'backwpup') . '</td><td>' . esc_html(PHP_VERSION) . '</td></tr>';
     echo '<tr title="&gt;=5.0.7"><td>' . __('MySQL version', 'backwpup') . '</td><td>' . esc_html($wpdb->get_var('SELECT VERSION() AS version')) . '</td></tr>';
     if (function_exists('curl_version')) {
         $curlversion = curl_version();
         echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . esc_html($curlversion['version']) . '</td></tr>';
         echo '<tr title=""><td>' . __('cURL SSL version', 'backwpup') . '</td><td>' . esc_html($curlversion['ssl_version']) . '</td></tr>';
     } else {
         echo '<tr title=""><td>' . __('cURL version', 'backwpup') . '</td><td>' . __('unavailable', 'backwpup') . '</td></tr>';
     }
     echo '<tr title=""><td>' . __('WP-Cron url:', 'backwpup') . '</td><td>' . esc_html(site_url('wp-cron.php')) . '</td></tr>';
     echo '<tr><td>' . __('Server self connect:', 'backwpup') . '</td><td>';
     $raw_response = BackWPup_Job::get_jobrun_url('test');
     $test_result = '';
     if (is_wp_error($raw_response)) {
         $test_result .= sprintf(__('The HTTP response test get an error "%s"', 'backwpup'), esc_html($raw_response->get_error_message()));
     } elseif (200 !== (int) wp_remote_retrieve_response_code($raw_response) && 204 !== (int) wp_remote_retrieve_response_code($raw_response)) {
         $test_result .= sprintf(__('The HTTP response test get a false http status (%s)', 'backwpup'), esc_html(wp_remote_retrieve_response_code($raw_response)));
     }
     $headers = wp_remote_retrieve_headers($raw_response);
     if (isset($headers['x-backwpup-ver']) && BackWPup::get_plugin_data('version') !== $headers['x-backwpup-ver']) {
         $test_result .= sprintf(__('The BackWPup HTTP response header returns a false value: "%s"', 'backwpup'), esc_html($headers['x-backwpup-ver']));
     }
     if (empty($test_result)) {
         esc_html_e('Response Test O.K.', 'backwpup');
     } else {
         echo esc_html($test_result);
     }
     echo '</td></tr>';
     echo '<tr><td>' . __('Temp folder:', 'backwpup') . '</td><td>';
     if (!is_dir(BackWPup::get_plugin_data('TEMP'))) {
         echo sprintf(__('Temp folder %s doesn\'t exist.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
     } elseif (!is_writable(BackWPup::get_plugin_data('TEMP'))) {
         echo sprintf(__('Temporary folder %s is not writable.', 'backwpup'), esc_html(BackWPup::get_plugin_data('TEMP')));
     } else {
         echo esc_html(BackWPup::get_plugin_data('TEMP'));
     }
     echo '</td></tr>';
     echo '<tr><td>' . __('Log folder:', 'backwpup') . '</td><td>';
     if (!is_dir(get_site_option('backwpup_cfg_logfolder'))) {
         echo sprintf(__('Logs folder %s not exist.', 'backwpup'), esc_html(get_site_option('backwpup_cfg_logfolder')));
     } elseif (!is_writable(get_site_option('backwpup_cfg_logfolder'))) {
         echo sprintf(__('Log folder %s is not writable.', 'backwpup'), esc_html(get_site_option('backwpup_cfg_logfolder')));
     } else {
         echo esc_html(get_site_option('backwpup_cfg_logfolder'));
     }
     echo '</td></tr>';
     echo '<tr title=""><td>' . __('Server', 'backwpup') . '</td><td>' . esc_html($_SERVER['SERVER_SOFTWARE']) . '</td></tr>';
     echo '<tr title=""><td>' . __('Operating System', 'backwpup') . '</td><td>' . esc_html(PHP_OS) . '</td></tr>';
     echo '<tr title=""><td>' . __('PHP SAPI', 'backwpup') . '</td><td>' . esc_html(PHP_SAPI) . '</td></tr>';
     echo '<tr title=""><td>' . __('Current PHP user', 'backwpup') . '</td><td>' . esc_html(get_current_user()) . '</td></tr>';
     $text = (bool) ini_get('safe_mode') ? __('On', 'backwpup') : __('Off', 'backwpup');
     echo '<tr title=""><td>' . __('Safe Mode', 'backwpup') . '</td><td>' . $text . '</td></tr>';
     echo '<tr title="&gt;=30"><td>' . __('Maximum execution time', 'backwpup') . '</td><td>' . ini_get('max_execution_time') . ' ' . __('seconds', 'backwpup') . '</td></tr>';
     if (defined('ALTERNATE_WP_CRON') && ALTERNATE_WP_CRON) {
         echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
     } else {
         echo '<tr title="ALTERNATE_WP_CRON"><td>' . __('Alternative WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
     }
     if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
         echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('On', 'backwpup') . '</td></tr>';
     } else {
         echo '<tr title="DISABLE_WP_CRON"><td>' . __('Disabled WP Cron', 'backwpup') . '</td><td>' . __('Off', 'backwpup') . '</td></tr>';
     }
     if (defined('FS_CHMOD_DIR')) {
         echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>' . FS_CHMOD_DIR . '</td></tr>';
     } else {
         echo '<tr title="FS_CHMOD_DIR"><td>' . __('CHMOD Dir', 'backwpup') . '</td><td>0755</td></tr>';
     }
     $now = localtime(time(), true);
     echo '<tr title=""><td>' . __('Server Time', 'backwpup') . '</td><td>' . esc_html($now['tm_hour']) . ':' . esc_html($now['tm_min']) . '</td></tr>';
     echo '<tr title=""><td>' . __('Blog Time', 'backwpup') . '</td><td>' . esc_html(date_i18n('H:i')) . '</td></tr>';
     echo '<tr title=""><td>' . __('Blog Timezone', 'backwpup') . '</td><td>' . esc_html(get_option('timezone_string')) . '</td></tr>';
     echo '<tr title=""><td>' . __('Blog Time offset', 'backwpup') . '</td><td>' . sprintf(__('%s hours', 'backwpup'), esc_html(get_option('gmt_offset'))) . '</td></tr>';
     echo '<tr title="WPLANG"><td>' . __('Blog language', 'backwpup') . '</td><td>' . esc_html(get_bloginfo('language')) . '</td></tr>';
     echo '<tr title="utf8"><td>' . __('MySQL Client encoding', 'backwpup') . '</td><td>';
     echo defined('DB_CHARSET') ? esc_html(DB_CHARSET) : '';
     echo '</td></tr>';
     echo '<tr title="URF-8"><td>' . __('Blog charset', 'backwpup') . '</td><td>' . esc_html(get_bloginfo('charset')) . '</td></tr>';
     echo '<tr title="&gt;=128M"><td>' . __('PHP Memory limit', 'backwpup') . '</td><td>' . esc_html(ini_get('memory_limit')) . '</td></tr>';
     echo '<tr title="WP_MEMORY_LIMIT"><td>' . __('WP memory limit', 'backwpup') . '</td><td>' . esc_html(WP_MEMORY_LIMIT) . '</td></tr>';
     echo '<tr title="WP_MAX_MEMORY_LIMIT"><td>' . __('WP maximum memory limit', 'backwpup') . '</td><td>' . esc_html(WP_MAX_MEMORY_LIMIT) . '</td></tr>';
     echo '<tr title=""><td>' . __('Memory in use', 'backwpup') . '</td><td>' . esc_html(size_format(@memory_get_usage(true), 2)) . '</td></tr>';
     //disabled PHP functions
     $disabled = ini_get('disable_functions');
     if (!empty($disabled)) {
         $disabledarry = explode(',', $disabled);
         echo '<tr title=""><td>' . __('Disabled PHP Functions:', 'backwpup') . '</td><td>';
         echo esc_html(implode(', ', $disabledarry));
         echo '</td></tr>';
     }
     //Loaded PHP Extensions
     echo '<tr title=""><td>' . __('Loaded PHP Extensions:', 'backwpup') . '</td><td>';
     $extensions = get_loaded_extensions();
     sort($extensions);
     echo esc_html(implode(', ', $extensions));
     echo '</td></tr>';
     echo '</table>';
     $output = ob_get_contents();
     ob_end_clean();
     return array('success' => 1, 'response' => $output);
 }