<!--#INCLUDE FILE="setup.asp" -->
<!--#include file="checkuser.asp" -->
<!--#INCLUDE FILE="theme.asp" -->
<%
Locat="在线用户"
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

if BoolVar(9) then
	sql="select O.userid,O.ip,O.logintime,O.activetime,O.location,O.act from online O inner join student S on O.userid=S.userid where S.locked<2 order by O.logintime"
else
	sql="select userid,ip,logintime,activetime,location,act from online order by logintime"
end if

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=""Profile.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;去第"
%><input type=hidden value="<%=order%>" name="orderby">&nbsp;<input type=text name=targetPage size=2 style="height:16px;width:20px;">&nbsp;页</td><td width=15 align=right style="cursor:hand" onclick="document.location.href='UserList.asp?OrderBy='+orderby.value+'&page='+targetPage.value;"><img src=images/btngo.gif width=13 height=15></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

Call footer%>

