Page 1 of 1

Not sure if this is possible, but....

Posted: Tue Jun 03, 2008 8:59 am
by Zanne
Basically I have 2 files, TextToBeFound.txt and WebLogs.txt. I want to search each line from TextToBeFound.text to WebLogs.txt. If I can't find a file, say /images/.htaccess, I want to echo the result as something not found. If I find a match between TextToBeFound.txt, I want to move onto the next item to be found, which would be /images/smiley.jpg, in TextToBeFound.txt

TextToBeFound.txt:
/index.php
/test.php
/images/.htaccess
/images/smiley.jpg
/images/banner.jpg
/images/footer.jpg
/includes/index.php
/inlcudes/header.php
/includes/footer.php
/includes/banner_home.php

WebLogs.txt:
77.232.66.15 - - [01/May/2008:00:00:09 -0700] "GET /index.php HTTP/1.1" 200 4433 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
211.28.180.76 - - [01/May/2008:00:16:30 -0700] "GET /images/smiley.jpg HTTP/1.1" 200 4433 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
211.28.180.76 - - [01/May/2008:00:16:30 -0700] "GET /images/Banner.jpg HTTP/1.1" 200 21615 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
211.28.180.76 - - [01/May/2008:00:16:36 -0700] "GET /images/banner.jpg HTTP/1.1" 200 194180 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
211.28.180.76 - - [01/May/2008:00:17:26 -0700] "GET /images/footer.jpg HTTP/1.1" 404 390 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"
211.28.180.76 - - [01/May/2008:00:17:32 -0700] "GET /test.php HTTP/1.1" 206 48180 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)"

Here's the code I have so far. Please help! If you know of any software that can do this, please also let me know =)

<?
$text=fopen("TextToBeFound.txt", r);
$logs=fopen("WebLogs.txt", r);

while (!feof($text)) {
$line=fgets($text);
while (!feof($text2)) {
$line2=fgets(text2);
//Refer to Question
}
fclose(text2);
}
fclose($text);