Esempio n. 1
0
 public function index($id = '')
 {
     if ($id == '') {
         View::AdminErrorMessage('goback', '非法入口!Go Die');
     }
     $fields = Request::getRequest('page', 'int');
     $page = isset($fields) && $fields > 0 ? $fields : 1;
     $article = self::$models->Article;
     $tag = self::$models->Tag;
     $mem = self::$models->Memcache;
     $ret = $mem->get('tagController_index_' . $id . '_' . $page);
     if (empty($ret)) {
         $ret = array();
         $ret['tag'] = $tag->getTagById($id);
         if (empty($ret['tag'])) {
             NotFound();
         }
         $ret['tagarticleShow'] = $article->getArticleTagShow($ret['tag']['tag'], $page);
         $ret['pushArticleList'] = $article->getPushArticleList();
         $ret['newArticleList'] = $article->getNewArticleList();
         $ret['commentArticleList'] = $article->getCommentArticleList();
         $ret['pageNav'] = @array_pop($ret['tagarticleShow']);
         $mem->set('tagController_index_' . $id . '_' . $page, $ret, 12 * 3600);
     }
     View::Transmit('tagshow', $ret);
 }
Esempio n. 2
0
 public function logingo()
 {
     if (Request::getRequest('dosubmit', 'str')) {
         $admin = self::$models->Admin;
         $email = Request::getRequest('email', 'str');
         $password = md5(Request::getRequest('password', 'str'));
         $result = $admin->getByUser($email);
         //var_dump($result);exit();
         if ($result['is_block'] == '1') {
             View::AdminErrorMessage('admin/login', 'sorry,你的帐号被管理员拉黑!');
         }
         if (isset($result) && $result['password'] == $password) {
             $session = array();
             $session['id'] = $result['id'];
             $session['username'] = $result['username'];
             $session['type'] = 'pc';
             $session['block'] = $result['is_block'];
             $session['email'] = $result['email'];
             Request::setSession($this->sessionId, $session);
             //var_dump($_SESSION);
             View::jsJump('/admin/index');
         } else {
             View::AdminErrorMessage('admin/login', '密码or帐号错误,登录后台失败!');
         }
     }
 }
 public function index($id = '')
 {
     if ($id == '') {
         View::AdminErrorMessage('goback', '木有选择文章哦!');
     }
     $fields = Request::getRequest('page', 'int');
     $page = isset($fields) && $fields > 0 ? $fields : 1;
     $article = self::$models->Article;
     $comment = self::$models->Comment;
     $mem = self::$models->Memcache;
     $ret = $mem->get('articleshowController_index_id_' . $id);
     if (empty($ret)) {
         $ret = array();
         $ret['articleShow'] = $article->getArticleShow($id);
         if (empty($ret['articleShow'])) {
             NotFound();
         }
         $ret['articleShow']['tag'] = explode('|', $ret['articleShow']['tag']);
         $ret['articleRelevant'] = $article->getArticleRelevant($ret['articleShow']['mid'], $ret['articleShow']['id']);
         $ret['pushArticleList'] = $article->getPushArticleList();
         $ret['newArticleList'] = $article->getNewArticleList();
         $ret['commentArticleList'] = $article->getCommentArticleList();
         $mem->set('articleshowController_index_id_' . $id, $ret);
     }
     $ret['comments'] = $comment->getArticleCommentList($id, $page);
     if (!empty($ret['comments']['counts'])) {
         $ret['articleShow']['counts'] = array_pop($ret['comments']);
     }
     if (!empty($ret['comments']['page'])) {
         $ret['articleShow']['commentPage_nav'] = array_pop($ret['comments']);
     }
     $article->updatePlus($id, 'clicks');
     //文章的点击数+1
     View::Transmit('articleshow', $ret);
 }
Esempio n. 4
0
 private static function ClassData($class)
 {
     $fields = Request::getRequest('page', 'int');
     $page = isset($fields) && $fields > 0 ? $fields : 1;
     $article = self::$models->Article;
     $mem = self::$models->Memcache;
     $configclass = getClass();
     $meunclass = $configclass['menu_class'];
     $articleclass = $configclass['article_class'];
     if (empty($meunclass[$class]) && empty($articleclass[$class])) {
         View::AdminErrorMessage('goback', '入口错误误误!');
     }
     $ret = $mem->get('classController_ClassData_' . $class . $page);
     $memc = $class;
     if (!empty($meunclass[$class]) && is_array($meunclass[$class])) {
         $class = $meunclass[$class];
         array_shift($class);
         $class = array_flip($class);
     }
     if (empty($ret)) {
         $ret = array();
         $ret['articleClassList'] = $article->getArticleClassList($class, $page);
         $ret['pageNav'] = @array_pop($ret['articleClassList']);
         $mem->set('classController_ClassData_' . $memc . $page, $ret);
     }
     $ret['meunclass'] = $meunclass;
     $ret['articleclass'] = $articleclass;
     $ret['nav'] = $class;
     View::Transmit('newclassshow', $ret);
 }
