Exemple #1
0
 function sync_weibo()
 {
     $qqwb = jconf::get('qqwb');
     if (!$qqwb['is_synctopic_tojishigou']) {
         return;
     }
     $info = array();
     $uid = jget('uid', 'int');
     if ($uid < 1) {
         $uid = MEMBER_ID;
     }
     if ($uid < 1) {
         return;
     }
     $info = qqwb_bind_info($uid);
     if (!$info) {
         return;
     }
     if (!qqwb_bind($uid)) {
         return;
     }
     $uid = (int) $info['uid'];
     if ($uid < 1) {
         return;
     }
     $qqwb_username = $info['qqwb_username'];
     if (!$qqwb_username) {
         return;
     }
     if (!qqwb_syncweibo_tojishigou($uid)) {
         return;
     }
     if ($qqwb['syncweibo_tojishigou_time'] > 0 && $info['last_read_time'] + $qqwb['syncweibo_tojishigou_time'] > TIMESTAMP) {
         return;
     }
     $member = DB::fetch_first("select * from " . TABLE_PREFIX . "members where `uid`='{$uid}'");
     if (!$member) {
         return;
     }
     require_once ROOT_PATH . 'include/ext/qqwb/qqoauth.php';
     $QQAuth = new QQOAuth($qqwb['app_key'], $qqwb['app_secret'], $info['token'], $info['tsecret']);
     $rs = $QQAuth->statusesUserTimeline($info['qqwb_username']);
     $datas = $rs['data']['info'];
     if ($datas) {
         krsort($datas);
         $TopicLogic = jlogic('topic');
         foreach ($datas as $data) {
             $qqwb_id = $data['idstr'] ? $data['idstr'] : ($data['qqwb_id'] ? $data['qqwb_id'] : $data['id']);
             if ($qqwb_id && !DB::fetch_first("select * from " . TABLE_PREFIX . "qqwb_bind_topic where `qqwb_id`='{$qqwb_id}'") && ($content = trim(strip_tags(array_iconv('utf-8', $this->Config['charset'], $data['origtext'] . (isset($data['source']['origtext']) ? " /" . "/@{$data['source']['name']}: {$data['source']['origtext']}" : "")))))) {
                 DB::query("insert into " . TABLE_PREFIX . "qqwb_bind_topic (`qqwb_id`) values ('{$qqwb_id}')");
                 $_t = $data['timestamp'] ? $data['timestamp'] : TIMESTAMP;
                 $add_datas = array('content' => $content, 'from' => 'qqwb', 'type' => 'first', 'uid' => $uid, 'timestamp' => $_t);
                 $add_result = $TopicLogic->Add($add_datas);
                 if (is_array($add_result) && count($add_result)) {
                     $tid = max(0, (int) $add_result['tid']);
                     if ($tid > 0) {
                         DB::query("replace into " . DB::table('qqwb_bind_topic') . " (`tid`, `qqwb_id`) values ('{$tid}', '{$qqwb_id}')");
                         if ($qqwb['is_syncimage_tojishigou'] && $data['image']) {
                             $TopicLogic->_parse_url_image($add_result, $this->_img($data['image']));
                         }
                         if ($qqwb['is_syncimage_tojishigou'] && $data['source']['image']) {
                             $TopicLogic->_parse_url_image($add_result, $this->_img($data['source']['image']));
                         }
                     }
                 }
             }
         }
     }
     DB::query("update " . TABLE_PREFIX . "qqwb_bind_info set `last_read_time`='" . TIMESTAMP . "',`last_read_id`='{$qqwb_id}' where `qqwb_username`='{$qqwb_username}'");
     $this->_update($uid);
     exit;
 }
Exemple #2
0
function qqwb_bind_icon($uid = 0)
{
    $return = '';
    $uid = max(0, (int) ($uid ? $uid : MEMBER_ID));
    if ($uid > 0 && ($sys_config = qqwb_enable())) {
        $return = "<img src='{$sys_config['site_url']}/images/qqwb/qqwb_off.gif' alt='未绑定腾讯微博' />";
        if (qqwb_bind($uid)) {
            $return = "<img src='{$sys_config['site_url']}/images/qqwb/qqwb_on.gif' alt='已经绑定腾讯微博' />";
            if ($sys_config['qqwb']['is_synctopic_tojishigou'] && qqwb_syncweibo_tojishigou($uid)) {
                $return .= "<img src='{$sys_config['site_url']}/index.php?mod=qqwb&code=sync_weibo&uid={$uid}' width='0' height='0' style='display:none' />";
            }
            if ($sys_config['qqwb']['is_syncreply_tojishigou'] && 'topic' == jget('mod') && is_numeric(jget('code')) && ($tid = jget('code')) > 0 && ($qbt = qqwb_bind_topic($tid)) && $qbt['last_read_time'] + $sys_config['qqwb']['syncweibo_tojishigou_time'] < TIMESTAMP) {
                $return .= "<img src='{$sys_config['site_url']}/index.php?mod=qqwb&code=sync_reply&tid={$tid}' width='0' height='0' style='display:none' />";
            }
        }
        if (MEMBER_ID > 0) {
            $return = "<a href='#' title='腾讯微博绑定设置' onclick=\"window.location.href='{$sys_config['site_url']}/index.php?mod=account&code=qqwb';return false;\">{$return}</a>";
        }
    }
    return $return;
}