?? char.asp
字號:
<%
dim WINNT_CHINESE
function strLength(str)
ON ERROR RESUME NEXT
dim WINNT_CHINESE
WINNT_CHINESE = (len("論壇")=2)
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 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
sub error()
response.write "<br><table cellpadding=0 cellspacing=0 border=0 width="&TableWidth&" bgcolor="&tablebackcolor&" align=center>"&_
"<tr><td><table cellpadding=3 cellspacing=1 border=0 width=""100%""><tr align=center>"&_
"<td width=""100%"" bgcolor="&tabletitlecolor&"><font color="&TableFontColor&"><b>論壇錯誤信息</b></font></td>"&_
"</tr><tr><td width=""100%"" bgcolor="&tablebodycolor&">"&_
"<font color="&TableContentColor&"><b>產(chǎn)生錯誤的可能原因:</b><br><br>"&_
"<li>您是否仔細(xì)閱讀了<a href=help.asp><font color="&TableContentColor&">幫助文件</font></a>"&_
""&errmsg&"</font></td></tr><tr align=center><td width=""100%"" bgcolor="&tabletitlecolor&">"&_
"<a href=javascript:history.go(-1)><font color="&TableFontColor&"> << 返回上一頁</font></a>"&_
"</td></tr> </table> </td></tr></table>"
end sub
function browser(info)
if Instr(info,"NetCaptor 6.5.0")>0 then
browser="瀏 覽 器:NetCaptor 6.5.0"
elseif Instr(info,"MyIe 3.1")>0 then
browser="瀏 覽 器:MyIe 3.1"
elseif Instr(info,"NetCaptor 6.5.0RC1")>0 then
browser="瀏 覽 器:NetCaptor 6.5.0RC1"
elseif Instr(info,"NetCaptor 6.5.PB1")>0 then
browser="瀏 覽 器:NetCaptor 6.5.PB1"
elseif Instr(info,"MSIE 5.5")>0 then
browser="瀏 覽 器:Internet Explorer 5.5"
elseif Instr(info,"MSIE 6.0")>0 then
browser="瀏 覽 器:Internet Explorer 6.0"
elseif Instr(info,"MSIE 6.0b")>0 then
browser="瀏 覽 器:Internet Explorer 6.0b"
elseif Instr(info,"MSIE 5.01")>0 then
browser="瀏 覽 器:Internet Explorer 5.01"
elseif Instr(info,"MSIE 5.0")>0 then
browser="瀏 覽 器:Internet Explorer 5.00"
elseif Instr(info,"MSIE 4.0")>0 then
browser="瀏 覽 器:Internet Explorer 4.01"
else
browser="瀏 覽 器:未知"
end if
end function
function system(info)
if Instr(info,"NT 5.1")>0 then
system=system+"操作系統(tǒng):Windows XP"
elseif Instr(info,"Tel")>0 then
system=system+"操作系統(tǒng):Telport"
elseif Instr(info,"webzip")>0 then
system=system+"操作系統(tǒng):webzip"
elseif Instr(info,"flashget")>0 then
system=system+"操作系統(tǒng):flashget"
elseif Instr(info,"offline")>0 then
system=system+"操作系統(tǒng):offline"
elseif Instr(info,"NT 5")>0 then
system=system+"操作系統(tǒng):Windows 2000"
elseif Instr(info,"NT 4")>0 then
system=system+"操作系統(tǒng):Windows NT4"
elseif Instr(info,"98")>0 then
system=system+"操作系統(tǒng):Windows 98"
elseif Instr(info,"95")>0 then
system=system+"操作系統(tǒng):Windows 95"
else
system=system+"操作系統(tǒng):未知"
end if
end function
Function chkemail(strEmailAddr)
Dim re
Set re = new RegExp
re.pattern = "^[a-zA-Z][A-Za-z0-9_.-]+@[a-zA-Z0-9_]+?\.[a-zA-Z]{2,3}$"
chkemail=re.Test(strEmailAddr)
end function
Function chkoicq(oicq)
Dim re1
Set re1 = new RegExp
re1.IgnoreCase = false
re1.global = false
re1.Pattern = "[0-9]{4,9}$"
chkoicq = re1.Test(oicq)
End Function
function DateToStr(dtDateTime)
DateToStr = year(dtDateTime) & doublenum(Month(dtdateTime)) & doublenum(Day(dtdateTime)) & doublenum(Hour(dtdateTime)) & doublenum(Minute(dtdateTime)) & doublenum(Second(dtdateTime)) & ""
end function
function doublenum(fNum)
if fNum > 9 then
doublenum = fNum
else
doublenum = "0" & fNum
end if
end function
rem ------------ubb代碼
function ChkBadWords(fString)
if not(isnull(BadWords) or isnull(fString)) then
bwords = split(BadWords, "|")
for i = 0 to ubound(bwords)
fString = Replace(fString, bwords(i), string(len(bwords(i)),"*"))
next
ChkBadWords = fString
end if
end function
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(9), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")
fString=ChkBadWords(fString)
HTMLEncode = fString
end if
end function
function HTMLcode(fString)
if not isnull(fString) then
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLcode = fString
end if
end function
function HTMLDecode(fString)
if not isnull(fString) then
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 if
end function
public function translate(sourceStr,fieldStr)
rem 處理邏輯表達(dá)式的轉(zhuǎn)化問題
dim sourceList
dim resultStr
dim i,j
if instr(sourceStr," ")>0 then
dim isOperator
isOperator = true
sourceList=split(sourceStr)
'--------------------------------------------------------
rem Response.Write "num:" & cstr(ubound(sourceList)) & "<br>"
for i = 0 to ubound(sourceList)
rem Response.Write i
Select Case ucase(sourceList(i))
Case "AND","&","和","與"
resultStr=resultStr & " and "
isOperator = true
Case "OR","|","或"
resultStr=resultStr & " or "
isOperator = true
Case "NOT","!","非","!","!"
resultStr=resultStr & " not "
isOperator = true
Case "(","(","("
resultStr=resultStr & " ( "
isOperator = true
Case ")",")",")"
resultStr=resultStr & " ) "
isOperator = true
Case Else
if sourceList(i)<>"" then
if not isOperator then resultStr=resultStr & " and "
if inStr(sourceList(i),"%") > 0 then
resultStr=resultStr&" "&fieldStr& " like '" & replace(sourceList(i),"'","''") & "' "
else
resultStr=resultStr&" "&fieldStr& " like '%" & replace(sourceList(i),"'","''") & "%' "
end if
isOperator=false
End if
End Select
rem Response.write resultStr+"<br>"
next
translate=resultStr
else '單條件
if inStr(sourcestr,"%") > 0 then
translate=" " & fieldStr & " like '" & replace(sourceStr,"'","''") &"' "
else
translate=" " & fieldStr & " like '%" & replace(sourceStr,"'","''") &"%' "
End if
rem 前后各加一個空格,免得連sql時忘了加,而出錯。
end if
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 address(sip)
if isnumeric(left(sip,2)) then
set iprs=server.createobject("adodb.recordset")
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
sql="select Top 1 country,city from address where ip1 <="&num&" and ip2 >="&num&""
iprs.open sql,conn,1,1
if iprs.eof and iprs.bof then
country="亞洲"
city=""
else
country=iprs(0)
city=iprs(1)
end if
iprs.close
set iprs=nothing
set cmd=nothing
end if
address=country&city
else
address="未知"
end if
end function
'用戶IP限制
function LockIP(sip)
LockIP=false
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
ipsql="select count(*) from LockIP where ip1 <="&num&" and ip2 >="&num&""
set iprs=server.createobject("adodb.recordset")
iprs.open ipsql,conn,1,1
if iprs(0)>0 then
LockIP=true
end if
iprs.close
set iprs=nothing
end if
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
scriptname=request.ServerVariables("PATH_INFO")
if instr(scriptname,"admin")=0 and instr(scriptname,"stat")=0 then
if LockIP(Request.ServerVariables("REMOTE_ADDR")) then
response.write "<table align=center height=20% style=font-size:12px><tr><td>您的IP已經(jīng)被限制不能訪問本論壇,請和管理員聯(lián)系"&SystemEmail&"。</td></tr></table>"
response.end
end if
end if
%>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -