欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp論壇在線(xiàn)人數(shù)統(tǒng)計(jì)研究

 更新時(shí)間:2007年03月12日 00:00:00   作者:  
1。建立數(shù)據(jù)庫(kù)表
  表名為online 
  設(shè)如下字段
  id '用來(lái)記錄每一個(gè)訪(fǎng)問(wèn)都的session.sessionid
  name '如果是訪(fǎng)客,則記錄為訪(fǎng)客。
  online  '如果是訪(fǎng)各為0 如果是會(huì)員1 
  datetime '最近活動(dòng)時(shí)間
  username '會(huì)員的登錄用戶(hù)名,訪(fǎng)客為空。
  ip '記錄訪(fǎng)問(wèn)都的登錄IP

  head.asp '向數(shù)據(jù)庫(kù)表寫(xiě)入在線(xiàn)人數(shù),該頁(yè)面必須搜入到每一個(gè)用于瀏覽ASP頁(yè)面中。


 <%
set rs=Server.CreateObject("ADODB.Recordset")
if session("username")="" then 判斷用戶(hù)未登錄
sql="select * from online where id='"&session.sessionid&"' "  '判斷這個(gè)sessionid是否存在于數(shù)據(jù)庫(kù)表中.
rs.Open sql,Conn,1,3
if rs.eof then  '訪(fǎng)客第一次瀏覽
rs.addnew
rs("id")=session.sessionID
rs("name")="游客"
rs("online")=0      '0表示用戶(hù)未登陸,是游客身份
rs("datetime")=now()
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
        If userip = "" Then 
        userip= Request.ServerVariables("REMOTE_ADDR")
        end if
  rs("ip")=userip
else      '訪(fǎng)客非第一次瀏覽 


 rs("datetime")=now()  '更新活動(dòng)時(shí)間
rs.update
rs.close
end if
else
sql="select * from online where id='" & session.sessionID & "' or admin='"&session("username")&"'"  '判斷sessionid 或者 用戶(hù)名記錄已存在數(shù)據(jù)表中。
rs.Open sql,Conn,1,3
if rs.eof then
rs.addnew   '會(huì)員第一次進(jìn)入網(wǎng)站(可能從網(wǎng)站首頁(yè)直接登錄進(jìn)入論壇)。
rs("id")=session.sessionID
rs("name")=session("show") '寫(xiě)入用戶(hù)昵稱(chēng)
rs("username")=session("username")    '寫(xiě)入登錄用戶(hù)名
rs("online")=1         '表示用戶(hù)已經(jīng)登陸,是會(huì)員身份
rs("datetime")=now()        '將當(dāng)前系統(tǒng)時(shí)間設(shè)置為用戶(hù)的登陸時(shí)間
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
        If userip = "" Then 
        userip= Request.ServerVariables("REMOTE_ADDR")
        end if
  rs("ip")=userip
else  //會(huì)員非第一次瀏覽網(wǎng)站,訪(fǎng)客登錄網(wǎng)站。
rs("name")=session("show") 更新用戶(hù)昵稱(chēng)
rs("username")=session("username") 
rs("online")=1         '表示用戶(hù)已經(jīng)登陸,是會(huì)員身份
rs("datetime")=now() 
end if 
rs.update
rs.close
end if
set rs=nothing
%>
conn.execute("delete from online where datediff('s',datetime,now())>60")  '刪除60秒沒(méi)有活動(dòng)的訪(fǎng)客,時(shí)間可以自己調(diào)整。 



相關(guān)文章

最新評(píng)論