苗启源的部落格Thinks(想法) - http://www.miaoqiyuan.cn Fri, 30 Dec 2011 16:20:41 +0000 http://wordpress.org/?v=2.9.1 en hourly 1 猫七数据加密、解密类 http://www.miaoqiyuan.cn/p/catseven-coding http://www.miaoqiyuan.cn/p/catseven-coding#comments Fri, 30 Dec 2011 15:08:05 +0000 mqycn http://www.miaoqiyuan.cn/?p=803 在很多场合,特别重要的要加密传输。使用成熟的加密算法是一个不错的选择,但是~ 有些算法这个语言支持而另一种语言不支持。或者直接要安装某某组件,实在是太烦琐了,为了方便以后使用,自己抽空写了一个。

'=====================================================================
'=                       猫七数据加密、解密类                         =
'=     Copyright (c) 2011 猫七(QQ:77068320) All rights reserverd.    =
'=              请尊重作者劳动成果,转载请保留代码的完整性             =
'=====================================================================
'= 作者:苗启源(博客:http://www.miaoqiyuan.cn)                        =
'= 讨论:http://www.miaoqiyuan.cn/p/catseven-coding
'= 最新:http://www.miaoqiyuan.cn/products/Catseven.Coding.rar
'=====================================================================
'=  文件名:Class.Catseven.Coding.asp                                =
'=  功  能:猫七数据加密、解密函数                                     =
'=====================================================================
  class Catseven_Coding
    public akey,ekey,keylen,keymax,autolen

    '类初始化
    '  akey    编码表
    '  ekey    密钥
    '  keylen  标准编码长度
    '  keymax  最大编码长度,默认1000,代表1000-数据长度必须是3位数字,即数据的长度可以为0-900
    '  autolen 如果不足,是否补全
    public sub class_initialize()
      akey   = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
      ekey   = "f67RSTUOPDp02qd34ABbMijQFxyr5szZnot89+Y/=EghkVavwuHCXWmKLJNGIcel1"
      keylen = 900
      keymax = 1000
      autolen= true
    end sub

    '函数:randkey
    '功能:创建随机字符
    '参数:rndkeylen  随机字符长度
    private function randkey(byval rndkeylen)
      dim rndnum,keymap,rstr,i
      keymap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
      rstr = ""
      for i = 1 to rndkeylen
        randomize
        rndnum = cLng(len(keymap) - 1) * rnd() + 1
        rstr   = rstr & mid(keymap,rndnum,1)
      next
      randkey = rstr
    end function

    '函数:encode
    '功能:加密字符串
    '参数:str    要加密的字符串
    public function encode(byval str)
      dim alen,i,vstr,kstr,vkey
      str  = replace(str,"\","")
      alen = len(str)
      if alen = 0 then
        encode = ""
      else
        vstr = ""
        vkey = randkey(1)
        for i = 1 to len(str)
          kstr = mid(str,i,1)
          vstr = vstr & mid(akey,instr(ekey,kstr),1)
        next
        alen = keymax - alen
        vstr = len(alen) & vkey & randkey(9 - len(keymax)) & alen & UCase(vkey) & vstr
        alen = len(vstr)
        if keylen < alen then keylen = alen
        if keylen > keymax * 0.9 then keylen = keymax * 0.9
        vstr = mid(vstr,1,keylen)
        if alen < keylen and autolen = true then
          vstr = vstr & randkey(keylen - alen)
        end if
        encode = vstr
      end if
    end function

    '函数:decode
    '功能:解密字符串
    '参数:str    要解密的字符串
    public function decode(byval str)
      dim alen,i,vstr,kstr,vkey
      alen = mid(str,1,1)
      vkey = mid(str,2,1)
      if not isnumeric(alen) then
        decode = ""
      else
        alen = mid(str,11 - alen,alen)
        if not isnumeric(alen) then
          decode = ""
        else
          alen = keymax - alen + 1
          str = mid(str,11,alen)
          if mid(str,1,1) = UCase(vkey) then
            vstr = ""
            str = mid(str,2)
            for i = 1 to len(str)
              kstr = mid(str,i,1)
              vstr = vstr & mid(ekey,instr(akey,kstr),1)
            next
            decode = vstr
          else
            decode = ""
          end if
        end if
      end if
    end function
  end class

使用的时候比较简单,只支持英文加密,所以使用的时候,请配合base64函数(相关代码:http://www.miaoqiyuan.cn/p/tag/base64)使用。加密的时候用encode。

  set a = new Catseven_Coding
  a.autolen = true
  a.keylen  = 150
  response.write a.encode("5qyi6L+O5ZKM5oiR6K6o6K6677yM5pys5paH5Y6f5paH5Zyw5Z2A77yaaHR0cDovL3d3dy5taWFvcWl5dWFuLmNuL3AvQ2F0c2V2ZW4tQ29kaW5n")

'base64编码后的字符

解密的时候直接用decode。

  set a = new Catseven_Coding
  response.write a.decode("3kfRpeT888KcNaVB4lHcf3UchVDB3BhB3BBCCaUcKadcKuycmBAcKuycfawcfMRCCauuyDL9Jhv4POPOaciu1Yv91/cO1Yx426x4PRvXMYL9MtMf1QiXMksu1cgkwbbM5c2IZDXHMqcZSnkCb4C6LP")

'解码后,为base64编码

可以指定ekey指定对照表

]]>
http://www.miaoqiyuan.cn/p/catseven-coding/feed 0
Windows8不是怪胎,我们都是out man http://www.miaoqiyuan.cn/p/hello-world http://www.miaoqiyuan.cn/p/hello-world#comments Wed, 23 Nov 2011 13:24:10 +0000 mqycn http://www.miaoqiyuan.cn/?p=772 谷歌的Chrome系统终于出现了,它的最大的优点是开机速度超快、入手超简单。进入ChromeOS,唯一的程序就是一个浏览器。所以可以说对所有木马和病毒免疫。所有文档均云存储在互联网上,不用担心丢失,也令其成为最安全的操作系统,另外几秒钟便可启动并接入互联网,也让同类上网本黯然失色。目前Win8是唯一能与之抗衡的系统。

