发款php蜘蛛统计插件只要有mysql就可用

前端之家收集整理的这篇文章主要介绍了发款php蜘蛛统计插件只要有mysql就可用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

于是昨天便认真的做了一下,功能多一点,可以对各种搜索引擎统计分析。可以在多个时间段进行查看。其实代码很简单,为了更简洁些,代码压缩到6k.分为6个文件
1.安装程序 spilder_install.PHP
<div class="codetitle"><a style="CURSOR: pointer" data="55038" class="copybut" id="copybut55038" onclick="doCopy('code55038')"> 代码如下:

<div class="codebody" id="code55038">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;


安装<a href="/tag/chajian/" target="_blank" class="keywords">插件</a>

<?PHP
if($_POST['act']=='install')//如果是安装
{
$MysqL_host=trim($_POST['MysqL_host']);//获取主机
$MysqL_user=trim($_POST['MysqL_user']);//获取用户名
$MysqL_pwd=trim($_POST['MysqL_pwd']);//获取密码
$MysqL_db=trim($_POST['MysqL_db']);//数据库
$table_prefix=trim($_POST['table_prefix']);//获取前缀
if($link=MysqL_connect($MysqL_host,$MysqL_user,$MysqL_pwd))
{
echo "连接服务器成功!.................
";
}
else
{
echo "";
}
if(MysqL_select_db($MysqL_db,$link))
{
echo "连接数据库成功!.............
正在创建表................
";
}
$sql="CREATE TABLE spilder_sp_count (
id bigint(20) NOT NULL auto_increment,
r_time int(11) NOT NULL,
r_name varchar(50) NOT NULL,
r_url varchar(200) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=4 ;
";
MysqL_query("DROP TABLE IF EXISTS ".$table_prefix."sp_count;");//删除已存在
$sql=strreplace("spilder",$table_prefix,$sql);//替换前缀
if(MysqL_query($sql))
{
echo "表创建成功!正在写入文件";
}
$f=file_get_contents("spilder_config.PHP");//获取配置内容
$f=str_replace(" ","",$f);//去除空格
$f=preg_replace("/MysqL_host=.;/iUs","MysqL_host='{$MysqL_host}';",$f);
$f=preg_replace("/MysqL_user=.
;/iUs","MysqL_user='{$MysqL_user}';",$f);
$f=preg_replace("/MysqL_pwd=.;/iUs","MysqL_pwd='{$MysqL_pwd}';",$f);
$f=preg_replace("/MysqL_db=.
;/iUs","MysqL_db='{$MysqL_db}';",$f);
$f=preg_replace("/table_prefix=.;/iUs","table_prefix='{$table_prefix}';",$f);
$f=preg_replace("/sp_admin=.
;/iUs","sp_admin='{$sp_admin}';",$f);
file_put_contents("spilder_config.PHP",$f);
file_put_contents("isinstall.txt","OK");
echo "恭喜!荐礼啦蜘蛛统计程序安装成功 <a href=\"index.php\">查看";
exit();
}
?>

<table width="600" border="0" align="center">
<tr>
<td align="center">荐礼啦 蜘蛛统计查看器</td>
</tr>
</table>
<form method="post">
<table width="600" border="0" align="center" cellspacing="0">
<tr>
<td width="280"></td>
<td width="610">开始安装</td>
</tr>
<tr>
<td align="right">服务器:</td>
<td>
(一般不用改)</td>
</tr>
<tr>
<td align="right">用户名:</td>
<td></td>
</tr>
<tr>
<td align="right">密码:</td>
<td></td>
</tr>
<tr>
<td align="right">数据库:</td>
<td></td>
</tr>
<tr>
<td align="right">表前缀:</td>
<td>
</td>
</tr>
<tr>
<td align="right">管理密码:</td>
<td></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
</tr>
</table>




2.蜘蛛记录文件
<div class="codetitle"><a style="CURSOR: pointer" data="46752" class="copybut" id="copybut46752" onclick="doCopy('code46752')"> 代码如下:
<div class="codebody" id="code46752">
<?PHP
require("spilder_config.PHP");//调用配置文件
$link=MysqL_connect($MysqL_host,$MysqL_pwd) or die("服务器连接出错");//链接数据库
MysqL_select_db($MysqL_db,$link) or die('数据库连接出错');
$searchbot = get_naps_bot();
if($searchbot)
{
date_default_timezone_set('PRC'); //设置默认时区
$r_time=strtotime(date("Y-m-d H:i:s"));//最后更新时间
$ServerName = $_SERVER["SERVER_NAME"] ;
$ServerPort = $_SERVER["SERVER_PORT"] ;
$ScriptName = $_SERVER["SCRIPT_NAME"] ;
$QueryString = $_SERVER["QUERY_STRING"] ;
$url="http://".$ServerName ;
If ($ServerPort != "80")
{
$url = $url.":".$ServerPort ;
}
$url=$url.$ScriptName ;
If ($QueryString !="")
{
$url=$url."?".$QueryString ;
}
//$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$GLOBALS['db']->db_query("insert into {$table_prefix}sp_count(r_time,r_name,r_url) values('$r_time','$searchbot','$url')");
}
function get_naps_bot()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent,'googlebot') !== false){
return 'Googlebot';
}elseif (strpos($useragent,'msnbot') !== false){
return 'MSNbot';
}elseif (strpos($useragent,'slurp') !== false){
return 'Yahoobot';
}elseif (strpos($useragent,'baiduspider') !== false){
return 'Baiduspider';
}elseif (strpos($useragent,'sogou') !== false){
return 'Sogoubot';
}elseif (strpos($useragent,'soso') !== false){
return 'Sosobot';
}elseif(strpos($useragent,'youdao')!==false)
{
return 'Youdao';
}
else
{
return false;
}
}
?>

