﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-一江春水向东流-文章分类-PHP+MySQL开发</title><link>http://www.blogjava.net/huyi2006/category/17669.html</link><description>                            做一个有思想的人,期待与每一位热爱思考的人交流,您的关注是对我最大的支持。</description><language>zh-cn</language><lastBuildDate>Tue, 08 Sep 2009 21:43:40 GMT</lastBuildDate><pubDate>Tue, 08 Sep 2009 21:43:40 GMT</pubDate><ttl>60</ttl><item><title>判断终端是来自手机</title><link>http://www.blogjava.net/huyi2006/articles/294242.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Tue, 08 Sep 2009 00:13:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/294242.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/294242.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/294242.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/294242.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/294242.html</trackback:ping><description><![CDATA[function is_wap()
{
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']); 
    $uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|sie|philips|panasonic|alcatel|lenovo|cldc|midp|wap|mobile)/i"; 
    if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
    {//如果在访问的URL中已经找到 wap字样，表明已经在访问WAP页面，无需跳转，下一版本增加 feed访问时也不跳转 
        return true; 
    }else{ 
        return false; 
    } 
} 
<img src ="http://www.blogjava.net/huyi2006/aggbug/294242.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2009-09-08 08:13 <a href="http://www.blogjava.net/huyi2006/articles/294242.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL修改root密码的各种方法整理</title><link>http://www.blogjava.net/huyi2006/articles/247943.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Tue, 23 Dec 2008 09:12:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/247943.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/247943.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/247943.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/247943.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/247943.html</trackback:ping><description><![CDATA[
		<p>整理了以下四种在MySQL中修改root密码的方法,可能对大家有所帮助!</p>
		<p>方法1： 用SET PASSWORD命令</p>
		<p>　　mysql -u root</p>
		<p>　　mysql&gt; SET PASSWORD FOR <a href="mailto:'root'@'localhost'">'root'@'localhost'</a> = PASSWORD('newpass');</p>
		<p>方法2：用mysqladmin</p>
		<p> </p>
		<p>　　mysqladmin -u root password "newpass"</p>
		<p>　　如果root已经设置过密码，采用如下方法</p>
		<p>　　mysqladmin -u root password oldpass "newpass"</p>
		<p>方法3： 用UPDATE直接编辑user表</p>
		<p>　　mysql -u root</p>
		<p>　　mysql&gt; use mysql;</p>
		<p>　　mysql&gt; UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';</p>
		<p>　　mysql&gt; FLUSH PRIVILEGES;</p>
		<p>在丢失root密码的时候，可以这样</p>
		<p>　　mysqld_safe --skip-grant-tables&amp;</p>
		<p>　　mysql -u root mysql</p>
		<p>　　mysql&gt; UPDATE user SET password=PASSWORD("new password") WHERE user='root';</p>
		<p>　　mysql&gt; FLUSH PRIVILEGES;</p>
		<p> </p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/247943.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-12-23 17:12 <a href="http://www.blogjava.net/huyi2006/articles/247943.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下两个不同版本Mysql的安装实战（Mysql5和mysql4）</title><link>http://www.blogjava.net/huyi2006/articles/247941.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Tue, 23 Dec 2008 09:05:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/247941.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/247941.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/247941.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/247941.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/247941.html</trackback:ping><description><![CDATA[问题的产生：在已有的Red Hat Enterprise Linux AS 3.0系统上已经运行了一套web程序，使用Mysql4, tomcat41, 现在又要求安装一套新程序，依旧使用该tomcat41, 但数据库变为<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>。 <br /><br />注意事项： <br />新的程序需要注意字符集的问题， <br />1)具体数据库的权限和分组问题， <br />2)<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>下的具体数据库从windows直接拷贝到Linux下不好使的问题， <br />3)以及<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>需要设置密码的问题， <br />4)<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>在linux下对数据库区分大小写的问题。 <br />5) mysql在终端进入 <br />   mysql&gt; <br />   时的用户名和密码问题 <br /><br />此外，在具体安装<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>的过程中，要注意将<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>的安装位置（baseDir），数据库的具体存放位置（dataDir），端口号（改为3307）,进行修改，这样才能保证两个不同版本的数据库的同时运行。 <br /><br />版本号： <br />MySQL v4.0.24 <br />(1)MySQL-server-4.0.24-0.i386.rpm <br />(2)MySQL-client-4.0.24-0.i386.rpm <br />(3)MySQL-devel-4.0.24-0.i386.rpm <br />MySQL 5.0.51a <br />mysql-5.0.51a.tar.gz <br />下载地址：http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.0/mysql-5.0.51a.tar.gz <br /><br />安装MySQL v4.0.24 <br />#rpm -qa | grep sql <br />查询系统是否默认安装了mysql服务器 <br />然后卸载系统默认安装的mysql <br />卸载mysql命令如下： <br />#rpm -e --nodeps mysql-3.23.58-1 <br /><br />安装MySQL服务端： <br />#rpm -ivh MySQL-server-4.0.24-0.i386.rpm <br />测试服务端是否安装成功： <br />#netstat -nat <br />查看端口3306是否打开 <br />然后安装MySQL客户端 <br />#rpm -ivh MySQL-client-4.0.24-0.i386.rpm <br />安装MySQL连接包： <br />#rpm -ivh MySQL-devel-4.0.24-0.i386.rpm <br />此时Mysql4的各个安装路径如下： <br />以我们在Redhat下安装的MySQl4.0.26数据库为例： <br />(注意事项：rpm包使用的都是默认的设置，不能更改，以下均为默认设置) <br />1.配置文件：/etc/my.cnf <br />2.数据库目录：/var/lib/mysql <br />3.启动脚本：/etc/rc.d/init.d/mysql <br />4.端口3306 <br />5..socket文件/tmp/mysql.socket <br />—————————————————————————————————————— <br /><br />下面安装MySQL 5.0.51a <br /><br />由于我们安装的MySQL4.0.26的安装包类型是rpm包，所以，需要大家注意的是， <br />它使用的都是默认的设置，安装后生成的配置文件和数据库目录等等一系列的配置都是我们不能改变的。 <br />因此，如果要在同一开发环境下安装两个数据库的话，我们就必须处理以下这些问题： <br />1.配置文件安装路径不能相同 <br />2.数据库目录不能相同 <br />3.启动脚本不能同名 <br />4.端口不能相同 <br />5..socket文件的生成路径不能相同 <br />依据上面的各种要求：<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.0.51a.tar.gz的源码包安装做出以下调整： <br />--prefix=/usr/local/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>  ### 数据库安装目录 <br />--localstatedir=/var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>  ### 数据库存放目录 <br />--with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=all ### 字符集gbk加载和gbk_chinese_ci加载，可处理中文乱码问题 <br />其他的设置是对数据库的一下优化，在此就不再赘述。 <br /><br />参考了一些msyql5的安装文档，在这里感谢各位前辈 <br />mysql-5.0.51a.tar.gz解压后的安装详解： <br /><br />1# cd mysql-5.0.51a <br />2# mkdir /usr/local/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br /><br />(这步骤中的诸多参数中，关键的参数已经在前面介绍了，如有不懂，请参看前面的介绍。) <br />3# ./configure <br />--prefix=/usr/local/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br />--localstatedir=/var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> --with-comment=Source   <br />--with-server-suffix=-Community <br />--with-mysqld-user=mysql <br />--without-debug <br />--with-big-tables <br />--with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=all <br />--with-pthread <br />--enable-static <br />--enable-thread-safe-client <br />--with-client-ldflags=-all-static <br />--with-mysqld-ldflags=-all-static <br />--enable-assembler <br />--without-innodb <br />--without-ndb-debug <br />4# make <br />5# make install <br /><br />6.# useradd mysql //添加 mysql 用户 <br />7# cd /usr/local/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br />(注意：！！！在安装第二个数据库时候，虽然在./configure后加上了--localstatedir=/var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>但是并未在/var/lib下产生<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>目录，所以我们要在源码包编译安装完成之后先检查一下是否有这个目录，如果没有的话一定要手动创建一个 命令：＃ mkdir /var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>再执行第八步骤。) <br />8# bin/mysql_install_db --user=mysql <br />(在确保第七步骤正确完成之后，在执行本步骤时，如果正确的话，在/var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>下将会产生相应的数据库文件。) <br />9# chown -R root:mysql . 　　　　　　//设置权限，注意后面有一个 "." <br />10# chown -R mysql /var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> 　　//设置 mysql 目录权限 <br />11# chgrp -R mysql . 　　　　　　　　 //注意后面有一个 "." <br />12# cp share/mysql/my-huge.cnf /etc/my5.cnf <br />13# cp share/mysql/mysql.server /etc/rc.d/init.d/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> //开机自动启动 mysql。 <br />14# chmod 755 /etc/rc.d/init.d/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br />15# chkconfig --add <span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br /><br />16以下是安装第二个数据库时，对启动文件<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>和配置文件my5.cnf做出的必要修改。 <br />=================================================================================== <br />/etc/rc.d/init.d/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br /><br />修改下面的内容： <br /><br />1.datadir=/var/lib/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span><br />2.conf=/etc/my5.cnf <br />3.把"$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args &gt;/dev/null 2&gt;&amp;1 &amp;"替换为（双引号中的） <br />"$bindir/mysqld_safe --defaults-file=/etc/my5.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args &gt;/dev/null 2&gt;&amp;1 &amp;"（双引号中的） <br />=================================================================================== <br />/etc/my5.cnf <br /><br />修改下面的内容： <br /><br />port = 3307 ###修改相关的端口 <br />socket文件生成路径 <br /><br />把[client]和[mysqld]中的port号都改成3307, <br />socket = /tmp/mysql.sock改成socket = /tmp/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.sock <br />[client] <br />#password = your_password <br />port  = 3307 <br />socket  = /tmp/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.sock <br /><br /># Here follows entries for some specific programs <br /><br /># The MySQL server <br />[mysqld] <br />port  = 3307 <br />socket  = /tmp/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.sock <br />================================================================================== <br />17# /etc/rc.d/init.d/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> start 　　　　　　　　　　//启动 MySQL <br />18# bin/mysqladmin -u root password "password_for_root" ### 设置数据库JDBC连接的密码 <br />    注意事项：此密码与从终端客户端登陆数据库的密码是否为同一密码，还存在疑问。 <br />              设置终端客户端登陆数据库的密码：(默认设置：用户名：root 密码：（空）) <br />19# cd /usr/local/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>/bin(进入数据库安装目录下执行以下命令) <br />20# ./mysql -u root -p (登陆数据库，以mysql&gt;开头均属数据库内的操作,注意不要丢掉分号 <br />mysql&gt; use mysql; <br /><br />mysql&gt; UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; <br />mysql&gt; FLUSH PRIVILEGES; <br />mysql&gt; exit; <br />21# service <span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> stop 　　　　　　　　　　　　　　//关闭 MySQL <br /><br />22tomcat部署文件下的修改： <br />修改/usr/tomcat/jetmambo/WEB-INF/classes/jdbc.properties <br />1.3306改成3307 <br />2.jdbc.password=system(注意事项：这个密码就是数据库JDBC连接的密码) <br /><br />修改后如下： <br />jdbc.driverClassName=com.mysql.jdbc.Driver <br />jdbc.url=jdbc:mysql://localhost:3307/timef3_cmd?&amp;useUnicode=true&amp;characterEncoding=gbk <br />jdbc.username=root <br />jdbc.password=system <br /><br />23启动数据库和WEB服务器，验证数据库安装是否成功 <br />/etc/init.d/mysql restart <br />/etc/init.d/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span> restart <br />注意事项：必须保持两个数据库都开启服务,否则tomcat报SQLException <br />/usr/tomcat/bin/catalina.sh run <br /><br />补充说明： <br /><br />24linux下默认数据库中表名不忽略大小写，做如下设置： <br />/etc/my5.cnf <br /><br /># The MySQL server <br />[mysqld] <br />lower_case_table_names = 1 ### 1为忽略大小写 0为不忽略大小写 <br />port  = 3307 <br />socket  = /tmp/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.sock <br /><br />———————————————————————————————————— <br />遗留问题，不知那位大侠可以解答一下： <br />在终端进入 <br />&gt;mysql时 <br />报： <br />ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) <br />错误。 <br />---------------------------------------------------------------- <br />问题解决了 <br />http://www.javaeye.com/topic/203986 <br />非常感谢这篇文章 <br /><br />./mysql -uroot -p -S /tmp/<span class="hilite1"><font style="BACKGROUND-COLOR: #ffff00">mysql5</font></span>.sock <br /><br />如果不加参数-S，则在默认目录去找mysql.sock <br /><br /><img src ="http://www.blogjava.net/huyi2006/aggbug/247941.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-12-23 17:05 <a href="http://www.blogjava.net/huyi2006/articles/247941.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>apache 配置gzip压缩</title><link>http://www.blogjava.net/huyi2006/articles/237649.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Thu, 30 Oct 2008 09:33:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/237649.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/237649.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/237649.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/237649.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/237649.html</trackback:ping><description><![CDATA[1、 下载 <br /><br />到http://www.remotecommunications.com/apache/mod_gzip 下载mod_gzip.c 还有它的补丁。 <br /><br />2、 安装, 配置 <br /><br />　　把mod_gzip放到你的apache的源<a href="http://samoay.blog.163.com/blog/;" target="_self"><u><strong><font color="#1d4944">代码</font></strong></u></a>目录下，新建一个mod_gzip目录如果需要补丁(针对1.3.17.la版) 还需运行: <br />patch mod_gizp.c <br />　　按你需要，在配置中选择动态DSO或静态编译进apache系统。如何处理在README中讲得很清楚，如-add-module=mod_gzip.c, make,make install等等。这里不多讲。 <br /><br />把下列配置加入httpd.conf尾部。 <br /><br /># MOD_GZIP configuration <br />mod_gzip_on Yes <br />mod_gzip_minimum_file_size 1002 <br />mod_gzip_maximum_file_size 0 <br />mod_gzip_maximum_inmem_size 60000 <br />mod_gzip_item_include mime "application/x-httpd-php" <br />mod_gzip_item_include mime text/* <br />mod_gzip_item_include mime "httpd/unix-directory" <br />mod_gzip_dechunk Yes <br />mod_gzip_temp_dir "/tmp" <br />mod_gzip_keep_workfiles No <br />mod_gzip_item_include file ".php3$" <br />mod_gzip_item_include file ".txt$" <br />mod_gzip_item_include file ".html$" <br />mod_gzip_item_exclude file ".css$" <br />mod_gzip_item_exclude file ".js$" <br /><br /><br />在保存修改后运行 <br />…/bin/apachectl configtest确保配置修改无误。 <br />然后用 apachectl restart 指令重起服务。 <br /><br />3、 修改，测试 <br /><br />　　在宣布做好了之前在测试一下是优秀程序员的习惯。为了尽量不影响你的用户的浏览，我们可以用把新的apache驱动在8080端口上或者用指令控制mod_gzip起作用的目录,而不是一下子全用mod_gzip. <br />用法如下： <br /><br /><br />MOD_GZIP configuration <br /><br /><br />　　你再用IE4或netscape认真的全面测试一遍，没有问题后你就可以让你的用户很开心的发现'XX网站现在好快哦。' <br /><br />　　Mod_gzip真的很神奇，100K的<a href="http://samoay.blog.163.com/blog/;" target="_self"><u><strong><font color="#1d4944">HTML</font></strong></u></a>大文档只要12K就可以传到用户端了。越先采用这个技术你的用户对你的网站的高速度印象就越深。不过有所得必有所失，由于解压是在客户端进行的，效果和用户的浏览器有一定关系。笔者测试了MSIE4,5,5.5,netscape 4.5 , 6都运行得很好. 不过java,jpg,gif等等是没法压缩的。<img src ="http://www.blogjava.net/huyi2006/aggbug/237649.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-10-30 17:33 <a href="http://www.blogjava.net/huyi2006/articles/237649.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简洁、明晰！数据库设计三大范式应用实例剖析</title><link>http://www.blogjava.net/huyi2006/articles/228904.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sun, 14 Sep 2008 09:12:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/228904.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/228904.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/228904.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/228904.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/228904.html</trackback:ping><description><![CDATA[
		<div id="vogate_ad_area">
				<p>引言<br /><br />　　数据库的<a class="vLink1" id="vad_1" onmouseover="this.style.borderBottom='2px #FF3366 solid';var fxEvent=arguments[0];kwmouseover(this,1,fxEvent);" title="站长中国-中国站长门户 @Vogate.com" style="FONT-SIZE: 1em; CURSOR: hand; COLOR: #ff3366; BORDER-BOTTOM: #ff3366 1px dotted; TEXT-DECORATION: underline" onmouseout="this.style.borderBottom='1px #FF3366 dotted';kwmouseout(this,1)" href="http://action.vogate.com/c/c.php?r=http%3A//www.baidu.com/s%3Fwd%3D%25CA%25FD%25BE%25DD%25BF%25E2+%25B9%25D8%25BC%25FC%25D7%25D6&amp;aid=4862&amp;sid=6235007045049473&amp;click=1&amp;url=http%3A//WWW.ZZCHN.COM&amp;v=0&amp;k=%u8BBE%u8BA1&amp;s=http%3A//news.csdn.net/n/20061230/100207.html&amp;rn=832291" target="_blank" name="1">设计</a>范式是数据库设计所需要满足的规范，满足这些规范的数据库是简洁的、结构明晰的，同时，不会发生插入（insert）、删除（delete）和更新（update）操作异常。反之则是乱七八糟，不仅给数据库的编程人员制造麻烦，而且面目可憎，可能存储了大量不需要的冗余<a class="vLink1" id="vad_2" onmouseover="this.style.borderBottom='2px #FF3366 solid';var fxEvent=arguments[0];kwmouseover(this,2,fxEvent);" title="商丘网-商丘热线 @Vogate.com" style="FONT-SIZE: 1em; CURSOR: hand; COLOR: #ff3366; BORDER-BOTTOM: #ff3366 1px dotted; TEXT-DECORATION: underline" onmouseout="this.style.borderBottom='1px #FF3366 dotted';kwmouseout(this,2)" href="http://action.vogate.com/c/c.php?r=http%3A//www.baidu.com/s%3Fwd%3D%25CA%25FD%25BE%25DD%25BF%25E2+%25B9%25D8%25BC%25FC%25D7%25D6&amp;aid=5404&amp;sid=6235007045049473&amp;click=1&amp;url=http%3A//www.shangqiu.cc&amp;v=0&amp;k=%u4FE1%u606F&amp;s=http%3A//news.csdn.net/n/20061230/100207.html&amp;rn=356113" target="_blank" name="2">信息</a>。<br /><br />　　设计范式是不是很难懂呢？非也，大学教材上给我们一堆数学公式我们当然看不懂，也记不住。所以我们很多人就根本不按照范式来设计数据库。<br /><br />　　实质上，设计范式用很<a class="vLink1" id="vad_0" onmouseover="this.style.borderBottom='2px #FF3366 solid';var fxEvent=arguments[0];kwmouseover(this,0,fxEvent);" title="形象顾问培训 @Vogate.com" style="FONT-SIZE: 1em; CURSOR: hand; COLOR: #ff3366; BORDER-BOTTOM: #ff3366 1px dotted; TEXT-DECORATION: underline" onmouseout="this.style.borderBottom='1px #FF3366 dotted';kwmouseout(this,0)" href="http://action.vogate.com/c/c.php?r=http%3A//www.baidu.com/s%3Fwd%3D%25CA%25FD%25BE%25DD%25BF%25E2+%25B9%25D8%25BC%25FC%25D7%25D6&amp;aid=5228&amp;sid=6235007045049473&amp;click=1&amp;url=http%3A//www.funtry.com&amp;v=0&amp;k=%u5F62%u8C61&amp;s=http%3A//news.csdn.net/n/20061230/100207.html&amp;rn=866855" target="_blank" name="0">形象</a>、很简洁的话语就能说清楚，道明白。本文将对范式进行通俗地说明，并以笔者曾经设计的一个简单论坛的数据库为例来讲解怎样将这些范式应用于实际工程。<br /><br />　　范式说明<br /><br />　　第一范式（1NF）：数据库表中的字段都是单一属性的，不可再分。这个单一属性由基本类型构成，包括整型、实数、字符型、逻辑型、日期型等。<br /><br />　　例如，如下的数据库表是符合第一范式的：<br /><br /></p>
				<table cellspacing="0" cellpadding="2" width="90%" align="center" border="1">
						<tbody>
								<tr>
										<td>字段1 </td>
										<td>字段2 </td>
										<td>字段3 </td>
										<td>字段4</td>
								</tr>
								<tr>
										<td> </td>
										<td> </td>
										<td> </td>
										<td> </td>
								</tr>
						</tbody>
				</table>
				<br />　　而这样的数据库表是不符合第一范式的：<br /><br /><table cellspacing="0" cellpadding="2" width="90%" align="center" border="1"><tbody><tr><td>字段1 </td><td>字段2 </td><td colspan="2">字段3 </td><td>字段4</td></tr><tr><td> </td><td> </td><td>字段3.1</td><td>字段3.2 </td><td> </td></tr></tbody></table><p><br />　　很显然，在当前的任何关系数据库管理系统（DBMS）中，傻瓜也不可能做出不符合第一范式的数据库，因为这些DBMS不允许你把数据库表的一列再分成二列或多列。因此，你想在现有的DBMS中设计出不符合第一范式的数据库都是不可能的。<br /><br />　　第二范式（2NF）：数据库表中不存在非关键字段对任一候选关键字段的部分函数依赖（部分函数依赖指的是存在组合关键字中的某些字段决定非关键字段的情况），也即所有非关键字段都完全依赖于任意一组候选关键字。 
