<!--#INCLUDE FILE="conn.asp" -->
<!--#include file="admin_Checkuser.asp"-->
<!--#include file="inc/htmlencode.asp"-->
<HTML><HEAD><title><%=StrVar(1)%>--管理页面</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<!--#include file="inc/admin_main.css"-->
</HEAD>
<BODY leftMargin=0 topMargin=0 marginwidth="0" marginheight="0">
<%
if  not sysadmin or session("adminlogin")<>"0K" Then
	Errmsg=Errmsg+"<br>"+"<li>本页面为管理员专用，请<a href=admin_index.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()
		ElseIf Request.form("action")="反审核" Then
			Call nopassphoto()
		Else
			Call photolist()
		End if
		
End Sub


Sub photolist()

dim sql,rs,altinfo,depth
dim totalpages,currentpage
dim i,classid,phototype
phototype=cint(request("type"))
if phototype="" or phototype=0 then
phototype=0
else
phototype=1
end if
 
classid=trim(request("classid"))

if classid="" then classid=0

response.write ""&_
    "<script language=JavaScript src=""../inc/jsfun.asp""></script>"&_
	"<Script language=""javascript"" src=""../inc/PopText.asp""></Script>"&_
	"<script language=JavaScript src=""inc/showpic.js""></script>"&_
	"<table width=""90%"" align=center border=0 Class=TableBorder><tr><td class=forumRowHighlight>当前照片审核功能已<font color=brown>"
	if BoolVar(7) then response.write "开启" else response.write "关闭"
	response.write "</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>"
	if phototype=1 then response.write"<a href=?type=0&classid="&classid&">未审核的相片</a>" else response.write"<a href=?type=1&classid="&classid&">已审核的相片</a>"
	response.write"</b></td><td align=right class=forumRowHighlight>查看指定学校相片: "

	dim tmprsc,tmpsqlc
		Response.write"<select name=""classid"" id=""classid"" onChange=""location.href='?type="&phototype&"&classid='+this.options[selectedIndex].value"">"
		Response.write "<option value=0>全部学校相片</option>"
		tmpsqlc="Select classname,classid from class order by classid"
		Set tmprsc=Conn.Execute(tmpsqlc)
		if not tmprsc.eof Then
        do until tmprsc.eof
		Response.write "<option value="&tmprsc(1)&""
		if tmprsc(1)=clng(classid) then
		response.write " selected "
		end if
		Response.write ">├"&tmprsc(0)&"</option>"
			tmprsc.movenext
		loop
		end if
		set tmprsc=nothing
		Response.write"</select>"


Response.write"</td></tr></table>"&_
	"<TABLE width=""90%"" Class=TableBorder cellspacing=1 cellpadding=5 align=center>"&_
	"<form action=admin_photo.asp method=post>"&_
	"<TR><Th>"
	if phototype=1 then response.write"已审核的相片" else response.write"未审核的相片"
	response.write"</Th></TR>"&_
	"<TR><TD align=center height=170  class=forumrow>"&_
	"<TABLE border=0 width=""100%"" cellspacing=0 cellpadding=0>"

Set rs = server.CreateObject("ADODB.Recordset")
if classid>0 then
sql="Select filename,title,picid,width,height,classid,[file],smallfilename,depth,name,uptime,visitcount from photo where passed="&phototype&" and classid="&classid&" order by picid desc"
else
sql="Select filename,title,picid,width,height,classid,[file],smallfilename,depth,name,uptime,visitcount from photo where passed="&phototype&" order by picid desc"
end if

rs.open sql,conn,1,1

