📄 char.asp
字号:
<%
dim WINNT_CHINESE
function strLength(str)
ON ERROR RESUME NEXT
dim WINNT_CHINESE
WINNT_CHINESE = (len("同学录")=3)
if WINNT_CHINESE then
dim l,t,c
dim i
l=len(str)
t=l
for i=1 to l
c=asc(mid(str,i,1))
if c<0 then c=c+65536
if c>255 then
t=t+1
end if
next
strLength=t
else
strLength=len(str)
end if
if err.number<>0 then err.clear
end function
function isValidstring(para)
on error resume next
dim str
dim l,i,invalidchar
invalidchar="=%?#&;,'+<>()-:\*!/|"&chr(32)&chr(34)&chr(9)
if isNUll(para) then
isValidstring=""
exit function
end if
str=cstr(para)
if trim(str)="" then
isValidstring=""
exit function
end if
l=len(str)
for i = 1 to l
c = Mid(str, i, 1)
if InStr(invalidchar,c)>0 then
isValidstring = c
exit function
end if
next
isValidstring=""
if err.number<>0 then err.clear
end function
function isChinese(para)
on error resume next
dim str
dim i
if isNUll(para) then
isChinese=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isChinese=false
exit function
end if
for i=1 to len(str)
c=asc(mid(str,i,1))
if c>=0 then
isChinese=false
exit function
end if
next
isChinese=true
if err.number<>0 then err.clear
end function
function isInteger(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
isInteger=false
exit function
end if
str=cstr(para)
if trim(str)="" then
isInteger=false
exit function
end if
l=len(str)
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isInteger=false
exit function
end if
next
isInteger=true
if err.number<>0 then err.clear
end function
function cutStr(str,strlen)
dim l,t,c
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
cutStr=left(str,i)&"..."
exit for
else
cutStr=str
end if
next
end function
function ChkBadWords(fString)
bwords = split(BadWords, "|")
for i = 0 to ubound(bwords)
fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"))
next
ChkBadWords = fString
end function
function HTMLEncode(fString)
if not isnull(fString) and fString<>"" then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
fString = ChkBadWords(fString)
end if
HTMLEncode = fString
end function
function HTMLDecode(fString)
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, "", CHR(13))
fString = Replace(fString, "</P><P>", CHR(10) & CHR(10))
fString = Replace(fString, "<BR>", CHR(10))
HTMLDecode = fString
end function
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
function IsValidTel(para)
on error resume next
dim str
dim l,i
if isNUll(para) then
IsValidTel=false
exit function
end if
str=cstr(para)
if len(trim(str))<7 then
IsValidTel=false
exit function
end if
l=len(str)
for i=1 to l
if not (mid(str,i,1)>="0" and mid(str,i,1)<="9" or mid(str,i,1)="-") then
IsValidTel=false
exit function
end if
next
IsValidTel=true
if err.number<>0 then err.clear
end function
Function GetIp(IP)
ips=Split(ip,".")
GetIp=ips(0)&"."&ips(1)&".*.*"
end Function
'用户来源
function ipsource(sip)
dim iprs,ipsql,ipconn,ipconnstr
if isnumeric(left(sip,2)) then
if sip="127.0.0.1" then sip="192.168.0.1"
str1=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str2=left(sip,instr(sip,".")-1)
sip=mid(sip,instr(sip,".")+1)
str3=left(sip,instr(sip,".")-1)
str4=mid(sip,instr(sip,".")+1)
if isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 then
else
num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
ipconnstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("data/ip.mdb")
Set ipconn = Server.CreateObject("ADODB.Connection")
ipconn.Open ipconnstr
set iprs=server.createobject("adodb.recordset")
ipsql="select Top 1 country,city from address where ip1 <="&num&" and ip2 >="&num&""
iprs.open ipsql,ipconn,1,1
if iprs.eof and iprs.bof then
country="亚洲"
city=""
else
country=iprs("country")
city=iprs("city")
end if
iprs.close
set iprs=nothing
ipconn.close
set ipconn=nothing
end if
ipsource=country&city
else
ipsource="未知"
end if
end function
function ChkPost()
chkpost=false
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
chkpost=false
else
chkpost=true
end if
end function
function getrealname(byval username)
tmpsql = "select realname from [student] where userid='"&username&"'"
set tmprs=conn.execute(tmpsql)
if not tmprs.eof then
getrealname=htmlencode(tmprs(0))
else
getrealname=""
end if
end function
function constellation(byval birthday)
dim bir,birmon,birday
mon=month(birthday)
if len(mon)=1 then mon="0"&mon
da=day(birthday)
if len(da)=1 then da="0"&da
bir=mon&da
if bir>="0120" and bir<="0218" then
constellation="<img src=star/z11.gif alt=水瓶座"&birthday&">"
elseif bir>="0219" and bir<="0320" then
constellation="<img src=star/z12.gif alt=双鱼座"&birthday&">"
elseif bir>="0321" and bir<="0419" then
constellation="<img src=star/z1.gif alt=白羊座"&birthday&">"
elseif bir>="0420" and bir<="0520" then
constellation="<img src=star/z2.gif alt=金牛座"&birthday&">"
elseif bir>="0521" and bir<="0621" then
constellation="<img src=star/z3.gif alt=双子座"&birthday&">"
elseif bir>="0622" and bir<="0722" then
constellation="<img src=star/z4.gif alt=巨蟹座"&birthday&">"
elseif bir>="0723" and bir<="0822" then
constellation="<img src=star/z5.gif alt=狮子座"&birthday&">"
elseif bir>="0823" and bir<="0922" then
constellation="<img src=star/z6.gif alt=处女座"&birthday&">"
elseif bir>="0923" and bir<="1023" then
constellation="<img src=star/z7.gif alt=天秤座"&birthday&">"
elseif bir>="1024" and bir<="1121" then
constellation="<img src=star/z8.gif alt=天蝎座"&birthday&">"
elseif bir>="1122" and bir<="1221" then
constellation="<img src=star/z9.gif alt=射手座"&birthday&">"
elseif bir>="1222" or bir<="0119" then
constellation="<img src=star/z10.gif alt=摩羯座"&birthday&">"
end if
end function
Function IsFSOInstalled()
On Error Resume Next
IsFSOInstalled = False
Err = 0
Dim TestObj
Set TestObj = Server.CreateObject("Scripting.FileSystemObject")
If 0 = Err Then IsFSOInstalled = True
Set TestObj = Nothing
Err = 0
End Function
Function Checkstr(str)
str=replace(str,"'","''")
Checkstr=str
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -