예제 #1
0
 function request($route, $params, $toArray = TRUE)
 {
     $AppKey = XWB_APP_KEY;
     $EncryptKey = XWB_plugin::pCfg('encrypt_key');
     $paramsJSON = json_encode($params);
     $EncryptTime = time();
     $secret = md5(sprintf("#%s#%s#%s#%s#%s#", $AppKey, $route, $paramsJSON, $EncryptTime, $EncryptKey));
     $data = array('A=' . $route, 'P=' . $paramsJSON, 'T=' . $EncryptTime, 'F=' . $secret);
     $url = $this->url;
     $this->http->setUrl($url);
     $this->http->setData(implode('&', $data));
     $time_start = microtime();
     $result = $this->http->request('post');
     $time_end = microtime();
     $time_process = array_sum(explode(' ', $time_end)) - array_sum(explode(' ', $time_start));
     if ($toArray) {
         $result = xwb_util_json::decode($result, true);
     }
     $code = $this->http->getState();
     $this->logRespond(rtrim($this->url, '/') . '/' . $route, 'post', (int) $code, $result, array('param' => $params, 'time_process' => $time_process, 'triggered_error' => $this->http->get_triggered_error()));
     if (200 != $code) {
         $result = array("rst" => false, "errno" => "50001", "err" => "network error");
         $this->setError($result);
     }
     return $result;
 }
 /**
  * 构造函数
  */
 function sitePushback2share()
 {
     $this->_userConfig['ip'] = DB::mysqli_escape(XWB_plugin::getIP());
     $this->_userConfig['uid'] = (int) XWB_plugin::pCfg('pushback_uid');
     $this->_userConfig['username'] = DB::mysqli_escape(XWB_plugin::convertEncoding((string) XWB_plugin::pCfg('pushback_username'), 'UTF-8', XWB_S_CHARSET));
     $this->_userConfig['timestamp'] = (int) TIMESTAMP;
     //DZ已有的变量,直接使用之
     if ($this->_userConfig['uid'] < 1) {
         $this->_userConfig['uid'] = 0;
         $this->_userConfig['username'] = '******';
     }
 }
예제 #3
0
 function _validate($A, $P, $T, $F)
 {
     /// 超时检测
     if (XWB_REMOTE_API_TIME_VALIDATY < time() - $T) {
         $this->_ERHelper('4010004');
     }
     $secret = md5(sprintf("#%s#%s#%s#%s#%s#", XWB_APP_KEY, $A, $P, $T, XWB_plugin::pCfg('encrypt_key')));
     if (0 !== strcasecmp($F, $secret)) {
         $this->_ERHelper('4010003', TRUE, 'load');
     }
     return;
 }
 /**
  * 关闭远程API
  */
 function closeApi()
 {
     $stx = XWB_plugin::pCfg('switch_to_xweibo');
     if (XWB_plugin::setPCfg(array('switch_to_xweibo' => 0))) {
         $api = XWB_plugin::N('apixwb');
         $response = $api->setNotice(0, '', FALSE);
         //            if( !is_array($response) || 0 != $response['errno']) {
         //                XWB_plugin::setPCfg(array('switch_to_xweibo' => $stx));
         //            }
         exit(json_encode($response));
     } else {
         exit(json_encode(array('errno' => 1, 'err' => '配置文件无法写入')));
     }
 }
 /**
  * 关闭远程API
  */
 function closeApi()
 {
     if (!xwb_token::checkInput('p', $this->tokehash, true)) {
         exit(json_encode(array('errno' => 1, 'err' => '令牌验证失败,请返回重试')));
     }
     $stx = XWB_plugin::pCfg('switch_to_xweibo');
     if (XWB_plugin::setPCfg(array('switch_to_xweibo' => 0))) {
         $api = XWB_plugin::N('apixwb');
         $response = $api->setNotice(0, '', FALSE);
         //            if( !is_array($response) || 0 != $response['errno']) {
         //                XWB_plugin::setPCfg(array('switch_to_xweibo' => $stx));
         //            }
         exit(json_encode($response));
     } else {
         exit(json_encode(array('errno' => 1, 'err' => '配置文件无法写入')));
     }
 }
/**
 * 新浪微博签名替换函数
 * @version $Id: xwb_format_signature.function.php 1004 2012-06-11 10:32:46Z yaoying $
 * @param string $s
 */