可能用过Win8的用户,会感觉Win8是个怪胎。如果同时用ChromeOS和Win8的用户,会无奈的发现。这是一场革命。就像Win取代Dos,一部留神。我们都Out了。要知道当初Dos用户也说自己用的最优秀的系统,Win98/Win2000到05年的时候,仍占半壁江山。

2001年的XP到2011,已经在我们的PC上运行了十年,仍然占86%的市场。微软已经明确表示于2014年取消WinXP的技术支持,这就意味着2014年后漏洞满天飞。就在国人还没准备升级到Win7的时候。Win8已经悄悄的来了。也许有人说Win8是怪胎。

2010年1月,Win7国内市场占用率2.9%,7月达到4.87%,2011年1月8.91%,2011年6月12.21%,2011年10月15.32。曾经自诩是电脑高手我,今天才发现电脑竟然是如此的陌生。

云计算的概念已经炒了几年,到目前仍然没有一个标准。但是云计算的概念却越来越清晰。谷歌期待着ChromeOS操作系统使谷歌更深入地进入云计算领域,作为微软Windows和苹果Mac计算机的替代产品。谷歌将用ChromeOS操作系统把赌注押在云计算方面。

使用ChromeOS操作系统,用户不需要下载软件或者在内部存储数据。数据位于谷歌的云计算中,在世界各地的数据中心中的并行排列的服务器支持谷歌的云计算。

未来的电脑应该朝移动,带宽,云计算发展。可能仍然有人会站出来说:功能是不错,那我们常用的PhotoShop怎么运行的。这点你可以去了解下Native Client。

第一,移动,移动就意味这有限的电池容量,意味着小屏幕,这对于基于Chrome OS这样的精简系统是天然友好的。未来取决于公司愿意员工走出去,还是留在办公室。这是手机和PC之争。

第二,带宽,由于Chrome OS的应用第一次使用时都要从网上下载,高带宽会大大提高系统的可用性。这就看3G,4G的发展速度。

第三,云计算, 是否有足够的云端应用供Chrome OS来使用。

您可以说讨厌Win8、讨厌ChromeOS,但是你阻止不了他的发展。抛弃WindowsXP是迟早的事情。

曾经记得哪位高人说过:人生最大的敌人是自己。现在看来果然不错,Microsoft的Windows打败了无数对手,目前最大的敌人就是IE6和WinXP。Google的Android目前是安装量最多的手机操作系统,他的最大的麻烦就是出现了太多的自己(版本太多)。

