Browse Source

文章, 评论, 留言

huwhois 3 years ago
parent
commit
6f801ec270

+ 6 - 14
app/common/model/Article.php

@@ -23,7 +23,7 @@ class Article extends Base
         "discussed"   => "int",
         "discussed"   => "int",
         "status"      => "int",
         "status"      => "int",
         "top"         => "int",
         "top"         => "int",
-        "sorts"       => "int",
+        "sort"       => "int",
         "hits"        => "int",
         "hits"        => "int",
         "likes"       => "int",
         "likes"       => "int",
         "content_type"=> "int",
         "content_type"=> "int",
@@ -83,7 +83,7 @@ class Article extends Base
         $limit = empty($params['limit']) ? 20 : (int)$params['limit'];
         $limit = empty($params['limit']) ? 20 : (int)$params['limit'];
 
 
         $list = self::where($where)
         $list = self::where($where)
-            ->field('id,cid,title,titlepic,username,summary,content_type,hits,sorts,status,create_time')
+            ->field('id,cid,title,titlepic,username,summary,content_type,hits,sort,status,create_time')
             ->with(['category'])
             ->with(['category'])
             ->order('id desc')->paginate($limit, false, ['query' => $params]);
             ->order('id desc')->paginate($limit, false, ['query' => $params]);
 
 
@@ -105,14 +105,14 @@ class Article extends Base
         $order = !empty($order) ? array_merge($order, ['id' => 'desc']) : ['id' => 'desc'];
         $order = !empty($order) ? array_merge($order, ['id' => 'desc']) : ['id' => 'desc'];
 
 
         return self::where($where)
         return self::where($where)
-            ->field('id,cid,title,titlepic,username,summary,hits,sorts,status,create_time')
+            ->field('id,cid,title,titlepic,username,summary,hits,sort,status,create_time')
             ->order($order)->limit($limit)->select();
             ->order($order)->limit($limit)->select();
     }
     }
 
 
     public static function getTop($limit)
     public static function getTop($limit)
     {
     {
-        return self::with('category')->field('id,cid,title,titlepic,summary,username,hits,sorts,status,create_time')
-            ->order('sorts desc, hits desc')->limit($limit)->select();
+        return self::with('category')->field('id,cid,title,titlepic,summary,username,hits,sort,status,create_time')
+            ->order('sort desc')->limit($limit)->select();
     }
     }
 
 
     public static function getOne($id)
     public static function getOne($id)
@@ -128,7 +128,7 @@ class Article extends Base
     {
     {
         if ($cid) {
         if ($cid) {
             $id_list = self::where(['status' => 1, 'cid' => $cid])
             $id_list = self::where(['status' => 1, 'cid' => $cid])
-                ->order(['sorts' => 'desc', 'id' => 'desc'])
+                ->order(['sort' => 'desc', 'id' => 'desc'])
                 ->column('id');
                 ->column('id');
         } else {
         } else {
             $id_list = self::where(['status' => 1])->column('id');
             $id_list = self::where(['status' => 1])->column('id');
@@ -170,12 +170,4 @@ class Article extends Base
 
 
         return $timeList;
         return $timeList;
     }
     }
-
-    public static function sort($data)
-    {
-        $article = self::find($data['id']);
-        $article->sort = $data['sort'];
-
-        return $article->save();
-    }
 }
 }

+ 7 - 0
app/common/model/ArticleDolikeLog.php

@@ -0,0 +1,7 @@
+<?php
+namespace app\common\model;
+
+class ArticleDolikeLog extends \think\Model
+{
+    
+}

+ 4 - 15
app/common/model/Base.php

@@ -5,25 +5,14 @@ namespace app\common\model;
 use think\model;
 use think\model;
 
 
 class Base extends model
 class Base extends model
