<!--#include file="conn.asp"-->
<%
if session("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
else
if request.cookies("timesshop")("admin")="" then
conn.close
set conn = nothing
response.Write "<script language='javascript'>alert('请先登录！');history.go(-1);</script>"
response.End
end if
end if
%>
<title>管理评论</title>
<%dim action
action=FormatSQL(SafeRequest("action",0))
%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#6699cc">
  <tr bgcolor="#6699cc"> 
    <td height="20" colspan="2" align="center"><font color="#FFFFFF">管理评论</font></td>
  </tr>
  <tr> 
    <td height="20" bgcolor="#FFFFFF" align="center"><a href="admincomment.asp?action=no">未审核的评论</a></td>
    <td bgcolor="#FFFFFF" align="center"><a href="admincomment.asp?action=yes">已审核的评论</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <form name="form1" method="post" action="">
      <td height="200" colspan="2"> 
        <%
				Const MaxPerPage=20 
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    				if Not isempty(SafeRequest("page",1)) then
      				currentPage=Cint(SafeRequest("page",1))
   				else
      				currentPage=1
   				end if 
				set rs=server.CreateObject("adodb.recordset")
		  select case action
		  case "no"
		  rs.open "select product.name,product.id,review.reviewid,review.reviewcontent,review.ipaddr,review.reviewdtm from review,product where product.id=review.id and review.audit=0",conn,1,1
		  case "yes"
		  rs.open "select product.name,product.id,review.reviewid,review.reviewcontent,review.ipaddr,review.reviewdtm from review,product where product.id=review.id and review.audit=1",conn,1,1
		  end select
				if err.number<>0 then
				response.write "数据库中暂时无数据"
				end if
				if rs.eof And rs.bof then
       			Response.Write "<p align='center' class='contents'> 目前还没有任何评论！</p>"
   				else
	  				totalPut=rs.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 totalput,MaxPerPage,"admincomment.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookmark
            				bookmark=rs.bookmark
            				showContent
             				showpage totalput,MaxPerPage,"admincomment.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"admincomment.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0

			%>
        <table width="90%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
          <tr bgcolor="#FFFFFF"> 
            <td width="29%" align="center"><font color="#FF6600">评论商品名称</font></td>
            <td width="25%" align="center"><font color="#FF6600">评论正文</font></td>
            <td width="20%" align="center"><font color="#FF6600">评论时间</font></td>
            <td width="12%" align="center"><font color="#FF6600">来访IP</font></td>
            <td width="8%" align="center"><font color="#FF6600">操 作</font></td>
            <td width="8%" align="center"><font color="#FF6600">回 复</font></td>
          </tr>
          <%  
		 
		  do while not rs.eof%>
          <tr bgcolor="#FFFFFF" align="center"> 
            <td> 
              <%if len(rs("name"))>20 then
			response.write "<a href=../product.asp?id="&rs("id")&" target=_blank>"&left(trim(rs("name")),18)&"...</a>"
			else
			response.write "<a href=../product.asp?id="&rs("id")&" target=_blank>"&trim(rs("name"))&"</a>"
			end if
			%>
            </td>
            <td> 
              <% if len(rs("reviewcontent"))>20 then
			response.write "<a href=# onClick=""javascript:window.open('chkcomment.asp?id="&rs("reviewid")&"','','width=310,height=190,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"" title="&trim(rs("reviewcontent"))&">"&left(trim(rs("reviewcontent")),18)&"...</a>"
			else
			response.write "<a href=# onClick=""javascript:window.open('chkcomment.asp?id="&rs("reviewid")&"','','width=310,height=190,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"" title="&trim(rs("reviewcontent"))&">"&trim(rs("reviewcontent"))&"</a>"
			end if%>
            </td>
            <td><%=rs("reviewdtm")%></td>
            <td><%=rs("ipaddr")%></td>
            <td> <input name="audit" type="checkbox" id="audit" value="<%=rs("reviewid")%>"> 
            </td>
            <TD><a href=replyview.asp?id=<%=rs("reviewid")%>>回 复</a></TD>
          </tr>
          <%i=i+1
		  if i>=MaxPerPage then Exit Do
		  rs.movenext
		  loop
		  rs.close
		  set rs=nothing
		  %>
          <tr bgcolor="#FFFFFF"> 
            <td height="30" colspan="6" align="center"> 
              <%if action="no" then%>
              <input type="submit" name="Submit" value="通过审核" onClick="this.form.action='savecomment.asp?action=audit';this.form.submit()"> 
              <%end if%>
              &nbsp; <input type="button" name="Submit2" value="删 除" onClick="this.form.action='savecomment.asp?action=del';this.form.submit()"> 
              &nbsp;&nbsp;全选 
              <input type="checkbox" name="checkbox" value="Check All" onClick="mm()"> 
            </td>
          </tr>
        </table>
        <%  
				End Sub   
  
				Function showpage(totalnumber,maxperpage,filename)  
  				Dim n
  				
				If totalnumber Mod maxperpage=0 Then  
					n= totalnumber \ maxperpage  
				Else
					n= totalnumber \ maxperpage+1  
				End If
				
				Response.Write "<form method=Post action="&filename&"?action="&action&">"  
				Response.Write "<p align='center' class='contents'> "  
				If CurrentPage<2 Then  
					Response.Write "<font class='contents'>首 页 上一页</font> "  
				Else  
					Response.Write "<a href="&filename&"?page=1&action="&action&" class='contents'>首 页</a> "  
					Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&action="&action&" class='contents'>上一页</a> "  
				End If
				
				If n-currentpage<1 Then  
					Response.Write "<font class='contents'>下一页 末 页</font>"  
				Else  
					Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&action="&action&" class='contents'>"  
					Response.Write "下一页</a> <a href="&filename&"?page="&n&"&action="&action&" class='contents'>末 页</a>"  
				End If  
					Response.Write "<font class='contents'> 页次：</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"页</font> "  
					Response.Write "<font class='contents'> 共有"&totalnumber&"条记录 " 
					Response.Write "<font class='contents'>" 
					Response.Write "</form>"  
				End Function  
			%>
      </td>
    </form>
  </tr>
</table>
<br>
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#6699cc">
  <tr> 
    <td height="20" bgcolor="#6699cc" align="center"><font color="#FFFFFF">其 它 操 作</font></td>
  </tr>
  <tr> 
    <td height="88" bgcolor="#FFFFFF"> 
      <table width="90%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#CCCCCC">
        <tr align="center">  
          <td height="20" bgcolor="#FFFFFF" >删除一周前未审核评论 &nbsp; <input type="submit" name="Submit4" value="确 认" onClick="if(confirm('您确定这样操作吗?')) location.href='savecomment.asp?action=delzhou';else return;"> 
          </td>
        </tr>
        <tr align="center"> 
          <td height="16" bgcolor="#FFFFFF" >删除所有未审核评论 &nbsp;&nbsp;&nbsp;
            <input type="submit" name="Submit4" value="确 认" onClick="if(confirm('您确定这样操作吗?')) location.href='savecomment.asp?action=delall';else return;"> 
          </td>
        </tr>
      </table></td>
  </tr>
</table>
<!--#include file="footer.asp"-->
</body>
</html>
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>
