<!--#include file="config.asp"-->
<!--#include file="../inc/classmenu.asp"-->
<%
Dim HtmlContent,TempListContent,ChannelRootDir
Dim userid,username
userid = Newasp.ChkNumeric(Request("userid"))
username = Newasp.CheckStr(Request("name"))
username = Newasp.CheckBadstr(username)
ChannelRootDir = Newasp.InstallDir & "user/"
Newasp.LoadTemplates 9999, 5, 0

HtmlContent = Newasp.HtmlContent
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", 0)
'--频道目录
HtmlContent = Replace(HtmlContent,"{$ChannelRootDir}", ChannelRootDir)
HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)

If userid = 0 And Len(username) = 0 Then
	Call ShowUserList
Else
	Call ShowUserInfo
End If

If Founderr = True Then
	Call Returnerr(ErrMsg)
End If
CloseConn
Public Sub ShowUserList()
	Dim Rs,SQL,i,j,forbid
	Dim maxperpage,CurrentPage,Pcount,totalrec,totalnumber
	Dim strList,strName,RowCode,strContent,strUserName
	Dim strHomePage,strUserMail,strShowPage
	
	forbid = Newasp.ChkNumeric(Newasp.HtmlSetting(17))
	If forbid = 2 Then
		ErrMsg = Newasp.HtmlSetting(18)
		Founderr = True
		Exit Sub
	End If
	If forbid = 1 Then
		If CInt(Newasp.membergrade) = 0 Then
			ErrMsg = Newasp.HtmlSetting(19)
			Founderr = True
			Exit Sub
		End If
	End If
	maxperpage = Newasp.ChkNumeric(Newasp.HtmlSetting(11))
	If maxperpage = 0 Then maxperpage = 20
	CurrentPage = Newasp.ChkNumeric(Request("page"))
	If CurrentPage = 0 Then CurrentPage = 1
	'If Not IsObject(Conn) Then ConnectionDatabase
	SQL = "SELECT userid,username,nickname,UserGrade,UserGroup,UserClass,UserLock,userpoint,usermoney,TrueName,UserSex,usermail,HomePage,oicq,JoinTime,ExpireTime,LastTime,userlogin FROM [NC_User] ORDER BY JoinTime DESC ,userid DESC"
	Set Rs = Server.CreateObject("ADODB.Recordset")
	Rs.Open SQL,Conn,1,1
	If Not (Rs.BOF And Rs.EOF) Then
		totalrec = Rs.RecordCount
		Pcount = CLng(totalrec / maxperpage)  '得到总页数
		If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
		If CurrentPage < 1 Then CurrentPage = 1
		If CurrentPage > Pcount Then CurrentPage = Pcount
		Rs.PageSize = maxperpage
		Rs.AbsolutePage = CurrentPage
		i = 0
		j = (CurrentPage - 1) * maxperpage + 1
		Do While Not Rs.EOF And i < maxperpage
			If Not Response.IsClientConnected Then ResponseEnd
			If (i mod 2) = 0 Then
				RowCode = 1
			Else
				RowCode = 2
			End If
			strContent = strContent & Newasp.HtmlSetting(13)
			strUserName = "<a href=""?userid=" & Rs("userid") & """>" & Rs("username") & "</a>"
			strContent = Replace(strContent, "{$UserName}", strUserName)
			strContent = Replace(strContent, "{$UserID}", Rs("userid"))
			strContent = Replace(strContent, "{$UserLogin}", Rs("userlogin"))
			strContent = Replace(strContent, "{$UserPoint}", Rs("userpoint"))
			strContent = Replace(strContent, "{$UserSex}", Rs("UserSex"))
			strContent = Replace(strContent, "{$UserQQ}", Rs("oicq"))
			strContent = Replace(strContent, "{$LastTime}", Rs("LastTime"))
			strContent = Replace(strContent, "{$DateAndTime}", Rs("JoinTime"))
			strContent = Replace(strContent, "{$OrderID}", j)
			strUserMail = "<a href=""mailto:" & Rs("usermail") & """ target=""_blank"" title=""给此用户发送邮件"">电子信箱</a>"
			strContent = Replace(strContent, "{$UserMail}", strUserMail)
			strContent = Replace(strContent, "{$UserGroup}", Rs("UserGroup"))
			If Newasp.CheckNull(Rs("HomePage")) Then
				strHomePage = "<a href=""" & Rs("HomePage") & """ target=""_blank"" title=""点击查看用户主页"">用户主页</a>"
				strContent = Replace(strContent, "{$HomePage}", strHomePage)
			Else
				strContent = Replace(strContent, "{$HomePage}", "没有主页")
			End If
			Rs.movenext
			i = i + 1
			j = j + 1
			If i >= maxperpage Then Exit Do
		Loop
	End If
	Rs.Close:Set Rs = Nothing
	strShowPage = ShowPages(CurrentPage,Pcount,totalrec,maxperpage,"")
	TempListContent = Newasp.HtmlSetting(12) & strContent & Newasp.HtmlSetting(14)
	HtmlContent = Replace(HtmlContent,"{$UserManageContent}", TempListContent)
	HtmlContent = Replace(HtmlContent, "{$ReadListPage}", strShowPage)
	HtmlContent = Replace(HtmlContent,"{$PageTitle}",Newasp.HtmlSetting(10))
	Response.Write HtmlContent
End Sub

Sub ShowUserInfo()
	If userid = 0 And Len(username) = 0 Then Exit Sub
	Dim Rs,SQL,forbid,sendurl
	Dim strContent,strHomePage,strUserMail
	
	forbid = Newasp.ChkNumeric(Newasp.HtmlSetting(17))
	If forbid = 2 Then
		ErrMsg = Newasp.HtmlSetting(18)
		Founderr = True
		Exit Sub
	End If
	If forbid = 1 Then
		If CInt(Newasp.membergrade) = 0 Then
			ErrMsg = Newasp.HtmlSetting(19)
			Founderr = True
			Exit Sub
		End If
	End If
	
	If userid = 0 Then
		SQL = "SELECT userid,username,nickname,UserGrade,UserGroup,UserClass,UserLock,userpoint,usermoney,TrueName,UserSex,usermail,HomePage,oicq,JoinTime,ExpireTime,LastTime,userlogin FROM [NC_User] WHERE username='" & username &"'"
	Else
		SQL = "SELECT userid,username,nickname,UserGrade,UserGroup,UserClass,UserLock,userpoint,usermoney,TrueName,UserSex,usermail,HomePage,oicq,JoinTime,ExpireTime,LastTime,userlogin FROM [NC_User] WHERE userid=" & userid
	End If
	Set Rs = Newasp.Execute(SQL)
	strContent = ""
	If Not (Rs.BOF And Rs.EOF) Then
		sendurl = "message.asp?action=new&amp;touser="& Rs("username")
		strContent = Newasp.HtmlSetting(16)
		strContent = Replace(strContent, "{$UserName}", Rs("username"))
		strContent = Replace(strContent, "{$username}", "<a href=""" & sendurl & """ target=""_blank"">" & Rs("username") & "</a>")
		strContent = Replace(strContent, "{$UserID}", Rs("userid"))
		strContent = Replace(strContent, "{$UserGroup}", Rs("UserGroup"))
		strContent = Replace(strContent, "{$UserLogin}", Rs("userlogin"))
		strContent = Replace(strContent, "{$UserPoint}", Rs("userpoint"))
		strContent = Replace(strContent, "{$UserSex}", Rs("UserSex"))
		strContent = Replace(strContent, "{$SendUrl}", sendurl)
		strContent = Replace(strContent, "{$SendMessage}", "<a href=""" & sendurl & """ target=""_blank"">发送短消息</a>")
		strContent = Replace(strContent, "{$UserQQ}", Newasp.ChkNull(Rs("oicq")))
		strContent = Replace(strContent, "{$LastTime}", Rs("LastTime"))
		strContent = Replace(strContent, "{$DateAndTime}", Rs("JoinTime"))
		strUserMail = "<a href=""mailto:" & Rs("usermail") & """ target=""_blank"" title=""给此用户发送邮件"">" & Rs("usermail") & "</a>"
		strContent = Replace(strContent, "{$UserMail}", strUserMail)
		If Newasp.CheckNull(Rs("HomePage")) Then
			strHomePage = "<a href=""" & Rs("HomePage") & """ target=""_blank"" title=""点击查看用户主页"">" & Rs("HomePage") & "</a>"
			strContent = Replace(strContent, "{$HomePage}", strHomePage)
		Else
			strContent = Replace(strContent, "{$HomePage}", "没有主页")
		End If
	End If
	Rs.Close:Set Rs = Nothing
	HtmlContent = Replace(HtmlContent,"{$UserManageContent}", strContent)
	HtmlContent = Replace(HtmlContent,"{$PageTitle}",Newasp.HtmlSetting(15))
	Response.Write HtmlContent
End Sub

%>