Hier meine Lösung, die zwar Ressourcen frisst, die mir aber bei der Fehlersuche (Log-Spammer) nützlich war:
Umleitung von allen Anfragen auf ein Logskript, das die gewünschte Seite mit einem speziellen Präfix vor der URL
erneut anfragt, ins Logfile einträgt, und dem Nutzer anzeigt.
Durch die Verwendung von Snoopy-Features wie POST, MIME-Type, ist die Sache beinahe transparent.
Wie gesagt - es verdoppelt den Datenverkehr, nix für den Dauerbetrieb
- liefert aber auch anders kaum erhältliche Informationen.
Vielleicht hat jemand Lust, die Sache zu perfektionieren?
Z.B. ist das Logfile-Format noch nicht Standard, und wahrscheinlich sind noch Fehler im Skript...
Gruß,
Frank
Mein Skript log.php:
- Code: Alles auswählen
<?
# Add to .htaccess under web root:
# RewriteEngine on
# RewriteCond %{ENV:REDIRECT_STATUS} ^$
# RewriteCond %{REQUEST_URI} !^/*log\.php
# RewriteCond %{REQUEST_URI} !^/*prefix_for_requests_from_logscript_
# RewriteRule .+ /log.php?request_uri_for_logscript=$0 [QSA,L]#
# RewriteCond %{ENV:REDIRECT_STATUS} ^$
# RewriteCond %{REQUEST_URI} !^/*log\.php
# RewriteRule ^prefix_for_requests_from_logscript_(.+) $1 [QSA,L]
# Then all requests are redirected to log.php - this script
# (with url in additional parameter "request_uri_for_logscript").
# This will write a logfile, and retrieve the resource via Snoopy
# with the special prefix "prefix_for_requests_from_logscript_"
# The above .htaccess will direct urls with this prefix to the original resource.
# %{ENV:REDIRECT_STATUS} is needed for [L] is not enough in .htaccess context
# for .htaccess is parsed again after every rewriting step.
# Frank Schweickert, 6-Apr-2008
include_once("snoopy.class.php"); # download http://sourceforge.net/projects/snoopy/ (GNU)
# reconstruct URL from GET parameters
$resource= $_GET['request_uri_for_logscript'];
unset($_GET['request_uri_for_logscript']);
$query = array();
if ($url{strlen($url)-1}!="/") {
foreach( $_GET as $key => $item )
$query[] = $key . "=" . $item;
if ($query)
$resource .= "?".implode("&", $query);
}
$url = "http://".$_SERVER['SERVER_NAME']."/"."prefix_for_requests_from_logscript_".$resource;
# retrieve and show contents
$snoopy = new Snoopy;
$snoopy->_submit_method = $_SERVER['REQUEST_METHOD']; # this was actually meant to be a private variable... but...
$snoopy->cookies = $_COOKIE;
$snoopy->submit($url, $_POST, $_FILES);
foreach($snoopy->headers as $line)
header($line);
$contents = $snoopy->results;
echo $contents;
mylog(strlen($contents),$resource); # log success
exit;
function mylog($bytes,$res) {
$f = fopen(__FILE__.".log","a+");
fwrite($f,gmdate("Y/m/j H:i:s", time() + 3600*(1+date("I")))."\t".$bytes."\t".$res."\t");
fwrite($f,$_SERVER['REMOTE_ADDR']."\t".$_SERVER['HTTP_REFERER']."\t".$_SERVER['HTTP_USER_AGENT']."\r\n");
fclose($f);
}
?>

