if (!is_error($result)) { pdo_delete('core_cron', array('uniacid' => $_W['uniacid'], 'id' => $id)); } else { message("删除{$cron['title']}失败", url('cron/display/list'), 'error'); } } } } message('删除计划任务成功', url('cron/display/list'), 'success'); } else { message('没有选择要删除的任务', referer(), 'error'); } } if ($do == 'run') { $id = intval($_GPC['id']); $status = cron_run($id); if (is_error($status)) { message($status['message'], referer(), 'error'); } message('执行计划任务成功', referer(), 'success'); } if ($do == 'status') { $id = intval($_GPC['id']); $status = intval($_GPC['status']); if (!in_array($status, array(0, 1))) { exit('状态码错误'); } $cron = pdo_get('core_cron', array('uniacid' => $_W['uniacid'], 'id' => $id)); if (empty($cron)) { exit('任务不存在或已删除'); }
define('CLI_SCRIPT', true); global $CLI_VMOODLE_PRECHECK; $CLI_VMOODLE_PRECHECK = true; // Force first config to be minimal. // Config preload to get real roots. require '../../../config.php'; require_once $CFG->dirroot . '/lib/clilib.php'; // cli only functions require_once $CFG->dirroot . '/lib/cronlib.php'; // now get cli options list($options, $unrecognized) = cli_get_params(array('help' => false, 'host' => true), array('h' => 'help', 'H' => 'host')); if ($unrecognized) { $unrecognized = implode("\n ", $unrecognized); cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); } if ($options['help']) { $help = "Execute periodic cron actions.\n\nOptions:\n-h, --help Print out this help\n-H, --host The host name to work for\n\nExample:\n\$sudo -u www-data /usr/bin/php admin/cli/cron.php\n"; echo $help; die; } if (!empty($options['host'])) { // arms the vmoodle switching echo 'Arming for ' . $options['host']; // mtrace not yet available. define('CLI_VMOODLE_OVERRIDE', $options['host']); } // Replay full config whenever. If vmoodle switch is armed, will switch now config. require dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php'; echo 'Config check : playing for ' . $CFG->wwwroot; cron_run();
<?php chdir('./'); define('DEBUG', 0); define('APP_NAME', 'bbs'); define('IN_SAE', class_exists('SaeKV')); $conf = @(include './conf/conf.php'); // 支持 SAE IN_SAE and (include './conf/sae.conf.php'); include './xiunophp/xiunophp.php'; include './model.inc.php'; $browser = get__browser(); check_browser($browser); runtime_init(); online_init(); for ($i = 1; $i < 1000; $i++) { $subject = '欢迎使用 Xiuno BBS 3.0 新一代论坛系统。' . $i; $message = '祝您使用愉快!'; $thread = array('fid' => 1, 'uid' => 1, 'subject' => $subject, 'message' => $message, 'seo_url' => '', 'time' => $time, 'longip' => $longip); $tid = thread_create($thread, $longip); for ($j = 0; $j < 10; $j++) { $post = array('tid' => $tid, 'uid' => 1, 'create_date' => $time, 'userip' => $longip, 'isfirst' => 0, 'message' => $message . rand(1, 10000)); $pid = post_create($post, 1); } if ($i % 100 == 0) { echo '.'; } } cron_run(1); echo '生成数据完毕';
$cron['nextrun'] = $cron['nextrun'] ? date('Y-m-d H:i:s', $cron['nextrun']) : 'N/A'; $cron['run'] = $cron['available']; $cron['cn'] = $cn; } } } if ($do == 'del') { if (checksubmit('submit')) { echo 90; $ids = $_GPC['cronid']; if (!empty($ids)) { $idstr = implode(',', $ids); if (preg_match('/^(\\d{1,10},)*(\\d{1,10})$/', $idstr)) { $state = pdo_query('DELETE FROM ' . tablename('cron') . " WHERE cronid IN ({$idstr})"); if ($state !== false) { //没有删除计划任务的程序文件 message('删除计划任务成功', url('system/cron'), 'success'); } else { message('删除计划任务失败', url('system/cron'), 'error'); } } } } } if ($do == 'run') { $id = intval($_GPC['id']); load()->func('cron'); cron_run($id); message('执行计划任务成功', url('system/cron/list'), 'success'); } template('system/cron');
case 2: if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 12 hour")) { $update = true; } break; case 1: default: if (datetime_convert('UTC', 'UTC', 'now') > datetime_convert('UTC', 'UTC', $t . " + 1 hour")) { $update = true; } break; } if (!$update) { continue; } } logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]); proc_run('php', 'include/onepoll.php', $contact['id']); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } } logger('cron: end'); set_config('system', 'last_cron', time()); return; } if (array_search(__FILE__, get_included_files()) === 0) { cron_run($_SERVER["argv"], $_SERVER["argc"]); killme(); }