<!--#INCLUDE FILE="setup.asp" -->
<!--#include file=checkuser.asp-->
<!--#include file=include/htmlencode.asp-->
<title><%=StrVar(1)%>--管理页面</title>
<link href="css.asp" rel="stylesheet" type="text/css">
<!--#include file=theme.css-->
<body alink=#333333 vlink=#333333 link=#333333 topmargin=0 class=adminbody>
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=superindex.asp target=_top>登陆</a>后进入。"
	Call Error("Information",ErrMsg)
Else
	Call main()
End if

Call endconnection()


Sub main()
%>
<table cellpadding=5 cellspacing=1 border=0 width=100% Class=TableBorder align=center>
<tr>
	<th>欢迎<b><%=membername%></b>进入管理页面</th>
</tr>
</table>

		<%
		if Request.form("action")="删除图片" Then
			Call deletephoto()
		ElseIf Request.form("action")="通过审核" Then
			Call passphoto()
		Else
			Call photolist()
		End if
		
End Sub


Sub photolist()

dim sql,rs
dim totalpages,currentpage
dim i

response.write "<BR><BR>"&_
	"<script language=JavaScript src=""script/jsfun.asp""></script>"&_
	"<script language=JavaScript src=""script/viewimage.js""></script>"&_
	"<table width=""90%"" align=center border=0><tr><td>当前照片审核功能已<font color=brown>"
	if BoolVar(7) then response.write "开启" else response.write "关闭"
	response.write "</font></td></tr></table>"&_
	"<TABLE width=""90%"" Class=TableBorder cellspacing=1 cellpadding=5 align=center>"&_
	"<form action=sysadm_photo.asp method=post>"&_
	"<TR><Th>班级相片审核</Th></TR>"&_
	"<TR Class=LightTableBody><TD align=center height=170>"&_
	"<TABLE border=0 width=""100%"" cellspacing=0 cellpadding=0>"

Set rs = server.CreateObject("ADODB.Recordset")
sql="Select filename,title,picid,width,height,classid from photo where passed=false order by picid desc"
rs.open sql,conn,1,1

if rs.eof and rs.bof Then 

	Response.Write "<tr><td>&nbsp;&nbsp;没有要审核的照片！"&_
	"</td></tr></table>"
Else

	rs.pagesize=20
	totalpages=rs.pagecount
	currentpage=Request("Page")
	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 i=1 to 20

		if i mod 4=1 Then Response.Write "<TR>"

		Response.Write "<TD align=center width=""25%"" height=""160"">"&_

			"<TABLE cellSpacing=2 cellPadding=0 width=120 border=0 Class=TableBorder>"&_
			"<TR><TD height=120 align=center Class=DarkTableBody>"&_
			"<!--<table border=1 cellspacing=0 cellpadding=0>"&_
			"<tr><td>--><IMG src="&StrVar(8)&rs(0)&" "&sizeadjust(rs(3),rs(4),100)&" onclick=""javascript:ShowPic('"&rs(5)&"','"&rs(2)&"')"" onmouseover=""this.style.cursor='hand'"">"&_
			"<!--</td></tr></table>-->"&_
			"</TD></TR></TABLE>"&_
			"<TABLE cellSpacing=0 cellPadding=0 width=120 border=0>"&_
			"<TR><TD><input type=checkbox name=photoid value="&rs(2)&">&nbsp;"&htmlencode(left(rs(1),8))&"</TD>"&_
			"</TR></TABLE>"&_
			"</TD>"

		rs.movenext

		if currentpage=totalpages then
			if rs.eof then 
				response.write "</tr>"
				exit for
			end if
		end if
		if i mod 4=0 then response.write "</tr>"

	next

	rs.close
	Set rs=Nothing

	response.write  "</table>"&_
		"</td></tr>"&_
		"<tr class=DarkTableBody><td>"&_
		"<TABLE width=100% border=0>"&_
		"<TR>"&_
		"	<TD><input type=checkbox name=chkall onclick=""CheckAll(this.form)"">全选/取消</TD>"&_
		"	<TD align=right><input type=submit value=删除图片 name=action class=button>"&_
		"	<input type=submit value=通过审核 name=action class=button></TD>"&_
		"</TR>"&_
		"</TABLE>"&_
		"</td></tr></form></table>"&_
		"<table width=""90%"" border=0 align=center><tr><td>"

	if currentpage=0 Then currentpage=1
	if not (currentpage=1 or totalpages=0) Then
		Response.Write "　<a href=?Page="&currentpage-1&">&nbsp;上一页</a>"
	End if
			
	if not (currentpage=totalpages or totalpages=0) Then
		Response.Write "　<a href=?Page="&currentpage+1&">&nbsp;下一页</a>"
	End if

	Response.Write "</td><td align=right>页 "&currentpage&"&nbsp;/&nbsp;"&totalpages

End if

Response.Write "</td></tr></table>"


End Sub



Sub DeletePhoto()

Dim idlist,idarr,photoid
   
if Request("photoid")="" Then
	Errmsg=Errmsg+"<br>"+"<li>请选择所要进行管理操作的相片！"
	Response.Write ErrMsg
	Exit Sub
End if

idlist=Request("photoid")

idArr=Split(idlist,",")
SucDelNum=0
for i = 0 to ubound(idarr)
	photoid=Clng(idarr(i))

	sql = "Select name,filename from photo where picid="&photoid
	Set rs=conn.Execute(sql)

	if not (rs.Eof and rs.bof) Then

		sql="update student Set point=point+"&PointSet(21)&" where userid='"&rs(0)&"'"
		conn.execute(sql)

		if IsFSOInstalled Then
			Set fso = CreateObject("Scripting.FileSystemObject")
			photofile=StrVar(8)&rs(1)
			filepath=server.mappath(photofile)
			if fso.FileExists(filepath)=True Then
				Set file = fso.GetFile(filepath)
				file.delete  
			End if
			Set file=Nothing
			Set fso=Nothing
		End if

		conn.execute("delete from photo where picid="&photoid)
		SucDelNum=SucDelNum+1
	End if

	Set rs=Nothing
next

Response.Write "<BR><BR><CENTER>成功删除&nbsp;<font color=brown>"&SucDelNum&"</font>&nbsp;张照片！</CENTER>"

End Sub


Sub passphoto()
	dim sql
	if Request("photoid")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请选择所要进行管理操作的相片！"
		Response.Write ErrMsg
	Else

		sql="update photo Set passed=True where picid in ("&Request("photoid")&")"
		conn.Execute(sql)

		Response.Write "<BR><BR><center>成功对照片进行审核操作！</center>"
	End if
End Sub


Function sizeadjust(byval fotow,byval fotoh,byval shrksize)
	sizeadjust=""
	if fotow="" or fotoh="" Then Exit Function
	if fotow>0 and fotoh>0 Then
		if fotow>shrksize or fotoh>shrksize Then
			if  fotow>=fotoh Then sizeadjust="width="&shrksize Else sizeadjust="height="&shrksize
		End if
	Else
		sizeadjust="width="&shrksize&" height="&shrksize
	End if
End Function

%>
<!--#include file=include/chkfso.asp-->

