当前位置: 首页>>代码示例>>PHP>>正文


PHP backupbuddy_core::schedule_single_event方法代码示例

本文整理汇总了PHP中backupbuddy_core::schedule_single_event方法的典型用法代码示例。如果您正苦于以下问题:PHP backupbuddy_core::schedule_single_event方法的具体用法?PHP backupbuddy_core::schedule_single_event怎么用?PHP backupbuddy_core::schedule_single_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backupbuddy_core的用法示例。


在下文中一共展示了backupbuddy_core::schedule_single_event方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cron

 function cron($method, $args, $rescheduleCount = 0)
 {
     //if ( ( '1' == pb_backupbuddy::$options['limit_single_cron_per_pass'] ) && ( $this->_methods_ran > 0 ) ) { // If limiting to one cron method per PHP load AND we have already ran one method this PHP process then chunk to next run.
     if (1 == 2) {
         // Disabled until 7.0.
         $rescheduleCount++;
         $nextRun = time() + 1;
         $options = array($args, $rescheduleCount);
         if ($rescheduleCount >= backupbuddy_constants::CRON_SINGLE_PASS_RESCHEDULE_LIMIT) {
             // Safety net to prevent runaway rescheduling.
             $message = 'Error #8399823: Max cron single pass reschedule limit of `' . backupbuddy_constants::CRON_SINGLE_PASS_RESCHEDULE_LIMIT . '` hit. Method: `' . $method . '`; Args: `' . print_r($options, true) . '`.';
             pb_backupbuddy::status('error', $message);
             if ('process_backup' == $method) {
                 // If backup process then log to serial log file.
                 pb_backupbuddy::status('error', $message, $args[0]);
             }
             return false;
         }
         if (false === backupbuddy_core::schedule_single_event($nextRun, $method, $options)) {
             $message = 'Error #838923: Unable to reschedule cron based on setting to limit single cron per pass enabled. Method: `' . $method . '`; Args: `' . print_r($options, true) . '`. Reschedule count: `' . $rescheduleCount . '`.';
             pb_backupbuddy::status('error', $message);
             if ('process_backup' == $method) {
                 // If backup process then log to serial log file.
                 pb_backupbuddy::status('error', $message, $args[0]);
             }
             return false;
         }
         $message = 'Rescheduled cron as setting to limit single cron per pass enabled. Details: `' . print_r($options, true) . '`. Reschedule count: `' . $rescheduleCount . '`.';
         pb_backupbuddy::status('details', $message);
         if ('process_backup' == $method) {
             // If backup process then log to serial log file.
             pb_backupbuddy::status('details', $message, $args[0]);
         }
         /*
          *		TODO:	Once PING API is available, request a ping in the future so we make sure this actually runs reasonably soon.
          *				Because we need a delay we are not firing off the cron here immediately so there will be no chaining of PHP
          *				which may result in large delays before the next process if there's little site traffic.
          */
         //error_log( 'rescheduled_cron' );
         return true;
     }
     $this->_methods_ran++;
     return call_user_func_array(array(&$this, '_' . $method), $args);
 }
开发者ID:Brandonsmith23,项目名称:prodgyr,代码行数:44,代码来源:cron.php

示例2: schedule_php_memory_tests

 public static function schedule_php_memory_tests($force_run = false)
 {
     pb_backupbuddy::status('details', 'About to schedule PHP memory tests.');
     if (pb_backupbuddy::$options['php_memory_test_minimum_interval'] <= 0) {
         pb_backupbuddy::status('warnings', 'PHP memory test disabled based on advanced settings.');
         return false;
     }
     // Don't run memory test too often.
     if (pb_backupbuddy::$options['last_tested_php_memory'] > 0) {
         // if it's run at least once...
         $elapsed = time() - pb_backupbuddy::$options['last_tested_php_memory'];
         if ($elapsed < pb_backupbuddy::$options['php_memory_test_minimum_interval']) {
             // Not enough time elapsed since last run.
             pb_backupbuddy::status('details', 'Not enough time elapsed since last PHP memory test interval. Waiting until next housekeeping (or longer). Elapsed: `' . $elapsed . '`. Interval limit: `' . pb_backupbuddy::$options['php_memory_test_minimum_interval'] . '`.');
             return;
         }
     }
     // Schedule to run test.
     $cronArgs = array($schedule_results = true);
     $schedule_result = backupbuddy_core::schedule_single_event(time(), 'php_memory_test', $cronArgs);
     if (true === $schedule_result) {
         pb_backupbuddy::status('details', 'PHP memory test cron event scheduled.');
     } else {
         pb_backupbuddy::status('error', 'PHP memory test cron event FAILED to be scheduled.');
     }
     // Spawn now if enabled.
     if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) {
         pb_backupbuddy::status('details', 'Spawning cron now.');
         update_option('_transient_doing_cron', 0);
         // Prevent cron-blocking for next item.
         spawn_cron(time() + 150);
         // Adds > 60 seconds to get around once per minute cron running limit.
     }
 }
开发者ID:arobbins,项目名称:spellestate,代码行数:34,代码来源:housekeeping.php