Esempio n. 5
0
 public static function pushs()
 {
     $ret = array();
     $diary = self::$models->Diary;
     $ret['pushs'] = $diary->getPushList();
     if (Request::getRequest('dosubmit', 'str')) {
         $pushimg = Request::getRequest('pushimg', 'array');
         $pushurl = Request::getRequest('pushurl', 'array');
         $result = $diary->editPush(self::$models->make('Qiniu', array('alice')), $pushurl, $pushimg, $_FILES['doc']);
         $result ? View::AdminMessage('admin/pushs', '修改成功') : View::AdminErrorMessage('goback', '修改失败');
     }
     View::Transmit('admin/pushs', $ret);
 }
Esempio n. 6
0
 public static function tag_edit($id)
 {
     $ret = $fields = array();
     $tag = self::$models->Tag;
     $ret['tags'] = $tag->getTagById($id);
     if (Request::getRequest('dosubmit', 'str')) {
         $fields['tag'] = Request::getRequest('username', 'str');
         if ($ret['tags']['tag'] == $fields['tag']) {
             View::AdminErrorMessage('goback', '你未做修改!');
         }
         $result = $tag->editTag($id, $fields, $ret['tags']['tag']);
         $result ? View::AdminMessage('admin/tags', '修改成功') : View::AdminErrorMessage('goback', '修改失败');
     }
     View::Transmit('admin/tag_edit', $ret);
 }
Esempio n. 7
0
 public function search()
 {
     if (Request::getRequest('dosubmit', 'str')) {
         $mem = self::$models->Memcache;
         $index = self::$models->Index;
         $article = self::$models->Article;
         $ret = $mem->get('indexController_search');
         if (empty($ret)) {
             $ret = array();
             $ret['pushArticleList'] = $article->getPushArticleList();
             $ret['newArticleList'] = $article->getNewArticleList();
             $ret['commentArticleList'] = $article->getCommentArticleList();
             $mem->set('indexController_search', $ret, 12 * 3600);
         }
         $ret['keyword'] = Request::getRequest('search', 'str');
         $ret['searchList'] = $index->getSearchList($ret['keyword']);
         View::Transmit('search', $ret);
     } else {
         View::AdminErrorMessage('goback', '没有输入关键词!');
     }
 }
Esempio n. 8
0
 public static function comments()
 {
     $fields = Request::getRequest('page', 'int');
     $page = isset($fields) && $fields > 0 ? $fields : 1;
     $ret = $scree = array();
     $comment = self::$models->Comment;
     if (Request::getRequest('keyword', 'str') && Request::getRequest('keyword_type', 'str')) {
         $scree['keyword'] = Request::getRequest('keyword', 'str');
         $scree['keyword_type'] = Request::getRequest('keyword_type', 'str');
         $ret['CommentList'] = $comment->getCommentList($page, $scree);
     } elseif (!empty(Request::getRequest('aid', 'int'))) {
         $scree['keyword'] = Request::getRequest('aid', 'int');
         $scree['keyword_type'] = 'aid';
         $ret['CommentList'] = $comment->getCommentList($page, $scree);
     } else {
         $ret['CommentList'] = $comment->getCommentList($page);
     }
     $ret['scree'] = $scree;
     $ret['pageNav'] = @array_pop($ret['CommentList']);
     View::Transmit('admin/comments', $ret);
 }
Esempio n. 9
0
 public static function edit($type, $id)
 {
     $ret = $fields = array();
     $user = self::$models->User;
     $ret['users'] = $user->getOneUser($type, $id);
     if (Request::getRequest('dosubmit', 'str')) {
         $fields['username'] = Request::getRequest('username', 'str');
         $fields['email'] = Request::getRequest('email', 'str');
         $fields['password'] = Request::getRequest('oldpw', 'str');
         $fields['newpw'] = Request::getRequest('newpw', 'str');
         $fields['newpw_a'] = Request::getRequest('newpw_a', 'str');
         if (empty($fields['password']) && empty($fields['newpw'])) {
             $fields['password'] = $ret['users']['password'];
             unset($fields['newpw']);
             unset($fields['newpw_a']);
         } else {
             $password = $ret['users']['password'];
             if ($password !== md5($fields['password'])) {
                 View::AdminErrorMessage('admin/user_edit', '原始密码不正确');
             }
             $fields['password'] = md5($fields['newpw_a']);
             unset($fields['newpw']);
             unset($fields['newpw_a']);
         }
         $result = $user->editUser($id, $fields);
         if ($result) {
             if ($fields['username'] !== $ret['users']['username']) {
                 $session = Request::getSession('admin_user_login');
                 $session['username'] = $fields['username'];
                 Request::setSession('admin_user_login', $session);
                 $user->editArticleAuthor($fields['username'], $id);
             }
             View::AdminMessage('goback', '修改成功');
         } else {
             View::AdminErrorMessage('goback', '修改失败');
         }
     }
     View::Transmit('admin/user_edit', $ret);
 }
Esempio n. 10
0
    public static function baiduSite()
    {
        if (Request::getRequest('dosubmit', 'str')) {
            $fields = Request::getRequest('pushbaidu', 'array');
            $api = BAIDU_SITE_API;
            $ch = curl_init();
            $options = array(CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode('
', $fields), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'));
            curl_setopt_array($ch, $options);
            $result = curl_exec($ch);
            strpos($result, 'success') ? View::AdminMessage('goback', '成功推送' . $result) : View::AdminErrorMessage('goback', '推送失败' . $result);
        }
        View::Transmit('admin/baidusite');
    }