当前位置: 首页 > 后端技术 > PHP

多语言维基百科网站源码开发之二

时间:2023-03-30 03:22:31 PHP

这是多语言维基百科网站源代码开发的第二篇文章。我之前讲过第一篇文章。需要的朋友可以到我的博客首页看看。废话不说,直接进入正题。如果你不明白,你可以问我。这篇文章也在后台部分,是管理员版块的动态首页publicfunctionindex(){$where=[];$where[]=['状态','<>',-1];$username=input('用户名');//搜索条件if(!empty(input('username'))){$where[]=['id|username','like',"%{$username}%"];}if(!is_root()){$where[]=['role_id','<>',2];$list=Db::name('manager')->where($where)->paginate(10);$page=$list->render();View::assign(['list'=>$list,'page'=>$page]);returnView::fetch();}publicfunctionstatus(){if(d('manager')->where('id',input('id'))->update(['status'=>input('状态')])){return$this->success('状态修改成功');}return$this->error('状态修改失败');}管理员添加页面publicfunctionadd(){if(Request::isAjax()){$info=input('info/a');$password=input('密码');$confirm_password=input('confirm_password');如果($密码!=$确认密码){return$this->error('密码不一致');}$info['密码']=md5($密码);if(d('manager')->insert($info)){return$this->success('添加成功');}return$this->error('添加失败');}$在哪里=[];if(!is_root()){$where[]=['id','<>',2];$list=d('role')->where($where)->select();视图::分配(['列表'=>$列表]);returnView::fetch();}Admin添加页面publicfunctionedit(){if(Request::isAjax()){$id=input('id');$info=input('信息/a');$password=input('密码');$confirm_password=input('confirm_password');if($password!=$confirm_password){return$this->error('密码不匹配');}if($password!=''){$info['password']=md5($password);}if(d('manager')->where('id',$id)->update($info)){return$this->success('修改成功');}返回$this->error('修改失败');}$在哪里=[];if(!is_root()){$where[]=['id','<>',2];}$id=input('id');$list=d('角色')->where($where)->select();$info=d('manager')->where('id',$id)->find();View::assign(['list'=>$list,'info'=>$info]);returnView::fetch();}publicfunctiondel(){$id=input('id');if(d('manager')->where([['id','=',$id]])->delete(['status'=>-1])){returnjson(['code'=>1,'msg'=>'删除成功']);}returnjson(['code'=>0,'msg'=>'删除失败']);}管理员菜单管理publicfunctionindex(){$where=[];$where[]=['状态','<>',-1];$username=input('用户名');//搜索条件if(!empty(input('username'))){$where[]=['id|username','like',"%{$username}%"];}if(!is_root()){$where[]=['role_id','<>',2];$list=Db::name('manager')->where($where)->paginate(10);$page=$list->render();View::assign(['list'=>$list,'page'=>$page]);returnView::fetch();}publicfunctionstatus(){if(d('manager')->where('id',input('id'))->update(['status'=>input('status')])){return$this->success('状态修改成功');}return$this->error('状态修改失败');}publicfunctionindex(){$status=input('status','');$哪里=[];$where[]=['状态','<>',-1];如果($status!=''){$where[]=['status','=',$status];$list=d('menu')->where($where)->order('sort,idasc')->select()->toArray();$list=Cate::toLevel($list);查看::赋值(['列表'=>$列表]);returnView::fetch();}publicfunctionstatus(){if(d('menu')->where('id',input('id'))->update(['status'=>input('status')])){return$this->success('状态修改成功');}return$this->error('状态修改失败');}publicfunctionsort(){if(d('menu')->where('id',input('id'))->update(['sort'=>input('status')])){return$this->success('修改成功');}return$this->error('修改失败');}