【Vegas原创】网站计数器(asp)
Global.asa 加入以下代码:
<Script language="VBScript" runat="server">
Sub Session_OnStart
Dim strCon
strCon="Database=tmpCounter;uid=sa;pwd=****;driver={SQL Server};server=****"
Dim server_name,url
url=Request.ServerVariables("SCRIPT_NAME")
urlArray=Split(url,"/")
server_name=Request.ServerVariables("SERVER_NAME") & "/" & urlArray(1)
Application.Lock
If Application("counter")=null Then
Application("counter")=1
Else
Application("counter")=Application("counter")+1
End If
Application.Unlock
Dim login_ip
login_ip=Request.ServerVariables("REMOTE_ADDR")
Dim insStr
insStr="insert tcounter(login_ip,server_name,counter) values('" & login_ip & "','" & server_name & "'," & Application("counter") & ")"
Set db=server.CreateObject("ADODB.Connection")
db.open strCon
db.execute(insStr)
db.close()
Set db=Nothing
End Sub
</Script>
Sub Session_OnStart
Dim strCon
strCon="Database=tmpCounter;uid=sa;pwd=****;driver={SQL Server};server=****"
Dim server_name,url
url=Request.ServerVariables("SCRIPT_NAME")
urlArray=Split(url,"/")
server_name=Request.ServerVariables("SERVER_NAME") & "/" & urlArray(1)
Application.Lock
If Application("counter")=null Then
Application("counter")=1
Else
Application("counter")=Application("counter")+1
End If
Application.Unlock
Dim login_ip
login_ip=Request.ServerVariables("REMOTE_ADDR")
Dim insStr
insStr="insert tcounter(login_ip,server_name,counter) values('" & login_ip & "','" & server_name & "'," & Application("counter") & ")"
Set db=server.CreateObject("ADODB.Connection")
db.open strCon
db.execute(insStr)
db.close()
Set db=Nothing
End Sub
</Script>
喜欢请赞赏一下啦^_^
![](https://images.cnblogs.com/cnblogs_com/amadeuslee/1997630/o_21070809243911.jpg)