示例3: implode

            pb_backupbuddy::alert('Error: Unable to delete `' . $item . '`. Verify permissions.');
        }
    }
    if (count($deleted_files) > 0) {
        pb_backupbuddy::alert('Deleted ' . implode(', ', $deleted_files) . '.');
        delete_transient('pb_backupbuddy_stashquota_' . $itxapi_username);
        // Delete quota transient since it probably has changed now.
    }
    echo '<br>';
}
// Handle copying files to local
if (pb_backupbuddy::_GET('cpy_file') != '') {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Stash copy.');
    backupbuddy_core::schedule_single_event(time(), 'process_remote_copy', array('stash', pb_backupbuddy::_GET('cpy_file'), $settings));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
    $link = $s3->get_object($manage_data['bucket'], $manage_data['subkey'] . $remote_path . pb_backupbuddy::_GET('downloadlink_file'), array('preauth' => time() + 3600));
    pb_backupbuddy::alert('You may download this backup (' . pb_backupbuddy::_GET('downloadlink_file') . ') with <a href="' . $link . '">this link</a>. The link is valid for one hour.');
    echo '<br>';
}
// QUOTA INFORMATION.
$account_info = pb_backupbuddy_destination_stash::get_quota(array('itxapi_username' => $itxapi_username, 'itxapi_password' => $itxapi_password), false);
/*
echo '<pre>';
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:_manage.php

示例4: send


//.........这里部分代码省略.........
             $dataRemains = false;
         }
         $isFileTest = false;
         if (false !== stristr(basename($file), 'remote-send-test.php')) {
             $isFileTest = true;
             $settings['sendType'] = 'test';
         }
         if (true === $dataRemains) {
             $isFileDone = false;
         } else {
             $isFileDone = true;
         }
         if (!isset($size)) {
             $size = '';
         }
         pb_backupbuddy::status('details', 'Connecting to remote server to send data.');
         $response = backupbuddy_remote_api::remoteCall($apiSettings, 'sendFile_' . $settings['sendType'], array(), $settings['max_time'], $file, $fileData, $prevPointer, $isFileTest, $isFileDone, $size, $filePath);
         unset($fileData);
         // Free up memory.
         $settings['chunks_sent']++;
         if (true === $dataRemains) {
             // More chunks remain.
             pb_backupbuddy::status('details', 'Connection finished sending part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . '.');
         } else {
             // No more chunks remain.
             pb_backupbuddy::status('details', 'Connection finished sending final part ' . $settings['chunks_sent'] . '.');
         }
         if (false === $response) {
             echo implode(', ', backupbuddy_remote_api::getErrors()) . ' ';
             pb_backupbuddy::status('error', 'Errors encountered details: ' . implode(', ', backupbuddy_remote_api::getErrors()));
             global $pb_backupbuddy_destination_errors;
             $pb_backupbuddy_destination_errors[] = backupbuddy_remote_api::getErrors();
             return false;
             //implode( ', ', backupbuddy_remote_api::getErrors() );
         }
         if (FALSE === ($prevPointer = ftell($fs))) {
             pb_backupbuddy::status('error', 'Error #438347844: Unable to get ftell pointer of file handle for passing to prevPointer.');
             @fclose($fs);
             return false;
         } else {
             pb_backupbuddy::status('details', 'File pointer: `' . $prevPointer . '`.');
         }
         if (true === $dataRemains) {
             // More data remains so see if we need to consider chunking to a new PHP process.
             // If we are within X second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
             if (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM >= $settings['max_time']) {
                 pb_backupbuddy::status('message', 'Approaching limit of available PHP chunking time of `' . $settings['max_time'] . '` sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
                 @fclose($fs);
                 // Tells next chunk where to pick up.
                 $settings['resume_point'] = $prevPointer;
                 // Schedule cron.
                 $cronTime = time();
                 $cronArgs = array($settings, $files, $send_id, $delete_after);
                 $cronHashID = md5($cronTime . serialize($cronArgs));
                 $cronArgs[] = $cronHashID;
                 $schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
                 if (true === $schedule_result) {
                     pb_backupbuddy::status('details', 'Next Site chunk step cron event scheduled.');
                 } else {
                     pb_backupbuddy::status('error', 'Next Site chunk step cron even FAILED to be scheduled.');
                 }
                 spawn_cron(time() + 150);
                 // Adds > 60 seconds to get around once per minute cron running limit.
                 update_option('_transient_doing_cron', 0);
                 // Prevent cron-blocking for next item.
                 return array($prevPointer, 'Sent part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . ' parts.');
                 // filepointer location, elapsed time during the import
             } else {
                 // End if.
                 pb_backupbuddy::status('details', 'Not approaching time limit.');
             }
         } else {
             pb_backupbuddy::status('details', 'No more data remains (eg for chunking) so finishing up.');
         }
     }
     // end while data remains in file.
     // Update fileoptions stats.
     pb_backupbuddy::status('details', 'About to load fileoptions data.');
     require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
     pb_backupbuddy::status('details', 'Fileoptions instance #20.');
     $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
     if (true !== ($result = $fileoptions_obj->is_ok())) {
         pb_backupbuddy::status('error', __('Fatal Error #9034.279327. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         return false;
     }
     pb_backupbuddy::status('details', 'Fileoptions data loaded.');
     $fileoptions =& $fileoptions_obj->options;
     $fileoptions['finish_time'] = microtime(true);
     $fileoptions['status'] = 'success';
     $fileoptions['_multipart_status'] = 'Sent all parts.';
     if (isset($uploaded_speed)) {
         $fileoptions['write_speed'] = $uploaded_speed;
     }
     $fileoptions_obj->save();
     unset($fileoptions);
     // Made it this far so completed!
     pb_backupbuddy::status('message', 'Finished sending file. Took ' . round(microtime(true) - self::$_timeStart, 3) . ' seconds this round.');
     pb_backupbuddy::status('deployFileSent', 'File sent.');
     return true;
 }
开发者ID:elephantcode,项目名称:elephantcode,代码行数:101,代码来源:init.php

示例5: remoteSendRetry

 public static function remoteSendRetry(&$fileoptions_obj, $send_id, $maximumRetries = 1)
 {
     // Destination settings are stored for this destination so see if we can retry sending it (if settings permit).
     if (isset($fileoptions_obj->options['destinationSettings']) && count($fileoptions_obj->options['destinationSettings']) > 0) {
         /*
         echo '<pre>';
         print_r( $fileoptions_obj->options );
         echo '</pre>';
         */
         $destination_settings = $fileoptions_obj->options['destinationSettings'];
         // these are the latest; includes info needed for chunking too.
         //$send_id = $fileoptions_obj->options['sendID'];
         $delete_after = $fileoptions_obj->options['deleteAfter'];
         $retries = $fileoptions_obj->options['retries'];
         $file = $fileoptions_obj->options['file'];
         if ($retries < $maximumRetries) {
             pb_backupbuddy::status('details', 'Timed out remote send has not exceeded retry limit (`' . $maximumRetries . '`). Trying to send again.');
             //$fileoptions_obj->options['retries']++;
             //$fileoptions_obj->save(); // NOTE: Retry count now updates in bootstrap.php send() function. Only leaving this here temporarily to help get rid of failed resends from accumulating with old format.
             // Schedule send of this piece.
             pb_backupbuddy::status('details', 'Scheduling cron to send to this remote destination...');
             $cronArgs = array($destination_settings, $file, $send_id, $delete_after, $identifier = '', $isRetry = true);
             /*
             echo 'cronargs: ';
             echo '<pre>';
             print_r( $cronArgs );
             echo '</pre>';
             */
             $schedule_result = backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
             if ($schedule_result === FALSE) {
                 $error = 'Error scheduling file transfer. Please check your BackupBuddy error log for details. A plugin may have prevented scheduling or the database rejected it.';
                 pb_backupbuddy::status('error', $error);
                 echo $error;
             } else {
                 pb_backupbuddy::status('details', 'Cron to send to remote destination scheduled.');
             }
             spawn_cron(time() + 150);
             // Adds > 60 seconds to get around once per minute cron running limit.
             update_option('_transient_doing_cron', 0);
             // Prevent cron-blocking for next item.
             return true;
         } else {
             pb_backupbuddy::status('details', 'Maximum remote send timeout retries (`' . $maximumRetries . '`) passed to function met. Not resending.');
             return false;
         }
     }
 }
