/**
  * 评论回推设置:设置和开启评论回推选项
  */
 function doCfg4pushback()
 {
     if (!defined('XWB_S_IS_ADMIN') || !XWB_S_IS_ADMIN || !XWB_plugin::isRequestBy('POST')) {
         XWB_plugin::deny('');
     } elseif (!xwb_token::checkInput('p', 'pushback', true)) {
         XWB_plugin::showError('令牌验证失败,请返回重试');
     }
     $is_pushback_open = 1;
     $pushback_to_thread = intval(XWB_plugin::V('p:pushback_to_thread'));
     $pushback_to_blog = intval(XWB_plugin::V('p:pushback_to_blog'));
     $pushback_to_doing = intval(XWB_plugin::V('p:pushback_to_doing'));
     $pushback_to_share = intval(XWB_plugin::V('p:pushback_to_share'));
     if (!$pushback_to_thread && !$pushback_to_blog && !$pushback_to_doing && !$pushback_to_share) {
         $is_pushback_open = 0;
     }
     $res = XWB_Plugin::setPCfg(array('is_pushback_open' => $is_pushback_open, 'pushback_to_thread' => $pushback_to_thread, 'pushback_to_blog' => $pushback_to_blog, 'pushback_to_doing' => $pushback_to_doing, 'pushback_to_share' => $pushback_to_share));
     if (true == $res) {
         $ret = array(1, '设置保存成功。');
     } else {
         $ret = array(0, '设置保存失败,请检查配置文件app.cfg.php是否具有可写权限?');
     }
     $this->_oScript('xwbSetTips', $ret);
     $pushInstance = XWB_Plugin::O('pushbackCommunicator');
     if (1 == $is_pushback_open) {
         $pushInstance->setPushback('comment');
     } else {
         $pushInstance->cancelPushback();
     }
 }
 /**
  * 设置错误提示
  *
  * @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);
 }
 /**
  * 帖子转发
  */
 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);
 }
 function setError($error)
 {
     if (!$this->error_exit) {
         return;
     }
     $err = array('Access time failure' => '请求时间失效', 'Signature is not correct' => '签名不正确', 'Request path is not correct' => '请求路径不正确', 'Save faileds' => '数据保存失败', 'Update faileds' => '数据更新失败');
     $errmsg = isset($error['error']) ? strtolower($error['error']) : 'UNDEFINED ERROR';
     $msg = isset($err[$errmsg]) ? $err[$errmsg] : '未知错误';
     if ('utf8' != strtolower(XWB_S_CHARSET)) {
         $msg = XWB_plugin::convertEncoding($msg, XWB_S_CHARSET, 'UTF-8');
     }
     XWB_plugin::showError($msg);
 }
 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, '&');
 }
Esempio n. 6
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);
 }