/** * 执行一个计划任务 * * @param 计划任务文件 * @param 计划任务名称 * @return bool 执行成功true,否则false */ function RunCron($file, $name) { return cron::run($file, $name); }
<?php ini_set('max_execution_time', 600); //600 seconds = 10 minutes $cron = new cron(); $cron->domain_id=1; $message = $cron->run(); try { //json //header('Content-type: application/json'); //echo encode::json( $message, 'pretty' ); //xml ob_end_clean(); header('Content-type: application/xml'); echo encode::xml( $message ); } catch (Exception $e) { echo $e->getMessage(); }
if ((empty($_REQUEST['pw']) || $_REQUEST['pw'] != $cron_pw) && (empty($cmd_pw) || $cmd_pw['pw'] != $cron_pw)) { msg('计划任务执行失败:密码错误<br/><br/>你需要通过访问 <b>do.php?pw=密码</b> 才能执行计划任务', false); } } if (isset($_GET['in_thread'])) { define('SYSTEM_CRON_THREAD', true); } doAction('cron_1'); if (SYSTEM_PAGE == 'runcron') { $cron = isset($_GET['cron']) ? sqladds(strip_tags($_GET['cron'])) : msg('运行失败:计划任务未指定'); $cpw = option::get('cron_pw'); $x = $m->once_fetch_array("SELECT * FROM `" . DB_PREFIX . "cron` WHERE `name` = '{$cron}';"); if (empty($x['id'])) { msg('运行失败:此计划任务不存在'); } $log = cron::run($x['file'], $x['name']); if ($x['freq'] == '-1') { cron::del($x['name']); } else { cron::aset($x['name'], array('lastdo' => time(), 'log' => $log)); } } else { $sign_multith = option::get('sign_multith'); if (!isset($_GET['donnot_sign_multith']) && !empty($sign_multith) && function_exists('fsockopen')) { for ($ii = 0; $ii < $sign_multith; $ii++) { sendRequest(SYSTEM_URL . 'do.php?donnot_sign_multith&in_thread&pw=' . $cron_pw); } } $return = ''; if (option::get('cron_last_do_time') != $today) { option::set('cron_last_do_time', $today);
case 'admin:cron': doAction('cron_setting_1'); if (!empty($_GET['act'])) { cron::aset($_GET['act'], array('no' => 0)); } elseif (!empty($_GET['dis'])) { cron::aset($_GET['dis'], array('no' => 1)); } elseif (isset($_GET['uninst'])) { cron::del($_GET['uninst']); } elseif (isset($_GET['add'])) { if (stripos($_POST['file'], 'do.php') !== false) { msg('<h4>请不要将do.php加入到云签的计划任务中来</h4>若需签到,请用云监控监控<br/>' . SYSTEM_URL . 'do.php<br/>即可实现计划任务(cron)的效果<br/><br/>推荐云监控:<a href="http://www.aliyun.com/product/jiankong/" target="_blank">阿里云监控</a> 或 <a href="http://jk.cloud.360.cn/" target="_blank">360网站服务监控</a> 或 <a href="http://ce.baidu.com/" target="_blank">百度云观测</a><br/>如果你的服务器在国外且国内访问较慢,则推荐使用:<a href="http://www.mywebcron.com/" target="_blank">Free Web Cron Service </a>', SYSTEM_URL . 'index.php?mod=admin:cron'); } else { cron::set($_POST['name'], $_POST['file'], $_POST['no'], $_POST['status'], $_POST['freq'], $_POST['lastdo'], $_POST['log']); } } elseif (isset($_GET['run'])) { $return = cron::run($_GET['file'], $_GET['run']); cron::aset($_GET['run'], array('lastdo' => time(), 'log' => $return)); } elseif (isset($_GET['xorder'])) { foreach ($_POST['order'] as $key => $value) { cron::aset($key, array('orde' => $value)); } } doAction('cron_setting_2'); Redirect('index.php?mod=admin:cron&ok'); break; case 'admin:update:back': if (isset($_GET['del'])) { if (file_exists(SYSTEM_ROOT . '/setup/update_backup/' . $_GET['del'])) { DeleteFile(SYSTEM_ROOT . '/setup/update_backup/' . $_GET['del']); } Redirect('index.php?mod=admin:update:back&ok');
} $jsonrpc->makeSuccess(utils::o2a($object)); } if ($jsonrpc->getMethod() == 'object::full') { $cache = cache::byKey('api::object::full'); $cron = cron::byClassAndFunction('object', 'fullData'); if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('object'); $cron->setFunction('fullData'); $cron->setSchedule('* * * * * 2000'); $cron->setTimeout(10); $cron->save(); if (!$cron->running()) { $cron->run(true); } if ($cache->getValue() != '') { $jsonrpc->makeSuccess(json_decode($cache->getValue(), true)); } $jsonrpc->makeSuccess(array()); } if ($jsonrpc->getMethod() == 'object::fullById') { $object = object::byId($params['id']); if (!is_object($object)) { throw new Exception('Objet introuvable : ' . $params['id'], -32601); } $return = utils::o2a($object); $return['eqLogics'] = array(); foreach ($object->getEqLogic() as $eqLogic) { $eqLogic_return = utils::o2a($eqLogic);