php 记录图片浏览次数次数
<?php
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
$lab =$_GET['lab'];
$fp = fopen('ipdata.txt','ar+');
$i = 1;
if(filesize('ipdata.txt') > 0)
{
$t = array();
$content = fread($fp,filesize('ipdata.txt'));
$t = split("\n",$content);
$i = sizeof($t);
}
$record = $i.' ip: '.$_SERVER['REMOTE_ADDR'].' date: '.date('Y-m-d H:i:s')."\n";
fwrite($fp,$record);
fclose($fp);
$filename = "001.jpg";
$size = getimagesize($filename); //获取mime信息
$fp=fopen($filename, "rb"); //二进制方式打开文件
if ($size && $fp) {
header("Content-type: {$size['mime']}");
fpassthru($fp); // 输出至浏览器
exit;
} else {
// error
}
?>