diff --git a/.env.example b/.env.example index 0dbde09..70377b9 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,7 @@ DB_PORT=3306 DB_DATABASE=lqycms DB_USERNAME=root DB_PASSWORD=123456 +DB_PREFIX=fl_ BROADCAST_DRIVER=log CACHE_DRIVER=file diff --git a/app/Common/function.php b/app/Common/function.php index 47bbccc..f20087f 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -1,13 +1,17 @@ where($map)->field($field)->order($orderby)->limit($limit)->select(); + $model = \DB::table($modelname); + if($where!=''){$model = $model->where($where);} + if($orderby!=''){$model = $model->orderBy($orderby[0], $orderby[1]);} + if($field!='*'){$model = $model->select(\DB::raw($field));} + + $skip = ($page-1)*$size; + + return object_to_array($model->skip($skip)->take($size)->get()); } //pc前台栏目、标签、内容页面地址生成 @@ -18,17 +22,17 @@ function get_front_url($param='') if($param['type'] == 'list') { //列表页 - $url .= '/cat'.$param['catid'].'.html'; + $url .= '/cat'.$param['catid']; } else if($param['type'] == 'content') { //内容页 - $url .= '/cat'.$param['catid'].'/id'.$param['id'].'.html'; + $url .= '/p/'.$param['id']; } else if($param['type'] == 'tags') { //tags页面 - $url .= '/tag'.$param['tagid'].'.html'; + $url .= '/tag'.$param['tagid']; } else if($param['type'] == 'page') { @@ -40,24 +44,24 @@ function get_front_url($param='') } //wap前台栏目、标签、内容页面地址生成 -function murl(array $param) +function get_wap_front_url(array $param) { $url = ''; if($param['type'] == 'list') { //列表页 - $url .= '/cat'.$param['catid'].'.html'; + $url .= '/cat'.$param['catid']; } else if($param['type'] == 'content') { //内容页 - $url .= '/cat'.$param['catid'].'/id'.$param['id'].'.html'; + $url .= '/p/'.$param['id']; } else if($param['type'] == 'tags') { //tags页面 - $url .= '/tag'.$param['tagid'].'.html'; + $url .= '/tag'.$param['tagid']; } else if($param['type'] == 'page') { @@ -460,10 +464,10 @@ function typeinfo($typeid) } //根据栏目id获取该栏目下文章/商品的数量 -function catarcnum($typeid,$modelname='article') +function catarcnum($typeid, $modelname='article') { $map['typeid']=$typeid; - return db($modelname)->where($map)->count('id'); + return \DB::table($modelname)->where($map)->count('id'); } //根据Tag id获取该Tag标签下文章的数量 @@ -491,12 +495,13 @@ function imgmatch($url) } //将栏目列表生成数组 -function get_category($modelname,$parent_id=0,$pad=0) +function get_category($modelname, $parent_id=0, $pad=0) { $arr=array(); - $cats = db($modelname)->where("reid=$parent_id")->order('id asc')->select(); - + $temp = \DB::table($modelname)->where('reid', $parent_id)->orderBy('id', 'asc')->get(); + $cats = object_to_array($temp); + if($cats) { foreach($cats as $row)//循环数组 @@ -512,9 +517,10 @@ function get_category($modelname,$parent_id=0,$pad=0) } } -function tree($list,$pid=0) +function category_tree($list,$pid=0) { global $temp; + if(!empty($list)) { foreach($list as $v) @@ -523,10 +529,11 @@ function tree($list,$pid=0) //echo $v['id']; if(array_key_exists("child",$v)) { - tree($v['child'],$v['reid']); + category_tree($v['child'],$v['reid']); } } } + return $temp; } @@ -568,6 +575,39 @@ function taglist($id,$tagid=0) if($tags!=""){return db("tagindex")->where($tags)->select();} } +//读取动态配置 +function sysconfig($varname='') +{ + $sysconfig = cache('sysconfig'); + $res = ''; + + if(empty($sysconfig)) + { + cache()->forget('sysconfig'); + + $sysconfig = \App\Http\Model\Sysconfig::orderBy('id')->select('varname', 'value')->get()->toArray(); + + cache(['sysconfig' => $sysconfig], \Carbon\Carbon::now()->addMinutes(86400)); + } + + if($varname != '') + { + foreach($sysconfig as $row) + { + if($varname == $row['varname']) + { + $res = $row['value']; + } + } + } + else + { + $res = $sysconfig; + } + + return $res; +} + //获取https的get请求结果 function get_curl_data($c_url,$data='') { @@ -788,3 +828,85 @@ function dir_delete($dir) closedir($handle); return @rmdir($dir); } + +//对象转数组 +function object_to_array($object, $get=0) +{ + $res = ''; + if($get==0) + { + foreach($object as $key=>$value) + { + $res[$key] = (array)$value; + } + } + else + { + $res = (array)$object; + } + + return $res; +} + +/** + * 操作错误跳转的快捷方法 + * @access protected + * @param string $msg 错误信息 + * @param string $url 页面跳转地址 + * @param mixed $time 当数字时指定跳转时间 + * @return void + */ +function error_jump($msg='', $url='', $time=3) +{ + if ($url=='' && isset($_SERVER["HTTP_REFERER"])) + { + $url = $_SERVER["HTTP_REFERER"]; + } + + if(!headers_sent()) + { + header("Location:".route('admin_jump')."?error=$msg&url=$url&time=$time"); + exit(); + } + else + { + $str = ""; + exit($str); + } +} + +/** + * 操作成功跳转的快捷方法 + * @access protected + * @param string $msg 提示信息 + * @param string $url 页面跳转地址 + * @param mixed $time 当数字时指定跳转时间 + * @return void + */ +function success_jump($msg='', $url='', $time=1) +{ + if ($url=='' && isset($_SERVER["HTTP_REFERER"])) + { + $url = $_SERVER["HTTP_REFERER"]; + } + + if(!headers_sent()) + { + header("Location:".route('admin_jump')."?message=$msg&url=$url&time=$time"); + exit(); + } + else + { + $str = ""; + exit($str); + } +} + + + + + + + + + diff --git a/app/Http/Controllers/Admin/ArticleController.php b/app/Http/Controllers/Admin/ArticleController.php new file mode 100644 index 0000000..8e368d9 --- /dev/null +++ b/app/Http/Controllers/Admin/ArticleController.php @@ -0,0 +1,281 @@ +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"]); + } + + if(isset($_REQUEST["ischeck"])) + { + $query->where('ischeck', $_REQUEST["ischeck"]); //未审核过的文章 + } + }; + + $posts = parent::pageList('article', $where); + foreach($posts as $key=>$value) + { + $info = DB::table('arctype')->select('typename')->where("id", $value->typeid)->first(); + $posts[$key]->typename = $info->typename; + $posts[$key]->body = ''; + } + + $data['posts'] = $posts; + + return view('admin.article.index', $data); + + //if(!empty($_GET["id"])){$id = $_GET["id"];}else {$id="";}if(preg_match('/[0-9]*/',$id)){}else{exit;} + + /* if(!empty($id)){$map['typeid']=$id;} + $Article = M("Article")->field('id')->where($map); + $counts = $Article->count(); + + $pagesize =CMS_PAGESIZE;$page =0; + if($counts % $pagesize){ //取总数据量除以每页数的余数 + $pages = intval($counts/$pagesize) + 1; //如果有余数,则页数等于总数据量除以每页数的结果取整再加一,如果没有余数,则页数等于总数据量除以每页数的结果 + }else{$pages = $counts/$pagesize;} + if(!empty($_GET["page"])){$page = $_GET["page"]-1;$nextpage=$_GET["page"]+1;$previouspage=$_GET["page"]-1;}else{$page = 0;$nextpage=2;$previouspage=0;} + if($counts>0){if($page>$pages-1){exit;}} + $start = $page*$pagesize; + $Article = M("Article")->field('id,typeid,title,pubdate,click,litpic,tuijian')->where($map)->order('id desc')->limit($start,$pagesize)->select(); + + $this->counts = $counts; + $this->pages = $pages; + $this->page = $page; + $this->nextpage = $nextpage; + $this->previouspage = $previouspage; + $this->id = $id; + $this->posts = $Article; */ + + //echo '
'; + //print_r($Article); + //return $this->fetch(); + } + + public function add() + { + $data = ''; + if(!empty($_REQUEST["catid"])){$data['catid'] = $_REQUEST["catid"];}else{$data['catid'] = 0;} + + return view('admin.article.add', $data); + } + + public function doadd() + { + $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 + $content="";if(!empty($_POST["body"])){$content = $_POST["body"];} + $_POST['pubdate'] = time();//更新时间 + $_POST['addtime'] = time();//添加时间 + $_POST['user_id'] = $_SESSION['admin_user_info']['id']; // 发布者id + + //关键词 + if(!empty($_POST["keywords"])) + { + $_POST['keywords']=str_replace(",",",",$_POST["keywords"]); + } + else + { + if(!empty($_POST["title"])) + { + $title=$_POST["title"]; + $title=str_replace(",","",$title); + $title=str_replace(",","",$title); + $_POST['keywords']=get_keywords($title);//标题分词 + } + } + + if(isset($_POST["dellink"]) && $_POST["dellink"]==1 && !empty($content)){$content=replacelinks($content,array(sysconfig('CMS_BASEHOST')));} //删除非站内链接 + $_POST['body']=$content; + + //提取第一个图片为缩略图 + if(isset($_POST["autolitpic"]) && $_POST["autolitpic"] && empty($litpic)) + { + if(getfirstpic($content)) + { + //获取文章内容的第一张图片 + $imagepath = '.'.getfirstpic($content); + + //获取后缀名 + preg_match_all ("/\/(.+)\.(gif|jpg|jpeg|bmp|png)$/iU",$imagepath,$out, PREG_PATTERN_ORDER); + + $saveimage='./uploads/'.date('Y/m',time()).'/'.basename($imagepath,'.'.$out[2][0]).'-lp.'.$out[2][0]; + + //生成缩略图,按照原图的比例生成一个最大为240*180的缩略图 + \Intervention\Image\Facades\Image::make($imagepath)->resize(sysconfig('CMS_IMGWIDTH'), sysconfig('CMS_IMGHEIGHT'))->save($saveimage); + + //缩略图路径 + $_POST['litpic']='/uploads/'.date('Y/m',time()).'/'.basename($imagepath,'.'.$out[2][0]).'-lp.'.$out[2][0]; + } + } + + unset($_POST["dellink"]); + unset($_POST["autolitpic"]); + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + if(DB::table('article')->insert($_POST)) + { + success_jump("添加成功!"); + } + else + { + error_jump("添加失败!请修改后重新添加"); + } + } + + public function edit() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else {$id="";}if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('article')->where('id', $id)->first(), 1); + + return view('admin.article.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;} + $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 + $content="";if(!empty($_POST["body"])){$content = $_POST["body"];} + $_POST['pubdate'] = time();//更新时间 + $_POST['user_id'] = $_SESSION['admin_user_info']['id']; // 修改者id + + if(!empty($_POST["keywords"])) + { + $_POST['keywords']=str_replace(",",",",$_POST["keywords"]); + } + else + { + if(!empty($_POST["title"])) + { + $title=$_POST["title"]; + $title=str_replace(",","",$title); + $title=str_replace(",","",$title); + $_POST['keywords']=get_keywords($title);//标题分词 + } + } + + if(isset($_POST["dellink"]) && $_POST["dellink"]==1 && !empty($content)){$content=replacelinks($content,array(CMS_BASEHOST));} //删除非站内链接 + $_POST['body']=$content; + + //提取第一个图片为缩略图 + if(isset($_POST["autolitpic"]) && $_POST["autolitpic"] && empty($litpic)) + { + if(getfirstpic($content)) + { + //获取文章内容的第一张图片 + $imagepath = '.'.getfirstpic($content); + + //获取后缀名 + preg_match_all ("/\/(.+)\.(gif|jpg|jpeg|bmp|png)$/iU",$imagepath,$out, PREG_PATTERN_ORDER); + + $saveimage='./uploads/'.date('Y/m',time()).'/'.basename($imagepath,'.'.$out[2][0]).'-lp.'.$out[2][0]; + + //生成缩略图,按照原图的比例生成一个最大为240*180的缩略图 + \Intervention\Image\Facades\Image::make($imagepath)->resize(sysconfig('CMS_IMGWIDTH'), sysconfig('CMS_IMGHEIGHT'))->save($saveimage); + + //缩略图路径 + $_POST['litpic']='/uploads/'.date('Y/m',time()).'/'.basename($imagepath,'.'.$out[2][0]).'-lp.'.$out[2][0]; + } + } + + unset($_POST["dellink"]); + unset($_POST["autolitpic"]); + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + if(DB::table('article')->where('id', $id)->update($_POST)) + { + success_jump("修改成功!", route('admin_article')); + } + else + { + error_jump("修改失败!"); + } + } + + //删除文章 + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("删除失败!请重新提交");} + + if(DB::table("article")->whereIn("id", explode(',', $id))->delete()) + { + success_jump("$id ,删除成功"); + } + else + { + error_jump("$id ,删除失败!请重新提交"); + } + } + + + //重复文章列表 + public function repetarc() + { + $data['posts'] = object_to_array(DB::table('article')->select(DB::raw('title,count(*) AS count'))->orderBy('count', 'desc')->groupBy('title')->having('count', '>', 1)->get()); + + return view('admin.article.repetarc', $data); + } + + //推荐文章 + public function recommendarc() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("您访问的页面不存在或已被删除!");} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['tuijian'] = 1; + + if(DB::table("article")->whereIn("id", explode(',', $id))->update($data)) + { + success_jump("$id ,推荐成功"); + } + else + { + error_jump("$id ,推荐失败!请重新提交"); + } + } + + //检测重复文章数量 + public function articleexists() + { + $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("article")->where($where)->count(); + } +} diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php new file mode 100644 index 0000000..0a2d4c3 --- /dev/null +++ b/app/Http/Controllers/Admin/CategoryController.php @@ -0,0 +1,123 @@ +where('id', $id)->first(), 1); + } + + $data['id'] = $id; + } + else + { + $data['id'] = 0; + } + + return view('admin.category.add', $data); + } + + public function doadd() + { + if(!empty($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['reid']=0;}else{$_POST['reid'] = $_POST["prid"];}}//父级栏目id + $_POST['addtime'] = time();//添加时间 + unset($_POST["prid"]); + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table('arctype')->insert($_POST)) + { + success_jump('添加成功!'); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + public function edit() + { + $id = $_GET["id"];if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $post = object_to_array(DB::table('arctype')->where('id', $id)->first(), 1); + $reid = $post['reid']; + if($reid!=0){$data['postone'] = object_to_array(DB::table('arctype')->where('id', $reid)->first());} + + $data['post'] = $post; + + return view('admin.category.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + $_POST['addtime'] = time(); //添加时间 + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table('arctype')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_category')); + } + else + { + error_jump('修改失败!请修改后重新添加'); + } + } + + public function del() + { + if(!empty($_REQUEST["id"])){$id = $_REQUEST["id"];}else{error_jump('删除失败!请重新提交');} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + + if(DB::table('arctype')->where('reid', $id)->first()) + { + error_jump('删除失败!请先删除子栏目'); + } + else + { + if(DB::table('arctype')->where('id', $id)->delete()) + { + if(DB::table("article")->where('typeid', $id)->count()>0) //判断该分类下是否有文章,如果有把该分类下的文章也一起删除 + { + if(DB::table("article")->where('typeid', $id)->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('栏目下的文章删除失败!'); + } + } + else + { + success_jump('删除成功'); + } + } + else + { + error_jump('删除失败!请重新提交'); + } + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/CommonController.php b/app/Http/Controllers/Admin/CommonController.php new file mode 100644 index 0000000..9bcdde1 --- /dev/null +++ b/app/Http/Controllers/Admin/CommonController.php @@ -0,0 +1,54 @@ +user_info = $_SESSION['admin_user_info']; + } + else + { + header("Location:".route('page404')); + exit(); + } + } + + /** + * 获取分页数据及分页导航 + * @param string $modelname 模块名与数据库表名对应 + * @param array $map 查询条件 + * @param string $orderby 查询排序 + * @param string $field 要返回数据的字段 + * @param int $listRows 每页数量,默认10条 + * + * @return 格式化后输出的数据。内容格式为: + * - "code" (string):代码 + * - "info" (string):信息提示 + * + * - "result" array + * + * - "img_list" (array) :图片队列,默认8张 + * - "img_title" (string):车图名称 + * - "img_url" (string):车图片url地址 + * - "car_name" (string):车名称 + */ + public function pageList($modelname, $map = '', $orderby = '', $field = '', $listRows = 15) + { + $orderby = !empty($orderby) ? $orderby : $orderby = ['id', 'desc']; + + // 查询满足的数据,并且每页显示15条数据 + $voList = DB::table($modelname)->where($map)->orderBy($orderby[0], $orderby[1])->paginate($listRows); + + return $voList; + } +} diff --git a/app/Http/Controllers/Admin/IndexController.php b/app/Http/Controllers/Admin/IndexController.php new file mode 100644 index 0000000..e84331d --- /dev/null +++ b/app/Http/Controllers/Admin/IndexController.php @@ -0,0 +1,35 @@ + $username, 'pwd' => $pwd])->orWhere(['email' => $username, 'pwd' => $pwd])->first(); + + if($User) + { + $admin_user_info = $User->toArray(); + $admin_user_info['rolename'] = $User->userrole->rolename; + + $_SESSION['admin_user_info'] = $admin_user_info; + + $User->logintime = time(); + $User->save(); + + return redirect()->route('admin'); + } + else + { + return redirect()->route('admin_login'); + } + } + + //退出登录 + public function logout() + { + session_unset(); + session_destroy();// 退出登录,清除session + success_jump('退出成功!', route('home')); + } + + //密码恢复 + public function recoverpwd() + { + $data["username"] = "admin888"; + $data["pwd"] = "21232f297a57a5a743894a0e4a801fc3"; + + if(DB::table('user')->where('id', 1)->update($data)) + { + success_jump('密码恢复成功!', route('admin_login')); + } + else + { + error_jump('密码恢复失败!', route('home')); + } + } + + /** + * 判断用户名是否存在 + */ + public function userexists() + { + $map['username'] = ""; + if(isset($_POST["username"]) && !empty($_POST["username"])) + { + $map['username'] = $_POST["username"]; + } + else + { + return 0; + } + + return DB::table("user")->where($map)->count(); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/PageController.php b/app/Http/Controllers/Admin/PageController.php new file mode 100644 index 0000000..1da0b42 --- /dev/null +++ b/app/Http/Controllers/Admin/PageController.php @@ -0,0 +1,85 @@ +orderBy('id', 'desc')->get()); + return view('admin.page.index', $data); + } + + public function doadd() + { + $_POST['pubdate'] = time();//更新时间 + $_POST['click'] = rand(200,500);//点击 + + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table("page")->insert($_POST)) + { + success_jump('添加成功!'); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + public function add() + { + return view('admin.page.add'); + } + + public function edit() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('page')->where('id', $id)->first(), 1); + + return view('admin.page.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + $_POST['pubdate'] = time();//更新时间 + + unset($_POST["_token"]); + if(isset($_POST['editorValue'])){unset($_POST['editorValue']);} + + if(DB::table('page')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_page')); + } + else + { + error_jump('修改失败!请修改后重新添加'); + } + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("删除失败!请重新提交");} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + + if(DB::table('page')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump("删除失败!请重新提交"); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 03e02a2..29614ad 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,13 +1,47 @@ getActionName(); + list($class, $method) = explode('@', $action); + + return ['controller' => $class, 'method' => $method]; + } } diff --git a/app/Http/Controllers/Home/CommonController.php b/app/Http/Controllers/Home/CommonController.php new file mode 100644 index 0000000..1b4c96b --- /dev/null +++ b/app/Http/Controllers/Home/CommonController.php @@ -0,0 +1,12 @@ +middleware('guest')->except('logout'); + parent::__construct(); } public function index() { - dd('home/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(); + + //$comment = Article::find(1)->arctype()->first()->toArray(); + //echo $comment->arctype->typename; + //print_r($comment); + + //dd($comment); + } + + public function page404() + { + return view('home.404'); } } diff --git a/app/Http/Controllers/Wap/IndexController.php b/app/Http/Controllers/Wap/IndexController.php index 2be6b5f..e565cba 100644 --- a/app/Http/Controllers/Wap/IndexController.php +++ b/app/Http/Controllers/Wap/IndexController.php @@ -2,9 +2,9 @@ namespace App\Http\Controllers\Wap; -use App\Http\Controllers\Controller; +use App\Http\Controllers\CommonController; -class IndexController extends Controller +class IndexController extends CommonController { /** * Create a new controller instance. diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 66d34c3..ab5b0d1 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -56,5 +56,7 @@ class Kernel extends HttpKernel 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + + 'check.login' => \App\Http\Middleware\CheckLogin::class, ]; } diff --git a/app/Http/Middleware/CheckLogin.php b/app/Http/Middleware/CheckLogin.php new file mode 100644 index 0000000..bac1f0a --- /dev/null +++ b/app/Http/Middleware/CheckLogin.php @@ -0,0 +1,28 @@ +has('admin_user_info')) + { + redirect()->route('admin_login'); + } + else + { + + } + + return $next($request); + } +} diff --git a/app/Http/Model/Arctype.php b/app/Http/Model/Arctype.php new file mode 100644 index 0000000..b9fc78d --- /dev/null +++ b/app/Http/Model/Arctype.php @@ -0,0 +1,41 @@ +hasMany(Article::class, 'typeid', 'id'); + } + +} diff --git a/app/Http/Model/Article.php b/app/Http/Model/Article.php new file mode 100644 index 0000000..bfb6793 --- /dev/null +++ b/app/Http/Model/Article.php @@ -0,0 +1,61 @@ +isValid()) { + $newName = md5(rand(1, 1000) . $pic->getClientOriginalName()) . "." . $pic->getClientOriginalExtension(); + $pic->move('uploads', $newName); + return $newName; + } + } + return ''; + } + + /** + * 获取关联到文章的分类 + */ + public function arctype() + { + return $this->belongsTo(Arctype::class, 'typeid', 'id'); + } + +} diff --git a/app/Http/Model/Sysconfig.php b/app/Http/Model/Sysconfig.php new file mode 100644 index 0000000..c797ef9 --- /dev/null +++ b/app/Http/Model/Sysconfig.php @@ -0,0 +1,17 @@ +belongsTo(UserRole::class, 'role_id', 'id'); + } } diff --git a/app/Http/Model/UserRole.php b/app/Http/Model/UserRole.php new file mode 100644 index 0000000..9bcf321 --- /dev/null +++ b/app/Http/Model/UserRole.php @@ -0,0 +1,25 @@ +hasMany(User::class, 'role_id', 'id'); + } +} diff --git a/composer.json b/composer.json index 8b179bb..d07f250 100644 --- a/composer.json +++ b/composer.json @@ -6,10 +6,11 @@ "type": "project", "require": { "php": ">=5.6.4", + "intervention/image": "^2.3", "laravel/framework": "5.4.*", - "overtrue/laravel-wechat": "~3.1", - "maatwebsite/excel": "~2.1.0", - "laravel/tinker": "~1.0" + "laravel/tinker": "~1.0", + "maatwebsite/excel": "~2.1.0", + "overtrue/laravel-wechat": "~3.1" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index c00c639..186696b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "5fb27d16232b4890e5783a0fd2f70f79", + "content-hash": "2367b038aae2731238e00c910f6f6cc3", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -396,6 +396,68 @@ ], "time": "2017-03-20T17:10:46+00:00" }, + { + "name": "intervention/image", + "version": "2.3.13", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "15a517f052ee15d373ffa145c9642d5fec7ddf5c" + }, + "dist": { + "type": "zip", + "url": "https://files.phpcomposer.com/files/Intervention/image/15a517f052ee15d373ffa145c9642d5fec7ddf5c.zip", + "reference": "15a517f052ee15d373ffa145c9642d5fec7ddf5c", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "3.*" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@olivervogel.net", + "homepage": "http://olivervogel.net/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "time": "2017-04-23T18:45:36+00:00" + }, { "name": "jakub-onderka/php-console-color", "version": "0.1", diff --git a/config/app.php b/config/app.php index 135e977..e0bf9db 100644 --- a/config/app.php +++ b/config/app.php @@ -64,7 +64,7 @@ return [ | */ - 'timezone' => 'UTC', + 'timezone' => 'Asia/Shanghai', /* |-------------------------------------------------------------------------- @@ -162,6 +162,7 @@ return [ Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, + Intervention\Image\ImageServiceProvider::class, /* * Package Service Providers... @@ -225,6 +226,7 @@ return [ 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, + 'Image' => Intervention\Image\Facades\Image::class, //图片处理 ], diff --git a/config/custom.php b/config/custom.php new file mode 100644 index 0000000..8593a09 --- /dev/null +++ b/config/custom.php @@ -0,0 +1,12 @@ + [ + "0"=>"不推荐", + "1"=>"一级推荐", + "2"=>"二级推荐", + "3"=>"三级推荐", + "4"=>"四级推荐" + ], +]; diff --git a/config/database.php b/config/database.php index cab5d06..be4b663 100644 --- a/config/database.php +++ b/config/database.php @@ -49,7 +49,7 @@ return [ 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', + 'prefix' => env('DB_PREFIX', 'fl_'), 'strict' => true, 'engine' => null, ], diff --git a/public/index.php b/public/index.php index 1e1d775..607b53a 100644 --- a/public/index.php +++ b/public/index.php @@ -19,6 +19,8 @@ | */ +session_start(); //开启session + require __DIR__.'/../bootstrap/autoload.php'; /* diff --git a/resources/views/admin/article/add.blade.php b/resources/views/admin/article/add.blade.php new file mode 100644 index 0000000..26df9ba --- /dev/null +++ b/resources/views/admin/article/add.blade.php @@ -0,0 +1,164 @@ +发布文章_后台管理 @include('admin.common.header') +++ + + \ No newline at end of file diff --git a/resources/views/admin/article/edit.blade.php b/resources/views/admin/article/edit.blade.php new file mode 100644 index 0000000..2cebaa0 --- /dev/null +++ b/resources/views/admin/article/edit.blade.php @@ -0,0 +1,147 @@ +++ ++文章列表 > 发布文章
+ + +修改文章_后台管理 @include('admin.common.header') +++ + + \ No newline at end of file diff --git a/resources/views/admin/article/index.blade.php b/resources/views/admin/article/index.blade.php new file mode 100644 index 0000000..3145601 --- /dev/null +++ b/resources/views/admin/article/index.blade.php @@ -0,0 +1,115 @@ +++ ++文章列表 > 修改文章
+ + +文章列表_后台管理 @include('admin.common.header') +++ \ No newline at end of file diff --git a/resources/views/admin/article/repetarc.blade.php b/resources/views/admin/article/repetarc.blade.php new file mode 100644 index 0000000..00a83f6 --- /dev/null +++ b/resources/views/admin/article/repetarc.blade.php @@ -0,0 +1,26 @@ +++ +栏目管理 > 文章列表 [ ">发布文章 ]
+ +++ + + ++ +
++ + + + +ID +选择 +文章标题 +更新时间 +类目 点击 操作 ++ + +id; ?> ++ title; ?> litpic)){echo "[图]";}if($row->tuijian==1){echo "[荐]";} ?> +pubdate); ?> +typename; ?> click; ?> "content","catid"=>$row->typeid,"id"=>$row->id)); ?>">预览 修改 删除 ++ + ++ 反选 + 删除 + 特荐 + +{{ $posts->links() }}+ + + +重复文档列表_后台管理 @include('admin.common.header') + + \ No newline at end of file diff --git a/resources/views/admin/category/add.blade.php b/resources/views/admin/category/add.blade.php new file mode 100644 index 0000000..e56efd5 --- /dev/null +++ b/resources/views/admin/category/add.blade.php @@ -0,0 +1,145 @@ +添加栏目_后台管理 @include('admin.common.header') +++ + + \ No newline at end of file diff --git a/resources/views/admin/category/index.blade.php b/resources/views/admin/category/index.blade.php new file mode 100644 index 0000000..0d453df --- /dev/null +++ b/resources/views/admin/category/index.blade.php @@ -0,0 +1,21 @@ +++ ++栏目管理 > 栏目添加
+ + +栏目列表_后台管理 @include('admin.common.header') + + \ No newline at end of file diff --git a/resources/views/admin/common/header.blade.php b/resources/views/admin/common/header.blade.php new file mode 100644 index 0000000..128441a --- /dev/null +++ b/resources/views/admin/common/header.blade.php @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/resources/views/admin/common/leftmenu.blade.php b/resources/views/admin/common/leftmenu.blade.php new file mode 100644 index 0000000..f1d09de --- /dev/null +++ b/resources/views/admin/common/leftmenu.blade.php @@ -0,0 +1,26 @@ +
· 欢迎使用专业的PHP网站管理系统,轻松建站的首选利器,完全免费、开源、无授权限制。
+· LQYCMS采用PHP+Mysql架构,符合企业网站SEO优化理念、功能全面、安全稳定。
请输入您的用户名、密码:
+