开发者ID:bunnywong,项目名称:freshlinker,代码行数:47,代码来源:core.php

示例6: array

            $delete_count++;
            // Delete Rackspace file
            $container->delete_object($rsfile);
        }
    }
    if ($delete_count > 0) {
        pb_backupbuddy::alert(sprintf(_n('Deleted %d file', 'Deleted %d files', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
    }
    echo '<br>';
}
// Copy Rackspace backup to the local backup files
if (!empty($_GET['cpy_file'])) {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Rackspace copy.');
    backupbuddy_core::schedule_single_event(time(), 'process_rackspace_copy', array($_GET['cpy_file'], $rs_username, $rs_api_key, $rs_container, $rs_server));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// List objects in container
/*
if ( $rs_path != '' ) {
	$results = $container->get_objects( 0, NULL, 'backup-', $rs_path );
} else {
*/
$results = $container->get_objects(0, NULL, 'backup-');
/* } */
$urlPrefix = pb_backupbuddy::ajax_url('remoteClient') . '&destination_id=' . htmlentities(pb_backupbuddy::_GET('destination_id'));
?>
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:_manage.php

示例7: cron_next_step

 function cron_next_step($spawn_cron = true, $future_offset = 0)
 {
     if ('1' == pb_backupbuddy::$options['skip_spawn_cron_call']) {
         pb_backupbuddy::status('details', 'Advanced option to skip call to spawn cron enabled. Setting to skip spawn_cron() call.');
         $spawn_cron = false;
     }
     pb_backupbuddy::status('details', 'Scheduling Cron for `' . $this->_backup['serial'] . '`.');
     // Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
     // This is not essential so use include and not require (suppress any warning)
     @(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
     if (class_exists('pluginbuddy_wpdbutils')) {
         global $wpdb;
         $dbhelper = new pluginbuddy_wpdbutils($wpdb);
         if (!$dbhelper->kick()) {
             pb_backupbuddy::status('error', __('Database Server has gone away, unable to schedule next backup step. The backup cannot continue. This is most often caused by mysql running out of memory or timing out far too early. Please contact your host.', 'it-l10n-backupbuddy'));
             pb_backupbuddy::status('haltScript', '');
             // Halt JS on page.
             return false;
         }
     } else {
         pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
     }
     // Schedule event.
     $cron_time = time() + $future_offset;
     $cron_tag = pb_backupbuddy::cron_tag('process_backup');
     $cron_args = array($this->_backup['serial']);
     pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `' . $cron_tag . '` and serial arguments `' . implode(',', $cron_args) . '`.');
     $schedule_result = backupbuddy_core::schedule_single_event($cron_time, $cron_tag, $cron_args);
     if ($schedule_result === false) {
         pb_backupbuddy::status('error', 'Unable to schedule next cron step. Verify that another plugin is not preventing / conflicting.');
     } else {
         pb_backupbuddy::status('details', 'Next step scheduled.');
         pb_backupbuddy::status('startAction', 'cronPass');
         pb_backupbuddy::status('cronParams', base64_encode(json_encode(array('time' => $cron_time, 'tag' => $cron_tag, 'args' => $cron_args))));
     }
     update_option('_transient_doing_cron', 0);
     // Prevent cron-blocking for next item.
     // Spawn cron.
     if ($spawn_cron === true) {
         pb_backupbuddy::status('details', 'Calling spawn_cron().');
         spawn_cron(time() + 150);
         // Adds > 60 seconds to get around once per minute cron running limit.
     } else {
         pb_backupbuddy::status('details', 'Not calling spawn_cron().');
     }
     pb_backupbuddy::status('details', 'About to run next step. If the backup does not proceed within 15 seconds then something is interfering with the WordPress CRON system such as: server loopback issues, caching plugins, or scheduling plugins. Try disabling other plugins to see if it resolves issue.  Check the Server Information page cron section to see if the next BackupBuddy step is scheduled to run. Enable "Classic" backup mode on the "Settings" page to rule out non-cron issues.');
     return;
 }
开发者ID:jcwproductions,项目名称:jcwproductions-blog,代码行数:48,代码来源:backup.php

示例8: send


//.........这里部分代码省略.........
                 // Need to retry checking that the file confirm was a success.
                 // Grab array of files from customer's stash directory
                 $files = pb_backupbuddy_destination_stash2::listFiles($settings, $settings['_multipart_file']);
                 if (count($files) > 0) {
                     pb_backupbuddy::status('details', 'Stash confirmed upload completition was successful.');
                 } else {
                     pb_backupbuddy::status('error', 'Error #23972793: Error notifying Stash of upload success even after wait. Details: `' . print_r($response, true) . '`.');
                     return false;
                 }
             } else {
                 // Normal Stash part send.
                 $update_status = 'Sent part ' . $settings['_multipart_partnumber'] . ' of ' . count($settings['_multipart_counts']) . ' parts.';
                 pb_backupbuddy::status('details', 'Getting etags and notifying of multipart upload completion.');
                 try {
                     $response = self::$_client->completeMultipartUpload(array('Bucket' => $settings['bucket'], 'UploadId' => $settings['_multipart_id'], 'Key' => $settings['_multipart_remotefile'], 'Parts' => $settings['_multipart_etag_parts']));
                 } catch (Exception $e) {
                     return self::_error('Unable to notify server of completion of all parts for multipart upload `' . $settings['_multipart_id'] . '`. Details: `' . $e->getMessage() . '`.');
                 }
                 pb_backupbuddy::status('details', 'Server notified of multipart completion.');
                 if ('1' == $settings['stash_mode']) {
                     // Stash send confirm.
                     pb_backupbuddy::status('details', 'Notifying Stash of upload completion.');
                     $additionalParams = array('upload_id' => $settings['_stash_upload_id']);
                     $response = pb_backupbuddy_destination_stash2::stashAPI($settings, 'upload-complete', $additionalParams);
                     if (!is_array($response) || !isset($response['success'])) {
                         // If not array OR success key missing. May be a timeout or waiting on AWS system to combine multipart still. Check for file later.
                         $settings['_retry_stash_confirm'] = true;
                         $settings['_multipart_counts'] = array();
                         // No more parts remain.
                         $cronTime = time() + self::STASH_CONFIRM_RETRY_DELAY;
                         $cronArgs = array($settings, $file, $send_id, $delete_after);
                         $cronHashID = md5($cronTime . serialize($cronArgs));
                         $cronArgs[] = $cronHashID;
                         $schedule_result = backupbuddy_core::schedule_single_event($cronTime, 'destination_send', $cronArgs);
                         if (true === $schedule_result) {
                             pb_backupbuddy::status('details', 'Scheduled retry attempt to confirm send in `' . self::STASH_CONFIRM_RETRY_DELAY . '` seconds.');
                         } else {
                             pb_backupbuddy::status('error', 'Scheduled retry attempt FAILED to be scheduled.');
                         }
                         /*
                          *		TODO:	Once PING API is available, request a ping in the future so we make sure this actually runs reasonably soon.
                          *				Because we need a delay we are not firing off the cron here immediately so there will be no chaining of PHP
                          *				which may result in large delays before the next process if there's little site traffic.
                          */
                         return array($settings['_multipart_id'], 'Pending multipart send confirmation.');
                     } else {
                         // Array.
                         if (isset($response['success']) && true !== $response['success']) {
                             // Success key set AND not true.
                             pb_backupbuddy::status('error', 'Error #83298932: Error notifying Stash of upload success. Details: `' . print_r($response, true) . '`.');
                             return false;
                         } else {
                             // Success.
                             pb_backupbuddy::status('details', 'Stash notified of upload completition.');
                         }
                     }
                 }
             }
             // end not a Stash confirm retry.
             pb_backupbuddy::status('details', 'No more parts left for this multipart upload. Clearing multipart instance variables.');
             $settings['_multipart_partnumber'] = 0;
             $settings['_multipart_id'] = '';
             $settings['_multipart_file'] = '';
             $settings['_multipart_remotefile'] = '';
             // Multipart completed so safe to prevent housekeeping of incomplete multipart uploads.
             $settings['_multipart_transferspeeds'][] = $uploaded_speed;
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:67,代码来源:init.php

示例9: base64_decode

    }
    echo '<br>';
}
// end deletion.
// Handle copying files to local
if (pb_backupbuddy::_GET('cpy_file') != '') {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating Stash copy.');
    $file = base64_decode(pb_backupbuddy::_GET('cpy_file'));
    if (FALSE !== strstr($file, '?')) {
        $url = $file;
        $file = basename($file);
        $file = substr($file, 0, strpos($file, '?'));
    }
    backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_remote_copy'), array('stash2', $file, $settings));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// end copying to local.
// Handle download link
if (pb_backupbuddy::_GET('downloadlink_file') != '') {
    pb_backupbuddy::alert('Download the selected backup file with <a href="' . esc_url(base64_decode(pb_backupbuddy::_GET('downloadlink_file'))) . '">this link</a>. The link is valid for one hour.');
    echo '<br>';
}
// end download link.
// Get list of files for this site.
if ('true' != pb_backupbuddy::_GET('listAll')) {
    $remotePath = 'backup-' . backupbuddy_core::backup_prefix();
开发者ID:shelbyneilsmith,项目名称:wptools,代码行数:31,代码来源:_manage.php

示例10: cron_next_step

 function cron_next_step($spawn_cron = true, $future_offset = 0, $next_step_title = '')
 {
     // Internal cron (optional; disabled by default).
     if ('1' == pb_backupbuddy::$options['use_internal_cron']) {
         if ($future_offset > 0) {
             // Delay requsted.
             if ($future_offset > backupbuddy_core::adjustedMaxExecutionTime()) {
                 $future_offset = 5;
                 // If huge, try 5 sec.
             }
             sleep($future_offset);
         }
         $cron_url = site_url();
         $args = array('backupbuddy_cron_action' => 'process_backup', 'backupbuddy_serial' => $this->_backup['serial'], 'backupbuddy_time' => time(), 'backupbuddy_key' => pb_backupbuddy::$options['log_serial']);
         pb_backupbuddy::status('details', 'Attempting to bypass WordPress cron and use internal cron system calling `' . $cron_url . '`. Args: `' . print_r($args, true) . '`.');
         pb_backupbuddy::flush();
         $response = wp_remote_post($cron_url, array('method' => 'POST', 'timeout' => backupbuddy_core::adjustedMaxExecutionTime(), 'redirection' => 3, 'httpversion' => '1.0', 'blocking' => false, 'headers' => array(), 'body' => $args, 'cookies' => array()));
         pb_backupbuddy::status('details', 'Cron response: `' . print_r($response, true) . '`.');
         return;
     }
     if ('1' == pb_backupbuddy::$options['skip_spawn_cron_call']) {
         pb_backupbuddy::status('details', 'Advanced option to skip call to spawn cron enabled. Setting to skip spawn_cron() call.');
         $spawn_cron = false;
     }
     pb_backupbuddy::status('details', 'Scheduling Cron for `' . $this->_backup['serial'] . '`.');
     // Need to make sure the database connection is active. Sometimes it goes away during long bouts doing other things -- sigh.
     // This is not essential so use include and not require (suppress any warning)
     @(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
     if (class_exists('pluginbuddy_wpdbutils')) {
         global $wpdb;
         $dbhelper = new pluginbuddy_wpdbutils($wpdb);
         if (!$dbhelper->kick()) {
             pb_backupbuddy::status('error', __('Database Server has gone away, unable to schedule next backup step. The backup cannot continue. This is most often caused by mysql running out of memory or timing out far too early. Please contact your host.', 'it-l10n-backupbuddy'));
             pb_backupbuddy::status('haltScript', '');
             // Halt JS on page.
             return false;
         }
     } else {
         pb_backupbuddy::status('details', __('Database Server connection status unverified.', 'it-l10n-backupbuddy'));
     }
     // Schedule event.
     $cron_time = time() + $future_offset;
     $cron_args = array($this->_backup['serial']);
     pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `backupbuddy_cron` to run method `process_backup` and serial arguments `' . implode(',', $cron_args) . '`.');
     $schedule_result = backupbuddy_core::schedule_single_event($cron_time, 'process_backup', $cron_args);
     if ($schedule_result === false) {
         pb_backupbuddy::status('error', 'Unable to schedule next cron step. Verify that another plugin is not preventing / conflicting.');
     } else {
         pb_backupbuddy::status('details', 'Next step scheduled.');
         pb_backupbuddy::status('startAction', 'cronPass');
         pb_backupbuddy::status('cronParams', base64_encode(json_encode(array('time' => $cron_time, 'tag' => 'backupbuddy_cron', 'method' => 'process_backup', 'args' => $cron_args))));
     }
     update_option('_transient_doing_cron', 0);
     // Prevent cron-blocking for next item.
     // Spawn cron.
     if ($spawn_cron === true) {
         pb_backupbuddy::status('details', 'Calling spawn_cron().');
         spawn_cron(time() + 150);
         // Adds > 60 seconds to get around once per minute cron running limit.
     } else {
         pb_backupbuddy::status('details', 'Not calling spawn_cron().');
     }
     $next_step_note = '';
     if ('' != $next_step_title) {
         $next_step_note = ' (' . $next_step_title . ' expected)';
     }
     pb_backupbuddy::status('details', 'About to run next step' . $next_step_note . '. If the backup does not proceed within 15 seconds then something is interfering with the WordPress CRON system such as: server loopback issues, caching plugins, or scheduling plugins. Try disabling other plugins to see if it resolves issue.  Check the Server Information page cron section to see if the next BackupBuddy step is scheduled to run. Enable "Classic" backup mode on the "Settings" page to rule out non-cron issues. Additionally you may verify no other backup processes are trying to run at the same time by verifying there is not an existing backup process listed in the cron hogging the cron process.');
     return;
 }
开发者ID:Brandonsmith23,项目名称:prodgyr,代码行数:69,代码来源:backup.php

示例11: send

 public static function send($settings = array(), $files = array(), $send_id = '', $delete_remote_after = false)
 {
     self::$_timeStart = microtime(true);
     $settings = self::_normalizeSettings($settings);
     if (false === ($settings = self::_connect($settings))) {
         $error = 'Unable to connect with Google Drive. See log for details.';
         echo $error;
         pb_backupbuddy::status('error', $error);
         return false;
     }
     $chunkSizeBytes = $settings['max_burst'] * 1024 * 1024;
     // Send X mb at a time to limit memory usage.
     foreach ($files as $file) {
         $fileSize = filesize($file);
         $fileinfo = pathinfo($file);
         $fileextension = $fileinfo['extension'];
         if ('zip' == $fileextension) {
             $mimeType = 'application/zip';
         } elseif ('php' == $fileextension) {
             $mimeType = 'application/x-httpd-php';
         } else {
             $mimeType = '';
         }
         pb_backupbuddy::status('details', 'About to upload file `' . $file . '` of size `' . $fileSize . '` with mimetype `' . $mimeType . '`. Internal chunk size of `' . $chunkSizeBytes . '` bytes.');
         //Insert a file
         $driveFile = new Google_Service_Drive_DriveFile();
         $driveFile->setTitle(basename($file));
         $driveFile->setDescription('BackupBuddy file');
         $driveFile->setMimeType($mimeType);
         self::$_client->setDefer(true);
         try {
             $insertRequest = self::$_drive->files->insert($driveFile);
         } catch (Exception $e) {
             pb_backupbuddy::alert('Error #3232783268336: initiating upload. Details: ' . $e->getMessage());
             return;
         }
         // See https://developers.google.com/api-client-library/php/guide/media_upload
         try {
             $media = new Google_Http_MediaFileUpload(self::$_client, $insertRequest, $mimeType, null, true, $chunkSizeBytes);
         } catch (Exception $e) {
             pb_backupbuddy::alert('Error #3893273937: initiating upload. Details: ' . $e->getMessage());
             return;
         }
         $media->setFileSize($fileSize);
         pb_backupbuddy::status('details', 'Opening file for sending in binary mode.');
         $fs = fopen($file, 'rb');
         // If chunked resuming then seek to the correct place in the file.
         if ('' != $settings['resume_point'] && $settings['resume_point'] > 0) {
             // Resuming send of a partially transferred file.
             if (0 !== fseek($fs, $settings['resume_point'])) {
                 // Returns 0 on success.
                 pb_backupbuddy::status('error', 'Error #3872733: Failed to seek file to resume point `' . $settings['resume_point'] . '` via fseek().');
                 return false;
             }
             $prevPointer = $settings['resume_point'];
         } else {
             // New file send.
             $prevPointer = 0;
         }
         $needProcessChunking = false;
         // Set true if we need to spawn off resuming to a new PHP page load.
         $uploadStatus = false;
         while (!$uploadStatus && !feof($fs)) {
             $chunk = fread($fs, $chunkSizeBytes);
             $uploadStatus = $media->nextChunk($chunk);
             // Handle splitting up across multiple PHP page loads if needed.
             if (!feof($fs) && 0 != $settings['max_time']) {
                 // More data remains so see if we need to consider chunking to a new PHP process.
                 // If we are within X second of reaching maximum PHP runtime then stop here so that it can be picked up in another PHP process...
                 if (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM >= $settings['max_time']) {
                     pb_backupbuddy::status('message', 'Approaching limit of available PHP chunking time of `' . $settings['max_time'] . '` sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
                     @fclose($fs);
                     // Tells next chunk where to pick up.
                     $settings['resume_point'] = $prevPointer;
                     if (isset($chunksTotal)) {
                         $settings['chunks_total'] = $chunksTotal;
                     }
                     // Schedule cron.
                     $cronTime = time();
                     $cronArgs = array($settings, $files, $send_id, $delete_after = false);
                     $cronHashID = md5($cronTime . serialize($cronArgs));
                     $cronArgs[] = $cronHashID;
                     $schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
                     if (true === $schedule_result) {
                         pb_backupbuddy::status('details', 'Next Site chunk step cron event scheduled.');
                     } else {
                         pb_backupbuddy::status('error', 'Next Site chunk step cron even FAILED to be scheduled.');
                     }
                     spawn_cron(time() + 150);
                     // Adds > 60 seconds to get around once per minute cron running limit.
                     update_option('_transient_doing_cron', 0);
                     // Prevent cron-blocking for next item.
                     return array($prevPointer, 'Sent part ' . $settings['chunks_sent'] . ' of ~' . $settings['chunks_total'] . ' parts.');
                     // filepointer location, elapsed time during the import
                 } else {
                     // End if.
                     pb_backupbuddy::status('details', 'Not approaching time limit.');
                 }
             } else {
                 pb_backupbuddy::status('details', 'No more data remains (eg for chunking) so finishing up.');
//.........这里部分代码省略.........
开发者ID:arobbins,项目名称:iab,代码行数:101,代码来源:init.php

示例12: send

 public static function send($settings = array(), $file, $send_id = '', $delete_after = false)
 {
     $settings = self::_init($settings);
     // Handles formatting & sanitizing settings.
     // Process multipart transfer that we already initiated in a previous runthrough.
     if ($settings['_multipart_id'] != '') {
         // Multipart upload initiated and needs parts sent.
         $backup_type = str_replace('/', '', $settings['_multipart_backup_type']);
         // For use later by file limiting.
         $backup_size = $settings['_multipart_backup_size'];
         $this_part_number = $settings['_multipart_partnumber'] + 1;
         // Open file for streaming.
         $f = @fopen($settings['_multipart_file'], 'rb');
         if (false === $f) {
             return self::_error('Error #437734. Unable to open file `' . $settings['_multipart_file'] . '` to send. Did it get deleted?');
         }
         if (-1 == @fseek($f, (int) $settings['_multipart_counts'][$settings['_multipart_partnumber']]['seekTo'])) {
             return self::_error('Error #833838: Unable to fseek file.');
         }
         $sendStart = time(true);
         pb_backupbuddy::status('details', 'Beginning upload of part `' . $this_part_number . '` of `' . count($settings['_multipart_counts']) . '` parts of file `' . $settings['_multipart_file'] . '` to remote location `' . $settings['_multipart_remotefile'] . '` with multipart ID `' . $settings['_multipart_id'] . '`.');
         try {
             $response = self::$_client->uploadPart(array('Bucket' => $settings['bucket'], 'Key' => $settings['_multipart_remotefile'], 'UploadId' => $settings['_multipart_id'], 'PartNumber' => $this_part_number, 'ContentLength' => (int) $settings['_multipart_counts'][$settings['_multipart_partnumber']]['length'], 'Body' => $f));
         } catch (Exception $e) {
             @fclose($f);
             return self::_error('Unable to upload file part for multipart upload `' . $settings['_multipart_id'] . '`. Details: `' . $e->getMessage() . '`.');
         }
         @fclose($f);
         pb_backupbuddy::status('details', 'Success sending chunk. Upload details: `' . print_r($response, true) . '`.');
         $uploaded_size = $backup_size;
         $uploaded_speed = time(true) - $sendStart;
         pb_backupbuddy::status('details', 'Uploaded size: ' . pb_backupbuddy::$format->file_size($uploaded_size) . ', Speed: ' . pb_backupbuddy::$format->file_size($uploaded_speed) . '/sec.');
         // Load fileoptions to the send.
         pb_backupbuddy::status('details', 'About to load fileoptions data.');
         require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
         pb_backupbuddy::status('details', 'Fileoptions instance #10.');
         $fileoptions_obj = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/send-' . $send_id . '.txt', $read_only = false, $ignore_lock = false, $create_file = false);
         if (true !== ($result = $fileoptions_obj->is_ok())) {
             return self::_error(__('Fatal Error #9034.2344848. Unable to access fileoptions data.', 'it-l10n-backupbuddy') . ' Error: ' . $result);
         }
         pb_backupbuddy::status('details', 'Fileoptions data loaded.');
         $fileoptions =& $fileoptions_obj->options;
         $update_status = 'Sent part ' . $this_part_number . ' of ' . count($settings['_multipart_counts']) . '.';
         // Made it here so success sending part. Increment for next part to send.
         $settings['_multipart_partnumber']++;
         if (!isset($settings['_multipart_counts'][$settings['_multipart_partnumber']])) {
             // No more parts exist for this file. Tell S3 the multipart upload is complete and move on.
             pb_backupbuddy::status('details', 'S3 getting parts with etags to notify S3 of completed multipart send.');
             try {
                 $response = self::$_client->listParts(array('Bucket' => $settings['bucket'], 'UploadId' => $settings['_multipart_id'], 'Key' => $settings['_multipart_remotefile']));
                 $etag_parts = $etag_parts->Parts;
             } catch (Exception $e) {
                 return self::_error('Error #8332893: Unable to list parts on server. Details: `' . $e->getMessage() . '`.');
             }
             pb_backupbuddy::status('details', 'Got parts list. Details: ' . print_r($etag_parts, true));
             pb_backupbuddy::status('details', 'Notifying server of multipart upload completion.');
             try {
                 $response = self::$_client->completeMultipartUpload(array('Bucket' => $settings['bucket'], 'UploadId' => $settings['_multipart_id'], 'Key' => $settings['_multipart_remotefile'], 'Parts' => $etag_parts));
             } catch (Exception $e) {
                 return self::_error('Unable to notify server of completion of all parts for multipart upload `' . $settings['_multipart_id'] . '`. Details: `' . $e->getMessage() . '`.');
             }
             pb_backupbuddy::status('details', 'Server notified of multipart completion.');
             pb_backupbuddy::status('details', 'No more parts left for this multipart upload. Clearing multipart instance variables.');
             $settings['_multipart_partnumber'] = 0;
             $settings['_multipart_id'] = '';
             $settings['_multipart_file'] = '';
             $settings['_multipart_remotefile'] = '';
             // Multipart completed so safe to prevent housekeeping of incomplete multipart uploads.
             $settings['_multipart_transferspeeds'][] = $uploaded_speed;
             // Overall upload speed average.
             $uploaded_speed = array_sum($settings['_multipart_transferspeeds']) / count($settings['_multipart_counts']);
             pb_backupbuddy::status('details', 'Upload speed average of all chunks: `' . pb_backupbuddy::$format->file_size($uploaded_speed) . '`.');
             $settings['_multipart_counts'] = array();
             // Update stats.
             $fileoptions['_multipart_status'] = $update_status;
             $fileoptions['finish_time'] = time();
             $fileoptions['status'] = 'success';
             if (isset($uploaded_speed)) {
                 $fileoptions['write_speed'] = $uploaded_speed;
             }
             $fileoptions_obj->save();
             unset($fileoptions);
         }
         // Schedule to continue if anything is left to upload for this multipart of any individual files.
         if ($settings['_multipart_id'] != '') {
             pb_backupbuddy::status('details', 'S3 multipart upload has more parts left. Scheduling next part send.');
             $cronTime = time();
             $cronArgs = array($settings, $file, $send_id, $delete_after);
             $cronHashID = md5($cronTime . serialize($cronArgs));
             $cronArgs[] = $cronHashID;
             $schedule_result = backupbuddy_core::schedule_single_event($cronTime, pb_backupbuddy::cron_tag('destination_send'), $cronArgs);
             if (true === $schedule_result) {
                 pb_backupbuddy::status('details', 'Next S3 chunk step cron event scheduled.');
             } else {
                 pb_backupbuddy::status('error', 'Next S3 chunk step cron even FAILED to be scheduled.');
             }
             spawn_cron(time() + 150);
             // Adds > 60 seconds to get around once per minute cron running limit.
             update_option('_transient_doing_cron', 0);
             // Prevent cron-blocking for next item.
//.........这里部分代码省略.........
开发者ID:Offirmo,项目名称:base-wordpress,代码行数:101,代码来源:init.php

示例13: time

         pb_backupbuddy::status('details', 'Waiting for the pre-backup initialization for serial `' . $serial . '` to complete: ' . $init_wait_retry_count, $serial);
         pb_backupbuddy::status('wait_init', '', $serial);
     }
 }
 //***** Process any specialAction methods.
 if ('checkSchedule' == $specialAction) {
     if (FALSE === ($next_scheduled = wp_next_scheduled('pb_backupbuddy_process_backup', array($serial)))) {
         //pb_backupbuddy::status( 'details', print_r( pb_backupbuddy::_POST(), true ), $serial );
         pb_backupbuddy::status('warning', 'WordPress reports the next step is not currently scheduled. It is either in the process of running or went missing. Consider enabled advanced setting missing cron rescheduling if this persists.', $serial, null, $echoNotWrite = true);
         if ('1' == pb_backupbuddy::$options['backup_cron_rescheduling']) {
             pb_backupbuddy::status('details', 'Missing cron rescheduling enabled. Attempting to add the missing schedule back in.', $serial);
             // Schedule event.
             $cron_time = time();
             $cron_args = array($serial);
             pb_backupbuddy::status('details', 'Scheduling next step to run at `' . $cron_time . '` (localized time: ' . pb_backupbuddy::$format->date(pb_backupbuddy::$format->localize_time($cron_time)) . ') with cron tag `backupbuddy_cron` to run method `process_backup` and serial arguments `' . implode(',', $cron_args) . '`.', $serial);
             $schedule_result = backupbuddy_core::schedule_single_event($cron_time, 'process_backup', $cron_args);
             if ($schedule_result === false) {
                 pb_backupbuddy::status('error', 'Unable to reschedule missing cron step. Verify that another plugin is not preventing / conflicting.', $serial);
             } else {
                 pb_backupbuddy::status('details', 'Next step rescheduled.', $serial);
                 pb_backupbuddy::status('startAction', 'cronPass', $serial);
                 // Resets the time this action began so we will not attempt re-scheduling a second time for a bit.
                 pb_backupbuddy::status('cronParams', base64_encode(json_encode(array('time' => $cron_time, 'tag' => 'backupbuddy_cron', 'method' => 'process_backup', 'args' => $cron_args))), $serial);
             }
         }
     } else {
         $timeFromNow = $next_scheduled - time();
         pb_backupbuddy::status('details', 'Checked cron schedule. Next run: `' . $next_scheduled . '`. ' . $timeFromNow . ' seconds from now.', $serial, null, $echoNotWrite = true);
         if ($timeFromNow < 0) {
             // Time cron was to run is in the past.
             $missedTime = abs($timeFromNow);
开发者ID:AgilData,项目名称:WordPress-Skeleton,代码行数:31,代码来源:_getBackupStatus.php

示例14: array

<?php

backupbuddy_core::verifyAjaxAccess();
pb_backupbuddy::load();
// Schedule to run.
$cronArgs = array($schedule_results = false, $force_run = true);
$schedule_result = backupbuddy_core::schedule_single_event(time(), 'php_runtime_test', $cronArgs);
if (true === $schedule_result) {
    pb_backupbuddy::status('details', 'PHP runtime test cron event scheduled.');
} else {
    pb_backupbuddy::status('error', 'PHP runtime test cron event FAILED to be scheduled.');
}
if ('1' != pb_backupbuddy::$options['skip_spawn_cron_call']) {
    pb_backupbuddy::status('details', 'Spawning cron now.');
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
}
die(__('This may take a few minutes...', 'it-l10n-backupbuddy'));
开发者ID:arobbins,项目名称:spellestate,代码行数:20,代码来源:run_php_runtime_test.php

示例15: ftp_close

        // close this connection
        ftp_close($conn_id);
    }
    if ($delete_count > 0) {
        pb_backupbuddy::alert(sprintf(_n('Deleted %d file.', 'Deleted %d files.', $delete_count, 'it-l10n-backupbuddy'), $delete_count));
    } else {
        pb_backupbuddy::alert(__('No backups were deleted.', 'it-l10n-backupbuddy'));
    }
    echo '<br>';
}
// Copy ftp backups to the local backup files
if (!empty($_GET['cpy_file'])) {
    pb_backupbuddy::alert('The remote file is now being copied to your local backups. If the backup gets marked as bad during copying, please wait a bit then click the `Refresh` icon to rescan after the transfer is complete.');
    echo '<br>';
    pb_backupbuddy::status('details', 'Scheduling Cron for creating ftp copy.');
    backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('process_ftp_copy'), array($_GET['cpy_file'], $ftp_server, $ftp_username, $ftp_password, $ftp_directory, $port, $ftps));
    spawn_cron(time() + 150);
    // Adds > 60 seconds to get around once per minute cron running limit.
    update_option('_transient_doing_cron', 0);
    // Prevent cron-blocking for next item.
}
// Connect to server
if ($ftps == '1') {
    // Connect with FTPs.
    if (function_exists('ftp_ssl_connect')) {
        $conn_id = ftp_ssl_connect($ftp_server, $port);
        if ($conn_id === false) {
            pb_backupbuddy::status('details', 'Unable to connect to FTPS  `' . $ftp_server . '` on port `' . $port . '` (check address/FTPS support and that server can connect to this address via this port).', 'error');
            return false;
        } else {
            pb_backupbuddy::status('details', 'Connected to FTPs.');
开发者ID:shelbyneilsmith,项目名称:wptools,代码行数:31,代码来源:_manage.php


注:本文中的backupbuddy_core::schedule_single_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。