<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../sub.asp"-->
<%
ClassID=Clng(request("ClassID"))
title=request("title")

if title="" then
	if ClassID=0 then
		sql="select a.titleID,a.titleName,a.titleNum,a.Photoer,a.ClassID,a.Recomm,a.updatetime,b.ID,b.photo,b.Num,b.tuijian,b.index from title as a,imgbook as b where b.titleID=a.titleID"
	else
		sql="select a.titleID,a.titleName,a.titleNum,a.Photoer,a.ClassID,a.Recomm,a.updatetime,b.ID,b.photo,b.Num,b.tuijian,b.index from title as a,imgbook as b where b.titleID=a.titleID and a.ClassID="&ClassID
	end if
else
	sql="select a.titleID,a.titleName,a.titleNum,a.Photoer,a.ClassID,a.Recomm,a.updatetime,b.ID,b.photo,b.Num,b.tuijian,b.index from title as a,imgbook as b where b.titleID=a.titleID and (a.titleName like '%"&title&"%' or a.Photoer like '%"&title&"%')"
end if
sql=sql&" order by a.titleID desc,b.ID desc"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="images/bbs.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function ChangeClass()
{
this.location.href="manage.asp?ClassID="+document.form2.ClassID.value;
}
function unselectall()
{
    if(document.myform.chkAll.checked){
	document.myform.chkAll.checked = document.myform.chkAll.checked&0;
    } 	
}

function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "")
       e.checked = form.chkAll.checked;
    }
  }
function ConfirmDel(){
	if(confirm("确定要删除选中的图片吗？本操作是无法恢复的！"))
		return true;
	else
		return false;
}
</script>
<style type="text/css">
<!--
.style1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</head>
<body leftmargin="0" topmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <form name="form2" method="post" action="manage.asp">
      <td width="17%" align="center" bgcolor="#799AE1" style="border-bottom: 1 solid #000000"> 
      <%ShowClass(ClassID)%><input name="submit" type="submit" id="submit" value="转到"></td></form>
      <td colspan="4" align="center" bgcolor="#799AE1" style="border-bottom: 1 solid #000000"><font color="#FF0000"><%=Session("manage")%></font> <%if session("flag")<>0 then%>
        管理自己上传的图片 
        <%else%>
        正在管理所有图片 
        <%end if%> </td>
    <form name="form3" method="post" action="manage.asp">
      <td width="35%" colspan="2" bgcolor="#799AE1" style="border-bottom: 1 solid #000000"> 
        查找 
        <input name="title" type="text" id="title" size="8" title="请输入标题或摄影师的名字">
        <input type="submit" name="Submit" value="确定">
     </td> </form>
  </tr>
</table>
<table width="98%" border="0" align="center" cellpadding="6" cellspacing="0">
<form action="delete.asp" method="post" name="myform" onsubmit="return ConfirmDel();"><tr>
    <td width="32">ID</td> 
    <td width="151" height="20">&nbsp;组图名称</td>
    <td width="95"><div align="center">缩略图</div></td>
    <td width="97"><div align="center">上传日期</div></td>
    <td width="98"><div align="center">首推荐</div></td>
    <td width="80"><div align="center">顶图</div></td>
    <td width="97"><div align="center"><font color="#FF0000">摄影师</font></div></td>
    <td width="253" align="center">操作</td>
  </tr>
  <% 
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1

rs.pagesize=10
rs.cachesize=10
currentpage=Clng(request("page"))
if currentpage<1 then currentpage=1
if currentpage>rs.pagecount then currentpage=rs.pagecount
rs.absolutepage=currentpage

