我正在研究一个跟踪像素,它应该将请求者的ip和一些其他信息记录到html文件中,但html文件永远不会被创建,如果我创建它,它将保持为空。
<?php
// Create an image, 1x1 pixel in size
$im=imagecreate(1,1);
// Set the background colour
$white=imagecolorallocate($im,255,255,255);
// Allocate the background colour
imagesetpixel($im,1,1,$white);
// Set the image type
header("content-type:image/jpg");
// Create a JPEG file from the image
imagejpeg($im);
// Free memory associated with the image
imagedestroy($im);
// Server variables
$ip = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$useragent = $_SERVER['HTTP_USER_AGENT'];
$browser = get_browser(null, true);
$fecha = date("Y-m-d;h:i:s");
if (isset($_GET['type'])) {
$type = $_GET['type'];
}
$f = fopen("list.html", "a");
fwrite ($f,
'IP: [<b><font color="#660000">'.$ip.'</font></b>]
Referer: [<b><font color="#9900FF">'.$referer.'</font></b>]
User Agent: [<b><font color="#996600">'.$useragent.'</font></b>]
Browser: [<b><font color="#996600">'.$browser.'</font></b>]
Date: [<b><font color="#FF6633">'.$fecha.'</font></b>]<br> ');
if (isset($type) {
fwrite ($f, 'Type: [<b><font color="#660000">'.$type.'</font></b>]'
fclose($f);
?>
答案 0 :(得分:0)
您的脚本末尾有错误,必须是:
if ( isset($type) ) {
fwrite ($f, 'Type: [<b><font color="#660000">'.$type.'</font></b>]');
fclose($f);
}
?>
更正了,您的脚本正常工作