/**
  * 关闭远程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' => '配置文件无法写入')));
     }
 }
<?php

/*
 * @version $Id: newarticle.hack.php 453 2010-12-23 04:36:02Z yaoying $
 */
if (!defined('IS_IN_XWB_PLUGIN')) {
    exit('Access Denied!');
}
global $_G;
$aid = isset($GLOBALS['aid']) ? (int) $GLOBALS['aid'] : 0;
$subject = isset($_POST['title']) ? (string) $_POST['title'] : '';
if ($aid >= 1) {
    if (XWB_plugin::V('p:syn')) {
        $xp_publish = XWB_plugin::N('xwb_plugins_publish');
        register_shutdown_function(array(&$xp_publish, 'articleSync'), (int) $aid, $subject);
    }
}
 /**
  * 新增用户绑定关系
  *
  */
 function addBindUser($site_uid, $sina_uid, $access_toke, $token_secret, $nickname = false, $turn = true)
 {
     if ($site_uid < 1) {
         return false;
     }
     $db = $discuz->db;
     $site_uid = DB::mysqli_escape($site_uid);
     $sina_uid = DB::mysqli_escape($sina_uid);
     $access_toke = DB::mysqli_escape($access_toke);
     $token_secret = DB::mysqli_escape($token_secret);
     $sql = "INSERT INTO " . DB::table('xwb_bind_info') . " (`uid`,`sina_uid`,`token`,`tsecret`,`profile`) VALUES('{$site_uid}','{$sina_uid}','{$access_toke}','{$token_secret}','[]')";
     $rst = DB::query($sql, 'UNBUFFERED');
     $switch = XWB_plugin::pCfg('switch_to_xweibo');
     if ($turn && $switch && $rst) {
         $api = XWB_plugin::N('apixwb');
         $api->updateBindUser($site_uid, $sina_uid, $access_toke, $token_secret, $nickname);
     }
     return $rst;
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 /**
  * 获取WBAPI类
  * @return weibo weibo类
  */
 function &getWB()
 {
     //以下这段代码原来和plugin.env.php有重合,进行精简或者弃用
     /*
     if ( !defined('XWB_S_UID') ||  XWB_S_UID < 1 ){
     	$sess = XWB_plugin::getUser();
     	$wBind	= $sess->getInfo('waiting_site_bind');
     	$wReg	= $sess->getInfo('waiting_site_reg');
     	if (empty($wBind) && empty($wReg) ){
     		$sess->clearToken();
     	}
     }
     */
     //echo '<pre>';print_r($_SESSION);exit;
     $wb = XWB_plugin::N('weibo');
     $wb->setConfig();
     return $wb;
 }
 /**
  * 生成UC所需的头像编码POST数据。
  * @return array 编码好的数据
  */
 function _createUCAvatarPostdata()
 {
     $postdata = array();
     $imageEncoder = XWB_plugin::N('imageEncoder');
     foreach ($this->faceTempPath as $key => $face) {
         $content = file_get_contents($face);
         if (empty($content)) {
             break;
         }
         $postkey = 'avatar' . $key;
         $postdata[$postkey] = $imageEncoder->flashdata_encode($content);
     }
     $imageEncoder = null;
     return $postdata;
 }