<!--#include file="inc/conn1.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="Admin_ChkPurview.asp"-->
<!--#include file="inc/ubbcode.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/admin_code_Photo.asp"-->

<%


PurviewChecked=false
FileName="Admin_PhotoManage.asp"
ClassID=Trim(request("ClassID"))
keyword=trim(request("keyword"))
if keyword<>"" then 
	keyword=ReplaceBadChar(keyword)
end if
strField=trim(request("Field"))

if ClassID="" then
	ClassID=0
	if strField="" and  AdminPurview=2 and AdminPurview_Photo=3 and ManageType<>"MyPhoto" then
		set tClass=conn.execute("select ClassName,RootID,ParentID,Depth,ParentPath,Child,ClassMaster,ClassID From FlvClass where ClassMaster like '%" & AdminName & "%'")
		do while not tClass.eof
			if CheckClassMaster(tClass(6),AdminName)=true then
				ClassName=tClass(0)
				RootID=tClass(1)
				ParentID=tClass(2)
				Depth=tClass(3)
				ParentPath=tClass(4)
				Child=tClass(5)
				ClassMaster=tClass(6)
				ClassID=tClass(7)
				PurviewChecked=True
				exit do
			end if
			tClass.movenext
		loop
	end if
else
	ClassID=CLng(ClassID)
end if
if ClassID>0 and PurviewChecked=False then
	set tClass=conn.execute("select ClassName,RootID,ParentID,Depth,ParentPath,Child,ClassMaster From PhotoClass where ClassID=" & ClassID)
	if tClass.bof and tClass.eof then
		founderr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的栏目</li>"
		Call WriteErrMsg()
		response.end
	else
		ClassName=tClass(0)
		RootID=tClass(1)
		ParentID=tClass(2)
		Depth=tClass(3)
		ParentPath=tClass(4)
		Child=tClass(5)
		ClassMaster=tClass(6)
		PurviewChecked=CheckClassMaster(tClass(6),AdminName)
		if PurviewChecked=False and ParentID>0 then
			set tClass=conn.execute("select ClassMaster from PhotoClass where ClassID in (" & ParentPath & ")")
			do while not tClass.eof
				PurviewChecked=CheckClassMaster(tClass(0),AdminName)
				if PurviewChecked=True then exit do
				tClass.movenext
			loop
		end if
	end if
end if
if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if
if ManageType="MyPhoto" then
	FileName=FileName & "?ManageType=" & ManageType
	strFileName=FileName & "&ClassID=" & ClassID & "&strField=" & strField & "&keyword=" & keyword
else
	strFileName=FileName & "?ClassID=" & ClassID & "&strField=" & strField & "&keyword=" & keyword
end if

%>





<%
const MaxPerPage=10

if request("page")<>"" then
    currentPage=cint(request("page"))
else
	currentPage=1
end if

if request("action")="SetElite" then
	id=request("id")
	conn.execute("update mtv_photo set elite=1 where id=" &id)
elseif request("action")="CancelElite" then
	id=request("id")
	conn.execute("update mtv_photo set elite=0 where id=" &id)
elseif request("action")="Del" then
	mtv_id=request("id")

	sql="select * from mtv_img_list where mtv_id=" & mtv_id
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	do while not rs.eof
		imgUrl=replace(rs("imgpath"),"http://127.0.0.1/","")
		Set fso = CreateObject("Scripting.FileSystemObject")
		if fso.FileExists(server.MapPath(imgUrl)) then
			fso.DeleteFile(server.MapPath(imgUrl))
		end if
		set fso=nothing
		rs.movenext
	loop
	rs.close
	'删除表中数据
	conn.execute("delete from mtv_img_list where mtv_id=" & mtv_id)
	conn.execute("delete from mtv_Photo where id=" & mtv_id)
end if
%>
<html>
<head>
<title>图片管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="Admin_Style.css">
<link href="Common/Style.css" rel="stylesheet" type="text/css">
<div id="All">
<div id="ShowMain">
  <div class="TitleBar">通过丰富的配置,您可以建立一个属于您自己的播客家园.</div>
  <div id="TabContent">
    <div class="ShowSimpleCon">
<DIV id=All>
<SCRIPT language=javascript>
function ConfirmDel()
{
	if(confirm("确定要删除选中的相册吗？"))
		return true;
	else
		return false;
}

