PHP IIS Log analysis search engine crawler 1th/2 page _php instance

Source: Internet
Author: User
Tags explode php source code
Use Note:
To modify the absolute path of the IIS log in the iis.php file
For example: $folder = "c:/windows/system32/logfiles/site log directory/"; Be sure to bring a slash (/) in the back.
(with virtual space do not understand the absolute path of your site to see?) Upload a probe!
Direct Check view: http://site domain name/iis.php
Local view: To download the log to the local http://127.0.0.1/iis.php)
Attention:
Site Log directory, note that the directory must have site users Read permissions!
If you download the log to local please modify the 143 line URL for your website URL, this operation is not necessary operation, does not affect the analysis results.
Modifying the file name iis.php need to modify the corresponding code CTRL+H replace all iis.php with the file name you want to modify otherwise the program will run an error.
If the IIS log file is too large, it may cause the program to timeout! At the same time do not recommend everyone to use!
The following is the PHP source code:
[Code]
<?php
/*
Cowboy IIS log spider Crawl Record Analyzer V1.1 (PHP GB2312 version)
Author: Cowboy
qq:172379201
Email:17gd@163.com
*/
//===================================================
Header ("content-type:text/html; charset=gb2312 ");
Site Log directory, note that the directory must have site users Read permissions!
$folder = "c:/windows/system32/logfiles/w3svc1155699908/";//Remember to bring the slash behind!
$pagesize = 25;//Set the number of paging bar!
//=========================
$type = addslashes ($_get[' type '));
if ($type) $type = Base64_decode ($type);
$showfile = addslashes ($_get[' showfile '));
$page = addslashes ($_get[' page '));
if (! $page) $page = 1;
//============================
Open 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>
&LT;TD height=\ "25\" width=\ "25%\" align=\ "Center\" ><a href=\ "iisfile.php?type=". Base64_encode (Baiduspider). " &showfile= ". $arr _file[$i]." \ "> Baidu </a></td>
&LT;TD height=\ "25\" width=\ "25%\" align=\ "Center\" ><a href=\ "iisfile.php?type=". Base64_encode (Googlebot). " &showfile= ". $arr _file[$i]." \ "> Google (google) </a></td>
&LT;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 "This log directory does not exist or insufficient permissions, please check the settings!" ";
Exit ();
}
}elseif ($type = = ' Baiduspider ') {
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 = = ' Baiduspider ')
{
$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 "The log file does not exist, please 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>
&LT;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\ "> per page". $pagesize. "Article current". $page. " /$pagecount ";
$showpage. = "<a href=\" type= ". Base64_encode ($type)." &showfile= ". $showfile." \ "> Home </a>";
if ($page!=1)
{
$showpage. = "<a href=\" type= ". Base64_encode ($type)." &showfile= ". $showfile." &page= ". ($page-1). " \ "> Prev </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 </a>";
}
$showpage. = $weei. " </td> ";
if ($show)
{
$html = pagehtml ();
$copy = Mycopy ();
$htmltitle = "Cowboy IIS log Spider Crawl Record Analyzer-";//Please keep, 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 ("
Current 1/2 page 12 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.