Exemplo n.º 1
0
 public function doLogin()
 {
     $res = array();
     $username = trim(doSafe($_POST['username']));
     $password = trim(doSafe($_POST['password']));
     $code = trim(doSafe($_POST['code']));
     //验证是否有空值提交
     if (empty($username) || empty($password) || empty($code)) {
         $res['status'] = 1;
         echo json_encode($res);
         exit;
     }
     //验证验证码是否正确
     if (!self::checkVerify($code)) {
         $res['status'] = 0;
         echo json_encode($res);
         exit;
     }
     //验证密码和用户是否匹配
     $where = array('username' => $username, 'password' => md5($password), 'is_admin' => 1);
     $user = new UserModel();
     $userInfo = $user->getUserByUsernameAndPassword($where);
     if (!empty($userInfo)) {
         $res['status'] = 10;
         $res['url'] = APP . '/Admin/Index/index';
         $_SESSION['user'] = $userInfo;
     } else {
         $res['status'] = 2;
     }
     echo json_encode($res);
     exit;
 }
Exemplo n.º 2
0
 public function doEdit()
 {
     $data['describe_info'] = doSafe($_POST['describe_info']);
     $data['nav'] = intval($_POST['nav']);
     if (empty($data['describe_info'])) {
         href('请填写完整的信息');
     }
     if ($this->id === 0) {
         //新增标签
         $res = $this->tag->addTag($data);
         if ($res) {
             href('新增标签成功', 2);
         } else {
             href('新增标签失败');
         }
     } else {
         //修改标签
         $res = $this->tag->chengeTagByTagId($this->id, $data);
         if ($res) {
             href('修改标签成功', 2);
         } else {
             href('修改标签失败');
         }
     }
 }
Exemplo n.º 3
0
 public function index()
 {
     $s = doSafe($_GET['s']);
     $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1;
     $article = new ArticleModel();
     //合计文章数目
     $total = $article->getTotal($s);
     //输出首页数据
     if ($total == 0) {
         if ($p < 1) {
             $this->display("Error/index.tpl");
             exit;
         }
     } else {
         if ($p < 1 || $p > ceil($total / $this->pageNum)) {
             $this->display("Error/index.tpl");
             exit;
         }
     }
     $articleList = $article->getArticle($p, $this->pageNum, $s);
     //			获取分页条
     $getPage = new Page();
     $this->assign(array('total' => $total, 'page' => $getPage->getPage(APP . '/search/?s=' . $s . '&p=', $total, $this->pageNum, $p), 'articleList' => $articleList));
     $this->display('Search/index.tpl');
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct();
     $this->id = intval(doSafe($_GET['id']));
     $this->article = new ArticleModel();
     $this->articleTag = new ArticleTagModel();
     $this->file = new Upload('title-img', 'title');
 }
Exemplo n.º 5
0
 public function shareWeibo()
 {
     $weiboConfig = $this->_WBconfig;
     $id = (int) doSafe($_POST['id']);
     $article = new ArticleModel();
     $res = $article->getArticleById($id);
     $url = array();
     $url['url'] = $weiboConfig['HOSTURL'] . $id;
     $url['content'] = 'utf-8';
     $url['pic'] = $weiboConfig['LOCALHOST'] . rtrim($res['title_img'], '.');
     $url['title'] = $res['description'];
     $url['searchPic'] = 'false';
     $ajaxReturn = $weiboConfig['APPKEY'] . http_build_query($url);
     echo json_encode(array($ajaxReturn));
 }
Exemplo n.º 6
0
 public function index()
 {
     $id = $_GET['id'];
     $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1;
     if ($id === '') {
         //400页面
         $this->display("Error/index.tpl");
         exit;
     }
     //根据接受信息查询
     $tag = new TagModel();
     $tagInfo = $tag->getIdByInfo($id);
     if (empty($tagInfo)) {
         $this->display("Error/index.tpl");
         exit;
     }
     //通过tag_id找到article_id
     $article = new ArticleModel();
     $articletag = new ArticletagModel();
     $articleIds = $articletag->getArticleIdByTagId($id);
     //合计文章数目
     $total = count($articleIds);
     //输出首页数据
     if ($total == 0) {
         if ($p < 1) {
             $this->display("Error/index.tpl");
             exit;
         }
     } else {
         if ($p < 1 || $p > ceil($total / $this->pageNum)) {
             $this->display("Error/index.tpl");
             exit;
         }
     }
     if (empty($articleIds)) {
         //该分类下无文章
         $articleList = array();
     } else {
         //根据ID去查找文章
         $articleList = $article->getArticleByIds($articleIds, $p, $this->pageNum);
     }
     $getPage = new Page();
     $this->assign(array('total' => $total, 'id' => $id, 'page' => $getPage->getPage(APP . '/tag/index/id/' . $id . '/p/', $total, $this->pageNum, $p), 'articleList' => $articleList));
     //			获取分页条
     $this->display('Tag/index.tpl');
 }
Exemplo n.º 7
0
 public function index()
 {
     $article = new ArticleModel();
     //合计文章数目
     $total = $article->getTotal();
     //输出首页数据
     $p = !empty($_GET['p']) ? (int) doSafe($_GET['p']) : 1;
     //			$p = $p < 1 ? 1 : $p;
     //			$p = $p > ceil($total/$this->pageNum) ? ceil($total/$this->pageNum) : $p;
     if ($p < 1 || $p > ceil($total / $this->pageNum)) {
         $this->display("Error/index.tpl");
         exit;
     }
     $articleList = $article->getArticle($p, $this->pageNum);
     //			获取分页条
     $getPage = new Page();
     $this->assign(array('page' => $getPage->getPage(APP . '/index/index/p/', $total, $this->pageNum, $p), 'articleList' => $articleList, 'APP' => APP));
     $this->display('Index/index.tpl');
 }
Exemplo n.º 8
0
 public function shareComment()
 {
     $id = (int) doSafe($_POST['articleId']);
     $comment_info = doSafe($_POST['info']);
     if (empty($id) || empty($comment_info)) {
         echo json_encode(0);
         exit;
     }
     //根据微博id找到userID
     $commentUser = new CommentuserModel();
     $user = $commentUser->findUserByWeiboId($_SESSION['weibo']['weibo_id']);
     $userId = $user['comment_user_id'];
     $addArr = array('comment_user_id' => $userId, 'article_id' => $id, 'comment_info' => $comment_info, 'comment_time' => time());
     $comment = new CommentModel();
     if ($comment->addComment($addArr)) {
         echo json_encode(2);
         exit;
     } else {
         echo json_encode(1);
         exit;
     }
 }