Do While Not rs.Eof %>
  <tr> 
    <td><input name="id" type="checkbox" id="id" value="<%=rs("ID")%>"  onclick="unselectall()"></td> 
    <td height="20"><a href="../see.asp?ID=<%=rs("ID")%>&titleID=<%=rs("titleID")%>" target=_blank class="black"><%=rs("titleName")%></a></td>
    <td height="20"><div align="center"><script src="../showpic.asp?location=admin&jpgsize=s&FileName=<%=rs("photo")%>"></script></div></td>
    <td height="20"><div align="center"><%=rs("updatetime")%></div></td>
    <td height="20" align="center">
        <%if rs("tuijian")=1 then%>
        <span class="style1">√</span>        
        <%else%>
        <strong>×</strong>        
        <%end if%></td>
    <td height="20" align="center"><%if rs("index")=1 then%>
      <span class="style1">√</span>
      <%else%>
      <strong>×</strong>
      <%end if%>
    </td>
    <td height="20"><div align="center"><font color="#FF0000"><%=rs("Photoer")%></font></div></td>
    <td height="20" align="center"><a href="setRec.asp?rec=1&ID=<%=rs("ID")%>&action=1&page=<%=currentpage%>" class="black">推荐</a>|<a href="setRec.asp?rec=0&ID=<%=rs("ID")%>&action=1&page=<%=currentpage%>" class="black">不推荐</a>|<a href="modify.asp?id=<%=rs("id")%>&Num=<%=rs("Num")%>&page=<%=currentpage%>&titleName=<%=rs("titleName")%>&ClassID=<%=rs("ClassID")%>&titleID=<%=rs("titleID")%>" class="black">修改</a>|<a href="delete.asp?id=<%=rs("ID")%>&titleID=<%=rs("titleID")%>" class="black">删除</a>|<a href="setRec.asp?rec=1&ID=<%=rs("ID")%>&action=3&page=<%=currentpage%>" class="black">顶</a>|<a href="setRec.asp?rec=0&ID=<%=rs("ID")%>&action=3&page=<%=currentpage%>" class="black">不顶</a></td>
  </tr>
  <%
i=i+1
rs.MoveNext
If i>=rs.pagesize Then Exit Do
Loop  %>
  <tr>
    <td height="20" align="center"><input name="chkAll" type="checkbox" id="chkAll" value="1" onclick=CheckAll(this.form)></td>
    <td height="20">选中本页所有图片</td>
    <td height="20" colspan="6" style="padding-left: 20px;"><input type="submit" name="Submit3" value="删除选中的图片"></td>
    </tr>
</form>
</table>
<form name="form1" method="post" action="manage.asp">
  <table width="438" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td><div align="center">共有图片:<font color=red><%=rs.recordcount%></font> 张,<%=rs.pagecount%>页&nbsp;&nbsp;
          <%if currentpage>1 then%>
          <a href=manage.asp class="black">首页</a>&nbsp; <a href=manage.asp?page=<%=currentpage-1%> class="black"> 
          上一页</a>
          <%end if%>
          <%if currentpage<rs.pagecount then%> &nbsp;
          <a href=manage.asp?page=<%=currentpage+1%> class="black">下一页</a>&nbsp;  <a href=manage.asp?page=<%=rs.pagecount%> class="black">尾页</a>
          <%end if%>
          每页显示<%=rs.pagesize%>张 &nbsp; &nbsp;&nbsp; 
          <input name="search" type="hidden" id="search" value="<%=search%>">
          <input name="key" type="hidden" id="key" value="<%=key%>">
        </div></td>
    </tr>
  </table>
</form>
</body>
</html>
<%
set rs=server.CreateObject("adodb.recordset")
sql="select titleID,titleCount,clickCount from title order by titleID desc"
rs.open sql,conn,1,3
do while not rs.eof 
	set rs1=conn.execute("select count(*),sum(click) from imgbook where titleID="&cint(rs("titleID")))
    if RS1(0)<>0 then
	rs(1)=cint(rs1(0))
	rs(2)=cint(rs1(1))
	rs.update
	End if
	rs.movenext
	rs1.close
loop
set rs1=nothing
rsclose

set rs=server.CreateObject("adodb.recordset")
rs.open "select * from title where titleCount=0",conn,1,3
do while not rs.eof 
	rs.delete
	rs.update
	rs.movenext
loop
rsclose

ConnClose()
%>