/**
  * 设置错误提示
  *
  * @param string $error
  * @return unknown
  */
 function setError($error)
 {
     $errmsg = isset($error['error']) ? strtolower($error['error']) : 'UNDEFINED ERROR';
     if (strpos($errmsg, 'token_')) {
         $msg = XWB_plugin::L('xwb_token_error');
     } elseif (strpos($errmsg, 'user does not exists')) {
         $msg = XWB_plugin::L('xwb_user_not_exists');
     } elseif (strpos($errmsg, 'target weibo does not exist')) {
         $msg = XWB_plugin::L('xwb_target_weibo_not_exist');
     } elseif (strpos($errmsg, 'weibo id is null')) {
         $msg = XWB_plugin::L('xwb_weibo_id_null');
     } elseif (strpos($errmsg, 'system error')) {
         $msg = XWB_plugin::L('xwb_system_error');
     } elseif (strpos($errmsg, 'consumer_key')) {
         $msg = XWB_plugin::L('xwb_app_key_error');
     } elseif (strpos($errmsg, 'ip request')) {
         $msg = XWB_plugin::L('xwb_request_reach_api_maxium');
     } elseif (strpos($errmsg, 'update comment')) {
         $msg = XWB_plugin::L('xwb_comment_reach_api_maxium');
     } elseif (strpos($errmsg, 'update weibo')) {
         $msg = XWB_plugin::L('xwb_update_reach_api_maxium');
     } elseif (strpos($errmsg, 'high level')) {
         $msg = XWB_plugin::L('xwb_access_resource_api_denied');
     } else {
         $msg = XWB_plugin::L('xwb_system_error');
     }
     //DEBUG 日志
     $req_url = $this->last_req_url;
     XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$this->req_error_count}\t{$msg}\t{$req_url}\tERROR ARRAY:\r\n" . print_r($error, 1));
     //DEBUG END
     if (!$this->is_exit_error) {
         return false;
     }
     if ('utf8' != strtolower(XWB_S_CHARSET)) {
         $msg = XWB_plugin::convertEncoding($msg, XWB_S_CHARSET, 'UTF-8');
     }
     XWB_plugin::showError($msg);
 }
 /**
  * 根据发送过来的数据,组装出已经转码的、要插入对应数据库的回帖内容
  *
  * @param array $data API发送过来的数据
  * @return string 要插入的回帖内容(已经转码)
  */
 function _createContent($data)
 {
     //转换为论坛所需要的字符集
     if (empty($data['nick'])) {
         $data['nick'] = '回推';
     }
     $nickname = XWB_plugin::convertEncoding((string) $data['nick'], 'UTF-8', XWB_S_CHARSET);
     $content = XWB_plugin::convertEncoding((string) $data['text'], 'UTF-8', XWB_S_CHARSET);
     //DZ函数
     $content = dhtmlspecialchars($content);
     $content = $this->_replaceSinaUrlToUBB($content);
     $content = $this->_filterContent($content);
     if (empty($content)) {
         return '';
     }
     if (isset($data['pic']) && !empty($data['pic'])) {
         $content .= "\n\n" . '[img]http://ww3.sinaimg.cn/large/' . $data['pic'] . '.jpg[/img]';
     }
     $content = $content . "\n\n" . '[img]' . XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png') . '[/img] ' . '[size=2][color=gray]' . '[url=' . XWB_plugin::getWeiboProfileLink($data['uid']) . ']' . XWB_plugin::L('xwb_reply_from_2', $nickname) . '[/url][/color][/size]';
     return $content;
 }
 /**
  * 根据发送过来的数据,组装出已经转码的、要插入对应数据库的回帖内容
  *
  * @param array $data API发送过来的数据
  * @return string 要插入的回帖内容(已经转码)
  */
 function _createContent($data)
 {
     //转换为论坛所需要的字符集
     if (empty($data['nick'])) {
         $data['nick'] = '回推';
     }
     $nickname = XWB_plugin::convertEncoding((string) $data['nick'], 'UTF-8', XWB_S_CHARSET);
     $content = XWB_plugin::convertEncoding((string) $data['text'], 'UTF-8', XWB_S_CHARSET);
     //DZ函数
     $content = dhtmlspecialchars($content);
     $content = $this->_replaceSinaUrlToHTML($content);
     $content = $this->_filterContent($content);
     if (empty($content)) {
         return '';
     }
     if (isset($data['pic']) && !empty($data['pic'])) {
         $content .= "<br />" . '<img src="chttp://ww3.sinaimg.cn/large/' . $data['pic'] . '.jpg" />';
     }
     $content = '<img src="' . XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png') . '" />' . $nickname . '(<a href="' . XWB_plugin::getWeiboProfileLink($data['uid']) . '" target="_blank">' . XWB_plugin::L('xwb_weibo') . '</a>): ' . $content;
     return $content;
 }
