function _syn_to_sina($data = array()) { if ($GLOBALS['_J']['config']['sina_enable'] && $data && $data['uid'] > 0 && $data['tid'] > 0 && 'sina' != $data['from'] && sina_weibo_init() && sina_weibo_bind($data['uid'], 1) && !$GLOBALS['imjiqiren_sys_config']['imjiqiren']['sina_update_disable']) { $sina_config = jconf::get('sina'); if ($data['totid'] > 0 && $sina_config['is_syncreply_toweibo'] && sina_weibo_bind_setting($data['uid']) || $data['totid'] < 1 && $sina_config['is_synctopic_toweibo'] && jget('syn_to_sina')) { if (TRUE === IN_JISHIGOU_INDEX || TRUE === IN_JISHIGOU_AJAX || TRUE === IN_JISHIGOU_ADMIN) { $result = jsg_schedule(array('data' => $data), 'syn_to_sina', $data['uid']); } else { include ROOT_PATH . 'include/ext/xwb/to_xwb.inc.php'; } } } }
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_share($tid = '') { $return = ''; if (($sys_config = sina_weibo_enable()) && jconf::get('sina', 'is_rebutton_display')) { $tid = max(0, (int) ($tid ? $tid : $GLOBALS['jsg_tid'])); $uid = max(0, (int) ($uid ? $uid : MEMBER_ID)); $link = "javascript:void((function(s,d,e,r,l,p,t,z,c) {var%20f='http:/" . "/v.t.sina.com.cn/share/share.php?appkey={$sys_config[sina][app_key]}',u=z||d.location,p=['&url=',e(u),'& title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'& content=',c||'gb2312','&pic=',e(p||'')].join('');function%20a() {if(!window.open([f,p].join(''),'mb', ['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width- 440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');}; if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();}) (screen,document,encodeURIComponent,'','','','','',''));"; if ($uid > 0 && $tid > 0) { if (sina_weibo_bind($uid)) { $link = "{$sys_config['site_url']}/index.php?mod=xwb&m=xwbSiteInterface.share&tid={$tid}"; $link = "javascript:void( window.open('" . urlencode($link) . "', '', 'toolbar=0,status=0,resizable=1,width=680,height=500') );"; } } $return = ' | <a title="转发到新浪微博" href="' . $link . '" id="sina_weibo_share"><img src="' . $sys_config['site_url'] . '/images/xwb/bgimg/icon_logo.png" /></a>'; } return $return; }