paginate($pageSize); return $list; } // 管理员日志记录 public static function record() { // 入库信息 $userid = Session::get('adminuser.userid', 0); $username = Session::get('adminuser.username', ''); $url = Request::url(); $title = ''; $content = Request::except(['s', '_pjax']); //s 变量为系统内置的变量,_pjax为js的变量,无记录的必要 $ip = Request::ip(); $userAgent = Request::server('HTTP_USER_AGENT'); // 标题处理 $route = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', Request::controller())) . '/' . strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', Request::action())); $active = \app\common\model\SysMenu::where('url', $route)->find(); $title = $active != null ? $active['name'] : ""; // 内容处理(过长的内容和涉及密码的内容不进行记录) if ($content) { foreach ($content as $k => $v) { if (is_string($v) && strlen($v) > 200 || stripos($k, 'password') !== false || stripos($k, 'newpassword') !== false || stripos($k, 'repassword') !== false) { unset($content[$k]); } } } // 插入数据 if (!empty($title)) { // 查询管理员上一条数据 $result = self::where('userid', '=', $userid) ->order('id', 'desc') ->find(); if ($result) { if ($result->url != $url) { self::create([ 'title' => $title ? $title : '', 'username' => $username, 'content' => ! is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content, 'url' => $url, 'userid' => $userid, 'user_agent' => $userAgent, 'ip' => $ip ]); } } else { self::create([ 'title' => $title ? $title : '', 'username' => $username, 'content' => ! is_scalar($content) ? json_encode($content, JSON_UNESCAPED_UNICODE) : $content, 'url' => $url, 'userid' => $userid, 'user_agent' => $userAgent, 'ip' => $ip ]); } } } }