本文整理汇总了PHP中BackWPup_Job::is_debug方法的典型用法代码示例。如果您正苦于以下问题:PHP BackWPup_Job::is_debug方法的具体用法?PHP BackWPup_Job::is_debug怎么用?PHP BackWPup_Job::is_debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackWPup_Job
的用法示例。
在下文中一共展示了BackWPup_Job::is_debug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: job_run
/**
* Dumps the Database
*
* @param $job_object BackWPup_Job
*
* @return bool
*/
public function job_run(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 1;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to backup database …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
}
//build filename
if (empty($job_object->steps_data[$job_object->step_working]['dbdumpfile'])) {
$job_object->steps_data[$job_object->step_working]['dbdumpfile'] = $job_object->generate_filename($job_object->job['dbdumpfile'], 'sql') . $job_object->job['dbdumpfilecompression'];
}
try {
//Connect to Database
$sql_dump = new BackWPup_MySQLDump(array('dumpfile' => BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']));
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('Connected to database %1$s on %2$s', 'backwpup'), DB_NAME, DB_HOST));
}
//Exclude Tables
foreach ($sql_dump->tables_to_dump as $key => $table) {
if (in_array($table, $job_object->job['dbdumpexclude'], true)) {
unset($sql_dump->tables_to_dump[$key]);
}
}
//set steps must done
$job_object->substeps_todo = count($sql_dump->tables_to_dump);
if ($job_object->substeps_todo == 0) {
$job_object->log(__('No tables to backup.', 'backwpup'), E_USER_WARNING);
unset($sql_dump);
return TRUE;
}
//dump head
if (!isset($job_object->steps_data[$job_object->step_working]['is_head'])) {
$sql_dump->dump_head(TRUE);
$job_object->steps_data[$job_object->step_working]['is_head'] = TRUE;
}
//dump tables
$i = 0;
foreach ($sql_dump->tables_to_dump as $table) {
if ($i < $job_object->substeps_done) {
$i++;
continue;
}
if (empty($job_object->steps_data[$job_object->step_working]['tables'][$table])) {
$num_records = $sql_dump->dump_table_head($table);
$job_object->steps_data[$job_object->step_working]['tables'][$table] = array('start' => 0, 'length' => 1000);
if ($job_object->is_debug()) {
$job_object->log(sprintf(__('Backup database table "%s" with "%s" records', 'backwpup'), $table, $num_records));
}
}
$while = true;
while ($while) {
$dump_start_time = microtime(TRUE);
$done_records = $sql_dump->dump_table($table, $job_object->steps_data[$job_object->step_working]['tables'][$table]['start'], $job_object->steps_data[$job_object->step_working]['tables'][$table]['length']);
$dump_time = microtime(TRUE) - $dump_start_time;
if (empty($dump_time)) {
$dump_time = 0.01;
}
if ($done_records < $job_object->steps_data[$job_object->step_working]['tables'][$table]['length']) {
//that is the last chunk
$while = FALSE;
}
$job_object->steps_data[$job_object->step_working]['tables'][$table]['start'] = $job_object->steps_data[$job_object->step_working]['tables'][$table]['start'] + $done_records;
// dump time per record and set next length
$length = ceil($done_records / $dump_time * $job_object->get_restart_time());
if ($length > 25000 || 0 >= $job_object->get_restart_time()) {
$length = 25000;
}
if ($length < 1000) {
$length = 1000;
}
$job_object->steps_data[$job_object->step_working]['tables'][$table]['length'] = $length;
$job_object->do_restart_time();
}
$sql_dump->dump_table_footer($table);
$job_object->substeps_done++;
$i++;
$job_object->update_working_data();
}
//dump footer
$sql_dump->dump_footer();
unset($sql_dump);
} catch (Exception $e) {
$job_object->log($e->getMessage(), E_USER_ERROR, $e->getFile(), $e->getLine());
unset($sql_dump);
return FALSE;
}
$filesize = filesize(BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']);
if (!is_file(BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile']) || $filesize < 1) {
$job_object->log(__('MySQL backup file not created', 'backwpup'), E_USER_ERROR);
return FALSE;
} else {
$job_object->additional_files_to_backup[] = BackWPup::get_plugin_data('TEMP') . $job_object->steps_data[$job_object->step_working]['dbdumpfile'];
$job_object->log(sprintf(__('Added database dump "%1$s" with %2$s to backup file list', 'backwpup'), $job_object->steps_data[$job_object->step_working]['dbdumpfile'], size_format($filesize, 2)));
}
//.........这里部分代码省略.........
示例2: job_run_archive
/**
* @param $job_object
*
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to send backup file to Dropbox …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
}
try {
$dropbox = new BackWPup_Destination_Dropbox_API($job_object->job['dropboxroot']);
// cahnge oauth1 to oauth2 token
if (!empty($job_object->job['dropboxsecret']) && empty($job_object->job['dropboxtoken']['access_token'])) {
$dropbox->setOAuthTokens(array('access_token' => $job_object->job['dropboxtoken'], 'oauth_token_secret' => BackWPup_Encryption::decrypt($job_object->job['dropboxsecret'])));
$job_object->job['dropboxtoken'] = $dropbox->token_from_oauth1();
BackWPup_Option::update($job_object->job['jobid'], 'dropboxtoken', $job_object->job['dropboxtoken']);
BackWPup_Option::delete($job_object->job['jobid'], 'dropboxsecret');
}
// set the tokens
$dropbox->setOAuthTokens($job_object->job['dropboxtoken']);
//get account info
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$info = $dropbox->accountInfo();
if (!empty($info['uid'])) {
if ($job_object->is_debug()) {
$user = $info['display_name'] . ' (' . $info['email'] . ')';
} else {
$user = $info['display_name'];
}
$job_object->log(sprintf(__('Authenticated with Dropbox of user: %s', 'backwpup'), $user));
//Quota
if ($job_object->is_debug()) {
$dropboxfreespase = $info['quota_info']['quota'] - $info['quota_info']['shared'] - $info['quota_info']['normal'];
$job_object->log(sprintf(__('%s available on your Dropbox', 'backwpup'), size_format($dropboxfreespase, 2)));
}
} else {
$job_object->log(__('Not Authenticated with Dropbox!', 'backwpup'), E_USER_ERROR);
return false;
}
$job_object->log(__('Uploading to Dropbox …', 'backwpup'));
}
// put the file
self::$backwpup_job_object =& $job_object;
if ($job_object->substeps_done < $job_object->backup_filesize) {
//only if upload not complete
$response = $dropbox->upload($job_object->backup_folder . $job_object->backup_file, $job_object->job['dropboxdir'] . $job_object->backup_file);
if ($response['bytes'] == $job_object->backup_filesize) {
if (!empty($job_object->job['jobid'])) {
BackWPup_Option::update($job_object->job['jobid'], 'lastbackupdownloadurl', network_admin_url('admin.php') . '?page=backwpupbackups&action=downloaddropbox&file=' . ltrim($response['path'], '/') . '&jobid=' . $job_object->job['jobid']);
}
$job_object->substeps_done = 1 + $job_object->backup_filesize;
$job_object->log(sprintf(__('Backup transferred to %s', 'backwpup'), 'https://content.dropboxapi.com/1/files/' . $job_object->job['dropboxroot'] . $response['path']), E_USER_NOTICE);
} else {
if ($response['bytes'] != $job_object->backup_filesize) {
$job_object->log(__('Uploaded file size and local file size don\'t match.', 'backwpup'), E_USER_ERROR);
} else {
$job_object->log(sprintf(__('Error transfering backup to %s.', 'backwpup') . ' ' . $response['error'], __('Dropbox', 'backwpup')), E_USER_ERROR);
}
return false;
}
}
$backupfilelist = array();
$filecounter = 0;
$files = array();
$metadata = $dropbox->metadata($job_object->job['dropboxdir']);
if (is_array($metadata)) {
foreach ($metadata['contents'] as $data) {
if ($data['is_dir'] != true) {
$file = basename($data['path']);
if ($job_object->is_backup_archive($file)) {
$backupfilelist[strtotime($data['modified'])] = $file;
}
$files[$filecounter]['folder'] = "https://content.dropboxapi.com/1/files/" . $job_object->job['dropboxroot'] . dirname($data['path']) . "/";
$files[$filecounter]['file'] = $data['path'];
$files[$filecounter]['filename'] = basename($data['path']);
$files[$filecounter]['downloadurl'] = network_admin_url('admin.php?page=backwpupbackups&action=downloaddropbox&file=' . $data['path'] . '&jobid=' . $job_object->job['jobid']);
$files[$filecounter]['filesize'] = $data['bytes'];
$files[$filecounter]['time'] = strtotime($data['modified']) + get_option('gmt_offset') * 3600;
$filecounter++;
}
}
}
if ($job_object->job['dropboxmaxbackups'] > 0 && is_object($dropbox)) {
//Delete old backups
if (count($backupfilelist) > $job_object->job['dropboxmaxbackups']) {
ksort($backupfilelist);
$numdeltefiles = 0;
while ($file = array_shift($backupfilelist)) {
if (count($backupfilelist) < $job_object->job['dropboxmaxbackups']) {
break;
}
$response = $dropbox->fileopsDelete($job_object->job['dropboxdir'] . $file);
//delete files on Cloud
if ($response['is_deleted'] == 'true') {
foreach ($files as $key => $filedata) {
if ($filedata['file'] == '/' . $job_object->job['dropboxdir'] . $file) {
unset($files[$key]);
}
//.........这里部分代码省略.........
示例3: job_run
/**
* @param $job_object
* @return bool
*/
public function job_run(BackWPup_Job $job_object)
{
global $wpdb;
/* @var wpdb $wpdb */
$job_object->log(sprintf(__('%d. Trying to check database …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']));
if (!isset($job_object->steps_data[$job_object->step_working]['DONETABLE']) || !is_array($job_object->steps_data[$job_object->step_working]['DONETABLE'])) {
$job_object->steps_data[$job_object->step_working]['DONETABLE'] = array();
}
//to check
$tables = array();
$tablestype = array();
$restables = $wpdb->get_results('SHOW FULL TABLES FROM `' . DB_NAME . '`', ARRAY_N);
foreach ($restables as $table) {
if ($job_object->job['dbcheckwponly'] && substr($table[0], 0, strlen($wpdb->prefix)) != $wpdb->prefix) {
continue;
}
$tables[] = $table[0];
$tablestype[$table[0]] = $table[1];
}
//Set num
$job_object->substeps_todo = sizeof($tables);
//Get table status
$status = array();
$resstatus = $wpdb->get_results("SHOW TABLE STATUS FROM `" . DB_NAME . "`", ARRAY_A);
foreach ($resstatus as $tablestatus) {
$status[$tablestatus['Name']] = $tablestatus;
}
//check tables
if ($job_object->substeps_todo > 0) {
foreach ($tables as $table) {
if (in_array($table, $job_object->steps_data[$job_object->step_working]['DONETABLE'], true)) {
continue;
}
if ($tablestype[$table] == 'VIEW') {
$job_object->log(sprintf(__('Table %1$s is a view. Not checked.', 'backwpup'), $table));
continue;
}
if ($status[$table]['Engine'] != 'MyISAM' && $status[$table]['Engine'] != 'InnoDB') {
$job_object->log(sprintf(__('Table %1$s is not a MyISAM/InnoDB table. Not checked.', 'backwpup'), $table));
continue;
}
//CHECK TABLE funktioniert bei MyISAM- und InnoDB-Tabellen (http://dev.mysql.com/doc/refman/5.1/de/check-table.html)
$check = $wpdb->get_row("CHECK TABLE `" . $table . "` MEDIUM", OBJECT);
if (strtolower($check->Msg_text) == 'ok') {
if ($job_object->is_debug()) {
$job_object->log(sprintf(__('Result of table check for %1$s is: %2$s', 'backwpup'), $table, $check->Msg_text));
}
} elseif (strtolower($check->Msg_type) == 'warning') {
$job_object->log(sprintf(__('Result of table check for %1$s is: %2$s', 'backwpup'), $table, $check->Msg_text), E_USER_WARNING);
} else {
$job_object->log(sprintf(__('Result of table check for %1$s is: %2$s', 'backwpup'), $table, $check->Msg_text), E_USER_ERROR);
}
//Try to Repair table
if (!empty($job_object->job['dbcheckrepair']) && strtolower($check->Msg_text) != 'ok' && $status[$table]['Engine'] == 'MyISAM') {
$repair = $wpdb->get_row('REPAIR TABLE `' . $table . '` EXTENDED', OBJECT);
if (strtolower($repair->Msg_text) == 'ok') {
$job_object->log(sprintf(__('Result of table repair for %1$s is: %2$s', 'backwpup'), $table, $repair->Msg_text));
} elseif (strtolower($repair->Msg_type) == 'warning') {
$job_object->log(sprintf(__('Result of table repair for %1$s is: %2$s', 'backwpup'), $table, $repair->Msg_text), E_USER_WARNING);
} else {
$job_object->log(sprintf(__('Result of table repair for %1$s is: %2$s', 'backwpup'), $table, $repair->Msg_text), E_USER_ERROR);
}
}
$job_object->steps_data[$job_object->step_working]['DONETABLE'][] = $table;
$job_object->substeps_done++;
}
$job_object->log(__('Database check done!', 'backwpup'));
} else {
$job_object->log(__('No tables to check.', 'backwpup'));
}
unset($job_object->steps_data[$job_object->step_working]['DONETABLE']);
return TRUE;
}