Ejemplo n.º 1
0
 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 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));
     }
 }
Ejemplo n.º 3
0
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);
    }
}
Ejemplo n.º 4
0
 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();
         }
     }
 }
Ejemplo n.º 5
0
 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();
 }
Ejemplo n.º 6
0
 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' . ']文件中的日志';
         }
     }
 }
Ejemplo n.º 7
0
<?php

require_once 'config.inc.php';
require_once 'include/utils/utils.php';
require_once 'include/database/PearDatabase.php';
require_once 'Sms/SmsLib.php';
global $current_user;
global $adb;
// new a mail
$mail = new SaeMail();
$nowdatetime = date("Y-m-d H:i:s");
$queue = new SaeTaskQueue('sendnums');
$array = array();
$url = "http://" . $_SERVER['HTTP_HOST'] . "/getSendMailNums.php";
//查出所有用户
$query = "select id,phone_mobile,email1,last_name,user_name from ec_users where 1";
$result = $adb->query($query);
$num_rows = $adb->num_rows($result);
if ($num_rows > 0) {
    for ($i = 0; $i < $num_rows; $i++) {
        $userid = $adb->query_result($result, $i, "id");
        $phone_mobile = $adb->query_result($result, $i, "phone_mobile");
        $email1 = $adb->query_result($result, $i, "email1");
        $last_name = $adb->query_result($result, $i, "last_name");
        $user_name = $adb->query_result($result, $i, "user_name");
        //搜索该用户所有的提醒规则模板
        $query2 = "select * from ec_memdayconfig where smownerid='{$userid}'";
        $result2 = $adb->query($query2);
        $num_rows2 = $adb->num_rows($result2);
        if ($num_rows2 > 0) {
            for ($j = 0; $j < $num_rows2; $j++) {
    $qiandao = json_decode($qiandao, 1);
    if (!is_array($qiandao)) {
        echo '<font color="#999999">' . $row['id'] . '</font><br>';
    } elseif (isset($qiandao['status']) && $qiandao['status'] == 401) {
        //删除失效cookie
        $tmp = $db->prepare('DELETE FROM `' . $dbpre . 'cookie` WHERE id = ?');
        $tmp->bindValue(1, $row['id']);
        $tmp->execute();
        echo '<font color="red">' . $row['id'] . '</font><br>';
    } elseif ($qiandao['success'] == TRUE || $qiandao['result'] == '您今天已签到过') {
        //成功
        $tmp = $db->prepare('UPDATE `' . $dbpre . 'cookie` SET last_sign = \'' . $date . '\' WHERE id = ?');
        $tmp->bindValue(1, $row['id']);
        $tmp->execute();
        echo '<font color="green">' . $row['id'] . '</font><br>';
    } else {
        //未知
        echo '<font color="black">' . $row['id'] . '</font><br>';
    }
}
$tmp = $db->prepare('SELECT count(*) as num FROM `' . $dbpre . 'cookie` WHERE last_sign <> ?');
$tmp->bindValue(1, $date);
$tmp->execute();
//查询
$tmp->setFetchMode(PDO::FETCH_ASSOC);
$tmp = $tmp->fetch();
if ($tmp['num'] != 0) {
    //还有没有签到的
    $queue = new SaeTaskQueue($task);
    $queue->addTask($self);
}
Ejemplo n.º 9
0
 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));
 }
Ejemplo n.º 10
0
 $mentions = find_mentions($c_content . ' @' . $t_obj['author'], $cur_uname, $cur_uid);
 if ($mentions && count($mentions) <= 10) {
     foreach ($mentions as $m_name) {
         if (intval($m_name)) {
             $DBM->unbuffered_query("UPDATE `yunbbs_users` SET `notic` =  concat('{$tid},', `notic`) WHERE `id`='{$m_name}'");
             $MMC->delete('u_' . $m_name);
         } else {
             if (strlen($m_name) > 3) {
                 $DBM->unbuffered_query("UPDATE `yunbbs_users` SET `notic` =  concat('{$tid},', `notic`) WHERE `name`='{$m_name}'");
             }
         }
     }
 }
 // send to weibo
 if ($send2wb && $cur_user['expires'] > $timestamp) {
     $queue = new SaeTaskQueue('default');
     $queue->addTask("http://" . $_SERVER['HTTP_HOST'] . "/task/sendmsg/reply/" . $cur_uid . "/" . $new_rid);
     $queue->push();
 }
 // 保存内容md5值
 $MMC->set('cm_' . $conmd5, '1', 0, 3600);
 // 跳到评论最后一页
 if ($page < $new_taltol_page) {
     $c_content = '';
     header('location: /t/' . $tid . '/' . $new_taltol_page);
     exit;
 } else {
     $cur_ucode = $new_ucode;
     $formhash = formhash();
 }
 // 若不转向
Ejemplo n.º 11
0
Archivo: Ysu.php Proyecto: yang22t/ysu
 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);
     }
 }
Ejemplo n.º 12
0
                 } else {
                     if (strlen($m_name) > 3) {
                         $DBM->unbuffered_query("UPDATE `yunbbs_users` SET `notic` =  concat('{$new_aid},', `notic`) WHERE `name`='{$m_name}'");
                     }
                 }
             }
         }
         // send to weibo
         if ($send2wb && $cur_user['expires'] > $timestamp) {
             $queue = new SaeTaskQueue('default');
             $queue->addTask("http://" . $_SERVER['HTTP_HOST'] . "/task/sendmsg/topic/" . $cur_uid . "/" . $new_aid);
             $queue->push();
         }
         // set tags
         if (!isset($queue)) {
             $queue = new SaeTaskQueue('default');
         }
         $queue->addTask("http://" . $_SERVER['HTTP_HOST'] . "/task/fenci/" . $new_aid);
         $queue->push();
         // auto ping google & baidu
         $queue->addTask("http://" . $_SERVER['HTTP_HOST'] . "/task/atping/" . $new_aid);
         $queue->push();
         // 保存内容md5值
         $MMC->set('cm_' . $conmd5, '1', 0, 3600);
         $p_title = $p_content = '';
         header('location: /t/' . $new_aid);
         exit;
     }
 } else {
     $tip = '标题' . mb_strlen($p_title, 'utf-8') . ' 或 内容' . mb_strlen($p_content, 'utf-8') . ' 太长了';
 }
Ejemplo n.º 13
0
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';
    }
}