我很好奇啊,是怎么篡改的,谁来说说,网站统计次数被篡改

WBOY
Release: 2016-06-23 14:24:44
Original
989 people have browsed it

本帖最后由 xjl756425616 于 2013-10-22 09:16:19 编辑

被人统计次数改了
原本3650多
被改成了50多,今天早晨6:22分改的,貌似是广东深圳那边的IP




代码如下
<?php	$file_name=$_REQUEST['name'];	$file_name=iconv("utf-8","gb2312",$file_name);	$file_dir="./download/";	if(!file_exists($file_dir.$file_name))	{		echo "文件找不到!";		exit;	}	else	{		header("Content-Type:text/plain");  		header("Accept-Ranges:bytes");		header("Content-Disposition:attachment;filename=".$file_name);		$file=fopen($file_dir.$file_name,"r");		echo fread($file,filesize($file_dir.$file_name));		fclose($file);		$num=file_get_contents("./num.dat");		$num=(int)($num)+1;		file_put_contents("./num.dat",$num);		exit;	}?>
Copy after login

回复讨论(解决方案)

1.程序可被用来下载任意文件。

2.文本计数器,可能你在读取后,从修改数据到写入数据之间,被其它人的请求优先写入了,导致数据不准。

        $num=file_get_contents("./num.dat");
        $num=(int)($num)+1;
         file_put_contents("./num.dat",$num);

写文件不加锁?必然会因并发造成数据丢失

用 数据库。更准确

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!