diff --git a/app/Common/function.php b/app/Common/function.php index 581fab5..474ac1c 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -623,7 +623,7 @@ function get_category($modelname, $parent_id=0, $pad=0) { $arr=array(); - $temp = \DB::table($modelname)->where('reid', $parent_id)->orderBy('id', 'asc')->get(); + $temp = \DB::table($modelname)->where('pid', $parent_id)->orderBy('id', 'asc')->get(); $cats = object_to_array($temp); if($cats) @@ -649,11 +649,11 @@ function category_tree($list,$pid=0) { foreach($list as $v) { - $temp[] = array("id"=>$v['id'],"deep"=>$v['deep'],"typename"=>$v['typename'],"reid"=>$v['reid'],"typedir"=>$v['typedir'],"addtime"=>$v['addtime']); + $temp[] = array("id"=>$v['id'],"deep"=>$v['deep'],"name"=>$v['name'],"pid"=>$v['pid']); //echo $v['id']; if(array_key_exists("child",$v)) { - category_tree($v['child'],$v['reid']); + category_tree($v['child'],$v['pid']); } } } diff --git a/app/Http/Controllers/Admin/ArticleController.php b/app/Http/Controllers/Admin/ArticleController.php index 8e368d9..94b6ba7 100644 --- a/app/Http/Controllers/Admin/ArticleController.php +++ b/app/Http/Controllers/Admin/ArticleController.php @@ -39,8 +39,8 @@ class ArticleController extends CommonController $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; + $info = DB::table('arctype')->select('name')->where("id", $value->typeid)->first(); + $posts[$key]->name = $info->name; $posts[$key]->body = ''; } diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php index 0a2d4c3..d277ad3 100644 --- a/app/Http/Controllers/Admin/CategoryController.php +++ b/app/Http/Controllers/Admin/CategoryController.php @@ -13,7 +13,20 @@ class CategoryController extends CommonController public function index() { - return view('admin.category.index'); + $catlist = category_tree(get_category('arctype',0)); + + if($catlist) + { + foreach($catlist as $k=>$v) + { + $arctype = DB::table("arctype")->where('id', $v['id'])->first(); + $catlist[$k]['typedir'] = $arctype->typedir; + $catlist[$k]['addtime'] = $arctype->addtime; + } + } + + $data['catlist'] = $catlist; + return view('admin.category.index', $data); } public function add() @@ -39,7 +52,7 @@ class CategoryController extends CommonController public function doadd() { - if(!empty($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['reid']=0;}else{$_POST['reid'] = $_POST["prid"];}}//父级栏目id + if(!empty($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['pid']=0;}else{$_POST['pid'] = $_POST["prid"];}}//父级栏目id $_POST['addtime'] = time();//添加时间 unset($_POST["prid"]); unset($_POST["_token"]); @@ -90,7 +103,7 @@ class CategoryController extends CommonController { 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()) + if(DB::table('arctype')->where('pid', $id)->first()) { error_jump('删除失败!请先删除子栏目'); } diff --git a/app/Http/Controllers/Admin/FriendlinkController.php b/app/Http/Controllers/Admin/FriendlinkController.php index c010635..01a770c 100644 --- a/app/Http/Controllers/Admin/FriendlinkController.php +++ b/app/Http/Controllers/Admin/FriendlinkController.php @@ -66,7 +66,7 @@ class FriendlinkController extends CommonController public function del() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{$this->error('删除失败!请重新提交',FLADMIN.'/Friendlink' , 3);} //if(preg_match('/[0-9]*/',$id)){}else{exit;} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} if(DB::table('friendlink')->whereIn("id", explode(',', $id))->delete()) { diff --git a/app/Http/Controllers/Admin/MenuController.php b/app/Http/Controllers/Admin/MenuController.php new file mode 100644 index 0000000..37535c9 --- /dev/null +++ b/app/Http/Controllers/Admin/MenuController.php @@ -0,0 +1,83 @@ +insert($_POST)) + { + success_jump('添加成功!', route('admin_menu')); + } + 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('menu')->where('id', $id)->first(), 1); + $data['menu'] = category_tree(get_category('menu',0)); + + return view('admin.menu.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + + unset($_POST["_token"]); + if(DB::table('menu')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_menu')); + } + else + { + error_jump('修改失败!'); + } + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('menu')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 8a4ab7d..3b4103c 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -34,8 +34,8 @@ class ProductController extends CommonController $posts = parent::pageList('product', $where); foreach($posts as $key=>$value) { - $info = DB::table('product_type')->select('typename')->where("id", $value->typeid)->first(); - $posts[$key]->typename = $info->typename; + $info = DB::table('product_type')->select('name')->where("id", $value->typeid)->first(); + $posts[$key]->name = $info->name; $posts[$key]->body = ''; } diff --git a/app/Http/Controllers/Admin/ProducttypeController.php b/app/Http/Controllers/Admin/ProducttypeController.php index a170bd6..0a01cc8 100644 --- a/app/Http/Controllers/Admin/ProducttypeController.php +++ b/app/Http/Controllers/Admin/ProducttypeController.php @@ -13,8 +13,20 @@ class ProductTypeController extends CommonController public function index() { - $data['catlist'] = category_tree(get_category('product_type',0)); - return view('admin.producttype.index', $data); + $catlist = category_tree(get_category('product_type',0)); + + if($catlist) + { + foreach($catlist as $k=>$v) + { + $arctype = DB::table("arctype")->where('id', $v['id'])->first(); + $catlist[$k]['typedir'] = $arctype->typedir; + $catlist[$k]['addtime'] = $arctype->addtime; + } + } + + $data['catlist'] = $catlist; + return view('admin.producttype.index', $data); } public function add() @@ -41,7 +53,7 @@ class ProductTypeController extends CommonController public function doadd() { - if(isset($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['reid']=0;}else{$_POST['reid'] = $_POST["prid"];}unset($_POST["prid"]);}//父级栏目id + if(isset($_POST["prid"])){if($_POST["prid"]=="top"){$_POST['pid']=0;}else{$_POST['pid'] = $_POST["prid"];}unset($_POST["prid"]);}//父级栏目id $_POST['addtime'] = time();//添加时间 unset($_POST["_token"]); @@ -92,7 +104,7 @@ class ProductTypeController extends CommonController { if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(DB::table("product_type")->where('reid', $id)->first()) + if(DB::table("product_type")->where('pid', $id)->first()) { error_jump('删除失败!请先删除子分类'); } diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 0ae840d..e929f17 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -13,18 +13,68 @@ class UserController extends CommonController public function index() { - return view('admin.user.index'); + $posts = parent::pageList('user'); + + $data['posts'] = $posts; + + return view('admin.user.index', $data); + } + + public function add() + { + $data['rolelist'] = object_to_array(DB::table('user_role')->orderBy('listorder','desc')->get()); + + return view('admin.user.add', $data); + } + + public function doadd() + { + unset($_POST["_token"]); + $_POST['pwd'] = md5($_POST['pwd']); + if(DB::table('user')->insert($_POST)) + { + success_jump('添加成功!', route('admin_user')); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } } public function edit() { - $data['post'] = object_to_array(DB::table('user')->where('id', 1)->first(), 1); + 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('user')->where('id', $id)->first(), 1); + $data['rolelist'] = object_to_array(DB::table('user_role')->orderBy('listorder','desc')->get()); + return view('admin.user.edit', $data); } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + + unset($_POST["_token"]); + $_POST['pwd'] = md5($_POST['pwd']); + if(DB::table('user')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_user')); + } + else + { + error_jump('修改失败!'); + } + } - public function doedit() + //修改密码 + /* public function doedit() { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + unset($_POST["_token"]); + if(!empty($_POST["username"])){$data['username'] = $map['username'] = $_POST["username"];}else{error_jump('用户名不能为空');exit;}//用户名 if(!empty($_POST["oldpwd"])){$map['pwd'] = md5($_POST["oldpwd"]);}else{error_jump('旧密码错误');exit;} if($_POST["newpwd"]==$_POST["newpwd2"]){$data['pwd'] = md5($_POST["newpwd"]);}else{error_jump('密码错误');exit;} @@ -34,7 +84,7 @@ class UserController extends CommonController if($User) { - if(DB::table('user')->where('id', 1)->update($data)) + if(DB::table('user')->where('id', $id)->update($data)) { session_unset(); session_destroy(); @@ -45,5 +95,19 @@ class UserController extends CommonController { error_jump('修改失败!旧用户名或密码错误'); } + } */ + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('user')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } } } \ No newline at end of file diff --git a/app/Http/Controllers/Admin/UserRoleController.php b/app/Http/Controllers/Admin/UserRoleController.php new file mode 100644 index 0000000..56232fb --- /dev/null +++ b/app/Http/Controllers/Admin/UserRoleController.php @@ -0,0 +1,80 @@ +insert($_POST)) + { + success_jump('添加成功!', route('admin_userrole')); + } + 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('user_role')->where('id', $id)->first(), 1); + + return view('admin.userrole.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + + unset($_POST["_token"]); + if(DB::table('user_role')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_userrole')); + } + else + { + error_jump('修改失败!'); + } + } + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('user_role')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } + } +} diff --git a/app/Http/Controllers/Home/IndexController.php b/app/Http/Controllers/Home/IndexController.php index bc5879d..ee8d16a 100644 --- a/app/Http/Controllers/Home/IndexController.php +++ b/app/Http/Controllers/Home/IndexController.php @@ -28,7 +28,7 @@ class IndexController extends CommonController $data['post'] = $post; $subcat="";$sql=""; - $post2 = object_to_array(DB::table('arctype')->select('id')->where('reid', $cat)->get()); + $post2 = object_to_array(DB::table('arctype')->select('id')->where('pid', $cat)->get()); 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; @@ -59,7 +59,7 @@ class IndexController extends CommonController { if(empty($id) || !preg_match('/[0-9]+/',$id)){error_jump('您访问的页面不存在或已被删除!', route('page404'));} - if(cache("detailid$id")){$post = cache("detailid$id");}else{$post = object_to_array(DB::table('article')->where('id', $id)->first(), 1);if(empty($post)){error_jump('您访问的页面不存在或已被删除!', route('page404'));}$post['typename'] = DB::table('arctype')->where('id', $post['typeid'])->value('typename');cache(["detailid$id"=>$post], \Carbon\Carbon::now()->addMinutes(2592000));} + if(cache("detailid$id")){$post = cache("detailid$id");}else{$post = object_to_array(DB::table('article')->where('id', $id)->first(), 1);if(empty($post)){error_jump('您访问的页面不存在或已被删除!', route('page404'));}$post['name'] = DB::table('arctype')->where('id', $post['typeid'])->value('name');cache(["detailid$id"=>$post], \Carbon\Carbon::now()->addMinutes(2592000));} if($post) { $cat = $post['typeid']; @@ -197,7 +197,7 @@ class IndexController extends CommonController $data['post'] = $post; $subcat="";$sql=""; - $post2 = object_to_array(DB::table('product_type')->select('id')->where('reid', $cat)->get()); + $post2 = object_to_array(DB::table('product_type')->select('id')->where('pid', $cat)->get()); if(!empty($post2)){foreach($post2 as $row){$subcat=$subcat."typeid=".$row["id"]." or ";}} $subcat=$subcat."typeid=".$cat; $data['sql'] = $subcat; @@ -226,7 +226,7 @@ class IndexController extends CommonController { if(empty($id) || !preg_match('/[0-9]+/',$id)){error_jump('您访问的页面不存在或已被删除!', route('page404'));} - $post = object_to_array(DB::table('product')->where('id', $id)->first(), 1);if(empty($post)){error_jump('您访问的页面不存在或已被删除!', route('page404'));}$post['typename'] = DB::table('arctype')->where('id', $post['typeid'])->value('typename'); + $post = object_to_array(DB::table('product')->where('id', $id)->first(), 1);if(empty($post)){error_jump('您访问的页面不存在或已被删除!', route('page404'));}$post['name'] = DB::table('arctype')->where('id', $post['typeid'])->value('name'); if($post) { $cat = $post['typeid']; diff --git a/resources/views/admin/article/add.blade.php b/resources/views/admin/article/add.blade.php index 26df9ba..c8bacc8 100644 --- a/resources/views/admin/article/add.blade.php +++ b/resources/views/admin/article/add.blade.php @@ -75,9 +75,9 @@ function upImage() diff --git a/resources/views/admin/article/edit.blade.php b/resources/views/admin/article/edit.blade.php index 2cebaa0..d3de76c 100644 --- a/resources/views/admin/article/edit.blade.php +++ b/resources/views/admin/article/edit.blade.php @@ -76,9 +76,9 @@ function upImage() diff --git a/resources/views/admin/article/index.blade.php b/resources/views/admin/article/index.blade.php index baeaeb5..53c4bbc 100644 --- a/resources/views/admin/article/index.blade.php +++ b/resources/views/admin/article/index.blade.php @@ -23,7 +23,7 @@