ASP的自定义实用函数表1精.docx
- 文档编号:11213871
- 上传时间:2023-02-25
- 格式:DOCX
- 页数:32
- 大小:25.49KB
ASP的自定义实用函数表1精.docx
《ASP的自定义实用函数表1精.docx》由会员分享,可在线阅读,更多相关《ASP的自定义实用函数表1精.docx(32页珍藏版)》请在冰豆网上搜索。
ASP的自定义实用函数表1精
ASP的自定义实用函数表
(1)
2004-9-206:
55:
00 作者:
模板天下收集整理 来源:
未知 网友评论0条 论坛
'汉字判断
functionisChinese(para)
onerrorresumenext
ifisNUll(para)then
isChinese=false
exitfunction
endif
iftrim(para)=""then
isChinese=false
exitfunction
endif
dimc
fori=1tolen(para)
c=asc(mid(para,i,1))
ifc>=0then
isChinese=false
exitfunction
endif
next
isChinese=true
iferr.number<>0thenerr.clear
endfunction
%>
如:
ifnotisChinese(request("name"))then
errmsg=errmsg+"
"+"
founderr=true
else
username=trim(request("name"))
endif
----------------------------------------------
'替换指定文件内字符串的函数
<%
functionFSOlineedit(filename,Target,String)
DimobjFSO,objCountFile,FiletempData
SetobjFSO=Server.CreateObject("Scripting.FileSystemObject")
SetobjCountFile=objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData=objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,String)
SetobjCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)
objCountFile.WriteFiletempData
objCountFile.Close
SetobjCountFile=Nothing
SetobjFSO=Nothing
EndFunction
response.writeFSOlineedit("test.txt","世界","明天是一个好天去")
%>
----------------------------------------------
'获取中文字符串拼音首字母串的函数
<%
response.write"
ifrequest.form("content")=""then
response.write"
else
functiongetpychar(char)
tmp=65536+asc(char)
if(tmp>=45217andtmp<=45252)then
getpychar="A"
elseif(tmp>=45253andtmp<=45760)then
getpychar="B"
elseif(tmp>=45761andtmp<=46317)then
getpychar="C"
elseif(tmp>=46318andtmp<=46825)then
getpychar="D"
elseif(tmp>=46826andtmp<=47009)then
getpychar="E"
elseif(tmp>=47010andtmp<=47296)then
getpychar="F"
elseif(tmp>=47297andtmp<=47613)then
getpychar="G"
elseif(tmp>=47614andtmp<=48118)then
getpychar="H"
elseif(tmp>=48119andtmp<=49061)then
getpychar="J"
elseif(tmp>=49062andtmp<=49323)then
getpychar="K"
elseif(tmp>=49324andtmp<=49895)then
getpychar="L"
elseif(tmp>=49896andtmp<=50370)then
getpychar="M"
elseif(tmp>=50371andtmp<=50613)then
getpychar="N"
elseif(tmp>=50614andtmp<=50621)then
getpychar="O"
elseif(tmp>=50622andtmp<=50905)then
getpychar="P"
elseif(tmp>=50906andtmp<=51386)then
getpychar="Q"
elseif(tmp>=51387andtmp<=51445)then
getpychar="R"
elseif(tmp>=51446andtmp<=52217)then
getpychar="S"
elseif(tmp>=52218andtmp<=52697)then
getpychar="T"
elseif(tmp>=52698andtmp<=52979)then
getpychar="W"
elseif(tmp>=52980andtmp<=53640)then
getpychar="X"
elseif(tmp>=53689andtmp<=54480)then
getpychar="Y"
elseif(tmp>=54481andtmp<=62289)then
getpychar="Z"
else'如果不是中文,则不处理
getpychar=char
endif
endfunction
functiongetpy(str)
fori=1tolen(str)
getpy=getpy&getpychar(mid(str,i,1))
next
endfunction
content=request.form("content")
response.write"
response.write" history.go(-1)>返回" endif %> -------------------------------------------- ip限制函数 '****************************** 'FunctionCheckIp(cInput_Ip,cBound_Ip) 'Createdbyqqdao,qqdao@2001/11/28 '说明: 首先需要根据;号循环,然后判断是否含有"-",如果有则进行拆分处理,最后判断是否在范围内 '参数: cInput_Ip,代检查的ip 'cBound_Ip,给定的范围格式为,单个ip,和范围ip,范围ip最后使用”-“分割,如果是“*”则必须放到最后一位 ' 每个范围后添加": ALLOW"表示允许登陆,添加": REFUSE"表示拒绝登陆。 多个范围用”;“隔开 ' 例如192.168.1*.*: ALLOW;192.168.1.1: ALLOW;192.168.1.1-10: REFUSE" '返回值: true/false '更新: 2001/12/05 支持ALLOW,REFUSE支持’*‘,不想对? 支持,因为和*差不多 '****************************** functionCheckIp(cInput_Ip,cBound_Ip) dimcSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip CheckIp=false cSingle_Ip=split(cBound_Ip,";") fori=0toubound(cSingle_Ip) ifInstr(cSingle_Ip(i),"REFUSE")<>0then '就是拒绝了 cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),": ")-1) ifInstr(cTemp_IP,"*")<>0then '是宽范围 cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1) ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen CheckIp=false exitfunction endif endif ifInstr(cTemp_IP,"-")=0then cStart_IP=cTemp_IP cEnd_Ip =cTemp_IP else cStart_IP=left(cTemp_IP,instr(cTemp_IP,"-")-1) cEnd_Ip =left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1) endif if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then CheckIp=false exitfunction endif elseifInstr(cSingle_Ip(i),"ALLOW")<>0then '允许 cTemp_IP=left(cSingle_Ip(i),instr(cSingle_Ip(i),": ")-1) ifInstr(cTemp_IP,"*")<>0then '是宽范围 cStart_IP=left(cTemp_IP,instr(cTemp_IP,"*")-1) ifleft(cInput_Ip,len(cStart_IP))=cStart_IPthen CheckIp=true endif endif ifInstr(cTemp_IP,"-")=0then cStart_IP=cTemp_IP cEnd_Ip =cTemp_IP else cStart_IP=left(cTemp_IP,instr(cTemp_IP,"-")-1) cEnd_Ip =left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1) endif if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)<=Ip2Str(cEnd_Ip)then CheckIp=true else CheckIp=false endif endif next endfunction '****************************** 'FunctionIp2Str(cIp) 'Createdbyqqdao,qqdao@2001/11/28 '参考动网ip算法 '参数: cIpip地址 '返回值: 转换后数值 '****************************** functionIp2Str(cIp) Dimstr1,str2,str3,str4 DimcIp_Temp ifcIp="127.0.0.1"thencIp="192.168.0.1" str1=left(cIp,instr(cIp,".")-1) cIp_Temp=mid(cIp,instr(cIp,".")+1) str2=left(cIp_Temp,instr(cIp_Temp,".")-1) cIp_Temp=mid(cIp_Temp,instr(cIp_Temp,".")+1) str3=left(cIp_Temp,instr(cIp_Temp,".")-1) str4=mid(cIp_Temp,instr(cIp_Temp,".")+1) ifisNumeric(str1)=0orisNumeric(str2)=0orisNumeric(str3)=0orisNumeric(str4)=0then else Ip2Str=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1 endif endfunction '代码调用演示 ifCheckIp("192.168.1.1","192.168.1.*: REFUSE")then response.write"登陆成功" else response.write"您的ip不被允许" endif cinput_ip就是要检查的ip,也就是Request.ServerVariables("REMOTE_ADDR") cbound_ip是范围,可以存到库里,范围的写法,我已详细说明了。 ---------------------------------------------- 汉字转化为拼音 很多问题都是因为中文问题造成的 如文件名最好别用中文 现在的解决方法一般是产生一个ID,将这个ID做文件名 网页上如果url带汉字也经常出错 现在的解决方法一般用urlencode编码 现在用了这个转化,就好多了 原理,使用Dictionary技术 1.添加索引 2.遍历词典 <% Setd=CreateObject("Scripting.Dictionary") d.add"a",-20319 d.add"ai",-20317 d.add"an",-20304 d.add"ang",-20295 d.add"ao",-20292 d.add"ba",-20283 d.add"bai",-20265 d.add"ban",-20257 d.add"bang",-20242 d.add"bao",-20230 d.add"bei",-20051 d.add"ben",-20036 d.add"beng",-20032 d.add"bi",-20026 d.add"bian",-20002 d.add"biao",-19990 d.add"bie",-19986 d.add"bin",-19982 d.add"bing",-19976 d.add"bo",-19805 d.add"bu",-19784 d.add"ca",-19775 d.add"cai",-19774 d.add"can",-19763 d.add"cang",-19756 d.add"cao",-19751 d.add"ce",-19746 d.add"ceng",-19741 d.add"cha",-19739 d.add"chai",-19728 d.add"chan",-19725 d.add"chang",-19715 d.add"chao",-19540 d.add"che",-19531 d.add"chen",-19525 d.add"cheng",-19515 d.add"chi",-19500 d.add"chong",-19484 d.add"chou",-19479 d.add"chu",-19467 d.add"chuai",-19289 d.add"chuan",-19288 d.add"chuang",-19281 d.add"chui",-19275 d.add"chun",-19270 d.add"chuo",-19263 d.add"ci",-19261 d.add"cong",-19249 d.add"cou",-19243 d.add"cu",-19242 d.add"cuan",-19238 d.add"cui",-19235 d.add"cun",-19227 d.add"cuo",-19224 d.add"da",-19218 d.add"dai",-19212 d.add"dan",-19038 d.add"dang",-19023 d.add"dao",-19018 d.add"de",-19006 d.add"deng",-19003 d.add"di",-18996 d.add"dian",-18977 d.add"diao",-18961 d.add"die",-18952 d.add"ding",-18783 d.add"diu",-18774 d.add"dong",-18773 d.add"dou",-18763 d.add"du",-18756 d.add"duan",-18741 d.add"dui",-18735 d.add"dun",-18731 d.add"duo",-18722 d.add"e",-18710 d.add"en",-18697 d.add"er",-18696 d.add"fa",-18526 d.add"fan",-18518 d.add"fang",-18501 d.add"fei",-18490 d.add"fen",-18478 d.add"feng",-18463 d.add"fo",-18448 d.add"fou",-18447 d.add"fu",-18446 d.add"ga",-18239 d.add"gai",-18237 d.add"gan",-18231 d.add"gang",-18220 d.add"gao",-18211 d.add"ge",-18201 d.add"gei",-18184 d.add"gen",-18183 d.add"geng",-18181 d.add"gong",-18012 d.add"gou",-17997 d.add"gu",-17988 d.add"gua",-17970 d.add"guai",-17964 d.add"guan",-17961 d.add"guang",-17950 d.add"gui",-17947 d.add"gun",-17931 d.add"guo",-17928 d.add"ha",-17922 d.add"hai",-17759 d.add"han",-17752 d.add"hang",-17733 d.add"hao",-17730 d.add"he",-17721 d.add"hei",-17703 d.add"hen",-17701 d.add"heng",-17697 d.add"hong",-17692 d.add"hou",-17683 d.add"hu",-17676 d.add"hua",-17496 d.add"huai",-17487 d.add"huan",-17482 d.add"huang",-17468 d.add"hui",-17454 d.add"hun",-17433 d.add"huo",-17427 d.add"ji",-17417 d.add"jia",-17202 d.add"jian",-17185 d.add"jiang",-16983 d.add"jiao",-16970 d.add"jie",-16942 d.add"jin",-16915 d.add"jing",-16733 d.add"jiong",-16708 d.add"jiu",-16706 d.add"ju",-16689 d.add"juan",-16664 d.add"jue",-16657 d.add"jun",-16647 d.add"ka",-16474 d.add"kai",-16470 d.add"kan",-16465 d.add"kang",-16459 d.add"kao",-16452 d.add"ke",-16448 d.add"ken",-16433
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ASP 自定义 实用 函数
![提示](https://static.bdocx.com/images/bang_tan.gif)