计数器
数据结构 [counter] count 数字 sdate 日期 ldate 日期 today allday yesterday topday 数字
sub txlcount()
if session(“in”)<>”in” then
session(“in”)=”in”
application.lock
conn.execute(“update [counter] set [count]=count+1,today=today+1″)
end if
sql=”select * from [counter]”
set rs=server.createobject(“adodb.recordset”)
rs.open sql,conn,1,3
if formatdatetime(now(),2)<>formatdatetime(rs(2),2) then
if rs(3)>rs(6) then
rs(6)=rs(3)
end if
rs(5)=rs(3)
rs(3)=1
rs(4)=rs(4)+1
rs(2)=formatdatetime(now(),2)
rs.update
end if
dim s, i,g
dim countlong,avg
countlong=6
avg=int(rs(0)\rs(4))
g =CStr(rs(0))
s =Len(g)
response.write “总访问量:<a style=””CURSOR: hand””title=————-“&txl_info(0)&”————
”&_
“ 今日访问:”&rs(3)&”人
”&_
“ 昨日访问:”&rs(5)&”人
” &_
“ 最高日访问:”&rs(6)&”人
” &_
“ 平均日访问:”&avg&”人
”&_
“ 总访问人数:”&rs(0)&”人
”&_
“ 总统计天数:”&rs(4)&”天
”&_
“ 统计日期:”&formatdatetime(rs(1),1)&”
”&_
“———————————–“&_
“>”
For i = 1 to countlong – s
response.write”<img src=’images/counter/0.gif’></img>”
next
for i=1 to s
response.write “<img src=’images/counter/” & mid(g,i,1) & “.gif’></img>”
next
response.write “</a><br />”
rs.close
set rs=nothing
end sub
rem 过滤BadWord字符
function ChkBadWords(fString)
dim bwords,ii
if not(isnull(BadWords) or isnull(fString)) then
bwords = split(BadWords, “|”)
for ii = 0 to ubound(bwords)
fString = Replace(fString, bwords(ii), string(len(bwords(ii)),”*”))
next
ChkBadWords = fString
end if
end function
Rem 过滤HTML代码
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
Rem 过滤表单字符
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
Rem 判断是否来自外部
function ChkPost()
dim server_v1,server_v2
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
Rem 过滤SQL非法字符
function checkStr(str)
if isnull(str) then
checkStr = “”
exit function
end if
checkStr=replace(str,”‘”,”””)
end function
Rem 判断数字是否整形
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
接取数字验证
userid=replace(request.QueryString(“id”),”‘”,””)
userid=replace(userid,”;”,””)
userid=replace(userid,”–“,””)
userid=replace(userid,”)”,””)
Job=replace(rs_home(“Job”),”<br />”,chr(13))
Job=replace(Job,” “,” “)
else
Job=rs_home(“Job”)
rem 禁止用teleport、webzip、flashget、offline软件下载
Dim UserAgent,Stats,ScriptName
UserAgent=Trim(lcase(Request.Servervariables(“HTTP_USER_AGENT”)))
ScriptName=lcase(request.ServerVariables(“PATH_INFO”))
If Instr(UserAgent,”teleport”)>0 or Instr(UserAgent,”webzip”)>0 or Instr(UserAgent,”flashget”)>0 or Instr(UserAgent,”offline”)>0 Then
response.redirect “error.htm”
response.end
end if
‘以年月创建上传文件夹,格式:2003-8
Private Function CreatePath(PathValue)
Dim objFSO,Fsofolder,uploadpath
uploadpath = year(now) & “-” & month(now)
If Right(PathValue,1)<>”/” Then PathValue = PathValue&”/”
On Error Resume Next
Set objFSO = Server.CreateObject(“Scripting.FileSystemObject”)
If objFSO.FolderExists(Server.MapPath(PathValue & uploadpath))=False Then
objFSO.CreateFolder Server.MapPath(PathValue & uploadpath)
End If
If Err.Number = 0 Then
CreatePath = PathValue & uploadpath & “/”
Else
CreatePath = PathValue
End If
Set objFSO = Nothing
End Function
‘JS InnerHtml (对象名,追加信息)
Sub InnerHtml(obj,msg)
ReportTxt = ReportTxt & “<li>”& msg &”</li>”
Response.Write “<script LANGUAGE=””JavaScript””>”&obj&”.innerHTML += “”<li>”&msg&”</li>””;</script>”
Response.Flush
End Sub
‘JS 错误提示信息,并自已返回上一页
Sub ErrMsg(msg)
Response.Write “<script LANGUAGE=””JavaScript””>ErrMsg(“””&msg&”””);</script>”
Response.Flush
End Sub
//错误提示,并返回历史前一页
function ErrMsg(msg){
if (msg!=”)
{
alert(“错误信息:\n\r”+msg)
history.go(-1);
}
}
‘系统分配随机密码
Public Function Createpass()
Dim Ran,i,LengthNum
LengthNum=16
Createpass=””
For i=1 To LengthNum
Randomize
Ran = CInt(Rnd * 2)
Randomize
If Ran = 0 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& UCase(Chr(Ran))
ElseIf Ran = 1 Then
Ran = CInt(Rnd * 9)
Createpass = Createpass & Ran
ElseIf Ran = 2 Then
Ran = CInt(Rnd * 25) + 97
Createpass =Createpass& Chr(Ran)
End If
Next
End Function
‘取得带端口的URL
Property Get Get_ScriptNameUrl()
If request.servervariables(“SERVER_PORT”)=”80″ Then
Get_ScriptNameUrl=”http://” & request.servervariables(“server_name”)&replace(lcase(request.servervariables(“script_name”)),ScriptName,””)
Else
Get_ScriptNameUrl=”http://” & request.servervariables(“server_name”)&”:”&request.servervariables(“SERVER_PORT”)&replace(lcase(request.servervariables(“script_name”)),ScriptName,””)
End If
End Property
Rem 判断发言是否来自外部
Public Function ChkPost()
Dim server_v1,server_v2
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=True
End Function
function cutstr(tempstr,tempwid)
if len(tempstr)>tempwid then
cutstr=left(tempstr,tempwid)&”…”
else
cutstr=tempstr
end if
end function