</SCRIPT>
</head>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="8" border="0" cellpadding="0" cellspacing="0">
  <tr>
  </tr>
</table>

<table width="100%" height="40" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="22"><%call Admin_ShowPath("图片管理")%></td>
    <td width="200" height="22" align="right">&nbsp;</td>
  </tr>
</table>
<%
sql="select * from mtv_photo order by id desc"

Set rsPhotoList= Server.CreateObject("ADODB.Recordset")
rsPhotoList.open sql,conn,1,1
if rsPhotoList.eof and rsPhotoList.bof then
	totalPut=0
		response.write "<p align='center'><br>没有任何视屏！<br></p>"
else
   	totalPut=rsPhotoList.recordcount
	if currentpage<1 then
   		currentpage=1
   	end if
   	if (currentpage-1)*MaxPerPage>totalput then
   		if (totalPut mod MaxPerPage)=0 then
     		currentpage= totalPut \ MaxPerPage
	  	else
	      	currentpage= totalPut \ MaxPerPage + 1
   		end if
   	end if
    if currentPage=1 then
       	showContent
       	showpage strFileName,totalput,MaxPerPage,true,true,"个相册"
 	else
     	if (currentPage-1)*MaxPerPage<totalPut then
       	   	rsPhotoList.move  (currentPage-1)*MaxPerPage
       		dim bookmark
           	bookmark=rsPhotoList.bookmark
            showContent
            showpage strFileName,totalput,MaxPerPage,true,true,"个相册"
       	else
	        currentPage=1
           	showContent
          	showpage strFileName,totalput,MaxPerPage,true,true,"个相册"
	    end if
	end if
end if
rsPhotoList.close
set rsPhotoList=nothing  

sub showContent
   	dim PhotoNum
    PhotoNum=0
%>
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
          <tr class="title" height="22"> 
            <td width="64"  height="22" align="center" bgcolor="f8f8f9"><strong>ID</strong></td>
            <td width="148" align="center" bgcolor="f8f8f9"><strong>缩略图</strong></td>
            <td width="547" align="center" bgcolor="f8f8f9" ><strong>图片名称</strong></td>
            <td width="154" align="center" bgcolor="f8f8f9" ><strong>图片作者</strong></td>
            <td width="78" align="center" bgcolor="f8f8f9" ><strong>查看次数</strong></td>
            <td width="176" align="center" bgcolor="f8f8f9" ><strong>操作</strong></td>
          </tr>
          <%do while not rsPhotoList.eof%>
          <tr > 
            <td width="64" align="center" bgcolor="#FFFFFF"><%=rsPhotoList("id")%></td>
            <td width="148" align="center" bgcolor="#FFFFFF"><a href="mv/mtv_play.asp?id=<%=rsPhotoList("id")%>"><img src="<%=rsPhotoList("s_images")%>" width="80" height="80" border="0"></a></td>
            <td bgcolor="#FFFFFF"> <%=rsPhotoList("title")%></td>
            <td width="154" align="center" bgcolor="#FFFFFF"><%=rsPhotoList("username") %></td>
            <td width="78" align="center" bgcolor="#FFFFFF"><%= rsPhotoList("click_num") %></td>
            <td width="176" align="center" bgcolor="#FFFFFF"> <%
            	response.write "<a href='?ID=" & rsPhotoList("ID") & "&Action=Del' onclick='return ConfirmDel();'>删除</a>&nbsp;"
            	if rsPhotoList("Elite")=False then	
					response.write "<a href='?ID=" & rsPhotoList("ID") & "&Action=SetElite'>设为推荐</a>"
				else
					response.write "<a href='?ID=" & rsPhotoList("ID") & "&Action=CancelElite'><font color=red>取消推荐</font></a>"
				end if
            %></td>
          </tr>
<%
		PhotoNum=PhotoNum+1
	   	if PhotoNum>=MaxPerPage then exit do
	   	rsPhotoList.movenext
	loop
%>
        </table>
<%
end sub
%>
<table width="100%" height="8" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
call CloseConn()
%>    </div>
    <div style="clear:both"></div>
  </div>
</div>
<div class="FooterDiv">
<p class="Text"><span>Copyright &copy; 2006-2007 <a href="Http://Www.WuhU263.Cn/" target="_blank">芜湖播客家园</a> 版权所有. 并保留一切权利.</p>
</div>
</div>
</body>
</html>