function xwb_uninstall()
 {
     global $_xwb_install;
     $this->tpl_dir = dirname(__FILE__) . '/tpl';
     $this->v = $_xwb_install;
     $this->_sess = XWB_plugin::getUser();
     $this->_chkIsAdmin();
 }
 /**
  * 获取当前授权的单个登录新浪用户资料(保护方法)
  */
 function _getSinaUserInfo()
 {
     $xwb_user = XWB_plugin::getUser();
     $sina_id = $xwb_user->getInfo('sina_uid');
     if (is_numeric($sina_id) && $sina_id > 0) {
         $wb = XWB_plugin::getWB();
         $wb->is_exit_error = false;
         $this->sina_userinfo = (array) $wb->getUserShow($sina_id);
     }
 }
                </div>
                <?php 
}
?>
                
            </div>
            

            
            
            
            
            
        </div>
        <b class="bg_regBot">&nbsp;</b>
    </div>
</div>
<?php 
$xwb_sess = XWB_plugin::getUser();
$xwb_statInfo = $xwb_sess->getStat();
foreach ($xwb_statInfo as $k => $stat) {
    $xwb_statType = isset($stat['xt']) ? (string) $stat['xt'] : 'unknown';
    echo XWB_plugin::statUrl($xwb_statType, $stat, true);
}
if (!empty($xwb_statInfo)) {
    $xwb_sess->clearStat();
}
?>
</body>
</html>
 /**
  * 当发现用户取消授权后,对其进行解绑操作
  * 属于本插件特殊用途的函数,仅用于方法oAuthRequest中
  */
 function _delBindCheck($errmsg)
 {
     if (XWB_S_UID <= 0) {
         return false;
     }
     if (false === strpos(str_replace(' ', '', strtolower($errmsg)), 'accessorwasrevoked')) {
         return false;
     }
     XWB_plugin::delBindUser(XWB_S_UID);
     //远程API
     $sess = XWB_plugin::getUser();
     $sess->clearToken();
     dsetcookie($this->_getBindCookiesName(XWB_S_UID), -1, 604800);
     return true;
 }
 function bind()
 {
     if (!XWB_plugin::pCfg('is_account_binding')) {
         XWB_plugin::showError('新浪微博绑定功能已经关闭!');
     }
     if (XWB_S_UID > 0 && XWB_plugin::isUserBinded()) {
         $xwb_user = XWB_plugin::getUser();
         $sina_id = $xwb_user->getInfo('sina_uid');
         $wb = XWB_plugin::getWB();
         $wb->is_exit_error = false;
         $sina_user_info = $wb->getUserShow($sina_id);
         if (isset($sina_user_info['error_code']) || isset($sina_user_info['error'])) {
             include XWB_P_ROOT . '/tpl/xwb_cenbind_error.tpl.php';
         } else {
             $db = XWB_plugin::getDB();
             $share = XWB_plugin::V("R:share");
             $share_msg = '';
             if ($share) {
                 $bind_info = $db->fetch_first("select * from " . XWB_S_TBPRE . "xwb_bind_info where `uid`='" . XWB_S_UID . "'");
                 $share_time = $bind_info['share_time'];
                 if (!$share_time) {
                     $share_time = time();
                     $db->query("update " . XWB_S_TBPRE . "xwb_bind_info set `share_time`='" . $share_time . "' where `uid`='" . XWB_S_UID . "'");
                     jclass('misc')->update_account_bind_info(XWB_S_UID, '', '', 1);
                     $share_msg = "<img src='" . (XWB_plugin::baseUrl() . XWB_plugin::URL('&code=enter&share_time=' . $share_time)) . "' width='0' height='0' />";
                 }
             } else {
                 /**
                  * 分享给好友显示页面
                  */
                 $skip_share = XWB_plugin::V("R:skip_share");
                 if (!$skip_share) {
                     $bind_info = $db->fetch_first("select * from " . XWB_S_TBPRE . "xwb_bind_info where `uid`='" . XWB_S_UID . "'");
                     if (!$bind_info['share_time']) {
                         include XWB_P_ROOT . '/tpl/xwb_cenbind_share.tpl.php';
                         exit;
                     }
                 }
             }
             $screen_name = $sina_user_info['screen_name'];
             $profile = XWB_plugin::O('xwbUserProfile');
             $setting = $profile->get('bind_setting', 1);
             $tojishigou = $profile->get('synctopic_tojishigou', 0);
             $reply_tojishigou = $profile->get('syncreply_tojishigou', 0);
             include XWB_P_ROOT . '/tpl/xwb_cenbind_on.tpl.php';
         }
     } else {
         include XWB_P_ROOT . '/tpl/xwb_cenbind_off.tpl.php';
     }
 }
 /**
  * 帖子转发
  */
 function doShare()
 {
     if (!XWB_plugin::pCfg('is_rebutton_display') || !XWB_plugin::isRequestBy('POST')) {
         XWB_plugin::showError('网站管理员关闭了插件功能“新浪微博分享”。请稍后再试。');
     }
     $sess = XWB_plugin::getUser();
     /* 判断是否外部转发 */
     if (1 != $sess->getInfo('forshare')) {
         XWB_plugin::showError('禁止外部转发');
     }
     /* 销毁 SESSION['forshare'] 变量*/
     $sess->delInfo('forshare');
     /* 判断转发时间间隔 */
     $shareTime = intval(XWB_plugin::pCfg('wbx_share_time'));
     if ($shareTime >= time() - intval($sess->getInfo('sharetime'))) {
         XWB_plugin::showError("转发过快,转发间隔为 {$shareTime} 秒");
     }
     /* 获取用户信息 */
     $rst = $this->_getUserInfo();
     if (isset($rst['error_no']) && 0 < $rst['error_no']) {
         $this->_showTip($rst['error']);
     }
     /* 获取传递信息 */
     $message = trim(strval(XWB_plugin::V('p:message')));
     $pic = trim(strval(XWB_plugin::V('p:share_pic')));
     if (empty($message)) {
         $this->_showTip('错误:转发信息不能为空.', $rst);
     }
     /* 转发主题 */
     $xp_publish = XWB_plugin::N('xwb_plugins_publish');
     $ret = $xp_publish->sendShare($message, $pic);
     /* 写入 SESSION 发布时间 */
     $sess->setInfo('sharetime', time());
     /* 错误处理 */
     if ($ret === false || $ret === null) {
         $this->_showTip('错误:系统错误!', $rst);
     }
     if (isset($ret['error_code']) && isset($ret['error'])) {
         $error_code_se = substr($ret['error'], 0, 5);
         if ('400' == $ret['error_code'] && '40025' == $error_code_se) {
             $ret['error'] = '错误:不能发布相同的微博!';
         } else {
             $ret['error'] = '错误:系统错误!';
         }
         $this->_showTip($ret['error'], $rst);
     }
     $this->_showTip('转发成功!', $rst);
 }
 function _getOAuthUrl()
 {
     static $aurl = null;
     if (!empty($aurl)) {
         return $aurl;
     }
     $sess = XWB_plugin::getUser();
     $sess->clearToken();
     $wbApi = XWB_plugin::getWB();
     $keys = $wbApi->getRequestToken();
     if (!isset($keys['oauth_token']) || !isset($keys['oauth_token_secret'])) {
         $api_error_origin = isset($keys['error']) ? $keys['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
         $api_error = isset($keys['error_CN']) && !empty($keys['error_CN']) && 'null' != $keys['error_CN'] ? $keys['error_CN'] : '';
         XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$wbApi->req_error_count}\t{$api_error}\t{$wbApi->last_req_url}\tERROR ARRAY:\r\n" . print_r($keys, 1));
         XWB_plugin::showError("服务器获取Request Token失败;请稍候再试。<br />错误原因:{$api_error}[{$api_error_origin}]");
     }
     //print_r($keys);
     $aurl = $wbApi->getAuthorizeURL($keys['oauth_token'], false, XWB_plugin::getEntryURL('xwbAuth.authCallBack'));
     $sess->setOAuthKey($keys, false);
     return rtrim($aurl, '&');
 }
 /**
  * 分享同步
  * @param integer $sid
  * @param array $arr
  */
 function shareSync($sid, $arr)
 {
     global $_G;
     $type = $title = $pic = '';
     if (isset($arr['image']) && !empty($arr['image']) && XWB_plugin::pCfg('is_upload_image')) {
         $pic = str_replace('.thumb.jpg', '', $arr['image']);
     }
     switch (strtolower($arr['type'])) {
         case 'space':
             $type = 'username';
             break;
         case 'blog':
             $type = 'subject';
             break;
         case 'album':
             $type = 'albumname';
             break;
         case 'pic':
             $type = 'albumname';
             break;
         case 'thread':
             $type = 'subject';
             break;
         case 'article':
             $type = 'title';
             break;
         case 'link':
         case 'video':
         case 'music':
         case 'flash':
             $type = 'link';
             break;
         default:
             break;
     }
     $arr['body_data'] = unserialize($arr['body_data']);
     if (empty($type)) {
         return false;
     } elseif ('link' != $type) {
         $pattern = '/^<a[ ]+href[ ]*=[ ]*"([a-zA-Z0-9\\/\\\\@:%_+.~#*?&=\\-]+)"[ ]*>(.+)<\\/a>$/';
         preg_match($pattern, $arr['body_data'][$type], $match);
         if (3 !== count($match)) {
             return false;
         }
         $link = $_G['siteurl'] . $match[1];
         if (1 == XWB_plugin::pcfg('link_visit_promotion')) {
             $link .= '&fromuid=' . $_G['uid'];
         }
         $title = 'pic' == $type ? $arr['body_data']['title'] : $match[2];
     } else {
         $link = $arr['body_data']['data'];
     }
     $message = !empty($arr['body_general']) ? (string) $arr['body_general'] : (string) $arr['title_template'];
     if (!empty($title)) {
         $message = $this->_convert($message . ' | ' . $title);
     } else {
         $message = $this->_convert($message);
     }
     $link = ' ' . $link;
     $length = 140 - ceil(strlen(urlencode($link)) * 0.5);
     $message = $this->_substr($message, $length);
     $message .= $link;
     $wb = XWB_plugin::getWB();
     // 同步到微博
     if (!empty($pic)) {
         $ret = $wb->upload($message, $pic, null, null, false);
         if (isset($ret['error_code']) && 400 == (int) $ret['error_code']) {
             $ret = $wb->update($message, false);
         }
     } else {
         $ret = $wb->update($message, false);
     }
     //同步微博后的ID
     if (!empty($ret['id'])) {
         //@todo json_decode可能存在解析超过int最大数的错误(#47644)问题
         $mid = $ret['id'];
         $this->insertSyncId($sid, $ret['id'], 'share');
         //日志同步统计上报
         $sess = XWB_plugin::getUser();
         $sess->appendStat('ryz', array('uid' => XWB_plugin::getBindInfo("sina_uid"), 'mid' => $mid, 'type' => 4));
     }
 }