function xwb_format_signature($s)
{
    static $xweibourl = null;
    if (null == $xweibourl) {
        $xweibourl = rtrim(strval(XWB_plugin::pCfg('baseurl_to_xweibo')), '/');
    }
    if (XWB_plugin::pCfg('switch_to_xweibo') && !empty($xweibourl)) {
        $xweibourl_ta = $xweibourl . '/index.php?m=ta&id=';
    } else {
        $xweibourl_ta = 'http://weibo.com/u/';
    }
    $p = "#&lt;-sina_sign,(\\d+),([a-z0-9]+),(\\d+)-&gt;#sim";
    $rp = '<a href="' . $xweibourl_ta . '\\1" target="_blank"><img border="0" src="http://service.t.sina.com.cn/widget/qmd/\\1/\\2/\\3.png"/></a>';
    //$p = XWB_plugin::convertEncoding($p,'UTF8', XWB_S_CHARSET);
    //$rp= XWB_plugin::convertEncoding($rp,'UTF8', XWB_S_CHARSET);
    if (!empty($s) && preg_match($p, $s, $m)) {
        return preg_replace($p, $rp, $s);
    }
    return $s;
}
 /**
  * 获取未读取数目
  * 只有开启了标准版对接功能之后,才有此功能
  */
 function setUnreadCookie()
 {
     $result = array('errno' => 0, 'uid' => XWB_S_UID, 'followers' => 0, 'dm' => 0, 'mentions' => 0, 'comments' => 0, 'allsum' => 0);
     if (!$this->_checkNextUnreadTime()) {
         $result['errno'] = -1;
     } elseif (!XWB_plugin::pCfg('switch_to_xweibo')) {
         $this->_setNextUnreadCheckTime();
         $result['errno'] = -3;
     } elseif (!XWB_S_UID || !XWB_Plugin::isUserBinded()) {
         $this->_setNextUnreadCheckTime();
         $result['errno'] = -2;
     } else {
         $wb = XWB_plugin::getWB();
         $wb->is_exit_error = false;
         $respond = $wb->getUnread();
         if (!is_array($respond) || isset($respond['error'])) {
             $result['errno'] = isset($respond['error']) ? (int) $respond['error'] : -3;
         } else {
             $result = array_merge($result, $respond);
             $this->_setUnreadCookie($result);
         }
         $this->_setNextUnreadCheckTime();
     }
     if ($result['errno'] != 0) {
         header("HTTP/1.1 403 Forbidden");
     }
     echo 'var _xwb_unread_new = ' . json_encode($result) . ';';
     exit;
 }
예제 #8
0
/**
 * 加载新浪微博的底部信息
 */
function jsg_sina_footer()
{
    $tipsType = $GLOBALS['xwb_tips_type'];
    $site_uid = XWB_S_UID;
    $sina_uid = XWB_plugin::getBindInfo("sina_uid");
    $siteVer = XWB_S_VERSION;
    $siteName = str_replace("'", "\\'", $GLOBALS['_J']['config']['site_name']);
    $pName = CURSCRIPT . '_' . CURMODULE;
    $regUrl = XWB_plugin::URL("xwbSiteInterface.reg");
    $setUrl = XWB_plugin::URL("xwbSiteInterface.bind");
    $bindUrl = XWB_plugin::URL("xwbSiteInterface.bind");
    $signerUrl = XWB_plugin::URL("xwbSiteInterface.signer");
    $authUrl = XWB_plugin::URL("xwbAuth.login");
    $getTipsUrl = XWB_plugin::URL("xwbSiteInterface.getTips");
    $attentionUrl = XWB_plugin::URL("xwbSiteInterface.attention");
    $wbxUrl = XWB_plugin::pCfg("wbx_url");
    $xwb_loadScript1 = $GLOBALS['_J']['site_url'] . '/images/xwb/dlg.js';
    $xwb_loadScript2 = $GLOBALS['_J']['site_url'] . '/images/xwb/xwb.js';
    $xwb_css_base = $GLOBALS['_J']['site_url'] . '/images/xwb/xwb_base.css';
    $xwb_css_append = $GLOBALS['_J']['site_url'] . ('/images/xwb/xwb_' . XWB_S_VERSION . '.css');
    $return = <<<EOF
<script language="javascript">
var _xwb_cfg_data ={
\ttipsType:\t'{$tipsType}',site_uid:\t'{$site_uid}',sina_uid:\t'{$sina_uid}',
\tsiteVer:\t'{$siteVer}',siteName:\t'{$siteName}',pName:'{$pName}',
\tregUrl:\t\t'{$regUrl}',
\tsetUrl:\t\t'{$setUrl}',
\tbindUrl:\t'{$bindUrl}',
\tsignerUrl:\t'{$signerUrl}',
\tauthUrl:\t'{$authUrl}',
\tgetTipsUrl:\t'{$getTipsUrl}',
\tattentionUrl:\t'{$attentionUrl}',
\twbxUrl:\t\t'{$wbxUrl}'
};

function xwb_loadScript(file, charset){
\tvar script = document.createElement('SCRIPT');
\tscript.type = 'text/javascript'; script.charset = charset; script.src = file;
\tdocument.getElementsByTagName('HEAD')[0].appendChild(script);
}
xwb_loadScript("{$xwb_loadScript1}", "UTF-8");
xwb_loadScript("{$xwb_loadScript2}", "UTF-8");
</script>
<link href="{$xwb_css_base}" rel="stylesheet" type="text/css" />
<link href="{$xwb_css_append}" rel="stylesheet" type="text/css" />

EOF;
    /*
    $sess = XWB_plugin::getUser();
    $xwb_statInfo = $sess->getStat();
    foreach( $xwb_statInfo as $k => $stat ){
    	$xwb_statType = isset($stat['xt']) ? (string)$stat['xt'] : 'unknown';
    	$return .= XWB_plugin::statUrl( $xwb_statType, $stat, true );
    }
    
    if( !empty($xwb_statInfo) ){
    	$sess->clearStat();
    }
    */
    return $return;
}
예제 #9
0
 checked="checked" <?php 
    }
    ?>
 />是</label> &nbsp; <label for="tojishigou_0"><input name="tojishigou" id="tojishigou_0" type="radio" value="0" <?php 
    if ($tojishigou == 0) {
        ?>
 checked="checked" <?php 
    }
    ?>
 />否</label></div>
        </div>
        <?php 
}
?>
        <?php 
