【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>

 

posted @ 2007-03-16 09:43  李济宏(Amadeus)  阅读(153)  评论(0编辑  收藏  举报