佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > ASP訪問數(shù)量統(tǒng)計代碼

ASP訪問數(shù)量統(tǒng)計代碼

熱門標簽:團購網(wǎng)站 Linux服務器 科大訊飛語音識別系統(tǒng) Mysql連接數(shù)設置 銀行業(yè)務 服務器配置 阿里云 電子圍欄
1。建立數(shù)據(jù)庫表
表名為online
設如下字段
id '用來記錄每一個訪問都的session.sessionid
name '如果是訪客,則記錄為訪客。
online '如果是訪各為0 如果是會員1
datetime '最近活動時間
username '會員的登錄用戶名,訪客為空。
ip '記錄訪問都的登錄IP
head.asp '向數(shù)據(jù)庫表寫入在線人數(shù),該頁面必須搜入到每一個用于瀏覽ASP頁面中。
%
set rs=Server.CreateObject("ADODB.Recordset")
if session("username")="" then 判斷用戶未登錄
sql="select * from online where id='"session.sessionid"' " '判斷這個sessionid是否存在于數(shù)據(jù)庫表中.
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() '更新活動時間
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 '會員第一次進入網(wǎng)站(可能從網(wǎng)站首頁直接登錄進入論壇)。
rs("id")=session.sessionID
rs("name")=session("show") '寫入用戶昵稱
rs("username")=session("username") '寫入登錄用戶名
rs("online")=1 '表示用戶已經(jīng)登陸,是會員身份
rs("datetime")=now() '將當前系統(tǒng)時間設置為用戶的登陸時間
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If userip = "" Then
userip= Request.ServerVariables("REMOTE_ADDR")
end if
rs("ip")=userip
else //會員非第一次瀏覽網(wǎng)站,訪客登錄網(wǎng)站。
rs("name")=session("show") 更新用戶昵稱
rs("username")=session("username")
rs("online")=1 '表示用戶已經(jīng)登陸,是會員身份
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秒沒有活動的訪客,時間可以自己調(diào)整。
您可能感興趣的文章:
  • 采用ngxtop實現(xiàn)nginx實時訪問數(shù)據(jù)統(tǒng)計
  • python統(tǒng)計日志ip訪問數(shù)的方法
  • Java代碼統(tǒng)計網(wǎng)站中不同省份用戶的訪問數(shù)

標簽:大理 廣元 衢州 衡水 萍鄉(xiāng) 蚌埠 江蘇 棗莊

巨人網(wǎng)絡通訊聲明:本文標題《ASP訪問數(shù)量統(tǒng)計代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    和龙市| 舟曲县| 奉化市| 营山县| 永胜县| 郓城县| 乌兰察布市| 偃师市| 平利县| 永泰县| 萨迦县| 漳浦县| 新野县| 南涧| 清水河县| 石首市| 紫阳县| 杭锦旗| 化德县| 舞阳县| 莲花县| 江阴市| 凌源市| 固阳县| 外汇| 阿拉善左旗| 蕲春县| 萝北县| 定西市| 寿宁县| 江华| 安乡县| 东城区| 怀远县| 莎车县| 庆安县| 罗江县| 大姚县| 南郑县| 巍山| 玉门市|