</p><table cellspacing="0" cellpadding="0" align="left" border="0"><tbody><tr><td valign="top"> </td></tr><tr><td> </td></tr></tbody></table><br /><br />　　假定选课关系表为SelectCourse(学号, 姓名, 年龄, 课程名称, 成绩, 学分)，关键字为组合关键字(学号, 课程名称)，因为存在如下决定关系：<br /><br />　　(学号, 课程名称) → (姓名, 年龄, 成绩, 学分)<br /><br />　　这个数据库表不满足第二范式，因为存在如下决定关系：<br /><br />　　(课程名称) → (学分)<br /><br />　　(学号) → (姓名, 年龄)<br /><br />　　即存在组合关键字中的字段决定非关键字的情况。<br /><br />　　由于不符合2NF，这个选课关系表会存在如下问题：<br /><br />　　(1) 数据冗余：<br /><br />　　同一门课程由n个学生选修，"学分"就重复n-1次；同一个学生选修了m门课程，姓名和年龄就重复了m-1次。<br /><br />　　(2) 更新异常：<br /><br />　　若调整了某门课程的学分，数据表中所有行的"学分"值都要更新，否则会出现同一门课程学分不同的情况。<br /><br />　　(3) 插入异常：<br /><br />　　假设要开设一门新的课程，暂时还没有人选修。这样，由于还没有"学号"关键字，课程名称和学分也无法记录入数据库。<br /><br />　　(4) 删除异常：<br /><br />　　假设一批学生已经完成课程的选修，这些选修记录就应该从数据库表中删除。但是，与此同时，课程名称和学分信息也被删除了。很显然，这也会导致插入异常。 <br /><br />　　把选课关系表SelectCourse改为如下三个表：<br /><br />　　学生：Student(学号, 姓名, 年龄)；<br /><br />　　课程：Course(课程名称, 学分)；<br /><br />　　选课关系：SelectCourse(学号, 课程名称, 成绩)。<br /><br />　　这样的数据库表是符合第二范式的，消除了数据冗余、更新异常、插入异常和删除异常。<br /><br />　　另外，所有单关键字的数据库表都符合第二范式，因为不可能存在组合关键字。<br /><br />　　第三范式（3NF）：在第二范式的基础上，数据表中如果不存在非关键字段对任一候选关键字段的传递函数依赖则符合第三范式。所谓传递函数依赖，指的是如果存在"A → B → C"的决定关系，则C传递函数依赖于A。因此，满足第三范式的数据库表应该不存在如下依赖关系：<br /><br />　　关键字段 → 非关键字段x → 非关键字段y<br /><br />　　假定学生关系表为Student(学号, 姓名, 年龄, 所在<a href="http://edu.itbulo.com/"><font color="#000000">学院</font></a>, <a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>地点, <a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>电话)，关键字为单一关键字"学号"，因为存在如下决定关系：<br /><br />　　(学号) → (姓名, 年龄, 所在<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>, <a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>地点, <a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>电话)<br /><br />　　这个数据库是符合2NF的，但是不符合3NF，因为存在如下决定关系：<br /><br />　　(学号) → (所在<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>) → (<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>地点, <a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>电话)<br /><br />　　即存在非关键字段"<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>地点"、"<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>电话"对关键字段"学号"的传递函数依赖。<br /><br />　　它也会存在数据冗余、更新异常、插入异常和删除异常的情况，读者可自行分析得知。<br /><br />　　把学生关系表分为如下两个表：<br /><br />　　学生：(学号, 姓名, 年龄, 所在<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>)；<br /><br />　　<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>：(<a href="http://edu.itbulo.com/"><u><font color="#004a9c">学院</font></u></a>, 地点, 电话)。<br /><br />　　这样的数据库表是符合第三范式的，消除了数据冗余、更新异常、插入异常和删除异常。<br /><br />　　鲍依斯-科得范式（BCNF）：在第三范式的基础上，数据库表中如果不存在任何字段对任一候选关键字段的传递函数依赖则符合第三范式。<p>　假设仓库管理关系表为StorehouseManage(仓库ID, 存储物品ID, 管理员ID, 数量)，且有一个管理员只在一个仓库<a class="vLink1" id="vad_3" onmouseover="this.style.borderBottom='2px #FF3366 solid';var fxEvent=arguments[0];kwmouseover(this,3,fxEvent);" title="找酒店工作，上最佳东方！ @Vogate.com" style="FONT-SIZE: 1em; CURSOR: hand; COLOR: #ff3366; BORDER-BOTTOM: #ff3366 1px dotted; TEXT-DECORATION: underline" onmouseout="this.style.borderBottom='1px #FF3366 dotted';kwmouseout(this,3)" href="http://action.vogate.com/c/c.php?r=http%3A//www.baidu.com/s%3Fwd%3D%25CA%25FD%25BE%25DD%25BF%25E2+%25B9%25D8%25BC%25FC%25D7%25D6&amp;aid=10358&amp;sid=6235007045049473&amp;click=1&amp;url=http%3A//www.veryeast.cn&amp;v=0&amp;k=%u5DE5%u4F5C&amp;s=http%3A//news.csdn.net/n/20061230/100207.html&amp;rn=416714" target="_blank" name="3">工作</a>；一个仓库可以存储多种物品。这个数据库表中存在如下决定关系：<br /><br />　　(仓库ID, 存储物品ID) →(管理员ID, 数量)<br /><br />　　(管理员ID, 存储物品ID) → (仓库ID, 数量)<br /><br />　　所以，(仓库ID, 存储物品ID)和(管理员ID, 存储物品ID)都是StorehouseManage的候选关键字，表中的唯一非关键字段为数量，它是符合第三范式的。但是，由于存在如下决定关系：<br /><br />　　(仓库ID) → (管理员ID)<br /><br />　　(管理员ID) → (仓库ID)<br /><br />　　即存在关键字段决定关键字段的情况，所以其不符合BCNF范式。它会出现如下异常情况：<br /><br />　　(1) 删除异常：<br /><br />　　当仓库被清空后，所有"存储物品ID"和"数量"信息被删除的同时，"仓库ID"和"管理员ID"信息也被删除了。<br /><br />　　(2) 插入异常：<br /><br />　　当仓库没有存储任何物品时，无法给仓库分配管理员。<br /><br />　　(3) 更新异常：<br /><br />　　如果仓库换了管理员，则表中所有行的管理员ID都要修改。<br /><br />　　把仓库管理关系表分解为二个关系表：<br /><br />　　仓库管理：StorehouseManage(仓库ID, 管理员ID)；<br /><br />　　仓库：Storehouse(仓库ID, 存储物品ID, 数量)。<br /><br />　　这样的数据库表是符合BCNF范式的，消除了删除异常、插入异常和更新异常。 </p><p> </p><p>范式应用<br /><br />　　我们来逐步搞定一个论坛的数据库，有如下信息：<br /><br />　　（1） 用户：用户名，email，主页，电话，联系地址<br /><br />　　（2） 帖子：发帖标题，发帖内容，回复标题，回复内容 <br /><br />　　第一次我们将数据库设计为仅仅存在表：<br />　　 
</p><table cellspacing="0" cellpadding="2" width="90%" align="center" border="1"><tbody><tr><td>用户名 </td><td>email </td><td>主页</td><td>电话</td><td>联系地址</td><td>发帖标题</td><td>发帖内容</td><td>回复标题</td><td>回复内容</td></tr></tbody></table><br />　　这个数据库表符合第一范式，但是没有任何一组候选关键字能决定数据库表的整行，唯一的关键字段用户名也不能完全决定整个元组。我们需要增加"发帖ID"、"回复ID"字段，即将表修改为：<br /><br /><table cellspacing="0" cellpadding="2" width="90%" align="center" border="1"><tbody><tr><td>用户名</td><td>email</td><td>主页</td><td>电话</td><td>联系地址</td><td>发帖ID</td><td>发帖标题</td><td>发帖内容</td><td>回复ID</td><td>回复标题</td><td>回复内容</td></tr></tbody></table><br />　　这样数据表中的关键字(用户名，发帖ID，回复ID)能决定整行：<br /><br />　　(用户名,发帖ID,回复ID) → (email,主页,电话,联系地址,发帖标题,发帖内容,回复标题,回复内容)<br /><br />　　但是，这样的设计不符合第二范式，因为存在如下决定关系：<br /><br />　　(用户名) → (email,主页,电话,联系地址)<br /><br />　　(发帖ID) → (发帖标题,发帖内容)<br /><br />　　(回复ID) → (回复标题,回复内容)<br /><br />　　即非关键字段部分函数依赖于候选关键字段，很明显，这个设计会导致大量的数据冗余和操作异常。 
<table cellspacing="0" cellpadding="0" align="left" border="0"><tbody><tr><td valign="top"> </td></tr><tr><td> </td></tr></tbody></table><br /><br />　　我们将数据库表分解为（带下划线的为关键字）：<br /><br />　　（1） 用户信息：用户名，email，主页，电话，联系地址<br /><br />　　（2） 帖子信息：发帖ID，标题，内容<br /><br />　　（3） 回复信息：回复ID，标题，内容<br /><br />　　（4） 发贴：用户名，发帖ID<br /><br />　　（5） 回复：发帖ID，回复ID<br /><br />　　这样的设计是满足第1、2、3范式和BCNF范式要求的，但是这样的设计是不是最好的呢？<br /><br />　　不一定。<br /><br />　　观察可知，第4项"发帖"中的"用户名"和"发帖ID"之间是1：N的关系，因此我们可以把"发帖"合并到第2项的"帖子信息"中；第5项"回复"中的"发帖ID"和"回复ID"之间也是1：N的关系，因此我们可以把"回复"合并到第3项的"回复信息"中。这样可以一定量地减少数据冗余，新的设计为：<br /><br />　　（1） 用户信息：用户名，email，主页，电话，联系地址<br /><br />　　（2） 帖子信息：用户名，发帖ID，标题，内容<br /><br />　　（3） 回复信息：发帖ID，回复ID，标题，内容<br /><br />　　数据库表1显然满足所有范式的要求；<br /><br />　　数据库表2中存在非关键字段"标题"、"内容"对关键字段"发帖ID"的部分函数依赖，即不满足第二范式的要求，但是这一设计并不会导致数据冗余和操作异常；<br /><br />　　数据库表3中也存在非关键字段"标题"、"内容"对关键字段"回复ID"的部分函数依赖，也不满足第二范式的要求，但是与数据库表2相似，这一设计也不会导致数据冗余和操作异常。<br /><br />　　由此可以看出，并不一定要强行满足范式的要求，对于1：N关系，当1的一边合并到N的那边后，N的那边就不再满足第二范式了，但是这种设计反而比较好！<br /><br />　　对于M：N的关系，不能将M一边或N一边合并到另一边去，这样会导致不符合范式要求，同时导致操作异常和数据冗余。 <br />对于1：1的关系，我们可以将左边的1或者右边的1合并到另一边去，设计导致不符合范式要求，但是并不会导致操作异常和数据冗余。<br /><br />　　结论<br /><br />　　满足范式要求的数据库设计是结构清晰的，同时可避免数据冗余和操作异常。这并意味着不符合范式要求的设计一定是错误的，在数据库表中存在1：1或1：N关系这种较特殊的情况下，合并导致的不符合范式要求反而是合理的。<br /><br />　　在我们设计数据库的时候，一定要时刻考虑范式的要求。<p></p></div>
<img src ="http://www.blogjava.net/huyi2006/aggbug/228904.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-09-14 17:12 <a href="http://www.blogjava.net/huyi2006/articles/228904.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Mysql中的临时表</title><link>http://www.blogjava.net/huyi2006/articles/210097.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Mon, 23 Jun 2008 08:57:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/210097.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/210097.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/210097.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/210097.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/210097.html</trackback:ping><description><![CDATA[
		<h1 class="firstHeading">
				<div id="jump-to-nav">
						<a class="new" title="Template:Java MySQL" href="http://codex.wordpress.org.cn/index.php?title=Template:Java_MySQL&amp;action=edit">
								<font color="#000000" size="2">emplate:Java MySQL</font>
						</a>
						<font color="#000000" size="2">当工作在非常大的表上时，你可能偶尔需要运行很多查询获得一个大量数据的小的子集，不是对整个表运行这些查询，而是让MySQL每次找出所需的少数记录，将记录选择到一个临时表可能更快些，然后多这些表运行查询。</font>
				</div>
		</h1>
		<div id="bodyContent">
				<p>创建临时表很容易，给正常的CREATE TABLE语句加上TEMPORARY关键字： </p>
				<pre>CREATE TEMPORARY TABLE tmp_table (
name VARCHAR(10) NOT NULL,
value INTEGER NOT NULL
)
</pre>
				<p>临时表将在你连接MySQL期间存在。当你断开时，MySQL将自动删除表并释放所用的空间。当然你可以在仍然连接的时候删除表并释放空间。 </p>
				<pre>DROP TABLE tmp_table
</pre>
				<p>如果在你创建名为tmp_table临时表时名为tmp_table的表在数据库中已经存在，临时表将有必要屏蔽（隐藏）非临时表tmp_table。 </p>
				<p>如果你声明临时表是一个HEAP表，MySQL也允许你指定在内存中创建它： </p>
				<pre>CREATE TEMPORARY TABLE tmp_table (
name VARCHAR(10) NOT NULL,
value INTEGER NOT NULL
) TYPE = HEAP
</pre>
				<p>　 </p>
				<p>因为HEAP表存储在内存中，你对它运行的查询可能比磁盘上的临时表快些。然而，HEAP表与一般的表有些不同，且有自身的限制。详见MySQL参考手册。 </p>
				<p>正如前面的建议，你应该测试临时表看看它们是否真的比对大量数据库运行查询快。如果数据很好地索引，临时表可能一点不快。 </p>
		</div>
<img src ="http://www.blogjava.net/huyi2006/aggbug/210097.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-06-23 16:57 <a href="http://www.blogjava.net/huyi2006/articles/210097.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何在mysql中创建内存表</title><link>http://www.blogjava.net/huyi2006/articles/208867.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Wed, 18 Jun 2008 06:41:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/208867.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/208867.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/208867.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/208867.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/208867.html</trackback:ping><description><![CDATA[
		<strong>如何创建内存表</strong>？<br />    创建内存表非常的简单，只需注明 ENGINE= MEMORY 即可:<br />    CREATE TABLE  `tablename` ( `columnName` varchar(256) NOT NUL) ENGINE=MEMORY DEFAULT CHARSET=latin1 MAX_ROWS=100000000; 
