<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="Class_Checkuser.asp" -->
<!--#INCLUDE FILE="Class_Top.asp" -->

<%
Locat="在线用户"
if membername="" then
  	errmsg=errmsg+"<br>"+"<li>您还没有<a href=Class_Login.asp><font color=red>登录或注册校友录</font></a>。"
	call top(1,1)
	call error("Information",errmsg)
	
	else
Call top(1,1)
response.write "<br><br>"&_
"<table cellpadding=5 cellspacing=1 border=0 width=100% Class=TableBorder>"&_
"<tr Class=DarkTableBody>"&_
"<td colspan=6 valign=top width=350 height=30 valign=absmiddle>&nbsp;>> <B>校友录在线用户列表</B> <<"&_
"<font face=宋体>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前在线用户数："&OnlineUsersNum&"人</font></td>"&_
"</tr><tr>"&_
	"<th><a href=""?OrderBy=userid"">用户名</a></th>"&_
	"<th>IP地址</th><th>登陆时间</th><th>最后活动时间</th>"&_
	"<th>当前位置</th><th>当前动作</th></tr>"

Dim totalPages,currentPage,order
Dim rs,sql
currentPage=Request("page")

if Request("OrderBy")="point" or Request("OrderBy")="regdate" or Request("OrderBy")="visitcount" or Request("OrderBy")="lastlogin" or Request("OrderBy")="userid" Then
	order=Request("OrderBy")
Else
	order="regdate"
End if

	sql="select userid,ip,logintime,activetime,location,act from online order by logintime"

Set rs=server.createobject("adodb.recordset")
rs.open sql,Conn,1,1

if rs.eof and rs.bof Then
	response.write "<tr Class=LightTableBody><td colspan=9 height=30><font color=brown>&nbsp;&nbsp;没有注册用户在线:(</font></td></tr>"
Else
	pagesize=20
	rs.pagesize=pagesize
	totalpages=rs.pagecount
	if currentpage="" Then currentpage=1
	if not isNumeric(currentpage) Then
		currentpage=1
	ElseIf Cint(currentpage)>totalpages Then
		currentpage=totalpages
	End if
	currentpage=Cint(currentpage)
	rs.absolutepage=currentpage

	for total=1 to pagesize
		if rs.eof Then Exit for
		name=htmlencode(rs(0))
		response.write "<tr Class=LightTableBody >"&_
		"<td >&nbsp;<a href=""Class_Userinfo.asp?Name="&name&""" target=_blank  title=""查看"&name&"的个人信息"">"&name&"</a></td>"&_
		"<td align=center>"

		if sysadmin Then Response.Write rs(1) Else Response.Write getip(rs(1))

		response.write "</td>"&_
			"<td align=center>"&timevalue(rs(2))&"</td><td align=center>"&timevalue(rs(3))&"</td>"&_
			"<td>"&rs(4)&"</td><td>"&rs(5)&"</td></tr>"
		rs.movenext
	next

%>
</table>
<table width=100% align=center>
<tr><td align=left valign=center>
<% if currentpage=0 Then currentpage=1
if not (currentpage=1 or totalpages=0) Then
	Response.Write "　<a href=?page="&currentpage-1&"&OrderBy="&order&"><img src=images/left.gif border=0>&nbsp;上一页</a>"
End if
		
if not (currentpage=totalpages or totalpages=0) Then
	Response.Write "　<a href=?page="&currentpage+1&"&OrderBy="&order&"><img src=images/right.gif border=0>&nbsp;下一页</a>"
End if
%></td>
<td align=right valign=center><%Response.Write "页 "&currentpage&"&nbsp;/&nbsp;"&totalpages&"&nbsp;&nbsp;&nbsp;去第"
Response.Write " <select name=""page"" style=""width:35px"" onChange=""location.href='?OrderBy="&order&"&page='+this.options[selectedIndex].value"">"
dim i
i=1
do while i<=totalpages
             if i=currentPage then
             response.write("<option selected value="&i&">"&i&"</option>")
             else
             response.write("<option value="&i&">"&i&"</option>")
             end if
             i=i+1
             loop
	Response.Write "</select> 页"
%>
</td><td width=15 align=right style="cursor:hand"></td></tr>
<%
End if

rs.close:Set rs=Nothing
response.write "</table><BR>"


Function OnlineUsersNum()

	Dim oRs,oSql
	if BoolVar(9) then
		oSql="Select count(O.userid) from online O inner join student S on O.userid=S.userid where S.locked<2 "
	else
		oSql="Select count(userid) from online"
	end if	
	Set oRs=Conn.Execute(oSql)
	if oRs.eof and oRs.bof Then
		OnlineUsersNum=0
	Else
		OnlineUsersNum=oRs(0)
	End if
	Set oRs=Nothing

End Function


Function GetIp(IP)
	ips=Split(ip,".")
	GetIp=ips(0)&"."&ips(1)&".*.*"
end Function
end if
Call footer%>

