表一: admin
字段: id(int11) name(varchvr) password(varchvr)
表二: lo
字段: id(int11) username(varchvr) sex(varchvr) qq(varchvr) email(varchvr) info(text) ip(varchvr) submit_time(datetime)
1、conn.php(连接数据库文件)
mysql_connect("localhost","root","");//连接数据库
mysql_select_db("lyb");//选择数据库
?>
2、header.php(公用头部文件)
3、footer.php(公用底部文件)
$counterFile="conter.xml";
function displayCounter($counterFile){
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
print "
“;
exec(”rm -rf $counterFile”);
exec(”echo $num > $counterFile”);
}
if(!file_exists($counterFile)){
exec(”echo 0 > $counterFile”);
}
displayCounter($counterFile);
?>
代码备份,回头参考
以下为引用内容:
我的博客使用的是虚拟主机,也想实现url优化,但是我没有服务器权限,怎么办?很简单,我们可以从$_SERVER[”REQUEST_URI”]和$_SERVER['PATH_INFO']来下手原网站访问地址是 http://www.phpweblog.net/test.php?a=1&b=2&c=3
使用了 mode_rewrite 函数后,就可以用 http://www.phpweblog.net/test.php/a/1/b/2/c/3 来访问了,而且程序基本不用修改.
function mod_rewrite(){
if ( isset ( $_SERVER [ ' PATH_INFO ' ])){
$url = substr ( $_SERVER [ ' PATH_INFO ' ] , 1 );
$url = explode ( ‘ / ‘ , $url );
foreach ( $url as $key => $value ){
if ( $key % 2 != 1 ){
if ( $value != ” ) $_GET [ $value ] = $url [ $key + 1 ];
$querystring [] = $value . ‘ = ‘ . $url [ $key + 1 ];
}
}
$_SERVER [ ' QUERY_STRING ' ] = implode ( ” & ” , $querystring );
$_SERVER [ ' PHP_SELF ' ] = substr ( $_SERVER [ ' PHP_SELF ' ] , 0 , strpos ( $_SERVER [ ' PHP_SELF ' ] , ‘ .php ‘ ) + 4 );
$_SERVER [ ' REQUEST_URI ' ] = $_SERVER [ ' PHP_SELF ' ] . ‘ ? ‘ . $_SERVER [ ' QUERY_STRING ' ];
}
}
mod_rewrite();
http : // www.phpweblog.net/test.php/a/1/b/2/c/3
echo ‘
' ;echo " GET数组如下:
" ;
print_r ( $_GET );
Array
(
[a] => 1
[b] => 2
[c] => 3
)
![]()
via php函数实现虚拟主机url优化
以下为引用内容:
ASP网站程序在国内运用很广,但是类似于asp99.asp?id= 20050307213811这样的URL有点不利于搜索引擎的收录,也就是说不符合友好URL(URLs-Friendly)的标准,那么我们用 ISAPI_Rewrite打造一个Clean URL,让蜘蛛欢欢喜喜的来爬你的站吧.废话不多说,开工!
1.下载ISAPI_Rewrite.ISAPI_Rewrite分精简(Lite)和完全(Full)版.精简版不支持对每个虚拟主机站点进行重写,只能进行全局处理.不过对于有服务器的朋友,精简版也就够啦.精简版下载地址:http: //www.helicontech.com/download/,就是那Lite Version (free)啦.
2.安装.msi的文件,和装一般程序一样装就可以了,俺就装在D:ISAPI_Rewrite.
3.接下来一步比较重要哦,看仔细喽.打开Internet 信息服务,右键,web站点属性,电ISAPI筛选器选项卡.添加筛选器,名称自己填,路径自己指定ISAPI_Rewrite.dll,然后确定.
4.来测试一下.新建一个1ting.asp,里面写上
<%=request.querystring("inso")%>
效果就是执行的时候1ting.asp?inso=*浏览器显示*.
5.这一步很重要哦,开始添加rewrite规则.正则,好头痛,幸亏这个例子比较简单.
找到ISAPI_Rewrite目录,把httpd.ini的只读属性去掉,打开编辑.我们要把1ting.asp?inso=asp99映射成为1ting-asp99.html这样的类型,需要在httpd.ini里加上这么一行:
RewriteRule /1ting-([0-9,a-z]*).html /1ting.asp?inso=$1
保存.
via here
以下为引用内容:
sapi_rewrite利用正则表达式进行替换规则的表示。下面是一个简单的例子,我想让我们的用户输入 http://localhost/test-12314.html 实际上访问的是 http://localhost/test.asp?id=12314 。那么我们的匹配表达式应该是 /test-([0-9]*).html 对应的格式化表达式应该为 /test.asp?id=$1 。
进行正则表达式的编写的时候,可以利用isapi_rewrite提供的正则表达式测试工具(默认安装提供),进行调试。做好了匹配表达式和格式化表达式,我们可以把它们放到安装目录下的httpd.ini里面。文件保存后,不需重新启动iis即可生效。
对于我的网站,我防盗链的方法是在httpd.ini里面加入如下语句
RewriteCond Host: (.+)
RewriteCond Referer: (?!http://1.*).*
RewriteRule .*.(?:gif|jpg|png|exe|rar|zip) /block.gif [I,O]
然后重启IIS,这时防盗链就开始起作用了,其他网站盗链过来的请求都会被拒绝。
via wolxu blog
数据库及表
#
# 表的结构 naps_stats_bot
#
Create TABLE naps_stats_bot (
botid int(10) unsigned NOT NULL auto_increment,
botname varchar(100) NOT NULL default ‘’,
botagent varchar(200) NOT NULL default ‘’,
bottag varchar(100) NOT NULL default ‘’,
botcount int(11) NOT NULL default ‘0′,
botlast datetime NOT NULL default ‘0000-00-00 00:00:00′,
botlasturl varchar(250) NOT NULL default ‘’,
UNIQUE KEY botid (botid),
KEY botname (botname)
) TYPE=MyISAM AUTO_INCREMENT=9 ;
#
# 导出表中的数据 naps_stats_bot
#
Insert INTO naps_stats_bot VALUES (1, ‘Googlebot’, ‘Googlebot/2.X (+http://www.googlebot.com/bot.html)’, ‘googlebot’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (2, ‘MSNbot’, ‘MSNBOT/0.1 (http://search.msn.com/msnbot.htm)’, ‘msnbot’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (3, ‘Inktomi Slurp’, ‘Slurp/2.0′, ’slurp’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (4, ‘Baiduspider’, ‘Baiduspider+(+http://www.baidu.com/search/spider.htm)’, ‘baiduspider’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (5, ‘Yahoobot’, ‘Mozilla/5.0+(compatible;+Yahoo!+Slurp;+http://help.yahoo.com/help/us/ysearch/slurp)’, ’slurp’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (6, ‘Sohubot’, ’sohu-search’, ’sohu-search’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (7, ‘Lycos’, ‘Lycos/x.x’, ‘lycos’, 0, ‘0000-00-00 00:00:00′, ‘’);
Insert INTO naps_stats_bot VALUES (8, ‘Robozilla’, ‘Robozilla/1.0′, ‘robozilla’, 0, ‘0000-00-00 00:00:00′, ‘’);
/***************************************************************************
* NAPS -- Network Article Publish System
* ----------------------------------------------
* bot.php
* -------------------
* begin : 2004-08-15
* copyright : (C) 2004 week9
* email : wapshow@gmail.com
* homepage : http://www.week9.com
* http://www.wapshow.com
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
***************************************************************************/
/***************************************************************************
*
* NAPS产品是自由软件。你可以且必须根据《GNU GPL-GNU通用公共许可证》的相关规定
* 复制、修改及分发NAPS产品。任何以NAPS产品为基础的衍生发行版未必须经过飘飘的授权。
*
***************************************************************************/
error_reporting(E_ALL & ~E_NOTICE);
function get_naps_bot()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent, 'googlebot') !== false){
return 'Googlebot';
}
if (strpos($useragent, 'msnbot') !== false){
return 'MSNbot';
}
if (strpos($useragent, 'slurp') !== false){
return 'Yahoobot';
}
if (strpos($useragent, 'baiduspider') !== false){
return 'Baiduspider';
}
if (strpos($useragent, 'sohu-search') !== false){
return 'Sohubot';
}
if (strpos($useragent, 'lycos') !== false){
return 'Lycos';
}
if (strpos($useragent, 'robozilla') !== false){
return 'Robozilla';
}
return false;
}
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
//添加蜘蛛的抓取记录
$searchbot = get_naps_bot();
if ($searchbot) {
$DB_naps->query(”Update naps_stats_bot SET botcount=botcount+1, botlast=NOW(), botlasturl=’$tlc_thispage’ Where botname=’$searchbot’”);
}
?>
这个页面的评注有点意思。选择文字后出现 评注 窗口。下面的曲线也很显眼。代码在这个 articlenote.js 文件,貌似 prototype 的语法。
http://code.google.com/p/ie7-js/
新的版本支持更好一些。让 ie 能够使用标准的 css 语法。
以下为引用内容:
IE7 is a JavaScript library to make Microsoft Internet Explorer behave like a standards-compliant browser. It fixes many HTML and CSS issues and makes transparent PNG work correctly under IE5 and IE6.