diff --git a/app/api/common.php b/app/api/common.php
index 2c26559..90ca6f0 100644
--- a/app/api/common.php
+++ b/app/api/common.php
@@ -1,4 +1,9 @@
['except' => ['index','login','reg'] ]
];
@@ -31,6 +31,7 @@ class Index extends BaseController
{
$list = Db::name('Article')->select();
$seo = get_system_config('web');
+ add_user_log('api', '首页');
$this->apiSuccess('请求成功',['list' => $list,'seo' => $seo]);
}
@@ -76,6 +77,7 @@ class Index extends BaseController
//获取jwt的句柄
$jwtAuth = JwtAuth::getInstance();
$token = $jwtAuth->setUid($user['id'])->encode()->getToken();
+ add_user_log('api', '登录');
$this->apiSuccess('登录成功',['token' => $token]);
}
}
@@ -110,6 +112,7 @@ class Index extends BaseController
$char = mb_substr($param['username'], 0, 1, 'utf-8');
$uid = Db::name('User')->strict(false)->field(true)->insertGetId($param);
if($uid){
+ add_user_log('api', '注册');
$this->apiSuccess('注册成功');
}else{
$this->apiError('注册失败');
@@ -131,6 +134,7 @@ class Index extends BaseController
$jwtAuth = JwtAuth::getInstance();
$uid = $jwtAuth->getUid();
$userInfo = Db::name('User')->where(['id' => $uid])->find();
+ add_user_log('api', '测试页面');
$this->apiSuccess('请求成功',['list' => $list,'user' => $userInfo]);
}
diff --git a/app/common.php b/app/common.php
index 5ff6e6c..b6d9049 100644
--- a/app/common.php
+++ b/app/common.php
@@ -273,6 +273,122 @@ function get_file($id)
}
+//获取当前登录用户的信息
+function get_login_user($key = "")
+{
+ $session_user = get_config('app.session_user');
+ if (\think\facade\Session::has($session_user)) {
+ $gougu_user = \think\facade\Session::get($session_user);
+ if (!empty($key)) {
+ if (isset($gougu_user[$key])) {
+ return $gougu_user[$key];
+ } else {
+ return '';
+ }
+ } else {
+ return $gougu_user;
+ }
+ } else {
+ return '';
+ }
+}
+/**
+ * 客户操作日志
+ * @param string $type 操作类型 login reg add edit view delete down join sign play order pay
+ * @param string $param_str 操作内容
+ * @param int $param_id 操作内容id
+ * @param array $param 提交的参数
+ */
+function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
+{
+ $request = request();
+ switch ($type) {
+ case 'login':
+ $title = '登录';
+ break;
+ case 'reg':
+ $title = '注册';
+ break;
+ case 'add':
+ $title = '新增';
+ break;
+ case 'edit':
+ $title = '编辑';
+ break;
+ case 'view':
+ $title = '查看';
+ break;
+ case 'delete':
+ $title = '删除';
+ break;
+ case 'down':
+ $title = '下载';
+ break;
+ case 'join':
+ $title = '报名';
+ break;
+ case 'sign':
+ $title = '签到';
+ break;
+ case 'play':
+ $title = '播放';
+ break;
+ case 'order':
+ $title = '下单';
+ break;
+ case 'pay':
+ $title = '支付';
+ break;
+ case 'api':
+ $title = 'API请求';
+ break;
+ case 'install':
+ $title = '安装';
+ break;
+ default:
+ $title = '未知';
+ break;
+ }
+ if ($type == 'login') {
+ $login_user = \think\facade\Db::name('user')->where(array('id' => $param_id))->find();
+ if ($login_user['nickname'] == '') {
+ $login_user['nickname'] = $login_user['name'];
+ }
+ if ($login_user['nickname'] == '') {
+ $login_user['nickname'] = $login_user['username'];
+ }
+ } else {
+ $login_user = get_login_user();
+ if (empty($login_user)) {
+ $login_user = [];
+ $login_user['id'] = 0;
+ $login_user['nickname'] = '游客';
+ } else {
+ if ($login_user['nickname'] == '') {
+ $login_user['nickname'] = $login_user['username'];
+ }
+ }
+ }
+ $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . '执行了' . $title . '操作';
+ if ($param_str != '') {
+ $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . $title . '了' . $param_str;
+ }
+ $data = [];
+ $data['uid'] = $login_user['id'];
+ $data['nickname'] = $login_user['nickname'];
+ $data['type'] = $type;
+ $data['title'] = $title;
+ $data['content'] = $content;
+ $data['param_id'] = $param_id;
+ $data['param'] = json_encode($param);
+ $data['module'] = \think\facade\App::initialize()->http->getName();
+ $data['controller'] = app('request')->controller();
+ $data['function'] = app('request')->action();
+ $data['ip'] = $request->ip();
+ $data['create_time'] = time();
+ \think\facade\Db::name('user_log')->strict(false)->field(true)->insert($data);
+}
+
/**
* 判断是否是手机浏览器
* @return bool
diff --git a/app/home/common.php b/app/home/common.php
index ed02abf..0b1f61a 100644
--- a/app/home/common.php
+++ b/app/home/common.php
@@ -6,114 +6,6 @@
*/
// 这是home公共文件
-//获取当前登录用户的信息
-function get_login_user($key = "")
-{
- $session_user = get_config('app.session_user');
- if (\think\facade\Session::has($session_user)) {
- $gougu_user = \think\facade\Session::get($session_user);
- if (!empty($key)) {
- if (isset($gougu_user[$key])) {
- return $gougu_user[$key];
- } else {
- return '';
- }
- } else {
- return $gougu_user;
- }
- } else {
- return '';
- }
-}
-/**
- * 客户操作日志
- * @param string $type 操作类型 login add edit view delete,pay
- * @param int $param_id 操作类型
- * @param array $param 提交的参数
- */
-function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
-{
- $request = request();
- switch ($type) {
- case 'login':
- $title = '登录';
- break;
- case 'reg':
- $title = '注册';
- break;
- case 'add':
- $title = '新增';
- break;
- case 'edit':
- $title = '编辑';
- break;
- case 'view':
- $title = '查看';
- break;
- case 'delete':
- $title = '删除';
- break;
- case 'down':
- $title = '下载';
- break;
- case 'join':
- $title = '报名';
- break;
- case 'sign':
- $title = '签到';
- break;
- case 'play':
- $title = '播放';
- break;
- case 'order':
- $title = '下单';
- break;
- case 'pay':
- $title = '支付';
- break;
- default:
- $title = '未知';
- break;
- }
- if ($type == 'login') {
- $login_user = \think\facade\Db::name('user')->where(array('id' => $param_id))->find();
- if ($login_user['nickname'] == '') {
- $login_user['nickname'] = $login_user['name'];
- }
- if ($login_user['nickname'] == '') {
- $login_user['nickname'] = $login_user['username'];
- }
- } else {
- $login_user = get_login_user();
- if (empty($login_user)) {
- $login_user = [];
- $login_user['id'] = 0;
- $login_user['nickname'] = '游客';
- } else {
- if ($login_user['nickname'] == '') {
- $login_user['nickname'] = $login_user['username'];
- }
- }
- }
- $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . '执行了' . $title . '操作';
- if ($param_str != '') {
- $content = $login_user['nickname'] . '在' . date('Y-m-d H:i:s') . $title . '了' . $param_str;
- }
- $data = [];
- $data['uid'] = $login_user['id'];
- $data['nickname'] = $login_user['nickname'];
- $data['type'] = $type;
- $data['title'] = $title;
- $data['content'] = $content;
- $data['param_id'] = $param_id;
- $data['param'] = json_encode($param);
- $data['module'] = \think\facade\App::initialize()->http->getName();
- $data['controller'] = app('request')->controller();
- $data['function'] = app('request')->action();
- $data['ip'] = $request->ip();
- $data['create_time'] = time();
- \think\facade\Db::name('user_log')->strict(false)->field(true)->insert($data);
-}
//读取导航列表,用于前台
function get_navs($name)
diff --git a/app/home/controller/Index.php b/app/home/controller/Index.php
index 0cb6374..d29d3d6 100644
--- a/app/home/controller/Index.php
+++ b/app/home/controller/Index.php
@@ -21,6 +21,12 @@ class Index extends BaseController
$count = \think\facade\Db::name('UserLog')->where(array('type' => 'down'))->count();
return View('',['version'=>$version,'count'=>$count]);
}
+
+ public function logs()
+ {
+ add_user_log('view', '开发日志');
+ return View('');
+ }
public function down()
{
diff --git a/app/home/controller/Login.php b/app/home/controller/Login.php
index c05be0d..0898bed 100644
--- a/app/home/controller/Login.php
+++ b/app/home/controller/Login.php
@@ -30,6 +30,17 @@ class Login
public function errorshow()
{
return View();
+ }
+ //系统安装提交
+ function install_ajax()
+ {
+ add_user_log('install', '系统');
+ if (!empty($_GET['callback'])) {
+ return $_GET['callback'] . '("install ok!")'; // jsonp
+ }
+ else{
+ return to_assign(0, 'install ok!');
+ }
}
//提交登录
public function login_submit()
diff --git a/app/home/view/common/footer.html b/app/home/view/common/footer.html
index 835e38a..fb81dad 100644
--- a/app/home/view/common/footer.html
+++ b/app/home/view/common/footer.html
@@ -3,24 +3,24 @@