<p> </p><p><strong>注意</strong>：<br />    当内存表中的数据大于max_heap_table_size设定的容量大小时，mysql会转换超出的数据存储到磁盘上，因此这是性能就大打折扣了，所以我们还需要根据我们的实际情况调整max_heap_table_size，例如在.cnf文件中[mysqld]的下面加入：<br />        max_heap_table_size = 2048M<br />    另外在建表语句中还可以通过MAX_ROWS来控制表的记录数。<br /><br />内存表使用哈希散列索引把数据保存在内存中，因此具有极快的速度，适合缓存中小型数据库，但是使用上受到一些限制，以下是蓝草使用的一些感受。<br /><br />1、heap对所有用户的连接是可见的，这使得它非常适合做缓存。<br /><br />2、仅适合使用的场合。heap不允许使用xxxTEXT和xxxBLOB数据类型；只允许使用=和&lt;=&gt;操作符来搜索记录（不允许&lt;、&gt;、&lt;=或&gt;=）；不支持auto_increment；只允许对非空数据列进行索引（not null）。<br />注：操作符 “&lt;=&gt;” 说明：NULL-safe equal.这个操作符和“=”操作符执行相同的比较操作，不过在两个操作码均为NULL时，其所得值为1而不为NULL，而当一个操作码为NULL时，其所得值为0而不为NULL。<br /><br />3、一旦服务器重启，所有heap表数据丢失，但是heap表结构仍然存在，因为heap表结构是存放在实际数据库路径下的，不会自动删除。重启之后，heap将被清空，这时候对heap的查询结果都是空的。<br /><br />4、如果heap是复制的某数据表，则复制之后所有主键、索引、自增等格式将不复存在，需要重新添加主键和索引，如果需要的话。<br /><br />5、对于重启造成的数据丢失，有以下的解决办法：<br />　a、在任何查询之前，执行一次简单的查询，判断heap表是否存在数据，如果不存在，则把数据重新写入，或者DROP表重新复制某张表。这需要多做一次查询。不过可以写成include文件，在需要用该heap表的页面随时调用，比较方便。<br />　b、对于需要该heap表的页面，在该页面第一次且仅在第一次查询该表时，对数据集结果进行判断，如果结果为空，则需要重新写入数据。这样可以节省一次查询。<br />　c、更好的办法是在mysql每次重新启动时自动写入数据到heap，但是需要配置服务器，过程比较复杂，通用性受到限制。<br /><br />6、一些预期可能用到的sql语句<br /><br />//如果表存在，则删除<br />DROP TABLE IF EXISTS `abc`;<br />//复制整张表xyz为heap表abc（包含所有数据）<br />CREATE TABLE `abc` type=heap select * from `xyz`;<br />//添加主键id<br />ALTER TABLE `abc` ADD PRIMARY KEY (`id`);<br />//添加索引username<br />ALTER TABLE `abc` ADD INDEX `abc` (`username`); <br />出自蓝草空间<br /></p><img src ="http://www.blogjava.net/huyi2006/aggbug/208867.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-06-18 14:41 <a href="http://www.blogjava.net/huyi2006/articles/208867.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>php下操作sqlite的一个类</title><link>http://www.blogjava.net/huyi2006/articles/203413.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Wed, 28 May 2008 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/203413.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/203413.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/203413.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/203413.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/203413.html</trackback:ping><description><![CDATA[
		<p>class Sqlite {<br />var $link;<br />var $querynum = 0;</p>
		<p>/*连接Sqlite数据库，参数：dbname-&gt;数据库名字*/<br />function Open($dbname) {<br />if(!($this-&gt;link = @sqlite_open($dbname))) {<br />$this-&gt;halt('Can not Open to Sqlite');<br />}<br />}</p>
		<p>/*执行sql语句，返回对应的结果标识*/<br />function Query($sql) {<br />$this-&gt;querynum++;<br />if($query = @sqlite_query($this-&gt;link, $sql)) {<br />return $query;<br />} else {<br />$this-&gt;halt('Sqlite Query Error', $sql);<br />}<br />}</p>
		<p>/*执行Insert Into语句，并返回最后的insert操作所产生的自动增长的id*/<br />function Insert($table, $iarr) {<br />$value = $this-&gt;InsertSql($iarr);<br />$this-&gt;Query('INSERT INTO "' . $table . '" ' . $value);<br />return sqlite_last_insert_rowid($this-&gt;link);<br />}</p>
		<p>/*执行Update语句，并返回最后的update操作所影响的行数*/<br />function Update($table, $uarr, $condition = '') {<br />$value = $this-&gt;UpdateSql($uarr);<br />if ($condition) {<br />$condition = ' WHERE ' . $condition;<br />}<br />$this-&gt;Query('UPDATE "' . $table . '"' . ' SET ' . $value . $condition);<br />return sqlite_changes($this-&gt;link);<br />}</p>
		<p>/*执行Delete语句，并返回最后的Delete操作所影响的行数*/<br />function Delete($table, $condition = '') {<br />if ($condition) {<br />$condition = ' WHERE ' . $condition;<br />}<br />$this-&gt;Query('DELETE "' . $table . '"' . $condition);<br />return sqlite_changes($this-&gt;link);<br />}</p>
		<p>/*将字符转为可以安全保存的sqlite值，比如a'a转为a''a*/<br />/*<br />function EnCode($str) {<br />if (strpos($str, "\0") === false) {<br />if (strpos($str, '\'') === false) {<br />return $str;<br />} else {<br />return str_replace('\'', '\'\'', $str);<br />}<br />} else {<br />$str = str_replace("\0", '', $str);<br />if (strpos($str, '\'') === false) {<br />return $str;<br />} else {<br />return str_replace('\'', '\'\'', $str);<br />}<br />}<br />}<br />*/<br />function EnCode($str) {<br />return sqlite_escape_string($str);<br />}</p>
		<p>/*将可以安全保存的sqlite值转为正常的值，比如a''a转为a'a*/<br />function DeCode($str) {<br />if (strpos($str, '\'\'') === false) {<br />return $str;<br />} else {<br />return str_replace('\'\'', '\'', $str);<br />}<br />}</p>
		<p>/*将对应的列和值生成对应的insert语句，如：array('id' =&gt; 1, 'name' =&gt; 'name')返回("id", "name") VALUES (1, 'name')*/<br />function InsertSql($iarr) {<br />if (is_array($iarr)) {<br />$fstr = '';<br />$vstr = '';<br />foreach ($iarr as $key =&gt; $val) {<br />$fstr .= '"' . $key . '", ';<br />$vstr .= '\'' . $val . '\', ';<br />}<br />if ($fstr) {<br />$fstr = '(' . substr($fstr, 0, -2) . ')';<br />$vstr = '(' . substr($vstr, 0, -2) . ')';<br />return $fstr . ' VALUES ' . $vstr;<br />} else {<br />return '';<br />}<br />} else {<br />return '';<br />}<br />}</p>
		<p>/*将对应的列和值生成对应的insert语句，如：array('id' =&gt; 1, 'name' =&gt; 'name')返回"id" = 1, "name" = 'name'*/<br />function UpdateSql($uarr) {<br />if (is_array($uarr)) {<br />$ustr = '';<br />foreach ($uarr as $key =&gt; $val) {<br />$ustr .= '"' . $key . '" = \'' . $val . '\', ';<br />}<br />if ($ustr) {<br />return substr($ustr, 0, -2);<br />} else {<br />return '';<br />}<br />} else {<br />return '';<br />}<br />}</p>
		<p>/*返回对应的查询标识的结果的一行*/<br />function GetRow($query, $result_type = SQLITE_ASSOC) {<br />return sqlite_fetch_array($query, $result_type);<br />}</p>
		<p>/*清空查询结果所占用的内存资源*/<br />function Clear($query) {<br />$query = null;<br />return true;<br />}</p>
		<p>/*关闭数据库*/<br />function Close() {<br />return sqlite_close($this-&gt;link);<br />}</p>
		<p>function halt($message = '', $sql = '') {<br />$ei = sqlite_last_error($this-&gt;link);<br />$message .= '&lt;br /&gt;Sqlite Error: ' . $ei . ', ' . sqlite_error_string($ei);<br />if ($sql) {<br />$sql = '&lt;br /&gt;sql:' . $sql;<br />}<br />exit('DataBase Error.&lt;br /&gt;Message: ' . $message . $sql);<br />}<br />}</p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/203413.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-28 10:34 <a href="http://www.blogjava.net/huyi2006/articles/203413.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP生成缩略图的实现</title><link>http://www.blogjava.net/huyi2006/articles/202634.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:20:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202634.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202634.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202634.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202634.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202634.html</trackback:ping><description><![CDATA[
		<p>PHP令我们惊喜的就是在图形图象处理方面要忧于ASP，用GD库PHP就可以轻松的实现缩略图。这一篇文章我们的目的就是用GD来生成缩略图，PHP可以把缩略图直接生成输送到浏览器也可以以文件的形式把其存储到硬盘当中。</p>
		<p> </p>
		<p>在生成缩略图的过程当中我们需要用到GD库当中的几个函数：</p>
		<p>getimagesize(string filename [,array var])),取得图像的信息，返回值是一人array,包括几项信息$var[0]----返回图像的width,$var[1]----返回height,[2]返回图像文件的type,[4]返回的是与&lt;img src=""&gt;当中的wdith,height有关的width="",height=""信息。</p>
		<p>imageX(resource image)</p>
		<p>imageY(resource image)  返回图像的宽和高</p>
		<p>imagecopyresized(des img,src img,int des_x,int des_y,int src_x,int src_y,int des_w,int des_h,int src_w,int src_y)  复制并截取区域图像</p>
		<p>imagecreatetruecolor(int width,int height)  创建一个真彩图</p>
		<p>imagejpeg(resource image) </p>
		<p>下面就是Code:<br />&lt;?php<br /># Constants<br />define(IMAGE_BASE, '/var/www/html/mbailey/images');<br />define(MAX_WIDTH, 150);<br />define(MAX_HEIGHT, 150);</p>
		<p># Get image location<br />$image_file = str_replace('..', '', $_SERVER['QUERY_STRING']);<br />$image_path = IMAGE_BASE . "/$image_file";</p>
		<p># Load image<br />$img = null;<br />$ext = strtolower(end(explode('.', $image_path)));<br />if ($ext == 'jpg' || $ext == 'jpeg') {<br />    $img = @imagecreatefromjpeg($image_path);<br />} else if ($ext == 'png') {<br />    $img = @imagecreatefrompng($image_path);<br /># Only if your version of GD includes GIF support<br />} else if ($ext == 'gif') {<br />    $img = @imagecreatefrompng($image_path);<br />}</p>
		<p># If an image was successfully loaded, test the image for size<br />if ($img) {</p>
		<p>    # Get image size and scale ratio<br />    $width = imagesx($img);<br />    $height = imagesy($img);<br />    $scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);</p>
		<p>    # If the image is larger than the max shrink it<br />    if ($scale &lt; 1) {<br />        $new_width = floor($scale*$width);<br />        $new_height = floor($scale*$height);</p>
		<p>        # Create a new temporary image<br />        $tmp_img = imagecreatetruecolor($new_width, $new_height);</p>
		<p>        # Copy and resize old image into new image<br />        imagecopyresized($tmp_img, $img, 0, 0, 0, 0,<br />                         $new_width, $new_height, $width, $height);<br />        imagedestroy($img);<br />        $img = $tmp_img;<br />    }<br />}</p>
		<p># Create error image if necessary<br />if (!$img) {<br />    $img = imagecreate(MAX_WIDTH, MAX_HEIGHT);<br />    imagecolorallocate($img,0,0,0);<br />    $c = imagecolorallocate($img,70,70,70);<br />    imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);<br />    imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);<br />}</p>
		<p># Display the image<br />header("Content-type: image/jpeg");<br />imagejpeg($img);<br />?&gt; </p>
		<p>我们把上面的Code存储为test.php,然后通过test.php?image name的形式来访问，结果会让你惊喜的，因为在这里你看到了PHP的优点，它可以让ASP相形见绌。</p>
		<p>上面的这段代码当中我们通过end(explode(".",$image_path)来取得文件的扩展名，但是我感觉还是不理想。这样是能够取得文件的类型的，因为end()函数会跳到本array的最后一个单元，但是如果我们采用getimagesize()会取得更为强大的专门针对于图像文件的类型。</p>
		<p>本程序显示的缩略图是限制宽高都在150内，然后用min()函数来取得它们比值的最小值来计算缩略图的宽和高，并且通过一系列的GD库函数来取得相应的信息，并且呈现给浏览器，当然你也可以写到你所使用的硬盘当中。</p>
		<p>好了，这就是PHP的缩略图功能，大家觉得有什么好的意见可以多多拍砖! <br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202634.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:20 <a href="http://www.blogjava.net/huyi2006/articles/202634.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用户登录</title><link>http://www.blogjava.net/huyi2006/articles/202633.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:16:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202633.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202633.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202633.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202633.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202633.html</trackback:ping><description><![CDATA[
		<p>&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;用户登录&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;body alink="#FF0000" link="#000099" vlink="#CC6600" topmargin="8" leftmargin="0" bgColor="#FFFFFF"&gt;<br />&lt;br&gt;<br />&lt;?<br /> require("mysql.class.php");<br /> if($userid!="")<br /> {<br />  $db-&gt;dbconnect($db-&gt;dbbase,0);<br />  //判断用户名和密码是否在正确<br />  $strSql="select * from user where userid='$userid' and password='$password'";<br />  $result=$db-&gt;dbquery($strSql,$database);<br />  $num=$db-&gt;dbgetnum($result);<br />  //$num=mysql_numrows($result);<br />  $db-&gt;dbclose();<br />  //mysql_close($myconn);<br />  if($num&gt;0)<br />  {<br />   echo "&lt;center&gt;登录成功！&lt;/center&gt;&lt;br&gt;";<br />  }<br />  else echo "&lt;center&gt;&lt;font color=red&gt;登录失败！请检查用户名和密码！&lt;/font&gt;&lt;/center&gt;&lt;br&gt;";<br /> }<br /> else<br /> {<br />  echo "&lt;center&gt;请输入用户名和密码登录！&lt;/center&gt;"<br />?&gt;<br />&lt;form action="&lt;?echo $PHP_SELF?&gt;" method="post"&gt;<br />&lt;table cellspacing=0 bordercolordark=#FFFFFF width="60%" bordercolorlight=#000000 border=1 align="center" cellpadding="2"&gt;<br />  &lt;tr bgcolor="#6b8ba8" style="color:FFFFFF"&gt;<br />    &lt;td width="100%" align="center" valign="bottom" height="19" colspan="3"&gt;用户登录&lt;/td&gt;<br />  &lt;/tr&gt;<br />  &lt;tr&gt;<br />    &lt;td width="30%" align="center"&gt;用户名：&lt;/td&gt;<br />    &lt;td width="70%" align="center"&gt;&lt;input type="text" name="userid" size="20" maxsize="20"&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br />  &lt;tr&gt;<br />    &lt;td width="30%" align="center"&gt;密  码：&lt;/td&gt;<br />    &lt;td width="70%" align="center"&gt;&lt;input type="password" name="password" size="20" maxsize="20"&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br />  &lt;tr&gt;<br />    &lt;td width="100%" align="center" colspan="2"&gt;&lt;input type="submit" value="登录"&gt;&lt;/td&gt;<br />  &lt;/tr&gt;<br />&lt;/table&gt;<br />&lt;/form&gt;<br />&lt;?<br /> }<br />?&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</p>
		<p>
				<br /> </p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202633.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:16 <a href="http://www.blogjava.net/huyi2006/articles/202633.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用户注册reg.php</title><link>http://www.blogjava.net/huyi2006/articles/202632.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:15:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202632.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202632.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202632.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202632.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202632.html</trackback:ping><description><![CDATA[
		<p>require("mysql.class.php");<br /> if($userid!="")<br /> {<br />  $ID = uniqid("userID");<br />  //$db = mysql_connect("localhost","root","");<br />  $db-&gt;dbconnect($db-&gt;dbbase,0);<br />  //mysql_select_db ("test");<br />  $strSql="insert into user (id,username,userid,password,email,department,tel) values ('$id','$username','$userid','$password','$email','$department','$tel')";<br />  //$result = mysql_query ("insert into user (id, username, userid, password, email,department,tel)VALUES ('$ID','$username','$userid','$password','$email','$departmen','$tel')");<br />  $result=$db-&gt;dbquery($strSql);<br />  if(!$result)<br />  {<br />   echo "出现错误：", mysql_error();<br />   exit;<br />  }<br />  if($result)<br />  {<br />   //mysql_close($db);<br />   $db-&gt;dbclose();<br />   echo "用户 $username 注册成功";<br />   print('');<br />  }<br /> }<br /> else<br /> {<br /> echo "资料填写不完整，请仔细填写！";<br />?&gt;<br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202632.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:15 <a href="http://www.blogjava.net/huyi2006/articles/202632.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>文件类-file.class.php</title><link>http://www.blogjava.net/huyi2006/articles/202631.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:13:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202631.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202631.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202631.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202631.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202631.html</trackback:ping><description><![CDATA[
		<p>/*<br /> 本类用于对文件系统的处理<br />*/<br />class IO {<br /> var $result;// 操作返回结果，如方法返回值为 mixed，则成功操作结果可在此获得<br /> var $exec_cmd;//执行方法，暂时没应用到<br /> var $exist_dir;//创建目录时最后存在的目录，现用于 copy() 和 move()<br /> var $buffer_size;//文件读取缓冲区大小，根据服务应用规模和服务器配置修改，建议默认值<br /> /**<br />     * @]Class Name[= IO<br />     * @]Class URI[= System.IO<br />     * @]Purpose[=<br />     *     本类用于对文件系统的处理<br />     * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />     * @]Version[= 1.1.1<br />     * @]Create[= 17:13 2004-3-25<br />     * @]Modifications[=<br />     *     4:04 2004-3-30<br />     *     + 修复 generate_path() 方法中存在的一些 BUG<br />     *     + 重新设计方法 no_comment()<br />     *     4:32 2004-3-29<br />     *     + 简化方法 list_dir() 的返回值<br />     *     + 增加方法 file_info() 获取文件或目录信息<br />     *     5:35 2004-3-28<br />     *     + 整理优化算法<br />     *     7:31 2004-3-27<br />     *     + 将错误处理抽象为基类<br />     *     + 增加方法 no_comment() 删除文件中 C 规范注释<br />     * @]See[=<br />     */<br /> function IO() {<br />  //parent::SnkClass();<br />  $this-&gt;result=array();<br />  $this-&gt;exec_cmd="";<br />  $this-&gt;exist_dir="";<br />  $this-&gt;buffer_size=8192;<br />  return $this;<br /> }<br /> /**<br />         * @]Method Name[= list_dir()<br />         * @]Purpose[=<br />         *     读取指定目录内容，返回内容数组<br />         * @]Parameter[=<br />         *     string $dir_path 指定目录路径，默认为当前目录<br />         * @]Return[= mixed 错误返回 FALSE，否则返回<br />         *     array(<br />         *         array("name","location","type"),<br />         *         ......<br />         *     )<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */</p>
		<p> // 读取指定目录内容，返回内容数组<br /> function list_dir($path="."){<br />  if(!is_dir($path)) return $this-&gt;error_occur(oxooob,__FUNCTION__);<br />  if(!is_readable($path)) return $this-&gt;error_occur(0x0002,$path);<br />  <a href="mailto:$dh=@opendir($path">$dh=@opendir($path</a>);<br />  $result=array();<br />  $path=realpath($path);<br />  //// 保证目录绝对地址后带目录分隔符<br />  if($path[strlen($path)-1]!=DIRECTORY_SEPARATOR) $path.=DIRECTORY_SEPARATOR;</p>
		<p>  // 使用 !== 防止处理名称为 0 或 FALSE 的文件、目录<br />  while(FALSE!=($fh=readdir($dh))){<br />   if($fh=="." || $fh=="..") continue;<br />   $i=$path.$fh;<br />   $t=array("name"=&gt;$fh,"location"=&gt;$i,"type"=&gt;is_file($i)?1:(is_dir($i)?0:-1));<br />   $result[]=$t;<br />  }<br />  closedir($dh);<br />  unset($dh,$fh,$t,$i);<br />  clearstatcache();// 清除文件系统缓存<br />  return $this-&gt;result=$result;<br /> }<br />/**<br />         * @]Method Name[= file_info()<br />         * @]Purpose[=<br />         *     获取指定文件或目录的属性<br />         * @]Parameter[=<br />         *     string $dir_path 指定目录路径，默认为当前目录<br />         * @]Return[= mixed 错误返回 FALSE，否则返回<br />         *     array("name","location","type","size","access","change","modify","read","write"),<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */</p>
		<p> //获取指定文件或目录的属<br /> function file_info($path="."){<br />  $path=realpath($path);<br />  if(!$path) return $this-&gt;error_occur(oxoooa,__FUNCTION__);<br />  $result=array(<br />   "name"=&gt;substr($path,strpos($path,DIRECTORY_SEPARATOR)+1),<br />   "location"=&gt;$path,<br />   "type"=&gt;is_file($i)?1:(is_dir($i)?0:-1),<br />   "size"=&gt;filesize($path),<br />   "access"=&gt;fileatime($path),<br />   "modify"=&gt;filemtime($path),<br />   "change"=&gt;filectime($path),<br />   "read"=&gt;is_readable($path),<br />   "write"=&gt;is_writeable($path)<br />  );<br />  clearstatcache();<br />  return $this-&gt;result=$result;<br /> }<br />/**<br />         * @]Method Name[= seek_file()<br />         * @]Purpose[=<br />         *     根据正则表达式条件，在相应目录及给定层次的子目录中搜索匹配的文件、目录<br />         * @]Parameter[=<br />         *     string $pattern 兼容 PERL 标准的正则表达式指明搜索匹配要求，会添加 /^ $/，默认为 .*<br />         *     string $path 进行搜索的目录路径，默认为当前路径<br />         *     enum $seesk_type 有 -1 0 1 三种可能值，0 仅文件夹，1 仅文件，-1 两者都包括，默认为 1<br />         *     int $sub_dir 搜索的子目录深度，指定目录不算，建议不要超过 5，默认为 0<br />         *     limit $limit 搜索结果限制，避免过度浪费系统资源，默认为 100<br />         * @]Return[= mixed 错误返回 FALSE，否则<br />         *     array(<br />         *         array(<br />         *             "name","locate","type"<br />         *         ),<br />         *         ......<br />         *     )<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */</p>
		<p> //根据正则表达式条件，在相应目录及给定层次的子目录中搜索匹配的文件、目录<br /> function seek_file($path=".*",$path=".",$seek_type=1,$sub_dir_level=0,$limit=100){<br />  //check parameter<br />  $is_error=$seek_type!=1&amp;&amp;$seek_type!=0&amp;&amp;$seek_type!=1;<br />  $is_error=$is_error &amp;&amp; (!is_int($sub_dir_level) || $sub_dir_level &lt; 0);<br />  $is_error = $is_error &amp;&amp; (!is_int($limit) || $limit &lt; 1);<br />        if ($is_error) return $this-&gt;error_occur(0x000B, __FUNCTION__);<br />        unset($is_error);<br />        $result = array();<br />        /* array() == FALSE，所以需要使用 === */<br />        if (FALSE===$i=$this-&gt;list_dir($path)) return FALSE; // 如果不能列举目录，返回<br />        for ($j=0,$k=count($i);$j&lt;$k;$j++) {<br />             if ($i[$j]["type"]==-1) continue; // 对于非目录非文件项目，跳过<br />             if ($i[$j]["type"]==0&amp;&amp;$sub_dir_level) { // 如果需要搜索下层目录<br />                if (FALSE===$l=$this-&gt;seek_file($pattern,$i[$j]["location"],$seek_type,($sub_dir_level - 1),$limit)) return FALSE;<br />                    $result = array_merge($result, $l); // 将下层目录搜索结果添加<br />                }<br />                if ($seek_type+$i[$j]["type"]==1||!preg_match("/^".$pattern."$/", $i[$j]["name"])) continue; // 如果不搜索当前类型，跳过<br />                $result[] = $i[$j];<br />                if (count($result)&gt;=$limit) { // 截去超过要求的长度，离开列举<br />                    array_splice($result, $limit);<br />                    break;<br />                }<br />            }<br />        unset($i, $j, $k, $l);<br />        return $this-&gt;result = $result;</p>
		<p> }<br />  /*<br />         * @]Method Name[= delete()<br />         * @]Purpose[=<br />         *     删除指定对象，文件或文件夹——包括内含子目录和文件的非空文件夹<br />         * @]Parameter[=<br />         *     string $path 指定要删除的内容路径，文件或目录均可<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function delete($path="") {<br />            $path = realpath($path);<br />            if (!$path) return $this-&gt;error_occur(0x000A, __FUNCTION__);<br />            if (!is_dir($path)) {<br />                if (@unlink($path)) return TRUE; // 文件删除成功<br />                return $this-&gt;error_occur(0x0004, $path);<br />            } else {<br />                if (FALSE===$i=$this-&gt;list_dir($path)) return FALSE; // 不能列举目录<br />                for ($j=0,$k=count($i);$j&lt;$k;$j++)<br />                    if (!$this-&gt;delete($i[$j]["location"])) return FALSE; // 删除目录内容出错<br />                unset($i, $j, $k);<br />                return TRUE;<br />            }<br />        }</p>
		<p>        /**<br />         * @]Method Name[= generate_path()<br />         * @]Purpose[=<br />         *     获取现有或不存在文件、目录的绝对地址<br />         * @]Parameter[=<br />         *     string $path 要获取地址的文件、目录现有相对、绝对地址<br />         * @]Return[= string 获得的地址<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function generate_path($path="") {<br />            $i = "/"==DIRECTORY_SEPARATOR ? "\\" : "/"; // 统一目录分割符<br />            $path = str_replace($i, DIRECTORY_SEPARATOR, strval($path));<br />            if ($path[strlen($path)-1]!=DIRECTORY_SEPARATOR) $path .= DIRECTORY_SEPARATOR;<br />            $i = strpos($path, DIRECTORY_SEPARATOR); // 获得路径中首个目录分割符的位置<br />            $ext = substr($path, $i+1);<br />            $path = substr($path, 0, $i+1);<br />            if ($i=realpath($path)) $path = $i; // 得到基本路径<br />            else {<br />                $ext = $path.$ext;<br />                $path = realpath(".");<br />            }<br />            if (strlen($ext)) { // 对剩余内容处理<br />                $ext = preg_replace("/[\:\*\?\"\&lt;\&gt;\|]/", "", explode(DIRECTORY_SEPARATOR, $ext));<br />                array_pop($ext);<br />                $path = explode(DIRECTORY_SEPARATOR, $path); // 建立目录层轴<br />                if ($path[count($path)-1]=="") array_pop($path);<br />                while (count($ext)) {<br />                    $i = array_shift($ext);<br />                    if ($i==".."&amp;&amp;count($path)&gt;1) array_pop($path);<br />                    elseif (""!=str_replace(".", "", $i)) $path[] = $i;<br />                }<br />                $path = implode(DIRECTORY_SEPARATOR, $path);<br />            }<br />            unset($ext, $i);<br />            return $path;<br />        }</p>
		<p>        /**<br />         * @]Method Name[= make_dir()<br />         * @]Purpose[=<br />         *     建立任意文件夹，相对或绝对路径皆可，深层建立亦可<br />         * @]Parameter[=<br />         *     string $path 要建立的最终目录路径<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function make_dir($path="") {<br />            $i = explode(DIRECTORY_SEPARATOR, $this-&gt;generate_path($path)); // 生成目录路径<br />            $path = array_shift($i);<br />            for ($j=0,$k=count($i);$j&lt;$k;$j++) {<br />                $path .= DIRECTORY_SEPARATOR.$i[$j];<br />                if (!is_dir($path)) {<br />                    if ($this-&gt;exist_dir=="") $this-&gt;exist_dir = $path; // 记录最后存在的目录路径<br />                    if (<a href="mailto:!@mkdir($path">!@mkdir($path</a>)) return $this-&gt;error_occur(0x0003, substr($path, 0, strrpos($path, DIRECTORY_SEPARATOR)));<br />                }<br />            }<br />            if ($this-&gt;exist_dir=="") $this-&gt;exist_dir = $path;<br />            return TRUE;<br />        }</p>
		<p>        /**<br />         * @]Method Name[= verify_file()<br />         * @]Purpose[=<br />         *     使用 MD5 算法比较两个文件是否相同<br />         * @]Parameter[=<br />         *     string $src 源文件路径<br />         *     string $dst 目标文件路径<br />         *     boolean $interal 对于超过 1MB 文件，设置 FALSE 省去 MD5 检验步骤，减轻服务器负担<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function verify_file($src="", $dst="", $interal=TRUE) {<br />            if (!is_file($src)||!is_file($dst)) return $this-&gt;error_occur(0x000B, __FUNCTION__);<br />            if (!is_readable($src)) return $this-&gt;error_occur(0x0006, $src);<br />            if (!is_readable($dst)) return $this-&gt;error_occur(0x0006, $dst);<br />            $i = filesize($src);<br />            if (filesize($dst)!=$i) { // 文件大小不等<br />                unset($i);<br />                return FALSE;<br />            }<br />            if ($i&gt;1024*1024*1024&amp;&amp;!$interal) { // 对于 1MB 的文件，如果不要求精确检查，跳过<br />                unset($i);<br />                return TRUE;<br />            }<br />            unset($i);<br />            if (md5_file($src)!=md5_file($dst)) return FALSE; // 文件 MD5 效验不符合，内容不相同<br />            return TRUE;<br />        }</p>
		<p>        /**<br />         * @]Method Name[= copy()<br />         * @]Purpose[=<br />         *     对任意文件夹、文件进行复制，相对或绝对路径皆可，文件复制完成后会进行效验，检查是否出错数据错误<br />         * @]Parameter[=<br />         *     string $src_path 指定要复制的源内容路径，文件或目录均可<br />         *     string $dst_path 指定要复制的目标内容路径，文件或目录均可，性质由 $src_path 决定，可为 $src_path 下层目录<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function copy($src="", $dst="", $sub=FALSE) {<br />            if (!$src=realpath($src)) return $this-&gt;error_occur(0x000B, __FUNCTION__);<br />            $dst = $this-&gt;generate_path($dst);<br />            if (is_dir($src)) { // 处理目录<br />                /*<br />                 * 关于算法的说明：<br />                 *     本来打算使用很简单的递归算法，遇神杀神，遇魔斩魔的，后来发现一个问题：如果目标路径<br />                 *   为源路径的后代路径怎么办？这样算法会不停的探测下去…<br />                 *     于是添加了 $this-&gt;exist_dir 属性，用来记录这一情况下目标路径中存在的部分。于是新的问<br />                 *   题出来了：如何保存这一属性？<br />                 *     将整个功能整合到 $this-&gt;copy() 方法中，那么必然需要在这个函数中记录 $this-&gt;exist_dir<br />                 *   的变化，于是乎需要另外的一个有效的方法来阻止每一次操作中对其的更改。<br />                 *     作为变通，我使用的隐藏参数 $sub，这个参数无论如何，只要算法不变，永远在参数表的最<br />                 *   后一个。因此，方法开始变得不稳定，但这也没有办法，只能希望程序员自己不要故意破坏。<br />                 *     在外部调用时，因为默认 FALSE，所以对 $this-&gt;exist_dir 写。内部递归时，显性 TRUE，不<br />                 *   该属性，保证有效性。<br />                 */<br />                if (!is_readable($src)) return $this-&gt;error_occur(0x0002, $src);<br />                if ($dst[strlen($dst)-1]!=DIRECTORY_SEPARATOR) $dst .= DIRECTORY_SEPARATOR;<br />                if (TRUE===$sub&amp;&amp;$src==$this-&gt;exist_dir) return TRUE; // 源路径为记录的目标路径<br />                if (TRUE!==$sub) $this-&gt;exist_dir = ""; // 记录创建目录前目标目录路径中存在的目录路径<br />                if (!$this-&gt;make_dir($dst)) return FALSE; // 创建目录<br />                if (FALSE===$i=$this-&gt;list_dir($src)) return FALSE; // 读取目录出错<br />                for ($j=0,$k=count($i);$j&lt;$k;$j++) if (!$this-&gt;copy($i[$j]["location"], $dst.$i[$j]["name"],TRUE)) return FALSE;<br />                unset($i, $j, $k);<br />                RETURN TRUE;<br />            } else {<br />                if (!is_readable($src)) return $this-&gt;error_occur(0x0006, $src);<br />                if ($this-&gt;verify_file($src,$dst)) return TRUE;<br />                if (!copy($src,$dst)) return $this-&gt;error_occur(0x0007, $dst);<br />                if (!$this-&gt;verify_file($src,$dst)) {<br />                    @unlink($dst); // 复制文件失败删除新文件<br />                    return $this-&gt;error_occur(0x0007, $dst);<br />                }<br />                return TRUE;<br />            }<br />        }</p>
		<p>        /**<br />         * @]Method Name[= move()<br />         * @]Purpose[=<br />         *     对任意文件夹、文件进行移动，相对或绝对路径皆可，文件移动完成后会进行效验，检查是否出错数据错误<br />         * @]Parameter[=<br />         *     string $src_path 指定要移动的源内容路径，文件或目录均可<br />         *     string $dst_path 指定要移动的目标内容路径，文件或目录均可，性质由 $src_path 决定，可为 $src_path 下层目录<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function move($src="", $dst="", $sub=FALSE) {<br />            if (!$src=realpath($src)) return $this-&gt;error_occur(0x000B, __FUNCTION__);<br />            $dst = $this-&gt;generate_path($dst);<br />            if (is_dir($src)) { // 处理目录<br />                if (!is_readable($src)) return $this-&gt;error_occur(0x0002, $src);<br />                if ($dst[strlen($dst)-1]!=DIRECTORY_SEPARATOR) $dst .= DIRECTORY_SEPARATOR;<br />                if (TRUE===$sub&amp;&amp;$src==$this-&gt;exist_dir) return TRUE;<br />                if (TRUE!==$sub) $this-&gt;exist_dir = "";<br />                if (!$this-&gt;make_dir($dst)) return FALSE;<br />                if (FALSE===$i=$this-&gt;list_dir($src)) return FALSE;<br />                for ($j=0,$k=count($i);$j&lt;$k;$j++) if (!$this-&gt;move($i[$j]["location"], $dst.$i[$j]["name"],TRUE)) return FALSE;<br />                unset($i, $j, $k);<br />                if (FALSE===strpos($this-&gt;exist_dir,$src))<br />                    if (<a href="mailto:!@rmdir($src">!@rmdir($src</a>)) return $this-&gt;error_occur(0x0004, $src); // 对非目标目录的上层目录，删除<br />                return TRUE;<br />            } else {<br />                if (!is_readable($src)) return $this-&gt;error_occur(0x0006, $src);<br />                if ($this-&gt;verify_file($src,$dst)) return TRUE;<br />                if (!copy($src,$dst)) return $this-&gt;error_occur(0x0007, $dst);<br />                if (!$this-&gt;verify_file($src,$dst)) {<br />                    @unlink($dst);<br />                    return $this-&gt;error_occur(0x0007, $dst);<br />                }<br />                if (<a href="mailto:!@unlink($src">!@unlink($src</a>)) return $this-&gt;error_occur(0x0006, $src); // 删除源文件<br />                return TRUE;<br />            }<br />        }</p>
		<p>        /**<br />         * @]Method Name[= no_comment()<br />         * @]Purpose[=<br />         *     清除文件中 C 规范的注释<br />         * @]Parameter[=<br />         *     string $path 指定要执行操作的文件<br />         * @]Return[= boolean 错误返回 FALSE，否则 TRUE<br />         * @]Author[= SNakeVil &lt;51JS,BU,PHPx&gt; (<a href="mailto:snakevil@qq.com">snakevil@qq.com</a>)<br />         * @]See[=<br />         */<br />        function no_comment($path="") {<br />            if (!is_file($path)) return $this-&gt;error_occur(0x000B, __FUNCTION__);<br />            if (!is_readable($path)) return $this-&gt;error_occur(0x0006, $path);<br />            if (!is_writeable($path)) return $this-&gt;error_occur(0x0007, $path);<br />            if (!$th=tmpfile()) return $this-&gt;error_occur(0x000C, $path); // 创建临时文件<br />            $fh = fopen($path, "r+b");<br />            if (!flock($fh,LOCK_EX)) { // 锁定文件<br />                fclose($fh);<br />                unset($fh);<br />                return $this-&gt;error_occur(0x0009, $path);<br />            }<br />            $fbuffer = fread($fh, $this-&gt;buffer_size*2); // 文件读取缓冲区<br />            $tbuffer = ""; // 临时文件缓冲区<br />            $in_dq = $in_sq = $in_lc = $in_bc = FALSE;<br />            while ($fblen=strlen($fbuffer)) { // 处理原始数据<br />                $fstats = feof($fh);<br />                for ($i=0;$i&lt;$fblen;$i++) { // 分析文件内容<br />                    if (!$fstats&amp;&amp;$i+5&gt;$fblen) break; // 文件未完全读取时临近缓冲区读取完成读取下一块文件内容<br />                    $j = substr($fbuffer, $i, 2);<br />                    $k = $j[0];<br />                    if ($j=="/*"&amp;&amp;!$in_dq&amp;&amp;!$in_sq&amp;&amp;!$in_lc) { // 不在字符串和行注释中，块注释开始<br />                        $in_bc = TRUE;<br />                        $i++;<br />                    } elseif ($j=="*/"&amp;&amp;$in_bc) { // 块注释结束<br />                        $in_bc = FALSE;<br />                        $i+=2;<br />                    } elseif ($j=="//"&amp;&amp;!$in_dq&amp;&amp;!$in_sq&amp;&amp;!$in_bc) { // 行注释开始<br />                        $in_lc = TRUE;<br />                        $i++;<br />                    } elseif ($in_lc&amp;&amp;($k=="\r"||$k=="\n")) $in_lc = FALSE; // 行注释结束<br />                    elseif ($j=="<a>\\\\"||$j=="\\\""||$j=="\\'</a>") { // 转义字符<br />                        $tbuffer .= $j;<br />                        $i++;<br />                        continue;<br />                    } elseif ($k=="\""&amp;&amp;!$in_sq&amp;&amp;!$in_bc&amp;&amp;!$in_lc) $in_dq = !$in_dq; // 双引号字符串开始、结束<br />                    elseif ($k=="'"&amp;&amp;!$in_dq&amp;&amp;!$in_bc&amp;&amp;!$in_lc) $in_sq = !$in_sq; // 单引号字符串开始、结束<br />                    if ($in_lc||$in_bc) continue; // 在注释中，跳过<br />                    $tbuffer .= $fbuffer[$i];<br />                }<br />                $fbuffer = substr($fbuffer, $i); // 抛弃读取过的部分<br />                unset($i, $j, $k);<br />                if (!$fstats) $fbuffer .= fread($fh, $this-&gt;buffer_size);<br />                if ($fstats||strlen($tbuffer)&gt;=$this-&gt;buffer_size) { // 写入合法数据到临时文件<br />                    if (!fwrite($th,$tbuffer)) { // 写入失败，空间不足<br />                        fclose($th);<br />                        flock($fh, LOCK_UN);<br />                        fclose($fh);<br />                        unset($th, $fh, $in_dq, $in_sq, $in_lc, $in_bc, $i, $j, $k);<br />                        return $this-&gt;error_occur(0x000D, "");<br />                    }<br />                    $tbuffer = "";<br />                }<br />            }<br />            unset($fbuffer, $tbuffer, $fstats, $in_dq, $in_sq, $in_lc, $in_bc);<br />            rewind($fh); // 回移文件指针到文件首<br />            rewind($th);<br />            $i = $j = "";<br />            $k = 0;<br />            while (!feof($th)) { // 将临时文件数据写回源文件<br />                $i = fgets($th, $this-&gt;buffer_size);<br />                if ($j=="") { // 获得文件系统的换行符<br />                    $j= substr($i, -2);<br />                    if ($j=="\r\n") $k = 2;<br />                    elseif ($j[1]=="\r"||$j[1]=="\n") {<br />                        $k = 1;<br />                        $j = $j[1];<br />                    } else $j = "";<br />                }<br />                if (substr($i, -$k)==$j) {<br />                    $i = rtrim(substr($i, 0, -$k), " \t");<br />                    if (strlen($i)) fwrite($fh, $i.$j); // 清除右方空格<br />                    else continue;<br />                } else fwrite($fh, rtrim($i, " \t"));<br />            }<br />            fflush($fh); // 保存、关闭文件<br />            ftruncate($fh, ftell($fh));<br />            fclose($th);<br />            flock($fh, LOCK_UN);<br />            fclose($fh);<br />            unset($i, $j, $k, $fh, $th);<br />            return TRUE;<br />        }<br />    /**<br />     * @]Error List[=<br />     *     0x0001  指定目录不存在<br />     *     0x0002  指定目录无读取权限<br />     *     0x0003  指定目录无写入权限<br />     *     0x0004  指定目录无删除权限<br />     *     0x0005  指定文件不存在<br />     *     0x0006  指定文件无读取权限<br />     *     0x0007  指定文件无写入权限<br />     *     0x0008  指定文件无删除权限<br />     *     0x0009  指定文件无法锁定<br />     *     0x000A  指定对象不存在<br />     *     0x000B  方法指定参数不正确<br />     *     0x000C  无法创建临时文件<br />     *     0x000D  磁盘空间不足<br />     *     0x000E  <br />     *     0x000F  <br />     *     0x0010  <br />     *     0x0011  <br />     *     <br />     */<br />}</p>
		<p>;?&gt;</p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202631.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:13 <a href="http://www.blogjava.net/huyi2006/articles/202631.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>浏栏器-explore.class.php</title><link>http://www.blogjava.net/huyi2006/articles/202630.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:10:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202630.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202630.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202630.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202630.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202630.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #000000">&lt;?</span>
				<span style="COLOR: #000000">php<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">原作者：epsilon7 <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />//SonyMusic(sonymusic@163.net) </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> BrowserDetector { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$UA</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">$HTTP_USER_AGENT的内容 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$BROWSER</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Unknown</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">浏览器类型 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$PLATFORM</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Unknown</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">操作系统 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$VERSION</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">浏览器版本号 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$MAJORVER</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">浏览器主版本号 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$MINORVER</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">浏览器副版本号 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />/*</span>
				<span style="COLOR: #008000"> 构造函数开始 </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> BrowserDetector(){ <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">getenv</span>
				<span style="COLOR: #000000">(HTTP_USER_AGENT); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$preparens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">strpos</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$preparens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">trim</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">strpos</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$preparens</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$preparens</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">trim</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">strtok</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$parens</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">while</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">compatible</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/MSIE/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/Opera/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/X11/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">||</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/SunOS/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">||</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000"> (</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/Linux/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">PLATFORM </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Unix</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/Win/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">PLATFORM </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/Mac/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #000000">||</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">preg_match</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">/PPC/i</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$token</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">PLATFORM </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$token</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">strtok</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$msieIndex</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">strpos</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">MSIE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$msieIndex</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$msieIndex</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Mozilla</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Mozilla</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Netscape</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Mozilla</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Lynx</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Lynx</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Lynx</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Lynx</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">MSIE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">MSIE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">IE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">MSIE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Microsoft Internet Explorer</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Microsoft Internet Explorer</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">IE</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Microsoft Internet Explorer</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">elseif</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Opera</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)) </span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Opera</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Opera</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">Opera</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$browVer</span>
				<span style="COLOR: #000000">)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">trim</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">strpos</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$leftover</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">strpos</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">&gt;=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">) { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">MAJORVER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000">); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">MINORVER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">substr</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$j</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #008080">strlen</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION)); <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000"> { <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">MAJORVER </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />} <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">测试程序开始 </span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> browserdetector; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">UA</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">BROWSER</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">PLATFORM</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">VERSION</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">MAJORVER</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$test</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">MINORVER</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">&lt;br&gt;</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
				<span style="COLOR: #000000"> <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
		</div>
		<p>
				<br />&lt;?php<br />//原作者：epsilon7 <br />//SonyMusic(<a href="mailto:sonymusic@163.net">sonymusic@163.net</a>) <br />class BrowserDetector { <br />var $UA = ""; //$HTTP_USER_AGENT的内容 <br />var $BROWSER= "Unknown"; //浏览器类型 <br />var $PLATFORM = "Unknown"; //操作系统 <br />var $VERSION= ""; //浏览器版本号 <br />var $MAJORVER = ""; //浏览器主版本号 <br />var $MINORVER = ""; //浏览器副版本号 <br />/* 构造函数开始 */ <br />function BrowserDetector(){ <br />$this-&gt;UA = getenv(HTTP_USER_AGENT); <br />$preparens = ""; <br />$parens = ""; <br />$i = strpos($this-&gt;UA,"("); <br />if ($i &gt;= 0) { <br />$preparens = trim(substr($this-&gt;UA,0,$i)); <br />$parens = substr($this-&gt;UA,$i+1,strlen($this-&gt;UA)); <br />$j = strpos($parens,")"); <br />if($j&gt;=0) { <br />$parens = substr($parens,0,$j); <br />} <br />} <br />else { <br />$preparens = $this-&gt;UA; <br />} <br />$browVer = $preparens; <br />$token = trim(strtok($parens,";")); <br />while($token) { <br />if($token=="compatible") { <br />} <br />elseif(preg_match("/MSIE/i","$token")) { <br />$browVer = $token; <br />} <br />elseif(preg_match("/Opera/i","$token")) { <br />$browVer = $token; <br />} <br />elseif(preg_match("/X11/i","$token") || preg_match("/SunOS/i","$token") || preg_match ("/Linux/i","$token")) { <br />$this-&gt;PLATFORM = "Unix"; <br />} <br />elseif(preg_match("/Win/i","$token")) { <br />$this-&gt;PLATFORM = $token; <br />} <br />elseif(preg_match("/Mac/i","$token") || preg_match("/PPC/i","$token")) { <br />$this-&gt;PLATFORM = $token; <br />} <br />$token = strtok(";"); <br />} <br />$msieIndex = strpos($browVer,"MSIE"); <br />if($msieIndex &gt;= 0) { <br />$browVer = substr($browVer,$msieIndex,strlen($browVer)); <br />} <br />$leftover = ""; <br />if(substr($browVer,0,strlen("Mozilla")) == "Mozilla") { <br />$this-&gt;BROWSER = "Netscape"; <br />$leftover=substr($browVer,strlen("Mozilla")+1,strlen($browVer)); <br />} <br />elseif(substr($browVer,0,strlen("Lynx")) == "Lynx") { <br />$this-&gt;BROWSER = "Lynx"; <br />$leftover=substr($browVer,strlen("Lynx")+1,strlen($browVer)); <br />} <br />elseif(substr($browVer,0,strlen("MSIE")) == "MSIE") { <br />$this-&gt;BROWSER = "IE"; <br />$leftover=substr($browVer,strlen("MSIE")+1,strlen($browVer)); <br />} <br />elseif(substr($browVer,0,strlen("Microsoft Internet Explorer")) == "Microsoft Internet Explorer") { <br />$this-&gt;BROWSER = "IE"; <br />$leftover=substr($browVer,strlen("Microsoft Internet Explorer")+1,strlen($browVer)); <br />} <br />elseif(substr($browVer,0,strlen("Opera")) == "Opera") { <br />$this-&gt;BROWSER = "Opera"; <br />$leftover=substr($browVer,strlen("Opera")+1,strlen($browVer)); <br />} <br />$leftover = trim($leftover); <br />$i=strpos($leftover," "); <br />if($i &gt; 0) { <br />$this-&gt;VERSION = substr($leftover,0,$i); <br />} <br />else { <br />$this-&gt;VERSION = $leftover; <br />} <br />$j = strpos($this-&gt;VERSION,"."); <br />if($j &gt;= 0) { <br />$this-&gt;MAJORVER = substr($this-&gt;VERSION,0,$j); <br />$this-&gt;MINORVER = substr($this-&gt;VERSION,$j+1,strlen($this-&gt;VERSION)); <br />} <br />else { <br />$this-&gt;MAJORVER = $this-&gt;VERSION; <br />} <br />} <br />} </p>
		<p>//测试程序开始 <br />$test=new browserdetector; <br />echo $test-&gt;UA."&lt;br&gt;"; <br />echo $test-&gt;BROWSER."&lt;br&gt;"; <br />echo $test-&gt;PLATFORM."&lt;br&gt;"; <br />echo $test-&gt;VERSION."&lt;br&gt;"; <br />echo $test-&gt;MAJORVER."&lt;br&gt;"; <br />echo $test-&gt;MINORVER."&lt;br&gt;"; <br />?&gt; <br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202630.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:10 <a href="http://www.blogjava.net/huyi2006/articles/202630.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql连接类实现</title><link>http://www.blogjava.net/huyi2006/articles/202629.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:08:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202629.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202629.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202629.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202629.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202629.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">************************************<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    mysql连接类实现 -write by 三千<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> *************************************</span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">/*</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> 使用方法(可以执行一般mysql命令,insert, delete select  update)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> 在文件前,需要加载方法<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> require("mysql.class.php")<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db=new dbMysql; 加载类<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db-&gt;dbServer="localhost";<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db-&gt;dbUser="root";<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db-&gt;dbPwd="";<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db-&gt;dbDatabase="";<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> $db-&gt;dbConnect();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> query($sql,$database);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> query_first($sql,$database);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> fetch_array($sql,$database);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> count_records($table,$index,$where,$database);)//为得到一个表记录的数目，$table为表名，$index为key，$where为条件，$dbbase为数据库，后两个可以不选<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #008000">*/</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> db_Mysql<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$usepconnect</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbSever</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbDatabase</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbUser</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbPwd</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$dbLink</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 执行query命令的指针</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$num_rows</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 返回的条目数</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$insert_id</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 传回最后一次使用 INSERT 指令的 ID</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$affected_rows</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> 传回query命令所影响的列数目<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                  // INSERT、UPDATE 或 DELETE 所影响的列 (row) 数目。<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />                  // delete 如果不带where，那么则返回0</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbconnect(</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$usepconnect</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">global $usepconnect;</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$usepconnect</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_pconnect</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbServer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbUser</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbPwd);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">long connect</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_connect</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbServer</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbUser</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbPwd);</span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">short connect<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   //$this-&gt;dbhalt($this-&gt;dbbase);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink) </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbhalt(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">exsiting error when connecting!</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbbase</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbbase</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbDatabase;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_select_db</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbbase</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink))<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbhalt(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">can't use this database,please check database!</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  } </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> end func() connect database<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  //change database</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbchange_db(</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbconnect(</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">if($dbbase!="") $this-&gt;dbchange_db($dbbase);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_query</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">print($query_id);</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">query_id) </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbhalt(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">wrong sql sentence!</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">query_id;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbquery_first(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$returnarray</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_fetch_array</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">num_rows</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_num_rows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbfree_result(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$returnarray</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbhalt(</span>
				<span style="COLOR: #800080">$errmsg</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$msg</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />database is wrong!<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$msg</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$errmsg</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">echo</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">$msg</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">die</span>
				<span style="COLOR: #000000">();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbfetch_array(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$type</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">numrows</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_num_rows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">for</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">;</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">&lt;</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">numrows;</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">++</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$type</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #800080">$array</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_fetch_array</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />     </span>
				<span style="COLOR: #800080">$array</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #800080">$i</span>
				<span style="COLOR: #000000">]</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_fetch_array</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbfree_result(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$array</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbdelete(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbdase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">affected_rows</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_affected_rows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">free_reuslt(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbinsert(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">insert_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_insert_id</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">affected_rows</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_affected_rows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">free_reuslt(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbupdate(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbquery(</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">insert_id</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_insert_id</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">affected_rows</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #008080">mysql_affected_rows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">free_reuslt(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbcount_records(</span>
				<span style="COLOR: #800080">$table</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$index</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">id</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$where</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">!=</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">)</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbchangedb(</span>
				<span style="COLOR: #800080">$dbbase</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$result</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_query</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">select count(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$index</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">) as 'num' form</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$table</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">where</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$where</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">!</span>
				<span style="COLOR: #800080">$result</span>
				<span style="COLOR: #000000">) </span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbhalt(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">wrong sql sentence</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #800080">$sql</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #800080">$num</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_result</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">num</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$num</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbgetnum(</span>
				<span style="COLOR: #800080">$result</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #800080">$num</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">@</span>
				<span style="COLOR: #008080">mysql_numrows</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$result</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #0000ff">return</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$num</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbfree_result(</span>
				<span style="COLOR: #800080">$result_id</span>
				<span style="COLOR: #000000">){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   @</span>
				<span style="COLOR: #008080">mysql_free_result</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$query_id</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  </span>
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> dbclose(){<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />   </span>
				<span style="COLOR: #008080">mysql_close</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #800080">$this</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbLink);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />  }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> } </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000"> end class</span>
				<span style="COLOR: #008000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #800080">$db</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> db_Mysql;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #800080">$db</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbServer</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">localhost</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #800080">$db</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbUser</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">root</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #800080">$db</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbPwd</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">""</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /> </span>
				<span style="COLOR: #800080">$db</span>
				<span style="COLOR: #000000">-&gt;</span>
				<span style="COLOR: #000000">dbbase</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">test</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">; <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
				<span style="COLOR: #000000">?&gt;</span>
		</div>
		<p>/*************************************<br />    mysql连接类实现 -write by 三千<br /> **************************************/<br /> /*<br /> 使用方法(可以执行一般mysql命令,insert, delete select  update)<br /> 在文件前,需要加载方法<br /> require("mysql.class.php")<br /> $db=new dbMysql; 加载类<br /> $db-&gt;dbServer="localhost";<br /> $db-&gt;dbUser="root";<br /> $db-&gt;dbPwd="";<br /> $db-&gt;dbDatabase="";<br /> $db-&gt;dbConnect();</p>
		<p> query($sql,$database);<br /> query_first($sql,$database);<br /> fetch_array($sql,$database);<br /> count_records($table,$index,$where,$database);)//为得到一个表记录的数目，$table为表名，$index为key，$where为条件，$dbbase为数据库，后两个可以不选<br /> */</p>
		<p> class db_Mysql<br /> {<br />  <br />  var $usepconnect;<br />  var $dbSever;<br />  var $dbDatabase; <br />  var $dbbase;<br />  var $dbUser;<br />  var $dbPwd;<br />  var $dbLink;<br />  var $query_id;// 执行query命令的指针<br />  var $num_rows;// 返回的条目数<br />  var $insert_id;// 传回最后一次使用 INSERT 指令的 ID<br />  var $affected_rows;// 传回query命令所影响的列数目<br />                  // INSERT、UPDATE 或 DELETE 所影响的列 (row) 数目。<br />                  // delete 如果不带where，那么则返回0<br />  function dbconnect($dbbase,$usepconnect)<br />  {<br />   //global $usepconnect;<br />   if($usepconnect==1)<br />    $this-&gt;dbLink=@mysql_pconnect($this-&gt;dbServer,$this-&gt;dbUser,$this-&gt;dbPwd);//long connect<br />   else<br />    $this-&gt;dbLink=@mysql_connect($this-&gt;dbServer,$this-&gt;dbUser,$this-&gt;dbPwd);//short connect<br />   //$this-&gt;dbhalt($this-&gt;dbbase);<br />   if(!$this-&gt;dbLink) $this-&gt;dbhalt("exsiting error when connecting!");<br />   if($this-&gt;dbbase=="") $this-&gt;dbbase=$this-&gt;dbDatabase;<br />   if(<a href="mailto:!@mysql_select_db($this-&gt;dbbase,$this-&gt;dbLink">!@mysql_select_db($this-&gt;dbbase,$this-&gt;dbLink</a>))<br />    $this-&gt;dbhalt("can't use this database,please check database!");<br />  } // end func() connect database<br />  //change database<br />  function dbchange_db($dbbase){<br />   $this-&gt;dbconnect($dbbase);<br />  <br />  }<br />  function dbquery($sql){<br />   //if($dbbase!="") $this-&gt;dbchange_db($dbbase);<br />   $this-&gt;query_id=mysql_query($sql);<br />   //print($query_id);<br />   if(!$this-&gt;query_id) $this-&gt;dbhalt("wrong sql sentence!".$sql);<br />   return $this-&gt;query_id;<br />  }<br />  function dbquery_first($sql,$dbbase){<br />   $query_id=dbquery($sql,$dbbase);<br />   $returnarray=mysql_fetch_array($query_id);<br />   $this-&gt;num_rows=mysql_num_rows($query_id);<br />   $this-&gt;dbfree_result($query_id);<br />   return $returnarray;<br />  }<br />  function dbhalt($errmsg){<br />   $msg="</p>
		<p>database is wrong!</p>
		<p>";<br />   $msg=$errmsg;<br />   echo"$msg";<br />   die();<br />  }<br />  function dbfetch_array($sql,$dbbase,$type){<br />   $query_id=$this-&gt;dbquery($sql,$dbbase);<br />   $this-&gt;numrows=mysql_num_rows($query_id);<br />   for($i=0;$i&lt;$this-&gt;numrows;$i++){<br />    if($type==0)<br />     $array[$i]=mysql_fetch_array($query_id);<br />    else<br />     $array[$i]=mysql_fetch_array($query_id);<br />   }<br />   $this-&gt;dbfree_result($query_id);<br />   return $array;<br />  }<br />  function dbdelete($sql,$dbdase){<br />   $query_id=$this-&gt;dbquery($sql,$dbbase);<br />   $this-&gt;affected_rows=mysql_affected_rows($this-&gt;dbLink);<br />   $this-&gt;free_reuslt($query_id);<br />  }<br />  function dbinsert($sql,$dbbase){<br />   $query_id=$this-&gt;dbquery($sql,$dbbase);<br />   $this-&gt;insert_id=mysql_insert_id($this-&gt;dbLink);<br />   $this-&gt;affected_rows=mysql_affected_rows($this-&gt;dbLink);<br />   $this-&gt;free_reuslt($query_id);<br />  }<br />  function dbupdate($sql,$dbbase){<br />   $query_id=$this-&gt;dbquery($sql,$dbbase);<br />   $this-&gt;insert_id=mysql_insert_id($this-&gt;dbLink);<br />   $this-&gt;affected_rows=mysql_affected_rows($this-&gt;dbLink);<br />   $this-&gt;free_reuslt($query_id);<br />  }<br />  function dbcount_records($table,$index="id",$where="",$dbbase){<br />   if($dbbase!="")$this-&gt;dbchangedb($dbbase);<br />   <a href="mailto:$result=@mysql_query(&quot;select">$result=@mysql_query("select</a> count(".$index.") as 'num' form".$table."where".$where,$this-&gt;dbLink);<br />   if(!$result) $this-&gt;dbhalt("wrong sql sentence".$sql);<br />    <a href="mailto:$num=@mysql_result($result,0,&quot;num">$num=@mysql_result($result,0,"num</a>");<br />   return $num;<br />  }<br />  function dbgetnum($result){<br />   <a href="mailto:$num=@mysql_numrows($result">$num=@mysql_numrows($result</a>);<br />   return $num;<br />  }<br />  function dbfree_result($result_id){<br />   @mysql_free_result($query_id);<br />  }<br />  function dbclose(){<br />   mysql_close($this-&gt;dbLink);<br />  }<br /> } // end class<br /> $db=new db_Mysql;<br /> $db-&gt;dbServer="localhost";<br /> $db-&gt;dbUser="root";<br /> $db-&gt;dbPwd="";<br /> $db-&gt;dbbase="test"; </p>
		<p>
				<br />?&gt;</p>
		<p> </p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202629.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:08 <a href="http://www.blogjava.net/huyi2006/articles/202629.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图表类</title><link>http://www.blogjava.net/huyi2006/articles/202628.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:04:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202628.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202628.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202628.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202628.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202628.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: //				图形类-&gt;gd.class.php																								&lt;?				php				class				 GD{ 				/*				 函数说明 $data:y轴数据（数组） $graphdata:y轴数据--百分比（数组） $label:x轴数据（数组） $height:图像高度 $width:图像宽度 $...&nbsp;&nbsp;<a href='http://www.blogjava.net/huyi2006/articles/202628.html'>阅读全文</a><img src ="http://www.blogjava.net/huyi2006/aggbug/202628.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:04 <a href="http://www.blogjava.net/huyi2006/articles/202628.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个分页显示类</title><link>http://www.blogjava.net/huyi2006/articles/202626.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 12:00:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202626.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202626.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202626.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202626.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202626.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &lt;?				php				/*																 * 分页显示类 * PageItem.php　v 1.0.0 * 编程：Boban&lt;boban@21php.com&gt; * 讨论：http://www.21php.com/forums/ * 更新：2004-02-02 * 说明： * 1. 配合MYSQL数据库使用 * 2. 类没有提供连接数据库的...&nbsp;&nbsp;<a href='http://www.blogjava.net/huyi2006/articles/202626.html'>阅读全文</a><img src ="http://www.blogjava.net/huyi2006/aggbug/202626.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 20:00 <a href="http://www.blogjava.net/huyi2006/articles/202626.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>全正则的检测IP是否合法的函数</title><link>http://www.blogjava.net/huyi2006/articles/202625.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 24 May 2008 11:54:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/202625.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/202625.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/202625.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/202625.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/202625.html</trackback:ping><description><![CDATA[
		<p> </p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				<span style="COLOR: #0000ff">function</span>
				<span style="COLOR: #000000"> checkIP2(sIPAddress)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #008080">exp</span>
				<span style="COLOR: #000000">=/^</span>
				<span style="COLOR: #000000">(\d{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">}</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">\d\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">]\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">])\</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">(\d{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">}</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">\d\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">]\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />
				</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">])\</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">(\d{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">}</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">\d\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">]\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">])\</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">(\d{</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">,</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">}</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">\d\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">]\d</span>
				<span style="COLOR: #000000">|</span>
				<span style="COLOR: #000000">25</span>
				<span style="COLOR: #000000">[</span>
				<span style="COLOR: #000000">0</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">5</span>
				<span style="COLOR: #000000">])$</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> reg </span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000"> sIPAddress</span>
				<span style="COLOR: #000000">.</span>
				<span style="COLOR: #000000">match(</span>
				<span style="COLOR: #008080">exp</span>
				<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> ErrMsg</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">你输入的是一个非法的IP地址段！\nIP段为：:xxx.xxx.xxx.xxx（xxx<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />为0-255)！</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">var</span>
				<span style="COLOR: #000000"> Msg</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">你输入的是一个合法的IP地址段！</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">if</span>
				<span style="COLOR: #000000">(reg</span>
				<span style="COLOR: #000000">==</span>
				<span style="COLOR: #0000ff">null</span>
				<span style="COLOR: #000000">)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        alert(ErrMsg);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    </span>
				<span style="COLOR: #0000ff">else</span>
				<span style="COLOR: #000000">
						<br />
						<img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    {<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />        alert(reg);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />    }<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" />}<br /><img src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align="top" /></span>
		</div>
		<p>function checkIP2(sIPAddress)<br />{<br />    var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-</p>
		<p>5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;<br />    var reg = sIPAddress.match(exp);<br />    var ErrMsg="你输入的是一个非法的IP地址段！\nIP段为：:xxx.xxx.xxx.xxx（xxx</p>
		<p>为0-255)！"    <br />    var Msg="你输入的是一个合法的IP地址段！"    <br />    if(reg==null)<br />    {<br />        alert(ErrMsg);<br />    }<br />    else<br />    {<br />        alert(reg);<br />    }<br />}<br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/202625.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-05-24 19:54 <a href="http://www.blogjava.net/huyi2006/articles/202625.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库设计</title><link>http://www.blogjava.net/huyi2006/articles/189515.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sat, 29 Mar 2008 11:58:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/189515.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/189515.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/189515.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/189515.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/189515.html</trackback:ping><description><![CDATA[
		<a href="http://www.itisedu.com/phrase/200603011123415.html" target="_new">数据库设计</a>(<a href="http://www.itisedu.com/phrase/200604222040295.html" target="_new">Database Design</a>)是指对于一个给定的应用环境，构造最优的<a href="http://www.itisedu.com/phrase/200602271218062.html" target="_new">数据库</a><a href="http://www.itisedu.com/phrase/200603061709535.html" target="_new">模式</a>，建立数据库及其应用系统，使之能够有效地存储数据，满足各种用户的应用<a href="http://www.itisedu.com/phrase/200603101518295.html" target="_new">需求</a>（信息要求和处理要求）。
<p>　　在数据库领域内，常常把使用数据库的各<a href="http://www.itisedu.com/phrase/200603090857555.html" target="_new">类</a>系统统称为数据库应用系统。</p><p><strong>一、数据库和<a href="http://www.itisedu.com/phrase/200603011147495.html" target="_new">信息系统</a></strong><br />　　(1)数据库是信息系统的核心和基础，把信息系统中大量的数据按一定的模型组织起来，提供存储、维护、检索数据的<br />　   　功能，使信息系统可以方便、及时、准确地从数据库中获得所需的信息。<br />　　(2)数据库是信息系统的各个部分能否紧密地结合在一起以及如何结合的关键所在。<br />　　(3)数据库设计是信息系统开发和建设的重要组成部分。<br />　　(4)数据库设计人员应该具备的技术和知识：<br />　　　 　数据库的基本知识和数据库设计技术<br />　　　　 <a href="http://www.itisedu.com/phrase/200603021438435.html" target="_new">计算机</a>科学的基础知识和<a href="http://www.itisedu.com/phrase/200602281641255.html" target="_new">程序设计</a>的方法和技巧<br />　　　 　<a href="http://www.itisedu.com/phrase/200602281725525.html" target="_new">软件工程</a>的原理和方法<br />　　　　 应用领域的知识</p><p><strong>二、数据库设计的特点</strong><br />　　数据库建设是硬件、<a href="http://www.itisedu.com/phrase/200604232134205.html" target="_new">软件</a>和干件的结合<br />　　　三分技术，七分管理，十二分基础数据<br />　　　技术与管理的界面称之为“干件”<br />　　数据库设计应该与应用系统设计相结合<br />　　　结构（数据）设计：设计数据库<a href="http://www.itisedu.com/phrase/200603061723295.html" target="_new">框架</a>或数据库结构<br />　　　行为（处理）设计：设计应用<a href="http://www.itisedu.com/phrase/200604232224305.html" target="_new">程序</a>、事务处理等<br />　　结构和行为分离的设计<br />　　　传统的软件工程忽视对应用中数据语义的分析和抽象，只要有可能就尽量推迟数据结构设计的决策早期的数据库设计致力于数据模型和建模方法研究，忽视了对行为的设计<br />　　如图：<br /></p><p align="center"><img src="http://www.itisedu.com/manage/Upload/image/2006327171322129.jpg" border="0" /></p><p>　　　　　　   　 <br /><strong>三、数据库设计方法简述</strong><br />　　手工试凑法<br />　　　设计质量与设计人员的经验和水平有直接关系<br />　　　缺乏科学理论和工程方法的支持，工程的质量难以保证<br />　　　数据库运行一段时间后常常又不同程度地发现各种问题，增加了维护代价<br />　　规范设计法<br />　　　手工设计方<br />　　　基本思想<br />　　过程迭代和逐步求精<br />　　规范设计法(续)<br />　　典型方法：<br />　　(1)新奥尔良（New Orleans）方法：将数据库设计分为四个阶段<br />　　　　S.B.Yao方法：将数据库设计分为五个步骤<br />　　　　I.R.Palmer方法：把数据库设计当成一步接一步的过程<br />　　(2)计算机辅助设计<br />　　　　<a href="http://www.itisedu.com/phrase/200604040935115.html" target="_new">ORACLE</a> Designer 2000<br />　　　　<a href="http://www.itisedu.com/phrase/200604040934365.html" target="_new">SYBASE</a> PowerDesigner</p><p><strong>四、数据库设计的基本步骤</strong><br />　　数据库设计的过程(六个阶段) <br />　  1.<a href="http://www.itisedu.com/phrase/200603062220345.html" target="_new">需求分析</a>阶段<br />　　　准确了解与分析用户需求（包括数据与处理）<br />　　　是整个设计过程的基础，是最困难、最耗费时间的一步<br />　　2.概念结构设计阶段<br />　　　是整个数据库设计的关键<br />　　　通过对用户需求进行综合、归纳与抽象，形成一个独立于具体<a href="http://www.itisedu.com/phrase/200604221337185.html" target="_new">DBMS</a>的<a href="http://www.itisedu.com/phrase/200604181844195.html" target="_new">概念模型</a><br />　　3.逻辑结构设计阶段<br />　　　将概念结构转换为某个DBMS所支持的数据模型<br />　　　对其进行优化<br />　　4.数据库物理设计阶段<br />　　　为逻辑数据模型选取一个最适合应用环境的物理结构（包括存储结构和存取方法）<br />　　5.数据库实施阶段<br />　　　运用DBMS提供的数据语言、工具及宿主语言，根据逻辑设计和物理设计的结果<br />　　　建立数据库，编制与调试应用程序，组织数据入库，并进行试运行<br />　　6.数据库运行和维护阶段<br />　　　数据库应用系统经过试运行后即可投入正式运行。<br />　　　在<a href="http://www.itisedu.com/phrase/200603011056245.html" target="_new">数据库系统</a>运行过程中必须不断地对其进行评价、调整与修改<br />　　设计特点:<br />　　　在设计过程中把数据库的设计和对数据库中数据处理的设计紧密结合起来将这两个方面的需求分析、抽象、设计、实现在各个阶段同时进行，相互参照，相互补充，以完善两方面的设计</p><p>　　设计过程各个阶段的设计描述：<br />　　如图：<br />          </p><p align="center"><img src="http://www.itisedu.com/manage/Upload/image/2006327171351881.jpg" border="0" /></p><p><br /><strong>五、数据库各级模式的形成过程</strong><br />　　1.需求分析阶段：综合各个用户的应用需求<br />　　2.概念设计阶段：形成独立于机器特点，独立于各个DBMS产品的概念模式(E-R图)<br />　　3.逻辑设计阶段：首先将E-R图转换成具体的数据库产品支持的数据模型，如关系模型，形成数据库逻辑模式；然后根据用户处理的要求、安全性的考虑，在基本表的基础上再建立必要的<a href="http://www.itisedu.com/phrase/200603141659315.html" target="_new">视图</a>(View)，形成数据的外模式<br />　　4.物理设计阶段：根据DBMS特点和处理的需要，进行物理存储安排，建立索引，形成数据库内模式 </p><p><strong>六、数据库设计技巧</strong></p><p>　　<strong>1. 设计数据库之前（需求分析阶段）</strong><br />　　1) 理解客户需求，询问用户如何看待未来需求变化。让客户解释其需求，而且随着开发的继续，还要经常询问客户保证其需求仍然在开发的目的之中。<br />　　2) 了解企业业务可以在以后的开发阶段节约大量的时间。<br />　　3) 重视输入输出。<br />　　在定义数据库表和字段需求（输入）时，首先应检查现有的或者已经设计出的报表、查询和视图（输出）以决定为了支持这些输出哪些是必要的表和字段。<br />　　举例：假如客户需要一个报表按照邮政编码排序、分段和求和，你要保证其中包括了单独的邮政编码字段而不要把邮政编码糅进地址字段里。<br />　　4) 创建数据字典和ER 图表<br />　　ER 图表和数据字典可以让任何了解数据库的人都明确如何从数据库中获得数据。ER图对表明表之间关系很有用，而数据字典则说明了每个字段的用途以及任何可能存在的别名。对<a href="http://www.itisedu.com/phrase/200604022014515.html" target="_new">SQL</a> 表达式的文档化来说这是完全必要的。<br />　　5) 定义标准的<a href="http://www.itisedu.com/phrase/200603090845215.html" target="_new">对象</a>命名规范<br />　　数据库各种对象的命名必须规范。</p><p>　<strong>　2. 表和字段的设计（数据库逻辑设计）</strong><br />　　表设计原则<br />　　1) 标准化和规范化<br />　　数据的标准化有助于消除数据库中的数据冗余。标准化有好几种形式，但Third Normal Form（<a href="http://www.itisedu.com/phrase/200604172019525.html" target="_new">3NF</a>）通常被认为在性能、扩展性和数据完整性方面达到了最好平衡。简单来说，遵守3NF 标准的数据库的表设计原则是：“One Fact in One Place”即某个表只包括其本身基本的属性，当不是它们本身所具有的属性时需进行分解。表之间的关系通过外键相连接。它具有以下特点：有一组表专门存放通过键连接起来的关联数据。<br />　　举例：某个存放客户及其有关定单的3NF 数据库就可能有两个表：Customer 和Order。Order 表不包含定单关联客户的任何信息，但表内会存放一个键值，该键指向Customer 表里包含该客户信息的那一行。<br />　　事实上，为了效率的缘故，对表不进行标准化有时也是必要的。<br />　　2) 数据驱动<br />　　采用数据驱动而非硬编码的方式，许多策略变更和维护都会方便得多，大大增强系统的灵活性和扩展性。<br />　　举例，假如用户界面要访问外部数据源（<a href="http://www.itisedu.com/phrase/200602282323195.html" target="_new">文件</a>、<a href="http://www.itisedu.com/phrase/200604231236585.html" target="_new">XML</a> 文档、其他数据库等），不妨把相应的连接和路径信息存储在用户界面支持表里。还有，如果用户界面执行<a href="http://www.itisedu.com/phrase/200603110944215.html" target="_new">工作流</a>之类的任务（发送邮件、打印信笺、修改记录状态等），那么产生工作流的数据也可以存放在数据库里。角色权限管理也可以通过数据驱动来完成。事实上，如果过程是数据驱动的，你就可以把相当大的责任推给用户，由用户来维护自己的工作流过程。<br />　　3) 考虑各种变化<br />　　在设计数据库的时候考虑到哪些数据字段将来可能会发生变更。<br />　　举例，姓氏就是如此（注意是西方人的姓氏，比如女性结婚后从夫姓等）。所以，在建立系统存储客户信息时，在单独的一个数据表里存储姓氏字段，而且还附加起始日和终止日等字段，这样就可以跟踪这一数据条目的变化。</p><p><br />　　字段设计原则<br />　　4) 每个表中都应该添加的3 个有用的字段<br />dRecordCreationDate，在VB 下默认是Now()，而在<a href="http://www.itisedu.com/phrase/200604040933575.html" target="_new">SQL Server</a> 　　• 下默认为GETDATE()<br />sRecordCreator，在SQL Server 下默认为NOT NULL DEFAULT 　　• USER<br />nRecordVersion，记录的版本标记；有助于准确说明记录中出现null 数据或者丢失数据的原因 　　•<br />　　5) 对地址和电话采用多个字段<br />　　描述街道地址就短短一行记录是不够的。Address_Line1、Address_Line2 和Address_Line3 可以提供更大的灵活性。还有，电话号码和邮件地址最好拥有自己的数据表，其间具有自身的<a href="http://www.itisedu.com/phrase/200603051002565.html" target="_new">类型</a>和标记类别。<br />　　6) 使用角色实体定义属于某类别的列<br />　　在需要对属于特定类别或者具有特定角色的事物做定义时，可以用角色实体来创建特定的时间关联关系，从而可以实现自我文档化。<br />　　举例：用PERSON 实体和PERSON_<a href="http://www.itisedu.com/phrase/200604231258125.html" target="_new">TYPE</a> 实体来描述人员。比方说，当John Smith, Engineer 提升为John Smith, Director 乃至最后爬到John Smith, CIO 的高位，而所有你要做的不过是改变两个表PERSON 和PERSON_TYPE 之间关系的键值，同时增加一个日期/时间字段来知道变化是何时发生的。这样，你的PERSON_TYPE 表就包含了所有PERSON 的可能类型，比如Associate、Engineer、Director、CIO 或者CEO 等。还有个替代办法就是改变PERSON 记录来反映新头衔的变化，不过这样一来在时间上无法跟踪个人所处位置的具体时间。<br />　　7) 选择数字类型和文本类型尽量充足<br />　　在SQL 中使用smallint 和tinyint 类型要特别小心。比如，假如想看看月销售总额，总额字段类型是smallint，那么，如果总额超过了$32,767 就不能进行计算操作了。<br />　　而ID 类型的文本字段，比如客户ID 或定单号等等都应该设置得比一般想象更大。假设客户ID 为10 位数长。那你应该把数据库表字段的长度设为12 或者13 个字符长。但这额外占据的空间却无需将来<a href="http://www.itisedu.com/phrase/200603121222205.html" target="_new">重构</a>整个数据库就可以实现数据库规模的增长了。<br />　　8) 增加删除标记字段<br />　　在表中包含一个“删除标记”字段，这样就可以把行标记为删除。在关系数据库里不要单独删除某一行；最好采用清除数据程序而且要仔细维护索引整体性。 </p><p>　<strong>　3. 选择键和索引（数据库逻辑设计）</strong><br />　　键选择原则：<br />　　1) 键设计4 原则<br />为关联字段创建外键。 　　•<br />所有的键都必须唯一。 　　•<br />避免使用复合键。 　　•<br />外键总是关联唯一的键字段。 　　•<br />　　2) 使用系统生成的主键<br />　　设计数据库的时候采用系统生成的键作为主键，那么实际控制了数据库的索引完整性。这样，数据库和非人工机制就有效地控制了对存储数据中每一行的访问。采用系统生成键作为主键还有一个优点：当拥有一致的键结构时，找到逻辑缺陷很容易。<br />　　3) 不要用用户的键(不让主键具有可更新性)<br />　　在确定采用什么字段作为表的键的时候，可一定要小心用户将要编辑的字段。通常的情况下不要选择用户可编辑的字段作为键。<br />　　4) 可选键有时可做主键<br />　　把可选键进一步用做主键，可以拥有建立强大索引的能力。</p><p><br />　　索引使用原则：<br />　　索引是从数据库中获取数据的最高效方式之一。95%的数据库性能问题都可以采用索引技术得到解决。<br />　　1) 逻辑主键使用唯一的成组索引，对系统键（作为存储过程）采用唯一的非成组索引，对任何外键列采用非成组索引。考虑数据库的空间有多大，表如何进行访问，还有这些访问是否主要用作读写。<br />　　2) 大多数数据库都索引自动创建的主键字段，但是可别忘了索引外键，它们也是经常使用的键，比如运行查询显示主表和所有关联表的某条记录就用得上。<br />　　3) 不要索引memo/note 字段，不要索引大型字段（有很多字符），这样作会让索引占用太多的存储空间。<br />　　4) 不要索引常用的小型表<br />　　不要为小型数据表设置任何键，假如它们经常有插入和删除操作就更别这样作了。对这些插入和删除操作的索引维护可能比扫描表空间消耗更多的时间。</p><p><strong>　　4. 数据完整性设计（数据库逻辑设计）</strong><br />　　1) 完整性实现机制：<br />　　实体完整性：主键<br />　　参照完整性：<br />　　父表中删除数据：级联删除；受限删除；置空值<br />　　父表中插入数据：受限插入；递归插入<br />　　父表中更新数据：级联更新；受限更新；置空值<br />　　DBMS对参照完整性可以有两种方法实现：外键实现机制（约束规则）和触发器实现机制<br />　　用户定义完整性：<br />　　NOT NULL；CHECK；触发器<br />　　2) 用约束而非商务规则强制数据完整性<br />　　采用数据库系统实现数据的完整性。这不但包括通过标准化实现的完整性而且还包括数据的功能性。在写数据的时候还可以增加触发器来保证数据的正确性。不要依赖于商务层保证数据完整性；它不能保证表之间（外键）的完整性所以不能强加于其他完整性规则之上。<br />　　3) 强制指示完整性<br />　　在有害数据进入数据库之前将其剔除。激活数据库系统的指示完整性特性。这样可以保持数据的清洁而能迫使开发人员投入更多的时间处理错误条件。<br />　　4) 使用查找控制数据完整性<br />　　控制数据完整性的最佳方式就是限制用户的选择。只要有可能都应该提供给用户一个清晰的价值列表供其选择。这样将减少键入代码的错误和误解同时提供数据的一致性。某些公共数据特别适合查找：国家代码、状态代码等。<br />　　5) 采用视图<br />　　为了在数据库和应用程序代码之间提供另一层抽象，可以为应用程序建立专门的视图而不必非要应用程序直接访问数据表。这样做还等于在处理数据库变更时给你提供了更多的自由。</p><p><strong>　　5. 其他设计技巧</strong><br />　　1) 避免使用触发器<br />　　触发器的功能通常可以用其他方式实现。在调试程序时触发器可能成为干扰。假如你确实需要采用触发器，你最好集中对它文档化。<br />　　2) 使用常用英语（或者其他任何语言）而不要使用编码<br />　　在创建下拉菜单、列表、报表时最好按照英语名排序。假如需要编码，可以在编码旁附上用户知道的英语。<br />　　3) 保存常用信息<br />　　让一个表专门存放一般数据库信息非常有用。在这个表里存放数据库当前版本、最近检查/修复（对Access）、关联设计文档的名称、客户等信息。这样可以实现一种简单机制跟踪数据库，当客户抱怨他们的数据库没有达到希望的要求而与你联系时，这样做对非客户机/服务器环境特别有用。<br />　　4) 包含版本机制<br />　　在数据库中引入<a href="http://www.itisedu.com/phrase/200603292355295.html" target="_new">版本控制</a>机制来确定使用中的数据库的版本。时间一长，用户的需求总是会改变的。最终可能会要求修改数据库结构。把版本信息直接存放到数据库中更为方便。 <br />　　5) 编制文档<br />　　对所有的快捷方式、命名规范、限制和函数都要编制文档。<br />　　采用给表、列、触发器等加注释的数据库工具。对开发、支持和跟踪修改非常有用。<br />　　对数据库文档化，或者在数据库自身的内部或者单独建立文档。这样，当过了一年多时间后再回过头来做第2 个版本，犯错的机会将大大减少。<br />　　6) 测试、测试、反复测试<br />　　建立或者修订数据库之后，必须用用户新输入的数据测试数据字段。最重要的是，让用户进行测试并且同用户一道保证选择的数据类型满足商业要求。测试需要在把新数据库投入实际服务之前完成。<br />　　7) 检查设计<br />　　在开发期间检查数据库设计的常用技术是通过其所支持的应用程序原型检查数据库。换句话说，针对每一种最终表达数据的原型应用，保证你检查了数据模型并且查看如何取出数据。</p><p><br /></p><img src ="http://www.blogjava.net/huyi2006/aggbug/189515.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-03-29 19:58 <a href="http://www.blogjava.net/huyi2006/articles/189515.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>http状态码一览表  </title><link>http://www.blogjava.net/huyi2006/articles/188326.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Mon, 24 Mar 2008 11:06:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/188326.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/188326.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/188326.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/188326.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/188326.html</trackback:ping><description><![CDATA[这是我从网上收集的，这个博客上的一句经典话我也写下来吧<br /><p style="FONT-SIZE: 18pt">If you love someone, set him/her free.</p><p style="FONT-SIZE: 18pt">If he/she comes back to you,it's meant to be.<br /><br /></p><table style="TABLE-LAYOUT: fixed" cellspacing="0" cellpadding="0" width="99%" border="0"><tbody><tr><td><span style="FONT-WEIGHT: bold">http状态码一览表</span><p><span class="oblog_text" style="FONT-SIZE: 10pt"><a>pengyou 发表于 2008-1-21 11:58:00</a></span></p></td></tr><tr><td><span class="oblog_text" style="FONT-SIZE: 10pt"><span id="ob_logd2034369"><div class="digg_list" style="DISPLAY: inline; BACKGROUND: url(/Images/digg.gif) no-repeat left top; FLOAT: right; MARGIN: 0px 10px 5px 0px; WIDTH: 45px; HEIGHT: 55px; TEXT-ALIGN: center"><div class="digg_number" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: 600; FONT-SIZE: 18px; PADDING-BOTTOM: 11px; WIDTH: 45px; COLOR: #333; LINE-HEIGHT: 1; PADDING-TOP: 10px; FONT-FAMILY: tahoma,Arial,Helvetica,sans-serif">0</div><div class="digg_submit" style="PADDING-RIGHT: 0px; PADDING-LEFT: 6px; PADDING-BOTTOM: 0px; LINE-HEIGHT: 1; PADDING-TOP: 3px; LETTER-SPACING: 6px"><a style="FONT-SIZE: 12px; LINE-HEIGHT: 1" onclick="diggit(2034369);" href="javascript:void(null)"><font color="#002c99">推荐</font></a></div></div></span>http状态码一览表<br /><br />1**：请求收到，继续处理<br />2**：操作成功收到，分析、接受<br />3**：完成此请求必须进一步处理<br />4**：请求包含一个错误语法或不能完成<br />5**：服务器执行一个完全有效请求失败<br /><br />100——客户必须继续发出请求<br />101——客户要求服务器根据请求转换HTTP协议版本<br /><br />200——交易成功<br />201——提示知道新文件的URL<br />202——接受和处理、但处理未完成<br />203——返回信息不确定或不完整<br />204——请求收到，但返回信息为空<br />205——服务器完成了请求，用户代理必须复位当前已经浏览过的 
<div style="DIRECTION: ltr"><wbr>文件<br />206——服务器已经完成了部分用户的GET请求<br /><br />300——请求的资源可在多处得到<br />301——删除请求数据<br />302——在其他地址发现了请求数据<br />303——建议客户访问其他URL或访问方式<br />304——客户端已经执行了GET，但文件未变化<br />305——请求的资源必须从服务器指定的地址得到<br />306——前一版本HTTP中使用的代码，现行版本中不再使用<br />307——申明请求的资源临时性删除<br /><br />400——错误请求，如语法错误<br />401——请求授权失败<br />402——保留有效ChargeTo头响应<br />403——请求不允许<br />404——没有发现文件、查询或URl<br />405——用户在Request-Line字段定义的方法不允许<br />406——根据用户发送的Accept拖，请求资源不可访问<br />407——类似401，用户必须首先在代理服务器上得到授权<br />408——客户端没有在用户指定的饿时间内完成请求<br />409——对当前资源状态，请求不能完成<br />410——服务器上不再有此资源且无进一步的参考地址<br />411——服务器拒绝用户定义的Content-Length属<wbr>性请求<br />412——一个或多个请求头字段在当前请求中错误<br />413——请求的资源大于服务器允许的大小<br />414——请求的资源URL长于服务器允许的长度<br />415——请求资源不支持请求项目格式<br />416——请求中包含Range请求头字段，在当前请求资源范围<wbr>内没有range指示值，请求<br />也不包含If-Range请求头字段<br />417——服务器不满足请求Expect头字段指定的期望值<wbr>，如果是代理服务器，可能是下<br />一级服务器不能满足请求<br /><br />500——服务器产生内部错误<br />501——服务器不支持请求的函数<br />502——服务器暂时不可用，有时是为了防止发生系统过载<br />503——服务器过载或暂停维修<br />504——关口过载，服务器使用另一个关口或服务来响应用户<wbr>，等待时间设定值较长<br />505——服务器不支持或拒绝支请求头中指定的HTTP版本<br /><br />==============================<wbr>============================<br /><br />英文版：<br /><br />100：Continue<br />101：Switching Protocols<br />102：Processing<br /><br />200：OK<br />201：Created<br />202：Accepted<br />203：Non-Authoriative Information<br />204：No Content<br />205：Reset Content<br />206：Partial Content<br />207：Multi-Status<br /><br />300：Multiple Choices<br />301：Moved Permanently<br />302：Found<br />303：See Other<br />304：Not Modified<br />305：Use Proxy<br />306：(Unused)<br />307：Temporary Redirect<br /><br />400：Bad Request<br /><script><!--
D(["mb","401：Unauthorized\u003cbr /\u003e402：Payment Granted\u003cbr /\u003e403：Forbidden\u003cbr /\u003e404：File Not Found\u003cbr /\u003e405：Method Not Allowed\u003cbr /\u003e406：Not Acceptable\u003cbr /\u003e407：Proxy Authentication Required\u003cbr /\u003e408：Request Time-out\u003cbr /\u003e409：Conflict\u003cbr /\u003e410：Gone\u003cbr /\u003e411：Length Required\u003cbr /\u003e412：Precondition Failed\u003cbr /\u003e413：Request Entity Too Large\u003cbr /\u003e414：Request-URI Too Large\u003cbr /\u003e415：Unsupported Media Type\u003cbr /\u003e416：Requested range not satisfiable\u003cbr /\u003e417：Expectation Failed\u003cbr /\u003e422：Unprocessable Entity\u003cbr /\u003e423：Locked\u003cbr /\u003e424：Failed Dependency\u003cbr /\u003e\u003cbr /\u003e500：Internal Server Error\u003cbr /\u003e501：Not Implemented\u003cbr /\u003e502：Bad Gateway\u003cbr /\u003e503：Service Unavailable\u003cbr /\u003e504：Gateway Timeout\u003cbr /\u003e505：HTTP Version Not Supported\u003cbr /\u003e507：Insufficient Storage\u003cbr /\u003e\u003c/div\u003e",1]
);
D(["mb","\u003cdiv style\u003d\"direction:ltr\"\u003e\u003cspan class\u003dsg\u003e\u003cbr /\u003-\u003cbr /\u003e\u0026nbsp;[1;37m※ 来源:·瀚海星云 bbs.ustc.edu.cn·[FROM: \u003ca onclick\u003d\"return top.js.OpenExtLink(window,event,this)\" href\u003d\"http://60.166.127.65\" target\u003d_blank\u003e60.166.127.65\u003c/a\u003e] [m\u003cbr /\u003e\u003c/span\u003e\u003c/div\u003e",0]
);
D(["ce"]);

