Due to the recent busy schedule, the code is not properly written, and the interface is not beautified. please use it first. new features will be released to you as soon as they are added! Due to the recent busy schedule, the code is not properly written, and the interface is not beautified. please use it first. new features will be released to you as soon as they are added!
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 logs to Local #)
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:
The code is as follows:
/*
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. ="". Date (" Y-m-d ", filectime ($ folder. $ arr_file [$ I])."
Baidu (Baidu)
Google)
Yahoo)";
}
}
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. ="
". $ Num [0]." ". $ num [1]."
". $ Num [9]."
". $ Num [5]."
". $ Num [11]."
";
}
Unset ($ temp );
$ Showpage ="". $ Pagesize." current ". $ page."/$ pagecount ";
$ Showpage. = "homepage ";
If ($ page! = 1)
{
$ Showpage. = "previous page ";
}
If ($ page! = $ Pagecount)
{
$ Showpage. = "next page ";
$ Weei = "Last page ";
}
$ Showpage. = $ weei ."";
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 ("", $ showpage, $ html );
$ Html = str_replace ("[y]", $ y, $ html );
$ Html = str_replace ("[t]", $ t, $ html );
$ Html = str_replace ("[h]", $ h, $ html );
$ Html = str_replace ("[copy]", $ copy, $ html );
Return $ html;
}
}
}