From d2867b463517a0b977fe2bfa4bc79d5c4e7aa9c4 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Tue, 25 Feb 2020 17:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E4=B8=BA=E6=97=A5=E5=BF=97=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/AdminController.class.php | 27 +- .../UserActionLogController.class.php | 299 ++++++++++++++++++ .../Admin/View/UserActionLog/index.html | 239 ++++++++++++++ .../Admin/View/UserActionLog/operateLog.html | 239 ++++++++++++++ 4 files changed, 791 insertions(+), 13 deletions(-) create mode 100644 Application/Admin/Controller/UserActionLogController.class.php create mode 100644 Application/Admin/View/UserActionLog/index.html create mode 100644 Application/Admin/View/UserActionLog/operateLog.html diff --git a/Application/Admin/Controller/AdminController.class.php b/Application/Admin/Controller/AdminController.class.php index 7f4eadbc3..2e050f266 100644 --- a/Application/Admin/Controller/AdminController.class.php +++ b/Application/Admin/Controller/AdminController.class.php @@ -60,19 +60,20 @@ class AdminController extends Controller { if ($rule == "admin/index/index"){ //如果首页没有访问权限 自动检测有访问权限的页面然后跳转过去 - $qx = M("Auth_group")->table("__AUTH_GROUP__ as ag") - ->join("__AUTH_GROUP_ACCESS__ as aga on(ag.id=aga.group_id and aga.uid=".UID.")",'right') - ->where("ag.status=1")->limit(1)->select(); - if (empty($qx)){ - //如果没有任何权限 直接登出 - D('Member')->logout(); - session('[destroy]'); - } - $where['id'] = substr($qx[0]['rules'],0,strpos($qx[0]['rules'], ',')); - //$where['id'] = substr($qx[0]['rules'],0,1) - $dz = M("auth_rule")->field('name')->where($where)->find(); - $red = substr($dz['name'],6); - redirect(U("$red")); +// $qx = M("Auth_group")->table("__AUTH_GROUP__ as ag") +// ->join("__AUTH_GROUP_ACCESS__ as aga on(ag.id=aga.group_id and aga.uid=".UID.")",'right') +// ->where("ag.status=1")->limit(1)->select(); +// if (empty($qx)){ +// //如果没有任何权限 直接登出 +// D('Member')->logout(); +// session('[destroy]'); +// } +// $where['id'] = substr($qx[0]['rules'],0,strpos($qx[0]['rules'], ',')); +// //$where['id'] = substr($qx[0]['rules'],0,1) +// $dz = M("auth_rule")->field('name')->where($where)->find(); +// $red = substr($dz['name'],6); +// redirect(U("$red")); + redirect(U("Admin/Member/user_info")); }else{ $this->error('未授权访问!'); } diff --git a/Application/Admin/Controller/UserActionLogController.class.php b/Application/Admin/Controller/UserActionLogController.class.php new file mode 100644 index 000000000..44af5127a --- /dev/null +++ b/Application/Admin/Controller/UserActionLogController.class.php @@ -0,0 +1,299 @@ + +// +---------------------------------------------------------------------- + +namespace Admin\Controller; + +use User\Api\UserApi; +use Com\Wechat; +use Com\WechatAuth; + +/** + * 后台用户控制器 + * @author 麦当苗儿 + */ +class UserActionLogController extends AdminController +{ + + public function index($p = 0) { + + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $arraypage = $page; + + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + + $map = []; + + if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + } + + if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['action']) { + $map['action'] = ['like',"%{$_REQUEST['action']}%"]; + } + + $data = M('user_action_log','tab_')->where($map)->page($page,$row)->order('create_time DESC')->select(); + + $count = M('user_action_log','tab_')->where($map)->order('create_time DESC')->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page);//分页 + } + + $this->assign('data',$data); + + $this->display(); + + } + + public function del() { + + if (!$_REQUEST['id']) { + $this->ajaxReturn(['status'=>1001]); + } + + $map['id'] = $_REQUEST['id']; + + $is_del = M('user_action_log','tab_')->where($map)->delete(); + + if ($is_del) { + $this->ajaxReturn(['status'=>1]); + } else { + $this->ajaxReturn(['status'=>0]); + } + + } + + public function export() { + + $xlsName = $_REQUEST['xlsname']; + + $xlsCell = array( + '编号','行为','游戏','玩家','操作时间','操作IP地址' + ); + + $map = []; + + if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + } + + if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['action']) { + $map['action'] = ['like',"%{$_REQUEST['action']}%"]; + } + + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('GBK', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + + $accessNum=M('user_action_log','tab_')->where($map)->order('create_time DESC')->count(); + + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + + for($i = 1; $i <= $pages; $i++) { + /* 获取频道列表 */ + + $xlsData = M('user_action_log','tab_') + ->field("id,action,game_name,account,create_time,ip") + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('create_time DESC')->select(); + + foreach($xlsData as $key => $value) { + + $value['create_time'] = date("Y-m-d H:i:s", $value['create_time']); + + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + + } + unset($xlsData);//释放变量的内存 + //刷新输出缓冲到浏览器 + ob_flush(); + flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 + } + fclose($fp); + exit(); + + } + + public function operateLog($p = 0) { + + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $arraypage = $page; + + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + + $map = []; + + if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + } + + if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['action']) { + $map['op_name'] = ['like',"%{$_REQUEST['action']}%"]; + } + + $data = M('operation_log','tab_') + ->where($map) + ->page($page,$row) + ->order('create_time DESC') + ->select(); + + $count = M('operation_log','tab_')->where($map)->order('create_time DESC')->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page);//分页 + } + + $this->assign('data',$data); + + $this->display(); + + } + + public function operateLogDel() { + + if (!$_REQUEST['id']) { + $this->ajaxReturn(['status'=>1001]); + } + + $map['id'] = $_REQUEST['id']; + + $is_del = M('operation_log','tab_')->where($map)->delete(); + + if ($is_del) { + $this->ajaxReturn(['status'=>1]); + } else { + $this->ajaxReturn(['status'=>0]); + } + + } + + public function operateLoExport() { + + $xlsName = $_REQUEST['xlsname']; + + $xlsCell = array( + '编号','位置','类型','操作人','操作时间','操作IP地址' + ); + + $map = []; + + if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + } + + if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['time_start']&&$_REQUEST['time_end']) { + $map['create_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + $map['create_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['action']) { + $map['op_name'] = ['like',"%{$_REQUEST['action']}%"]; + } + + $csvFileName = $xlsName.'.csv'; + //设置好告诉浏览器要下载excel文件的headers + header('Content-Description: File Transfer'); + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment; filename="'. $csvFileName .'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + $fp = fopen('php://output', 'a');//打开output流 + mb_convert_variables('GBK', 'UTF-8', $xlsCell); + fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 + + $accessNum=M('operation_log','tab_')->where($map)->order('create_time DESC')->count(); + + $perSize = 5000;//每次查询的条数 + $pages = ceil($accessNum / $perSize); + + for($i = 1; $i <= $pages; $i++) { + /* 获取频道列表 */ + + $xlsData = M('operation_log','tab_') + ->field("id,menu,key,op_name,admin_account,create_time,op_ip") + ->where($map) + ->limit(($i-1)*$perSize ,$perSize) + ->order('create_time DESC')->select(); + + foreach($xlsData as $key => $value) { + + $value['menu'] = $value['menu'].'-'.$value['key']; + $value['create_time'] = date("Y-m-d H:i:s", $value['create_time']); + unset($value['key']); + + mb_convert_variables('GBK', 'UTF-8', $value); + fputcsv($fp, $value); + + } + unset($xlsData);//释放变量的内存 + //刷新输出缓冲到浏览器 + ob_flush(); + flush();//必须同时使用 ob_flush() 和flush() 函数来刷新输出缓冲。 + } + fclose($fp); + exit(); + + } + +} \ No newline at end of file diff --git a/Application/Admin/View/UserActionLog/index.html b/Application/Admin/View/UserActionLog/index.html new file mode 100644 index 000000000..0e10071ed --- /dev/null +++ b/Application/Admin/View/UserActionLog/index.html @@ -0,0 +1,239 @@ + + + + + + + + + + + + +
+ + +
+ +
+ + - +
+ + +
+
+ +
+   +
+ + +
+ 搜索 +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
编号行为游戏玩家操作时间操作IP地址操作
aOh! 暂时还没有内容!
{$data.id}{$data.action}{$data.game_name}{$data.account}{$data.create_time|date='Y-m-d H:i:s',###}{$data.ip}删除
+
+
+
+ 导出 + + {$_page|default=''} +
+
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + + diff --git a/Application/Admin/View/UserActionLog/operateLog.html b/Application/Admin/View/UserActionLog/operateLog.html new file mode 100644 index 000000000..e3b192799 --- /dev/null +++ b/Application/Admin/View/UserActionLog/operateLog.html @@ -0,0 +1,239 @@ + + + + + + + + + + + + +
+ + +
+ +
+ + - +
+ + +
+
+ +
+   +
+ + +
+ 搜索 +
+ +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
编号位置类型操作人操作时间操作IP地址操作
aOh! 暂时还没有内容!
{$data.id}{$data.menu}-{$data.key}{$data.menu}-{$data.key}{$data.op_name}{$data.admin_account}{$data.create_time|date='Y-m-d H:i:s',###}{$data.op_ip}删除
+
+
+
+ 导出 + + {$_page|default=''} +
+
+ + + + if(C('COLOR_STYLE')=='blue_color') echo ''; + + + + + +