📄 functions.asp
字号:
<%
'--------------------------判断用户名、代号和密码的合法性--------------------------
function symbol_name(sn_var)
dim safety_char:symbol_name="yes":sn_var=trim(sn_var)
if sn_var="" or isnull(sn_var) or len(sn_var)>20 or instr(sn_var,"|")>0 or instr(sn_var,":")>0 or instr(sn_var,chr(9))>0 or instr(sn_var,chr(32))>0 or instr(sn_var,"'")>0 or instr(sn_var,"""")>0 then symbol_name="no":exit function
safety_char=web_var(web_safety,1)
for i=1 to len(sn_var)
if instr(1,safety_char,mid(sn_var,i,1))>0 then symbol_name="no":exit function
next
end function
function symbol_ok(symbol_var)
dim safety_char:symbol_ok="yes":symbol_var=trim(symbol_var)
if symbol_var="" or isnull(symbol_var) or len(symbol_var)>20 then symbol_ok="no":exit function
safety_char=web_var(web_safety,2)
for i=1 to len(symbol_var)
if instr(1,safety_char,mid(symbol_var,i,1))=0 then symbol_ok="no":exit function
next
end function
'-------------------------------------字符处理--------------------------------------
function health_name(hnn)
health_name="yes":dim ti,tnum,tdim,hn
hn=hnn:tdim=split(web_var(web_safety,3),":"):tnum=ubound(tdim)
for ti=0 to tnum
if instr(hn,tdim(ti))>0 then health_name="no":erase tdim:exit function
next
erase tdim
tdim=split(web_var(web_safety,4),":"):tnum=ubound(tdim)
for ti=0 to tnum
if instr(hn,tdim(ti))>0 then health_name="no":erase tdim:exit function
next
erase tdim
end function
function health_var(hnn,vt)
dim ti,tj,tdim,ht,hn:hn=hnn
if int(mid(web_setup,4,1))=1 and vt=1 then
tdim=split(web_var(web_safety,4),":")
for ti=0 to ubound(tdim)
ht=""
for tj=1 to len(tdim(ti))
ht=ht&"*"
next
hn=replace(hn,tdim(ti),ht)
next
erase tdim
end if
health_var=hn
end function
'-------------------------------------错误信息--------------------------------------
function found_error(error_type,error_len)
if error_len>600 or error_len<200 then error_len=300
found_error=VbCrLf & "<table border=0 width=" & error_len & "><tr><td align=center height=50><font class=red>系统发现你输入的数据有以下错误:</font></td></tr><tr><td class=htd>" & error_type & "</td></tr><!--867446--><tr><td align=center height=50>" & go_back & "</td></tr></table>"
end function
'-------------------------------------地址处理--------------------------------------
function url_true(puu,pus)
dim puuu,pu:puuu=puu:pu=pus
if instr(1,pu,"://")<>0 then
url_true=pu
else
if right(puuu,1)<>"/" then puuu=puuu&"/"
url_true=puuu&pu
end if
end function
'-----------------------------------时间格式处理------------------------------------
Function time_type(tvar,tt)
dim ttt:ttt=tvar
if not(isdate(ttt)) then time_type="":exit function
select case tt
case 1 '10-10
time_type=month(ttt)&"-"&day(ttt)
case 11 '月-日
time_type=month(ttt)&"月"&day(ttt)&"日"
case 2 '年(2)-月-日 00-10-10
time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)
case 3 '2000-10-10
time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)
case 33 '年(4)-月-日
time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日"
case 4 '23:45
time_type=hour(ttt)&":"&minute(ttt)
case 44 '时:分
time_type=hour(ttt)&"时"&minute(ttt)&"分"
case 5 '23:45:36
time_type=hour(ttt)&":"&minute(ttt)&":"&second(ttt)
case 55 '时:分:秒
time_type=hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
case 6 '10-10 23:45
time_type=month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
case 66 '月-日 时:分
time_type=month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
case 7 '年(2)-月-日 时:分 00-10-10 23:45
time_type=right(year(ttt),2)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
case 8 '2000-10-10 23:45
time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)
case 88 '年(4)-月-日 时:分
time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"
case 9 '2000-10-10 23:45:45
time_type=year(ttt)&"-"&month(ttt)&"-"&day(ttt)&" "&hour(ttt)&":"&minute(ttt)&":"&second(ttt)
time_type=formatdatetime(time_type)
case 99 '年(4)-月-日 时:分:秒
time_type=year(ttt)&"年"&month(ttt)&"月"&day(ttt)&"日 "&hour(ttt)&"时"&minute(ttt)&"分"&second(ttt)&"秒"
case else
time_type=ttt
end select
end function
function upload_time(tt)
dim ttt:ttt=tt
ttt=replace(ttt,":",""):ttt=replace(ttt,"-","")
ttt=replace(ttt," ",""):ttt=replace(ttt,"/","")
ttt=replace(ttt,"PM",""):ttt=replace(ttt,"AM","")
ttt=replace(ttt,"上午",""):ttt=replace(ttt,"下午","")
upload_time=ttt
end function
'-------------------------------------字符处理--------------------------------------
function code_form(strers)
dim strer:strer=trim(strers)
If isNull(strer) or strer="" Then code_form="":exit function
strer=replace(strer,"'","""")
code_form=strer
end function
function code_word(strers)
dim strer:strer=trim(strers)
If isNull(strer) or strer="" Then code_word="":exit function
strer=replace(strer,"'","'")
code_word=strer
end function
function code_html(strers,chtype,cutenum)
dim strer:strer=strers
if isnull(strer) or strer="" then code_html="":exit function
strer=health_var(strer,1)
if cutenum>0 then strer=cuted(strer,cutenum)
strer=replace(strer,"<","<")
strer=replace(strer,">",">")
strer=replace(strer,chr(39),"'") '单引号
strer=replace(strer,chr(34),""") '双引号
strer=replace(strer,chr(32)," ") '空格
select case chtype
case 1
strer=replace(strer,chr(9)," ") 'table
strer=replace(strer,chr(10),"") '回车
strer=replace(strer,chr(13),"")
case 2
strer=replace(strer,chr(9)," ")'table
strer=replace(strer,chr(10),"<br>") '回车
strer=replace(strer,chr(13),"<br>")
end select
code_html=strer
end function
'------------------------------------字符分割--------------------------------------
function cuted(types,num)
dim ctypes,cnum,ci,tt,tc,cc,cmod
cmod=3
ctypes=types:cnum=int(num):cuted="":tc=0:cc=0
for ci=1 to len(ctypes)
if cnum<0 then cuted=cuted&"...":exit for
tt=mid(ctypes,ci,1)
if int(asc(tt))>=0 then
cuted=cuted&tt:tc=tc+1:cc=cc+1
if tc=2 then tc=0:cnum=cnum-1
if cc>cmod then cnum=cnum-1:cc=0
else
cnum=cnum-1
if cnum<=0 then cuted=cuted&"...":exit for
cuted=cuted&tt
end if
next
End Function
function lens(types)
dim ctypes,i,tc,cc,tt
ctypes=types:cc=len(ctypes)
for i=1 to len(ctypes)
tt=mid(ctypes,i,1)
if int(asc(tt))<0 then cc=cc+1
next
lens=cc
end function
function cuter(typess,nummers)
dim types:types=typess
if len(types)>nummers then
cuter=left(types,nummers) & "..."
else
cuter=types
end if
end function
'-----------------------------------随机N位数字-------------------------------------
function rand_num(rnum)
dim ri,rmax,rmin:rmax=1:rmin=1
for ri=1 to rnum+1
rmax=rmax*10
next
rmax=rmax-1
for ri=1 to rnum
rmin=rmin*10
next
Randomize
rand_num=int((rand_num-rmin+1)*RND)+rmin
end function
'-------------------------------判断发言是否来自外部-------------------------------
function post_chk()
dim server_v1,server_v2
post_chk="no"
server_v1=Request.ServerVariables("HTTP_REFERER")
server_v2=Request.ServerVariables("SERVER_NAME")
if mid(server_v1,8,len(server_v2))=server_v2 then post_chk="yes":exit function
end function
'------------------------------------邮件识别--------------------------------------
function email_ok(email)
dim names,name,i,c
email_ok="yes":names = Split(email, "@")
if UBound(names) <> 1 then email_ok="no":exit function
for each name in names
if Len(name) <= 0 then email_ok="no":exit function
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz-_.", c) <= 0 and not IsNumeric(c) then email_ok="no":exit function
next
if Left(name, 1) = "." or Right(name, 1) = "." then email_ok="no":exit function
next
if InStr(names(1), ".") <= 0 then email_ok="no":exit function
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then email_ok="no":exit function
if InStr(email, "..") > 0 then email_ok="no"
end function
'------------------------------------IP SYS--------------------------------------
function ip_sys(isu,iun) '0,*=ip_sys 1,0=ip 1,1=ip:port 2,*=port 3,*=sys
dim userip,userip2
select case isu
case 2
ip_sys=Request.ServerVariables("REMOTE_PORT")
case 3
ip_sys=Request.Servervariables("HTTP_USER_AGENT")
case else
userip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
userip2=Request.ServerVariables("REMOTE_ADDR")
if instr(userip,",")>0 then userip=left(userip,instr(userip,",")-1)
if instr(userip2,",")>0 then userip2=left(userip2,instr(userip2,",")-1)
if userip="" then
ip_sys=userip2
else
ip_sys=userip
end if
if isu=0 then ip_sys="您的真实IP是:" & ip_sys & ":" & Request.ServerVariables("REMOTE_PORT") & "," & view_sys(Request.Servervariables("HTTP_USER_AGENT")):exit function
if iun=1 then ip_sys=ip_sys&":"&Request.ServerVariables("REMOTE_PORT")
end select
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -