ASP顯示當前線上人數功能

來源:互聯網
上載者:User
<%onlineTimeout=10    ''定義線上啟用時間的時間間隔Function Userip()  GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")       ''''''''''''''''''''''獲得使用者的虛擬IP地址


<%
onlineTimeout=10    ''定義線上啟用時間的時間間隔
Function Userip()
  GetClientIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")       ''''''''''''''''''''''獲得使用者的虛擬IP地址
  If GetClientIP = "" or isnull(GetClientIP) or isempty(GetClientIP) Then
    GetClientIP = Request.ServerVariables("REMOTE_ADDR")          ''''''''''如果未使用Proxy 伺服器,就獲得來源的IP地址
  End If
  Userip = GetClientIP
End Function
sql="select o_id from c_online where o_ip='' "&Userip()&" '' "      在資料庫中尋找所獲得 的IP地址的id
Set rs=conn.execute(sql)
If rs.eof and rs.bof Then
    sql="insert into c_online(o_ip) values('' "&Userip()&" '')"     如果資料庫中沒有就表明是新IP,那麼插入操作
    conn.execute(sql)
Else
    sql="update c_online set o_ltime=now() where o_ip='' "&Userip()&" '' "    更資料庫的目前時間
    conn.execute(sql)
End If
sql="delete from c_online where dateadd(''s'',"&onlineTimeout*60&",o_ltime) < now()"    定義十分鐘重新整理
conn.execute(sql)
rs.close
Set rs=nothing
Function allonline()
    tmprs=conn.execute("Select count(o_id) from c_online")
    allonline=tmprs(0)
    set tmprs=nothing
end Function
%>
<%Response.Write "document.write(""線上"&allonline()&"人"")"%>



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.