Exemplo n.º 1
0
 public function douban()
 {
     if ($this->request->get("code")) {
         //已获得code
         $code = $this->request->get("code");
         $params = array('client_id' => DOUBAN_CLIENT_ID, 'client_secret' => DOUBAN_CLIENT_SECRET, 'redirect_uri' => $this->_siteUrl . DOUBAN_REDIRECT_URI, 'grant_type' => 'authorization_code', 'code' => $code);
         $result = json_decode(HTTP::request(DOUBAN_ACCESS_TOKEN_URL, $params, 'POST'));
         if (!isset($result->code)) {
             $set = array('douban_access_token' => $result->access_token, 'douban_refresh_token' => $result->refresh_token, 'douban_expires_in' => $result->expires_in, 'douban_last_time' => time() + $result->expires_in);
             Widget_Plugins_Edit::configPlugin("SyncPost", $set);
             $this->widget('Widget_Notice')->set(_t('豆瓣广播授权成功!'), 'success');
         } else {
             $this->widget('Widget_Notice')->set(_t('豆瓣广播授权失败,异常信息:' . $result->code . ' - ' . $result->msg), 'error');
         }
         header('Location: ' . $this->_siteUrl . __TYPECHO_ADMIN_DIR__ . 'options-plugin.php?config=SyncPost');
         //刷新页面
     } else {
         //获取授权code
         $params = array('client_id' => DOUBAN_CLIENT_ID, 'redirect_uri' => $this->_siteUrl . DOUBAN_REDIRECT_URI, 'response_type' => 'code');
         header('Location: ' . DOUBAN_AUTHORIZATION_CODE_URL . '?' . http_build_query($params));
         //刷新页面
     }
 }
Exemplo n.º 2
0
 /**
  * 手动配置插件变量
  * 
  * @access public
  * @static
  * @param mixed $pluginName 插件名称
  * @param array $settings 变量键值对
  * @param bool $isPersonal. (default: false) 是否为私人变量
  * @return void
  */
 public static function configPlugin($pluginName, array $settings, $isPersonal = false)
 {
     if (empty($settings)) {
         return;
     }
     Widget_Plugins_Edit::configPlugin($pluginName, $settings, $isPersonal);
 }
Exemplo n.º 3
0
 /** 解绑微信用户 **/
 private function unbindUser($postObj)
 {
     $_bindUserNo = $this->_options->bindUserNo;
     $sendUser = (string) $postObj->FromUserName;
     $resultStr = "";
     if ($_bindUserNo != "" && $sendUser == $_bindUserNo) {
         $array["bindUserNo"] = "";
         $array["bindCaptcha"] = WeChatHelper_Plugin::randString(8);
         Widget_Plugins_Edit::configPlugin("WeChatHelper", $array);
         $resultStr = "恭喜,解除绑定成功!";
     }
     return $resultStr;
 }
Exemplo n.º 4
0
 /**
  * 同步插件设置
  *
  * @access public
  * @return void
  */
 public function syncsettings()
 {
     //验证组合表单
     $requests = array_merge($this->request->from('fixedwidth'), $this->request->from('fixedheight'), $this->request->from('fixedratio'));
     $validator = new Typecho_Validate();
     $validator->addRule('fixedwidth', 'isInteger', _t('固定宽度请输入整数数字'));
     $validator->addRule('fixedheight', 'isInteger', _t('固定高度请输入整数数字'));
     $validator->addRule('fixedratio', array(new HighSlide_Plugin(), 'ratioformat'), _t('固定比例请输入:与数字'));
     $validator->addRule('fixedwidth', 'required', _t('固定宽度不能为空'));
     $validator->addRule('fixedheight', 'required', _t('固定高度不能为空'));
     $validator->addRule('fixedratio', 'required', _t('固定比例不能为空'));
     if ($error = $validator->run($requests)) {
         $this->widget('Widget_Notice')->set($error, 'error');
         $this->response->goBack();
     }
     //构建同步数组
     $syncsets = array('qiniubucket', 'qiniudomain', 'qiniuaccesskey', 'qiniusecretkey', 'qiniuprefix', 'upyunbucket', 'upyundomain', 'upyunuser', 'upyunpwd', 'upyunkey', 'upyunprefix', 'bcsbucket', 'bcsapikey', 'bcssecretkey', 'bcsprefix', 'storage', 'local', 'thumbfix', 'fixedwidth', 'fixedheight', 'fixedratio', 'gallery');
     foreach ($syncsets as $syncset) {
         $result = $this->request->from($syncset);
         $datas[$syncset] = $result[$syncset];
     }
     //返回原页并提示信息
     Widget_Plugins_Edit::configPlugin('HighSlide', $datas);
     $this->widget('Widget_Notice')->set(_t('相册设置已保存'), NULL, 'success');
     $this->response->goBack();
 }