lovecom
中级会员
 
UID 80708
精华
0
积分 212
帖子 101
金钱 212 喜悦币
威望 0
人脉 0
阅读权限 30
注册 2006-9-28
状态 离线
|
[推荐阅读] 求助:我该怎么办?
日志文件太大,或者处理多个文件这样肯定不行。
$dir = "logs";
$handle = opendir($dir);
while (false !== ($fname = readdir($handle))) {
if ($fname != ".." && $fname != ".") {
$fd = fopen("$dir/$fname","r");
while ($str = fgets($fd)){
$match = "/([0-9.]*) \- \- \[([A-Za-z0-9:\/]*) \+[0-9]{4}\] \"GET \/(.*) HTTP\/1.1\" ([0-9-]+) ([0-9-]*)/siU";
preg_match($match,$str,$matches);
$ip = $matches[1];
$gettime = $matches[2];
$url=$matches[3];
}
之后对正则匹配出来的结果进行处理。最后只将计算结果入库
|
|