//--></script>
401：Unauthorized<br />402：Payment Granted<br />403：Forbidden<br />404：File Not Found<br />405：Method Not Allowed<br />406：Not Acceptable<br />407：Proxy Authentication Required<br />408：Request Time-out<br />409：Conflict<br />410：Gone<br />411：Length Required<br />412：Precondition Failed<br />413：Request Entity Too Large<br />414：Request-URI Too Large<br />415：Unsupported Media Type<br />416：Requested range not satisfiable<br />417：Expectation Failed<br />422：Unprocessable Entity<br />423：Locked<br />424：Failed Dependency<br /><br />500：Internal Server Error<br />501：Not Implemented<br />502：Bad Gateway<br />503：Service Unavailable<br />504：Gateway Timeout<br />505：HTTP Version Not Supported<br />507：Insufficient Storage</wbr></wbr></wbr></wbr></wbr></wbr></div></span></td></tr></tbody></table><img src ="http://www.blogjava.net/huyi2006/aggbug/188326.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-03-24 19:06 <a href="http://www.blogjava.net/huyi2006/articles/188326.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql 导入导出</title><link>http://www.blogjava.net/huyi2006/articles/188176.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Mon, 24 Mar 2008 03:20:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/188176.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/188176.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/188176.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/188176.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/188176.html</trackback:ping><description><![CDATA[　1.导出整个数据库
<p>　　mysqldump -u 用户名 -p 数据库名 &gt; 导出的文件名</p><p>　　mysqldump -u wcnc -p smgp_apps_wcnc &gt; wcnc.sql</p><p>　　2.导出一个表</p><p>　　mysqldump -u 用户名 -p 数据库名 表名&gt; 导出的文件名</p><p>　　mysqldump -u wcnc -p smgp_apps_wcnc users&gt; wcnc_users.sql</p><p>　　3.导出一个数据库结构</p><p>　　mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc &gt;d:wcnc_db.sql</p><p>　　-d 没有数据 --add-drop-table 在每个create语句之前增加一个drop table</p><p>　　4.导入数据库</p><p>　　常用source 命令</p><p>　　进入mysql数据库控制台，</p><p>　　如mysql -u root -p</p><p>　　mysql&gt;use 数据库</p><p>　　然后使用source命令，后面参数为脚本文件(如这里用到的.sql)</p><p>　　mysql&gt;source d:wcnc_db.sql</p><!--新闻内容//--><!--评论发布--><img src ="http://www.blogjava.net/huyi2006/aggbug/188176.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-03-24 11:20 <a href="http://www.blogjava.net/huyi2006/articles/188176.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>向mysql添加新用户并分配权限</title><link>http://www.blogjava.net/huyi2006/articles/188131.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Mon, 24 Mar 2008 01:15:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/188131.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/188131.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/188131.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/188131.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/188131.html</trackback:ping><description><![CDATA[mysql&gt;grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by ‘123′;<br />给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限，并设定口令为123。<br /><br />mysql&gt;grant all privileges on vtdc.* to joe@10.163.225.87 identified by ‘123′;<br />给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限，并设定口令为123。<br /><br />mysql&gt;grant all privileges on *.* to joe@10.163.225.87 identified by ‘123′;<br />给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限，并设定口令为123。<br /><br />mysql&gt;grant all privileges on *.* to joe@localhost identified by ‘123′;<br />给本机用户joe分配可对所有数据库的所有表进行所有操作的权限，并设定口令为123。<br /><br /><strong>修改密码<br /></strong>方法三 　　 
<p>　　mysql&gt; INSERT INTO mysql.user (Host,User,Password) VALUES </p><p>　　('%','system', PASSWORD('manager')); </p><p>　　mysql&gt; FLUSH PRIVILEGES 　　 </p><p>　　确切地说这是在增加一个用户，用户名为system，密码为manager。注意要使用PASSWORD函数，然后还要使用FLUSH </p><p>　　PRIVILEGES来执行确认。 　　 </p><p>　　方法四 　　 </p><p>　　和方法三一样，只是使用了REPLACE语句 </p><p>　　mysql&gt; REPLACE INTO mysql.user (Host,User,Password) </p><p>　　VALUES('%','system',PASSWORD('manager')); </p><p>　　mysql&gt; FLUSH PRIVILEGES 　 </p><p>　　方法五 　　 </p><p>　　使用SET PASSWORD语句 　　 </p><p>　　mysql&gt; SET PASSWORD FOR <a href="mailto:system@&quot;%"><font color="#3366cc">system@"%</font></a>" = PASSWORD('manager'); 　　 </p><p>　　你也必须使用PASSWORD()函数，但是不需要使用FLUSH PRIVILEGES来执行确认。 　　 </p><p>　　方法六 　　 </p><p>　　使用GRANT ... IDENTIFIED BY语句，来进行授权。 　　 </p><p>　　mysql&gt; GRANT USAGE ON *.* TO <a href="mailto:system@&quot;%"><font color="#3366cc">system@"%</font></a>" IDENTIFIED BY 'manager'; 　　 </p><p>　　这里PASSWORD()函数是不必要的，也不需要使用FLUSH PRIVILEGES来执行确认。 　　 </p><p>　　注：PASSWORD()函数作用是为口令字加密，在程序中MySql自动解释。</p><img src ="http://www.blogjava.net/huyi2006/aggbug/188131.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-03-24 09:15 <a href="http://www.blogjava.net/huyi2006/articles/188131.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>rh 9下卸载mysql3.23</title><link>http://www.blogjava.net/huyi2006/articles/188060.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sun, 23 Mar 2008 11:15:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/188060.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/188060.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/188060.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/188060.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/188060.html</trackback:ping><description><![CDATA[rh9 上mysql 3.23.54a-11.i386.rpm的卸载<br />1、rpm -qa|grep mysql<br />2、rpm -e --nodeps mysql-3.23.54a-11<br />3、rpm -e --nodeps mysql-server-3.23.54a-11<img src ="http://www.blogjava.net/huyi2006/aggbug/188060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2008-03-23 19:15 <a href="http://www.blogjava.net/huyi2006/articles/188060.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用Squid实现反向代理</title><link>http://www.blogjava.net/huyi2006/articles/169127.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Thu, 20 Dec 2007 10:45:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/169127.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/169127.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/169127.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/169127.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/169127.html</trackback:ping><description><![CDATA[
		<div class="content">
				<p class="MsoNormal">
						<b style="mso-bidi-font-weight: normal">
								<i style="mso-bidi-font-style: normal">
										<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">背景介绍</span>
								</i>
						</b>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">：<span lang="EN-US"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">代理服务器是使用非常普遍的一种将局域网主机联入互联网的一种方式，使用代理上网可以节约紧缺的<span lang="EN-US">IP</span>地址资源，而且可以阻断外部主机对内部主机的访问，使内部网主机免受外部网主机的攻击。但是，如果想让互联网上的主机访问内部网的主机资源（例如：<span lang="EN-US">Web</span>站点），又想使内部网主机免受外部网主机攻击，一般的代理服务是不能实现的，需要使用反向代理来实现。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">本文将详细介绍反向代理服务的概念以及如何利用反向代理服务器提高<span lang="EN-US">WEB</span>服务器的性能和安全性。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt">
						<b style="mso-bidi-font-weight: normal">
								<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">
										<span style="mso-list: Ignore">一．<span style="FONT: 7pt 'Times New Roman'">       </span></span>
								</span>
						</b>
						<b style="mso-bidi-font-weight: normal">
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">反向代理的概念 <span lang="EN-US"><o:p></o:p></span></span>
						</b>
				</p>
				<p class="MsoNormal">
						<b style="mso-bidi-font-weight: normal">
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
										<o:p> </o:p>
								</span>
						</b>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">什么是反向代理呢？其实，反向代理也就是通常所说的<span lang="EN-US">WEB</span>服务器加速，它是一种通过在繁忙的<span lang="EN-US">WEB</span>服务器和<span lang="EN-US">Internet</span>之间增加一个高速的<span lang="EN-US">WEB</span>缓冲服务器（即：<span lang="EN-US">WEB</span>反向代理服务器）来降低实际的<span lang="EN-US">WEB</span>服务器的负载。典型的结构如下图所示：<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /?>
								<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path=" m@4@5 l@4@11@9@11@9@5 xe" filled="f" stroked="f">
										<v:stroke joinstyle="miter">
										</v:stroke>
										<v:formulas>
												<v:f eqn="if lineDrawn pixelLineWidth 0 ">
												</v:f>
												<v:f eqn="sum @0 1 0 ">
												</v:f>
												<v:f eqn="sum 0 0 @1 ">
												</v:f>
												<v:f eqn="prod @2 1 2 ">
												</v:f>
												<v:f eqn="prod @3 21600 pixelWidth ">
												</v:f>
												<v:f eqn="prod @3 21600 pixelHeight ">
												</v:f>
												<v:f eqn="sum @0 0 1 ">
												</v:f>
												<v:f eqn="prod @6 1 2 ">
												</v:f>
												<v:f eqn="prod @7 21600 pixelWidth ">
												</v:f>
												<v:f eqn="sum @8 21600 0 ">
												</v:f>
												<v:f eqn="prod @7 21600 pixelHeight ">
												</v:f>
												<v:f eqn="sum @10 21600 0 ">
												</v:f>
										</v:formulas>
										<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect">
										</v:path>
										<o:lock v:ext="edit" aspectratio="t">
										</o:lock>
								</v:shapetype>
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<span style="mso-spacerun: yes">
										<img alt="" hspace="0" src="http://www.opendigest.org/showimg.php?iid=6" align="baseline" border="0" /> </span>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<span style="mso-spacerun: yes">
								</span>
						</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">Web</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">服务器加速（反向代理）是针对<span lang="EN-US">Web</span>服务器提供加速功能的。它作为代理<span lang="EN-US">Cache</span>，但并不针对浏览器用户，而针对一台或多台特定<span lang="EN-US">Web</span>服务器（这也是反向代理名称的由来）。实施反向代理（如上图所示），只要将<span lang="EN-US">Reverse Proxy Cache</span>设备放置在一台或多台<span lang="EN-US">Web</span>服务器前端即可。当互联网用户访问某个<span lang="EN-US">WEB</span>服务器时，通过<span lang="EN-US">DNS</span>服务器解析后的<span lang="EN-US">IP</span>地址是<span lang="EN-US">Reverse Proxy Server</span>的<span lang="EN-US">IP</span>地址<span lang="EN-US">,</span>而非原始<span lang="EN-US">Web</span>服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US">,</span>这时<span lang="EN-US">Reverse Proxy Server</span>设备充当<span lang="EN-US">Web</span>服务器，浏览器可以与它连接，无需再直接与<span lang="EN-US">Web</span>服务器相连。因此，大量<span lang="EN-US">Web</span>服务工作量被卸载到反向代理服务上。不但能够防止外部网主机直接和<span lang="EN-US">web</span>服务器直接通信带来的安全隐患，而且能够很大程度上减轻<span lang="EN-US">web</span>服务器的负担，提高访问速度。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -36pt; mso-list: l1 level1 lfo5; tab-stops: list 36.0pt">
						<b>
								<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体">
										<span style="mso-list: Ignore">二．<span style="FONT: 7pt 'Times New Roman'">       </span></span>
								</span>
						</b>
						<b>
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">反向代理和其它代理的比较<span lang="EN-US"><o:p></o:p></span></span>
						</b>
				</p>
				<p class="MsoNormal">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
										<o:p> </o:p>
								</span>
						</b>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-font-kerning: 0pt">下面将对几种典型的代理服务作一个简单的比较。</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">在网络上常见的代理服务器有三种：<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo4; tab-stops: list 39.0pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体">
								<span style="mso-list: Ignore">1．<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">标准的代理缓冲服务器<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">一个标准的代理缓冲服务被用于缓存静态的网页（例如：<span lang="EN-US">html</span>文件和图片文件等）到本地网络上的一台主机上（即代理服务器）。当被缓存的页面被第二次访问的时候，浏览器将直接从本地代理服务器那里获取请求数据而不再向原<span lang="EN-US">web</span>站点请求数据。这样就节省了宝贵的网络带宽，而且提高了访问速度。但是，要想实现这种方式，必须在每一个内部主机的浏览器上明确指明代理服务器的<span lang="EN-US">IP</span>地址和端口号。客户端上网时，每次都把请求送给代理服务器处理，代理服务器根据请求确定是否连接到远程<span lang="EN-US">web</span>服务器获取数据。如果在本地缓冲区有目标文件，则直接将文件传给用户即可。如果没有的话则先取回文件，先在本地保存一份缓冲，然后将文件发给客户端浏览器。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo4; tab-stops: list 39.0pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体">
								<span style="mso-list: Ignore">2．<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">透明代理缓冲服务器<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">透明代理缓冲服务和标准代理服务器的功能完全相同。但是，代理操作对客户端的浏览器是透明的（即不需指明代理服务器的<span lang="EN-US">IP</span>和端口）。透明代理服务器阻断网络通信，并且过滤出访问外部的<span lang="EN-US">HTTP</span>（<span lang="EN-US">80</span>端口）流量。如果客户端的请求在本地有缓冲则将缓冲的数据直接发给用户，如果在本地没有缓冲则向远程<span lang="EN-US">web</span>服务器发出请求，其余操作和标准的代理服务器完全相同。对于<span lang="EN-US">Linux</span>操作系统来说，透明代理使用<span lang="EN-US">Iptables</span>或者<span lang="EN-US">Ipchains</span>实现。因为不需要对浏览器作任何设置，所以，透明代理对于<span lang="EN-US">ISP</span>（<span lang="EN-US">Internet</span>服务器提供商）特别有用。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt; mso-list: l4 level1 lfo4; tab-stops: list 39.0pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体">
								<span style="mso-list: Ignore">3．<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">反向代理缓冲服务器<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="MARGIN-LEFT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-spacerun: yes">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">反向代理是和前两种代理完全不同的一种代理服务。使用它可以降低原始<span lang="EN-US">WEB</span>服务器的负载。反向代理服务器承担了对原始<span lang="EN-US">WEB</span>服务器的静态页面的请求，防止原始服务器过载。它位于本地<span lang="EN-US">WEB</span>服务器和<span lang="EN-US">Internet</span>之间，处理所有对<span lang="EN-US">WEB</span>服务器的请求，组织了<span lang="EN-US">WEB</span>服务器和<span lang="EN-US">Internet</span>的直接通信。如果互联网用户请求的页面在代理服务器上有缓冲的话，代理服务器直接将缓冲内容发送给用户。如果没有缓冲则先向<span lang="EN-US">WEB</span>服务器发出请求，取回数据，本地缓存后再发送给用户。这种方式通过降低了向<span lang="EN-US">WEB</span>服务器的请求数从而降低了<span lang="EN-US">WEB</span>服务器的负载。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<b>
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">三．反向代理工作原理<span lang="EN-US"><o:p></o:p></span></span>
						</b>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">反向代理服务器位于本地<span lang="EN-US">WEB</span>服务器和<span lang="EN-US">Internet</span>之间<span lang="EN-US">,</span>如下图所示：</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
						</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p>
						<span style="FONT-SIZE: 10.5pt; mso-bidi-font-family: Arial">
								<img alt="" hspace="0" src="http://www.opendigest.org/showimg.php?iid=82" align="baseline" border="0" />
						</span>
				</p>
				<p>
						<span style="FONT-SIZE: 10.5pt; mso-bidi-font-family: Arial">当用户浏览器发出一个<span lang="EN-US">HTTP</span>请求时，通过域名解析将请求定向到反向代理服务器（如果要实现多个<span lang="EN-US">WEB</span>服务器的反向代理，需要将多个<span lang="EN-US">WEB</span>服务器的域名都指向反向代理服务器）。由反向代理服务器处理器请求。反向代理一般只缓存可缓冲的数据（比如<span lang="EN-US">html</span>网页和图片等），而一些<span lang="EN-US">CGI</span>脚本程序或者<span lang="EN-US">ASP</span>之类的程序不缓存。它根据从<span lang="EN-US">WEB</span>服务器返回的<span lang="EN-US">HTTP</span>头标记来缓冲静态页面。有四个最重要<span lang="EN-US">HTTP</span>头标记：<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<ul type="disc">
						<li class="MsoNormal" style="TEXT-ALIGN: left; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">Last-Modified: </span>
								<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">告诉反向代理页面什么时间被修改</span>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</li>
						<li class="MsoNormal" style="TEXT-ALIGN: left; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">Expires: </span>
								<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">告诉反向代理页面什么时间应该从缓冲区中删除</span>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</li>
						<li class="MsoNormal" style="TEXT-ALIGN: left; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">Cache-Control: </span>
								<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">告诉反向代理页面是否应该被缓冲</span>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</li>
						<li class="MsoNormal" style="TEXT-ALIGN: left; mso-list: l2 level1 lfo3; tab-stops: list 36.0pt; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">Pragma: </span>
								<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">告诉反向代理页面是否应该被缓冲<span lang="EN-US">.</span></span>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</li>
				</ul>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">例如：在默认情况下，<span lang="EN-US">ASP</span>页面返回<span lang="EN-US">” Cache-control: private.” </span>，所以<span lang="EN-US">ASP</span>页面时不会在反向代理服务器缓存的<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<b style="mso-bidi-font-weight: normal">
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">四．</span>
						</b>
						<b>
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">代理服务器软件<span lang="EN-US">squid</span>简介</span>
						</b>
						<b style="mso-bidi-font-weight: normal">
								<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
										<o:p>
										</o:p>
								</span>
						</b>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">Squid Internet Object Cache (Harvest Project</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">的后续版本<span lang="EN-US">) </span>是美国政府大力助的一项研究计划，其目的为解决网络带宽不足的问题，是现在<span lang="EN-US">Unix</span>系统上使用者最多功能也最完整的一套软体。<span lang="EN-US">Apache</span>和<span lang="EN-US">Netscape</span>虽附有相关的<span lang="EN-US">Proxy</span>模块，但因其功能简单而不够普及。有关<span lang="EN-US">squid</span>的详细说明可到<span lang="EN-US">squid</span>网站<span lang="EN-US">(http://www.squid-cache.org)</span>查询。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-INDENT: 21pt">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">Squid</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">最典型的应用是代理局域网的机器联入互联网，它支持现在流行的网络协议。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">Squid</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">的另一项非常出色的功能就是实现反向代理功能。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<b>
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">五．使用<span lang="EN-US">Squid</span>配置反向代理（<span lang="EN-US">HTTP </span>加速器）<span lang="EN-US"><o:p></o:p></span></span>
						</b>
				</p>
				<p>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-SIZE: 10.5pt">通过<span lang="EN-US">squid</span>配置反向代理主要就是配置“<span lang="EN-US">squid.conf</span>”这个配置文件。下面以<span lang="EN-US">Linux</span>操作系统为例进行介绍，其它版本的在<span lang="EN-US">UNIX</span>也同样适用。在<span lang="EN-US">Linux</span>中<span lang="EN-US">squid</span>如果是以源代码方式安装的话，这个文件一般在“<span lang="EN-US">/usr/local/squid/etc/</span>”目录下。如果是系统自带的<span lang="EN-US">squid</span>，一般配置文件在“<span lang="EN-US">/etc/squid/</span>”目录下。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p style="MARGIN-LEFT: 39pt; TEXT-INDENT: -18pt; mso-list: l1 level2 lfo5; tab-stops: list 39.0pt">
						<span lang="EN-US" style="FONT-SIZE: 10.5pt">
								<span style="mso-list: Ignore">1．<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt">Squid</span>
						<span style="FONT-SIZE: 10.5pt">反向代理单个后台<span lang="EN-US">WEB</span>服务器<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p style="MARGIN-LEFT: 21pt">
						<span style="FONT-SIZE: 10.5pt">如果<span lang="EN-US">WEB</span>服务器和反向代理服务器是两台单独的机器（一般的反向代理应该有两块网卡分别连接了内外部网络）。那么，应该修改下面的内容来设置反向代理服务。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; BACKGROUND: #d9d9d9; mso-bidi-font-family: 'Courier New'; mso-shading: white; mso-pattern: gray-15 auto">http_port 80 # squid</span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span style="FONT-SIZE: 10.5pt; BACKGROUND: #d9d9d9; mso-bidi-font-family: 'Courier New'; mso-shading: white; mso-pattern: gray-15 auto">监听的端口<span lang="EN-US"><br />httpd_accel_host 172.16.250.250 # </span>内部<span lang="EN-US">WEB</span>服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US"><br />httpd_accel_port 80 # WEB</span>服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US"><br />httpd_accel_single_host on # </span>转发为缓冲的请求到一台单独的机器<span lang="EN-US"><br />httpd_accel_with_proxy on #<br />httpd_accel_uses_host_header off</span></span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; BACKGROUND: #d9d9d9; mso-shading: white; mso-pattern: gray-15 auto">
								</span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; BACKGROUND: #d9d9d9; mso-bidi-font-family: 'Courier New'; mso-shading: white; mso-pattern: gray-15 auto">
										<o:p>
										</o:p>
								</span>
						</i>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">如果<span lang="EN-US">WEB</span>服务器和反向代理服务器是同一台机器。那么，应该设置<span lang="EN-US">WEB</span>服务器的监听端口为非<span lang="EN-US">80</span>端口（比如：<span lang="EN-US">81</span>端口）。要修改的内容如下：</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 'Courier New'; mso-shading: white; mso-pattern: gray-15 auto">http_port 80 # squid</span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 'Courier New'; mso-shading: white; mso-pattern: gray-15 auto">监听的端口<span lang="EN-US"><br />httpd_accel_host localhost # </span>内部<span lang="EN-US">WEB</span>服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US"><br />httpd_accel_port 81 # WEB</span>服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US"><br />httpd_accel_single_host on # </span>转发为缓冲的请求到一台单独的机器<span lang="EN-US"><br />httpd_accel_with_proxy on #<br />httpd_accel_uses_host_header off</span></span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 'Courier New'; mso-font-kerning: 0pt; mso-shading: white; mso-pattern: gray-15 auto">
										<o:p>
										</o:p>
								</span>
						</i>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">下面解释一下配置指令。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">http_port 80</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">选项<span lang="EN-US"> http_port </span>指定<span lang="EN-US">squid</span>监听<span lang="EN-US">HTTP</span>请求的端口，一般都设置成<span lang="EN-US">80</span>端口，这样使用户感觉不到反向代理的存在，就像访问真正的<span lang="EN-US">WEB</span>服务器一样。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan" align="left">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_host 172.16.250.250</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">和 </span>
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_port 80</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">选项<span lang="EN-US">httpd_accel_host </span>和<span lang="EN-US"> httpd_accel_port </span>指定<span lang="EN-US">WEB</span>服务器的<span lang="EN-US">IP</span>地址和端口号，可以根据自己的<span lang="EN-US">WEB</span>服务器的实际情况而定。</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<span lang="EN-US">
										<o:p>
										</o:p>
								</span>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_single_host on</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">选项</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_single_host </span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">为<span lang="EN-US">on </span>时，<span lang="EN-US">squid</span>被设置成仅对单一的<span lang="EN-US">web</span>服务器作反向代理。不考虑<span lang="EN-US">HTTP</span>头信息，<span lang="EN-US">Squid</span>转发所有的未被缓冲的页面请求到这个<span lang="EN-US">web</span>服务器。如果<span lang="EN-US">squid</span>需要做多个<span lang="EN-US">web</span>服务器反向代理，必须将此选项设置为<span lang="EN-US">off</span>，并且使用转向器或者<span lang="EN-US">DNS</span>去映射请求到合适的后台<span lang="EN-US">WEB</span>服务器。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_with_proxy on</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">如果希望<span lang="EN-US">squid</span>既作反向代理服务器又作本地机器的上网代理，需要将<span lang="EN-US" style="mso-bidi-font-weight: bold">httpd_accel_with_proxy</span><span lang="EN-US"></span></span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">改为 </span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">on</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">，默认情况下是<span lang="EN-US">off</span></span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">httpd_accel_uses_host_header off</span>
						</b>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">在<span lang="EN-US">HTTP</span>协议<span lang="EN-US">1.1</span>中，<span lang="EN-US">HTTP</span>请求包括一个主机头信息，指定<span lang="EN-US">URL</span>的主机名或者主机的<span lang="EN-US">IP</span>地址。这个选项可以用来完成多个后台<span lang="EN-US">WEB</span>服务器的反向代理功能。</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
						</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">2</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">．</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">Squid</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">反向代理多个后台</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">WEB</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我们可以用</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">Squid</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">反向代理多个后台</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">WEB</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器。例如：我们可以配置</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">squid</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">同时反向代理</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">www.abc.com, www.xyz.com, www.lmn.com</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">三个后台</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial">WEB</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">服务器，示意图如下：</span>
						<b>
								<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
										<o:p>
										</o:p>
								</span>
						</b>
				</p>
				<p>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt; mso-bidi-font-weight: bold">
								<span style="mso-tab-count: 1">    <img alt="" hspace="0" src="http://www.opendigest.org/showimg.php?iid=83" align="baseline" border="0" /></span>
						</span>
						<span lang="EN-US" style="mso-bidi-font-size: 10.5pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p>
						<span lang="EN-US" style="FONT-SIZE: 10.5pt">Squid</span>
						<span style="FONT-SIZE: 10.5pt">的配置如下：<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-shading: white; mso-pattern: gray-15 auto">httpd_accel_host virtual<br />httpd_accel_port 80 <br />httpd_accel_single_host off <br />httpd_accel_uses_host_header on</span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-shading: white; mso-pattern: gray-15 auto">
										<o:p>
										</o:p>
								</span>
						</i>
				</p>
				<p>
						<i style="mso-bidi-font-style: normal">
								<span style="FONT-SIZE: 10.5pt; BACKGROUND: #d9d9d9; mso-bidi-font-family: Arial; mso-shading: white; mso-pattern: gray-15 auto">（注意<span lang="EN-US">:</span>编译<span lang="EN-US">Squid</span>时需激活<span lang="EN-US">Internal DNS</span>选项）<span lang="EN-US"><o:p></o:p></span></span>
						</i>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">然后设置设置反响代理需要的域名解析（<span lang="EN-US">Internet</span>用户通过这里解析三个网站的域名）如下：</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt; mso-shading: white; mso-pattern: gray-15 auto">www.abc.com 202.102.240.74<br />www.xyz.com 202.102.240.74<br />www.lmn.com 202.102.240.74</span>
						</i>
						<i style="mso-bidi-font-style: normal">
								<span lang="EN-US" style="BACKGROUND: #d9d9d9; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt; mso-shading: white; mso-pattern: gray-15 auto">
										<o:p>
										</o:p>
								</span>
						</i>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">使三个域名都指向反向代理服务器的<span lang="EN-US">IP</span>地址<span lang="EN-US">202.102.240.74</span>。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">下面设置反向代理所需要的<span lang="EN-US">DNS</span>入口信息（即设置内部<span lang="EN-US">DNS</span>，仅仅是<span lang="EN-US">squid</span>在内部使用，<span lang="EN-US">Internet</span>用户不可见）。有两种方法可以设置内部<span lang="EN-US">DNS</span>，使用内部<span lang="EN-US">DNS</span>服务器来解析或者使用<span lang="EN-US">/etc/hosts</span>文件来实现。<span lang="EN-US"><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">使用内部<span lang="EN-US">DNS</span>服务器的资源记录如下：</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">
								<br />
								<i style="mso-bidi-font-style: normal">
										<span style="BACKGROUND: #d9d9d9; mso-shading: white; mso-pattern: gray-15 auto">www.abc.com IN A 172.16.1.2<br />www.xyz.com IN A 172.16.1.3<br />www.lmn.com IN A 172.16.1.4</span>
								</i>
								<o:p>
								</o:p>
						</span>
				</p>
				<p class="MsoNormal" style="TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" align="left">
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: Arial; mso-font-kerning: 0pt">如果使用<span lang="EN-US">/etc/hosts</span>文件来实现内部<span lang="EN-US">DNS</span>（编译时应使用<span lang="EN-US">disable internal dns</span>选项）<span lang="EN-US">,</span>编辑<span lang="EN-US">/etc/hosts</span>文件添加如下条目： <span lang="EN-US"><br /><i style="mso-bidi-font-style: normal"><span style="BACKGROUND: #d9d9d9; mso-shading: white; mso-pattern: gray-15 auto">172.16.1.2 www.abc.com<br />172.16.1.3 www.xyz.com<br />172.16.1.4 www.lmn.com</span></i><o:p></o:p></span></span>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-style: italic; mso-bidi-font-size: 10.5pt">
								<o:p> </o:p>
						</span>
				</p>
				<p class="MsoNormal">
						<b>
								<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-bidi-font-style: italic">结论<span lang="EN-US"><o:p></o:p></span></span>
						</b>
				</p>
				<p class="MsoNormal">
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-style: italic; mso-bidi-font-size: 10.5pt">
								<span style="mso-tab-count: 1">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-bidi-font-weight: bold; mso-bidi-font-style: italic; mso-bidi-font-size: 10.5pt">通过本文中的论述和相关实例，可以看出，反向代理方式不单是一种<span lang="EN-US">WEB</span>服务器加速器，而且使也一种对外提供<span lang="EN-US">Web</span>发布时使用的有效的防火墙技术，使用它不但能节约紧缺的<span lang="EN-US">IP</span>地址资源，加速<span lang="EN-US">WEB</span>服务器的访问速度，而且能够保护<span lang="EN-US">WEB</span>主机，因此能够适应多种应用场合。</span>
						<span lang="EN-US" style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt">
								<o:p>
								</o:p>
						</span>
				</p>
		</div>
<img src ="http://www.blogjava.net/huyi2006/aggbug/169127.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2007-12-20 18:45 <a href="http://www.blogjava.net/huyi2006/articles/169127.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>利用ajax实现无刷新更新数据</title><link>http://www.blogjava.net/huyi2006/articles/103116.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sun, 11 Mar 2007 08:58:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/103116.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/103116.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/103116.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/103116.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/103116.html</trackback:ping><description><![CDATA[
		<p>利用ajax实现无刷新更新数据</p>
		<p>show.html //客户端</p>
		<p>&lt;script language="JavaScript"&gt; <br />function GetResult() { <br />   http_request = false;<br />  //开始初始化XMLHttpRequest对象<br />  if(window.XMLHttpRequest) { //Mozilla 浏览器<br />   http_request = new XMLHttpRequest();<br />   if (http_request.overrideMimeType) {//设置MiME类别<br />    http_request.overrideMimeType('text/xml');<br />   }<br />  }<br />  else if (window.ActiveXObject) { // IE浏览器<br />   try {<br />    http_request = new ActiveXObject("Msxml2.XMLHTTP");<br />   } catch (e) {<br />    try {<br />     http_request = new ActiveXObject("Microsoft.XMLHTTP");<br />    } catch (e) {}<br />   }<br />  }<br />  if (!http_request) { // 异常，创建对象实例失败<br />   window.alert("不能创建XMLHttpRequest对象实例.");<br />   return false;<br />  }</p>
		<p>
				<br />http_request.open("POST","rand.php",false); <br />http_request.send(); <br />var strResult = http_request.responseText; </p>
		<p> RemoveRow(); //删除以前的数据. </p>
		<p> num1 = strResult; //字段num1的值 </p>
		<p> row1 = tb.insertRow(); <br /> cell1 = row1.insertCell(); <br /> cell1.innerText = num1; <br /> <br />} </p>
		<p>
				<br />function RemoveRow() { <br />    //保留第一行表头,其余数据均删除. <br />   var iRows = tb.rows.length; <br />   for(var i=0;i&lt;iRows-1;i++) { <br />      tb.deleteRow(1); <br />   } <br />} </p>
		<p>function MyShow() { <br />    //2秒自动刷新一次,2秒取得一次数据. <br />   timer = window.setInterval("GetResult()",2000); <br />} <br />&lt;/script&gt; </p>
		<p>&lt;body onload="MyShow()"&gt; <br />&lt;p&gt; <br />&lt;/p&gt; <br />&lt;table width="47%" height="23"border="0" cellpadding="1" cellspacing="0" id="tb"&gt; <br />&lt;tr&gt; <br />&lt;td&gt;num1&lt;/td&gt; </p>
		<p>&lt;/tr&gt; <br />&lt;/table&gt; </p>
		<p>get.php //服务端</p>
		<p>&lt;?</p>
		<p>echo rand();</p>
		<p>?&gt;<br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/103116.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2007-03-11 16:58 <a href="http://www.blogjava.net/huyi2006/articles/103116.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Apache下配置PHP5</title><link>http://www.blogjava.net/huyi2006/articles/87340.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Tue, 12 Dec 2006 12:32:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/87340.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/87340.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/87340.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/87340.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/87340.html</trackback:ping><description><![CDATA[
		<p>一 安装程序<br />1 Apache的程序安装相对来说要较为的简单一些,我们从网站下来的是一个Windows下的安装程序,我们可以直接双击运行,这样我们就便利Apache在我们的电脑上安下家来了.<br />2 我们在这里要注意的就是在下载PHP时一定要下载那个zip包的,而不要下载Installer的.将我们下载下来的PHP包解压到C盘下的根目录下,并将解压出来的文件夹改名为php.</p>
		<p>二 配置<br />1 最好是无论使用何种接口（CGI 或者 SAPI）都确保 php5ts.dll 可用，因此必须将此文件放到 Windows 路径中。最好的位置是 Windows 的 system 目录</p>
		<p>c:\windows\system for Windows 9x/ME  <br />c:\winnt\system32 for Windows NT/2000 或者 c:\winnt40\system32 for Windows NT/2000 服务器版  <br />c:\windows\system32 for Windows XP  </p>
		<p>2 下一步是设定有效的 PHP 配置文件，php.ini。压缩包中包括两个 ini 文件，php.ini-dist 和 php.ini-recommended。建议使用 php.ini-recommended，因为此文件对默认设置作了性能和安全上的优化。<br />将选择的 ini 文件拷贝到 PHP 能够找到的目录下并改名为 php.ini。PHP 默认在 Windows 目录下搜索 php.ini</p>
		<p>3 在 Windows 9x/ME/XP 下将选择的 ini 文件拷贝到 %WINDIR%，通常为 c:\windows。</p>
		<p>4 Apache中PHP的设置<br />有两种方法使得 PHP 工作在 Windows 下的 Apache。一是使用 CGI 二进制文件，另一是使用 Apache 模块 DLL。无论那种方法，您首先必须停止 Apache 服务器，然后编辑 httpd.conf，以配置 Apache 和 PHP 协同工作。</p>
		<p>如果我们要使用CGI二进制文件,那么我们要将如下指令插入到 Apache 的 httpd.conf 配置文件中，以设置 CGI 二进制文件：<br /> <br />PHP 以 CGI 方式安装到 Apache 2.0:</p>
		<p>ScriptAlias /php/ "c:/php/"<br />AddType application/x-httpd-php .php<br />Action application/x-httpd-php "/php/php.exe"</p>
		<p>如果我们想把 PHP 作为 Apache 2.0 的模块，那么就一定要移动 php4ts.dll 到 winnt/system32（Windows NT/2000）或 windows/system32（Windows XP），覆盖原有文件（如果有的话），对于 PHP 5，这个文件是 php5ts.dll。然后我们要插入如下两行到 httpd.conf 中，以使我们的 PHP 作为 Apache 的 PHP-Module 安装：</p>
		<p>PHP 以模块方式安装到 Apache 2.0:</p>
		<p>; For PHP 4 do something like this:<br />LoadModule php4_module "c:/php/php4apache2.dll"<br />AddType application/x-httpd-php .php</p>
		<p>; For PHP 5 do something like this:<br />LoadModule php5_module "c:/php/php5apache2.dll"<br />AddType application/x-httpd-php .php</p>
		<p>经过这样的配置以后,我们就安装好了我们的PHP和Apache服务器了.我们可以简单的测试一下:<br />1 测试Apache:<br />我们打开浏览器,在地址栏中输入localhost,如果可以出现Apache页面,则说明我们的Apache可以正常工作了.<br />2测试PHP设置:<br />我们可以简单的编写一个PHP页面,我们可以用文本编辑器,输入下面的代码:<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;<br />hello<br />&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;?php echo "hello,php"; ?&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br />然后将这个文件存为hello.php,将其放在Apache的htdocs目录中(我们也可以在http.conf文件中来更改这个目录的),然后在我们的浏览器中输入<a href="http://localhost/hello.php">http://localhost/hello.php</a>,如果能够正确的显示hello,php就说明我们的PHP配置是可以正常工作的.<br />这样以后我们也可以来设计我们的PHP站点了.<br /><br />mysql扩展<br />搜索extension_dir = ./ 这行，并将其路径指到你的PHP目录下的extensions目录，比如： <br />　　extension_dir = C:\php\extensions <br /><br />　　如若想支持更多模块，，搜索： <br />;Windows Extensions <br />;Note that MySQL and ODBC support is now built in, so no dll is needed for it. <br />; <br />下面都用分号在前面注释掉了支持的扩展模块，如果你想PHP支持某个模块，请将前面的“;”去掉即可 <br />修改完成后,保存php.ini，到此完成PHP的安装和配置。 <br />我们在下面加入一行 <br />extension=php_mysql.dll <br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/87340.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2006-12-12 20:32 <a href="http://www.blogjava.net/huyi2006/articles/87340.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学习AJAX笔记之二——中文乱码的解决</title><link>http://www.blogjava.net/huyi2006/articles/86154.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Thu, 07 Dec 2006 11:45:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/86154.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/86154.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/86154.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/86154.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/86154.html</trackback:ping><description><![CDATA[
		<p>AJAX的乱码的出现在的原因<br />由于XMLHTTP采用的是Unicode编码上传数据，而一般页面采用的是gb2312,这就造成显示页面时产生乱码。而当在获取页面时的XMLHttp返回的是utf-8编码，这就造成了显示产生乱码。<br />解决方法之一就是在PHP文件中显示声明为GB2312</p>
		<p>
				<strong>
						<font color="#ff0000">header("Content-Type:text/html;charset=GB2312");</font>
				</strong>
		</p>
		<p>而对于发送到服务器的中文进行转码。<br />如下<br /><strong><font color="#ff0000">$_POST["content"]=iconv("UTF-8","gb2312",$_POST["content"]);</font></strong><br />因而这样可以解决乱码问题</p>
		<p>方法二，是都采用UTF-8编码。这里就不多说了</p>
		<p>附测试例程<br />客户端<br /></p>
		<p>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312"&gt;<br />&lt;title&gt;ajax post test&lt;/title&gt; <br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;div id="msg"&gt;&lt;/div&gt;<br />&lt;script language="javascript"&gt;<br />/**<br />* 初始化一个xmlhttp对象<br />*/<br />function InitAjax()<br />{<br />　var ajax=false; <br />　try { <br />　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); <br />　} catch (e) { <br />　　try { <br />　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); <br />　　} catch (E) { <br />　　　ajax = false; <br />　　} <br />　}<br />　if (!ajax &amp;&amp; typeof XMLHttpRequest!='undefined') { <br />　　ajax = new XMLHttpRequest(); <br />　} <br />　return ajax;<br />}<br />//在form 测试页面内有一个表单，一个显示的层<br />function sendData()<br />{<br /> var msg=document.getElementById("msg");<br /> var f=document.form1;<br /> var c=f.content.value;<br /> //接收数据的URL<br /> var url="dispmsg.php";<br /> var poststr="content="+c;<br /> var ajax=InitAjax();<br /> ajax.open("POST",url,true);<br /> ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<br /> ajax.send(poststr);<br /> ajax.onreadystatechange=function(){<br />  if(ajax.readyState==4 &amp;&amp; ajax.status==200){<br />  alert("I got something");<br />   msg.innerHTML=ajax.responseText;<br />  }<br /> }<br />}</p>
		<p>&lt;/script&gt;</p>
		<p>&lt;form name='form1'&gt;<br />&lt;input type="text" name='content' size=10&gt;<br />&lt;input type="button" value="确定" onclick="sendData()"&gt;&lt;!--我用submit时就出错--&gt;<br />&lt;/form&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;<br /></p>
		<p>
				<br /> </p>
		<p>服务器端<br />&lt;?php<br />header("Content-Type:text/html;charset=GB2312");<br />if($_POST['content'])<br />{<br /> $_POST["content"]=iconv("UTF-8","gb2312",$_POST["content"]);<br /> print("内容是".$_POST['content']);<br />}<br />else<br />{<br /> print("没有内容发送");<br />}<br />?&gt;</p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/86154.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2006-12-07 19:45 <a href="http://www.blogjava.net/huyi2006/articles/86154.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>数据库设计技巧14则</title><link>http://www.blogjava.net/huyi2006/articles/83888.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Mon, 27 Nov 2006 14:06:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/83888.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/83888.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/83888.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/83888.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/83888.html</trackback:ping><description><![CDATA[
		<font size="4">
				<font face="Arial">1. </font>
		</font>
		<font size="3">
				<font face="Garamond">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">原始单据与实体之间的关系 </span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<font face="Garamond" color="#0000cc" size="3">  </font>
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　可以是一对一、一对多、多对多的关系。在一般情况下，它们是一对一的关系：即一张原始单据对应且只对应一个实体。在特殊情况下，它们可能是一对多或多对一的关系，即一张原始单证对应多个实体，或多张原始单证对应一个实体。这里的实体可以理解为基本表。明确这种对应关系后，对我们设计录入界面大有好处。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　〖例</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">〗：一份员工履历资料，在人力资源信息系统中，就对应三个基本表：员工基本情况表、社会关系表、工作简历表。这就是“一张原始单证对应多个实体”的典型例子。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
				<font face="Garamond" color="#0000cc" size="3">2.  </font>
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">主键与外键 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　一般而言，一个实体不能既无主键又无外键。在</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E?R </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图中</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">处于叶子部位的实体</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">可以定义主键，也可以不定义主键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">因为它无子孙</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">), </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">但必须要有外键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">因为它有父亲</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　主键与外键的设计，在全局数据库的设计中，占有重要地位。当全局数据库的设计完成以后，有个美国数据库设计专家说：“键，到处都是键，除了键之外，什么也没有”，这就是他的数据库设计经验之谈，也反映了他对信息系统核心</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">数据模型</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的高度抽象思想。因为：主键是实体的高度抽象，主键与外键的配对，表示实体之间的连接。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
				<font face="Garamond" color="#0000cc" size="3"> 3.  </font>
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">基本表的性质 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　基本表与中间表、临时表不同，因为它具有如下四个特性： </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (1) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">原子性。基本表中的字段是不可再分解的。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (2) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">原始性。基本表中的记录是原始数据（基础数据）的记录。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (3) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">演绎性。由基本表与代码表中的数据，可以派生出所有的输出数据。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (4) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">稳定性。基本表的结构是相对稳定的，表中的记录是要长期保存的。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　理解基本表的性质后，在设计数据库时，就能将基本表与中间表、临时表区分开来。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
				<font face="Garamond" color="#0000cc" size="3">4.  </font>
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">范式标准 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　基本表及其字段之间的关系</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">应尽量满足第三范式。但是，满足第三范式的数据库设计，往往不是最好的设计。为了提高数据库的运行效率，常常需要降低范式标准：适当增加冗余，达到以空间换时间的目的。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　〖例</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">2</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">〗：有一张存放商品的基本表，如表</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">所示。“金额”这个字段的存在，表明该表的设计不满足第三范式，因为“金额”可以由“单价”乘以“数量”得到，说明“金额”是冗余字段。但是，增加“金额”这个冗余字段，可以提高查询统计的速度，这就是以空间换时间的作法。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　在</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Rose 2002</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">中，规定列有两种类型：数据列和计算列。“金额”这样的列被称为“计算列”，而“单价”和“数量”这样的列被称为“数据列”。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　表</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1 </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">商品表的表结构</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　商品名称</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">商品型号</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">单价</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">数量</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">金额</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　电视机 </font>
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 29? 2,500 40 100,000<br /></span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
						</font>
				</font>
		</font>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> <br /></span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 5. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">通俗地理解三个范式</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　通俗地理解三个范式，对于数据库设计大有好处。在数据库设计中，为了更好地应用三个范式，就必须通俗地理解三个范式</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">通俗地理解是够用的理解，并不是最科学最准确的理解</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">：</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　第一范式：</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1NF</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是对属性的原子性约束，要求属性具有原子性，不可再分解；</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　第二范式：</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">2NF</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是对记录的惟一性约束，要求记录有惟一标识，即实体的惟一性；</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　第三范式：</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">3NF</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是对字段冗余性的约束，即任何字段不能由其他字段派生出来，它要求字段没有冗余。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　没有冗余的数据库设计可以做到。但是，没有冗余的数据库未必是最好的数据库，有时为了提高运行效率，就必须降低范式标准，适当保留冗余数据。具体做法是：在概念数据模型设计时遵守第三范式，降低范式标准的工作放到物理数据模型设计时考虑。降低范式就是增加字段，允许冗余。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 6. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">要善于识别与正确处理多对多的关系</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　若两个实体之间存在多对多的关系，则应消除这种关系。消除的办法是，在两者之间增加第三个实体。这样，原来一个多对多的关系，现在变为两个一对多的关系。要将原来两个实体的属性合理地分配到三个实体中去。这里的第三个实体，实质上是一个较复杂的关系，它对应一张基本表。一般来讲，数据库设计工具不能识别多对多的关系，但能处理多对多的关系。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　〖例</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">3</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">〗：在“图书馆信息系统”中，“图书”是一个实体，“读者”也是一个实体。这两个实体之间的关系，是一个典型的多对多关系：一本图书在不同时间可以被多个读者借阅，一个读者又可以借多本图书。为此，要在二者之间增加第三个实体，该实体取名为“借还书”，它的属性为：借还时间、借还标志</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(0</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">表示借书，</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">表示还书</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">，另外，它还应该有两个外键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">“图书”的主键，“读者”的主键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">，使它能与“图书”和“读者”连接。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 7. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">主键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">PK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的取值方法</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> PK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是供程序员使用的表间连接工具，可以是一无物理意义的数字串</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">由程序自动加</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">1</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">来实现。也可以是有物理意义的字段名或字段名的组合。不过前者比后者好。当</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">PK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是字段名的组合时，建议字段的个数不要太多，多了不但索引占用空间大，而且速度也慢。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 8. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">正确认识数据冗余</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　主键与外键在多表中的重复出现</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">不属于数据冗余，这个概念必须清楚，事实上有许多人还不清楚。非键字段的重复出现</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">才是数据冗余！而且是一种低级冗余，即重复性的冗余。高级冗余不是字段的重复出现，而是字段的派生出现。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　〖例</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">4</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">〗：商品中的“单价、数量、金额”三个字段，“金额”就是由“单价”乘以“数量”派生出来的，它就是冗余，而且是一种高级冗余。冗余的目的是为了提高处理速度。只有低级冗余才会增加数据的不一致性，因为同一数据，可能从不同时间、地点、角色上多次录入。因此，我们提倡高级冗余</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">派生性冗余</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">，反对低级冗余</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">重复性冗余</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 9. E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图没有标准答案</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　信息系统的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图没有标准答案，因为它的设计与画法不是惟一的，只要它覆盖了系统需求的业务范围和功能内容，就是可行的。反之要修改</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图。尽管它没有惟一的标准答案，并不意味着可以随意设计。好的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E?R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图的标准是：结构清晰、关联简洁、实体个数适中、属性分配合理、没有低级冗余。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 10. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">视图技术在数据库设计中很有用</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　与基本表、代码表、中间表不同，视图是一种虚表，它依赖数据源的实表而存在。视图是供程序员使用数据库的一个窗口，是基表数据综合的一种形式</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">是数据处理的一种方法，是用户数据保密的一种手段。为了进行复杂处理、提高运算速度和节省存储空间</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">视图的定义深度一般不得超过三层。</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">若三层视图仍不够用</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">则应在视图上定义临时表</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">在临时表上再定义视图。这样反复交迭定义</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">视图的深度就不受限制了。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　对于某些与国家政治、经济、技术、军事和安全利益有关的信息系统，视图的作用更加重要。这些系统的基本表完成物理设计之后，立即在基本表上建立第一层视图，这层视图的个数和结构，与基本表的个数和结构是完全相同。并且规定，所有的程序员，一律只准在视图上操作。只有数据库管理员，带着多个人员共同掌握的“安全钥匙”，才能直接在基本表上操作。请读者想想：这是为什么？ </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 11. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">中间表、报表和临时表</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　中间表是存放统计数据的表，它是为数据仓库、输出报表或查询结果而设计的，有时它没有主键与外键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">数据仓库除外</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">。临时表是程序员个人设计的，存放临时记录，为个人所用。基表和中间表由</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">DBA</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">维护，临时表由程序员自己用程序自动维护。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 12. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">完整性约束表现在三个方面</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　域的完整性：用</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Check</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">来实现约束，在数据库设计工具中，对字段的取值范围进行定义时，有一个</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Check</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">按钮，通过它定义字段的值城。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　参照完整性：用</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">PK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">、</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">FK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">、表级触发器来实现。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　用户定义完整性：它是一些业务规则，用存储过程和触发器来实现。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 13. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">防止数据库设计打补丁的方法是“三少原则”</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (1) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">一个数据库中表的个数越少越好。只有表的个数少了，才能说明系统的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图少而精，去掉了重复的多余的实体，形成了对客观世界的高度抽象，进行了系统的数据集成，防止了打补丁式的设计；</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (2) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">一个表中组合主键的字段个数越少越好。因为主键的作用，一是建主键索引，二是做为子表的外键，所以组合主键的字段个数少了，不仅节省了运行时间，而且节省了索引存储空间；</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (3) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">一个表中的字段个数越少越好。只有字段的个数少了，才能说明在系统中不存在数据重复，且很少有数据冗余，更重要的是督促读者学会“列变行”，这样就防止了将子表中的字段拉入到主表中去，在主表中留下许多空余的字段。所谓“列变行”，就是将主表中的一部分内容拉出去，另外单独建一个子表。这个方法很简单，有的人就是不习惯、不采纳、不执行。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　数据库设计的实用原则是：在数据冗余和处理速度之间找到合适的平衡点。“三少”是一个整体概念，综合观点，不能孤立某一个原则。该原则是相对的，不是绝对的。“三多”原则肯定是错误的。试想：若覆盖系统同样的功能，一百个实体</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">共一千个属性</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图，肯定比二百个实体</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">共二千个属性</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E--R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图，要好得多。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　提倡“三少”原则，是叫读者学会利用数据库设计技术进行系统的数据集成。数据集成的步骤是将文件系统集成为应用数据库，将应用数据库集成为主题数据库，将主题数据库集成为全局综合数据库。集成的程度越高，数据共享性就越强，信息孤岛现象就越少，整个企业信息系统的全局</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">E?R</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">图中实体的个数、主键的个数、属性的个数就会越少。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　提倡“三少”原则的目的，是防止读者利用打补丁技术，不断地对数据库进行增删改，使企业数据库变成了随意设计数据库表的“垃圾堆”，或数据库表的“大杂院”，最后造成数据库中的基本表、代码表、中间表、临时表杂乱无章，不计其数，导致企事业单位的信息系统无法维护而瘫痪。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">“三多”原则任何人都可以做到，该原则是“打补丁方法”设计数据库的歪理学说。“三少”原则是少而精的原则，它要求有较高的数据库设计技巧与艺术，不是任何人都能做到的，因为该原则是杜绝用“打补丁方法”设计数据库的理论依据。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> 14. </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">提高数据库运行效率的办法</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　在给定的系统硬件和系统软件条件下，提高数据库系统的运行效率的办法是： </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (1) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">在数据库物理设计时，降低范式，增加冗余</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">少用触发器</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">, </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">多用存储过程。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (2) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">当计算非常复杂、而且记录条数非常巨大时</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">(</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">例如一千万条</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">)</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">，复杂计算要先在数据库外面，以文件系统方式用</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">C++</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">语言计算处理完成之后，最后才入库追加到表中去。这是电信计费系统设计的经验。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (3) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">发现某个表的记录太多，例如超过一千万条，则要对该表进行水平分割。水平分割的做法是，以该表主键</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">PK</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的某个值为界线，将该表的记录水平分割为两个表。若发现某个表的字段太多，例如超过八十个，则垂直分割该表，将原来的一个表分解为两个表。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (4) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">对数据库管理系统</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">DBMS</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">进行系统优化，即优化各种系统参数，如缓冲区个数。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<font face="Garamond">
				<font size="3">
						<font color="#0000cc">
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">　　</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> (5) </span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">在使用面向数据的</span>
								<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">SQL</span>
								<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">语言进行程序设计时，尽量采取优化算法。</span>
						</font>
				</font>
		</font>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　总之，要提高数据库的运行效率，必须从数据库系统级优化、数据库设计级优化、程序实现级优化，这三个层次上同时下功夫。 </font>
		</span>
		<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
				<br />
				<br />
		</span>
		<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">
				<font face="Garamond" color="#0000cc" size="3">　　上述十四个技巧，是许多人在大量的数据库分析与设计实践中，逐步总结出来的。对于这些经验的</font>
		</span>
<img src ="http://www.blogjava.net/huyi2006/aggbug/83888.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2006-11-27 22:06 <a href="http://www.blogjava.net/huyi2006/articles/83888.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>PHP生成静态网页的方法</title><link>http://www.blogjava.net/huyi2006/articles/83674.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Sun, 26 Nov 2006 14:17:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/83674.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/83674.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/83674.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/83674.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/83674.html</trackback:ping><description><![CDATA[
		<p>
				<font color="#000099">　一，PHP脚本与动态页面。<br />　　PHP脚本是一种服务器端脚本程序，可通过嵌入等方法与HTML文件混合，也可以类，函数封装等形式，以模板的方式对用户请求进行处理。无论以何种方式，它的基本原理是这样的。由客户端提出请求，请求某一页面　-----&gt;　WEB服务器引入指定相应脚本进行处理　-----&gt;　脚本被载入服务器　-----&gt;　由服务器指定的PHP解析器对脚本进行解析形成HTML语言形式　----&gt;　将解析后的HTML语句以包的方式传回给浏览器。由此不难看出，在页面发送到浏览器后，PHP就不存在了，已被转化解析为HTML语句。客户请求为一动态文件，事实上并没有真正的文件存在在那里，是PHP解析而成相对应的页面，然后发送回浏览器。这种页面处理方式被称为“动态页面”。<br />　　二，静态页面。<br />　　静态页面是指在服务器端确实存在的仅含HTML以及JS，CSS等客户端运行脚本的页面。它的处理方式是。由客户端提出请求，请求某一页面　----&gt;　WEB服务器确认并载入某一页面　----&gt;　WEB服务器将该页面以包的形式传递回浏览器。由这一过程，我们对比一下动态页面，即可方现。动态页面需由WEB服务器的PHP解析器进行解析，而且通常还需连接数据库，进行数据库存取操作，然后才能形成HTML语言信息包；而静态页面，无须解析，无须连接数据库，直接发送，可大大减轻服务器压力，提高服务器负载能力，大幅提供页面打开速度和网站整体打开速度。但其缺点是，不能动态地对请求进行处理，服务器上必须确实存在该文件。<br />　　三，模板及模板解析。<br />　　模板即尚未填充内容html文件。例如：<br />　temp.html <br />&lt;HTML&gt;<br /> &lt;TITLE&gt;{ title }&lt;/TITLE&gt;<br /> &lt;BODY&gt;<br /> this is a { file } file's templets<br /> &lt;/BODY&gt;<br />&lt;/HTML&gt;<br />PHP处理：<br />　templetest.php <br />&lt;?php<br /> $title = "</font>
				<a href="http://siyizhu.com/">
						<font color="#000099">http://siyizhu.com/</font>
				</a>
				<font color="#000099">测试模板";<br /> $file = "TwoMax Inter test templet,&lt;br&gt;author：</font>
				<a href="mailto:Matrix@Two_Max">
						<font color="#000099">Matrix@Two_Max</font>
				</a>
				<font color="#000099">";</font>
		</p>
		<p>
				<font color="#000099">　$fp = fopen ("temp.html","r");<br /> $content = fread ($fp,filesize ("temp.html"));<br /> $content .= str_replace ("{ file }",$file,$content);<br /> $content .= str_replace ("{ title }",$title,$content);</font>
		</p>
		<p>
				<font color="#000099"> echo $content;<br />?&gt; <br />模板解析处理，即将经PHP脚本解析处理后得出的结果填充(content)进模板的处理过程。通常借助于模板类。目前较流行的模板解析类有phplib，smarty，fastsmarty等等。模板解析处理的原理通常为替换。也有些程序员习惯将判断，循环等处理放进模板文件中，用解析类处理，典型应用为block概念，简单来说即为一个循环处理。由PHP脚本指定循环次数，如何循环代入等，再由模板解析类具体实施这些操作。<br />　　好了，对比过静态页面与动态页面各自的优劣，现在我们就来说说，如何用PHP生成静态文件。<br />　　PHP生成静态页面并不是指PHP的动态解析，输出HTML页面，而是指用PHP创建HTML页面。同时因为HTML的不可写性，我们创建的HTML若有修改，则需删掉重新生成即可。(当然你也可以选择用正则进行修改，但个人认为那样做倒不如删掉重新生成来得快捷，有些得不偿失。)<br />　　言归正传。用过PHP文件操作函数的PHP FANS知道，PHP中有一个文件操作函数fopen，即打开文件。若文件不存在，则尝试创建。这即是PHP可以用来创建HTML文件的理论基础。只要用来存放HTML文件的文件夹有写权限(即权限定义0777)，即可创建文件。（针对UNIX系统而言，Win系统无须考虑。）仍以上例为例，若我们修改最后一句，并指定在test目录下生成一个名为test.html的静态文件： <br />&lt;?php<br /> $title = "</font>
				<a href="http://siyizhu.com/">
						<font color="#000099">http://siyizhu.com/</font>
				</a>
				<font color="#000099">测试模板";<br /> $file = "TwoMax Inter test templet,&lt;br&gt;author：</font>
				<a href="mailto:Matrix@Two_Max">
						<font color="#000099">Matrix@Two_Max</font>
				</a>
				<font color="#000099">";<br />　$fp = fopen ("temp.html","r");<br /> $content = fread ($fp,filesize ("temp.html"));<br /> $content .= str_replace ("{file}",$file,$content);<br /> $content .= str_replace ("{title}",$title,$content);<br /> // echo $content; <br /> $filename = "test/test.html";<br /> $handle = fopen ($filename,"w"); //打开文件指针，创建文件<br /> /*<br />　检查文件是否被创建且可写<br /> */<br /> if (!is_writable ($filename)){<br /> die ("文件：".$filename."不可写，请检查其属性后重试！");<br /> }<br /> if (!fwrite ($handle,$content)){ //将信息写入文件<br /> die ("生成文件".$filename."失败！");<br /> } <br /> fclose ($handle); //关闭指针<br /> <br /> die ("创建文件".$filename."成功！");<br />?&gt;</font>
		</p>
		<p>
				<font color="#000099">实际应用中常见问题解决方案参考：<br />　　一，文章列表问题：　　<br />　　在数据库中创建字段，记录文件名，每生成一个文件，将自动生成的文件名存入数据库，对于推荐文章，只需指向存放静态文件的指定文件夹中的该页面即可。利用PHP操作处理文章列表，存为字符串，生成页面时替换此字符串即可。如，在页面中放置文章列表的表格加入标记{articletable}，而在PHP处理文件中： <br />&lt;?php<br /> $title = "</font>
				<a href="http://siyizhu.com/">
						<font color="#000099">http://siyizhu.com/</font>
				</a>
				<font color="#000099">测试模板";<br /> $file = "TwoMax Inter test templet,&lt;br&gt;author：</font>
				<a href="mailto:Matrix@Two_Max">
						<font color="#000099">Matrix@Two_Max</font>
				</a>
				<font color="#000099">";<br /> $fp = fopen ("temp.html","r");<br /> $content = fread ($fp,filesize ("temp.html"));<br /> $content .= str_replace ("{file}",$file,$content);<br /> $content .= str_replace ("{title}",$title,$content); <br /> // 生成列表开始<br /> $list = '';<br /> $sql = "select id,title,filename from article";<br /> $query = mysql_query ($sql);<br /> while ($result = mysql_fetch_array ($query)){<br /> $list .= '&lt;a href='.$root.$result['filename'].' target=_blank&gt;'.$result['title'].'&lt;/a&gt;&lt;br&gt;';<br /> }<br /> $content .= str_replace ("{articletable}",$list,$content); <br /> //生成列表结束<br /> // echo $content; <br /> $filename = "test/test.html";<br /> $handle = fopen ($filename,"w"); //打开文件指针，创建文件<br /> /*<br />　检查文件是否被创建且可写<br /> */<br /> if (!is_writable ($filename)){<br /> die ("文件：".$filename."不可写，请检查其属性后重试！");<br /> }<br /> if (!fwrite ($handle,$content)){ //将信息写入文件<br /> die ("生成文件".$filename."失败！");<br /> } <br /> fclose ($handle); //关闭指针 <br /> die ("创建文件".$filename."成功！");<br />?&gt;<br />二，分页问题。<br />　　如我们指定分页时，每页20篇。某子频道列表内文章经数据库查询为45条，则，首先我们通过查询得到如下参数：1，总页数；2，每页篇数。第二步，for ($i = 0; $i &lt; allpages; $i++)，页面元素获取，分析，文章生成，都在此循环中执行。不同的是，die ("创建文件".$filename."成功！";这句去掉，放到循环后的显示，因为该语句将中止程序执行。例： <br />&lt;?php<br /> $fp = fopen ("temp.html","r");<br /> $content = fread ($fp,filesize ("temp.html"));<br /> $onepage = '20';<br /> $sql = "select id from article where channel='$channelid'";<br /> $query = mysql_query ($sql);<br /> $num = mysql_num_rows ($query);<br /> $allpages = ceil ($num / $onepage);<br /> for ($i = 0;$i&lt;$allpages; $i++){<br /> if ($i == 0){<br /> $indexpath = "index.html";<br /> } else {<br /> $indexpath = "index_".$i."html";<br /> }<br /> $start = $i * $onepage;<br /> $list = '';<br /> $sql_for_page = "select name,filename,title from article where channel='$channelid' limit $start,$onepage";<br /> $query_for_page = mysql_query ($sql_for_page);<br /> while ($result = $query_for_page){<br /> $list .= '&lt;a href='.$root.$result['filename'].' target=_blank&gt;'.$title.'&lt;/a&gt;&lt;br&gt;';<br /> }<br /> $content = str_replace ("{articletable}",$list,$content);<br /> if (is_file ($indexpath)){<br /> @unlink ($indexpath); //若文件已存在，则删除<br /> }<br /> $handle = fopen ($indexpath,"w"); //打开文件指针，创建文件<br /> /*<br />　 检查文件是否被创建且可写<br /> */<br /> if (!is_writable ($indexpath)){<br /> echo "文件：".$indexpath."不可写，请检查其属性后重试！"; //修改为echo<br /> }<br /> if (!fwrite ($handle,$content)){ //将信息写入文件<br /> echo "生成文件".$indexpath."失败！"; //修改为echo<br /> } <br /> fclose ($handle); //关闭指针<br /> }<br /> fclose ($fp);<br /> die ("生成分页文件完成，如生成不完全，请检查文件权限系统后重新生成！");<br />?&gt;<br />大致思路如此，其中如其它数据生成，数据输入输出检查，分页内容指向等可酌情在页面中加入。<br />　　在实际文章系统处理过程当中，还有许多问题有待考虑，与动态页面不同之处，需注意的地方还有很多。但大致思路即是如此，其它方面可举一反三而得。<br /><br />文章转载于：<a href="http://www.tsingfeng.com/trackback.asp?tbID=249" target="_blank"><span id="myt">http://www.tsingfeng.com/trackback.asp?tbID=249</span></a></font>
		</p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/83674.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2006-11-26 22:17 <a href="http://www.blogjava.net/huyi2006/articles/83674.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX学习之1</title><link>http://www.blogjava.net/huyi2006/articles/83217.html</link><dc:creator>allic</dc:creator><author>allic</author><pubDate>Fri, 24 Nov 2006 04:38:00 GMT</pubDate><guid>http://www.blogjava.net/huyi2006/articles/83217.html</guid><wfw:comment>http://www.blogjava.net/huyi2006/comments/83217.html</wfw:comment><comments>http://www.blogjava.net/huyi2006/articles/83217.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/huyi2006/comments/commentRss/83217.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/huyi2006/services/trackbacks/83217.html</trackback:ping><description><![CDATA[
		<p>AJAX学习 </p>
		<p>从天极网上看了一些关于AJAX的内容之后，就想试试看。小试牛刀，写了一个小程序</p>
		<p>
				<font style="BACKGROUND-COLOR: #ffffff" color="#009900">
						<strong>这是客户端代码：<br /></strong>
				</font>
				<font color="#000099">&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;&lt;/title&gt;<br />&lt;script language="javascript"&gt;<br />/**<br />* 初始化一个xmlhttp对象<br />*/<br />function InitAjax()<br />{<br />　var ajax=false; <br />　try { <br />　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); <br />　} catch (e) { <br />　　try { <br />　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); <br />　　} catch (E) { <br />　　　ajax = false; <br />　　} <br />　}<br />　if (!ajax &amp;&amp; typeof XMLHttpRequest!='undefined') { <br />　　ajax = new XMLHttpRequest(); <br />　} <br />　return ajax;<br />}<br />&lt;/script&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;a href="#" onclick="getNews(1)"&gt;新闻&lt;/a&gt;<br />&lt;div id="show_news"&gt;&lt;/div&gt;<br />&lt;script&gt;<br />function getNews(newID)<br />{<br />if(typeof(newID)=='undefined')<br />{<br /> return false;<br />}<br />var url="getmsg.php?id="+newID;<br />var show=document.getElementById("show_news");<br />var ajax=InitAjax();<br />ajax.open("GET",url,true);<br />ajax.onreadystatechange=function(){<br />if(ajax.readyState==4&amp;&amp; ajax.status==200){<br />show.innerHTML=ajax.responseText;<br />}<br />}<br />ajax.send(null);<br />}<br />&lt;/script&gt;</font>
		</p>
		<p>
				<strong>
						<font color="#009933">下面是服务器端的.PHP文件</font>
				</strong>
				<br />
				<font color="#0000cc">&lt;?php<br />if($_GET[id]){<br /> echo"all right&lt;br&gt;";<br /> echo"the id is".$id;<br />}<br />?&gt;<br /></font>放到我的空间上测度一下效果不错。<br /><br />在Ajax中，关键就是用到了xmlhttp对象以及javascript,先是在初始化程序中生成一个xmlhttp对象，如果是IE的话，就是ActiveXObject对象。进一步就是把请求方法和url作为参数传入这个对象，当有响应时再实现onreadystatechange()方法。对返回的内容进行处理。原理就是这样简单。<br /><br />用POST方法实现，上面那个用的是GET方法。这个我没有写具体的代码作测试，只是我把不同的地方指出来。<br />POST方法主要是通过表单来实现，但是这个表单不能写上提交目标，表单的头应该写成类似于下面的格式<br />&lt;form name="user_info"&gt;,而action，method就可以免了。</p>
		<p>
				<br />//构建一个表单，表单中不需要action、method之类的属性，全部由ajax来搞定了。<br />＜form name="user_info"＞<br />姓名：＜input type="text" name="user_name" /＞＜br /＞<br />年龄：＜input type="text" name="user_age" /＞＜br /＞<br />性别：＜input type="text" name="user_sex" /＞＜br /＞</p>
		<p>＜input type="button" value="提交表单" onClick="saveUserInfo()"＞<br />＜/form＞<br />//构建一个接受返回信息的层：<br />＜div id="msg"＞＜/div＞ </p>
		<p>
				<font color="#000099">function saveUserInfo()<br />{<br />　//获取接受返回信息层<br />　var msg = document.getElementById("msg");</font>
		</p>
		<p>
				<font color="#000099">　//获取表单对象和用户信息值<br />　var f = document.user_info;<br />　var userName = f.user_name.value;<br />　var userAge = f.user_age.value;<br />　var userSex = f.user_sex.value;</font>
		</p>
		<p>
				<font color="#000099">　//接收表单的URL地址<br />　var url = "/save_info.php";</font>
		</p>
		<p>
				<font color="#000099">　//需要POST的值，把每个变量都通过&amp;来联接<br />　var postStr = "user_name="+ userName +"&amp;user_age="+ userAge +"&amp;user_sex="+ userSex;</font>
		</p>
		<p>
				<font color="#000099">　//实例化Ajax<br />　var ajax = InitAjax();<br />　<br />　//通过Post方式打开连接<br />　ajax.open("POST", url, true); </font>
		</p>
		<p>
				<font color="#000099">　//定义传输的文件HTTP头信息<br />　ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); </font>
		</p>
		<p>
				<font color="#000099">　//发送POST数据<br />　ajax.send(postStr);</font>
		</p>
		<p>
				<font color="#000099">　//获取执行状态<br />　ajax.onreadystatechange = function() { <br />　　//如果执行状态成功，那么就把返回信息写到指定的层里<br />　　if (ajax.readyState == 4 &amp;&amp; ajax.status == 200) { <br />　　　msg.innerHTML = ajax.responseText; <br />　　} <br />　} <br />}</font>
		</p>
		<p>比较GET和POST两方法，因为POST方法能发送任何数据，而且大小没有限制，因而比较灵活。不过要在ajax对象中指定HTTP头信息。其它同GET方法类似。<br /></p>
<img src ="http://www.blogjava.net/huyi2006/aggbug/83217.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/huyi2006/" target="_blank">allic</a> 2006-11-24 12:38 <a href="http://www.blogjava.net/huyi2006/articles/83217.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>