3.蜘蛛统计查看文件
<div class="codetitle"><a style="CURSOR: pointer" data="24725" class="copybut" id="copybut24725" onclick="doCopy('code24725')"> 代码如下:
<div class="codebody" id="code24725">
<?PHP
session_start();
require("spilder_config.PHP");
if($_GET['act']=='logout')
{
$_SESSION['ss_sp_admin']='';//清空
}
if($_GET['sp_admin_login'])
{
if($_GET['sp_admin_login']==$sp_admin)
{
$_SESSION['ss_sp_admin']=$sp_admin;
}
}
date_default_timezone_set('PRC'); //设置默认时区
$day_start=strtotime(date("Ymd")."000001");//一天的开始时间
$day_out=strtotime(date("Ymd")."235959");//一天的结束时间
$day=360024;//一天的时间
$link=MysqL_connect($MysqL_host,$MysqL_pwd) or die("服务器连接出错");
MysqL_select_db($MysqL_db,$link) or die('链接数据库出错');//连接数据库
if($_GET['act']=='del')
{
if($_SESSION['ss_sp_admin']<>'')
{
if($_GET['dt']==0)//清空
{
MysqL_query("delete from {$table_prefix}sp_count ");
}
$d_time=0;
if($_GET['dt']==1)//删除30天前
{
$d_time=$day_out-$day
30;
}elseif($_GET['dt']==2)//删除60天前
{
$d_time=$day_out-$day60;
}elseif($_GET['dt']==3)//删除90天前
{
$d_time=$day_out-$day
90;
}elseif($_GET['dt']==4)//删除180天前
{
$d_time=$day_out-$day180;
}elseif($_GET['dt']==5)//删除360天前
{
$d_time=$day_out-$day
360;
}
if($d_time>0)
{
MysqL_query("delete from {$table_prefix}sp_count where r_time<'$d_time'");//删除数据
}
}
}
$ss=intval($_GET['ss']);
if($ss>0)//查看分类统计
{
if($ss==999)//清空分类
{
$_SESSION['ss_ss']='';
}else
{
$_SESSION['ss_ss']=$ss;
}
}
$ss=$_SESSION['ss_ss'];
if($ss==1)
{
$ss='Baiduspider';
}elseif($ss==2)
{
$ss='Googlebot';
}elseif($ss==3)
{
$ss="MSNbot";
}elseif($ss==4)
{
$ss="Yahoobot";
}elseif($ss==5)
{
$ss="Sogoubot";
}elseif($ss==6)
{
$ss="Sosobot";
}elseif($ss==7)
{
$ss=7;
}
$t=intval($_GET['t']);//查看时间分类统计
if($t==0)//时时情况
{
if(empty($_SESSION['ss_ss']))
{
$sql =" select from {$table_prefix}sp_count order by id desc ";//最新情况
$sql2="select count(
) from {$table_prefix}sp_count ";
}else
{
$sql="select from {$table_prefix}sp_count where r_name='$ss' order by id desc ";
$sql2="select count(
) from {$table_prefix}sp_count where r_name='$ss' ";
}
$rscount=MysqL_query($sql2);
$rscount=@MysqL_fetch_array($rscount);
$rscount=$rscount[0];//获取总记录数
$page=intval(trim($_GET['page']));//当前页数
$pagesize=30;//每页记录数
$pagecount=ceil($rscount/$pagesize);//获取总页数
$pageurl="";
if($page<=1)
{
$page=1;
$pageurl.=" 首页 上一页";
}else
{
$pageurl .=" 首页 上一页";
}
if($page>=$pagecount)
{
$page=$pagecount;
$pageurl .=" 下一页 尾页";
}else
{
$pageurl .=" 下一页 尾页";
}
if($page<=1)
{
$page=1;
}
$start_rs=intval(($page-1)$pagesize);//开始
$end_rs=intval($page
$pagesize);//结束
$sql .=" limit {$start_rs},{$end_rs} ";
}
if($t==1)//查看今天天统计
{
$s_time=$day_start;//开始时间
$e_time=$day_out;//结束时间
$sql="select count() as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name ";
}elseif($t==2)//查看昨天统计
{
$s_time=$day_start-$day;//开始
$e_time=$day_out-$day;//结束
$sql="select count(
) as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name ";
}elseif($t==3)//查看前天天的统计
{
$s_time=$day_start-$day2;
$e_time=$day_out-$day
2;
$sql="select count() as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name";
}elseif($t==4)//查看七天的统计
{
$s_time=$day_start-$day
7;
$e_time=$day_out;
$sql="select count() as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name ";
}
elseif($t==5)//查看30天的
{
$s_time=$day_start-$day
30;
$e_time=$day_out;
$sql="select count() as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name ";
}elseif($t==6)//查看90天的统计
{
$s_time=$day_start-$day
90;
$e_time=$day_out;
$sql="select count(*) as ct,r_name from {$table_prefix}sp_count where r_time between '$s_time' and '$e_time' group by r_name ";
}
$res=MysqL_query($sql);// or die("请先安装程序安装");
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;


