public function run(&$params) { if (C('UPGRADE_NOTICE_ON') && (!S('think_upgrade_interval') || C('UPGRADE_NOTICE_DEBUG'))) { if (IS_SAE && C('UPGRADE_NOTICE_QUEUE') && !isset($_POST['think_upgrade_queque'])) { $queue = new SaeTaskQueue(C('UPGRADE_NOTICE_QUEUE')); $queue->addTask('http://' . $_SERVER['HTTP_HOST'] . __APP__, 'think_upgrade_queque=1'); if (!$queue->push()) { trace('升级提醒队列执行失败,错误原因:' . $queue->errmsg(), '升级通知出错', 'NOTIC', true); } return; } $akey = C('UPGRADE_NOTICE_AKEY', null, ''); $skey = C('UPGRADE_NOTICE_SKEY', null, ''); $this->accesskey_ = $akey ? $akey : (defined('SAE_ACCESSKEY') ? SAE_ACCESSKEY : ''); $this->secretkey_ = $skey ? $skey : (defined('SAE_SECRETKEY') ? SAE_SECRETKEY : ''); $current_version = C('UPGRADE_CURRENT_VERSION', null, 0); //读取接口 $info = $this->send('http://sinaclouds.sinaapp.com/thinkapi/upgrade.php?v=' . $current_version); if ($info['version'] != $current_version) { if ($this->send_sms($info['msg'])) { trace($info['msg'], '升级通知成功', 'NOTIC', true); } //发送升级短信 } S('think_upgrade_interval', true, C('UPGRADE_NOTICE_CHECK_INTERVAL', null, 604800)); } }
function TimingTask() { // load urls $mysql = new SaeMysql(); $sql = "SELECT url FROM `url`"; $data = $mysql->getData( $sql ); $mysql->closeDb(); $queue = new SaeTaskQueue('task_queue_0_2'); $array = array(); for($i = 0; $i < sizeof($data); ++$i) { //$array[] = array('url'=>"http://urlwatcher.sinaapp.com/url_watch.php", "postdata"=>"target=".$data[$i], "prior"=>true); $array[] = array('url'=>"http://urlwatcher.sinaapp.com/url_watch.php?target=" . $data[$i]["url"], "postdata"=>NULL, "prior"=>true); } $queue->addTask($array); $ret = $queue->push(); if ($ret === false) { var_dump($queue->errno(), $queue->errmsg()); echo "Failed."; } else { echo "Success."; print_r($array); } }
public function CookieReload($cookieid) { $queue = new \SaeTaskQueue('NewSign'); $queue->addTask("/index.php/Home/Queue/LoadTb", "cookieid=" . $cookieid); $queue->push(); echo json_encode(array('info' => '操作完毕,队列加载中', 'status' => true)); }
public function addMessage(Pub_entity $message) { $message->pub_id = null; $this->db->insert('pub', $message); if ($this->db->insert_id() > 0) { if (class_exists('SaeTaskQueue')) { $queue = new SaeTaskQueue('push'); $queue->addTask("/index.php/pubsub_channel/rowPush?id=" . $this->db->insert_id()); $queue->push(); } } }
public function CronInterface() { $db = M('SignList'); $queue = new \SaeTaskQueue('NewSign'); // 统计剩余未签到 $leftCount = $db->where('issign!=1')->count(); $queueLeftLength = $queue->leftLength(); $workArr = array(); if ($leftCount == 0) { echo 'Left UnSign Tieba is empty'; return; } // 剩余未签到是否大于队列长度 if ($leftCount > $queueLeftLength) { $workArr = $db->where('issign!=1')->limit($queueLeftLength)->select(); } else { $workArr = $db->where('issign!=1')->select(); } // 分发至队列 foreach ($workArr as $value) { $queue->addTask("/index.php/Home/Queue/TbSign", "cookieid=" . $value['cookieid'] . '&tiebaname=' . $value['tiebaname'] . '&fid=' . $value['fid'] . '&urlname=' . $value['urlname'] . '&signlistid=' . $value['id']); } $queue->push(); }
public function tq() { $t = new SaeTaskQueue("test"); $t->addTask("http://" . $_SERVER['HTTP_HOST'] . __URL__ . "/tq_test1"); //添加列队任务1 $t->addTask("http://" . $_SERVER['HTTP_HOST'] . __URL__ . "/tq_test2", "k1=v1&k2=v2", true); //添加列队任务2 if (!$t->push()) { echo '出错:' . $t->errmsg(); } else { if (IS_SAE) { echo '请查看SAE的日志中心执行,选择类型为debug'; } else { echo '执行成功!请查看[' . LOG_PATH . 'sae_debug.log' . ']文件中的日志'; } } }
$flag = 0; $sendresult = "发送失败" . $res; } saveMailLog($maillogsid, $userid, "自己", $email1, $subject, $content, $flag, $sendresult, $currenttime); } } } } } } } } } $queue->addTask($array); //将任务推入队列 $queue->push(); function getIntervar($userid) { global $adb; $query = "select interval from ec_systems where server_type='email' and smownerid='" . $userid . "' "; $row = $adb->getFirstLine($query); if (!empty($row)) { return $row['interval']; } else { return ''; } } function send_webmail($mail, $to_email, $subject, $contents, $smownerid, $callback) { global $adb, $log; global $current_user;
function api() { $request = array('source' => v('source'), 'data' => v('data'), 'ckeys' => v('ckeys')); $queue = new SaeTaskQueue('nowboard'); $queue->addTask("http://" . c('site_domain') . "/?a=apido", "request=" . serialize($request)); $ret = $queue->push(); return ajax_echo('sent.' . print_r($ret, 1)); }
public function timerAction() { $tasks = array(); $list = Ysu_LibraryModel::select_all(); if (empty($list)) { echo 'no task'; exit; } $queue = new SaeTaskQueue('ysulibrary'); foreach ($list as $v) { $tasks[] = array('url' => '/ysu/task', 'postdata' => 'param=' . json_encode($v)); } $queue->addTask($tasks); $ret = $queue->push(); if ($ret === false) { var_dump($queue->errno(), $queue->errmsg()); } else { echo 'total task: ' . count($list); } }
function cron($start = 0, $limit = 70, $schema_id = 0) { global $_db; $where = "WHERE `status` = 'on'"; if ($schema_id > 0) { $where .= " AND schema_id = {$schema_id}"; $start = 0; $limit = 1; } $sql = "SELECT * FROM `schemas` {$where} LIMIT {$start},{$limit}"; $schemas = $_db->get_results($sql); fetch_web($schemas); return count($schemas); } if (is_numeric($_REQUEST['start'])) { echo cron($_REQUEST['start'], $_REQUEST['limit']); } elseif (empty($_REQUEST['start'])) { $total = $_db->get_var("SELECT count(*) FROM `schemas` WHERE `status` = 'on'"); $queue = new SaeTaskQueue("cron_tail"); $array = array(); for ($i = 0; $i <= $total + 70; $i += 70) { $array[] = array('url' => "http://pickcat.sinaapp.com/cron.php", "postdata" => "start={$i}&limit=70"); } $queue->addTask($array); $ret = $queue->push(); if ($ret === false) { var_dump($queue->errno(), $queue->errmsg()); } else { echo 'true'; } }