Php tutorial record search engine spider crawling record code
<Center>
<Form action = "setup. php" method = "post">
<Table align = "center">
<Tr>
<Td> server: </td> <input value = "localhost" name = "server"/> </td>
</Tr>
<Tr>
<Td> User name: </td> <input value = "database tutorial User name" name = "sqluser"/> </td>
</Tr>
<Tr>
<Td> password & nbsp; Code: </td> <input value = "Database Password" name = "sqlpass"/> </td>
</Tr>
<Tr>
<Td> Database name: </td> <input value = "Database name" name = "sqldb"/> </td>
</Tr>
<Tr>
<Td> Administrator Account: </td> <input value = "admin" name = "adminname"/> </td>
</Tr>
<Tr>
<Td> administrator password: </td> <input value = "admin" name = "adminpass"/> </td>
</Tr>
<Tr>
<Td> </td> <input type = "submit" value = "Start installation"/> </td>
</Tr>
</Table>
</Form>
</Center>
Setup. php file
<? Php
@ $ Server =$ _ post ['server'];
@ $ Sqluser = $ _ post ['sqluser'];
@ $ Sqlpass = $ _ post ['sqlpass'];
@ $ Sqldb =$ _ post ['sqldb'];
@ $ Adminname = $ _ post ['adminname'];
@ $ Adminpass = md5 ($ _ post ['adminpass']);
@ $ Conn = mysql tutorial _ connect ($ server, $ sqluser, $ sqlpass) or die ("<script> alert ('database cannot be linked, check whether the username and password are incorrect. '); history. back (); </script> ");
$ Db = mysql_select_db ($ sqldb) or die ("<script> alert ('database cannot be found. Please check whether the database name is filled in incorrectly! '); History. back (); </script> ");
$ Sql1 = "set foreign_key_checks = 0 ";
$ Sql2 = "drop table if exists 'robots '";
$ Sql3 = "create table 'robots '(
'Id' int (11) not null auto_increment,
'Robotsname' varchar (200) default null,
'Robotsip' varchar (200) default null,
'Riqi' date default null,
'Shijian 'time default null,
'Robotspage' varchar (255) default null,
Primary key ('id ')
) Engine = innodb default charset = gbk ";
$ Sql1ok = mysql_query ($ sql1, $ conn );
$ Sql2ok = mysql_query ($ sql2, $ conn );
$ Sql3ok = mysql_query ($ sql3, $ conn );
If (! $ Sql1ok or! $ Sql2ok or! $ Sql3ok ){
Echo "<script> alert ('the mysql has a serious fault and the program cannot be installed. Please contact the program author! '); Location. href = 'HTTP: // www.axphp.com'; </script> ";
} Else
{
$ Conntext = file_get_contents ("conn. setup ");
$ Conntext = str_replace ("server", $ server, $ conntext );
$ Conntext = str_replace ("user", $ sqluser, $ conntext );
$ Conntext = str_replace ("pass", $ sqlpass, $ conntext );
$ Conntext = str_replace ("mysqldb", $ sqldb, $ conntext );
$ Conntext = str_replace ("adminzh", $ adminname, $ conntext );
$ Conntext = str_replace ("adminmatrix as", $ adminpass, $ conntext );
File_put_contents ("../config. php", $ conntext );
Rename ("setup. php", "setup. lock ");
Echo "<script> alert ('Congratulations, installation successful! '); Location. href =' ../index.html '; </script> ";
}
?>
Zz. php file
<? Php
Include_once 'config. php ';
@ $ Ax_ym = $ _ server ['request _ uri '];
@ $ Ax_ss = $ _ server ['HTTP _ user_agent '];
@ $ Ax_url = $ _ server ['HTTP _ referer'];
@ $ Ax_ip = $ _ server ['remote _ addr '];
@ $ Ax_date = date ("y-m-d ");
@ $ Ax_time = date ("h: I: s ");
$ Baidu = stristr ($ ax_ss, "baiduspider ");
$ Google = stristr ($ ax_ss, "googlebot ");
$ Soso = stristr ($ ax_ss, "sosospider ");
$ Youdao = stristr ($ ax_ss, "youdaobot ");
$ Bing = stristr ($ ax_ss, "bingbot ");
$ Sogou = stristr ($ ax_ss, "sogou web spider ");
$ Yahoo = stristr ($ ax_ss, "yahoo! Slurp ");
If ($ baidu)
{
$ Ax_ss = "baidu ";
}
Elseif ($ google)
{
$ Ax_ss = "google ";
}
Elseif ($ soso)
{
$ Ax_ss = "soso ";
}
Elseif ($ youdao)
{
$ Ax_ss = "youdao ";
}
Elseif ($ bing)
{
$ Ax_ss = "bing ";
}
Elseif ($ sogou)
{
$ Ax_ss = "sogou ";
}
Elseif ($ yahoo)
{
$ Ax_ss = "yahoo ";
}
Else
{
$ Ax_ss = null;
}
If ($ baidu or $ google or $ soso or $ youdao or $ bing or $ sogou or $ yahoo)
{
$ Zzsql = "insert into robots (robotsname, robotspage, robotsip, riqi, shijian) values ('$ ax_ss', '$ ax_ym',' $ ax_ip ',' $ ax_date ', '$ ax_time ')";
$ Exeok = mysql_query ($ zzsql, $ conn );
}
?>
Add
Include ('zz. php ')
Or js call
<Script src = "zz. php"> </script>
Source code download
Http://down.bKjia. c0m/down/tool/o/2011/0311/22881.html