UtilClass.asp
上传用户:qfkgdy
上传日期:2020-06-18
资源大小:1888k
文件大小:33k
- <%
- Class UtilClass
- Dim pageEmpty,page,pagenum,paramname,num,psize,wpage,tagNum,positionNum
-
- Dim position()
- Private Sub Class_Initialize
- pageEmpty=true
- tagNum=0
- positionNum=0
- End Sub
-
- '星期
- Function week(w)
- select case w
- case 1:week="日"
- case 2:week="一"
- case 3:week="二"
- case 4:week="三"
- case 5:week="四"
- case 6:week="五"
- case 7:week="六"
- end select
- End Function
-
- '防止二次提交
- Function token(ByVal t)
- Dim s
- select case t
- case 0:'播种
- s=tsn
- session("token")=s
- token="<postfield name=""token"" value="""&s&""" />"
- case 1:'取种
- s=request("token")
- if(s=session("token")) then
- token=true
- session("token")=""
- end if
- end select
- End Function
-
- '是否为有效IP
- Function ipValid()
- if(ipType(ip)=0) then
- ipValid=false
- else
- ipValid=true
- end if
- End Function
-
- '判断IP类型
- Function ipType(sip)
- Dim intIp
- intIp=ipInt(sip)
-
- '移动IP段(211.103.0.0-211.103.127.255 211.136.0.0-211.143.255.255 218.200.0.0-218.207.255.255 221.130.0.0-221.131.255.255)
- if(intIp>=3546742784 and intIp<=3546775551) or (intIp>=3548905472 and intIp<=3549429759) or (intIp>=3670540288 and intIp<=3671064575) or (intIp>=3716284416 and intIp<=3716415487) then
- ipType=1
- '联通IP段(61.240.0.0-61.243.255.255 61.245.0.0-61.245.127.255 220.192.0.0-220.207.255.255 211.90.0.0-211.97.255.255)
- elseif(intIp>=1039138816 and intIp<=1039400959) or (intIp>=1039466496 and intIp<=1039499263) or (intIp>=3703570432 and intIp<=3704619007) or (intIp>=3545890816 and intIp<=3546415103) then
- ipType=2
- '其它
- else
- ipType=0
- end if
- End Function
-
- 'IP转换为数字
- Function ipInt(sip)
- if not(isnull(sip) or sip="") then
- on error resume next
- dim strIp,arrIp
- strIp=cstr(trim(sip))
- arrIp=split(strIp,".")
- ipInt=arrIp(0)*256*256*256+arrIp(1)*256*256+arrIp(2)*256+arrIp(3)
- if(err.number>0) then
- ipInt=0
- end if
- else
- ipInt=0
- end if
- End Function
-
- '对应表
- Function hashmap(ByVal t,ByVal v)
- select case t
- case 1:'搜索(性别)
- select case v
- case 1:hashmap="男"
- case 2:hashmap="女"
- case 3:hashmap="不限"
- end select
- case 2:'搜索(年龄)
- select case v
- case 1:hashmap="18-26"
- case 2:hashmap="26-35"
- case 3:hashmap="18岁以下"
- case 4:hashmap="35岁以上"
- case 5:hashmap="不限"
- end select
- end select
- End Function
-
- '根据后缀判断是否为图片
- Function isImage(ByVal suffix)
- if(instr("gif jpg png jpeg ",suffix&" ")>0) then
- isImage=true
- end if
- End Function
-
- '解析自定义标签
- Public Function parseTag(str)
- parseTag=parsePictureTag(str)
- parseTag=parseSoftTag(str)
- parseTag=parseGameTag(str)
- parseTag=parseThemeTag(str)
- parseTag=parseThreadTag(str)
- End Function
-
- '解析图片标签
- Public Function parsePictureTag(str)
- Set rx=reg("(p:([^() trn}]+))", True, True)
- Set objMatches = rx.Execute(str)
- For Each objMatch In objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,"<a href=""/picture/view.asp?id=$1"">免费高清下载此图片</a>"))
- Next
- Set rx = Nothing
- parsePictureTag=str
- End Function
-
- '解析软件标签
- Public Function parseSoftTag(str)
- Set rx=reg("(r:([^() trn}]+))", True, True)
- Set objMatches = rx.Execute(str)
- For Each objMatch In objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,"<a href=""/soft/view.asp?id=$1"">免费下载此软件</a>"))
- Next
- Set rx = Nothing
- parseSoftTag=str
- End Function
-
- '解析游戏标签
- Public Function parseGameTag(str)
- Set rx=reg("(y:([^() trn}]+))", True, True)
- Set objMatches = rx.Execute(str)
- For Each objMatch In objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,"<a href=""/game/view.asp?id=$1"">免费下载此游戏</a>"))
- Next
- Set rx = Nothing
- parseGameTag=str
- End Function
-
- '解析主题标签
- Public Function parseThemeTag(str)
- Set rx=reg("(z:([^() trn}]+))", True, True)
- Set objMatches = rx.Execute(str)
- For Each objMatch In objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,"<a href=""/theme/view.asp?id=$1"">免费下载此主题</a>"))
- Next
- Set rx = Nothing
- parseThemeTag=str
- End Function
-
- '解析帖子标签
- Public Function parseThreadTag(str)
- Set rx=reg("(t:([^() trn}]+))", True, True)
- Set objMatches = rx.Execute(str)
- For Each objMatch In objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,"<a href=""/bbs/thread.asp?tid=$1"">进入查看此贴</a>"))
- Next
- Set rx = Nothing
- parseThreadTag=str
- End Function
-
- '网址转换(兼容FLASH escape)
- Function URLEncode(ByVal u)
- URLEncode=replace(server.URLEncode(u),"+","%20")
- End Function
-
- '阿拉伯数字转中文数字
- Function corder(ByVal n)
- dim i,j,k,strlen,retval,x,y,z,str
- z=array("零","一","二","三","四","五","六","七","八","九")
- y=array("","十","百","千")
- x=Array("","万","亿","万万亿")
- strlen=len(n)
- str1=n
- for i=1 to strlen
- j=mid(str1,i,1)
- retval=retval&z(j)
- if(j>0) then retval=retval&y((strlen-i) mod 4)
- retval=replace(retval,z(0)&z(0),z(0))
- if((strlen-i) mod 4)=0 and right(retval,1)=z(0) then retval=left(retval,len(retval)-1)
- if((strlen-i) mod 4)=0 then retval=retval&x(int((strlen-i)/4))
- next
- if(left(retval,2)="一十") then retval="十" & right(retval,len(retval)-2)
- corder=retval
- End Function
- '帖子类型
- Function thread(is_top,is_comment,is_elite,is_attach,is_lock)
- if(is_top=1 or is_top=2) then thread=thread&"[顶]"
- if(is_comment=1) then thread=thread&"[荐]"
- if(is_elite=1) then thread=thread&"[精]"
- if(is_attach>0) then thread=thread&"[附]"
- if(is_lock=1) then thread=thread&"[锁]"
- End Function
-
- '是否
- Function whether(w)
- if(w=1) then
- whether="是"
- else
- whether="否"
- end if
- End Function
-
- '检查颜色代码
- Function color(c)
- dim regex
- set regex=new RegExp
- regex.pattern="^#?[0-9|a-f|A-F]{6}$"
- color=regex.test(c)
- End Function
-
- '检查手机号码
- Function mobile(m)
- dim regex
- set regex=new RegExp
- regex.pattern="^(130|131|132|133|134|135|136|137|138|139|159|158|156)d{8}$"
- mobile=regex.test(m)
- End Function
-
- '条件
- Function con(ByVal c1,c2,c3)
- if(c1) then
- con=c2
- else
- con=c3
- end if
- End Function
-
- '未知
- Function unknown(ByVal t1,t2,t3)
- if(t1=t2) then
- unknown=t3
- else
- unknown=t1
- end if
- End Function
-
- '血型
- Function stature(s)
- select case s
- case 1:stature="160-165cm"
- case 2:stature="165-170cm"
- case 3:stature="170-175cm"
- case 4:stature="175-180cm"
- case 5:stature="160cm以下"
- case 6:stature="180cm以上"
- end select
- End Function
-
- '血型
- Function blood(b)
- select case b
- case 1:blood="A"
- case 2:blood="B"
- case 3:blood="AB"
- case 4:blood="O"
- case else:blood="未知"
- end select
- End Function
-
- '星座
- Function constellation(c)
- select case c
- case 1:constellation="水瓶座"
- case 2:constellation="双鱼座"
- case 3:constellation="白羊座"
- case 4:constellation="金牛座"
- case 5:constellation="双子座"
- case 6:constellation="巨蟹座"
- case 7:constellation="狮子座"
- case 8:constellation="处女座"
- case 9:constellation="天秤座"
- case 10:constellation="天蝎座"
- case 11:constellation="射手座"
- case 12:constellation="魔蝎座"
- case else:constellation="未知"
- end select
- End Function
-
- '生肖
- Function zodiac(z)
- select case z
- case 1:zodiac="鼠"
- case 2:zodiac="牛"
- case 3:zodiac="虎"
- case 4:zodiac="兔"
- case 5:zodiac="龙"
- case 6:zodiac="蛇"
- case 7:zodiac="马"
- case 8:zodiac="羊"
- case 9:zodiac="猴"
- case 10:zodiac="鸡"
- case 11:zodiac="狗"
- case 12:zodiac="猪"
- case else:zodiac="未知"
- end select
- End Function
-
- '学历
- Function education(e)
- select case e
- case 1:education="中学"
- case 2:education="大专"
- case 3:education="大学本科"
- case 4:education="双学士"
- case 5:education="硕士"
- case 6:education="博士"
- case else:education="未知"
- end select
- End Function
-
- '婚姻
- Function marriage(m)
- select case m
- case 1:marriage="未婚"
- case 2:marriage="已婚"
- case else:marriage="未知"
- end select
- End Function
-
- '资源名称
- Function resource(ByVal t,ByVal gid)
- if(t=0) then'中文
- select case gid
- case 1:resource="图片"
- case 2:resource="软件"
- case 3:resource="游戏"
- case 4:resource="主题"
- case 10:resource="贴子"
- end select
- else'英文
- select case gid
- case 1:resource="picture"
- case 2:resource="soft"
- case 3:resource="game"
- case 4:resource="theme"
- case 10:resource="thread"
- end select
- end if
- End Function
-
- '显示文件后缀
- Function ftype(f)
- ftype=split(f,".")(1)
- End Function
-
- '显示文件大小
- Function fsize(f)
- fsize=clng(f/1024)&"K"
- End Function
-
- '格式化生日
- Function birthday(b)
- if(b="") then
- birthday="1900-01-01"
- else
- birthday=left(b,4)&"-"&mid(b,5,2)&"-"&mid(b,7,2)
- end if
- End Function
-
- '检查生日格式
- Function isBirthday(b)
- if(isDate(birthday(b))) then
- isBirthday=true
- end if
- End Function
-
- '地区
- Function area(a)
- a=trim(a)
- if(a="" or a=",") then
- area="地区不详"
- else
- area=a
- end if
- End Function
-
- '年龄
- Function age(a)
- if(isDate(a)) then
- if(a="1900-1-1") then
- age="年龄不详"
- else
- age=dateDiff("yyyy",a,date())&"岁"
- end if
- else
- age="年龄不详"
- end if
- End Function
-
- '性别
- Function sex(s)
- select case s
- case 1:sex="男"
- case 2:sex="女"
- case else:sex="未知"
- end select
- End Function
-
- 'WAP TAB
- Sub tab(a,b,c,d,e)
- if(a=b) then
- response.Write(c)
- else
- response.Write("<a href="""&d&b&""">"&c&"</a>")
- end if
- response.Write(e)
- End Sub
-
- '格式化后日期
- Function d()
- d=convertDate(date,0)
- End Function
-
- '格式化后日期时间
- Function dt()
- dt=convertDateTime(date)
- End Function
-
- '将一个一位的数字前面加零
- Function fillZero(str)
- ttt=str
- if len(str)=1 then
- ttt="0" & str
- end if
- fillZero=ttt
- End Function
- '转化日期,将 一位补上零 2003-1-2 --> 2003-01-02
- Function convertDate(tDate,m)
- ttt=tDate
- if isdate(tDate) then
- ttt=year(tDate) & "-" & fillZero(month(tDate))
- if(m<>1) then
- ttt=ttt & "-" & fillZero(day(tDate))
- end if
- end if
- convertDate=ttt
- End Function
- '输入一个日期时间串,转换成年四位,其他两位的新的日期时间串
- Function convertDateTime(tDateTime)
- ttt=tDateTime
- if isdate(tDateTime) then
- ttt=year(tDateTime) & "-" & fillZero(month(tDateTime)) & "-" & fillZero(day(tDateTime)) & " " & fillZero(cstr(hour(tDateTime))) & ":" & fillZero(cstr(minute(tDateTime))) & ":" & fillZero(cstr(second(tDateTime)))
- end if
- convertDateTime=ttt
- End Function
-
- '格式化RS
- Sub list(ByVal rs,cols,str,style,row_num,splitter,prefix,suffix)
- Dim li
- li=0
- Dim arrCols,url,title
- Dim link,arrLink
- if not rs.eof then
- if(prefix<>"") then
- response.Write(prefix&"<br/>")
- end if
- do while not rs.eof
- li=li+1
- link=str
- arrCols=split(cols,",")
- for i=0 to ubound(arrCols)
- link=replace(link,"{"&arrCols(i)&"}",rs(arrCols(i)))
- next
- arrLink=split(link,"|")
- if(ubound(arrLink)>1) then
- response.Write(arrLink(2))
- end if
- response.Write("<a href="""&arrLink(0)&""">"&arrLink(1)&"</a>")
- if(style=1) then
- response.Write("<br/>")
- else
- if((li mod row_num)=0) then
- response.Write("<br/>")
- else
- if(li<>rs.recordcount) then response.Write(splitter)
- end if
- end if
- rs.movenext
- loop
- if((li mod row_num)<>0) then response.Write("<br/>")
- if(suffix<>"") then
- response.Write(suffix&"<br/>")
- end if
- end if
- rs.close
- if(style=1) then
- if((li mod row_num)<>0) then
- response.Write("<br/>")
- end if
- end if
- End Sub
-
- '输出排序样式
- Function oc(ByVal action,column)
- if(action.by=column) then
- oc=action.order
- end if
- End Function
-
- '格式化网址
- Function formatUrl(ByVal url,ftype)
- url=trim(url)
- select case ftype
- case 0:
- url=replace(url,"http://","")
- formatUrl=url
- case 1:
- if(instr(url,"http://")>0) then
- formatUrl=url
- else
- formatUrl="http://"&url
- end if
- end select
- formatUrl=replace(formatUrl,"&","&")
- formatUrl=replace(formatUrl,"&","&")
- End Function
-
- '判断用户权限
- Function inDomains(ByVal domains,sid)
- if(instr(","&domains&",",","&sid&",")>0) then
- inDomains=true
- else
- inDomains=false
- end if
- End Function
-
- '正则
- Function reg(spattern,bglobal,bignorecase)
- Dim rx
- Set rx=New RegExp
- rx.Pattern=spattern
- rx.Global=bglobal
- rx.IgnoreCase=bignorecase
- Set reg=rx
- Set rx=nothing
- End Function
- '手机号码中间3位显示*
- Function safeMobile(ByVal mobile)
- safeMobile=left(mobile,3)&"***"&right(mobile,5)
- End Function
-
- '直接输出下载文件
- Sub download(ByVal mime,filename,output)
- Call response.addHeader("content-type",mime)
- Call response.addHeader("Content-Disposition","attachment;filename="&filename)
- response.write(output)
- response.end()
- End Sub
-
- '数组是否存在项目中
- Function arrInstr(ByVal arr,value)
- if(isArray(arr)) then
- for i=0 to ubound(arr)
- if(instr(trim(value),arr(i))>0) then
- arrInstr=true
- exit function
- end if
- next
- end if
- End function
-
- '项目是否存在数组中
- Function inArray(ByVal arr,value)
- if(isArray(arr)) then
- for i=0 to ubound(arr)
- if(trim(arr(i))=trim(value)) then
- inArray=true
- exit function
- end if
- next
- end if
- End function
-
- 'ceil
- Function ceil(ByVal value)
- If(value>0) then
- value=FIX(value)+Sgn(value-FIX(value))
- Else
- value=FIX(value)
- End If
- ceil=value
- End function
-
- '验证EMAIL是否合法
- Function checkEmail(ByVal email)
- Dim re,pat
- Set re=New RegExp
- pat="^[w-.]{1,}@([da-zA-Z-]{1,}.){1,}[da-zA-Z-]{2,3}$"
- re.pattern=pat
- re.ignoreCase=true
- checkEmail=re.Test(email)
- End Function
- '验证IMEI是否合法
- Function checkImei(ByVal imei)
- Dim re,pat
- Set re=New RegExp
- pat="^3d{14}$"
- re.pattern=pat
- re.ignoreCase=true
- checkImei=re.Test(imei)
- End Function
- '判断checkbox中第一项值是否为key
- Function singleCheck(ByVal str,key)
- singleCheck=false
- Dim checkArr
- checkArr=split(str,",")
- if(ubound(checkArr)>=0) then
- if(checkArr(0)=key) then
- singleCheck=true
- end if
- end if
- End Function
-
- '循环打印字符串
- Function loopStr(ByVal loops,str)
- loopStr=""
- for i=1 to loops
- loopStr=loopStr&str
- next
- End Function
-
- '获取访问来源(支持REFERER与URL)
- 'urlParam为url时为相对地址
- Function getRefer(ByVal urlParam)
- Dim reUrl
- reUrl=request.ServerVariables("HTTP_REFERER")
- urlParam=trim(urlParam)
- if(urlParam<>"") then
- Dim urlValue
- urlValue=trim(request(urlParam))
- if(urlValue<>"") then
- reUrl=urlValue
- end if
- end if
- getRefer=reUrl
- End Function
-
- '清理所有COOKIE记录
- Function clearCookies()
- for each cookie in request.Cookies
- if not (request.Cookies(cookie).hasKeys) then
- response.Cookies(cookie)=empty
- else
- for each subkey in request.Cookies(cookie)
- response.Cookies(cookie)(subkey)=empty
- next
- end if
- next
- End Function
-
- '获取重写URL
- Function getRewriteUrl(inputStr,patStr)
- Dim regex,matches,match
- Set regex=new RegExp
- regex.ignoreCase=true
- regex.global=true
- regex.pattern=patStr
- Set matches=regex.execute(inputStr)
- Dim mValue,pName,pValue
- for each match in matches
- mValue=match.value
- pName=replace(mValue,"(","")
- pName=replace(pName,")","")
- pValue=request.QueryString(pName)
- inputStr=replace(inputStr,mValue,pValue)
- next
- Set match=nothing
- Set matches=nothing
- Set regex=nothing
- getRewriteUrl=inputStr
- End Function
-
- '获取textarea内容
- Function getTextarea(ByVal content)
- if(not isnull(content)) then
- getTextarea=replace(content,vbcrlf,"<br>")
- getTextarea=replace(getTextarea," "," ")
- end if
- End Function
-
- '将textarea内容按行转换为数组
- Function getTextareaArr(ByVal content)
- if(not isnull(content)) then
- getTextareaArr=split(content,vbcrlf)
- end if
- End Function
-
- '将数组转换为textarea
- Function setTextarea(ByVal arr)
- Dim asize
- asize=ubound(arr)-1
- for i=0 to asize
- setTextarea=setTextarea&arr(i)
- if(i<>asize) then
- setTextarea=setTextarea&vbcrlf
- end if
- next
- End Function
-
- '获取客户端IP地址
- Function ip()
- ip=request.ServerVariables("REMOTE_ADDR")
- End Function
-
- '密码加密
- Function password(ByVal psw)
- psw=psw&SECURITY_ENCRYPT_KEY
- password=md5(psw,32)
- End Function
-
- '时间字符串
- Function tsn()
- tsn=year(date())&month(date())&day(date())&hour(now())&minute(now())&second(now())
- End Function
-
- '生成全局唯一识别码
- Function sn(ByVal v)
- randomize
- v=int(rnd*10000000)&tsn&ip&v
- sn=md5(v,16)
- sn=ucase(sn)
- End Function
- '生成随机数
- Function rndc()
- randomize
- vcc=int(rnd*10000000)
- rndc=md5(vcc,16)
- End Function
- '获取日期数组
- Function getDateArr(ByVal datetime)
- Dim dateArr(3)
- dateArr(0)=year(datetime)
- dateArr(1)=month(datetime)
- dateArr(2)=day(datetime)
- dateArr(3)=getDate(datetime)
- getDateArr=dateArr
- End Function
-
- '昨天日期
- Function getYesterday()
- Dim daTemp
- daTemp=getDateArr(datetime)
- getYesterday=daTemp(0)&"-"&daTemp(1)&"-"&dateArr(2)
- End Function
-
- '获取日期
- Function getDate(ByVal datetime)
- getDate=split(datetime," ")(0)
- End Function
-
- '对比时间
- Function compareDate(ByVal datetime1,datetime2)
- if(getDate(datetime1)=getDate(datetime2)) then
- compareDate=true
- else
- compareDate=false
- end if
- End Function
-
- '产生随机表单名
- Function formId(ByVal input)
- Randomize
- formId=input&int(rnd*10000000)&tsn
- End Function
-
- '调用翻页(普通)
- Function pager(ByVal rs,pagesize,pn)
- paramname=pn
- if(paramname="") then
- paramname=PAGER_PARAM
- end if
- pagerTemp=0
- If rs.recordcount>0 Then
- pageEmpty=false
- rs.pagesize = pagesize
- psize = pagesize
- num=rs.recordcount
- pagenum=rs.pagecount
- page=request(paramname)
- If page <> "" then
- if not isnumeric(page) then
- page=0
- end if
- page = clng(page)
- if err.number <> 0 then
- err.clear
- page = 1
- end if
- if page < 1 then
- page = 1
- end if
- else
- page = 1
- End if
- if page*rs.pagesize > num and not((page-1)*rs.pagesize < num)then
- page=1
- end if
- rs.absolutepage = page
- if page<>pagenum then
- lablenum=rs.pagesize
- else
- lablenum=num-(page-1)*rs.pagesize
- end If
- pagerTemp=lablenum
- End If
-
- pager=pagerTemp
- End Function
- '调用翻页(对象)
- Function pagerObject(ByVal list,pagesize,pn)
- Dim nums(2)
- psize=pagesize
- paramname=pn
- if(paramname="") then
- paramname=PAGER_PARAM
- end if
- num=ubound(list)
- pagenum=ceil(num/psize)
- if(num>0) then
- pageEmpty=false
- page=request(paramname)
- page=limitLng(page,1,"")
- if(page>pagenum) then
- page=pagenum
- end if
- nums(0)=(page-1)*psize
- if(page<>pagenum) then
- nums(1)=page*psize
- else
- nums(1)=num
- end if
- end if
- pagerObject=nums
- End Function
-
- '调用翻页(存储过程)
- Sub pagerCommand(ByVal rc,pc,pn)
- paramname=pn
- if(paramname="") then
- paramname=PAGER_PARAM
- end if
- num=rc
- pagenum=pc
- if(num>0) then
- pageEmpty=false
- page=request(paramname)
- page=limitLng(page,1,"")
- if(page>pagenum) then
- page=pagenum
- end if
- end if
- End Sub
-
- '调用翻页(文字)
- Function pagerText(ByVal text,wsize,pn)
- paramname=pn
- if(paramname="") then
- paramname=PAGER_PARAM
- end if
- Dim wp,sw,ew,wlen
- page=limitInt(request(paramname),1,"")
- num=len(text)
- if(num>0) then
- pageEmpty=false
- wlen=len(text)
- pagenum=ceil(wlen/wsize)
- if (page=1) then
- sw=1
- else
- sw=(page-1)*wsize
- end if
- ew=wsize
- pagerText=mid(text,sw,ew)
- end if
- End Function
-
- '显示翻页
- Function paginate(ByVal ptype,url,rewrite)
- if (not pageEmpty) and (pagenum>1) Then
- Dim ut,ul,up,preUrl,sufUrl
- if(rewrite) then
- ut=PAGER_PARAM_COMMAND
- ul=len(url)
- up=instr(url,ut)
- preUrl=left(url,up-1)
- sufUrl=right(url,ul-up-len(ut)+1)
- else
- preUrl=getPage&"?"¶mname&"="
- if(url<>"") then
- if(ptype=0 or ptype=2 or ptype=3) then
- url="&"&url
- else
- url="&"&url
- end if
- end if
- sufUrl=url
- end if
- Select Case ptype
- Case 0: 'WML
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&(page+1)&sufUrl&""">下页</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&(page-1)&sufUrl&""">上页</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&"1"&sufUrl&""">首页</a> "
- end if
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&pagenum&sufUrl&""">末页</a> "
- end if
- paginate=paginate&" "&num&"条"
- if pagenum<>1 then
- paginate=paginate&"<br/>"
- end if
- paginate=paginate&page&"/"&pagenum&"页"
- Dim inputName
- inputName=formId(paramname)
- paginate=paginate&" 至<input name="""&inputName&""" format=""*N"" value="""" size=""3"" emptyok=""true"" />页 <anchor title=""跳转"">跳转<go href="""&getUrl(paramname)&""" method=""get""><postfield name="""¶mname&""" value=""$("&inputName&")"" /></go></anchor><br/>"
- Case 1: 'HTML
- if page<>pagenum then
- paginate=paginate&"<div class=""button"" onMouseOver=""this.className='button button-hover'"" onMouseOut=""this.className='button'"" onclick=""go('"&preUrl&(page+1)&sufUrl&"');"" style=""float:right"" title=""下一页""><span class=""left""></span><span class=""center""><span class=""icon next""></span></span><span class=""right""></span></div>"
- end if
- paginate=paginate&"<div style=""float:right; padding-left:4px; padding-right:4px;""><select onchange=""go('"&preUrl&"'+this.value+'"&sufUrl&"');"">"
- for i=1 to pagenum
- paginate=paginate&"<option value="""&i&""" "
- if(i=page) then
- paginate=paginate&"selected=""selected"""
- end if
- paginate=paginate&"> "&i&" / "&pagenum&" </option>"
- next
- paginate=paginate&"</select></div>"
- if page<>1 then
- paginate=paginate&"<div class=""button"" onMouseOver=""this.className='button button-hover'"" onMouseOut=""this.className='button'"" onclick=""go('"&preUrl&(page-1)&sufUrl&"');"" style=""float:right"" title=""上一页""><span class=""left""></span><span class=""center""><span class=""icon prev""></span></span><span class=""right""></span></div>"
- end if
- Case 2: '内容翻页
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&(page+1)&sufUrl&""">下页("&(page+1)&"/"&pagenum&")</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&(page-1)&sufUrl&""">上页"
- if(page=pagenum) then
- paginate=paginate&"("&(page-1)&"/"&pagenum&")"
- end if
- paginate=paginate&"</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&"1"&sufUrl&""">首</a> "
- end if
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&pagenum&sufUrl&""">末</a> "
- end if
- if pagenum<>1 then paginate=paginate&"<br/>"
- Case 3: '组图翻页
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&(page+1)&sufUrl&""">下张("&(page+1)&"/"&pagenum&")</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&(page-1)&sufUrl&""">上张"
- if(page=pagenum) then
- paginate=paginate&"("&(page-1)&"/"&pagenum&")"
- end if
- paginate=paginate&"</a> "
- end if
- if page<>1 then
- paginate=paginate&"<a href="""&preUrl&"1"&sufUrl&""">首</a> "
- end if
- if page<>pagenum then
- paginate=paginate&"<a href="""&preUrl&pagenum&sufUrl&""">末</a> "
- end if
- if pagenum<>1 then
- paginate=paginate&" 共"&num&"张"
- paginate=paginate&"<br/>"
- end if
- End Select
- End if
- End Function
-
- '字符串字节长度
- Function length(ByVal str)
- dim lenStr
- lenStr=0
- lenTemp=len(str)
- dim strTemp
- for i=1 to lenTemp
- strTemp=asc(mid(str,i,1))
- if strTemp>255 or strTemp<=0 then
- lenStr=lenStr+2
- else
- lenStr=lenStr+1
- end if
- next
- length=lenStr
- End Function
-
- '判断是否为int
- Function isInt(ByVal str)
- if not isnumeric(str) or len(str)>5 then
- isInt=false
- exit function
- elseif len(str)<5 then
- isInt=true
- exit function
- end if
- if cint(left(str,4))>3276 then
- isInt=false
- exit function
- elseif cint(left(str,4))=3276 and cint(right(str,1))>7 then
- isInt=false
- exit function
- else
- isInt=true
- exit function
- end if
- End Function
- '判断是否为lng
- Function isLng(ByVal str)
- if not isnumeric(str) or len(str)>10 then
- isLng=false
- exit function
- elseif len(str)<10 then
- isLng=true
- exit function
- end if
- if clng(left(str,9))>214748364 then
- isLng=false
- exit function
- elseif clng(left(str,9))=214748364 and clng(right(str,1))>7 then
- isLng=false
- exit function
- else
- isLng=true
- exit function
- end if
- End Function
- '限制int范围
- Function limitInt(ByVal num,min,max)
- if(isInt(num)) then
- num=cint(num)
- else
- num=0
- end if
- if(min="") then
- min=-32768
- end if
- if(max="") then
- max=32767
- end if
- if(num<min) then
- limitInt=min
- elseif(num>max) then
- limitInt=max
- else
- limitInt=num
- end if
- End Function
-
- '限制lng范围
- Function limitLng(ByVal num,min,max)
- if(isLng(num)) then
- num=clng(num)
- else
- num=0
- end if
- if(min="") then
- min=-2147483648
- end if
- if(max="") then
- max=2147483647
- end if
- if(num<min) then
- limitLng=min
- elseif(num>max) then
- limitLng=max
- else
- limitLng=num
- end if
- End Function
-
- '限制boolean范围
- Function limitBool(ByVal str)
- limitBool=false
- if(str<>"") then
- if(isnumeric(str)) then
- if(str=true) then
- limitBool=true
- exit function
- end if
- else
- if(lcase(str)="true") then
- limitBool=true
- exit function
- end if
- end if
- end if
- End Function
-
- '限制float范围
- Function limitFloat(ByVal num,min,max)
- if(min="") then
- min=-2147483648
- end if
- if(max="") then
- max=2147483647
- end if
- if(isLng(num)) then
- if(clng(num)<=min) then
- limitFloat=min
- elseif(clng(num)>=max) then
- limitFloat=max
- else
- limitFloat=num
- end if
- else
- limitFloat=min
- end if
- End Function
-
- '截取字符串
- Function cut(str,strLen,symbol)
- str=trim(str)
- if length(str)>strLen then
- cut=left(str,strLen-1)&symbol
- else
- cut=str
- end if
- End Function
-
- '字符过滤函数
- Function filter(ByVal fType,str)
- select case fType
- case "sql":'过滤SQL
- if str="" then exit function
- str=replace(str,chr(34),"")
- str=replace(str,chr(39),"")
- case "html":'过滤HTML标签
- dim objRegExp,match,matches,newStr,i
- Set objRegExp=new Regexp
- objRegExp.ignoreCase=true
- objRegExp.global=true
- objRegExp.pattern="<.+?>"
- Set matches=objRegExp.Execute(str)
- for each match in matches
- str=Replace(str,match.Value,"")
- next
- Set objRegExp=nothing
- case "wml":'过滤非法WML字符
- str=replace(str,"&","&")
- str=replace(str,">",">")
- str=replace(str,"<","<")
- str=replace(str,"""",""")
- str=replace(str,"{","")
- str=replace(str,"}","")
- str=replace(str,"[","")
- str=replace(str,"]","")
- '过滤乱码
- for i=1 to len(str)
- bitStr=mid(str,i,1)
- ascNum=ascw(bitStr)
- if ascNum>=0 and ascNum<=31 then
- bitStr=""
- end if
- newStr=newStr&bitStr
- next
- str=newStr
- '过滤默认表单值
- set rx=reg("$(([^)]*))",true,true)
- set objMatches=rx.execute(str)
- for each objMatch in objMatches
- str=replace(str,objMatch.Value,rx.replace(objMatch.Value,""))
- next
- set rx=nothing
- end select
- filter=str
- End Function
- '获取HTTP请求参数值
- Function req(ByVal fieldname,filters)
- Dim fieldvalue
- fieldvalue=request(fieldname)
- Dim filterArr
- filterArr=split(filters,"|")
- for i=0 to UBound(filterArr)
- fieldvalue=filter(filterArr(i),fieldvalue)
- next
- req=trim(fieldvalue)
- End Function
-
- '获取当前文件名
- Function getPage()
- getPage=CStr(Request.ServerVariables("SCRIPT_NAME"))
- End Function
-
- '获取分页URL,param为page名称
- Function getUrl(ByVal param)
- Dim a,b,c,d,e
- a=getPage&"?"&request.QueryString
- e="&"
- b=split(a,e)
- for i=0 to ubound(b)
- if(b(i)<>"") then
- c=split(b(i),"=")
- if(c(0)<>param) then
- d=d&b(i)&"&"
- end if
- end if
- next
- if(right(d,5)="&") then
- d=left(d,len(d)-5)
- end if
- if(right(d,1)="?") then
- d=left(d,len(d)-1)
- end if
- getUrl=replace(replace(d,param&"="&request.QueryString(param),""),"?&","?")
- End Function
-
- '获取URL参数的值
- Function getUrlValue(ByVal param,url)
- Dim a,b,c,d,e,f
- a=url
- c="?"
- e="&"
- b=split(a,c)
- if Ubound(b)>0 then
- d=b(1)
- b=split(d,e)
- for i=0 to ubound(b)
- if(b(i)<>"") then
- f=split(b(i),"=")
- if(f(0)=param) then
- getUrlValue=f(1)
- exit function
- end if
- end if
- next
- end if
- End Function
-
- '格式化时间
- Function formatTime(ByVal t,tType)
- dim yy,mm,dd,hh,min,sec
- yy=right(year(t),2)
- fyy=year(t)
- mm=month(t)
- dd=day(t)
- hh=hour(t)
- min=minute(t)
- sec=second(t)
- if mm<10 then
- fmm="0"&mm
- else
- fmm=mm
- end if
- if dd<10 then
- fdd="0"&dd
- else
- fdd=dd
- end if
- if hh<10 then
- fhh="0"&hh
- else
- fhh=hh
- end if
- if min<10 then
- fmin="0"&min
- else
- fmin=min
- end if
- if sec<10 then
- fsec="0"&sec
- else
- fsec=sec
- end if
- Select Case tType
- Case 1: formatTime=mm&"-"&dd&" "&hh&":"&min
- Case 2: formatTime=yy&"-"&mm&"-"&dd&" "&hh&":"&min
- Case 3: formatTime=fyy&fmm
- Case 4: formatTime=yy&fmm&fdd
- Case 5: formatTime=yy&fmm&fdd&hh&min
- Case 6: formatTime=fyy&"-"&fmm
- Case 7: formatTime=fyy&"年"&fmm&"月"
- Case 8: formatTime=fmm&"月"&fdd&"日"
- Case 9: formatTime=fyy&"年"&fmm&"月"&fdd&"日"
- Case 10: formatTime=fyy&fmm&fdd
- Case 11: formatTime=fmm&"-"&fdd
- Case 12: formatTime=fmm&"-"&fdd&" "&hh&":"&fmin
- Case 13: formatTime=fyy&"年"&fmm&"月"&fdd&"日"&" "&hh&":"&fmin
- Case 14: formatTime=fyy&"-"&fmm&"-"&fdd
- Case 15: formatTime=fyy&fmm&fdd&fhh&fmin&fsec
- Case 16: formatTime=fyy&"-"&fmm&"-"&fdd&" "&fhh&":"&fmin&":"&fsec
- Case 17: formatTime=fhh&":"&fmin
- Case 18: formatTime=fmm&fdd
- End Select
- End Function
-
- '返回时间字符串
- Function returnTime(ByVal str,tType)
- yy="20"&left(str,2)
- mm=mid(str,3,2)
- dd=right(str,2)
- Select Case tType
- Case 1:
- returnTime=yy&"-"&mm&"-"&dd
- End Select
- End Function
-
- '获取导航项目
- Function getNav(ByVal columns)
- Dim navList,navArr,nli,nls,navigation
- navList=split(columns,"|")
- nls=UBound(navList)
- for nli=0 to nls
- if(navList(nli)<>"") then
- navArr=split(navList(nli),",")
- if(navArr(1)<>"") then
- navigation=navigation&"<a href="""&navArr(1)&""">"&navArr(0)&"</a>"
- else
- navigation=navigation&navArr(0)
- end if
- if(nli<>nls) then
- if(navArr(0)<>"") then
- navigation=navigation&">"
- end if
- end if
- end if
- next
- getNav=navigation
- End Function
-
- '网站导航
- Sub nav(ByVal params)
- Dim navStr
- navStr="首页,/index.asp"
- if(params<>"") then
- navStr=navStr&"|"¶ms
- end if
- response.Write("--------------------<br/>")
- response.Write(getNav(navStr))
- response.Write("<br/>本站资源全部免费!")
- End Sub
-
- '网站导航
- Sub navs(ByVal params)
- Dim navStr
- navStr="首页,/index.asp"
- if(params<>"") then
- navStr=navStr&"|"¶ms
- end if
- response.Write("--------------------<br/>")
- response.Write("<img src=""/Clear_temporary_files.Asp"" alt="".""/>")
- response.Write(getNav(navStr))
- 'response.Write("<br/>QQ:84554888")
- 'response.Write("<br/>书签:<a href='wapck_com.SIS'>" & Request.ServerVariables("HTTP_HOST")) & "</a>"
- End Sub
-
- Sub antinav()
- if(not session("antinav")) then
- if(util.req("simulator","")="true") then
- session("antinav")=true
- end if
- end if
- if(not session("antinav")) then
- browsers=Lcase(Left(Request.ServerVariables("HTTP_USER_AGENT"),4))
- if browsers="oper" or browsers="winw" or browsers="wapi" or browsers="mc21" or browsers="up.b" or browsers="upg1" or browsers="upsi" or browsers="qwap" or browsers="jigs" or browsers="java" or browsers="alca" or browsers="wapj" or browsers="fetc" or browsers="r380" or browsers="mozi" or browsers="mozi" or browsers="cdr/" then
- response.redirect "http://127.0.0.1"
- end if
- end if
- End Sub
-
- Private Sub Class_Terminate
-
- End Sub
-
- End Class
- %>