添加识别蜘蛛爬虫记录、完善细节小bug

This commit is contained in:
hdm 2021-09-01 18:07:32 +08:00
parent c0dc76c6ff
commit 5f026df1ea
4 changed files with 30 additions and 14 deletions

View File

@ -292,6 +292,20 @@ function get_login_user($key = "")
return ''; return '';
} }
} }
/**
* 判断访客是否是蜘蛛
*/
function isRobot($except = '') {
$ua = strtolower ( $_SERVER ['HTTP_USER_AGENT'] );
$botchar = "/(baidu|google|spider|soso|yahoo|sohu-search|yodao|robozilla|AhrefsBot)/i";
$except ? $botchar = str_replace ( $except . '|', '', $botchar ) : '';
if (preg_match ( $botchar, $ua )) {
return true;
}
return false;
}
/** /**
* 客户操作日志 * 客户操作日志
* @param string $type 操作类型 login reg add edit view delete down join sign play order pay * @param string $type 操作类型 login reg add edit view delete down join sign play order pay
@ -321,7 +335,7 @@ function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
case 'delete': case 'delete':
$title = '删除'; $title = '删除';
break; break;
case 'down': case 'down':
$title = '下载'; $title = '下载';
break; break;
case 'join': case 'join':
@ -339,10 +353,10 @@ function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
case 'pay': case 'pay':
$title = '支付'; $title = '支付';
break; break;
case 'api': case 'api':
$title = 'API请求'; $title = 'API请求';
break; break;
case 'install': case 'install':
$title = '安装'; $title = '安装';
break; break;
default: default:
@ -350,7 +364,7 @@ function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
break; break;
} }
if ($type == 'login') { if ($type == 'login') {
$login_user = \think\facade\Db::name('user')->where(array('id' => $param_id))->find(); $login_user = \think\facade\Db::name('User')->where(array('id' => $param_id))->find();
if ($login_user['nickname'] == '') { if ($login_user['nickname'] == '') {
$login_user['nickname'] = $login_user['name']; $login_user['nickname'] = $login_user['name'];
} }
@ -363,6 +377,11 @@ function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
$login_user = []; $login_user = [];
$login_user['id'] = 0; $login_user['id'] = 0;
$login_user['nickname'] = '游客'; $login_user['nickname'] = '游客';
if(isRobot()){
$login_user['nickname'] = '蜘蛛';
$type = 'spider';
$title = '爬行';
}
} else { } else {
if ($login_user['nickname'] == '') { if ($login_user['nickname'] == '') {
$login_user['nickname'] = $login_user['username']; $login_user['nickname'] = $login_user['username'];
@ -386,7 +405,7 @@ function add_user_log($type, $param_str = '', $param_id = 0, $param = [])
$data['function'] = app('request')->action(); $data['function'] = app('request')->action();
$data['ip'] = $request->ip(); $data['ip'] = $request->ip();
$data['create_time'] = time(); $data['create_time'] = time();
\think\facade\Db::name('user_log')->strict(false)->field(true)->insert($data); \think\facade\Db::name('UserLog')->strict(false)->field(true)->insert($data);
} }
/** /**

View File

@ -14,9 +14,7 @@
<div class="r user-right"> <div class="r user-right">
<div class="user-info"> <div class="user-info">
<dl class="clearfix"> <dl class="clearfix">
<dt class="user-info-img"><img <dt class="user-info-img"><img src="{$userInfo.headimgurl}" /></dt>
src='{$userInfo.headimgurl}' />
</dt>
<dd class="user-info-name">{$userInfo.showname}</dd> <dd class="user-info-name">{$userInfo.showname}</dd>
<dd class="user-info-tips"> <dd class="user-info-tips">
{$userInfo.desc} {$userInfo.desc}
@ -30,18 +28,17 @@
<td class="td-gay" width="12%">真实姓名</td> <td class="td-gay" width="12%">真实姓名</td>
<td width="38%">{$userInfo.name}</td> <td width="38%">{$userInfo.name}</td>
<td class="td-gay" width="12%">性别</td> <td class="td-gay" width="12%">性别</td>
<td width="38%">{$userInfo.sex}</a> <td width="38%">{$userInfo.sex}</td>
</td>
</tr> </tr>
<tr> <tr>
<td class="td-gay">所在城市</td> <td class="td-gay">所在城市</td>
<td>{$userInfo.city}</a> <td>{$userInfo.city}</td>
<td class="td-gay">出生日期</td> <td class="td-gay">出生日期</td>
<td>{:date('Y-m-d',$userInfo.birthday)}</td> <td>{:date('Y-m-d',$userInfo.birthday)}</td>
</tr> </tr>
<tr> <tr>
<td class="td-gay">手机号码</td> <td class="td-gay">手机号码</td>
<td>{$userInfo.mobile}</a> <td>{$userInfo.mobile}</td>
<td class="td-gay">电子邮箱</td> <td class="td-gay">电子邮箱</td>
<td>{$userInfo.email}</td> <td>{$userInfo.email}</td>
</tr> </tr>

View File

@ -19,7 +19,7 @@ class Index
{ {
// 检测是否安装过 // 检测是否安装过
if (is_installed()) { if (is_installed()) {
echo '你已经安装过勾股cms系统!'; echo '你已经安装过勾股cms系统如需重新安装请删除“config/install.lock”文件';
die(); die();
} }
} }

View File

@ -25,7 +25,7 @@ CREATE TABLE `cms_admin` (
`last_login_time` int(11) NOT NULL DEFAULT '0', `last_login_time` int(11) NOT NULL DEFAULT '0',
`login_num` int(11) NOT NULL DEFAULT '0', `login_num` int(11) NOT NULL DEFAULT '0',
`last_login_ip` varchar(64) NOT NULL DEFAULT '', `last_login_ip` varchar(64) NOT NULL DEFAULT '',
`status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常-1禁止登录', `status` int(1) NOT NULL DEFAULT '1' COMMENT '1正常,0禁止登录,-1删除',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`) USING BTREE UNIQUE KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 COMMENT='管理员表'; ) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 COMMENT='管理员表';