猫七 于 2011.11.23

]]>
http://www.miaoqiyuan.cn/p/hello-world/feed 0
巧用JS复制网页内容 http://www.miaoqiyuan.cn/p/js-fav-copy http://www.miaoqiyuan.cn/p/js-fav-copy#comments Sun, 19 Dec 2010 12:07:20 +0000 mqycn http://www.miaoqiyuan.cn/?p=717 最近公司想整理下业务,看看有什么漏掉的订单。万网,息壤的业务比较多。万网的可以导出csv,而息壤就悲剧了。好几百页,只能一条一条的复制,郁闷。受QQ云输入法的影响,将JS保存到收藏夹,点击链接执行JS,加载外部JS创建表单,通过DOM获取内容,提交到本地的数据库。剩下的就好处理了。

1、新建收藏夹项目,路径填写:

javascript:(function(){$tmp=document.createElement("script");$tmp.src='http://192.168.99.29/_app/xirang.js';document.getElementsByTagName("head")[0].appendChild($tmp);})();

2、本地架设好服务器,xirang.js内容如下:

(function(){
  $tmp=document.createElement("div");
  $tmp.innerHTML=' <form action="http://192.168.99.29/_app/xirang.asp" style="display:none" method="post" id="__tmp_form"><textarea name="txtdb"></textarea></form>';
  document.getElementsByTagName("body")[0].appendChild($tmp);}
)();
hostlist = (function(){
  _t=document.getElementsByTagName("table");
  for(i=0;i<_t.length;i++){
    if(_t[i].getAttribute("className") == "listtable"){
      return _t[i];
    }
  }
  return "";
})();
if(typeof(hostlist) == "object"){
  __tmp_frm = document.getElementById("__tmp_form");
  __tmp_frm.txtdb.value = hostlist.innerHTML;
  __tmp_frm.submit();
}else{
  if(confirm("没有找到数据,点确定返回第一页")){
    location.href = "http://www.xrnet.cn/store/member.php?module=mysite&start_item=0&search=&sort_order=expiry_date&sort_order_desc=1";
  };
};

3、现在点击收藏夹中的项目,主机列表的内容(HTML代码)就到了一个表单中,并提交到了:http://192.168.99.29/_app/xirang.asp。

4、建立一个xirang.asp,保存内容。

  set conn = server.createobject("ADODB.Connection")
  conn.open "provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("xirang.mdb")
  set rs = server.createobject("ADODB.Recordset")

  frmstr = request.servervariables("HTTP_REFERER")
  if frmstr = "" then
    rs.open "select txt from txtdb",conn,1,1
    do while not rs.eof
      response.write rs(0)
      response.flush()
      rs.movenext
    loop
  else
    tmpstr = "<table width=""100%"" border=""1"">" & request.form("txtdb") & "</table>"
    stanum = split(mid(frmstr,instr(frmstr,"start_item")+11),"&")(0)
    if isnumeric(stanum) then stanum = cLng(stanum) else stanum = 0
    nxtnum = stanum + 20

    rs.open "select * from txtdb",conn,3,2
    rs.addnew
    rs("txt") = tmpstr
    rs("pag") = stanum
    rs.update
    rs.close
    set rs = nothing
    set conn = nothing

    response.redirect "http://www.xrnet.cn/store/member.php?module=mysite&start_item=" & nxtnum & "&search=&sort_order=expiry_date&sort_order_desc=1"
  end if

5、不停的点击收藏夹的,直到最后一页。

6、直接用浏览器打开,http://192.168.99.29/_app/xirang.asp,就导出了列表的数据。 另存为网页,改后缀名为.xls,用excel打开,另存为excel格式。用access/mssql导入,有脚本处理就可以了。这些不在本文的讨论范围,不提供代码。

