PbootCMS后臺日志增加返回狀態代碼功能
/core/log/LogDb.php
第33行處改為:
// 寫入日志
public function write($content, $level = "info", $username = null)
{
$username = $username ?: session('username');
//檢測http還是https....
if(isset($_SERVER['HTTP_X_CLIENT_SCHEME'])){
$scheme = $_SERVER['HTTP_X_CLIENT_SCHEME'] . '://';
}elseif(isset($_SERVER['REQUEST_SCHEME'])){
$scheme = $_SERVER['REQUEST_SCHEME'] . '://';
}else{
$scheme = 'http://';
}
//檢測http還是https....
$array=explode('爬行', $content); //取URL后綴
$codeurl=$_SERVER['HTTP_HOST'].$array[1]; //取URL后綴
$header_info=get_headers($scheme.$codeurl); //取返回狀態代碼
$data = array(
'level' => $level,
'event' => escape_string($content.'>>>'.$header_info[0]), //增加狀態代碼在內容中
'user_ip' => ip2long(get_user_ip()),
'user_os' => get_user_os(),
'user_bs' => get_user_bs(),
'create_user' => $username,
'create_time' => get_datetime(),
);
return self::$model->table('ay_syslog')->insert($data);
}
看效果:
掃一掃,關注我們