function SyncReply() { $sina = jconf::get('sina'); if (!$sina['is_syncreply_tojishigou']) { return; } $tid = max(0, (int) ($this->Post['tid'] ? $this->Post['tid'] : $this->Get['tid'])); if (!$tid) { return; } $info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `tid`='{$tid}'"); if (!$info) { return; } $mid = $info['mid']; if (!$mid) { return; } if ($sina['syncweibo_tojishigou_time'] > 0 && $info['last_read_time'] + $sina['syncweibo_tojishigou_time'] > time()) { return; } if (!($topic_info = DB::fetch_first("select * from " . TABLE_PREFIX . "topic where `tid`='{$tid}'"))) { return; } $xwb_bind_info = sina_weibo_bind_info($topic_info['uid']); if (!$xwb_bind_info) { return; } if (!sina_weibo_bind($topic_info['uid'])) { return; } if (!sina_weibo_syncreply_tojishigou($topic_info['uid'])) { return; } if (!$this->MemberHandler->HasPermission('xwb', '__syncreply', 0, $topic_info['uid'])) { return; } if ($this->module_config['oauth2_enable']) { $p = array('id' => $mid, 'access_token' => $xwb_bind_info['access_token']); $rets = sina_weibo_api('2/comments/show', $p, 'GET'); $datas = $rets['comments']; } else { require_once ROOT_PATH . 'include/ext/xwb/sina.php'; $wb = XWB_plugin::getWB(); $datas = $wb->getComments($mid); } if ($datas) { krsort($datas); $TopicLogic = jlogic('topic'); foreach ($datas as $data) { $mid = $data['idstr'] ? $data['idstr'] : ($data['mid'] ? $data['mid'] : $data['id']); $sina_uid = $data['user']['id']; if ($mid && ($bind_info = DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_info where `sina_uid`='{$sina_uid}'")) && !DB::fetch_first("select * from " . TABLE_PREFIX . "xwb_bind_topic where `mid`='{$mid}'") && ($content = trim(strip_tags(array_iconv('utf-8', $this->Config['charset'], $data['text'] . (isset($data['retweeted_status']) ? " /" . "/@{$data['retweeted_status']['user']['name']}: {$data['retweeted_status']['text']}" : "")))))) { DB::query("insert into " . TABLE_PREFIX . "xwb_bind_topic (`mid`) values ('{$mid}')"); $_t = time(); if ($data['created_at']) { $_t = strtotime($data['created_at']); } $_t = is_numeric($_t) ? $_t : 0; $add_datas = array('totid' => $tid, 'content' => $content, 'from' => 'sina', 'type' => 'reply', 'uid' => $bind_info['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) { if ($sina['is_syncimage_tojishigou'] && $data['original_pic']) { $TopicLogic->_parse_url_image($add_result, $data['original_pic']); } DB::query("replace into " . DB::table('xwb_bind_topic') . " (`tid`, `mid`) values ('{$_tid}', '{$mid}')"); } } } } } DB::query("update `" . TABLE_PREFIX . "xwb_bind_topic` set `last_read_time`='" . time() . "' where `tid`='{$tid}'"); }
function sina_weibo_bind_icon($uid = 0) { $return = ''; $uid = max(0, (int) ($uid ? $uid : MEMBER_ID)); if ($uid > 0 && ($sys_config = sina_weibo_enable())) { $return = "<img src='{$sys_config['site_url']}/images/xwb/bgimg/sinawebo_off.gif' alt='未绑定新浪微博' />"; if (sina_weibo_bind($uid, !rand(0, 10))) { $return = "<img src='{$sys_config['site_url']}/images/xwb/bgimg/sinawebo_on.gif' alt='已经绑定新浪微博' />"; if ($sys_config['sina']['is_synctopic_tojishigou'] && sina_weibo_synctopic_tojishigou($uid)) { $_read_now = true; if ($sys_config['sina']['syncweibo_tojishigou_time'] > 0) { $xwb_bind_info = sina_weibo_bind_info($uid); if ($xwb_bind_info['last_read_time'] + $sys_config['sina']['syncweibo_tojishigou_time'] > time()) { $_read_now = false; } } if ($_read_now && !jaccess('xwb', '__synctopic', $uid)) { $_read_now = false; } if ($_read_now) { $return .= "<img src='{$sys_config['site_url']}/index.php?mod=xwb&code=synctopic&uid={$uid}' width='0' height='0' style='display:none' />"; } } if ($sys_config['sina']['is_syncreply_tojishigou'] && is_numeric($_GET['code']) && sina_weibo_syncreply_tojishigou($uid) && ($xwb_bind_topic = sina_weibo_bind_topic($_GET['code'])) && ($topic_info = DB::fetch_first("select * from " . TABLE_PREFIX . "topic where `tid`='{$_GET['code']}'"))) { $_read_now = true; if ($sys_config['sina']['syncweibo_tojishigou_time'] > 0) { if ($xwb_bind_topic['last_read_time'] + $sys_config['sina']['syncweibo_tojishigou_time'] > time()) { $_read_now = false; } } if ($_read_now && !jaccess('xwb', '__syncreply', $topic_info['uid'])) { $_read_now = false; } if ($_read_now) { $return .= "<img src='{$sys_config['site_url']}/index.php?mod=xwb&code=syncreply&tid={$_GET['code']}' 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=sina';return false;\">{$return}</a>"; } } return $return; }