Esempio n. 1
0
 public function handleEditArticleAction()
 {
     if (!$this->getRequest()->isXmlHttpRequest()) {
         parent::notify("页面不存在");
         return false;
     }
     $uid = $this->getSession("uid");
     $email = $this->getSession("email");
     if (!isset($uid) || empty($uid) || !isset($email) || empty($email)) {
         $this->notify("请先登录", "http://" . $_SERVER["HTTP_HOST"] . "/login");
         return false;
     }
     Yaf_Dispatcher::getInstance()->disableView();
     $id = parent::getPost("id");
     $article = $this->m_study->Where("id=" . $id . " AND uid=" . $uid)->SelectOne();
     if (!$article) {
         die(json_encode(array("status" => 0, "msg" => "只能编辑自己的文章")));
     }
     if (!intval($article["status"])) {
         $this->notify("页面不存在");
         Yaf_Dispatcher::getInstance()->disableView();
         return false;
     }
     $title = parent::getPost("title");
     $category = (int) parent::getPost("category");
     $brief = parent::getPost("brief");
     $content = deep_htmlspecialchars(parent::getPost("content", false));
     $result = $this->m_study->UpdateByID(array("study_name" => $title, "sort_id" => $category, "content" => $content, "brief" => $brief), $id);
     if ($result) {
         die(json_encode(array("status" => 1, "msg" => "编辑文章成功", "url" => "http://" . $_SERVER["HTTP_HOST"] . "/study/detail?id=" . $id)));
     } else {
         die(json_encode(array("status" => 0, "msg" => "编辑文章失败")));
     }
 }
Esempio n. 2
0
 public function handleThreeAction()
 {
     Yaf_Dispatcher::getInstance()->disableView();
     $openid = parent::getPost("openid");
     $token = parent::getPost("token");
     $type = parent::getPost("type");
     $username = parent::getPost("username");
     if (!regex($username, "require")) {
         die(json_encode(array("status" => 0, "msg" => "昵称不能为空")));
     }
     $email = parent::getPost("email");
     if (!regex($email, "require")) {
         die(json_encode(array("status" => 0, "msg" => "邮箱不能为空")));
     }
     if (!regex($email, "email")) {
         die(json_encode(array("status" => 0, "msg" => "邮箱格式不正确")));
     }
     $exist_email = $this->m_user->Where("email='" . $email . "'")->Field("id")->SelectOne();
     if ($exist_email) {
         die(json_encode(array("status" => 0, "msg" => "邮箱已经注册过,请直接登录,如果忘记密码,请点击找回密码")));
     }
     $exist_username = $this->m_user->Where("username='******'")->Field("id")->SelectOne();
     if ($exist_username) {
         die(json_encode(array("status" => 0, "msg" => "昵称已经存在,请换一个")));
     }
     $result = $this->m_user->Insert(array("email" => $email, "avatar" => "/img/face.jpg", "brief" => "这家伙有点懒,还没有写个性签名! ", "username" => $username, "reg_time" => time(), "login_time" => time(), "login_ip" => getClientIP(), "reg_type" => 2));
     if ($result) {
         $model_user_three = $this->load('user_three');
         $model_user_three->Insert(array("user_id" => $result, "openid" => $openid, "type" => $type));
         //写入session
         parent::setSession('uid', $result);
         parent::setSession('email', $email);
         die(json_encode(array("status" => 1, "msg" => "绑定QQ成功。")));
     } else {
         die(json_encode(array("status" => 0, "msg" => "绑定QQ失败,请稍后再试...")));
     }
 }