Esempio n. 1
0
 public function editArticleAction()
 {
     $uid = $this->getSession("uid");
     $email = $this->getSession("email");
     if (!isset($uid) || empty($uid) || !isset($email) || empty($email)) {
         $this->notify("请先登录", "http://" . $_SERVER["HTTP_HOST"] . "/login");
     }
     $id = parent::get("id");
     if (!$id) {
         $this->notify("页面不存在");
         Yaf_Dispatcher::getInstance()->disableView();
         return false;
     }
     $article = $this->m_study->Where("id=" . $id . " AND uid=" . $uid)->SelectOne();
     if (!$article) {
         $this->notify("页面不存在");
         Yaf_Dispatcher::getInstance()->disableView();
         return false;
     }
     if (!intval($article["status"])) {
         $this->notify("页面不存在");
         Yaf_Dispatcher::getInstance()->disableView();
         return false;
     }
     //分类
     $sort_list = $this->m_study_sort->Where("status='1'")->Field("id,sort_name")->Select();
     $buffer['sort_list'] = $sort_list;
     $article["content"] = deep_htmlspecialchars_decode($article["content"]);
     $buffer['article'] = $article;
     $buffer['pageTitle'] = "编辑文章_泰语学习_泰语导航网";
     $this->getView()->assign($buffer);
 }
Esempio n. 2
0
 public function authAction()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     $type = parent::get("type", false);
     if ($type == "qq") {
         Yaf_loader::import(LIB_PATH . '/L_QqConnect.class.php');
         $qqObj = new L_QqConnect();
         $info = $qqObj->callback();
         $model_user_three = $this->load('user_three');
         $user_three = $model_user_three->Where("openid='" . $info["openid"] . "' AND type=0")->SelectOne();
         if ($user_three) {
             $user_info = $this->m_user->Where("id=" . $user_three["user_id"])->Field(array("id", "email"))->SelectOne();
             parent::setSession('uid', $user_info["id"]);
             parent::setSession('email', $user_info["email"]);
             $this->notify("QQ授权登录成功...", "/member", "success");
             die;
         } else {
             $user_info = $qqObj->get_user_info($info["token"], $info["openid"]);
             parent::setSession('openid', $info["openid"]);
             parent::setSession("token", $info["token"]);
             parent::setSession("nickname", $user_info["nickname"]);
             parent::setSession("type", 0);
             $this->notify("QQ授权成功...", "/login/three", "success");
             die;
         }
     } else {
         if ($type == "weibo") {
             Yaf_loader::import(LIB_PATH . '/L_Weibo.class.php');
             $weiboObj = new L_Weibo();
             $info = $weiboObj->callback();
             $model_user_three = $this->load('user_three');
             $user_three = $model_user_three->Where("openid='" . $info["openid"] . "' AND type=1")->SelectOne();
             if ($user_three) {
                 $user_info = $this->m_user->Where("id=" . $user_three["user_id"])->Field(array("id", "email"))->SelectOne();
                 parent::setSession('uid', $user_info["id"]);
                 parent::setSession('email', $user_info["email"]);
                 $this->notify("微博授权登录成功...", "/member", "success");
                 die;
             } else {
                 $user_info = $weiboObj->get_user_info($info["token"], $info["openid"]);
                 parent::setSession('openid', $info["openid"]);
                 parent::setSession("token", $info["token"]);
                 parent::setSession("nickname", $user_info["screen_name"]);
                 parent::setSession("type", 1);
                 $this->notify("微博授权成功...", "/login/three", "success");
                 die;
             }
         } else {
             $this->notify("无效回调的类型", "http://" . $_SERVER["HTTP_HOST"]);
             die;
         }
     }
 }