是否可以使用 PHP 记录请求?我还想记录图像、js、CSS 文件请求。
<img src="foo.png">
<link rel="stylesheet" href="foo.css">
我目前使用这段代码,但它只给我当前的请求 uri,而不是其他文件等。我还将所有请求重写到我的 index.php,其中有这行代码。
file_put_contents('foo.txt', $_SERVER['REQUEST_URI'] . PHP_EOL, FILE_APPEND | LOCK_EX);
小智 6
这是将所有 http 请求绘制到文件的选项。这适用于通过 HTTP 协议传输的所有请求
$myFile = "requestslog.txt";
    $fh = fopen($myFile, 'a') or die("can't open file");
    fwrite($fh, "\n\n--------------------------------------
        -------------------------\n");
    foreach($_SERVER as $h=>$v)
        if(ereg('HTTP_(.+)',$h,$hp))
            fwrite($fh, "$h = $v\n");
    fwrite($fh, "\r\n");
    fwrite($fh, file_get_contents('php://input'));
    fclose($fh);
    echo "<html><head /><body><iframe src=\"$myFile\" 
        style=\"height:100%; width:100%;\"></iframe></body></html>"
| 归档时间: | 
 | 
| 查看次数: | 12585 次 | 
| 最近记录: |