这种方法,可以保存任何内容。本人现在对外接单,如果有网站程序开发/重构的需求,欢迎和我联系。QQ:77068320

]]>
http://www.miaoqiyuan.cn/p/js-fav-copy/feed 0
PHP无限级分类函数 http://www.miaoqiyuan.cn/p/php-super-class http://www.miaoqiyuan.cn/p/php-super-class#comments Tue, 12 Oct 2010 16:32:08 +0000 mqycn http://www.miaoqiyuan.cn/?p=702 很早之前就想一套PHP无限级分类函数,供以后的项目用,今晚闲了无事,就写一个把。懒得动脑,就按以前的ASP无限级分类函数的思想写一个把。

  /*
    作者:苗启源(Miaoqiyuan.cn)
    函数:getCatagory
    功能:获得分类列表
    参数:cat_arr     -> 分类数组(Rscordset:id:分类编号,pid:上级分类,name:分类名称,childs:子分类)
          cat_pid     -> 上级分类编号
          cat_childs  -> 下级分类编号
          cat_select  -> 选择的分类
          cat_dir     -> 分类级别
    返回:返回分类列表(Option)
  */
  function getCatagory($cat_arr,$cat_pid,$cat_childs,$cat_select,$cat_dir,$format){
    if($cat_pid==0 && $format=="option"){
      echo '<option value="0">根目录</option>';
    }
    if(is_array($cat_arr)){
      foreach($cat_arr as $cat_id =>$cat){
        if($cat['pid'] == $cat_pid && strpos("," . $cat_childs . ",","," . $cat['id'] . ",") == 0){
        #if($cat['pid'] == $cat_pid){
          if($format == "option"){
            echo '<option value="'. $cat['id'] .'" '. (($cat_select == $cat['id'])?"selected":"") . '>' . $cat_dir . '┣ ' . $cat['name'] . '</option>';
          }else{
            #<li>{$cat.dir}┣<a href="?act=edt&id={$cat.id}&type=product">{$cat.name}</a></li>
            $tmp = $format;
            if(strpos($tmp,"{\$cat.dir}")>0)$tmp = str_replace("{\$cat.dir}",$cat_dir,$tmp);
            if(strpos($tmp,"{\$cat.id}")>0)$tmp = str_replace("{\$cat.id}",$cat['id'],$tmp);
            if(strpos($tmp,"{\$cat.pid}")>0)$tmp = str_replace("{\$cat.pid}",$cat['pid'],$tmp);
            if(strpos($tmp,"{\$cat.name}")>0)$tmp = str_replace("{\$cat.name}",$cat['name'],$tmp);
            if(strpos($tmp,"{\$cat.childs}")>0)$tmp = str_replace("{\$cat.childs}",$cat['childs'],$tmp);
            echo $tmp;
          }
          getCatagory($cat_arr,$cat['id'],$cat_childs,$cat_select,$cat_dir . "┃",$format);
        }
      }
    }
  }

  $cat_arr = Array(
    1 => Array(
      'id'     =>1,
      'pid'    =>0,
      'name'   =>'分类一',
      'childs' =>'1,2,3,4,5'
    ),
    2 => Array(
      'id'     =>2,
      'pid'    =>1,
      'name'   =>'分类二',
      'childs' =>'2,5'
    ),
    3 => Array(
      'id'     =>3,
      'pid'    =>1,
      'name'   =>'分类4',
      'childs' =>'3,4'
    ),
    4 => Array(
      'id'     =>4,
      'pid'    =>3,
      'name'   =>'分类4',
      'childs' =>'4'
    ),
    5 => Array(
      'id'     =>5,
      'pid'    =>2,
      'name'   =>'分类5',
      'childs' =>'5'
    )
  );

  getCatagory($cat_arr,0,'','','','<li>{$cat.dir}┣<a href="?act=edt&id={$cat.id}&type=product">{$cat.name}</a></li>');
]]>
http://www.miaoqiyuan.cn/p/php-super-class/feed 0
ASP写的MSSQL管理工具 http://www.miaoqiyuan.cn/p/mssql-asp http://www.miaoqiyuan.cn/p/mssql-asp#comments Sat, 12 Jun 2010 14:32:53 +0000 mqycn http://www.miaoqiyuan.cn/?p=616 本文为catseven落伍缩写,已发到落伍者,供catseven落伍。如有引用,请注明出处。
       因为工作,经常要操作数据库,考虑到安全问题,在防火墙中没有开mssql端口。每次遇到必须使用查询分析器的时候,就麻烦了。为了方便工作,写了这个工具。

      可以操作所有ADODB连接的数据库,当然包括MSSQL,MySQL,Access….

     本工具分为两个部分。控制代码和输入代码。

     控制代码就是VBScript部分,可以实现所有逻辑操作,和asp操作一样。

      输入部分就是Link、SQL分别用于输入连接字符串,SQL语句。如果控制代码不调用这些语句,则这部分无实际意义。

       默认,控制代码已经写好一个模板。点击执行,可以执行SQL语句,点击下载,将执行结果保存到Excel中。

       因为能直接操作VbScript,如果要使用,请设置好权限。新建mssql用户,在iis中设置mssql.asp以mssql的身份执行。mssql.asp的访问权限只有mssq用户。mssql对所有文件无任何权限,对mssql.asp只有可读权限。

      代码如下:

