您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > ASP的自定义实用函数表(1)
ASP的自定义实用函数表(1)2004-9-206:55:00作者:模板天下收集整理来源:未知网友评论0条论坛'汉字判断functionisChinese(para)onerrorresumenextifisNUll(para)thenisChinese=falseexitfunctionendififtrim(para)=thenisChinese=falseexitfunctionendifdimcfori=1tolen(para)c=asc(mid(para,i,1))ifc=0thenisChinese=falseexitfunctionendifnextisChinese=trueiferr.number0thenerr.clearendfunction%如:ifnotisChinese(request(name))thenerrmsg=errmsg++li用户名应为汉字founderr=trueelseusername=trim(request(name))endif----------------------------------------------'替换指定文件内字符串的函数%functionFSOlineedit(filename,Target,String)DimobjFSO,objCountFile,FiletempDataSetobjFSO=Server.CreateObject(Scripting.FileSystemObject)SetobjCountFile=objFSO.OpenTextFile(Server.MapPath(filename),1,True)FiletempData=objCountFile.ReadAllobjCountFile.CloseFiletempData=Replace(FiletempData,Target,String)SetobjCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)objCountFile.WriteFiletempDataobjCountFile.CloseSetobjCountFile=NothingSetobjFSO=NothingEndFunctionresponse.writeFSOlineedit(test.txt,世界,明天是一个好天去)%----------------------------------------------'获取中文字符串拼音首字母串的函数%response.writelinkhref=style.cssrel=stylesheetifrequest.form(content)=thenresponse.writecenterformmethod=postaction=asd.aspinputname=contenttype=text__inputtype=submit/formelsefunctiongetpychar(char)tmp=65536+asc(char)if(tmp=45217andtmp=45252)thengetpychar=Aelseif(tmp=45253andtmp=45760)thengetpychar=Belseif(tmp=45761andtmp=46317)thengetpychar=Celseif(tmp=46318andtmp=46825)thengetpychar=Delseif(tmp=46826andtmp=47009)thengetpychar=Eelseif(tmp=47010andtmp=47296)thengetpychar=Felseif(tmp=47297andtmp=47613)thengetpychar=Gelseif(tmp=47614andtmp=48118)thengetpychar=Helseif(tmp=48119andtmp=49061)thengetpychar=Jelseif(tmp=49062andtmp=49323)thengetpychar=Kelseif(tmp=49324andtmp=49895)thengetpychar=Lelseif(tmp=49896andtmp=50370)thengetpychar=Melseif(tmp=50371andtmp=50613)thengetpychar=Nelseif(tmp=50614andtmp=50621)thengetpychar=Oelseif(tmp=50622andtmp=50905)thengetpychar=Pelseif(tmp=50906andtmp=51386)thengetpychar=Qelseif(tmp=51387andtmp=51445)thengetpychar=Relseif(tmp=51446andtmp=52217)thengetpychar=Selseif(tmp=52218andtmp=52697)thengetpychar=Telseif(tmp=52698andtmp=52979)thengetpychar=Welseif(tmp=52980andtmp=53640)thengetpychar=Xelseif(tmp=53689andtmp=54480)thengetpychar=Yelseif(tmp=54481andtmp=62289)thengetpychar=Zelse'如果不是中文,则不处理getpychar=charendifendfunctionfunctiongetpy(str)fori=1tolen(str)getpy=getpy&getpychar(mid(str,i,1))nextendfunctioncontent=request.form(content)response.writecenter&getpy(content)&chr(10)response.writebrbrbrahref=#onclick=javascript:history.go(-1)返回/aendif%--------------------------------------------ip限制函数'******************************'FunctionCheckIp(cInput_Ip,cBound_Ip)'Createdbyqqdao,qqdao@263.net2001/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_IpCheckIp=falsecSingle_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_IPthenCheckIp=falseexitfunctionendifendififInstr(cTemp_IP,-)=0thencStart_IP=cTemp_IPcEnd_Ip=cTemp_IPelsecStart_IP=left(cTemp_IP,instr(cTemp_IP,-)-1)cEnd_Ip=left(cStart_IP,InStrRev(cStart_IP,.)-1)+.+mid(cTemp_IP,instr(cTemp_IP,-)+1)endififIp2Str(cInput_Ip)=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)=Ip2Str(cEnd_Ip)thenCheckIp=falseexitfunctionendifelseifInstr(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_IPthenCheckIp=trueendifendififInstr(cTemp_IP,-)=0thencStart_IP=cTemp_IPcEnd_Ip=cTemp_IPelsecStart_IP=left(cTemp_IP,instr(cTemp_IP,-)-1)cEnd_Ip=left(cStart_IP,InStrRev(cStart_IP,.)-1)+.+mid(cTemp_IP,instr(cTemp_IP,-)+1)endififIp2Str(cInput_Ip)=Ip2Str(cStart_IP)andIp2Str(cInput_Ip)=Ip2Str(cEnd_Ip)thenCheckIp=trueelseCheckIp=falseendifendifnextendfunction'******************************'FunctionIp2Str(cIp)'Createdbyqqdao,qqdao@263.net2001/11/28'参考动网ip算法'参数:cIpip地址'返回值:转换后数值'******************************functionIp2Str(cIp)Dimstr1,str2,str3,str4DimcIp_TempifcIp=127.0.0.1thencIp=192.168.0.1str1=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)=0thenelseIp2Str=cint(str1)*256*256*256+cint(str2)*256
本文标题:ASP的自定义实用函数表(1)
链接地址:https://www.777doc.com/doc-6371279 .html