示例#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);
 }
示例#2
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);
 }
示例#3
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);
 }
示例#4
0
文件: Tag.php 项目: leunico/aliceBlog
 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);
 }
示例#5
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', '没有输入关键词!');
     }
 }
示例#6
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);
 }
示例#7
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);
 }
示例#8
0
 public function setorder()
 {
     $loginInfo = Request::getSession('admin_user_login');
     $admin = self::$models->Admin;
     $result = $admin->getByUserId($loginInfo['id']);
     if ($result['is_admin'] == '0') {
         echo 'error';
     } else {
         echo Diary::setorder();
     }
 }
示例#9
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');
    }
示例#10
0
 public function IpLimit($ip)
 {
     //Cookie伪验证,如果要真实验证需配合数据库或Memcache
     $addComment = Request::getCookie('comment_ip');
     if (isset($addComment)) {
         $count = Request::getCookie('comment_ip_comments');
         if ($count > 20) {
             AjaxError('sorry..每天评论不能超过12条');
         } else {
             Request::setCookie('comment_ip_comments', $count + 1, time() + 86400);
         }
     } else {
         Request::setCookie('comment_ip', $ip, time() + 86400);
         Request::setCookie('comment_ip_comments', 1, time() + 86400);
     }
 }
示例#11
0
 public function scoreajax()
 {
     if ('POST' != $_SERVER['REQUEST_METHOD']) {
         header('Allow: POST');
         header('HTTP/1.1 405 Method Not Allowed');
         header('Content-Type: text/plain');
         die('Illegal request!');
     }
     $fields = array();
     $fields['action'] = isset($_POST['action']) ? intval($_POST['action']) : null;
     $fields['um_action'] = isset($_POST['um_action']) ? trim($_POST['um_action']) : null;
     $fields['um_id'] = isset($_POST['um_id']) ? intval($_POST['um_id']) : null;
     $data = array();
     $addScore = Request::getCookie('add_score_' . $fields['um_id']);
     //判断是否24小时内已经投过了。cookie判断,伪验证!安全点就使用ip验证。
     if (!empty($addScore) && $addScore - time() <= 86400) {
         AjaxError('24小时内只能投一次');
     }
     Request::setCookie('add_score_' . $fields['um_id'], time(), time() + 86400);
     $article = self::$models->Article;
     if ($fields['um_action'] == 'ding') {
         $result = $article->updatePlus($fields['um_id'], 'good_num');
     } elseif ($fields['um_action'] == 'xu') {
         $result = $article->updatePlus($fields['um_id'], 'bad_num');
     }
     echo $result ? $fields['action'] + 1 : '不明所以的失败了...';
 }
示例#12
0
 public function Pageindex($page, $pagesize = 10, $comment = false)
 {
     $total = $this->getCounter($this->tablename, $this->where_);
     $url = preg_replace("/([-]*page-[0-9]*)/i", "", Request::getFullPath());
     $postfix = '';
     $strpos = strpos($url, '?');
     if ($strpos !== false) {
         $postfix = substr($url, $strpos);
         $url = substr($url, 0, $strpos);
     }
     $s = substr($url, -1, 1) == '/' ? '' : '/';
     $s = strpos($url, '-') === FALSE ? $s : '-';
     $pages = ceil($total / $pagesize);
     $page = min($pages, $page);
     $prepg = $page - 1;
     if ($total < 1) {
         $this->clear();
         return FALSE;
     }
     if ($comment) {
         $pagenav = '<div class="pagenav">';
         for ($i = -10; $i <= 10; $i++) {
             $pageTmp = $page + $i;
             if ($pageTmp < 1 || $pageTmp > $pages) {
                 continue;
             }
             if ($i != 0) {
                 $pagenav .= "<a class=\"page-numbers\" href='{$url}?page={$pageTmp}#comments'>{$pageTmp}</a>";
             } else {
                 if ($i == 0) {
                     $pagenav .= "<span class=\"page-numbers current\">{$pageTmp}</span>";
                 }
             }
         }
         $pagenav .= "</div>";
     } else {
         $pagenav = '<div class="pagination"><ul>';
         $pagenav .= $prepg ? "<li class=\"prev-page\"><a href='{$url}'>首页</a></li>" : '';
         for ($i = -10; $i <= 10; $i++) {
             $pageTmp = $page + $i;
             if ($pageTmp < 1 || $pageTmp > $pages) {
                 continue;
             }
             if ($i != 0) {
                 $pagenav .= $pageTmp == 1 ? "<li><a href='{$url}'>{$pageTmp}</a></li>" : "<li><a href='{$url}?page={$pageTmp}'>{$pageTmp}</a></li>";
             } else {
                 if ($i == 0) {
                     $pagenav .= "<li class='active'><a href='{$url}?page={$pageTmp}'>{$pageTmp}</a></li>";
                 }
             }
         }
         $pagenav .= $page == $pages ? "<li><span>共" . $pages . "页</span></li></ul></div>" : "<li class=\"next-page\"><a href='{$url}?page={$pages}'>尾页</a></li><li><span>共 " . $pages . " 页</span></li></ul></div>";
     }
     if ($total <= $pagesize) {
         $pagenav = '';
     }
     $result = $this->get($pagesize, ($page - 1) * $pagesize);
     $result['page'] = $pagenav;
     if ($comment == true) {
         $result['counts'] = $total;
     }
     return $result;
 }