欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

显示在线人数

程序员文章站 2023-08-24 16:02:22
<%nowurl=request.servervariables("http_referer")username = session("wenday_sys_user...
<%
nowurl=request.servervariables("http_referer")
username = session("wenday_sys_user")
if username="" then
   username="客人"
end if
call sqlonline()
response.write "document.write(" & chr(34) & "  <font color=#000000>当前在线 "& online() &"人</font>"& chr(34) & ")"
'response.write "document.write(" & chr(34) & "  <a href=count/showonline.asp title=查看在线列表><font color=#000000>当前在线"& online() &"人</font></a>"& chr(34) & ")"
sub sqlonline()
dim statuserid
     statuserid=replace(request.servervariables("remote_host"),".","") 
  response.cookies("wenday_sys")("onlineid")=statuserid
 sql="select id from "&categoryname&"_online where id="&cstr(request.cookies("wenday_sys")("onlineid"))
 set rs=conn.execute(sql)
 if rs.eof and rs.bof then
  sql="insert into "&categoryname&"_online(id,username,ip,startime,lastimebk,browser,actforip,now_url) values ("&statuserid&",'"&username&"','"&request.servervariables("remote_host")&"',now(),now(),'"&request.servervariables("http_user_agent")&"','"&request.servervariables("http_x_forwarded_for")&"','"&request.servervariables("http_referer")&"')"
 else
  sql="update "&categoryname&"_online set lastimebk=now(),username='"&username&"' where id="&cstr(request.cookies("wenday_sys")("onlineid"))
 end if
 conn.execute(sql)
set rs=nothing
rem 删除超时用户
sql="delete from "&categoryname&"_online where datediff('s', lastimebk, now()) > "&kicktime&"*60"
conn.execute sql
end sub
function online()
dim tmprs
 sql="select count(id) from "&categoryname&"_online"
set tmprs=conn.execute(sql)
online=tmprs(0)
set tmprs=nothing
if isnull(online) then online=0
end function
closedatabase
%>