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

ASP訪問(wèn)數(shù)量統(tǒng)計(jì)代碼

 更新時(shí)間:2008年10月30日 15:21:20   作者:  
asp創(chuàng)建訪問(wèn)統(tǒng)計(jì)代碼,實(shí)例
1。建立數(shù)據(jù)庫(kù)表
表名為online
設(shè)如下字段
id '用來(lái)記錄每一個(gè)訪問(wèn)都的session.sessionid
name '如果是訪客,則記錄為訪客。
online '如果是訪各為0 如果是會(huì)員1
datetime '最近活動(dòng)時(shí)間
username '會(huì)員的登錄用戶名,訪客為空。
ip '記錄訪問(wèn)都的登錄IP
head.asp '向數(shù)據(jù)庫(kù)表寫入在線人數(shù),該頁(yè)面必須搜入到每一個(gè)用于瀏覽ASP頁(yè)面中。
<%
set rs=Server.CreateObject("ADODB.Recordset")
if session("username")="" then 判斷用戶未登錄
sql="select * from online where id='"&session.sessionid&"' " '判斷這個(gè)sessionid是否存在于數(shù)據(jù)庫(kù)表中.
rs.Open sql,Conn,1,3
if rs.eof then '訪客第一次瀏覽
rs.addnew
rs("id")=session.sessionID
rs("name")="游客"
rs("online")=0 '0表示用戶未登陸,是游客身份
rs("datetime")=now()
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip= Request.ServerVariables("REMOTE_ADDR")
end if
rs("ip")=userip
else '訪客非第一次瀏覽
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 或者 用戶名記錄已存在數(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") '寫入用戶昵稱
rs("username")=session("username") '寫入登錄用戶名
rs("online")=1 '表示用戶已經(jīng)登陸,是會(huì)員身份
rs("datetime")=now() '將當(dāng)前系統(tǒng)時(shí)間設(shè)置為用戶的登陸時(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)站,訪客登錄網(wǎng)站。
rs("name")=session("show") 更新用戶昵稱
rs("username")=session("username")
rs("online")=1 '表示用戶已經(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)的訪客,時(shí)間可以自己調(diào)整。

相關(guān)文章

最新評(píng)論