Ejemplo n.º 4
0
 /**
  * 根据在首页中显示的浮层显示对应的操作(内部函数,被authCallback最后调用)
  * 所有跟站点相关的对接,必须放到_showBinging
  * @param string $tipsType 类型
  * @uses showmessage(dz函数)
  */
 function _showBinging($tipsType)
 {
     global $_G;
     $sess = XWB_plugin::getUser();
     $referer = $sess->getInfo('referer');
     if (empty($referer)) {
         $referer = 'index.php';
     }
     //用于启动浮层
     $GLOBALS['xwb_tips_type'] = $tipsType;
     //不完美解决方案
     if (0 != $_G['config']['output']['forceheader'] && 'UTF8' != XWB_S_CHARSET) {
         @header("Content-type: text/html; charset=" . $_G['config']['output']['charset']);
     }
     if ('autoLogin' == $tipsType) {
         $_G['cookie'][$this->_getBindCookiesName((int) $_G['uid'])] = 99999;
         //仅为了不显示绑定按钮
         $_G['username'] = empty($_G['username']) ? 'SinaAPIUser' : $_G['username'];
         if ($_G['setting']['allowsynlogin'] && 0 < $_G['uid']) {
             loaducenter();
             $ucsynlogin = $_G['setting']['allowsynlogin'] ? uc_user_synlogin($_G['uid']) : '';
             $param = array('username' => $_G['username'], 'uid' => $_G['uid'], 'usergroup' => '');
             showmessage('login_succeed', $referer, $param, array('showdialog' => 1, 'locationtime' => true, 'extrajs' => $ucsynlogin));
         } else {
             showmessage('login_succeed', $referer, array('username' => $_G['username'], 'uid' => 0, 'usergroup' => ''));
         }
     } elseif ('siteuserNotExist' == $tipsType) {
         showmessage(XWB_plugin::L('xwb_site_user_not_exist'), '', array(), array(), 1);
     } elseif ('reg' == $tipsType) {
         showmessage(XWB_plugin::L('xwb_process_binding', 'openReg4dx'), null, array(), array(), 1);
     } elseif ('hasBinded' == $tipsType) {
         showmessage(XWB_plugin::L('xwb_process_binding', 'hasBind'), null, array(), array(), 1);
         //直接跳转到bind页面
     } else {
         if (version_compare(XWB_S_VERSION, '2', '>=')) {
             $pluginid = 'sina_xweibo_x2';
         } else {
             $pluginid = 'sina_xweibo';
         }
         XWB_plugin::redirect(XWB_plugin::siteUrl(0) . 'home.php?mod=spacecp&ac=plugin&id=' . $pluginid . ':home_binding', 3);
     }
 }
 /**
  * 门户文章同步到微博
  * @param int $id 文章id
  * @param int $subject 门户主题
  */
 function articleSync($id, $subject)
 {
     global $_G;
     if (empty($subject)) {
         $subject = XWB_plugin::L('xwb_article_no_subject');
     }
     $message = XWB_plugin::L('xwb_article_publish_message', $subject);
     $message = $this->_convert($message);
     $link = ' ' . $_G['siteurl'] . "portal.php?mod=view&aid={$id}";
     if (1 == XWB_plugin::pcfg('link_visit_promotion')) {
         $link .= '&fromuid=' . $_G['uid'];
     }
     $length = 140 - ceil(strlen(urlencode($link)) * 0.5);
     //2个字母为1个字
     $message = $this->_substr($message, $length);
     $message .= $link;
     $db = XWB_plugin::getDB();
     $wb = XWB_plugin::getWB();
     $ret = array();
     // 同步到微博
     $ret = $wb->update($message, false);
     //同步微博后的ID
     if (!empty($ret['id'])) {
         //@todo json_decode可能存在解析超过int最大数的错误(#47644)问题
         $mid = $ret['id'];
         $this->insertSyncId($id, $ret['id'], 'article');
         //日志同步统计上报
         $sess = XWB_plugin::getUser();
         $sess->appendStat('ryz', array('uid' => XWB_plugin::getBindInfo("sina_uid"), 'mid' => $mid, 'type' => 5));
         //插入“已同步到......”到指定id中。
         if (XWB_plugin::pCfg('wb_addr_display')) {
             $redirectURL = XWB_plugin::pCfg('switch_to_xweibo') && XWB_plugin::pCfg('baseurl_to_xweibo') ? rtrim(XWB_plugin::pCfg('baseurl_to_xweibo'), '/') . "/index.php?m=show&id={$mid}" : XWB_API_URL . $ret['user']['id'] . '/statuses/' . $mid;
             $insertSyncHTML = "\n\r" . '<DIV><FONT color="#808080" size=2><IMG src="' . XWB_plugin::getPluginUrl('images/bgimg/icon_logo.png') . '">&nbsp;' . XWB_plugin::L('xwb_topic_has_sycn_to') . '&nbsp;<a href="' . $redirectURL . '" target="_blank">' . $_G['username'] . XWB_plugin::L('xwb_topic_has_sycn_to_new_end') . '</A></FONT></DIV>';
             $insertSyncHTML = mysql_real_escape_string($insertSyncHTML);
             $db->query('UPDATE ' . DB::table('portal_article_content') . ' SET `content` = CONCAT(`content`, \'' . $insertSyncHTML . '\') WHERE `aid` = \'' . $id . '\'');
         }
     }
 }
 /**
  * 发表文章页面钩子:同步按钮显示
  */
 function portalcp_bottom_output()
 {
     global $_G;
     $return = '';
     if ('article' != $_G['gp_ac'] || !$_G['uid'] || (!isset($GLOBALS['op']) || 'add' != $GLOBALS['op']) || 'GET' != core_sina_xweibo_x2::getRequestMethod() || false == $this->_start_xweibo(true) || !XWB_plugin::pCfg('is_syncarticle_toweibo')) {
         return $return;
     }
     $lang['xwb_sycn_to_sina'] = XWB_plugin::L('xwb_sycn_to_sina');
     $lang['xwb_sycn_open'] = XWB_plugin::L('xwb_sycn_open');
     $p = XWB_plugin::O('xwbUserProfile');
     $html_checked = (int) $p->get('article2weibo_checked', 1);
     include template($this->pluginid . ':portalcp_newarticle');
     return $return;
 }
