<?php
include "../../include/conn.php";
include "../../include/function.php";
include "../admin_loginstate.php";
include "../admin_version.php";
//'**************************************************************************************************
//' 软件名称: 盘锦DJ舞曲网CMS Content Management PjRen.Net
//' 版本编号: Version 2.5
//' 盘锦舞曲: http://www.pj57.com
//' 官方网站: http://www.pjren.net
//' 小说网站: http://www.hx39.com
//' 0427DJ网: http://www.0427dj.net
//' 官方论坛: http://www.tianjiazhen.com
//' 版权所有: 盘锦舞曲开发团队    盘锦人(QQ:814006710)
//' 郑重声明:
//'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
//'    2、盘锦网络事业部保留此软件的法律追究权利
//'**************************************************************************************************
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>下载管理</title>
<script type="text/javascript" language="javascript">var tentpath='<?php echo S_SitePath;?>';</script>
<link href="../images/alerts.css" rel="stylesheet" type="text/css" media="screen" />
<link  href="../images/style.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery.js"></script>
<script src="../js/alerts.js"></script>
<script language="javascript">
	$(document).ready(function(){
                $("#ChkAll").click(function(){
		if($(this).attr("checked")==true){
			$("input[name='S_ID[]']").each(function(){
				$(this).attr("checked",true);									 
			})							
		}else{
			$("input[name='S_ID[]']").each(function(){
				$(this).attr("checked",false);									 
			})							
		}
                });
	});
function del(id){
	jConfirm('您确定要删除该记录吗?', '操作提示', function(r) {
		if(r==true){
			window.location='?action=del&S_ID='+id;
			}
				});
	};
function delall(){
	jConfirm('您确定要执行操作吗?', '操作提示', function(r) {
		if(r==true){form2.submit();}
		});
};
function backpage(){
	window.history.go(-1);
	};
</script>
</head>
<body>
<?php
SystemPer(9);
$ac=SafeRequest("action","get");
if($ac=="del"){return Del();}
if($ac=="delall"){ return DelAll();}
if($ac==""){
               $sql="select * from s_down Order by S_ID desc";
}
		global $db;
		$Arr=getpagerow($sql,30);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$action=SafeRequest("action","get");
?>
<form id="form2" action="?action=delall" method="post" name="form2">
    <table  width="100%" border="0" cellpadding="0" cellspacing="0" class="tb_style">
    	<tr>
            <td  height="30" colspan="5" class="td_title">&nbsp;会员下载记录</td>
        </tr>
        <tr>
            <td width="10%" height="30" bgcolor="#FFFFFF" class="td_btop3">&nbsp;编号</td>
            <td width="38%" height="30" bgcolor="#FFFFFF" class="td_btop3">&nbsp;舞曲名称</td>
            <td width="23%" height="30" bgcolor="#FFFFFF" class="td_btop3">&nbsp;下载者</td>
            <td width="18%" height="30" align="center" bgcolor="#FFFFFF" class="td_btop3">下载时间</td>
            <td width="11%" height="30" align="center" bgcolor="#FFFFFF" class="td_btop3">操作</td>
        </tr>
<?php
$numdate="a";
if($result){
	while ($row = $db ->fetch_array($result)){
		$numdate="b";
?>
    <tr>
        <td height="30" class="td_border"><input type="checkbox" value="<?php echo $row["S_ID"]?>" name="S_ID[]" class="checkbox"/><?php echo $row["S_ID"]?>.</td>
        <td height="30" class="td_border">&nbsp;<a href="<?php echo LinkUrl("s_video",$row['S_Classid'],1,$row['S_Djid'])?>" target="_blank"><?php echo $row["S_Name"]?></a></td>
        <td height="30" class="td_border">&nbsp;<a href="<?php echo linkweburl(1,$row["S_User"])?>" target="_blank"><?php echo $row["S_User"]?></a></td>
        <td height="30" class="td_border" align="center"><?php echo $row["S_Addtime"]?></td>
        <td height="30" class="td_border" align="center">
        <a style="cursor:pointer;" onclick="del(<?php echo $row["S_ID"]?>)">删除</a></td>
    </tr>
    <?php
	}
}
if($numdate=="a"){
	echo("<tr><td height='30' align='center' class='td_border' colspan='5'><b>暂无记录！</b></td></tr>");
}
	?>
    <tr>
        <td height="30" bgcolor="#FFFFFF"  colspan="10"><input type="checkbox" name="ChkAll" id="ChkAll" ids="S_ID" class="checkbox"/>
          全选 &nbsp;
        <input type="button" value="删除所选" class="rb1" onclick="delall()"/>        </td>
      </tr>
    <tr>
          <td height="40" colspan="10" align="right" valign="bottom" bgcolor="#FFFFFF" class="td_btop3">
          <?php echo $Arr[0];?>
          </td>
      </tr>
    </table>	
</form>
<?php
function Del(){
	global $db;
	$S_ID = SafeRequest("S_ID","get");
		$sqlc="select * from s_down where S_ID=$S_ID Order by S_ID desc";
		$crow=$db->getrow($sqlc);
		$sql1="delete from s_dt where S_Name='".$crow['S_Name']."' and s_user='".$crow['S_User']."'";
		$db->query($sql1);
	$sql="delete from s_down where S_ID=".$S_ID;
	if($db->query($sql)){
		die("<script>window.location='admin_down.php'</script>");
		}
	else{
		die("<script>jAlert('删除失败!','操作提示',function(R){history.back();})</script>");
		}
}

function DelAll(){
	global $db;
	$S_ID=RequestBox("S_ID");
	$S_ID=explode(",",$S_ID);
	for($i=0;$i<count($S_ID);$i++){
		$sqlc="select * from s_down where S_ID=".$S_ID[$i]." Order by S_ID desc";
		$crow=$db->getrow($sqlc);
		$sql1="delete from s_dt where S_Name='".$crow['S_Name']."' and s_user='".$crow['S_User']."'";
		$db->query($sql1);
		$sql="delete from s_down where S_ID=".$S_ID[$i];
		$db->query($sql);
		}
	die("<script>window.location='admin_down.php'</script>");
}
?>
<div class="bottom">
<?php

include "../admin_bottom.php";
?>
 
</div>
</body>
</html>