<?php
// +----------------------------------------------------------------------
// | 天方夜谭 [ 世界上最好用的QQ秒赞系统 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2014~2019 http://www.eirds.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 天方夜谭 <17404785@qq.com>
// +----------------------------------------------------------------------

/**
 * 手动测试 互刷访客
 */
require_once('common.php');
$qid=is_numeric(GET('qid'))?GET('qid'):exit('传入参数错误！');
if($info = $TFYT_DB->get_row("select qid,qq,cookie from ".PREFIX."qq where qid='{$qid}' and `visitor`>0 and status=0 limit 1")){
    $list = $TFYT_DB->get_results("select qid,qq,cookie from ".PREFIX."qq where qq!='{$info->qq}' and `visitor`>0 and status=0 order by rand()");
    if (!empty($list)){
        foreach ($list as $value) {
            $qzone = new qzone($value->qq,authcode($value->cookie, 'DECODE', 'qq17404785'));
            $qzone->visitqzone($info->qq);
            if ($qzone->skeyzt){
                $TFYT_DB->query("update ".PREFIX."qq set status='1' where qid='{$value->qid}'");
                foreach ($qzone->msg as $result){
                    echo $result.'<br/>';
                }
            }else{
                if($TFYT_DB->query("update ".PREFIX."qq set `lastvisitor`='{$NOW}' where qid='{$qid}'")){
                    foreach($qzone->msg as $result){
                        echo $result.'<br/>';
                    }
                }else{
                    exit("无法更新数据！");
                }
            }
        }
    }else{
        exit('目前暂无可用QQ！');
    }
}else{
    exit('请检查是否开启了本功能或状态是否失效');
}