From 7c38cb92e5661bdbd6c507589136ec94f75e037f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=80=E5=B3=B0?= <1feng.0595@gmail.com> Date: Thu, 1 Jun 2017 19:51:48 +0800 Subject: [PATCH] home --- app/Common/function.php | 63 ++++-- .../Controllers/Admin/ProductController.php | 138 ++++++------ .../Admin/ProducttypeController.php | 76 ++++--- app/Http/Controllers/Home/IndexController.php | 197 +++++++++++++++++- app/Http/Model/Arctype.php | 1 - app/Http/Model/Friendlink.php | 14 ++ app/Http/Model/Guestbook.php | 14 ++ app/Http/Model/Keyword.php | 14 ++ app/Http/Model/Page.php | 14 ++ app/Http/Model/Product.php | 43 ++++ app/Http/Model/ProductPic.php | 13 ++ app/Http/Model/ProductType.php | 26 +++ app/Http/Model/Searchword.php | 35 ++++ app/Http/Model/Slide.php | 12 ++ app/Http/Model/Sysconfig.php | 2 + app/Http/Model/Tagindex.php | 35 ++++ app/Http/Model/Taglist.php | 12 ++ app/Http/Model/User.php | 2 + app/Http/Model/UserRole.php | 2 + .../views/admin/common/leftmenu.blade.php | 2 +- resources/views/admin/product/add.blade.php | 16 +- resources/views/admin/product/edit.blade.php | 36 ++-- resources/views/admin/product/index.blade.php | 28 +-- .../views/admin/producttype/add.blade.php | 95 +++------ .../views/admin/producttype/edit.blade.php | 115 ++++------ .../views/admin/producttype/index.blade.php | 12 +- resources/views/home/common/footer.blade.php | 1 + resources/views/home/common/header.blade.php | 1 + resources/views/home/index/category.blade.php | 62 ++++++ .../views/home/index/category2.blade.php | 57 +++++ resources/views/home/index/detail.blade.php | 60 ++++++ resources/views/home/index/index.blade.php | 70 +++++++ resources/views/home/index/login.blade.php | 171 +++++++++++++++ resources/views/home/index/page.blade.php | 8 + resources/views/home/index/search.blade.php | 35 ++++ resources/views/home/index/sitemap.blade.php | 9 + resources/views/home/index/tag.blade.php | 62 ++++++ resources/views/home/index/tag2.blade.php | 58 ++++++ resources/views/home/index/tag3.blade.php | 57 +++++ resources/views/home/index/tags.blade.php | 7 + routes/web.php | 49 +++-- 41 files changed, 1393 insertions(+), 331 deletions(-) create mode 100644 app/Http/Model/Friendlink.php create mode 100644 app/Http/Model/Guestbook.php create mode 100644 app/Http/Model/Keyword.php create mode 100644 app/Http/Model/Page.php create mode 100644 app/Http/Model/Product.php create mode 100644 app/Http/Model/ProductPic.php create mode 100644 app/Http/Model/ProductType.php create mode 100644 app/Http/Model/Searchword.php create mode 100644 app/Http/Model/Slide.php create mode 100644 app/Http/Model/Tagindex.php create mode 100644 app/Http/Model/Taglist.php create mode 100644 resources/views/home/common/footer.blade.php create mode 100644 resources/views/home/common/header.blade.php create mode 100644 resources/views/home/index/category.blade.php create mode 100644 resources/views/home/index/category2.blade.php create mode 100644 resources/views/home/index/detail.blade.php create mode 100644 resources/views/home/index/index.blade.php create mode 100644 resources/views/home/index/login.blade.php create mode 100644 resources/views/home/index/page.blade.php create mode 100644 resources/views/home/index/search.blade.php create mode 100644 resources/views/home/index/sitemap.blade.php create mode 100644 resources/views/home/index/tag.blade.php create mode 100644 resources/views/home/index/tag2.blade.php create mode 100644 resources/views/home/index/tag3.blade.php create mode 100644 resources/views/home/index/tags.blade.php diff --git a/app/Common/function.php b/app/Common/function.php index 0ba542d..309204a 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -113,24 +113,59 @@ function get_wap_front_url(array $param) */ function arclist(array $param) { - $map=array(); - - if(isset($param['tuijian'])){$map['tuijian']=$param['tuijian'];} - if(isset($param['typeid'])){$map['typeid']=$param['typeid'];} - if(isset($param['image'])){$map['litpic']=array('NEQ','');} - if(isset($param['limit'])){$limit=$param['limit'];}else{if(isset($param['row'])){$limit="0,".$param['row'];}else{$limit='0,'.cms_pagesize;}} - if(isset($param['orderby'])){$orderby=$param['orderby'];}else{$orderby='id desc';} + $modelname = 'article'; + if(isset($param['table'])){$modelname = $param['table'];} + + $model = \DB::table($modelname); - if(isset($param['sql'])) - { - $Artlist = db("article")->field('body',true)->where($param['sql'])->order($orderby)->limit($limit)->select(); - } - else + $size = sysconfig('CMS_PAGESIZE');$page = 1;$skip = 0; + if(isset($param['limit'])){$limit=explode(',',$param['limit']); $skip = $limit[0]; $size = $limit[1];}else{if(isset($param['row'])){$size = $param['row'];}} // 参数格式:$param['limit'] = '2,10';$param['row'] = 10; + + //查询条件 + $where = function ($query) use ($param) { + if(isset($param['tuijian'])) + { + $query->where('tuijian', $param['tuijian']); + //$query->where('title', 'like', '%'.$_REQUEST['keyword'].'%'); + } + + if(isset($param['typeid'])) + { + $query->where('typeid', $param["typeid"]); + } + + if(isset($param['image'])) + { + $query->where('litpic', '<>', ''); + } + }; + + if(!empty($where)){$model = $model->where($where);} + + //排序 + if(isset($param['orderby'])) { - $Artlist = db("article")->field('body',true)->where($map)->order($orderby)->limit($limit)->select(); + $orderby = $param['orderby']; + + if(count($orderby) == count($orderby, 1)) + { + $model = $model->orderBy($orderby[0], $orderby[1]); + } + else + { + foreach($orderby as $row) + { + $model = $model->orderBy($row[0], $row[1]); + } + } } + + //要返回的字段 + if(isset($param['field'])){$model = $model->select(\DB::raw($param['field']));} + + if($skip==0){$skip = ($page-1)*$size;} - return $Artlist; + return object_to_array($model->skip($skip)->take($size)->get()); } /** diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 62db627..dc7e006 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -1,49 +1,55 @@ $value) + $res = ''; + $where = function ($query) use ($res) { + if(isset($_REQUEST["keyword"])) + { + $query->where('title', 'like', '%'.$_REQUEST['keyword'].'%'); + } + + if(isset($_REQUEST["typeid"]) && $_REQUEST["typeid"]!=0) + { + $query->where('typeid', $_REQUEST["typeid"]); + } + + if(isset($_REQUEST["id"])) + { + $query->where('typeid', $_REQUEST["id"]); + } + }; + + $posts = parent::pageList('product', $where); + foreach($posts as $key=>$value) { - $info = db('product_type')->field('content',true)->where("id=".$value['typeid'])->find(); - $value['typename'] = $info['typename']; - $posts[] = $value; + $info = DB::table('product_type')->select('typename')->where("id", $value->typeid)->first(); + $posts[$key]->typename = $info->typename; + $posts[$key]->body = ''; } - $this->assign('page',$prolist->render()); - $this->assign('posts',$posts); + $data['posts'] = $posts; - return $this->fetch(); + return view('admin.product.index', $data); } public function add() { - if(!empty($_GET["catid"])){$this->assign('catid',$_GET["catid"]);}else{$this->assign('catid',0);} + $data = []; + if(!empty($_GET["catid"])){$data['catid'] = $_GET["catid"];}else{$data['catid'] = 0;} - return $this->fetch(); + return view('admin.product.add', $data); } public function doadd() @@ -51,7 +57,7 @@ class Product extends Base $litpic="";if(!empty($_POST["litpic"])){$litpic = $_POST["litpic"];}else{$_POST['litpic']="";} //缩略图 if(empty($_POST["description"])){if(!empty($_POST["body"])){$_POST['description']=cut_str($_POST["body"]);}} //description $_POST['addtime'] = $_POST['pubdate'] = time(); //添加&更新时间 - $_POST['user_id'] = session('admin_user_info')['id']; // 发布者id + $_POST['user_id'] = $_SESSION['admin_user_info']['id']; // 发布者id //关键词 if(!empty($_POST["keywords"])) @@ -69,15 +75,16 @@ class Product extends Base } } + unset($_POST["_token"]); if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} - if(db('product')->insert($_POST)) + if(DB::table('product')->insert($_POST)) { - $this->success('添加成功!', FLADMIN.'/Product' , 1); + success_jump('添加成功!', route('admin_product')); } else { - $this->error('添加失败!请修改后重新添加', FLADMIN.'/Product/add' , 3); + error_jump('添加失败!请修改后重新添加'); } } @@ -85,10 +92,10 @@ class Product extends Base { if(!empty($_GET["id"])){$id = $_GET["id"];}else {$id="";}if(preg_match('/[0-9]*/',$id)){}else{exit;} - $this->assign('id',$id); - $this->assign('post',db('product')->where("id=$id")->find()); + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('product')->where('id', $id)->first(), 1); - return $this->fetch(); + return view('admin.product.edit', $data); } public function doedit() @@ -98,7 +105,7 @@ class Product extends Base $litpic="";if(!empty($_POST["litpic"])){$litpic = $_POST["litpic"];}else{$_POST['litpic']="";} //缩略图 if(empty($_POST["description"])){if(!empty($_POST["body"])){$_POST['description']=cut_str($_POST["body"]);}}//description $_POST['pubdate'] = time();//更新时间 - $_POST['user_id'] = session('admin_user_info')['id']; // 修改者id + $_POST['user_id'] = $_SESSION['admin_user_info']['id']; // 修改者id //关键词 if(!empty($_POST["keywords"])) @@ -116,66 +123,65 @@ class Product extends Base } } + unset($_POST["_token"]); if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} - if(db('product')->where("id=$id")->update($_POST)) + if(DB::table('product')->where('id', $id)->update($_POST)) { - $this->success('修改成功!', FLADMIN.'/Product' , 1); + success_jump('修改成功!', route('admin_product')); } else { - $this->error('修改失败!', FLADMIN.'/Product/edit?id='.$_POST["id"] , 3); + error_jump('修改失败!'); } } public function del() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{$this->error('删除失败!请重新提交',FLADMIN.'/Product' , 3);}if(preg_match('/[0-9]*/',$id)){}else{exit;} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(db('product')->where("id in ($id)")->delete()) + if(DB::table('product')->whereIn("id", explode(',', $id))->delete()) { - $this->success("$id ,删除成功", FLADMIN.'/Product' , 1); + success_jump("$id ,删除成功"); } else { - $this->error("$id ,删除失败!请重新提交", FLADMIN.'/Product', 3); + error_jump("$id ,删除失败!请重新提交"); } } //商品推荐 public function recommendarc() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{$this->error('删除失败!请重新提交',FLADMIN.'/Product' , 3);} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} $data['tuijian'] = 1; - - if(db('product')->where("id in ($id)")->update($data)) + if(DB::table('product')->whereIn("id", explode(',', $id))->update($data)) { - $this->success("$id ,推荐成功", FLADMIN.'/Product', 1); + success_jump("$id ,推荐成功"); } else { - $this->error("$id ,推荐失败!请重新提交", FLADMIN.'/Product', 3); + error_jump("$id ,推荐失败!请重新提交"); } } //商品是否存在 public function productexists() { - if(!empty($_GET["title"])) - { - $map['title'] = $_GET["title"]; - } - else - { - $map['title']=""; - } - - if(!empty($_GET["id"])) - { - $map['id'] = array('NEQ',$_GET["id"]); - } - - return db('product')->where($map)->count(); + $res = ''; + $where = function ($query) use ($res) { + if(isset($_REQUEST["title"])) + { + $query->where('title', $_REQUEST["title"]); + } + + if(isset($_REQUEST["id"])) + { + $query->where('id', '<>', $_REQUEST["id"]); + } + }; + + return DB::table("product")->where($where)->count(); } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/ProducttypeController.php b/app/Http/Controllers/Admin/ProducttypeController.php index 980656a..a170bd6 100644 --- a/app/Http/Controllers/Admin/ProducttypeController.php +++ b/app/Http/Controllers/Admin/ProducttypeController.php @@ -1,18 +1,20 @@ assign('catlist',tree(get_category('product_type',0))); - - return $this->fetch(); + $data['catlist'] = category_tree(get_category('product_type',0)); + return view('admin.producttype.index', $data); } public function add() @@ -21,18 +23,20 @@ class Producttype extends Base { $id = $_GET["reid"]; if(preg_match('/[0-9]*/',$id)){}else{exit;} + if($id!=0) { - $this->assign('postone',db("product_type")->field('content',true)->where("id=$id")->find()); + $data['postone'] = object_to_array(DB::table("product_type")->where('id', $id)->first(), 1); } - $this->assign('id',$id); + + $data['id'] = $id; } else { - $this->assign('id',0); + $data['id'] = 0; } - return $this->fetch(); + return view('admin.producttype.add', $data); } public function doadd() @@ -40,13 +44,16 @@ class Producttype extends Base if(isset($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['reid']=0;}else{$_POST['reid'] = $_POST["prid"];}unset($_POST["prid"]);}//父级栏目id $_POST['addtime'] = time();//添加时间 - if(db("product_type")->insert($_POST)) + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table("product_type")->insert($_POST)) { - $this->success('添加成功!', FLADMIN.'/Producttype' , 1); + success_jump('添加成功!', route('admin_producttype')); } else { - $this->error('添加失败!请修改后重新添加', FLADMIN.'/Producttype' , 3); + error_jump('添加失败!请修改后重新添加'); } } @@ -54,13 +61,13 @@ class Producttype extends Base { $id = $_GET["id"];if(preg_match('/[0-9]*/',$id)){}else{exit;} - $this->assign('id',$id); - $post = db("product_type")->where("id=$id")->find(); + $data['id'] = $id; + $post = object_to_array(DB::table("product_type")->where('id', $id)->first(), 1); $reid = $post['reid']; - if($reid!=0){$this->assign('postone',db("product_type")->where("id=$reid")->find());} - $this->assign('post',$post); + if($reid!=0){$data['postone'] = object_to_array(DB::table("product_type")->where('id', $reid)->first(), 1);} + $data['post'] = $post; - return $this->fetch(); + return view('admin.producttype.edit', $data); } public function doedit() @@ -68,47 +75,50 @@ class Producttype extends Base if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;} $_POST['addtime'] = time();//添加时间 - if(db("product_type")->where("id=$id")->update($_POST)) + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table("product_type")->where('id', $id)->update($_POST)) { - $this->success('修改成功!', FLADMIN.'/Producttype' , 1); + success_jump('修改成功!', route('admin_producttype')); } else { - $this->error('修改失败!请修改后重新添加', FLADMIN.'/Producttype/edit?id='.$_POST["id"] , 3); + error_jump('修改失败!请修改后重新添加'); } } public function del() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{$this->error('删除失败!请重新提交',FLADMIN.'/Producttype' , 3);} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(db("product_type")->where("reid=$id")->find()) + if(DB::table("product_type")->where('reid', $id)->first()) { - $this->error('删除失败!请先删除子分类', FLADMIN.'/Producttype', 3); + error_jump('删除失败!请先删除子分类'); } else { - if(db("product_type")->where("id=$id")->delete()) + if(DB::table("product_type")->where('id', $id)->delete()) { - if(db("product")->where("typeid=$id")->count()>0) //判断该分类下是否有商品,如果有把该分类下的商品也一起删除 + if(DB::table("product")->where('typeid', $id)->count()>0) //判断该分类下是否有商品,如果有把该分类下的商品也一起删除 { - if(db("product")->where("typeid=$id")->delete()) + if(DB::table("product")->where('typeid', $id)->delete()) { - $this->success('删除成功', FLADMIN.'/Producttype' , 1); + success_jump('删除成功'); } else { - $this->error('分类下的商品删除失败!', FLADMIN.'/Producttype', 3); + error_jump('分类下的商品删除失败!'); } } else { - $this->success('删除成功', FLADMIN.'/Producttype' , 1); + success_jump('删除成功'); } } else { - $this->error('删除失败!请重新提交', FLADMIN.'/Producttype', 3); + error_jump('删除失败!请重新提交'); } } } diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index 3382573..4dbe5d7 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -13,24 +13,199 @@ class IndexController extends CommonController parent::__construct(); } - public function index() + //首页 + public function index() { - $user = DB::table('article')->where('id', '1')->first(); - echo $user->title; - - //$Article = Article::find(1)->arctype; - //$Article = Article::find(1); - //$Article = Arctype::find(1)->article()->get()->toArray(); + return view('home.index.index'); + } + + //列表页 + public function category() + { + $cat=input('cat'); + $pagenow=input('page'); + + if(empty($cat) || !preg_match('/[0-9]+/',$cat)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;} + + if(cache("catid$cat")){$post=cache("catid$cat");}else{$post = db('arctype')->where("id=$cat")->find();if(empty($post)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;}cache("catid$cat",$post,2592000);} + $this->assign('post',$post); + + $subcat="";$sql=""; + $post2=db('arctype')->field('id')->where("reid=$cat")->select(); + if(!empty($post2)){foreach($post2 as $row){$subcat=$subcat."typeid=".$row["id"]." or ";}} + $subcat=$subcat."typeid=".$cat; + $sql=$subcat." or typeid2 in (".$cat.")";//echo $subcat2;exit; + $this->assign('sql',$sql); - //$comment = Article::find(1)->arctype()->first()->toArray(); - //echo $comment->arctype->typename; - //print_r($comment); + $counts=db("article")->where($sql)->count('id'); + if($counts>CMS_MAXARC){$counts=CMS_MAXARC;} + $pagesize=CMS_PAGESIZE;$page=0; + if($counts % $pagesize){//取总数据量除以每页数的余数 + $pages = intval($counts/$pagesize) + 1; //如果有余数,则页数等于总数据量除以每页数的结果取整再加一,如果没有余数,则页数等于总数据量除以每页数的结果 + }else{$pages = $counts/$pagesize;} + if(!empty($pagenow)){if($pagenow==1 || $pagenow>$pages){header("HTTP/1.0 404 Not Found");$this->error('您访问的页面不存在或已被删除!');exit;}$page = $pagenow-1;$nextpage=$pagenow+1;$previouspage=$pagenow-1;}else{$page = 0;$nextpage=2;$previouspage=0;} + $this->assign('page',$page); + $this->assign('pages',$pages); + $this->assign('counts',$counts); + $start=$page*$pagesize; - //dd($comment); + $this->assign('posts',arclist(array("sql"=>$sql,"limit"=>"$start,$pagesize"))); //获取列表 + $this->assign('pagenav',get_listnav(array("counts"=>$counts,"pagesize"=>$pagesize,"pagenow"=>$page+1,"catid"=>$cat))); //获取分页列表 + + if($post['templist']=='category2'){if(!empty($pagenow)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;}} + return $this->fetch($post['templist']); + return view('home.index.index'); } + + //文章详情页 + public function detail() + { + $id=input('id'); + if(empty($id) || !preg_match('/[0-9]+/',$id)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;} + + if(cache("detailid$id")){$post=cache("detailid$id");}else{$post = db('article')->where("id=$id")->find();if(empty($post)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;}$post['typename'] = db('arctype')->where("id=".$post['typeid'])->value('typename');cache("detailid$id",$post,2592000);} + if($post) + { + $cat=$post['typeid']; + $post['body']=ReplaceKeyword($post['body']); + if(!empty($post['writer'])){$post['writertitle']=$post['title'].' '.$post['writer'];} + + $this->assign('post',$post); + $this->assign('pre',get_article_prenext(array('aid'=>$post["id"],'typeid'=>$post["typeid"],'type'=>"pre"))); + } + else + { + $this->error('您访问的页面不存在或已被删除!', '/' , 3);exit; + } + + if(cache("catid$cat")){$post=cache("catid$cat");}else{$post = db('arctype')->where("id=$cat")->find();cache("catid$cat",$post,2592000);} + + return $this->fetch($post['temparticle']);return view('home.index.index'); + } + //标签详情页,共有3种显示方式,1正常列表,2列表显示文章,3显示描述 + public function tag() + { + $tag=input('tag'); + $pagenow=input('page'); + + if(empty($tag) || !preg_match('/[0-9]+/',$tag)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;} + + if(cache("tagid$tag")){$post=cache("tagid$tag");}else{$post = db('tagindex')->where("id=$tag")->find();cache("tagid$tag",$post,2592000);} + $this->assign('post',$post); + + $counts=db("taglist")->where("tid=$tag")->count('aid'); + if($counts>CMS_MAXARC){$counts=CMS_MAXARC;} + $pagesize=CMS_PAGESIZE;$page=0; + if($counts % $pagesize){//取总数据量除以每页数的余数 + $pages = intval($counts/$pagesize) + 1; //如果有余数,则页数等于总数据量除以每页数的结果取整再加一,如果没有余数,则页数等于总数据量除以每页数的结果 + }else{$pages = $counts/$pagesize;} + if(!empty($pagenow)){if($pagenow==1 || $pagenow>$pages){header("HTTP/1.0 404 Not Found");$this->error('您访问的页面不存在或已被删除!');exit;}$page = $pagenow-1;$nextpage=$pagenow+1;$previouspage=$pagenow-1;}else{$page = 0;$nextpage=2;$previouspage=0;} + $this->assign('page',$page); + $this->assign('pages',$pages); + $this->assign('counts',$counts); + $start=$page*$pagesize; + + $posts=db("taglist")->where("tid=$tag")->order('aid desc')->limit("$start,$pagesize")->select(); + foreach($posts as $row) + { + $aid[] = $row["aid"]; + } + $aid = isset($aid)?implode(',',$aid):""; + + if($aid!="") + { + if($post['template']=='tag2') + { + $this->assign('posts',arclist(array("sql"=>"id in ($aid)","orderby"=>"id desc","limit"=>"$pagesize","field"=>"title,body"))); //获取列表 + } + else + { + $this->assign('posts',arclist(array("sql"=>"id in ($aid)","orderby"=>"id desc","limit"=>"$pagesize"))); //获取列表 + } + } + else + { + $this->assign('posts',""); //获取列表 + } + + $this->assign('pagenav',get_listnav(array("counts"=>$counts,"pagesize"=>$pagesize,"pagenow"=>$page+1,"catid"=>$tag,"urltype"=>"tag"))); //获取分页列表 + + if($post['template']=='tag2' || $post['template']=='tag3'){if(!empty($pagenow)){$this->error('您访问的页面不存在或已被删除!', '/' , 3);exit;}} + return $this->fetch($post['template']); + return view('home.index.index'); + } + + //标签页 + public function tags() + { + return view('home.index.tags'); + } + + //搜索页 + public function search() + { + if(!empty($_GET["keyword"])) + { + $keyword = $_GET["keyword"]; //搜索的关键词 + if(strstr($keyword,"&")) exit; + + $map['title'] = array('LIKE',"%$keyword%"); + + $this->assign('posts',db("article")->field('body',true)->where($map)->order('id desc')->limit(30)->select()); + $this->assign('keyword',$keyword); + } + else + { + $this->error('请输入正确的关键词', '/' , 3);exit; + } + + return view('home.index.search'); + } + + //单页面 + public function page() + { + $id=input('id'); + + if(!empty($id) && preg_match('/[a-z0-9]+/',$id)) + { + $map['filename']=$id; + if(cache("pageid$id")){$post=cache("pageid$id");}else{$post = db('page')->where($map)->find();cache("pageid$id",$post,2592000);} + + if($post) + { + $this->assign('post',$post); + } + else + { + $this->error('您访问的页面不存在或已被删除!', '/' , 3);exit; + } + + } + else + { + $this->error('您访问的页面不存在或已被删除!', '/' , 3);exit; + } + + return view('home.index.'.$post['template']); + } + + //sitemap页面 + public function sitemap() + { + return $this->fetch(); + } + + //404页面 public function page404() { return view('home.404'); } + + //测试页面 + public function test() + { + return date("Y-m-d H:i:s",strtotime("2017-04")); + } } diff --git a/app/Http/Model/Arctype.php b/app/Http/Model/Arctype.php index b9fc78d..3ae0c9b 100644 --- a/app/Http/Model/Arctype.php +++ b/app/Http/Model/Arctype.php @@ -13,7 +13,6 @@ class Arctype extends Model * @var string */ protected $table = 'arctype'; - public $timestamps = false; /** * 表明模型是否应该被打上时间戳 diff --git a/app/Http/Model/Friendlink.php b/app/Http/Model/Friendlink.php new file mode 100644 index 0000000..ae5424c --- /dev/null +++ b/app/Http/Model/Friendlink.php @@ -0,0 +1,14 @@ +belongsTo(ProductType::class, 'typeid', 'id'); + } + +} diff --git a/app/Http/Model/ProductPic.php b/app/Http/Model/ProductPic.php new file mode 100644 index 0000000..f7ab507 --- /dev/null +++ b/app/Http/Model/ProductPic.php @@ -0,0 +1,13 @@ +hasMany(ProductType::class, 'typeid', 'id'); + } + +} diff --git a/app/Http/Model/Searchword.php b/app/Http/Model/Searchword.php new file mode 100644 index 0000000..afb16f5 --- /dev/null +++ b/app/Http/Model/Searchword.php @@ -0,0 +1,35 @@ +商品管理