if rs.eof and rs.bof Then 
if phototype=1 then response.write"<tr><td>&nbsp;&nbsp;没有已审核的相片！" else response.write"<tr><td>&nbsp;&nbsp;没有要审核的照片！"
	Response.Write "</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"">"
		
		if rs(8)<=8 Then depth=2^(rs(8)) Else depth=rs(8)&"b"
		
        altinfo="相片提供:"&rs(9)&"&lt;br&gt;"&_
		"上传时间:"&formatdatetime(rs(10),vbShortDate)&"&nbsp;"&formatdatetime(rs(10),vbShortTime)&"&lt;br&gt;"&_
		"人气指数:"&rs(11)&"&lt;br&gt;"&_
		"相片属性:"&rs(3)&"x"&rs(4)&"x"&depth

			Response.Write "<TABLE cellSpacing=2 cellPadding=0 width=120 border=0 Class=TableBorder>"&_
			"<TR><TD height=120 align=center>"&_
			"<!--<table border=1 cellspacing=0 cellpadding=0>"&_
			"<tr><td>--><IMG src=../"&rs(6)&rs(7)&" "&sizeadjust(rs(3),rs(4),120)&" onclick=""javascript:ShowPic('"&rs(5)&"','"&rs(2)&"')"" onmouseover=""this.style.cursor='hand'"" title="""&altinfo&""">"&_
			"<!--</td></tr></table>-->"&_
			"</TD></TR></TABLE>"&_
			"<TABLE cellSpacing=0 cellPadding=0  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><td Class=forumrowhighlight>"&_
		"<TABLE width=100% border=0>"&_
		"<TR>"&_
		"	<TD><input type=checkbox name=chkall onclick=""CheckAll(this.form)"">全选/取消</TD>"&_
		"<td>"
	if currentpage=0 Then currentpage=1
	if not (currentpage=1 or totalpages=0) Then
		Response.Write "　<a href=?type="&phototype&"&classid="&classid&"&Page="&currentpage-1&">&nbsp;上一页</a>"
	End if
			
	if not (currentpage=totalpages or totalpages=0) Then
		Response.Write "　<a href=?type="&phototype&"&classid="&classid&"&Page="&currentpage+1&">&nbsp;下一页</a>"
	End if

	Response.Write "</td><td>转到第 <select name=""page"" style=""width:35px"" onChange=""location.href='?type="&phototype&"&classid="&classid&"&page='+this.options[selectedIndex].value"">"

     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 align=right>页次 "&currentpage&"&nbsp;/&nbsp;"&totalpages
   Response.Write "</td>"&_
		"	<TD align=right><input type=submit value=删除图片 name=action class=button>&nbsp;"
		if phototype=-1 then response.write"<input type=submit value=反审核 name=action class=button>" else response.write"<input type=submit value=通过审核 name=action class=button>"
		response.write"</TD></TR>"&_
		"</TABLE>"&_
		"</td></tr></form></table>"
		end if
End Sub



Sub DeletePhoto()

Dim idlist,idarr,photoid
dim fso,photofile,filepath,file
dim rs,sql
if Request("photoid")="" Then
	Errmsg=Errmsg+"<br>"+"<li>请选择所要进行管理操作的相片！"
	Call Error("Information",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,[file],smallfilename 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="../"&rs(2)&rs(1)
			filepath=server.mappath(photofile)
			if fso.FileExists(filepath)=True Then
				Set file = fso.GetFile(filepath)
				file.delete  
			End if
			Set file=Nothing
			'''删小图
			photofile="../"&rs(2)&rs(3)
			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
Call adminmsg("恭喜，成功删除&nbsp;<font color=brown>"&SucDelNum&"</font>&nbsp;张照片！")

End Sub


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

		sql="update photo Set passed=1 where picid in ("&Request("photoid")&")"
		conn.Execute(sql)
    Call adminmsg("恭喜，成功对照片进行审核操作！")

	End if
End Sub
Sub nopassphoto()
	dim sql
	if Request("photoid")="" Then
		Errmsg=Errmsg+"<br>"+"<li>请选择所要进行管理操作的相片！"
	Call Error("Information",ErrMsg)
	Else

		sql="update photo Set passed=0 where picid in ("&Request("photoid")&")"
		conn.Execute(sql)
    Call adminmsg("恭喜，成功对照片进行反审核操作！")

	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="inc/chkfso.asp"-->