-{
-    // 删除
-    public static function del($id)
-    {
-        try {
-            self::destroy($id);
-            return json(['code' => 0, 'msg' => '删除成功!']);
-        } catch (\Exception $e) {
-            return json(['code' => 1, 'msg' => $e->getMessage()]);
-        }
-    }
-    
+{    
     // 排序修改
     // 排序修改
-    public static function sort($data)
+    public static function sorts($data)
     {
     {
         try {
         try {
             $info = self::find($data['id']);
             $info = self::find($data['id']);
-            if ($info->sort != $data['sorts']) {
-                $info->sort = $data['sorts'];
+            if ($info->sort != $data['sort']) {
+                $info->sort = $data['sort'];
                 $info->save();
                 $info->save();
                 return json(['code' => 0, 'msg' => '修改成功!']);
                 return json(['code' => 0, 'msg' => '修改成功!']);
             }
             }

+ 16 - 0
app/common/model/GuestBook.php

@@ -0,0 +1,16 @@
+<?php
+namespace app\common\model;
+
+class GuestBook extends Base
+{
+    protected $schema = [
+        "id"      => 'int',
+        "name"    => "varchar",
+        "contact" => "varchar",
+        "content" => "varchar",
+        "url"     => "varchar",
+        "time"    => 'int',
+        "mark"    => 'int',
+        "remark"  => "varchar"
+    ];
+}

+ 26 - 11
app/index/controller/Article.php

@@ -11,15 +11,15 @@ namespace app\index\controller;
 
 
 // 引入框架内置类
 // 引入框架内置类
 use think\facade\View;
 use think\facade\View;
+use think\exception\HttpException;
 
 
 use app\common\model\Category as CategoryModel;
 use app\common\model\Category as CategoryModel;
 use app\common\model\Article as ArticleModel;
 use app\common\model\Article as ArticleModel;
 use app\common\model\ArticleTags as ArticleTagsModel;
 use app\common\model\ArticleTags as ArticleTagsModel;
-use think\exception\HttpException;
+use app\common\model\ArticleDolikeLog;
 
 
 /**
 /**
  * 文章管理  
  * 文章管理  
-
  */
  */
 class Article extends Base
 class Article extends Base
 {
 {
@@ -40,7 +40,8 @@ class Article extends Base
             'limit' => $list->listRows(),
             'limit' => $list->listRows(),
             'page' => $list->currentPage(),
             'page' => $list->currentPage(),
             'lastPage' => $list->lastPage(),
             'lastPage' => $list->lastPage(),
-            'pagelist' => $list->render()
+            'pagelist' => $list->render(),
+            'cid' => $params['cid']
         ]);
         ]);
 
 
         return View::fetch();
         return View::fetch();
@@ -63,10 +64,6 @@ class Article extends Base
 
 
         $prev_next = ArticleModel::getNextPrev($id, $data->cid);
         $prev_next = ArticleModel::getNextPrev($id, $data->cid);
 
 
-        View::assign('cid', $data->cid);
-        View::assign('data', $data);
-        View::assign('prev_next', $prev_next);
-
         if ($data->content_type==1) {
         if ($data->content_type==1) {
             $parsedownExtension = new \ParsedownExtension();
             $parsedownExtension = new \ParsedownExtension();
             // $parsedownExtension->setTocEnabled(true);
             // $parsedownExtension->setTocEnabled(true);
@@ -75,6 +72,10 @@ class Article extends Base
             $data->content = $res['content'];
             $data->content = $res['content'];
         }
         }
 
 
+        View::assign('cid', $data->cid);
+        View::assign('data', $data);
+        View::assign('prev_next', $prev_next);
+
         return View::fetch();
         return View::fetch();
     }
     }
 
 
@@ -83,14 +84,28 @@ class Article extends Base
      */
      */
     public function dolike()
     public function dolike()
     {
     {
-        $id = input('post.id');
+        $id = $this->request->post('id');
+
+        $ip = $this->request->ip();
+
+        $log = ArticleDolikeLog::where('aid', $id)->where('ip', $ip)->find();
+
+        if ($log) {
+            return ['code' => 1, 'msg'=>'多谢喜欢, 已经点过赞了'];
+        }
 
 
         $res = ArticleModel::where('id', $id)->inc('likes')->update();
         $res = ArticleModel::where('id', $id)->inc('likes')->update();
 
 
+        // 记录 dolike 日志
+        @ArticleDolikeLog::create([
+            'aid' => $id,
+            'ip' => $this->request->ip()
+        ]);
+
         if ($res===false) {
         if ($res===false) {
-            return ['code' => 2];
+            return ['code' => 2, 'msg'=>'未知错误'];
         } else {
         } else {
-            return ['code' => 0, 'msg'=>'未知错误'];
+            return ['code' => 0];
         }
         }
     }
     }
 
 
@@ -139,7 +154,7 @@ class Article extends Base
      */
      */
     public function time()
     public function time()
     {
     {
-        $list =ArticleModel::field('id,cid,title,titlepic,username,summary,hits,sorts,status,create_time')->with(['category'])->order('update_time desc')->paginate();
+        $list =ArticleModel::field('id,cid,title,titlepic,username,summary,hits,sort,status,create_time')->with(['category'])->order('update_time desc')->paginate();
 
 
         View::assign('list', $list);
         View::assign('list', $list);
 
 

+ 4 - 1
app/index/controller/Base.php

@@ -71,11 +71,14 @@ abstract class Base
 
 
         $time_lists = Article::createTimeArchive();
         $time_lists = Article::createTimeArchive();
 
 
+        $last_lists = Article::getListByCid(0, 9);
+
         View::assign([
         View::assign([
             'cate_lists' => $cate_lists,
             'cate_lists' => $cate_lists,
             'hits_lists' => $hits_lists,
             'hits_lists' => $hits_lists,
             'top_lists'  => $top_lists,
             'top_lists'  => $top_lists,
-            'time_lists' => $time_lists
+            'time_lists' => $time_lists,
+            'last_lists' => $last_lists,
         ]);
         ]);
     }
     }
 }
 }

