后台日志实现
日志表:
/*管理员操作日志*/ public function adminlog(){ //请求总数与当前页数据 if(!empty($_POST['cp'])){ $where=["is_del"=>0]; /*请求总数*/ $amount=null; $logmessage=new OperateLog(); if(!empty($_POST['amount'])){ $r=$logmessage->amount($where); if($r || $r===0){ $amount=$r; }else{ return array('status'=>0,'msg'=>'查询失败'); } } /*请求当前页数据*/ $limit=$_POST['limit']; //分页 $list=$logmessage->listdata($where,$limit); if(!empty($list)){ foreach($list as $k=>$v){ $list[$k]['admin_id']=GetAdminName($v['admin_id']);//根据日志表查询操作后台的用户名称 $getInfo=substr($list[$k]['operate_way'],strripos($list[$k]['operate_way'],"/admin/")+8); $listWay=Db::table("access_node")->field("lower(name) as name,title")->where("name like '%".$getInfo."'")->find();//根据路径查找后台节点表中,本路径所代表的的title名字显示即可 $list[$k]['operate_way']=empty($listWay)?"":$listWay['title']; } } if(is_array($list)){ return array('status'=>1,'amount'=>$amount,'data'=>$list); }else{ return array('status'=>0,'msg'=>'查询失败'); } } return $this->fetch('checklog/adminlog'); }
access_node表: