<!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<%Head()
	dim admin_flag
	admin_flag=",16,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用，请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		Call Ms_error()
	End If
		Main(1)
		Select Case Request("action")
		Case "album"''读取数据列表
		call album()
		Case "folder"''目录管理
		call folder()
		Case "Toset"''执行操作
		call Toset()
		Case "viewal"''查看相册
		call viewal()
		Case "folder_s"
		call folder_s()
		Case Else
		call alIndex()''搜索表单
		End Select
		Main(0)
		Footer()

sub main(Str)
if Str=1 then%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
  <tr> 
    <th height="23" colspan="8" class="tableHeaderText">相册管理中心</th>
  </tr>
  <tr> 
    <td width="23%" height="25" align="center" class="forumrow">注意事项</td>
    <td width="77%" height="25" class="forumrow" colspan="7">
	<li>删除相册将一并删除本地上传文件；</li>
	<li>可进行审核、删除、移动操作；</li>
	<li>目录删除将删除目录下所有文件；</li>
	<li>删除必须服务器支持FSO权限方能使用，FSO使用帮助请浏览微软网站。如果您服务器不支持FSO请手动管理。</li></td>
  </tr>
  <tr> 
    <td height="29" align="center" class="forumRowHighlight">快捷方式</td>
	<td width="77%" height="29" class="forumRowHighlight" colspan="7"><a href="album.asp">管理首页</a> 
      | <a href="?action=folder">相册目录</a> | <a href="?action=album&t=1">所有相册</a> 
      | <a href="?action=album&t=2">最新100</a> | <a href="?action=album&t=3">人气100</a> 
      | <a href="?action=album&t=4">未审相册</a> | <a href="?action=album&t=5">本地上传</a> | <a href="?action=album&t=6">网络贴图</a></td>
  </tr>
  <%
	Else
%>
</table>
<p></p>
<%end if
end sub

sub alIndex()''搜索页%>
<tr>
<th colspan=8 align=left height=23>高级搜索表单</th>
</tr>
<FORM METHOD=POST ACTION="?action=album">
<input name="t" type="hidden" value=8>
<tr align=center height=23>
<td class=forumrow width="16%"><B>用户名</B></td>
<td class=forumrow colspan=7 align="left"><input name="Username" type="text" size="20">&nbsp;<input type=checkbox name="like" value="1" checked>
      完整匹配</td>
</tr>
<tr align=center height=23>
<td class=forumrow width="16%"><B>相册状态</B></td>
<td class=forumrow colspan=7 align="left"><input name="Checked" type="radio" value="1" checked>
      已审<input name="Checked" type="radio" value="0">未审</td>
</tr>
<tr align=center height=23>
<td class=forumrow width="16%"><B>相册来源</B></td>
<td class=forumrow colspan=7 align="left"><input name="LoN" type="radio" value="0" checked>
      网络<input name="LoN" type="radio" value="1">本地</td>
</tr>
<tr>
<td width=100% class=forumrow align=center colspan=8><input name="submit" type=submit value="  搜  索  "></td>
</tr>
</form>
<%end sub

sub folder()''目录管理
strFileName="album.asp?action="&Request("action") & ""
call tumppages()
dim sql
sql = " id,Phototype,Username,Isphoto,IsShell,Hits,Allpic,Addtime "%>
<tr>
<th colspan=8 align=left height=23>相册目录管理</th>
</tr>
<FORM METHOD=POST ACTION="?action=folder_s">
<tr align=center height=23>
<td class=forumRowHighlight width="16%"><B>用户名</B></td>
<td class=forumRowHighlight width="20%"><B>相册名称</B></td>
<td class=forumRowHighlight width="8%"><B>目录属性</B></td>
<td class=forumRowHighlight width="8%"><B>图片数</B></td>
<td class=forumRowHighlight width="12%"><B>目录封面</B></td>
<td class=forumRowHighlight width="17%"><B>建立时间</B></td>
<td class=forumRowHighlight width="6%"><B>人气</B></td>
<td class=forumRowHighlight><B>操作</B></td>
</tr>
<%set rs=server.createobject("adodb.recordset")
Sql = "SELECT " & sql & " from Ms_Uphtype ORDER BY ID DESC"
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%>
<tr align=center height=23>
<td class=forumrow width="16%"><a href="admin_user.asp?action=modify&username=<%=rs("username")%>"><%=rs("username")%></a></td>
<td class=forumrow width="20%" align="left"><a href=?action=album&t=7&id=<%=rs(0)%>><%=rs(1)%></a></td>
<td class=forumrow width="8%"><%if rs(4)=0 then
				  response.Write("[公开]")
				  elseif rs(4)=1 then
				  response.Write("[<font color=blue>私有</font>]")
				  else
				  response.Write("[<font color=red>密码</font>]")
				  end if%></td>
<td class=forumrow width="8%"><%=rs(6)%></td>
<td class=forumrow width="12%"><%if left(rs(3),3)="Pre" then
response.write("<img src=../"&rs(3)&" width=""50"" border=""0"" align=""absmiddle""></a>")
elseif left(rs(3),3)="Alb" then
response.write("<img src=../"&SaveUpFilesPath&rs(3)&" width=""50"" border=""0"" align=""absmiddle""></a>")
elseif rs(3)<>"" then
response.write("<img src="&rs(3)&" width=""50"" border=""0"" align=""absmiddle""></a>")
else
response.write("<img src=../images/nophoto_up.gif width=""50"" border=""0"" align=""absmiddle""></a>")
end if%></td>
<td class=forumrow width="17%"><%=rs(7)%></td>
<td class=forumrow width="6%"><%=rs(5)%></td>
<td class=forumrow><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  end if
  if totalrec>0 then%>
  <tr align="center"> 
      <td height="24" colspan="8" class=forumrow> <%
		  	call showpage(strFileName)
		  %></td>
    </tr>
<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow align=right><input type="radio" name="faction" value=1>删除目录&nbsp;&nbsp;
全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"></td>
    </tr>
</form>
<%end sub

sub folder_s()''目录操作
dim delid,fixid
response.write "<tr><th colspan=8 height=23 align=left>执行结果</th></tr>"
	if request("Vipaction")="" then
		response.write "<tr><td colspan=8 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	delid=replace(request.form("id"),"'","")
	delid=replace(delid,";","")
	delid=replace(delid,"--","")
	delid=replace(delid,")","")
	fixid=replace(delid,",","")
	fixid=Trim(replace(fixid," ",""))
	If Not IsNumeric(fixid) Then
		response.write "<tr><td colspan=8 class=forumrow>请选择相关记录。</td></tr>"
		founderr=true
	End If
	if not founderr then
	dim D_Filename,D_Viewname,objFSO,Maxnum
		if request("faction")=1 then''删除操作
		Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		set rs=Conn.Execute("select Fid,LorN,Filename,Viewname from Ms_Upphoto where FTypes in ("&delid&")")
				if not (rs.eof and rs.bof) then
				Maxnum=0
					do while not rs.eof
					if rs(1)=0 then''判断是否为本地上传
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					else''本地上传删除本地文件
						D_Filename=rs(2)
						D_Viewname=rs(3)
						if objFSO.fileExists(Server.MapPath("../"&SaveUpFilesPath&D_Filename)) then
							objFSO.DeleteFile(Server.MapPath("../"&SaveUpFilesPath&D_Filename))
						End if
						if objFSO.fileExists(Server.MapPath("../"&UpfilePreview&D_Viewname)) then
							objFSO.DeleteFile(Server.MapPath("../"&UpfilePreview&D_Viewname))
						End if
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					end if
					rs.movenext
					Maxnum=Maxnum+1
					loop
					else
					response.write "<tr><td colspan=8 class=forumrow>不存在记录。</td></tr>"
				end if
				rs.close
				Conn.Execute("delete from Ms_Uphtype where id in ("&delid&")")
				conn.execute("Update Ms_setup set Uploadph=Uploadph-"&Maxnum&" where Cid=1")
				response.write "<tr><td colspan=8 class=forumrow>删除目录成功。</td></tr>"
			else
			response.write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
	end if
end if
end sub


sub album()
strFileName="album.asp?action="&Request("action") & "&t="&request("t")&"&LoN="&request("LoN")&"&Checked="&request("Checked")&""
call tumppages()
dim sql
sql = " FID,Username,Filename,Viewname,FileTypes,FileSize,Hits,Checked,Addtime,LorN "
%>
<tr>
<th colspan=8 align=left height=23>搜索结果</th>
</tr>
<FORM METHOD=POST ACTION="?action=Toset">
<tr align=center height=23>
<td class=forumRowHighlight width="16%"><B>用户名</B></td>
<td class=forumRowHighlight width="7%"><B>属性</B></td>
<td class=forumRowHighlight width="25%"><B>图片</B></td>
<td class=forumRowHighlight width="8%"><B>大小</B></td>
<td class=forumRowHighlight width="7%"><B>状态</B></td>
<td class=forumRowHighlight width="17%"><B>制作时间</B></td>
<td class=forumRowHighlight width="6%"><B>人气</B></td>
<td class=forumRowHighlight><B>操作</B></td>
</tr>
<%dim sqlstr,Tsqlstr
set rs=server.createobject("adodb.recordset")
Select Case Request("t")
	Case 1
		Sql = "SELECT " & sql & " from Ms_Upphoto ORDER BY FID DESC"
	Case 2
		Sql = "SELECT top 100 " & sql & " from Ms_Upphoto ORDER BY FID DESC"
	case 3
		Sql = "SELECT top 100 " & sql & " from Ms_Upphoto ORDER BY hits DESC"
	case 4
		Sql = "SELECT " & sql & " from Ms_Upphoto Where Checked=0 ORDER BY FID DESC"
	case 5
		Sql = "SELECT " & sql & " from Ms_Upphoto Where LorN=1 ORDER BY FID DESC"
	case 6
		Sql = "SELECT " & sql & " from Ms_Upphoto Where LorN=0 ORDER BY FID DESC"
	case 7
		Sql = "SELECT " & sql & " from Ms_Upphoto Where FTypes="&request("id")&" ORDER BY FID DESC"	
	case 8
	sqlstr=""''搜索开始
	if request("username")<>"" then
			if request("like")=1 then
			sqlstr=" username='"&request("username")&"'"
			else
			sqlstr=" username like '%"&request("username")&"%'"
			end if
		end if
		if request("Checked")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and Checked="&request("Checked")&" "
			else
			sqlstr=" Checked="&request("Checked")&" "
			end if
		end if
		if request("LoN")<>"" then
			if sqlstr<>"" then
			sqlstr=sqlstr & " and LorN="&request("LoN")&" "
			else
			sqlstr=" LorN="&request("LoN")&" "
			end if
		end if
		if sqlstr<>"" then
		Sql = "SELECT " & sql & " from Ms_Upphoto Where " & sqlstr & " ORDER BY FID DESC"	
		else
		Response.Write "<tr><td colspan=8 class=forumrow>搜索条件不能都为空。</td></tr>"
		Response.End
		end if			
	case else
		Response.Write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		Response.End
	End Select
	rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%>
<tr align=center height=23>
<td class=forumrow width="16%"><a href="admin_user.asp?action=modify&username=<%=rs(1)%>"><%=rs(1)%></a></td>
    <td class=forumrow width="7%"><img src="../images/files/<%=rs(4)%>.gif" border=0></td>
    <td class=forumrow width="25%" align="left">
	<%response.write("<a href=""?action=viewal&id="&rs(0)&""" Title=""查看图片"">")
	if rs(9)=1 then
	response.write("<img src=../"&rs(3)&" width=""50"" border=""0"" align=""absmiddle""></a>")
response.Write("&nbsp;(<font color=red>本地</font>)")
else
response.write("<img src="&rs(3)&" width=""50"" border=""0"" align=""absmiddle""></a>")
response.Write("&nbsp;(<font color=blue>网络</font>)")
end if%></td>
<td class=forumrow width="8%"><%=rs(5)%></td>
<td class=forumrow width="7%"><%if rs(7)=1 then
	  response.Write("已审核")
	  elseif rs(7)=0 then
	  response.Write("<font color=red>未审核</font>")
	  elseif rs(7)=2 then
	  response.Write("<font color=red>不通过</font>")
	  end if%></td>
<td class=forumrow width="17%"><%=rs(8)%></td>
<td class=forumrow width="6%"><%=rs(6)%></td>
<td class=forumrow><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  else
  response.Write("<tr><td colspan=8 class=forumrow>暂时数据。</td></tr>")
  end if
  if totalrec>0 then%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow><%
		  	call showpage(strFileName)
		  %></td>
    </tr>
<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow align="right"><input type="radio" name="alaction" value="1">删除记录
	  <input type="radio" name="alaction" value="2">审核操作
	  <select name="chkset">
	  <option value=""></option>
	  <option value=1>选定审核</option>
	  <option value=2>全部审核</option>
	  <option value=3>选定取消</option>
	  <option value=4>全部取消</option>　
	  </select>
	  <input type="radio" name="alaction" value="3">删除未完成记录
	  
全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"></td>
    </tr>
</form>
<%end sub

sub Toset()''相册设置
dim delid,fixid
response.write "<tr><th colspan=8 height=23 align=left>执行结果</th></tr>"
	if request("alaction")="" then
		response.write "<tr><td colspan=8 class=forumrow>请指定相关参数。</td></tr>"
		founderr=true
	end if
	delid=replace(request.form("id"),"'","")
	delid=replace(delid,";","")
	delid=replace(delid,"--","")
	delid=replace(delid,")","")
	fixid=replace(delid,",","")
	fixid=Trim(replace(fixid," ",""))
	if not founderr then
	dim D_Filename,D_Viewname,objFSO
		if request("alaction")=1 then''删除操作
		Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		set rs=Conn.Execute("select Fid,LorN,Filename,Viewname from Ms_Upphoto where Fid in ("&delid&")")
				if not (rs.eof and rs.bof) then
					do while not rs.eof
					if rs(1)=0 then''判断是否为本地上传
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					else''本地上传删除本地文件
						D_Filename=rs(2)
						D_Viewname=rs(3)
						if objFSO.fileExists(Server.MapPath("../"&SaveUpFilesPath&D_Filename)) then
							objFSO.DeleteFile(Server.MapPath("../"&SaveUpFilesPath&D_Filename))
						End if
						if objFSO.fileExists(Server.MapPath("../"&UpfilePreview&D_Viewname)) then
							objFSO.DeleteFile(Server.MapPath("../"&UpfilePreview&D_Viewname))
						End if
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					end if
					rs.movenext
					loop
					else
					response.write "<tr><td colspan=8 class=forumrow>不存在记录。</td></tr>"
				end if
				rs.close
				dim Maxnum
				Maxnum=ubound(split(delid,","))
				conn.execute("Update Ms_setup set Uploadph=Uploadph-"&(Maxnum+1)&" where Cid=1")
				response.write "<tr><td colspan=8 class=forumrow>删除成功。</td></tr>"
		elseif request("alaction")=2 then''审核操作
			if request("chkset")=1 then''选定审核
			Conn.Execute("Update Ms_Upphoto set Checked="&Cint(request("chkset"))&" where Fid in ("&delid&")")
				response.write "<tr><td colspan=8 class=forumrow>选定相册审核成功。</td></tr>"
			elseif request("chkset")=2 then''全部审核
			Conn.Execute("Update Ms_Upphoto set Checked=1 where Checked=0")
				response.write "<tr><td colspan=8 class=forumrow>全部相册审核成功。</td></tr>"
			elseif  request("chkset")=3 then''选定撤消
			Conn.Execute("Update Ms_Upphoto set Checked=0 where Fid in ("&delid&")")
				response.write "<tr><td colspan=8 class=forumrow>选定相册撤消审核成功。</td></tr>"
			elseif  request("chkset")=4 then''全部撤消
			Conn.Execute("Update Ms_Upphoto set Checked=0 where Checked=1")
				response.write "<tr><td colspan=8 class=forumrow>全部相册撤消审核成功。</td></tr>"
			else
				response.write "<tr><td colspan=8 class=forumrow>请选择审核操作项。</td></tr>"
			end if
		elseif request("alaction")=3 then''删除未完成记录
		Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		set rs=Conn.Execute("select Fid,LorN,Filename,Viewname from Ms_Upphoto where Flag=0")
			if not (rs.eof and rs.bof) then
					do while not rs.eof
					if rs(1)=0 then''判断是否为本地上传
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					else''本地上传删除本地文件
						D_Filename=rs(2)
						D_Viewname=rs(3)
						if objFSO.fileExists(Server.MapPath("../"&SaveUpFilesPath&D_Filename)) then
							objFSO.DeleteFile(Server.MapPath("../"&SaveUpFilesPath&D_Filename))
						End if
						if objFSO.fileExists(Server.MapPath("../"&UpfilePreview&D_Viewname)) then
							objFSO.DeleteFile(Server.MapPath("../"&UpfilePreview&D_Viewname))
						End if
						Conn.Execute("delete from Ms_Upphoto where Fid="&rs(0)&"")
					end if
					rs.movenext
					loop
					else
					response.write "<tr><td colspan=8 class=forumrow>不存在记录。</td></tr>"
				end if
				rs.close
				response.write "<tr><td colspan=8 class=forumrow>删除成功。</td></tr>"
		else
			response.write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"	
		end if
	end if
end sub

sub viewal()''查看相册
sql="select Username,Filename,Viewname,FileTypes,FileSize,Hits,Checked,Addtime,LorN from [Ms_Upphoto] where Fid="&request("id")&""
		set rs=conn.execute(Sql)
		if not (rs.eof and rs.bof) then%>
<tr><th colspan=8 height=23 align=center><%=rs(0)%> 的相册</th></tr>
<tr>
<td width=100% class=forumRowHighlight colspan=8 align=center>来自：<%if rs(8)=1 then
response.write("本地")
else
response.Write("网络")
end if%>&nbsp;&nbsp;时间：<%=rs(7)%>&nbsp;&nbsp;人气：<%=rs(5)%>&nbsp;&nbsp;状态：
<%if rs(6)=1 then
	  response.Write("已审核")
	  elseif rs(6)=0 then
	  response.Write("<font color=red>未审核</font>")
	  elseif rs(6)=2 then
	  response.Write("<font color=red>不通过</font>")
	  end if%></td>
</tr>
<tr>
<td width=80% class=forumrow colspan=8 align=center>
<%if rs(8)=1 then
response.write("<img src=../"&SaveUpFilesPath&""&rs(1)&" border=0 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"">")
else
response.write("<img src="&rs(1)&" border=0 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333"">")
end if%>
</td>
</tr>
<tr>
<td width=20% class=forumrow align=right>文件格式</td>
<td width=80% class=forumrow colspan=7><img src="../images/files/<%=rs(3)%>.gif" border=0></td>
</tr>
<tr>
<td width=20% class=forumrow align=right>文件大小</td>
<td width=80% class=forumrow colspan=7><%=rs(4)%>
</td>
</tr>
<%end if
rs.close
end sub%>