时间:2021-07-01 10:21:17 帮助过:19人阅读
这是客户端的事
网上找到一款 php 结合 JS
$refer = ''; if (isset($_SERVER['HTTP_REFERER'])) { $refer = $_SERVER['HTTP_REFERER']; } $user_agent = ''; if (isset($_SERVER['HTTP_USER_AGENT'])) { $user_agent = $_SERVER['HTTP_USER_AGENT']; } $ip = $_SERVER['REMOTE_ADDR']; if (isset($_GET['stay_ms'])) { $log = '[' . date("Y-m-d H:i:s") . '] ' . $ip . ' ' . $refer . ' @ ' . number_format($_GET['stay_ms']) . "ms\r\n"; file_put_contents("log/log_" . date("Y-m-d") . ".txt", $log, FILE_APPEND); } if ($_SERVER['QUERY_STRING'] == '' || isset($_GET['day'])) { $day = isset($_GET['day']) ? $_GET['day'] : date("Y-m-d"); $file = "log/log_" .$day . ".txt"; if (file_exists($file)) { $log = file_get_contents($file); echo nl2br($log); } }