<%
Server.ScriptTimeout = 9999
starttime = timer()
cmd = request("cmd")

if request("out")="xls" and trim(cmd)<>"" then
	response.ContentType = "application/octet-stream"
	response.AddHeader "Content-Disposition", "attachment;filename=执行结果.xls"
	execute(cmd)
	response.end
end if
%>
<style type="text/css">
form{text-align:center}
textarea{width:100%;height:200px;border:solid 1px #CCC;}
input{height:20px;vertical-align:middle}
input.input{border:solid 1px #CCC;width:40%;line-height:18px;color:#090}
a{font-size:12px;color:#C00;text-decoration:none;}
</style>
<form action="mssql.asp" method="post">
<textarea name="cmd">
<%
if trim(cmd)="" then
%>set Conn = Server.CreateObject("ADODB.Connection")
Conn.open Request("link")

Set Rs=Conn.Execute(Request("sql"))
  for i = 0 to Rs.Fields.Count-1
    Response.write Rs(i).Name &"	"
  next
  response.write vbCrlf
  do while Not Rs.eof
    for i = 0 to Rs.Fields.Count-1
      Response.write Rs(i).value &"	"
    next
    response.write vbCrlf
	Rs.movenext
  loop
<%else%>
<%=cmd%>
<%end if%></textarea>
<%
sql = Request("sql")
link = request("link")
if sql = "" then sql = "select * from sysobjects"
if link = "" then link = "Provider=SQLOLEDB;Persist Security Info=False;User ID=sa;Password=123456;Initial Catalog=master;Data Source=(local)"
%>
Link:<input name="link" class="input" value="<%=link%>" />
SQL:<input name="sql" class="input" value="<%=sql%>" />
<input type="submit" value="执行" onclick="document.forms[0].action='?out=txt'"/>
<input type="submit" value="下载" onclick="document.forms[0].action='?out=xls'"/>
</form>
<%
response.flush()
if trim(cmd)<>"" then
	response.write "<hr /><textarea readonly=""readonly"">"
	execute(cmd)
	response.write "</textarea>"
end if
%><hr /><center style="font-size:12px;color:#C00">执行时间:<%=formatnumber((timer()-starttime)*1000,2,-1)%>毫秒。</center>
]]>
http://www.miaoqiyuan.cn/p/mssql-asp/feed 0
ASP生成静态HTML,可任意深度路径的函数 http://www.miaoqiyuan.cn/p/asp-create-html-function http://www.miaoqiyuan.cn/p/asp-create-html-function#comments Tue, 01 Jun 2010 16:02:28 +0000 mqycn http://www.miaoqiyuan.cn/?p=613 < % set FSO = Server.CreateObject("Scripting.FileSystemObject") Function CheckFile(byval Path) pathArr = Split(Path,"/") Path = replace(Path,"/" & pathArr(ubound(pathArr)),"") if Path = "" then Exit Function if not FSO.FolderExists(Server.Mappath(Path)) then Call CheckFile(Path) FSO.CreateFolder(Server.Mappath(Path)) end if End Function Function newFile(byval Path) if Right(Path,1)="/" then Path = Path & "index.html" end if Call CheckFile(Path) Set newFile = FSO.CreateTextFile(Server.Mappath(Path)) End Function set n = newFile("/index/cat2/path/demo/111/222/333/444/555/666/777/888/") n.write "12345" n.close set n = nothing set n = newFile("../../../../test.css") n.write "body{}" n.close set n = nothing %> ]]> http://www.miaoqiyuan.cn/p/asp-create-html-function/feed 0 ASP模板技术探讨之关联变量 http://www.miaoqiyuan.cn/p/asp-template-assgin http://www.miaoqiyuan.cn/p/asp-template-assgin#comments Mon, 31 May 2010 16:28:26 +0000 mqycn http://www.miaoqiyuan.cn/?p=611 ASP模板技术探讨之关联变量。
先看可实现的效果:

访问变量,需要与ASP结合
关联变量:支持关联的变量
{$#关联名#}
Assgin #关联名#,#变量#
{$#关联名#}

{$#关联名#.#索引#}
Assgin #关联名#,Array(“123″)
{$#关联名#.0}

{$#关联名#.#索引#.#索引#}
Assgin #关联名#,Array(Array(“123″))
{$#关联名#.0.0}

{$#关联名#.#索引#…..#索引#}
Assgin #关联名#,Array(Arr..ay(“123″)))
{$#关联名#.0…0}

{$#关联名#.#Directionary.Key#}
Assgin #关联名#,#DirectionaryName#
{$#关联名#.#Directionary.Key#}

<%
	Dim outHtml
	outHtml = "xxx"                '加载模板
	function Assign(t,n)
		if isArray(n) then
			for x=0 to ubound(n)
				Assign t&"."&x,n(x)
			next
		elseif isobject(n) then
			for each x in n
				Assign t&"."&x,n.item(x)
			next
		else
			if isnull(n) then
				outHtml=replace(outHtml,"{$"&t&"}","")
			else
				outHtml=replace(outHtml,"{$"&t&"}",n)
			end if
		end if
	end function
%>
]]>
http://www.miaoqiyuan.cn/p/asp-template-assgin/feed 0
使用php加密、压缩Javascript脚本 http://www.miaoqiyuan.cn/p/php-javascriptpacker http://www.miaoqiyuan.cn/p/php-javascriptpacker#comments Sat, 15 May 2010 13:56:33 +0000 mqycn http://www.miaoqiyuan.cn/p/%e4%bd%bf%e7%94%a8php%e5%8a%a0%e5%af%86%e3%80%81%e5%8e%8b%e7%bc%a9javascript%e8%84%9a%e6%9c%ac 又好久没有更新日志了,上次谈到将工作用的脚本换成php,现在发现这是一个非常非常明智的选择。
在Linux也可以直接用php当作脚本,处理工作的事情。也算是“跨平台脚本”咯~~~
今天说一下JS压缩,呵呵,这种工具我可写不出来,但是网上牛人已经帮我们写出了相应的类:JavaScriptPacker(http://creativecommons.org/licenses/LGPL/2.1/)
我们直接调用就可以咯,比如将test_resource.js压缩成test.js。

<?php
   #demo.php
   require_once 'class.JavaScriptPacker.php';
   $packer = new JavaScriptPacker(file_get_contents("./test_resource.js"), 'Normal', true, false);
   file_put_contents("./test.js",$packer->pack());
?>

直接 php demo.php

]]>
http://www.miaoqiyuan.cn/p/php-javascriptpacker/feed 0
FlashFxp传输超过2g文件 http://www.miaoqiyuan.cn/p/flashfxp-2g http://www.miaoqiyuan.cn/p/flashfxp-2g#comments Thu, 29 Apr 2010 13:12:11 +0000 mqycn http://www.miaoqiyuan.cn/?p=572    想下一个CentOS玩玩,在线太慢,想到局域网内有个公共文件共享的服务器,开了ftp。

     所处于一个超级内部局域网。我的机器ip为10.1.0.175,公共数据存储在10.0.0.254。用FlashFxp拉下来,速度很快,竟然能达到8MB。但是到数据2G的时候,就停止了。难道FlashFxp传输超过2g文件不可以吗?

     在网上找到很久,也没有找到解决办法,忽然想到了Windows自带了一个ftp。连上去,一会就下载完了。还是Windows自带的好哦。

]]>
http://www.miaoqiyuan.cn/p/flashfxp-2g/feed 0
ASP直接使用表单名称变量调用GET提交的数据 http://www.miaoqiyuan.cn/p/asp-get-var http://www.miaoqiyuan.cn/p/asp-get-var#comments Wed, 31 Mar 2010 04:13:20 +0000 mqycn http://www.miaoqiyuan.cn/?p=560 当PHP.ini设置register_globals = On是,通过GET提交的数据可以直接使用表单名调用GET提交的数据。asp就不可以,我想到了asp的execute,也谢了一个脚本,还能过滤SQL注入字符串

<%
Dim myRegExp

set myRegExp=New RegExp
myRegExp.Pattern = "[^a-z0-9_]"
myRegExp.Global=True

for each Req in Request.Querystring
	ReqV=Request.Querystring(Req)
	if trim(ReqV)&lt;&gt;"" then
		ReqV=replace(ReqV,"""","""""")
		Req=myRegExp.Replace(Req,"")
		Execute(Req&"="""&ReqV&"""")
	end if
next

response.write a
%>

调用很简单。比如GET提交/get_Test.asp?a=111&b=222

则直接可以使用Response.write a,输出结果为111。简单吧~

再次感谢小秦(Q48080163)提出的bug

]]>
http://www.miaoqiyuan.cn/p/asp-get-var/feed 2