if (XWB_plugin::pCfg('is_syncreply_tojishigou') && jaccess('xwb', '__syncreply')) {
    ?>
        <h3>读取新浪微博的评论内容到本站?</h3>
        <div class="radio-box">
        <div class="radio"><label for="reply_tojishigou_1"><input name="reply_tojishigou" id="reply_tojishigou_1" type="radio" value="1" <?php 
    if ($reply_tojishigou == 1) {
        ?>
 checked="checked" <?php 
    }
    ?>
 />是</label> &nbsp; <label for="reply_tojishigou_0"><input name="reply_tojishigou" id="reply_tojishigou_0" type="radio" value="0" <?php 
    if ($reply_tojishigou == 0) {
        ?>
 checked="checked" <?php 
    }
    ?>
예제 #10
0
 function authCallBack()
 {
     if (!XWB_plugin::pCfg('is_account_binding')) {
         XWB_plugin::showError('网站管理员关闭了插件功能“新浪微博绑定”。请稍后再试。');
     }
     //--------------------------------------------------------------------
     global $_G;
     $sess = XWB_plugin::getUser();
     $waiting_site_bind = $sess->getInfo('waiting_site_bind');
     if (empty($waiting_site_bind)) {
         //XWB_plugin::deny();
         $siteUrl = XWB_plugin::siteUrl(0);
         XWB_plugin::redirect($siteUrl, 3);
     }
     $sess->setOAuthKey(array(), true);
     //--------------------------------------------------------------------
     $wbApi = XWB_plugin::getWB();
     $db = XWB_plugin::getDB();
     $last_key = $wbApi->getAccessToken(XWB_plugin::V('r:oauth_verifier'));
     //print_r($last_key);
     if (!isset($last_key['oauth_token']) || !isset($last_key['oauth_token_secret'])) {
         $api_error_origin = isset($last_key['error']) ? $last_key['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
         $api_error = isset($last_key['error_CN']) && !empty($last_key['error_CN']) && 'null' != $last_key['error_CN'] ? $last_key['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($last_key, 1));
         XWB_plugin::showError("服务器获取Access Token失败;请稍候再试。<br />错误原因:{$api_error}[{$api_error_origin}]");
     }
     $sess->setOAuthKey($last_key, true);
     $wbApi->setConfig();
     $uInfo = $wbApi->verifyCredentials();
     $sess->setInfo('sina_uid', $uInfo['id']);
     $sess->setInfo('sina_name', $uInfo['screen_name']);
     //print_r($uInfo);
     //--------------------------------------------------------------------
     /// 此帐号是否已经在当前站点中绑定
     $sinaHasBinded = false;
     $stat_is_bind_type = 0;
     if (defined('XWB_S_UID') && XWB_S_UID > 0) {
         $bInfo = XWB_plugin::getBUById(XWB_S_UID, $uInfo['id']);
     } else {
         $bInfo = XWB_plugin::getBindUser($uInfo['id'], 'sina_uid');
         //远程API
     }
     if (!is_array($bInfo) && (defined('XWB_S_UID') && XWB_S_UID > 0)) {
         $bInfo = XWB_plugin::getBindUser(XWB_S_UID, 'site_uid');
         //登录状态下再查一次API,确保没有绑定
     }
     if (!empty($bInfo) && is_array($bInfo)) {
         $sinaHasBinded = true;
         dsetcookie($this->_getBindCookiesName($bInfo['uid']), (string) $bInfo['sina_uid'], 604800);
         //核查存储的access token是否有更新,有更新则进行自动更新
         if ($bInfo['sina_uid'] == $uInfo['id'] && ($bInfo['token'] != $last_key['oauth_token'] || $bInfo['tsecret'] != $last_key['oauth_token_secret'])) {
             XWB_plugin::updateBindUser($bInfo['uid'], $bInfo['sina_uid'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
             //远程API
         }
     }
     //--------------------------------------------------------------------
     /// 决定在首页中显示什么浮层
     $tipsType = '';
     //xwb_tips_type
     //已在论坛登录
     if (defined('XWB_S_UID') && XWB_S_UID) {
         if ($sinaHasBinded) {
             //$sinaHasBinded为true时,$bInfo必定存在
             if (XWB_S_UID != $bInfo['uid'] || $bInfo['sina_uid'] != $uInfo['id']) {
                 $tipsType = 'hasBinded';
                 $sess->clearToken();
             } else {
                 $tipsType = 'autoLogin';
             }
         } else {
             //远程API
             $rst = XWB_plugin::addBindUser(XWB_S_UID, $uInfo['id'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
             if (!$rst) {
                 echo "DB ERROR";
                 exit;
                 return false;
             }
             $tipsType = 'bind';
             dsetcookie($this->_getBindCookiesName(XWB_S_UID), (string) $uInfo['id'], 604800);
             //正向绑定统计上报
             $sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
         }
     } else {
         //从 wb 登录后 检查用户是否绑定,如果绑定了 则在附属站点自
         if ($sinaHasBinded) {
             require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
             $result = xwb_setSiteUserLogin((int) $bInfo['uid']);
             if (false == $result) {
                 dsetcookie($this->_getBindCookiesName($bInfo['uid']), -1, 604800);
                 XWB_plugin::delBindUser($bInfo['uid']);
                 //远程API
                 $tipsType = 'siteuserNotExist';
             } else {
                 $stat_is_bind_type = 1;
                 $tipsType = 'autoLogin';
             }
         } else {
             //已登录WB,没有附属站点的帐号 引导注册
             $sess->setInfo('waiting_site_reg', '1');
             $tipsType = 'reg';
         }
     }
     //--------------------------------------------------------------------
     //bind的页面需要跳转,故需要使用cookies记录
     if ($tipsType == 'bind') {
         dsetcookie('xwb_tips_type', $tipsType, 0);
     }
     //$sess->setInfo('xwb_tips_type', $tipsType);
     $sess->setInfo('waiting_site_bind', 0);
     //使用sina微博帐号登录成功(不管是否绑定)统计上报
     $sess->appendStat('login', array('uid' => $uInfo['id'], 'is_bind' => $stat_is_bind_type));
     //所有跟站点相关的对接,必须放到_showBinging
     $this->_showBinging($tipsType);
 }
 /**
  * 分享同步
  * @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));
     }
 }
 function checkApi()
 {
     $this->rst = array('ver' => XWB_P_VERSION, 'chatset' => XWB_S_CHARSET, 'pro' => XWB_P_PROJECT, 'switch' => XWB_plugin::pCfg('switch_to_xweibo'));
     $this->_LogHelper($this->apiRoute . '/checkApi');
     return array('rst' => $this->rst, 'errno' => $this->errno, 'err' => $this->err);
 }
 /**
  * 获取新浪微博或者xweibo的个人主页link
  * @param bigint $sina_uid
  * @return string
  */
 function getWeiboProfileLink($sina_uid = 0)
 {
     $xweibourl = rtrim(XWB_plugin::pCfg('baseurl_to_xweibo'), '/');
     if (XWB_plugin::pCfg('switch_to_xweibo') && !empty($xweibourl)) {
         $xweibourl_ta = $xweibourl . '/index.php?m=ta&id=' . $sina_uid;
     } else {
         $xweibourl_ta = 'http://weibo.com/' . $sina_uid;
     }
     return $xweibourl_ta;
 }
 /**
  * 获取转发主题信息 For DiscuzX1.5
  * @param $tid int 论坛thread id
  * @return array
  */
 function forShare($tid)
 {
     /* 主题URL */
     $baseurl = XWB_plugin::siteUrl();
     $topic_url = $baseurl . 'index.php?mod=topic&code=' . $tid;
     if (function_exists('get_full_url')) {
         $topic_url = get_full_url($baseurl, 'index.php?mod=topic&code=' . $tid);
     }
     $url = ' ' . $topic_url;
     /* 获取微博信息 */
     $db = XWB_plugin::getDB();
     $topic = $db->fetch_first("SELECT `tid`,`content`,`imageid` FROM " . XWB_S_TBPRE . "topic WHERE tid='{$tid}'");
     if (empty($topic)) {
         return FALSE;
     }
     /* 转码 */
     $message = $this->_convert(trim($topic['content']));
     /* 过滤UBB与表情 */
     $message = $this->_filter($message);
     $message = strip_tags($message);
     /* 将最后附带的url给删除 */
     $message = preg_replace("|\\s*http:/" . "/[a-z0-9-\\.\\?\\=&_@/%#]*\$|sim", "", $message);
     /* 合并标题和链接 */
     $message = $message . $url;
     // 取出所有图片
     $img_urls = array();
     if ($topic['imageid'] && XWB_plugin::pCfg('is_upload_image')) {
         $image_file = "/images/topic/" . jsg_face_path($topic['imageid']) . $topic['imageid'] . "_o.jpg";
         if (is_file(XWB_S_ROOT . $image_file)) {
             $img_urls[] = $baseurl . $image_file;
         }
     }
     return array('url' => $topic_url, 'message' => $message, 'pics' => array_map('trim', $img_urls));
 }
예제 #15
0
 */
error_reporting(0);
require_once 'plugin.env.php';
require_once XWB_P_ROOT . '/xplugin_apis/apiLoader.php';
XWB_plugin::init();
$apiLoader = new apiLoader();
if (0 === strcasecmp('post', $_SERVER['REQUEST_METHOD'])) {
    $A = dstripslashes($_POST['A']);
    $P = dstripslashes($_POST['P']);
    $T = dstripslashes($_POST['T']);
    $F = dstripslashes($_POST['F']);
    $RT = $apiLoader->load($A, $P, $T, $F);
} else {
    $A = 'apiSystem.checkApi';
    $P = json_encode(dstripslashes(isset($_POST['params']) ? (array) $_POST['params'] : array()));
    $T = time();
    $F = md5(sprintf("#%s#%s#%s#%s#%s#", XWB_APP_KEY, $A, $P, $T, XWB_plugin::pCfg('encrypt_key')));
    $RT = $apiLoader->load($A, $P, $T, $F);
}
exit(json_encode($RT));
function dump($var, $desc = false)
{
    echo '<pre>';
    if ($desc) {
        var_dump($var);
    } else {
        print_r($var);
    }
    echo '</pre>';
    exit;
}
예제 #16
0
 function authCallBack()
 {
     if (!XWB_plugin::pCfg('is_account_binding')) {
         XWB_plugin::showError('新浪微博绑定功能已经关闭!');
     }
     //--------------------------------------------------------------------
     $sess = XWB_plugin::getUser();
     $waiting_site_bind = $sess->getInfo('waiting_site_bind');
     if (empty($waiting_site_bind)) {
         //XWB_plugin::deny();
         $siteUrl = XWB_plugin::siteUrl(0);
         XWB_plugin::redirect($siteUrl, 3);
     }
     //--------------------------------------------------------------------
     $wbApi = XWB_plugin::getWB();
     $db = XWB_plugin::getDB();
     $last_key = $wbApi->getAccessToken(XWB_plugin::V('r:oauth_verifier'));
     $sess->setOAuthKey(array(), true);
     //		print_r($last_key);
     if (!isset($last_key['oauth_token']) || !isset($last_key['oauth_token_secret'])) {
         $api_error_origin = isset($last_key['error']) ? $last_key['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
         $api_error = isset($last_key['error_CN']) && !empty($last_key['error_CN']) && 'null' != $last_key['error_CN'] ? $last_key['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($last_key, 1));
         XWB_plugin::showError("服务器获取Access Token失败;请稍候再试。<br />错误原因:{$api_error}[{$api_error_origin}]");
     }
     $sess->setOAuthKey($last_key, true);
     $wbApi->setConfig();
     $uInfo = $wbApi->verifyCredentials();
     $sess->setInfo('sina_uid', $uInfo['id']);
     $sess->setInfo('sina_name', $uInfo['screen_name']);
     //print_r($uInfo);
     //--------------------------------------------------------------------
     /// 此帐号是否已经在当前站点中绑定
     $sinaHasBinded = false;
     if (defined('XWB_S_UID') && XWB_S_UID > 0) {
         $bInfo = $db->fetch_first("SELECT * FROM " . XWB_S_TBPRE . "xwb_bind_info WHERE sina_uid='" . $uInfo['id'] . "' OR uid='" . XWB_S_UID . "'");
     } else {
         $bInfo = $db->fetch_first("SELECT * FROM " . XWB_S_TBPRE . "xwb_bind_info WHERE sina_uid='" . $uInfo['id'] . "'");
     }
     if (!empty($bInfo) && is_array($bInfo)) {
         $sinaHasBinded = true;
         //核查存储的access token是否有更新,有更新则进行自动更新
         if ($bInfo['token'] != $last_key['oauth_token'] || $bInfo['tsecret'] != $last_key['oauth_token_secret']) {
             $db->query("UPDATE " . XWB_S_TBPRE . "xwb_bind_info SET token='" . (string) $last_key['oauth_token'] . "', tsecret='" . (string) $last_key['oauth_token_secret'] . "' WHERE sina_uid='" . $uInfo['id'] . "'");
         }
     }
     //--------------------------------------------------------------------
     /// 决定在首页中显示什么浮层
     $tipsType = '';
     //xwb_tips_type
     //已在论坛登录
     if (defined('XWB_S_UID') && XWB_S_UID) {
         if ($sinaHasBinded) {
             $tipsType = 'hasBinded';
             $sess->clearToken();
         } else {
             $inData = array();
             $inData['uid'] = XWB_S_UID;
             $inData['sina_uid'] = $uInfo['id'];
             $inData['token'] = $last_key['oauth_token'];
             $inData['tsecret'] = $last_key['oauth_token_secret'];
             $inData['profile'] = '[]';
             $sqlF = array();
             $sqlV = array();
             foreach ($inData as $k => $v) {
                 $sqlF[] = "`" . $k . "`";
                 $sqlV[] = "'" . mysql_real_escape_string($v) . "'";
             }
             $sql = "REPLACE INTO " . XWB_S_TBPRE . "xwb_bind_info  (" . implode(",", $sqlF) . ") VALUES (" . implode(",", $sqlV) . ") ;";
             $rst = $db->query($sql, 'UNBUFFERED');
             jclass('misc')->update_account_bind_info(XWB_S_UID, '', '', 1);
             if (!$rst) {
                 echo "DB ERROR";
                 exit;
                 return false;
             }
             $tipsType = 'bind';
             //正向绑定统计上报
             $sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
         }
     } else {
         //从 wb 登录后 检查用户是否绑定,如果绑定了 则在附属站点自
         if ($sinaHasBinded) {
             require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
             $result = xwb_setSiteUserLogin((int) $bInfo['uid']);
             if (!$result) {
                 $db->query("DELETE FROM " . XWB_S_TBPRE . "xwb_bind_info WHERE sina_uid='" . $uInfo['id'] . "'");
                 $tipsType = 'siteuserNotExist';
             } else {
                 $tipsType = 'autoLogin';
             }
         } else {
             //已登录WB,没有附属站点的帐号 引导注册
             $sess->setInfo('waiting_site_reg', '1');
             $tipsType = 'reg';
         }
     }
     //--------------------------------------------------------------------
     //bind的页面需要跳转,故需要使用cookies记录
     if ($tipsType == 'bind') {
         setcookie('xwb_tips_type', $tipsType, 0);
     }
     //$sess->setInfo('xwb_tips_type', $tipsType);
     $sess->setInfo('waiting_site_bind', 0);
     //使用sina微博帐号登录成功(不管是否绑定)统计上报
     $sess->appendStat('login', array('uid' => $uInfo['id']));
     //所有跟站点相关的对接,必须放到_showBinging
     $this->_showBinging($tipsType);
 }
                            <p>你的xweibo已经和你的论坛(<?php 
    echo str_replace('http://', '', trim($GLOBALS['_G']['siteurl'], '/'));
    ?>
)通信成功。</p>
                            <a onclick="setApi(0);return false;" href="void(0)" class="binding-btn back-on ">
                                <span>关闭通信</span>
                            </a>
                            <?php 
    echo XWB_plugin::pCfg('url_to_xweibo');
    ?>
(关闭通信后,论坛和微博将不再共享用户信息、互相推送内容)
                            <?php 
} else {
    ?>
                            xweibo接口地址:<input type="text" id="url" name="url" value="<?php 
    echo XWB_plugin::pCfg('url_to_xweibo');
    ?>
"/>
                            <a onclick="setApi(1);return false;" href="void(0)" class="binding-btn back-on ">
                                <span>开启通信</span>
                            </a>&nbsp;(示例:http://xweibo地址/api/xplugin.php)
                            <?php 
}
?>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
        <!--修改成功提示-->
        <div class="pop-win win-w fixed-pop hidden" id="popMsg" style="top:55%;">
?>
 />开启转发到微博功能<span>(开启后在主题贴、日志和相册页面会出现转发按钮)</span>
                        </label>
                    </li>
                    <li>
                    	<label for="part5">
                        	<input class="chk" id="part5" name="pluginCfg[is_syncreply_toweibo]" type="checkbox" value="1" <?php 
echo XWB_plugin::pCfg('is_syncreply_toweibo') ? 'checked="checked"' : '';
?>
 />用户在论坛的回复(回帖、日志评论等)作为微博评论回复到新浪微博<span>(在该主题贴、日志等同步到新浪微博,且回帖人绑定新浪微博有效)</span>
                        </label>
                    </li>
                    <li>
                    	<label for="part6">
                        	<input class="chk" id="part6" name="pluginCfg[link_visit_promotion]" type="checkbox" value="1" <?php 
echo XWB_plugin::pCfg('link_visit_promotion') ? 'checked="checked"' : '';
?>
 />把本站推送到微博上的链接纳入推广积分体系<span>(可在论坛后台“全局 » 积分设置 » 积分策略”设置)</span>
                        </label>
                    </li>
                </ul>
            <div class="btn">
            	<input class="conmon-btn" name="submit" type="submit" value="保存设置" />
            </div>
        </div>
        </form>
    </div>
<iframe src="" name="xwbHideFrame" frameborder="0" height="0" width="0"></iframe>
<!--保存设置成功提示-->
<div class="pop-win win-w fixed-pop hidden" id="popMsg">
	<div class="pop-t">
 /**
  * 获取用户名
  * @param $type
  */
 function _getInsertClassName($type)
 {
     if (!in_array($type, array('thread', 'blog', 'share', 'doing'))) {
         return '';
     }
     if (!XWB_plugin::pCfg('pushback_to_' . $type)) {
         return '';
     }
     return 'sitePushback2' . $type;
 }
예제 #20
0
 function setSync()
 {
     $uid = max(0, (int) MEMBER_ID);
     if ($uid < 1) {
         $this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", null);
     }
     $setting = (int) $this->Get['setting'];
     if ('sina' == $this->Get['type']) {
         define('IS_IN_XWB_PLUGIN', true);
         define('XWB_P_ROOT', ROOT_PATH . 'include/ext/xwb/');
         require_once XWB_P_ROOT . 'sina.php';
         require_once XWB_P_ROOT . 'lib/core.class.php';
         if (XWB_S_UID < 1 || !XWB_plugin::pCfg('is_account_binding')) {
             XWB_plugin::showError('新浪微博绑定功能已经关闭!');
         }
         $tojishigou = XWB_plugin::V('G:tojishigou');
         $reply_tojishigou = XWB_plugin::V('G:reply_tojishigou');
         $profile = XWB_plugin::O('xwbUserProfile');
         $profile->set(array('bind_setting' => (int) $setting, 'synctopic_tojishigou' => (int) $tojishigou, 'syncreply_tojishigou' => (int) $reply_tojishigou));
         $r = jclass('misc')->update_account_bind_info(XWB_S_UID, '', '', 1);
     } elseif ('qq' == $this->Get['type']) {
         $this->DatabaseHandler->Query("update " . TABLE_PREFIX . "qqwb_bind_info set `synctoqq`='{$setting}' where `uid`='{$uid}'");
         $r = jclass('misc')->update_account_bind_info($uid, '', '', 1);
     } elseif ('renren' == $this->Get['type'] && !$setting) {
         $r = $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "renren_bind_info where `uid`='{$uid}'");
     } elseif ('kaixin' == $this->Get['type']) {
         $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "kaixin_bind_info where `uid`='{$uid}'");
     }
     json_result('ok', $setting ? 0 : 1);
 }
예제 #21
0
 /**
  * 帖子转发
  */
 function doShare()
 {
     if (!XWB_plugin::pCfg('is_rebutton_display')) {
         XWB_plugin::showError('新浪微博资料页功能已经关闭!');
     }
     /* 判断是否外部转发 */
     if (!isset($_SESSION['forshare']) || TRUE !== $_SESSION['forshare']) {
         XWB_plugin::showError('禁止外部转发');
     }
     /* 销毁 SESSION['forshare'] 变量*/
     unset($_SESSION['forshare']);
     /* 判断转发时间间隔 */
     $shareTime = intval(XWB_plugin::pCfg('wbx_share_time'));
     if ($shareTime >= time() - intval(@$_SESSION['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 发布时间 */
     $_SESSION['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);
 }
    ?>
 />日志同步到微博后,微博评论回到本站
                        </label>
                    </li>
                    <li>
                    	<label for="pushback_to_doing">
                        	<input class="chk" id="pushback_to_doing" name="pushback_to_doing" type="checkbox" value="1" <?php 
    echo XWB_plugin::pCfg('pushback_to_doing') ? 'checked="checked"' : '';
    ?>
 />记录同步到微博后,微博评论回到本站
                        </label>
                    </li>
                    <li>
                    	<label for="pushback_to_share">
                        	<input class="chk" id="pushback_to_share" name="pushback_to_share" type="checkbox" value="1" <?php 
    echo XWB_plugin::pCfg('pushback_to_share') ? 'checked="checked"' : '';
    ?>
 />分享同步到微博后,微博评论回到本站
                        </label>
                    </li>
                    <?php 
}
?>
                </ul>
                <?php 
if (1 == $isOpen) {
    ?>
                <div class="btn">
                    <input class="conmon-btn" name="" type="submit" value="保存设置" />
                </div>
                <?php 
            		<ul>
                    	<li>
                    		<label for="part90">
                        		<input class="chk" id="part90" name="pluginCfg[is_rebutton_relateUid_assoc]" type="checkbox" value="1" <?php 
echo XWB_plugin::pCfg('is_rebutton_relateUid_assoc') ? 'checked="checked"' : '';
?>
 />转发到微博时关联官方帐号<span>(官方账号在转发时会被@,并在转发后提示关注他)</span>
                       	    </label>
                    	</li>
                    	<?php 
if (version_compare(XWB_S_VERSION, '2', '>=')) {
    ?>
                    	<li>
                    		<label for="part91">
                        		<input class="chk" id="part91" name="pluginCfg[display_ow_in_forum_index]" type="checkbox" value="1" <?php 
    echo XWB_plugin::pCfg('display_ow_in_forum_index') ? 'checked="checked"' : '';
    ?>
 />在论坛首页显示官方帐号和关注按钮
                       	    </label>
                    	</li>
                    	<?php 
}
?>
            		</ul>
            		<div class="btn">
            			<input class="conmon-btn" name="submit" type="submit" value="保存设置" />
            		</div>
            	</form>
            	<iframe src="" name="xwbHideFrame" frameborder="0" height="0" width="0"></iframe>
            </div>
            
 /**
  * 获取插件一个或者多个设置
  * 用于在插件框架没有启动时,读取相应的设置值
  * @static
  * @param mixed $key
  * @return mixed
  */
 function pCfg($key = null)
 {
     //插件已经初始化过,就使用插件的方法获取设置值
     if (defined('IS_IN_XWB_PLUGIN')) {
         return XWB_plugin::pCfg($key);
     }
     static $_configImported = false;
     static $_config = null;
     //否则就自己读取插件的设置
     if (false == $_configImported) {
         $configFile = DISCUZ_ROOT . './' . core_sina_xweibo_x2::getXwbRootName() . '/set.data.php';
         if (file_exists($configFile)) {
             require $configFile;
             $_config = (array) $__XWB_SET;
         }
         $_configImported = true;
     }
     if (null !== $key) {
         return isset($_config[$key]) ? $_config[$key] : null;
     } else {
         return $_config;
     }
 }
<?php

/*
 * @version $Id: viewthread.hack.php 673 2011-05-03 02:06:05Z yaoying $
 */
if (!defined('IS_IN_XWB_PLUGIN')) {
    exit('Access Denied!');
}
global $_G;
$uids = array();
$sina_uid = array();
foreach ($GLOBALS['postlist'] as $key => $row) {
    $uids[] = (int) $row['authorid'];
    //签名替换
    $GLOBALS['postlist'][$key]['signature'] = isset($row['signature']) ? XWB_plugin::F('xwb_format_signature', $row['signature']) : '';
    if ($row['first'] && XWB_plugin::pCfg('is_rebutton_display')) {
        $this->viewthread_subject = $row['subject'];
    }
}
$sina_uid = XWB_plugin::F('sinaUidFilter', $uids, false);
?>
" />
                	<label>秒</label>
            	</div>
            	<div class="set-s3-one reset-mar">
            		<p>微博转发间隔:</p>
                	<input class="input-box box-w1" name="pluginCfg[wbx_share_time]" type="text" value="<?php 
echo intval(XWB_plugin::pCfg('wbx_share_time'));
?>
" />
                	<label>秒</label>
            	</div>
            	<div class="set-s3-one reset-mar">
            		<p>绑定页活跃用户数据更新间隔:</p>
                	<input class="input-box box-w1" name="pluginCfg[wbx_huwb_update_time]" type="text" value="<?php 
echo intval(XWB_plugin::pCfg('wbx_huwb_update_time'));
?>
" />
                	<label>小时</label>
            	</div>
            </div>
        </div>
        <div class="btn">
            <input class="conmon-btn" name="submit" type="submit" value="保存设置" />
        </div>
        </form>
    </div>

<!--保存设置成功提示-->
<div class="pop-win win-w fixed-pop hidden" id="popMsg">
	<div class="pop-t">