/**
  * 评论回推设置:设置和开启评论回推选项
  */
 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 step1()
 {
     $tokenhash = '';
     if (!xwb_token::checkInput('g', 'xwbuninstall', false)) {
         echo 'XWB_TOKEN_HASH_CHECK_FAILURE!';
         exit;
     }
     $cfg = $this->getCfg();
     $tips = array();
     $st = true;
     if (!empty($_GET['delete_data'])) {
         //delete db data
         $db = XWB_plugin::getDB();
         foreach ($cfg['db_data'] as $name => $format) {
             $tbSql = sprintf($format, DB::table($name));
             $db->query($tbSql);
             $tips[] = array(1, "删除数据表 [PRE_]{$name} 成功");
         }
         $_GET['delete_data'] = 1;
     } else {
         $tips[] = array(1, "已保留微博插件数据");
         $_GET['delete_data'] = 0;
     }
     $lock_file_output = '论坛目录' . str_replace(dirname(dirname(XWB_P_DATA)), '', $this->v['lock_file']);
     if (false == @unlink($this->v['lock_file'])) {
         $tips[] = array(1, "无法删除或找不到安装锁定文件(位于:{$lock_file_output})。如果文件存在,请自行删除。");
     }
     $showTab = 'uninstall';
     $btn_enable = 'class="btn"';
     $btn_name = $st ? '完成' : '重试';
     if ($st) {
         //根据安装来源给出完成跳转链接
         if ($this->_sess->getInfo('boot_referer') == 'admincp') {
             $installtype = 'SC_' . XWB_S_CHARSET;
             if (version_compare(XWB_S_VERSION, '2', '<')) {
                 //X1.5
                 $link = '../../admin.php?action=plugins&operation=pluginuninstall&dir=sina_xweibo&installtype=' . $installtype . '&finish=1';
             } else {
                 //X2
                 $link = '../../admin.php?action=plugins&operation=pluginuninstall&dir=sina_xweibo_x2&installtype=' . $installtype . '&finish=1';
             }
         } else {
             $link = '../../index.php';
         }
     } else {
         $link = 'uninstall.php?step=1&delete_data=' . $_GET['delete_data'];
     }
     $image_file = $st ? 'sucess.png' : "icon.gif";
     include $this->tpl_dir . '/uninstall.php';
     exit;
 }
 /**
  * 关闭远程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' => '配置文件无法写入')));
     }
 }
 /**
  * 用户设置同步选项
  */
 function setUserProfileBind()
 {
     if (XWB_S_UID < 1) {
         XWB_plugin::showError('你尚未登录。');
     } elseif (!XWB_plugin::pCfg('is_account_binding') || !XWB_plugin::isRequestBy('POST')) {
         XWB_plugin::showError('网站管理员关闭了插件功能“新浪微博绑定”。请稍后再试。');
     } elseif (!xwb_token::checkInput('p', 'sync', true)) {
         XWB_plugin::showError('令牌验证失败,请返回重试');
     }
     $set = (array) XWB_plugin::V('p:set');
     $newset = array();
     $inputCheck = array('topic2weibo_checked' => array(0, 1), 'blog2weibo_checked' => array(0, 1), 'article2weibo_checked' => array(0, 1), 'share2weibo' => array(0, 1), 'doing2weibo' => array(0, 1));
     $newset = $this->_filterInput($set, $inputCheck);
     $profile = XWB_plugin::O('xwbUserProfile');
     $profile->set($newset);
     echo '<script>parent.showMsg(\'success\');</script>';
 }