php实现查看邮件是否已被阅读的方法
程序员文章站
2022-06-22 21:00:12
当你在发送邮件时,你或许很想知道该邮件是否被对方已阅读。这里有段非常有趣的代码片段能够显示对方ip地址记录阅读的实际日期和时间。 复制代码 代码如下: erro...
当你在发送邮件时,你或许很想知道该邮件是否被对方已阅读。这里有段非常有趣的代码片段能够显示对方ip地址记录阅读的实际日期和时间。
<?
error_reporting(0);
header("content-type: image/jpeg");
//get ip
if (!empty($_server['http_client_ip']))
{
$ip=$_server['http_client_ip'];
}
elseif (!empty($_server['http_x_forwarded_for']))
{
$ip=$_server['http_x_forwarded_for'];
}
else
{
$ip=$_server['remote_addr'];
}
//time
$actual_time = time();
$actual_day = date('y.m.d', $actual_time);
$actual_day_chart = date('d/m/y', $actual_time);
$actual_hour = date('h:i:s', $actual_time);
//get browser
$browser = $_server['http_user_agent'];
//log
$myfile = "log.txt";
$fh = fopen($myfile, 'a+');
$stringdata = $actual_day . ' ' . $actual_hour . ' ' . $ip . ' ' . $browser . ' ' . "\r\n";
fwrite($fh, $stringdata);
fclose($fh);
//generate image (es. dimesion is 1x1)
$newimage = imagecreate(1,1);
$grigio = imagecolorallocate($newimage,255,255,255);
imagejpeg($newimage);
imagedestroy($newimage);
?>
复制代码 代码如下:
<?
error_reporting(0);
header("content-type: image/jpeg");
//get ip
if (!empty($_server['http_client_ip']))
{
$ip=$_server['http_client_ip'];
}
elseif (!empty($_server['http_x_forwarded_for']))
{
$ip=$_server['http_x_forwarded_for'];
}
else
{
$ip=$_server['remote_addr'];
}
//time
$actual_time = time();
$actual_day = date('y.m.d', $actual_time);
$actual_day_chart = date('d/m/y', $actual_time);
$actual_hour = date('h:i:s', $actual_time);
//get browser
$browser = $_server['http_user_agent'];
//log
$myfile = "log.txt";
$fh = fopen($myfile, 'a+');
$stringdata = $actual_day . ' ' . $actual_hour . ' ' . $ip . ' ' . $browser . ' ' . "\r\n";
fwrite($fh, $stringdata);
fclose($fh);
//generate image (es. dimesion is 1x1)
$newimage = imagecreate(1,1);
$grigio = imagecolorallocate($newimage,255,255,255);
imagejpeg($newimage);
imagedestroy($newimage);
?>
上一篇: php查找任何页面上的所有链接的方法
下一篇: PHP5 操作MySQL数据库基础代码