<?php
# Name: PHP版程氏音乐CMS管理系统 v3.0
# Author: 程氏<web@chshcms.com> [QQ:848769359]
# Homepage:http://www.chshcms.cn/
include_once("../../lib/cs_label.php");
include_once("../../lib/cs_phpzip.php");
include_once("../loginstate.php");
SystemPer('6_1');
$ac=CS_Request("ac");
$op=CS_Request("op");
$sid=CS_Request("sid");
$id=CS_Request("id");
if(empty($sid)) $sid=1;
?>
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>chshdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<script type="text/javascript" src="../res/js/ajax.js"></script>
<script language="javascript" src="../res/js/jquery.js"></script>
<script language="javascript"> 
 
function del(_id){ 
  if (confirm("确定删除吗？")){
    window.location='?op=del&id='+_id;
    return true;
  }else{
     return false;
  }		
}
</script>
</head>
<body>
<div class="wrap">
<div class="nav">
	<ul class="cc">
		<li <?php if($sid==1) echo 'class="current"';?>><a href="?sid=1">歌曲评论</a></li>
		<li <?php if($sid==2) echo 'class="current"';?>><a href="?sid=2">文章评论</a></li>
		<li <?php if($sid==3) echo 'class="current"';?>><a href="?sid=3">专集评论</a></li>
        </ul>
</div>
<form class="J_ajaxForm" action="?op=delall" method="post" name="formb">
<div class="table_list">
<table width="100%" id="dellist">
		<thead>
			<tr>
				<td><label>选</label></td>
				<td>名称</td>
				<td><span>内容</span></td>
				<td><span>IP</span></td>
				<td><span>时间</span></td>
				<td>查看评论/删除</td>
			</tr>
		</thead>
<?php
		global $db;
                $sql="select * from ".Getdbname('pl')." where cs_sid=".$sid." order by CS_AddTime desc";
		$dancenum=$db->num_rows($db->query($sql));
		$Arr=getpagerow($sql,20);//sql,每页显示条数
		$result=$db->query($Arr[2]);
	if($dancenum==0){
                   echo '<tr><td class="tac" colspan="6">啊哦，没有符合条件的内容！</td></tr>';
        }else{
                if($result){
	                 while ($row = $db ->fetch_array($result)){
                         if($sid==1){
                               $title="歌曲";$table="dance";
                         }elseif($sid==2){
                               $title="文章";$table="news";
                         }elseif($sid==3){
                               $title="专集";$table="topic";
                         }
                               $clas=$db->getRow("select * from ".Getdbname($table)." where CS_ID=".$row['CS_DID']."");
                               if($clas){
                                  $Name=$clas['CS_Name'];
                                  if($sid==1){
                                       $link=LinkUrl('play','dance','id',$clas['CS_CID'],$clas['CS_ID']).'" target="play"';
                                  }elseif($sid==2){
                                       $link=LinkUrl('show','news','id',$clas['CS_CID'],$clas['CS_ID']).'" target="show"';
                                  }elseif($sid==3){
                                       $link=LinkUrl('show','zj','id',$clas['CS_CID'],$clas['CS_ID']).'" target="show"';
                                  }
                               }else{
                                  $Name='该'.$title.'已被删除!';
                                  $link='#';
                               }
?>
			   <tr>
				<td><input type="checkbox" class="J_check" name="CS_ID[]" value="<?php echo $row['CS_ID']?>" id="CS_ID"/>&nbsp;<?php echo $row['CS_ID']?></td>
				<td><a href="<?php echo $link?>"><?php echo $Name?></a></td>
				<td><?php echo facehtml(stripslashes(html_entity_decode($row['CS_Content'])))?></td>
				<td><?php echo $row['CS_IP']?></td>
				<td><?php echo $row['CS_AddTime']?></td>
				<td><a href="<?php echo $link?>">查看</a> &nbsp;&nbsp;<a style="cursor:pointer;"  onclick="del(<?php echo $row['CS_ID']?>)">删除</a></td>
			   </tr>
<?php
	                 }
                }
        }
?>
	</table>
			<div class="p10">
				<div class="pages">
				     <?php if($dancenum>20) echo $Arr[0];?>
                                </div>
			</div>
</div>
<div class="btn_wrap">
	<div class="btn_wrap_pd">
                <label class="mr20"><input type="checkbox" class="J_check_all" id="chkall" onClick="return CheckAll(this.form)" value="on">全选</label>
		<input name="button1" type="button" class="btn J_ajax_submit_btn" value="批量删除" onClick="DelInfo(this.form)">
                <div class="tips_error" id="Msg"></div>
	</div>
</div>
</form>
</div>
<?php
          //删除
          if($op=='del'){
		global $db;
		$CS_ID=CS_Request("id");
                $sql="delete from ".Getdbname('pl')." where CS_ID=".$CS_ID;
		if($db->query($sql)){
                        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,删除成功!").css("color","#026E12");</script>';
	                echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
		}
          }

          //批量删除
          if($op=='delall'){
		global $db;
		$CS_ID=CS_RequestBox("CS_ID");
	        $Arr=explode(',',$CS_ID);
		for($i=0;$i<count($Arr);$i++){
			$db->query("delete from ".Getdbname('pl')." where CS_ID=".$Arr[$i]."");
		}
                        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,删除成功!").css("color","#026E12");</script>';
	                echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
          }
?>
</body>
</html>

