本文整理汇总了PHP中spawn_cron函数的典型用法代码示例。如果您正苦于以下问题:PHP spawn_cron函数的具体用法?PHP spawn_cron怎么用?PHP spawn_cron使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn_cron函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: register_cron
function register_cron($run_immediately = false)
{
if ($this->check_cron_registered()) {
$this->unregister_cron();
}
wp_schedule_event($this->o['cron_time'], $this->o['refresh_period'], $this->cron_event);
if ($run_immediately) {
spawn_cron();
}
}
开发者ID:jardenberg,项目名称:SharedItems2WP,代码行数:10,代码来源:SharedItems2WP.php
示例2: handle_subscription
private function handle_subscription()
{
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
Header('Content-Type: text/plain');
$this->send_text('200 OK', $_GET['hub_challenge']);
} else {
wp_schedule_single_event(time(), 'degg_instagram_fetch', array($this->client_id, $this->tag));
spawn_cron(time());
$this->send_text('200 OK', "OK");
}
}
开发者ID:travisscheidegger,项目名称:wp-instagram-subscription,代码行数:11,代码来源:APIEndpoint.php
示例3: cron_next_step
function cron_next_step($spawn_cron = true)
{
$this->status('details', 'Scheduling Cron for ' . $this->_backup['serial'] . '.');
$this->log('Scheduling Cron for ' . $this->_backup['serial'] . '.');
wp_schedule_single_event(time(), $this->_parent->_var . '-cron_process_backup', array($this->_backup['serial']));
if ($spawn_cron === true) {
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:niko-lgdcom,项目名称:archives,代码行数:12,代码来源:backup.php
示例4: runAt
/**
* Schedule a run at time "$time" unless a it's already scheduled or running
*
* @param integer $time Unix timestamp
* @param bool $forceRun If true, schedule a run regardless of whether it's already running and/or scheduled
* @param array $args
*
* @return bool
*/
function runAt($time, $forceRun = false, $args = array())
{
if ($forceRun || !$this->isScheduled()) {
if ($forceRun || !$this->isRunning()) {
$this->log->info("{$this->cronHook}: schedule at {$time}");
$this->timestamp = $time;
$this->args = $args;
wp_schedule_single_event($time, $this->cronHook, $args);
spawn_cron();
return true;
} else {
$this->log->info("{$this->cronHook}: schedule at {$time} but is already running");
}
} else {
$this->log->info("{$this->cronHook}: schedule at {$time} but is already scheduled");
}
return false;
}
开发者ID:Bakerpedia,项目名称:Development_Site5,代码行数:27,代码来源:EasyRecipePlusScheduler.php
示例5: start_cron
/**
* Kicks of an import or export cronjob.
*
* @param $type
*/
protected function start_cron($type)
{
update_option('_wpghs_' . $type . '_started', 'yes');
wp_schedule_single_event(time(), 'wpghs_' . $type . '');
spawn_cron();
}
开发者ID:AramZS,项目名称:wordpress-github-sync,代码行数:11,代码来源:wp-github-sync.php
示例6: wp_cron
function wp_cron() {
// Prevent infinite loops caused by lack of wp-cron.php
if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false )
return;
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > time() )
return;
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > time() ) break;
foreach ( $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron();
break 2;
}
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:25,代码来源:cron.php
示例7: send
//.........这里部分代码省略.........
pb_backupbuddy::status('details', 'Notifying Stash of completed multipart upload with done url `' . $done_url . '`.');
$request = new RequestCore($done_url);
$response = $request->send_request(true);
if (!$response->isOK()) {
$this_error = 'Error #756834682. Could not finalize Stash upload. Response code: `' . $response->get_response_code() . '`; Response body: `' . $response->get_response_body() . '`; Response headers: `' . $response->get_response_header() . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
} else {
// Good server response.
// See if we got an optional json response.
$upload_data = @json_decode($response->body, true);
if (isset($upload_data['error'])) {
$this_error = 'Stash error(s): `' . implode(' - ', $upload_data['error']) . '`.';
$pb_backupbuddy_destination_errors[] = $this_error;
pb_backupbuddy::status('error', $this_error);
return false;
}
pb_backupbuddy::status('details', 'Stash success sending file `' . basename($settings['_multipart_file']) . '`. File uploaded via multipart across `' . $this_part_number . '` parts and reported to Stash as completed.');
}
pb_backupbuddy::status('details', 'Stash has no more parts left for this multipart upload. Clearing multipart instance variables.');
$settings['_multipart_partnumber'] = 0;
$settings['_multipart_id'] = '';
$settings['_multipart_file'] = '';
$settings['_multipart_counts'] = array();
$settings['_multipart_upload_data'] = array();
}
delete_transient('pb_backupbuddy_stashquota_' . $settings['itxapi_username']);
// Delete quota transient since it probably has changed now.
// Schedule to continue if anything is left to upload for this multipart of any individual files.
if ($settings['_multipart_id'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'Stash multipart upload has more parts left. Scheduling next part send.');
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('destination_send'), array($settings, $files, 'multipart', false));
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.
pb_backupbuddy::status('details', 'Stash scheduled send of next part(s). Done for this cycle.');
return array($settings['_multipart_id'], 'Sent ' . $this_part_number . ' of ' . count($multipart_destination_settings['_multipart_counts'] . ' parts.'));
}
}
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'Stash: Zip file. Detecting backup type if possible.');
$serial = pb_backupbuddy::$classes['core']->get_serial_from_file($file);
if (isset(pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `' . pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '` via integrity check data.');
$backup_type_dir = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'] . '/';
$backup_type = pb_backupbuddy::$options['backups'][$serial]['integrity']['detected_type'];
} else {
if (stristr($file, '-db-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `db` via filename.');
$backup_type_dir = 'db/';
$backup_type = 'db';
} elseif (stristr($file, '-full-') !== false) {
pb_backupbuddy::status('details', 'Stash: Detected backup type as `full` via filename.');
$backup_type_dir = 'full/';
$backup_type = 'full';
} else {
pb_backupbuddy::status('details', 'Stash: Could not detect backup type via integrity details nor filename.');
}
开发者ID:CherylMuniz,项目名称:fashion,代码行数:67,代码来源:init.php
示例8: wp_cron
function wp_cron() {
$crons = _get_cron_array();
if ( !is_array($crons) )
return;
$keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > time() )
return;
$schedules = wp_get_schedules();
foreach ( $crons as $timestamp => $cronhooks ) {
if ( $timestamp > time() ) break;
foreach ( $cronhooks as $hook => $args ) {
if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
continue;
spawn_cron();
break 2;
}
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:21,代码来源:cron.php
示例9: 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
示例10: ScheduleReloadAttachments
/**
* Schedule the loading of attachments
*/
function ScheduleReloadAttachments()
{
wp_schedule_single_event(time(), 'wishlistmember_attachments_load');
spawn_cron(time());
}
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:8,代码来源:wpm.php
示例11: _verb_getBackupStatus
private static function _verb_getBackupStatus()
{
$backupSerial = pb_backupbuddy::_POST('serial');
pb_backupbuddy::status('details', '*** End Remote Backup Log section', $backupSerial);
// Place at end of log.
backupbuddy_api::getBackupStatus($backupSerial);
// echos out. Use $returnRaw = true for remote_api call for this special verb that does not return json.
// Fix missing WP cron constant.
if (!defined('WP_CRON_LOCK_TIMEOUT')) {
define('WP_CRON_LOCK_TIMEOUT', 60);
// In seconds
}
// Try to force cron to run so that we can push the backup along.
spawn_cron(time() + 150);
// Adds > 60 seconds to get around once per minute cron running limit.
}
开发者ID:JDjimenezdelgado,项目名称:old-mmexperience,代码行数:16,代码来源:remote_api.php
示例12: ajax_remotesend
function ajax_remotesend()
{
wp_schedule_single_event(time(), 'pb_backupbuddy-cron_remotesend', array($_POST['destination_id'], $this->_options['backup_directory'] . $_POST['file']));
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.
echo 1;
die;
}
开发者ID:niko-lgdcom,项目名称:archives,代码行数:10,代码来源:backupbuddy.php
示例13: cron_next_step
function cron_next_step($spawn_cron = true, $future_offset = 0)
{
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)
pb_backupbuddy::status('details', 'Loading DB kicker in case database has gone away.');
@(include_once pb_backupbuddy::plugin_path() . '/lib/wpdbutils/wpdbutils.php');
if (class_exists('pluginbuddy_wpdbutils')) {
// This is the database object we want to use
global $wpdb;
// Get our helper object and let it use us to output status messages
$dbhelper = new pluginbuddy_wpdbutils($wpdb);
// If we cannot kick the database into life then signal the error and return false which will stop the backup
// Otherwise all is ok and we can just fall through and let the function return true
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('action', 'halt_script');
// Halt JS on page.
return false;
} else {
pb_backupbuddy::status('details', 'Database seems to still be connected.');
}
} else {
// Utils not available so cannot verify database connection status - just notify
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.');
}
// Spawn cron.
if ($spawn_cron === true) {
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.
pb_backupbuddy::status('details', 'About to run next step. If the backup stalls at this point then something is interfering with the WordPress CRON system such as a caching or scheduling plugin. 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:serker72,项目名称:T3S,代码行数:47,代码来源:backup.php
示例14: remote_send
public function remote_send()
{
if (defined('PB_DEMO_MODE')) {
die('Access denied in demo mode.');
}
if (pb_backupbuddy::_POST('send_importbuddy') == '1') {
$send_importbuddy = true;
} else {
$send_importbuddy = false;
}
wp_schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($_POST['destination_id'], pb_backupbuddy::$options['backup_directory'] . $_POST['file'], $_POST['trigger'], $send_importbuddy));
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.
echo 1;
die;
}
开发者ID:verbazend,项目名称:AWFA,代码行数:18,代码来源:ajax.php
示例15: send
//.........这里部分代码省略.........
$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'] != '' || count($files) > 0) {
pb_backupbuddy::status('details', 'S3 multipart upload has more parts left. Scheduling next part send.');
$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 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.
return array($settings['_multipart_id'], 'Sent part ' . $this_part_number . ' of ' . count($settings['_multipart_counts']) . ' parts.');
}
}
// end if multipart continuation.
require_once pb_backupbuddy::plugin_path() . '/classes/fileoptions.php';
// Upload each file.
foreach ($files as $file_id => $file) {
// Determine backup type directory (if zip).
$backup_type_dir = '';
$backup_type = '';
if (stristr($file, '.zip') !== false) {
// If a zip try to determine backup type.
pb_backupbuddy::status('details', 'S3: Zip file. Detecting backup type if possible.');
$serial = backupbuddy_core::get_serial_from_file($file);
// See if we can get backup type from fileoptions data.
pb_backupbuddy::status('details', 'Fileoptions instance #9.');
$backup_options = new pb_backupbuddy_fileoptions(backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt', $read_only = true, $ignore_lock = true);
if (true !== ($result = $backup_options->is_ok())) {
pb_backupbuddy::status('error', 'Unable to open fileoptions file `' . backupbuddy_core::getLogDirectory() . 'fileoptions/' . $serial . '.txt' . '`.');
} else {
if (isset($backup_options->options['integrity']['detected_type'])) {
pb_backupbuddy::status('details', 'S3: Detected backup type as `' . $backup_options->options['integrity']['detected_type'] . '` via integrity check data.');
//$backup_type_dir = $backup_options->options['integrity']['detected_type'] . '/';
$backup_type = $backup_options->options['integrity']['detected_type'];
}
}
// If still do not know backup type then attempt to deduce it from filename.
if ($backup_type == '') {
if (stristr($file, '-db-') !== false) {
开发者ID:russtx,项目名称:tac,代码行数:67,代码来源:init.php
示例16: start_import
/**
* Sets and kicks off the import cronjob
*/
public function start_import()
{
update_option('_wpghs_import_started', 'yes');
WordPress_GitHub_Sync::write_log(__('Starting import from GitHub.', WordPress_GitHub_Sync::$text_domain));
wp_schedule_single_event(time(), 'wpghs_import');
spawn_cron();
}
开发者ID:renzotello,项目名称:gitWebTrevor,代码行数:10,代码来源:wp-github-sync.php
示例17: scanSchedule
/**
* Schedule a site scan immediately unless it's already scheduled or already running
*
* @return bool TRUE if the scan was scheduled, false if it wasn't (because it's already scheduled or running)
*/
function scanSchedule()
{
if (!wp_next_scheduled(self::FOODERIFIC_SCAN)) {
if (get_transient(self::FOODERIFIC_SCAN) != 'run') {
/**
* Tell fooderific a scan was scheduled
* Really only for debugging so we can tell if scans aren't being run
*/
$data = new stdClass();
$data->action = 'scheduled';
$data->wpurl = get_bloginfo("wpurl");
$data->count = 0;
$args = array('body' => array('data' => serialize($data)));
wp_remote_post(self::FOODERIFIC_URL, $args);
wp_schedule_single_event(time(), self::FOODERIFIC_SCAN, array(0));
spawn_cron();
return true;
} else {
}
} else {
}
return false;
}
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:28,代码来源:EasyRecipePlusFooderific.php
示例18: remote_send
public function remote_send()
{
$success_output = false;
// Set to true onece a leading 1 has been sent to the javascript to indicate success.
$destination_id = pb_backupbuddy::_POST('destination_id');
if (pb_backupbuddy::_POST('file') != 'importbuddy.php') {
$backup_file = backupbuddy_core::getBackupDirectory() . pb_backupbuddy::_POST('file');
if (!file_exists($backup_file)) {
// Error if file to send did not exist!
$error_message = 'Unable to find file `' . $backup_file . '` to send. File does not appear to exist. You can try again in a moment or turn on full error logging and try again to log for support.';
pb_backupbuddy::status('error', $error_message);
pb_backupbuddy::alert($error_message, true);
die;
}
} else {
$backup_file = '';
}
// Send ImportBuddy along-side?
if (pb_backupbuddy::_POST('send_importbuddy') == '1') {
$send_importbuddy = true;
pb_backupbuddy::status('details', 'Cron send to be scheduled with importbuddy sending.');
} else {
$send_importbuddy = false;
pb_backupbuddy::status('details', 'Cron send to be scheduled WITHOUT importbuddy sending.');
}
// Delete local copy after send completes?
if (pb_backupbuddy::_POST('delete_after') == 'true') {
$delete_after = true;
pb_backupbuddy::status('details', 'Remote send set to delete after successful send.');
} else {
$delete_after = false;
pb_backupbuddy::status('details', 'Remote send NOT set to delete after successful send.');
}
// For Stash we will check the quota prior to initiating send.
if (pb_backupbuddy::$options['remote_destinations'][$destination_id]['type'] == 'stash') {
// Pass off to destination handler.
require_once pb_backupbuddy::plugin_path() . '/destinations/bootstrap.php';
$send_result = pb_backupbuddy_destinations::get_info('stash');
// Used to kick the Stash destination into life.
$stash_quota = pb_backupbuddy_destination_stash::get_quota(pb_backupbuddy::$options['remote_destinations'][$destination_id], true);
if (isset($stash_quota['error'])) {
echo ' Error accessing Stash account. Send aborted. Details: `' . implode(' - ', $stash_quota['error']) . '`.';
die;
}
if ($backup_file != '') {
$backup_file_size = filesize($backup_file);
} else {
$backup_file_size = 50000;
}
if ($backup_file_size + $stash_quota['quota_used'] > $stash_quota['quota_total']) {
echo "You do not have enough Stash storage space to send this file. Please upgrade your Stash storage or delete files to make space.\n\n";
echo 'Attempting to send file of size ' . pb_backupbuddy::$format->file_size($backup_file_size) . ' but you only have ' . $stash_quota['quota_available_nice'] . ' available. ';
echo 'Currently using ' . $stash_quota['quota_used_nice'] . ' of ' . $stash_quota['quota_total_nice'] . ' (' . $stash_quota['quota_used_percent'] . '%).';
die;
} else {
if (isset($stash_quota['quota_warning']) && $stash_quota['quota_warning'] != '') {
echo '1Warning: ' . $stash_quota['quota_warning'] . "\n\n";
$success_output = true;
}
}
}
// end if Stash.
pb_backupbuddy::status('details', 'Scheduling cron to send to this remote destination...');
$schedule_result = backupbuddy_core::schedule_single_event(time(), pb_backupbuddy::cron_tag('remote_send'), array($destination_id, $backup_file, pb_backupbuddy::_POST('trigger'), $send_importbuddy, $delete_after));
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.
// SEE cron.php remote_send() for sending function that we pass to via the cron above.
if ($success_output === false) {
echo 1;
}
die;
}
开发者ID:serker72,项目名称:T3S,代码行数:81,代码来源:ajax.php
示例19: spawn_cron
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
*/
$config = WPB2D_Factory::get('config');
if (!$config->get_option('in_progress')) {
spawn_cron();
}
$log = WPB2D_Factory::get('logger')->get_log();
if (empty($log)) {
?>
<p><?php
_e('You have not run a backup yet. When you do you will see a log of it here.');
?>
</p>
<?php
} else {
?>
<ul>
<?php
foreach (array_reverse($log) as $log_item) {
?>
开发者ID:TyRichards,项目名称:river_of_life,代码行数:31,代码来源:wpb2d-progress.php
示例20: send
//.........这里部分代码省略.........
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;
// 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'] = microtime(true);
$fileoptions['status'] = 'success';
if (isset($uploaded_speed)) {
$fileoptions['write_speed'] = $uploaded_speed;
}
$fileoptions_obj->save();
unset($fileoptions);
$fileDone = true;
@fclose($f);
} else {
// Parts remain. Schedule to continue if anything is left to upload for this multipart of any individual files.
pb_backupbuddy::status('details', 'S3 multipart upload has more parts left.');
$update_status = '<br>';
$totalSent = 0;
for ($i = 0; $i < $settings['_multipart_partnumber']; $i++) {
$totalSent += $settings['_multipart_counts'][$i]['length'];
}
$percentSent = ceil($totalSent / $settings['_multipart_backup_size'] * 100);
$update_status .= '<div class="backupbuddy-progressbar" data-percent="' . $percentSent . '"><div class="backupbuddy-progressbar-label"></div></div>';
if ('0' != $maxTime) {
// Not unlimited time so see if we can send more bursts this time or if we need to chunk.
// 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...
$totalSizeSent = self::$_chunksSentThisRound * $chunkSizeBytes;
// Total bytes sent this PHP load.
$bytesPerSec = $totalSizeSent / (microtime(true) - $sendStart);
$timeRemaining = $maxTime - (microtime(true) - self::$_timeStart + self::TIME_WIGGLE_ROOM);
if ($timeRemaining < 0) {
$timeRemaining = 0;
}
$bytesWeCouldSendWithTimeLeft = $bytesPerSec * $timeRemaining;
//pb_backupbuddy::status( 'details', 'Sent this burst: `' . pb_backupbuddy::$format->file_size( $totalSizeSent ) .'` in `' . (microtime(true) - $sendStart ) . '` secs. Speed: `' . pb_backupbuddy::$format->file_size( $bytesPerSec ) . '`/sec. Time Remaining (w/ wiggle): `' . $timeRemaining . '`. Size that could potentially be sent with remaining time: `' . pb_backupbuddy::$format->file_size( $bytesWeCouldSendWithTimeLeft ) . '` with chunk size of `' . pb_backupbuddy::$format->file_size( $chunkSizeBytes ) . '`.' );
if ($bytesWeCouldSendWithTimeLeft < $chunkSizeBytes) {
// We can send more than a whole chunk (including wiggle room) so send another bit.
pb_backupbuddy::status('message', 'Not enough time left (~`' . $timeRemaining . '`) with max time of `' . $maxTime . '` sec to send another chunk at `' . pb_backupbuddy::$format->file_size($bytesPerSec) . '` / sec. Ran for ' . round(microtime(true) - self::$_timeStart, 3) . ' sec. Proceeding to use chunking.');
@fclose($fs);
$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, '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.
@fclose(
|
请发表评论