/** * 评论回推设置:设置和开启评论回推选项 */ 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(); } }
/** * 帖子转发 */ 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); }