解决ASP查询MYSQL提示“多步操作产生错误。请检查每一步的状态值”
解决MySQL ODBC 5.2韩文乱码
ASP使用Redis
Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库。
一直想在ASP上使用Redis来着,可是网上找了一圈什么语言都有就是没有ASP版的,那就只能自己折腾了。
因为ASP是可以调用COM组件的,那最简单可行的方式就是下载VB的代码修改成COM组件。
来到官网https://redis.io/ 看了一圈,发现官网提供的VB客户端源码是VB.NET的。边下载边研究VB.NET怎么做COM组件的。
...阿里云短信的ASP版
说起阿里的短信接口真是坑爹,最开始叫阿里大鱼,后面改名成阿里大于,然后又并入阿里云平台,然后在云市场那里也有一个,然后又更新了几次,目前最新的情况是阿里云短信(https://dysms.console.aliyun.com/dysms.htm#/account),改来改去接口也是变了好几次,文档还写得不清楚,坑爹中的坑爹。
每次做新项目需要用到短信的,申请新账号就发现老的代码用不了了,又得重新撸。以前阿里大鱼那些接口还简单,最新版的阿里云短信,文档莫名其妙坑了我一整个晚上,终于OK了。下面分享折腾成果(测试过了 IIS下运行是肯定正常的),代码还没有整理,比较乱,需要用到的兄弟凑合着自己改吧。
...ASP的参数名按ASCII码从小到大排序(字典序)函数
各种各样的API接口签名都是要求对参数名先进行排序的,其他语言还好,自带了排序功能,ASP没有自带排序函数,只能自己定义。
这个函数并不是我写的,而是很多年前从支付宝的DEMO里面挖到的。
参数传数组进去,然后返回值是已经按ASCII码从小到大(也就是ABCDEFG...这样的)排序好的数组。
Function SortPara(sPara) Dim nCount nCount = ubound(sPara) For i = nCount To 0 Step -1 minmax = sPara( 0 ) minmaxSlot = 0 For j = 1 To i mark = (sPara( j ) > minmax) If mark Then minmax = sPara( j ) minmaxSlot = j End If Next If minmaxSlot <> i Then temp = sPara( minmaxSlot ) sPara( minmaxSlot ) = sPara( i ) sPara( i ) = temp End If Next SortPara = sPara end Function
...
Kesioncms(ASP)实现无限级导航菜单效果
一直以来使用kesioncms的时候,全站导航菜单我都是写死的(因为实在是不喜欢官方在后台提供的那个纯JS版顶部菜单,一来蜘蛛索引不了对SEO不好,二来看起来实在很蹩脚)今天刚好需要,自己撸了一个
查询语句
select id,foldername,tj from KS_Class where topflag=1 Order BY root,folderorder
循环体
ASP和PHP一致的base64类(UTF-8、可以自定义修改码表)
因为项目关系,需要ASP跟PHP一致的base64类,gb2312的编码还好,到了utf-8就各种出错了,找了网上两个类来修改一下,测试可以用,并且修复了原来php那个类某些情况会乱码、无法在PHP5.2下运行的BUG
ASP版本:
<% class Base64_cls private sBASE_64_CHARACTERS Private Sub Class_Initialize() sBASE_64_CHARACTERS = String2Bytes("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/") end sub function Encode(byval str) Encode=EncodeBytes(String2Bytes(str)) end function function EncodeBytes(byval str) EncodeBytes=Bytes2String(Base64encode(str),"gb2312") end function function Decode(byval str) dim charset:charset = response.Charset if charset="" then charset = "utf-8" Decode=decodeAny(str,charset) end function function DecodeAny(byval str,byval charset) DecodeAny=Bytes2String(DecodeBytes(str),charset) end function function DecodeBytes(byval str) DecodeBytes=Base64decode(String2Bytes(str)) end function Function Base64encode(asContents) Dim lnPosition Dim lsResult Dim Char1 Dim Char2 Dim Char3 Dim Char4 Dim Byte1 Dim Byte2 Dim Byte3 Dim SaveBits1 Dim SaveBits2 Dim lsGroupBinary Dim lsGroup64 Dim m4,len1,len2 len1=Lenb(asContents) if len1<1 then Base64encode="" exit Function end if asContents = midb(asContents,1) m3=Len1 Mod 3 If M3 > 0 Then asContents = asContents & String(3-M3, chrb(0)) IF m3 > 0 THEN len1=len1+(3-m3) len2=len1-3 else len2=len1 end if lsResult = "" For lnPosition = 1 To len2 Step 3 lsGroup64 = "" lsGroupBinary = Midb(asContents, lnPosition, 3) Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1)) Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1) Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1) Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1) Char4 = Midb(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1) lsGroup64 = Char1 & Char2 & Char3 & Char4 lsResult = lsResult & lsGroup64 Next if M3 > 0 then lsGroup64 = "" lsGroupBinary = Midb(asContents, len2+1, 3) Byte1 = Ascb(Midb(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3 Byte2 = Ascb(Midb(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15 Byte3 = Ascb(Midb(lsGroupBinary, 3, 1)) Char1 = Midb(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1) Char2 = Midb(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &HFF) + 1, 1) Char3 = Midb(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &HFF) + 1, 1) if M3=1 then lsGroup64 = Char1 & Char2 & ChrB(61) & ChrB(61) else lsGroup64 = Char1 & Char2 & Char3 & ChrB(61) end if lsResult = lsResult & lsGroup64 end if Base64encode = lsResult End Function Function Base64decode(asContents) Dim lsResult Dim lnPosition Dim lsGroup64, lsGroupBinary Dim Char1, Char2, Char3, Char4 Dim Byte1, Byte2, Byte3 Dim M4,len1,len2 len1= Lenb(asContents) M4 = len1 Mod 4 if len1 < 1 or M4 > 0 then Base64decode = "" exit Function end if if midb(asContents, len1, 1) = chrb(61) then m4=3 if midb(asContents, len1-1, 1) = chrb(61) then m4=2 if m4 = 0 then len2=len1 else len2=len1-4 end if For lnPosition = 1 To Len2 Step 4 lsGroupBinary = "" lsGroup64 = Midb(asContents, lnPosition, 4) Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1 Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF) Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF) Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63)) lsGroupBinary = Byte1 & Byte2 & Byte3 lsResult = lsResult & lsGroupBinary Next if M4 > 0 then lsGroupBinary = "" lsGroup64 = Midb(asContents, len2+1, m4) & chrB(65) if M4=2 then lsGroup64 = lsGroup64 & chrB(65) end if Char1 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 1, 1)) - 1 Char2 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 2, 1)) - 1 Char3 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 3, 1)) - 1 Char4 = InStrb(sBASE_64_CHARACTERS, Midb(lsGroup64, 4, 1)) - 1 Byte1 = Chrb(((Char2 And 48) \ 16) Or (Char1 * 4) And &HFF) Byte2 = lsGroupBinary & Chrb(((Char3 And 60) \ 4) Or (Char2 * 16) And &HFF) Byte3 = Chrb((((Char3 And 3) * 64) And &HFF) Or (Char4 And 63)) if M4=2 then lsGroupBinary = Byte1 elseif M4=3 then lsGroupBinary = Byte1 & Byte2 end if lsResult = lsResult & lsGroupBinary end if Base64decode = lsResult End Function function String2Bytes(byval content) content = Server.URLEncode(content) content = replace(content,"+"," ") dim ret,i,c i=1 do while i<=len(content) c = mid(content,i,1) if c="%" then ret = ret & chrb(cbyte("&H" & mid(content,i+1,2))) i=i+3 else ret = ret & chrb(asc(c)) i=i+1 end if loop String2Bytes = ret end function public Function Bytes2String(ByVal byt,byval charset) If LenB(byt) = 0 Then Bytes2String = "" Exit Function End If Dim mystream, bstr Set mystream =Server.CreateObject("ADODB.Stream") mystream.Type = 2 mystream.Mode = 3 mystream.Open mystream.WriteText byt mystream.Position = 0 mystream.CharSet = charset mystream.Position = 2 bstr = mystream.ReadText() mystream.Close Set mystream = Nothing Bytes2String = bstr End Function end class dim str,str_e,str_d str="Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,大家可以查看RFC2045~RFC2049,上面有MIME的详细规范。Base64编码可用于在HTTP环境下传递较长的标识信息。例如,在Java Persistence系统Hibernate中,就采用了Base64来将一个较长的唯一标识符(一般为128-bit的UUID)编码为一个字符串,用作HTTP表单和HTTP GET URL中的参数。在其他应用程序中,也常常需要把二进制数据编码为适合放在URL(包括隐藏表单域)中的形式。此时,采用Base64编码具有不可读性,即所编码的数据不会被人用肉眼所直接看到。" set base64 = new Base64_cls str_e = base64.Encode(str) response.write str_e&"
" str_d = base64.decode(str_e) response.write str_d set base64 = nothing %>
PHP版本:
...