+ 3 - 3
app/index/controller/Index.php

@@ -52,8 +52,8 @@ class Index extends Base
 
 
     public function guestBook()
     public function guestBook()
     {
     {
-        $data = GuestBook::getGuestBooks();
-        View::assign('data', $data);
+        $list = GuestBook::paginate();
+        View::assign('list', $list);
 
 
         return View::fetch();
         return View::fetch();
     }
     }
@@ -91,6 +91,6 @@ class Index extends Base
             return View::fetch('error');
             return View::fetch('error');
         }
         }
 
 
-        $this->redirect(url('blog/index/guestbook'), 302);
+        return redirect((string)url('index/guestbook'), 302);
     }
     }
 }
 }

+ 1 - 1
app/index/route/app.php

@@ -27,7 +27,7 @@ Route::get('think', function () {
 });
 });
 
 
 Route::view('/404', '404');
 Route::view('/404', '404');
-Route::get('/all', 'index/article/index');
+Route::get('/all', 'index/article/index')->append(['cid' => 0]);
 Route::get('/:year/:month/:day/:id', 'index/article/read');
 Route::get('/:year/:month/:day/:id', 'index/article/read');
 Route::get('/:year/:month', 'index/article/archive');
 Route::get('/:year/:month', 'index/article/archive');
 Route::post('/dolike', 'index/article/dolike');
 Route::post('/dolike', 'index/article/dolike');

+ 6 - 5
app/sys/controller/Base.php

