Note:
Modify the absolute path of iis logs in the iis. php file
For example, $ folder = "c:/windows/system32/logfiles/site log directory/"; // remember to include a slash (/).
(If you use a virtual space, do you not know how to view the absolute path of your site? Upload probes for viewing!
Direct query: http: // site domain name/iis. php
Local view method: Download the log to the local http: // 127.0.0.1/iis. php)
Note:
// Site log directory. Note that the directory must have the site User read permission!
// If you download logs to your local machine, modify the web site of Line 1 to the web site of your website. This operation is not necessary and does not affect the analysis result.
// To modify the file name iis. php, You need to modify the corresponding code ctrl + h to replace all iis. php files with the file name you want to modify. Otherwise, the program will run incorrectly.
// If the iis log file is too large, the program may time out! We do not recommend that you use it!
The following is the PHP source code:
[Code]
<? Php
/*
Cowboy IIS log spider crawling log analyzer V1.1 (PHP GB2312)
Author: cowboy
QQ: 172379201
Email: 17gd@163.com
*/
// ================================================ ==================
Header ("content-type: text/html; charset = gb2312 ");
// Site log directory. Note that the directory must have the site User read permission!
$ Folder = "C:/WINDOWS/system32/LogFiles/W3SVC1155699908/"; // remember to include a slash!
$ Pagesize = 25; // you can specify the number of lines displayed on the page!
// ================================
$ Type = addslashes ($ _ GET ['type']);
If ($ type) $ type = base64_decode ($ type );
$ Showfile = addslashes ($ _ GET ['showfile']);
$ Page = addslashes ($ _ GET ['page']);
If (! $ Page) $ page = 1;
// ==================================
// Open the Directory
If (! $ Type ){
If (file_exists ($ folder ))
{
$ Fp = opendir ($ folder );
While (false! = $ File = readdir ($ fp ))
{
If ($ file! = '.' & $ File! = '..')
{
$ File = "$ file ";
$ Arr_file [] = $ file;
}
}
If (is_array ($ arr_file ))
{
For ($ I = count ($ arr_file)-1; $ I> = 0; $ I --)
{
$ Indexstr. = "<tr> <td height = \" 25 \ "width = \" 25% \ "> ". date ("Y-m-d", filectime ($ folder. $ arr_file [$ I]). "</td>
<Td height = \ "25 \" width = \ "25% \" align = \ "center \"> <a href = \ "iisfile. php? Type = ". base64_encode (Baiduspider)." & showfile = ". $ arr_file [$ I]." \ "> Baidu (Baidu) </a> </td>
<Td height = \ "25 \" width = \ "25% \" align = \ "center \"> <a href = \ "iisfile. php? Type = ". base64_encode (Googlebot)." & showfile = ". $ arr_file [$ I]." \ "> Google </a> </td>
<Td height = \ "25 \" width = \ "25% \" align = \ "center \"> <a href = \ "iisfile. php? Type = ". base64_encode (yahoo ). "& showfile = ". $ arr_file [$ I]. "\"> yahoo </a> </td> </tr> ";
}
}
Closedir ($ fp );
$ Html = indexhtml ();
$ Copy = mycopy ();
$ Html = str_replace ("[showlog]", $ indexstr, $ html );
$ Html = str_replace ("[copy]", $ copy, $ html );
Echo $ html;
} Else {
Echo "the log directory does not exist or has insufficient permissions. Check the settings! ";
Exit ();
}
} Elseif ($ type = 'baidider ider '){
Echo show ($ type, $ folder, $ showfile, $ page, $ pagesize );
} Elseif ($ type = 'googlebot '){
Echo show ($ type, $ folder, $ showfile, $ page, $ pagesize );
} Elseif ($ type = 'yahoo '){
Echo show ($ type, $ folder, $ showfile, $ page, $ pagesize );
}
Function show ($ type, $ folder, $ showfile, $ page, $ pagesize)
{
If ($ type = 'baidider ider ')
{
$ Title = 'Baidu ';
} Elseif ($ type = 'googlebot '){
$ Title = 'Google ';
} Elseif ($ type = 'yahoo '){
$ Title = 'yahoo ';
}
If ($ type & $ folder & $ showfile)
{
If (file_exists ($ folder. $ showfile ))
{
$ Fp = fopen ($ folder. $ showfile, "r ");
} Else {
Echo "this log file does not exist. Check the settings! ";
Exit;
}
$ J = 0;
$ Y = 0;
$ T = 0;
$ H = 0;
While (! Feof ($ fp ))
{
$ Str = fgets ($ fp );
$ Str = iconv ("UTF-8", "GB2312 // IGNORE", $ str );
If (strpos ($ str, $ type ))
{
$ J ++;
$ Temp []. = $ str;
$ Tmpcount = explode ("", $ str );
If ($ tmpcount [11] = 200) $ t ++;
If ($ tmpcount [11] = 304) $ h ++;
If ($ tmpcount [11] = 404) $ y ++;
}
}
Fclose ($ fp );
$ Count = count ($ temp );
If ($ page = 1)
{
$ Countshow = $ count;
$ Mynum = $ count-$ pagesize;
} Else {
$ Countshow = $ count-($ page * $ pagesize-$ pagesize );
$ Mynum = $ count-$ page * $ pagesize;
}
$ Pagecount = ceil (count ($ temp)/$ pagesize );
If ($ page> = $ pagecount)
{
$ Mynum = $ pagecount;
}
$ M = 0;
For ($ I = $ countshow-1; $ I >=$ mynum; $ I --)
{
$ Num = explode ("", $ temp [$ I]);
$ Show. ="
<Tr>
<Td heigth \ "20 \"> ". $ num [0]." ". $ num [1]." </td>
<Td> ". $ num [9]." </td>
<Td> <a href = \"". rawurlencode ($ num [5]). "\" target = \ "_ blank \"> ". $ num [5]. "</a> </td>
<Td> ". $ num [11]." </td>
</Tr> ";
}
Unset ($ temp );
$ Showpage = "<td colspan = \" 4 \ "height = \" 30 \ "align = \" center \ "> each page ". $ pagesize. "current ". $ page. "/$ pagecount ";
$ Showpage. = "<a href = \"? Type = ". base64_encode ($ type)." & showfile = ". $ showfile." \ "> homepage </a> ";
If ($ page! = 1)
{
$ Showpage. = "<a href = \"? Type = ". base64_encode ($ type ). "& showfile = ". $ showfile. "& page = ". ($ page-1 ). "\"> previous page </a> ";
}
If ($ page! = $ Pagecount)
{
$ Showpage. = "<a href = \"? Type = ". base64_encode ($ type ). "& showfile = ". $ showfile. "& page = ". ($ page + 1 ). "\"> next page </a> ";
$ Weei = "<a href = \"? Type = ". base64_encode ($ type ). "& showfile = ". $ showfile. "& page = ". ($ pagecount ). "\"> last page </a> ";
}
$ Showpage. = $ weei. "</td> ";
If ($ show)
{
$ Html = pagehtml ();
$ Copy = mycopy ();
$ Htmltitle = "cowboy IIS log spider crawling record analyzer-"; // please keep it, thank you!
$ Html = str_replace ("[title]", $ title, $ html );
$ Html = str_replace ("[htmltitle]", $ htmltitle, $ html );
$ Html = str_replace ("[show]", $ show, $ html );
$ Html = str_replace ("[count]", $ j, $ html );
$ Html = str_replace ("