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

2019-04-09 14:20:11丽君

于是昨天便认真的做了一下,功能多一点,可以对各种搜索引擎统计分析。可以在多个时间段进行查看。其实代码很简单,为了更简洁些,代码压缩到6k.分为6个文件
1.安装程序 spilder_install.php 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>安装插件</title> 
</head> 
<?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 "连接服务器成功!.................<br>"; 
} 
else 
{ 
echo "<script>alert('链接出错!请检查数据库服务器配置!');history.go(-1);</script>"; 
} 
if(mysql_select_db($mysql_db,$link)) 
{ 
echo "连接数据库成功!.............<br>正在创建表................<br>"; 
} 
$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=str_replace("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">查看</a>"; 
exit(); 
} 
?> 
<body> 
<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><input name="mysql_host" type="text" id="mysql_host" value="localhost" /> 
(一般不用改)</td> 
</tr> 
<tr> 
<td align="right">用户名:</td> 
<td><input type="text" name="mysql_user" id="mysql_user" /></td> 
</tr> 
<tr> 
<td align="right">密码:</td> 
<td><input type="password" name="mysql_pwd" id="mysql_pwd" /></td> 
</tr> 
<tr> 
<td align="right">数据库:</td> 
<td><input type="text" name="mysql_db" id="mysql_db" /></td> 
</tr> 
<tr> 
<td align="right">表前缀:</td> 
<td><input name="table_prefix" type="text" id="table_prefix" value="spilder_" /> 
<input name="act" type="hidden" id="act" value="install" /></td> 
</tr> 
<tr> 
<td align="right">管理密码:</td> 
<td><input type="password" name="sp_admin" id="sp_admin" /></td> 
</tr> 
<tr> 
<td align="right"> </td> 
<td><input type="submit" name="button" id="button" value="安装" /></td> 
</tr> 
</table> 
</form> 
</body> 
</html>								 
			 
相关文章 大家在看