@@ -372,7 +372,8 @@ abstract class Base
     public function delete($id)
     public function delete($id)
     {
     {
         if (Request::isPost()) {
         if (Request::isPost()) {
-            if ($this->modelName::destroy($id)) {
+            $model = '\app\common\model\\' . $this->modelName;
+            if ($model ::destroy($id)) {
                 return ['code' => 1,'msg'=>'删除成功'];
                 return ['code' => 1,'msg'=>'删除成功'];
             } else {
             } else {
                 return ['code' => 0,'msg'=>'删除失败'];
                 return ['code' => 0,'msg'=>'删除失败'];
@@ -386,17 +387,17 @@ abstract class Base
         if (Request::isPost()) {
         if (Request::isPost()) {
             $param  = Request::param();
             $param  = Request::param();
 
 
-            $model = 'app\common\model\\' . $this->modelName;
+            $model = '\app\common\model\\' . $this->modelName;
 
 
-            return $model::sort($param);
+            return $model::sorts($param);
         }
         }
     }
     }
 
 
     // 状态变更
     // 状态变更
-    public function state(string $id)
+    public function status(string $id)
     {
     {
         if (Request::isPost()) {
         if (Request::isPost()) {
-            $model = 'app\common\model\\' . $this->modelName;
+            $model = '\app\common\model\\' . $this->modelName;
             return $model::state($id);
             return $model::state($id);
         }
         }
     }
     }

+ 59 - 0
app/sys/controller/GuestBook.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace app\sys\controller;
+
+use think\facade\View;
+use app\common\model\GuestBook as GuestBookModel;
+
+class GuestBook extends Base
+{
+    protected $modelName = "GuestBook";
+
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $list = GuestBookModel::order('id desc')->paginate();
+
+        View::assign('list', $list);
+
+        return View::fetch();
+    }
+
+    /**
+     * 状态修改 1,正常; 0,非正常
+     */
+    public static function mark($id)
+    {
+        try {
+            $info       = GuestBookModel::find($id);
+            $info->mark = 1 - $info['mark'];
+            $info->save();
+            return json(['code' => 0, 'msg' => '修改成功!', 'mark'=>$info->mark]);
+        } catch (\Exception $e) {
+            return json(['code' => 1, 'msg' => $e->getMessage()]);
+        }
+    }
+
+    /**
+     * 保存备注
+     * @param  int  $id
+     * @param  string  $remark
+     * @return \think\Response\Json 
+     * 
+     */
+    public function remark($id = 0, $remark = '')
+    {
+        try {
+            $info         = GuestBookModel::find($id);
+            $info->remark = $remark;
+            $info->save();
+            return json(['code' => 0, 'msg' => '修改成功!']);
+        } catch (\Exception $e) {
+            return json(['code' => 1, 'msg' => $e->getMessage()]);
+        }
+    }
+}

+ 18 - 17
view/index/article/index.html

@@ -1,16 +1,10 @@
 <div class="box">
 <div class="box">
-  <!-- <div class="place">
-
-      <a href="/jstt/bj/" target="_blank" id="pagecurrent">心得笔记</a>
-
-      <a href="/jstt/css3/" target="_blank">CSS3|Html5</a>
-
-      <a href="/jstt/web/" target="_blank">网站建设</a>
-
-      <a href="/news/jsex/" target="_blank">JS经典实例</a>
-
-      <a href="/jstt/t/" target="_blank">推荐工具</a>
-  </div> -->
+  <div class="place">
+    <a href="/index/all" class="{$cid==0 ? 'current_category': ''}">All</a>
+    {foreach $cate_lists as $value}
+    <a href="/index/{$value.url}" class="{$cid==$value.id ? 'current_category': ''}">{$value.name}</a>
+    {/foreach}
+  </div>
   <div class="blank"></div>
   <div class="blank"></div>
   <div class="blogs">
   <div class="blogs">
     {foreach $list as $val}
     {foreach $list as $val}
@@ -31,19 +25,26 @@
     <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
     <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
     {/lt}
     {/lt}
     <div class="pagelist">
     <div class="pagelist">
-      <a title="Total record">共&nbsp;<b>{$lastPage}</b>页</a>&nbsp;&nbsp;&nbsp;
+      <a title="Total record">共&nbsp;<b>{$lastPage}</b>&nbsp;页</a>&nbsp;&nbsp;&nbsp;
       {neq name="page" value="1"}
       {neq name="page" value="1"}
       <a href="{$baseUrl}">首页</a>
       <a href="{$baseUrl}">首页</a>
       <a href="{$baseUrl}?page={$page - 1}">上一页</a>&nbsp;
       <a href="{$baseUrl}?page={$page - 1}">上一页</a>&nbsp;
       {/neq}
       {/neq}
       <b>{$page}</b>&nbsp;
       <b>{$page}</b>&nbsp;
-      {neq name="page" value="$lastPage"}
+      {if ( $lastPage != 0) && ( $lastPage != $page) }
       <a href="{$baseUrl}?page={$page + 1}">下一页</a>&nbsp;
       <a href="{$baseUrl}?page={$page + 1}">下一页</a>&nbsp;
       <a href="{$baseUrl}?page={$lastPage}">尾页</a>
       <a href="{$baseUrl}?page={$lastPage}">尾页</a>
-      {/neq}
-      <input type="number" min="1" max="{$lastPage}">
+      {/if}
+      <input type="number" min="1" max="{$lastPage}" name="topage">
       <a href="javascript:goto()">转到</a>
       <a href="javascript:goto()">转到</a>
     </div>
     </div>
   </div>
   </div>
   {include file="aside"}
   {include file="aside"}
-</div>
+</div>
+
+<script>
+  function goto() {
+    var page = $("input[name='topage']").val();
+    window.location.href = "{$baseUrl}?page=" + page;
+  }
+</script>

+ 7 - 7
view/index/article/read.html

@@ -7,16 +7,16 @@
       <h3 class="news_title">{$data.title}</h3>
       <h3 class="news_title">{$data.title}</h3>
       <div class="bloginfo">
       <div class="bloginfo">
         <ul>
         <ul>
-          <li class="author"><a href="/{$data.category_url}"> {$data.category_name} </a></li>
+          <li class="author"><a href="/index/{$data.category_url}"> {$data.category_name} </a></li>
           <li class="timer">{$data.create_time}</li>
           <li class="timer">{$data.create_time}</li>
           <li class="view">{$data.hits} 已阅读</li>
           <li class="view">{$data.hits} 已阅读</li>
-          <li class="like">{$data.likes}</li>
+          <li class="like">{$data.likes} 点赞</li>
         </ul>
         </ul>
       </div>
       </div>
       <div class="tags">
       <div class="tags">
         {php}$tags = explode(',',$data->keywords);{/php}
         {php}$tags = explode(',',$data->keywords);{/php}
         {foreach $tags as $value}
         {foreach $tags as $value}
-        <a href="/tags/{$value}"  rel="tag" data-wpel-link="internal">{$value}</a> &nbsp;
+        <a href="/index/tags/{$value}"  rel="tag" data-wpel-link="internal">{$value}</a> &nbsp;
         {/foreach}
         {/foreach}
       </div>
       </div>
       <div class="news_about"><strong>简介</strong>{$data.summary}</div>
       <div class="news_about"><strong>简介</strong>{$data.summary}</div>
@@ -29,13 +29,13 @@
       {empty name="prev_next.prev"}
       {empty name="prev_next.prev"}
       <p>上一篇:<a >没有了</a></p>
       <p>上一篇:<a >没有了</a></p>
       {else}
       {else}
-      <p>上一篇:<a href="/read/{$prev_next['prev']['id']}" title="{$prev_next.prev.title}">{$prev_next.prev.title}</a></p>
+      <p>上一篇:<a href="/index/{$prev_next['prev']['create_time']|date='Y/m/d'}/{$prev_next['prev']['id']}" title="{$prev_next.prev.title}">{$prev_next.prev.title}</a></p>
       {/empty}
       {/empty}
       {empty name="prev_next.next"}
       {empty name="prev_next.next"}
-      <p>下一篇:<a href="/{$data.category_url}">返回列表</a></p>
+      <p>下一篇:<a href="/index/{$data.category_url}">返回列表</a></p>
       {else}
       {else}
       <p>下一篇:<a
       <p>下一篇:<a
-          href="/read/{$prev_next['next']['id']}"
+          href="/index/{$prev_next['prev']['create_time']|date='Y/m/d'}/{$prev_next['next']['id']}"
           title="{$prev_next.next.title}">{$prev_next.next.title}</a></p>
           title="{$prev_next.next.title}">{$prev_next.next.title}</a></p>
       {/empty}
       {/empty}
     </div>
     </div>
@@ -68,7 +68,7 @@
 
 
   function getLike(id) {
   function getLike(id) {
     var num = parseInt($('#diggnum').text());
     var num = parseInt($('#diggnum').text());
-    $.post('/dolike', {
+    $.post('/index/dolike', {
       'id': id
       'id': id
     }, function (res) {
     }, function (res) {
       if (res.code==0) {
       if (res.code==0) {

+ 9 - 3
view/index/aside.html

@@ -1,8 +1,14 @@
 <aside>
 <aside>
-  <div class="ztbox">
+  <!-- <div class="ztbox">
     <ul>
     <ul>
-      {foreach $cate_lists as $value}
-      <li><a href="/index/{$value.url}">{$value.name}</a></li>
+      <li><a href=""></a></li>
+    </ul>
+  </div> -->
+  <div class="paihang">
+    <h2>最近更新</h2>
+    <ul>
+      {foreach $last_lists as $value}
+      <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
       {/foreach}
       {/foreach}
     </ul>
     </ul>
   </div>
   </div>

+ 12 - 16
view/index/index/guestbook.html → view/index/index/guest_book.html

@@ -112,23 +112,23 @@ ul.pager li:last-child{
   <!-- #respond -->
   <!-- #respond -->
   <div id="respond" class="comment-respond">
   <div id="respond" class="comment-respond">
     <h3 id="reply-title" class="comment-reply-title">Leave a Reply</h3>
     <h3 id="reply-title" class="comment-reply-title">Leave a Reply</h3>
-    <form action="{:url('blog/index/saveguestbook')}" method="post" id="commentform" class="comment-form" novalidate="">
+    <form action="{:url('index/index/saveguestbook')}" method="post" id="commentform" class="comment-form" novalidate="">
       <p class="comment-notes"><span id="email-notes">我会妥善保存你的邮箱哒(`・ω・´).</span> 必填项已标记<span class="required">*</span></p>
       <p class="comment-notes"><span id="email-notes">我会妥善保存你的邮箱哒(`・ω・´).</span> 必填项已标记<span class="required">*</span></p>
       <p class="comment-form-comment">
       <p class="comment-form-comment">
-        <label for="comment">Comment</label>
-        <textarea required="" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea>
+        <label for="comment">Comment*</label>
+        <textarea required="" id="content" name="content" cols="45" rows="8" aria-required="true"></textarea>
       </p>
       </p>
       <p class="comment-form-author">
       <p class="comment-form-author">
         <label for="author">Name*</label>
         <label for="author">Name*</label>
-        <input id="author" name="author" type="text" placeholder="Jane Doe" value="" size="26">
+        <input id="Name" name="Name" type="text" placeholder="Jane Doe" value="" size="26">
       </p>
       </p>
       <p class="comment-form-email">
       <p class="comment-form-email">
-        <label for="email">Email*</label>
-        <input id="email" name="email" type="email" placeholder="name@email.com" value="" size="26">
+        <label for="contact">contact*</label>
+        <input id="contact" name="contact" type="text" placeholder="name@email.com or 13355556666" value="" size="26">
       </p>
       </p>
       <p class="comment-form-url">
       <p class="comment-form-url">
-        <label for="url">Website</label>
-        <input id="url" name="url" type="url" placeholder="http://google.com" value="" size="26">
+        <label for="url">url</label>
+        <input id="url" name="url" type="text" placeholder="https://www.google.com" value="" size="26">
       </p>
       </p>
       <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment">
       <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Comment">
         <!-- <input type="hidden" name="comment_post_ID" value="23" id="comment_post_ID">
         <!-- <input type="hidden" name="comment_post_ID" value="23" id="comment_post_ID">
@@ -138,20 +138,16 @@ ul.pager li:last-child{
   </div><!-- #respond end-->
   </div><!-- #respond end-->
   <div class="blank"></div>
   <div class="blank"></div>
   <div class="guestbook">
   <div class="guestbook">
-    {foreach $data as $val}
+    {foreach $list as $val}
     <div class="bloglist">
     <div class="bloglist">
       <div>
       <div>
-        <h2>{$val.author} <span>{$val.time|date="Y/m/d", ###}</span></h2>
+        <h2>{$val.name} <span>{$val.time|date="Y/m/d"}</span></h2>
       </div>
       </div>
-      <p>{$val.comment}</p>
+      <p>{$val.content}</p>
     </div>
     </div>
     {/foreach}
     {/foreach}
-    {php}$counts = count($data);{/php}
-    {lt name="counts" value="15"}
-    <p style="text-align: center;">全都给你了, 没有更多啦(╥╯^╰╥).</p>
-    {/lt}
     <div class="pagelist">
     <div class="pagelist">
-      {$data->render()}
+      {$list->render()}
     </div>
     </div>
   </div>
   </div>
 </div>
 </div>

+ 40 - 8
view/index/index/index.html

@@ -1,19 +1,19 @@
 <div class="box">
 <div class="box">
   <!-- PHP -->
   <!-- PHP -->
   <div class="newsbox f_l ">
   <div class="newsbox f_l ">
-    <div class="newstitle"><span><a href="/php">+</a></span><b>PHP</b></div>
+    <div class="newstitle"><span><a href="/index/php">+</a></span><b>PHP</b></div>
     <ul class="newsli">
     <ul class="newsli">
       {foreach $php_data as $val}
       {foreach $php_data as $val}
-      <li><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
+      <li><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
       {/foreach}
       {/foreach}
     </ul>
     </ul>
   </div>
   </div>
   <!-- notes_data -->
   <!-- notes_data -->
   <div class="newsbox f_r ">
   <div class="newsbox f_r ">
-    <div class="newstitle"><span><a href="/all">+</a></span><b>其他</b></div>
+    <div class="newstitle"><span><a href="/index/all">+</a></span><b>其他</b></div>
     <ul class="newsli">
     <ul class="newsli">
       {foreach $other_data as $val}
       {foreach $other_data as $val}
-      <li><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
+      <li><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></li>
 
 
       {/foreach}
       {/foreach}
     </ul>
     </ul>
@@ -22,7 +22,7 @@
   <!-- top -->
   <!-- top -->
   {foreach $top_data as  $key=> $val}
   {foreach $top_data as  $key=> $val}
   <div class="sbox  {switch name='key'}{case value='1'}f_l ml{/case}{case value='2'}f_r{/case}{default /}f_l{/switch}"> <span>{$val.category_name}</span>
   <div class="sbox  {switch name='key'}{case value='1'}f_l ml{/case}{case value='2'}f_r{/case}{default /}f_l{/switch}"> <span>{$val.category_name}</span>
-    <h2><a href="/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+    <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
     <p>{$val.summary}</p>
     <p>{$val.summary}</p>
   </div>
   </div>
   {/foreach}
   {/foreach}
@@ -31,10 +31,10 @@
   <div class="blogs">
   <div class="blogs">
     {foreach $all_data as $val}
     {foreach $all_data as $val}
     <div class="bloglist">
     <div class="bloglist">
-      <h2><a href="/read/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
+      <h2><a href="/index/{$val.create_time|date='Y/m/d'}/{$val.id}" title="{$val.title}">{$val.title}</a></h2>
       <div class="bloginfo">
       <div class="bloginfo">
         <ul>
         <ul>
-          <li class="author"><a href="/{$val.category_url}"> {$val.category_name} </a></li>
+          <li class="author"><a href="/index/{$val.category_url}"> {$val.category_name} </a></li>
           <li class="timer">{$val.create_time}</li>
           <li class="timer">{$val.create_time}</li>
           <li class="view">{$val.hits} 已阅读</li>
           <li class="view">{$val.hits} 已阅读</li>
           <li class="like">{$val.likes}</li>
           <li class="like">{$val.likes}</li>
@@ -44,5 +44,37 @@
     </div>
     </div>
     {/foreach}
     {/foreach}
   </div>
   </div>
-  {include file="aside"}
+  <aside>
+    <div class="ztbox">
+      <ul>
+        {foreach $cate_lists as $value}
+        <li><a href="/index/{$value.url}">{$value.name}</a></li>
+        {/foreach}
+      </ul>
+    </div>
+    <div class="paihang">
+      <h2>点击排行</h2>
+      <ul>
+        {foreach $hits_lists as $value}
+        <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+        {/foreach}
+      </ul>
+    </div>
+    <div class="paihang">
+      <h2>博文推荐</h2>
+      <ul>
+        {foreach $top_lists as $value}
+        <li><a href="/index/{$value.create_time|date='Y/m/d'}/{$value.id}" title="{$value.title}">{$value.title}</a></li>
+        {/foreach}
+      </ul>
+    </div>
+    <!-- <div class="paihang">
+      <h2>友情链接</h2>
+      <ul>
+        <li><a href="{//$Think.config.url_2048_root}">2048之陈小发</a></li>
+        <li><a href="{//$Think.config.url_blog_root}">huwhois个人博客</a></li>
+        <li><a href="{//$Think.config.url_1219_root}">1219fun</a></li>
+      </ul>
+    </div> -->
+  </aside>
 </div>
 </div>

+ 1 - 1
view/sys/article/index.html

@@ -63,7 +63,7 @@
                     <td>{$val.username}</td>
                     <td>{$val.username}</td>
                     <td>{$val.update_time}</td>
                     <td>{$val.update_time}</td>
                     <td>{$val.hits}</td>
                     <td>{$val.hits}</td>
-                    <td><input type="text" class="input-text input-sort" value="{$val.sorts}" data-id="{$val.id}"
+                    <td><input type="text" class="input-text input-sort" value="{$val.sort}" data-id="{$val.id}"
                             style="text-align: center;"></td>
                             style="text-align: center;"></td>
                     <td class="td-status">
                     <td class="td-status">
                         {if $val.status == 1}
                         {if $val.status == 1}

+ 2 - 2
view/sys/article/save.html

@@ -114,7 +114,7 @@
             <label class="form-label col-xs-2 col-sm-2">
             <label class="form-label col-xs-2 col-sm-2">
                 排序:</label>
                 排序:</label>
             <div class="formControls col-xs-4 col-sm-2">
             <div class="formControls col-xs-4 col-sm-2">
-                <input type="number" class="input-text" value="{$data.sorts}" id="sorts" name="sorts"
+                <input type="number" class="input-text" value="{$data.sort}" id="sort" name="sort"
                     style="width: 120px;">
                     style="width: 120px;">
             </div>
             </div>
         </div>
         </div>
@@ -155,7 +155,7 @@
                 ,summary: {
                 ,summary: {
                     maxlength: 500,
                     maxlength: 500,
                 }
                 }
-                ,sorts: {
+                ,sort: {
                     max: 99
                     max: 99
                 }
                 }
                 ,cid : {
                 ,cid : {

+ 2 - 2
view/sys/article/savemd.html

@@ -268,7 +268,7 @@
             <label class="form-label col-xs-2 col-sm-2">
             <label class="form-label col-xs-2 col-sm-2">
                 排序:</label>
                 排序:</label>
             <div class="formControls col-xs-4 col-sm-2">
             <div class="formControls col-xs-4 col-sm-2">
-                <input type="number" class="input-text" value="{$data.sorts}" id="sorts" name="sorts"
+                <input type="number" class="input-text" value="{$data.sort}" id="sort" name="sort"
                     style="width: 120px;">
                     style="width: 120px;">
             </div>
             </div>
         </div>
         </div>
@@ -582,7 +582,7 @@
                 , summary: {
                 , summary: {
                     maxlength: 500,
                     maxlength: 500,
                 }
                 }
-                , sorts: {
+                , sort: {
                     max: 99
                     max: 99
                 }
                 }
                 , cid: {
                 , cid: {

+ 114 - 0
view/sys/guest_book/index.html

@@ -0,0 +1,114 @@
+<article class="cl pd-20" style="min-width: 900px;">
+    <div class="cl pd-5 bg-1 bk-gray mt-20">
+        <span class="l">
+            <a href="javascript:;" onclick="del_all()" class="btn btn-danger radius">
+                <i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
+        </span>
+        <span class="r">共有数据:<strong id="total">{notempty name="list"}{$list->total()}{else/}0{/notempty}</strong>
+            条</span>
+    </div>
+    <div id="edatalist">
+        <table class="table table-border table-bordered table-bg">
+            <thead>
+                <tr class="text-c">
+                    <th width="25">
+                        <input type="checkbox" value="" name="">
+                    </th>
+                    <th style="min-width: 40px;">ID</th>
+                    <th style="min-width: 80px;">名称</th>
+                    <th style="min-width: 100px;">电话</th>
+                    <th style="min-width: 360px;">留言内容</th>
+                    <th style="min-width: 120px;">时间</th>
+                    <th>标记</th>
+                    <th style="min-width: 200px;">备注</th>
+                    <th>操作</th>
+                </tr>
+            </thead>
+            <tbody>
+                {foreach $list as $val}
+                <tr class="text-c va-m">
+                    <td>
+                        <input type="checkbox" value="{$val.id}" name="checkbox[]">
+                    </td>
+                    <td>{$val.id}</td>
+                    <td>{$val.name}</td>
+                    <td>{$val.contact}</td>
+                    <td class="text-l">{$val.content}</td>
+                    <td>{$val.time|date="Y-m-d H:i:s"}</td>
+                    <td class="td-status">
+                        <a href="javascript:;" onclick="mark(this,'{$val.id}')" style="text-decoration: none;"
+                            title="{$val.mark==1? '重点' : ''}">
+                            <span class="f-20 c-primary"><i class="Hui-iconfont">{$val.mark==1?'&#xe601;' :
+                                    '&#xe677;'}</i></span></a>
+                    </td>
+                    <td><input type="text" class="input-text input-remark text-l" value="{$val.remark}"
+                            data-id="{$val.id}"></td>
+                    <td class="td-manage">
+                        <a href="javascript:;" title="删除" style="text-decoration:none" class="btn btn-danger radius"
+                            onClick="del(this,'{$val.id}')">
+                            <i class="Hui-iconfont">&#xe6e2;</i>
+                        </a>
+                    </td>
+                </tr>
+                {/foreach}
+            </tbody>
+        </table>
+    </div>
+    <div class="cl pd-5 bg-1 bk-gray mt-20 ">
+        <span class="r">{notempty name="list"}{$list->render()}{/notempty}</span>
+    </div>
+</article>
+
+<script>
+    // 改变状态
+    function mark(obj, id) {
+        $.post('mark', {
+            'id': id
+        }, function (res) {
+            if (res.code == 0) {
+                layer.msg(res.msg, {
+                    icon: 1,
+                    time: 1000
+                });
+                if (res.mark == 1) {
+                    var img_str = '<a href="javascript:;" onclick="mark(this,' + id + ')" style="text-decoration: none;" title="重点"><span class="f-20 c-primary"><i class="Hui-iconfont">&#xe601;</i></span></a>';
+                } else {
+                    var img_str = '<a href="javascript:;" onclick="mark(this,' + id + ')" style="text-decoration: none;" title=""><span class="f-20 c-primary"><i class="Hui-iconfont">&#xe677;</i></span></a>';
+                }
+                $(obj).parents('td.td-status').append(img_str);
+                $(obj).remove();
+            } else {
+                layer.msg(res.msg, {
+                    icon: 5,
+                    time: 1000
+                });
+                return false;
+            }
+        }, 'json');
+    }
+
+    // 备注
+    $(".input-remark").change(function () {
+        var remark = $(this).val();
+        var id = $(this).data('id');
+
+        console.log(id);
+        $.post('remark', {
+            'id': id,
+            'remark': remark
+        }, function (res) {
+            if (res.code == 0) {
+                layer.msg(res.msg, {
+                    icon: 1,
+                    time: 1000
+                });
+            } else {
+                layer.msg(res.msg, {
+                    icon: 5,
+                    time: 1000
+                });
+                return false;
+            }
+        }, 'json');
+    });
+</script>