仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1471|回复: 19
打印 上一主题 下一主题

[学习教程] PHP网页编程之IIS日记剖析搜刮引擎爬虫纪录法式

[复制链接]
透明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:53:53 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
告诉你了一个方式,但是缺少努力这一环节,那也是白搭。   利用注重:
  修正iis.php文件中iis日记的相对途径
  例如:$folder=”c:/windows/system32/logfiles/站点日记目次/”; //前面记得必定要带斜杠(/)。
  ( 用虚拟空间的不懂检查你的站点相对途径?上传个探针检查!
  直接检查法:http://站点域名/iis.php
  当地检查法:把日记下载到当地 http://127.0.0.1/iis.php )
  注重:
  //站点日记目次,注重该目次必需要有站点用户读取权限!
  //假如把日记下载到当地请修正143行的网址为您网站的网址,此操作不是需要操作,不影响剖析了局。
  //修正文件称号iis.php 需求同时修正对应代码 ctrl+h 把 iis.php全体交换成您要修正的文件名 不然法式运转失足。
  //假如iis日记文件过大,能够会招致法式超时!同时也不建议人人利用!


  以下是PHP源代码:
<?php
/*
  牛仔IIS日记蜘蛛匍匐纪录剖析器 V1.1(PHP GB2312 版)
  作者:牛仔
  QQ:172379201
  Email:17gd@163.com
*/
//===================================================
  header("content-type:text/html; charset=gb2312");
//站点日记目次,注重该目次必需要有站点用户读取权限!
//假如把日记下载到当地请修正143行的网址为您网站的网址,此操作不是需要操作,不影响剖析了局。
//假如修正了文件称号iis.php 需求同时修正代码 Ctrl+H 把 iis.php全体交换成您要修正的文件名 不然法式运转失足。
&#36;folder="D:/Vhost/WebRoot/jooker82465/www/wordpress/uploads/W3SVC87164023/";  //前面记得必定要带斜杠 / !
&#36;pagesize = 50;//设置分页显示条数!
//=========================
&#36;type = addslashes(&#36;_GET[’type’]);
if (&#36;type)&#36;type = base64_decode(&#36;type);
&#36;showfile = addslashes(&#36;_GET[’showfile’]);
&#36;page = addslashes(&#36;_GET[’page’]);
if (!&#36;page)&#36;page=1;
//============================
//翻开目次
if (!&#36;type){
if (file_exists(&#36;folder))
{
  &#36;fp=opendir(&#36;folder);
  while(false!=&#36;file=readdir(&#36;fp))
  {
     if(&#36;file!=’.’ &&&#36;file!=’..’)
     {
         &#36;file="&#36;file";
         &#36;arr_file[]=&#36;file;
        }
  }
  if(is_array(&#36;arr_file))
  {
   for (&#36;i=count(&#36;arr_file)-1;&#36;i>=0;&#36;i--)
   {
    &#36;indexstr.="
<tr><td height=\"25\" width=\"10%\">".date("Y-m-d",filectime(&#36;folder.&#36;arr_file[&#36;i]))."</td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(Baiduspider)."&showfile=".&#36;arr_file[&#36;i]."\">百度(Baidu)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(Googlebot)."&showfile=".&#36;arr_file[&#36;i]."\">谷歌(Google)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(yahoo)."&showfile=".&#36;arr_file[&#36;i]."\">雅虎(yahoo)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(YodaoBot)."&showfile=".&#36;arr_file[&#36;i]."\">有道(yodao)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(Sosospider)."&showfile=".&#36;arr_file[&#36;i]."\">搜搜(soso)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(Sogou)."&showfile=".&#36;arr_file[&#36;i]."\">搜狗(sogou)</a></td>
<td height=\"25\" width=\"10%\" align=\"center\">
<a href=\"iis.php?type=".base64_encode(msnbot)."&showfile=".&#36;arr_file[&#36;i]."\">微软(msn)</a></td>
</tr>";
   }
   }
closedir(&#36;fp);
&#36;html = indexhtml();
&#36;copy = mycopy();
&#36;html = str_replace("[showlog]",&#36;indexstr,&#36;html);
&#36;html = str_replace("[copy]",&#36;copy,&#36;html);
echo &#36;html;
}else{
  echo "该日记目次不存在或权限缺乏,请反省设置!";
  exit();
}
}elseif (&#36;type==’Baiduspider’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’Googlebot’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’yahoo’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’YodaoBot’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’Sosospider’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’Sogou’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}elseif (&#36;type==’msnbot’){
  echo show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize);
}

function show(&#36;type,&#36;folder,&#36;showfile,&#36;page,&#36;pagesize)
{
if (&#36;type==’Baiduspider’)
{
  &#36;title=’百度’;
}elseif (&#36;type==’Googlebot’){
  &#36;title=’谷歌’;
}elseif (&#36;type==’yahoo’){
  &#36;title=’雅虎’;
}elseif (&#36;type==’YodaoBot’){
  &#36;title=’有道’;
}elseif (&#36;type==’Sosospider’){
  &#36;title=’搜搜’;
}elseif (&#36;type==’Sogou’){
  &#36;title=’搜狗’;
}elseif (&#36;type==’msnbot’){
  &#36;title=’MSN’;
}
if (&#36;type&&&#36;folder&&&#36;showfile)
{
  if(file_exists(&#36;folder.&#36;showfile))
  {
  &#36;fp= fopen(&#36;folder.&#36;showfile,"r");
  }else{
   echo "该日记文件不存在,请反省设置!";
   exit;
  }
  &#36;j=0;
  &#36;y=0;
  &#36;t=0;
  &#36;h=0;
  while (!feof(&#36;fp))
  {
   &#36;str = fgets(&#36;fp);
    &#36;str =iconv("UTF-8","GB2312//IGNORE",&#36;str);
   if(strpos(&#36;str,&#36;type))
   {
    &#36;j++;
    &#36;temp[].=&#36;str;
    &#36;tmpcount = explode(" ",&#36;str);
    if (&#36;tmpcount[11]==200)&#36;t++;
    if (&#36;tmpcount[11]==304)&#36;h++;
    if (&#36;tmpcount[11]==404)&#36;y++;
   }
  }
  fclose(&#36;fp);
  &#36;count = count(&#36;temp);
  if (&#36;page==1)
  {
   &#36;countshow=&#36;count;
   &#36;mynum = &#36;count-&#36;pagesize;
  }else{
   &#36;countshow =&#36;count-(&#36;page*&#36;pagesize-&#36;pagesize);
   &#36;mynum = &#36;count-&#36;page*&#36;pagesize;
  }
  &#36;pagecount =ceil(count(&#36;temp) / &#36;pagesize);
  if (&#36;page>=&#36;pagecount)
  {
   &#36;mynum = &#36;pagecount;
  }
  &#36;m=0;
  for (&#36;i=&#36;countshow-1;&#36;i>=&#36;mynum;&#36;i--)
  {
   &#36;num = explode(" ",&#36;temp[&#36;i]);
            &#36;domain="http://tarr.cn"; //网站URL 末尾不要带斜杠
    &#36;show.="
<tr onMouseOut=\"this.style.backgroundColor=’#FFFFFF’\" onMouseOver=\"this.style.backgroundColor=’#F6F6F6’\">
<td class=\"c\" width=\"200;\">".&#36;num[0]." ".&#36;num[1]."</td>
<td class=\"c\">".&#36;num[9]."</td>
<td class=\"pl\"><a href=\"&#36;domain&#36;num[5]\" _fcksavedurl="\"&#36;domain&#36;num[5]\"" target=\"_blank\">".&#36;num[5]."</a></td>
<td class=\"c\">".&#36;num[11]."</td>
</tr>";
  }
  unset(&#36;temp);
  &#36;showpage = "<td colspan=\"4\" height=\"30\" align=\"center\">每页 ".&#36;pagesize." 条 以后".&#36;page."/&#36;pagecount";
  &#36;showpage.="  <a href=\"?type=".base64_encode(&#36;type)."&showfile=".&#36;showfile."\">首页</a>";
  if (&#36;page!=1)
  {
   &#36;showpage.="  <a href=\"?type=".base64_encode(&#36;type)."&showfile=".&#36;showfile."&page=".(&#36;page-1)."\">上一页</a>";
  }
  if (&#36;page!=&#36;pagecount)
  {
  &#36;showpage.="  <a href=\"?type=".base64_encode(&#36;type)."&showfile=".&#36;showfile."&page=".(&#36;page+1)."\">下一页</a>";
  &#36;weei = "  <a href=\"?type=".base64_encode(&#36;type)."&showfile=".&#36;showfile."&page=".(&#36;pagecount)."\">尾页</a>";
  }
  &#36;showpage.=&#36;weei."</td>";
  if (&#36;show)
  {
  &#36;html = pagehtml();
  &#36;copy = mycopy();
  &#36;htmltitle = "牛仔IIS日记蜘蛛匍匐纪录剖析器 茄咧啡修正版";//请保存,感谢!
  &#36;html = str_replace("[title]",&#36;title,&#36;html);
  &#36;html = str_replace("[htmltitle]",&#36;htmltitle,&#36;html);
  &#36;html = str_replace("[show]",&#36;show,&#36;html);
  &#36;html = str_replace("[count]",&#36;j,&#36;html);
  &#36;html = str_replace("
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-22 06:25

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表