Ejemplo n.º 7
0
 /**
  * 根据在首页中显示的浮层显示对应的操作(内部函数,被authCallback最后调用)
  * 所有跟站点相关的对接,必须放到_showBinging
  * @param string $tipsType 类型
  * @uses showmessage(dz函数)
  */
 function _showBinging($tipsType)
 {
     //用于启动浮层
     $GLOBALS['xwb_tips_type'] = $tipsType;
     //不完美解决方案
     if ('UTF-8' != strtoupper($GLOBALS['_J']['config']['charset'])) {
         @header("Content-type: text/html; charset=utf-8");
     }
     if ('autoLogin' == $tipsType) {
         $synlogin_result = '';
         if (true === UCENTER) {
             //加载Ucenter客户端文件
             include_once ROOT_PATH . './api/uc_client/client.php';
             $ucuid = (int) $GLOBALS['_J']['config']['login_user']['ucuid'];
             if ($ucuid > 0) {
                 $synlogin_result = uc_user_synlogin($ucuid);
             }
         }
         //直接跳转到首页
         jsg_showmessage("登录成功{$synlogin_result}", $this->redirect_to, 5);
     } elseif ('siteuserNotExist' == $tipsType) {
         jsg_showmessage(XWB_plugin::L('xwb_site_user_not_exist'));
     } elseif ('reg' == $tipsType) {
         jsg_showmessage(XWB_plugin::L('xwb_process_binding', 'openReg4jsg'));
     } elseif ('hasBinded' == $tipsType) {
         jsg_showmessage(XWB_plugin::L('xwb_process_binding', 'hasBind'));
         //直接跳转到bind页面
     } else {
         XWB_plugin::redirect(XWB_plugin::siteUrl(0) . 'index.php?mod=account&code=sina', 3);
     }
 }