<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Maple'CR  - 脚本代码</title><link>http://www.maple.hk/</link><description>幻梦墟 - </description><generator>RainbowSoft Studio Z-Blog 1.8 Walle Build 100427</generator><language>zh-CN</language><copyright>Copyright 2005-2010 Maple.hk Some Rights Reserved.</copyright><pubDate>Thu, 09 Sep 2010 19:28:21 +0800</pubDate><item><title>asp好用的函数集</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20070115/159/</link><pubDate>Mon, 15 Jan 2007 08:39:52 +0800</pubDate><guid>http://www.maple.hk/archives/20070115/159/</guid><description><![CDATA[<p>防站外提交函数说明： 读取文件操作： '------------------------------------------------- '函数名称:ReadTextFile '作用:利用AdoDb.Stream对象来读取UTF-8格式的文本文件 '---------------------------------------------------- Function ReadFromTextFile (FileUrl,CharSet) dim str set stm=server.CreateObject(&quot;adodb.stream&quot;) stm.Type=2 '以本模式读取 stm.mode=3 stm.charset=CharSet stm.open stm.loadfromfile server.MapPath(FileUrl) str=stm.readtext stm.Close set stm=nothing ReadFromTextFile=str End Function 写文件操作： '------------------------------------------------- '函数名称:WriteToTextFile '作用:利用AdoDb.Stream对象来写入UTF-8格式的文本文件 '---------------------------------------------------- Sub WriteToTextFile (FileUrl,byval Str,CharSet) set stm=server.CreateObject(&quot;adodb.stream&quot;) stm.Type=2 '以本模式读取 stm.mode=3 stm.charset=CharSet stm.open stm.WriteText str stm.SaveToFile server.MapPath(FileUrl),2 stm.flush stm.Close set stm=nothing End Sub 创建一个config.asp的文件 call WriteToTextFile(&quot;config.asp&quot;,&quot;谁是最可爱的人&quot;,&quot;utf-8&quot;)</p>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20070115/159/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=159</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=159&amp;key=c3a1f964</trackback:ping></item><item><title>重新审视SqlDataReader的使用</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060926/143/</link><pubDate>Tue, 26 Sep 2006 10:11:16 +0800</pubDate><guid>http://www.maple.hk/archives/20060926/143/</guid><description><![CDATA[ADO.NET 1.x 利用SqlDataReader读取数据，针对每个结果集需要一个独立的连接。当然，你还必须管理这些连接并且要付出相应的内存和潜在的应用程序中的高度拥挤的瓶颈代价-特别是在数据集中的Web应用程序中。<br/><br/>      ADO.NET 2.的一个新特征多数据结果集（Multiple Active Result Sets，简称MARS）-它允许在单个连接上执行多重的数据库查询或存储过程。这样的结果是，你能够在单个连接上得到和管理多个、仅向前引用的、只读的结果集。目前实现这个功能的数据库只有Sql Server 2005。所以当我们针对Sql Sever 2005的时候，需要重新审视DataReader对象的使用。使用SqlServer 2005，可以在一个Command对象上同时打开多个DataReader，节约数据库联接所耗费的服务器资源，在实际开发中普遍存在的一种典型的从数据库中读写数据的情形是，你可以使用多重连接而现在只用一个连接就足够了。例如，如果你有一些来自于几个表中的数据-它们不能被联结到一个查询中，那么你就会有多重的连接-每个连接都有一个与之相关连的命令用于读取数据。同样，如果你正在向一个表写数据，那么你需要另外一个连接或连接集合-如果有多个表要被更新的话。<br/><br/>例如下面的代码<br/><br/>               //MultipleActiveResultSets=true打开联接 <br/>              string connstr = "server=(local);database=northwind;integrated security=true;MultipleActiveResultSets=true"; <br/><br/>              SqlConnection conn = new SqlConnection(connstr);<br/>            conn.Open();<br/>            SqlCommand cmd1 = new SqlCommand("sel&#101;ct * from customers", conn);<br/>            SqlCommand cmd2 = new SqlCommand("sel&#101;ct * from orders", conn);<br/>            SqlDataReader rdr1 = cmd1.ExecuteReader();<br/>           // next statement causes an error prior to SQL Server 2005<br/>            SqlDataReader rdr2 = cmd2.ExecuteReader();<br/>           // now you can reader from rdr1 and rdr2 at the same time.<br/><br/>              conn.Close();<br/>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060926/143/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=143</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=143&amp;key=f1e0af3e</trackback:ping></item><item><title>No.1进程管理器V1.62－－优秀的进程管理工具</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060925/141/</link><pubDate>Mon, 25 Sep 2006 09:07:17 +0800</pubDate><guid>http://www.maple.hk/archives/20060925/141/</guid><description><![CDATA[前二天有一个smss的木马挺厉害，最终我用傲盾的个人版防火墙把它找到了，但当时由于没有查看进程的软件，所以很麻烦。幸好那个木马不断的发数据包才被发现，否则还不知道是咋回事咧。<br/><br/>今天上传一个进程查看的工具，昨天用了一下，感觉特别的有用，不亏是第一的进程管理器。非常不错，我推荐哟！<br/><br/><br/><a href="http://www.maple.hk/upload/month_0609/eb4i_No1PV.rar" target="_blank">点击下载此文件</a>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060925/141/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=141</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=141&amp;key=129bbe99</trackback:ping></item><item><title>傲盾防火墙程序</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060923/140/</link><pubDate>Sat, 23 Sep 2006 08:16:07 +0800</pubDate><guid>http://www.maple.hk/archives/20060923/140/</guid><description><![CDATA[很多年前就在用这个免费版本的程序，昨天想用的时候却突然找不到了。在网上一搜发现也很难下载，所以就放到我的blog里面了。<br/><br/><br/><a href="http://www.maple.hk/upload/month_0609/rogv_kfwF1417.zip" target="_blank">点击下载此文件</a>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060923/140/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=140</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=140&amp;key=0223e356</trackback:ping></item><item><title>CSS中class:hover的用法</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060721/128/</link><pubDate>Fri, 21 Jul 2006 16:19:59 +0800</pubDate><guid>http://www.maple.hk/archives/20060721/128/</guid><description><![CDATA[<p><style type="text/css">中只能书写CSS描述，JS是不可以写的。今日仔细看了一个别人的例子，终于发现，原来是如此的简单！我们都知道，链接在CSS的定义中除了一个普通的<A>标记以外还可以对以下四种状态进行定义：a:link  没有接触过的链接a:visited访问过的链接a:hover 鼠标放在链接上的状态a:active 在链接上按下鼠标时的状态类似的，对其它CSS中的CLASS/TAG，也可以借鉴开头说的那个效果就是使用了:hover状态，因此解决方案如下：div.box_singleline {border:solid black 1px; padding:1px 4px 1px 4px;}div.box_singleline:hover {border: 1px solid #00f; background: #f8f8f8}<div class="box_singleline">something...</div></style></p><p>效果简述：一个用单线围绕的文本框，在鼠标放在上面的时候，边框和背景的颜色都有变化，提醒浏览者目前正在观看此部分内容。这种效果在BLOG中常用，我一开始以为是通过JS实现的，但当自己想用上它的时候，却发现我没法像定义外观（颜色、大小、边框等）那样去定义CSS中某个CLASS的事件因为在&lt;style&nbsp;type=&quot;text/css&quot;&gt;中只能书写CSS描述，JS是不可以写的。今日仔细看了一个别人的例子，终于发现，原来是如此的简单！我们都知道，链接在CSS的定义中除了一个普通的&lt;A&gt;标记以外还可以对以下四种状态进行定义：</p><p>a:link&nbsp;&nbsp;没有接触过的链接<br />a:visited访问过的链接<br />a:hover&nbsp;鼠标放在链接上的状态<br />a:active&nbsp;在链接上按下鼠标时的状态</p>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060721/128/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=128</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=128&amp;key=395054f6</trackback:ping></item><item><title>asp基础(分页)</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060717/127/</link><pubDate>Mon, 17 Jul 2006 11:26:05 +0800</pubDate><guid>http://www.maple.hk/archives/20060717/127/</guid><description><![CDATA[好久没写ASP竟然连分页都忘的差不多了，所以摘录了一个入门级分页的简单程序示例。 <br/><br/>                  简单的一个分页教程<br/><br/><blockquote><div class="quote"><br/><%<br/>Set conn = Server.CreateObject("ADODB.Connection")<br/>strcon="provider=microsoft.jet.oledb.4.0;data source="& _<br/>server.mappath("mdb.mdb")<br/>conn.Open strcon<br/><br/>Set rstObj = Server.CreateObject ("ADODB.Recordset")<br/>sql="sel&#101;ct * from table order by id desc"<br/>rstObj.Open sql, conn, 1<br/><br/>page=1 ' 设置变量PAGE=1<br/>rs.PageSize = 5  '每页显示记录数<br/><br/>if Not IsEmpty(Request("Page")) then   '如果PAGE已经初始化...<br/><br/>Page = CInt(Request("Page"))       '接收PAGE并化为数字型赋给PAGE变量<br/><br/>if Page > rst.PageCount then   '如果接收的页数大于总页数<br/>rst.AbsolutePage = rst.PageCount    '设置当前显示页等于最后页<br/><br/>elseif  Page <= 0 then   '如果page小于等于0<br/>Page = 1    '设置PAGE等于第一页<br/>else<br/>rs.AbsolutePage = Page  '如果大于零,显示当前页等于接收的页数 <br/>end if<br/>End if<br/>intCurPage = rsj.AbsolutePage <br/>%><br/><% <br/><br/>For i = 1 to rs.PageSize<br/>    if rst.eOF then <br/>Exit For <br/>end if                   '利用for next 循环依次读出记录<br/>%><br/><br/></div></blockquote><br/>上面的代码只需要改动Rs.pagesize=5,把5改为你想显示的记录数.比如说<br/>改为10.那么每页就是显示10页.还需要修改的是sel&#101;ct语句.就是你要检索的数据库了.<br/>也就是说放到任何一个系统中上面的代码只需很小的改动都可以直接拿过来用.<br/><br/>然后:<br/>接...就是你要循环读出记录的显示内容了..............比如<br/><br/><br/><blockquote><div class="quote"><table width=50 border=1 align=center><tr><TD><% =rs("内容") %></td></tr></table><%<br/>rs.movenxet<br/>next<br/>%><br/><br/></div></blockquote><br/>当然也可以改为response.write输出.那是你的事了.你可以自由发挥版面样式.<br/><br/>最后,添加"下一页,上一页"的链接:<br/><br/><br/><blockquote><div class="quote"><%<br/>if page<>1 then%><br/><a Href="fenye.asp?Page=<% = 1%>">首页</a> <br/><a Href="fenye.asp?ToPage=<% =ToPage -1 %>">上一页</a> <br/>%><br/><%<br/>end if  %><br/><%<br/>if page<>rs.pagecount then %><br/><a Href="fenye.asp?ToPage=<% =Page + 1%>">下一页</a> <br/><a Href="fenye.asp?ToPage=<% = rs.PageCount%>">尾页</a> <br/>%>  <br/><% <br/>end if %><br/><br/></div></blockquote><br/>上面的代码反正不管三七二十一只管复制粘贴.只需把"fenye.asp"改成你自己的文件名就可以了.随便把这段代码放在什么地方?就是你想让它出现下一页下一页链接的地方吧.<br/><br/>最后.关闭记录集释放资源:<br/><br/><br/><blockquote><div class="quote">CODE:[Copy to clipboard]<% <br/>rst.close <br/>Set rs = Nothing<br/>conn.close <br/>set conn=nothing <br/>%><br/><br/></div></blockquote>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060717/127/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=127</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=127&amp;key=e4f0d684</trackback:ping></item><item><title>SQL语句集锦(陆续添加中)</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060711/123/</link><pubDate>Tue, 11 Jul 2006 11:52:07 +0800</pubDate><guid>http://www.maple.hk/archives/20060711/123/</guid><description><![CDATA[<blockquote><div class="quote">NO.1<br/><br/>(1) INSERT [INTO] B SELECT id, field1, field2 FROM A WHERE NOT EXISTS (SELECT id FROM B WHERE id=[A.]id) <br/><br/>(2) INSERT [INTO] B SELECT * FROM A WHERE id NOT IN (SELECT id FROM B)<br/><br/>---------------------------------------------------------------------------<br/><br/>这两句,都是将 A 表中存在, 但B表中不存在的数据, 插入到B表中, 关联比较字段为 id.<br/>但这两句的执行效率,却是有数量级的差别.<br/><br/>结论有两点:<br/>尽量用 EXISTS 和 NOT EXISTS 代替 IN 和 NOT IN 不要偷懒, 尽量不用 SELECT * FROM ...., 而要写字段名 SELECT field1,field2,....  <br/></div></blockquote>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060711/123/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=123</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=123&amp;key=230fad44</trackback:ping></item><item><title>aspupload漏洞</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060620/118/</link><pubDate>Tue, 20 Jun 2006 15:15:23 +0800</pubDate><guid>http://www.maple.hk/archives/20060620/118/</guid><description><![CDATA[其实无论是组件还是非组件上传，都有这个漏洞，以下代码请需要得朋友仔细阅读，只要读懂代码就能融会贯通。 <br/>   <br/>  这里以ASPUPLOAD组件上传为例 <br/>   <br/>  以下3个关键函数： <br/>   <br/>  function killext(byval s1) ''干掉非法文件后缀 <br/>  dim allowext <br/>  allowext=".JPG,.JPEG,.GIF,.BMP,.PNG,.SWF,.RM,.MP3,.WAV,.MID,.MIDI,.RA,. <br/>  AVI,.MPG,.MPEG,.ASF,.ASX,.WMA,.MOV,.RAR,.ZIP,.EXE,.DOC,.XLS,.CHM,.HLP,.PDF" <br/>  s1=ucase(s1) <br/>  if len(s1)=0 then <br/>   killext="" <br/>  else <br/>   if not chk(allowext,s1,",") then <br/>   killext=".shit" <br/>   else <br/>   killext=s1 <br/>   end if <br/>  end if <br/>  end function <br/>   <br/>  function chk(byval s1,byval s2,byval fuhao) ''检查字符串包含 <br/>  dim i,a <br/>  chk=false <br/>  a=split(s1,fuhao) <br/>  for i = 0 to ubound(a) <br/>   if trim(a(i))=trim(s2) then <br/>   chk=true <br/>   exit for <br/>   end if <br/>  next <br/>  end function <br/>   <br/>  function gname(byval n1) ''以日期自动产生目录和文件名，参数1生成目录，参数2生成文件名（无后缀） <br/>  dim t,r <br/>  t=now() <br/>  randomize(timer) <br/>  r=int((rnd+1-1)*9999) <br/>  sel&#101;ct case n1 <br/>  case 1 <br/>  gname=year(t)&right("00"&month(t),2)&right("00"&day(t),2) <br/>  case 2 <br/>  gname=right("00"&hour(t),2)&right("00"&minute(t),2)&right("00"&second(t),2)&right("0000"&r,4) <br/>  end sel&#101;ct <br/>  end function <br/>   <br/>  调用方法： <br/>   <br/>  dim oup,ofile,ext,myfile <br/>   <br/>  Set oup = Server.CreateObject("Persits.Upload") <br/>  oup.SetMaxSize 10000000, True <br/>  call oup.Save() ''这里是上传到服务器内存，并没有实际文件产生 <br/>  set ofile = oup.files(1) <br/>  ext=killext(ofile.ext) <br/>   <br/>  myfile="/" & ganme(1) & "/" & gname(2) & ext <br/>   <br/>  call ofile.saveas(server.mappath(myfile)) <br/>   <br/>   <br/>   <br/>  附加说明： <br/>   <br/>  黑客如果用 nc 上传非法文件，最终得到的文件只是 <br/>   <br/>  如 200511051234559103.shit <br/>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060620/118/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=118</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=118&amp;key=7226dda0</trackback:ping></item><item><title>关于截取新闻标题的范例代码</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060609/115/</link><pubDate>Fri, 09 Jun 2006 08:52:52 +0800</pubDate><guid>http://www.maple.hk/archives/20060609/115/</guid><description><![CDATA[此函数的作用是截取新闻标题的前几个文字，文字后面用... ...来表示，代码如下：<br/><br/><blockquote><div class="quote"><%<br/>function cLeft(str,n)<br/>dim str1,str2,alln,Islefted<br/>str2 = ""<br/>alln = 0<br/>str1 = str<br/>Islefted = false<br/>if isnull(str) then<br/>cleft = ""<br/>exit function<br/>end if<br/>for i = 1 to len(str1)<br/>nowstr = mid(str1,i,1)<br/>if asc(nowstr)<0 then<br/>alln = alln + 2<br/>else<br/>alln = alln + 1<br/>end if<br/>if (alln<=n) then<br/>str2 = str2 & nowstr<br/>else<br/>Islefted = true<br/>exit for<br/>end if<br/>next<br/>if Islefted then<br/>str2 = str2 & ".."<br/>end if<br/>cleft = str2<br/>end function<br/>%><br/></div></blockquote><br/><br/><br/>使用方法：<br/><br/><blockquote><div class="quote"><%=cleft(rs("aaaaa"),30)%><br/></div></blockquote><br/><br/>30代表要截取的长度，超出的部分用…代替<br/>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060609/115/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=115</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=115&amp;key=e112730d</trackback:ping></item><item><title>[access]不重复随机读取数据库记录</title><author>credmaple@msn.com (credmaple)</author><link>http://www.maple.hk/archives/20060605/112/</link><pubDate>Mon, 05 Jun 2006 09:31:38 +0800</pubDate><guid>http://www.maple.hk/archives/20060605/112/</guid><description><![CDATA[看到经常有人问这个问题。又到网上找了些看，觉得写得不满意。<br/>大多读取记录到数组里去抽取。昨天又看到人写，心血来潮就顺手想了个，个人认为这种方法应该错吧，呵呵。刚好20行～_～<br/>实现方法：<br/>1。通过recordset游标可移动的特性，在已打开记录集里移动到随机位置读取记录。而且可以将就使用页面中已打开的RS对象。<br/>2。将出现过的随机数保存到一个字符串中，通过instr函数来检查是否重复，重复则递归调用函数至不重复。<br/><br/><br/>数据库打开查询若干，省略... ...<br/>Set rs = Server.CreateObject("Adodb.RecordSet")<br/>rs.open sql,conn,1,1<br/><br/>DIM Appeared<br/>Call DisRndRecord(10,rs.recordCount)'调用函数该位置显示记录<br/><br/>'################SUBS################<br/>'#DisRndRecord(DisNum,rsBound)<br/>'#参数DisNum：显示数量<br/>'#参数rsBound：随机数产生范围<br/>Sub DisRndRecord(DisNum,rsBound)<br/>	DIM i,ThisRnd<br/>	If rsBound < DisNum Then DisNum = rsBound'记录总数小于要抽取记录条数的情况<br/>	For i = 0 To DisNum - 1<br/>		ThisRnd = GetRnd(rsBound)'取得一个不重复的随机数<br/>		rs.Move(ThisRnd)'游标移动到随机数位置数读取<br/>		Response.Write("<br>("&rs("id")&")"&rs("Title"))<br/>		rs.Move(-ThisRnd)<br/>	Next<br/>End Sub<br/>'# 函数GetRnd(bound)返回一个不重复的随机数字<br/>'#参数bound：随机范围<br/>Function GetRnd(bound)<br/>	DIM ranNum<br/>	Randomize()<br/>	ranNum=int(bound*rnd)<br/>	If Instr(Appeared,"["&ranNum&"]") Then'产生的随机数是否出现过<br/>		ranNum = getRnd(bound)<br/>	End If<br/>	Appeared = Appeared & "["&ranNum&"]"'记录已出现的随机数<br/>	GetRnd = ranNum<br/>End Function<br/><br/>]]></description><category>脚本代码</category><comments>http://www.maple.hk/archives/20060605/112/#comment</comments><wfw:comment>http://www.maple.hk/</wfw:comment><wfw:commentRss>http://www.maple.hk/feed.asp?cmt=112</wfw:commentRss><trackback:ping>http://www.maple.hk/cmd.asp?act=tb&amp;id=112&amp;key=00a9b1d6</trackback:ping></item></channel></rss>