<a href="/tag/xianshi/" target="_blank" class="keywords">显示</a>蜘蛛记录情况
<style type="text/css">
td{font-size:14px;}
a,a:link{text-decoration:none; color:#000; }
a:hover{color:#F00;}



<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-bottom:6px;">
<tr>
<td height="28" align="center" bgcolor="#66CC00">

<a href="http://www.jianlila.com" target="_blank">荐礼啦 蜘蛛查看器

</td>
</tr>
</table>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td width="65" height="38" bgcolor="#FFFFFF">分类查看</td>
<td width="403" align="center" bgcolor="#FFFFFF">
<a href="?ss=999">所有的
<a href="?ss=1">百度
<a href="?ss=2">谷歌
<a href="?ss=3">必应
<a href="?ss=4">雅虎
<a href="?ss=5">搜狗
<a href="?ss=6">搜搜
<a href="?ss=7">有道</td>
<td width="322" bgcolor="#FFFFFF">
<a href="?t=0">时时
<a href="?t=1">今天
<a href="?t=2">昨天
<a href="?t=3">前天
<a href="?t=4">七天
<a href="?t=4">30天
<a href="?t=5">90天
</td>
</tr>
</table>
<?PHP
if($_SESSION['ss_sp_admin']==$spadmin)
{
?>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:12px; margin-bottom:12px;">
<tr>
<td width="208" align="right" bgcolor="#FFFFFF">管理<a href="?act=logout">退出 </td>
<td width="585" align="center" bgcolor="#FFFFFF">
<a href="?act=del&dt=0" onclick="return confirm('确定清空')">清空
@L
404_17@
<a href="?act=del&dt=3" onclick="return confirm('确定删除?')">90天前
<a href="?act=del&dt=4" onclick="return confirm('确定删除?')">180天前
<a href="?act=del&dt=5" onclick="return confirm('确定删除?')">360天前</td>
</tr>
</table>
<?php
}
?>
<?php
if($t==0)
{
?>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:6px;">
<tr>
<td width="133" align="center" bgcolor="#FFFFFF">蜘蛛</td>
<td width="217" align="center" bgcolor="#FFFFFF">时间</td>
<td width="440" align="center" bgcolor="#FFFFFF">地址</td>
</tr>
<?php
while($rs=mysql_fetch_array($res))
{
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><?php echo $rs['r_name'];?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo date("Y-m-d H:i:s",$rs['r_time']); ?></td>
<td align="center" bgcolor="#FFFFFF"><a href="<?php echo $rs['r_url'];?>" target="_blank"> <?php echo $rs['r_url'];?></td>
</tr>
<?PHP
}
?>
</table>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:20px; margin-bottom:20px;">
<tr>
<td align="center" bgcolor="#FFFFFF"><?php echo $pageurl;?></td>
</tr>
</table>
<?PHP
}else{
?>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:6px;">
<tr>
<td width="219" align="center" bgcolor="#FFFFFF">蜘蛛</td>
<td width="574" align="center" bgcolor="#FFFFFF">统计</td>
</tr>
<?PHP
while($rs=MysqL_fetch_array($res))
{
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><?php echo $rs['r_name'] ?></td>
<td align="center" bgcolor="#FFFFFF"><?php echo $rs['ct'];?></td>
</tr>
<?PHP
}
?>
</table>
<?PHP
}
?>
<table width="800" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC" style="margin-top:6px;">
<tr>
<td align="center" bgcolor="#FFFFFF">友情链接:<a href="http://www.jianlila.com" target="_blank">荐礼啦 <a href="http://www.aiwobama.com" target="_blank">爱我爸妈 <a href="http://www.heikediguo.net"&gt;黑客帝国</td>
</tr>
</table>


php蜘蛛统计

猜你在找的PHP相关文章