<?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、盘锦网络事业部保留此软件的法律追究权利
'**************************************************************************************************
*/
include "../../include/conn.php";
include "../../include/function.php";
include "../admin_version.php";
include "../admin_loginstate.php";
?>
<!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>
<script src="../js/jquery.js"></script>
<script src="../js/alerts.js"></script>
<link href="../images/alerts.css" rel="stylesheet" type="text/css" media="screen" />
<script language="javascript">
	$(document).ready(function(){
			$("#ChkAll").click(function(){
		if($(this).attr("checked")==true){
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",true);									 
			})							
		}else{
			$("input[id='S_ID']").each(function(){
				$(this).attr("checked",false);									 
			})							
		}
	})					   

	$("#delcheck").click(function(){
		jConfirm('<b>确定删除所选评论吗?</b>', '操作提示', function(r) {
				if(r==true){
					var types=$("#types").val();
					document.Feedback.action='?action=delall&types='+types;
					Feedback.submit();}
				});
	 })
	
	$("#delall").click(function(){
		jConfirm('<b>确定删除全部评论吗?</b>', '操作提示', function(r) {
				if(r==true){
					var types=$("#types").val();
					window.location='?action=deleteall&types='+types;
					Feedback.submit();}
				});
	 })
	 
	 $("#showreview1").click(function (){
		window.location='?action=listnews';
	});
	
		 $("#showreview2").click(function (){
			window.location='?action=listvideo';
	});
	
		 $("#showreview3").click(function (){
	window.location='?action=isnocheck';
	});

	$("#allowall").click(function(){
		jConfirm('<b>确定审核全部评论吗?</b>', '操作提示', function(r) {
				if(r==true){
					window.location='?action=checkall';
					Feedback.submit();}
				});
	 })
	
})
	
function del(id){
	jConfirm('<b>确定删除这条评论吗?</b>', '操作提示', function(r) {
		if(r==true){
			window.location='?action=del&S_ID='+id;
			}
				});
		
		}
</script>
<link  href="../images/style.css" rel="stylesheet" type="text/css" />

</head>

<body>
<?php
SystemPer(12);
class ui_review{
	public function editboard($emValues,$ActionUrl){
			$Names = $emValues[0];
			$Content = $emValues[1];
			$AddTime = $emValues[2];	
			$UserIP = $emValues[3];			
			$IsHandle = $emValues[4];
			$Title = $emValues[5];
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
					 <table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style">
						<form name="form1" method="post" action="<?php echo $ActionUrl?>" />
						  <tr>
							<td height="30" colspan="2" class="td_title">&nbsp;评论详细信息</td>
					   </tr>
						  <tr>
							<td width="10%" height="30" class="td_border">&nbsp;评论网友：</td>
							<td width="90%" class="td_border">&nbsp;<?php echo $Names?></td>
						  </tr>
						  <tr>
						    <td height="30" class="td_border">&nbsp;网友IP地址：</td>
						    <td class="td_border">&nbsp;<?php echo $UserIP?></td>
				       </tr>
						  <tr>
							<td width="10%" height="30" class="td_border">&nbsp;评论标题：</td>
							<td width="90%" class="td_border">&nbsp;<?php echo $Title?></td>
						  </tr>
						  <tr>
							<td height="26" class="td_border" >&nbsp;评论内容：</td>
							<td class="td_border">&nbsp;<?php echo $Content?></td>
						  </tr>
						  <tr>
							<td height="26" class="td_border" >&nbsp;评论时间：</td>
							<td class="td_border">&nbsp;<?php echo $AddTime?></td>
						  </tr>
						  <tr>
							<td height="30" class="td_border">&nbsp;是否审核：</td>
							<td class="td_border">&nbsp;<input name="S_Check" type="radio" value="0" <?php if($IsHandle=='0'){echo "checked";}?> class="radio" />
							已审核&nbsp;　
							<input type="radio" name="S_Check" value="1" <?php if($IsHandle=='1'){echo "checked";} ?> class="radio" />
							  未审核</td>
						  </tr>
				
						  <tr>
							<td height="30" align="right" class="td_border">&nbsp;</td>
							<td class="td_border"> &nbsp;
                            <input type="hidden" value="<?php echo urlencode($_SERVER['QUERY_STRING']);?>" id="types" name="types">
							  <input type="submit" name="Submit" value="编辑评论" class="rb1" />
							  &nbsp;&nbsp; <input type="button" name="Submit2" value="返回列表"  class="rb1" onclick="history.back()"/></td>
						  </tr>
				  </table>
		</div>
	</div>
</div>
<?php		
		}	
	
	public function main($sql,$pagecount,$title){
		global $db;
		$Arr=getpagerow($sql,$pagecount);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$recount=$db->num_rows($result);
?>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0"  class="tb_style">         
         					<form method="post" name="Feedback" action=""> 
                            <tr>
                              <td  height="30" colspan="7" class="td_title">&nbsp;网友评论管理<?php echo $title?></td>
                              </tr>
                            <tr>
            <td  height="30" class="td_border">&nbsp;编号</td>
            <td width="212" class="td_border">&nbsp;评论信息</td>
            <td width="92" align="center" class="td_border">网友</td>
            <td width="140" class="td_border">&nbsp;评论标题</td>
            <td width="91"  align="center" class="td_border">评论时间</td>
            <td width="34"  align="center" class="td_border">审核</td>
            <td width="91"  align="center" class="td_border">操 作</td>
          </tr>
 <?php
 if($recount=="0"){
 ?>
                        <tr>
                          <td height="30" colspan="10" align="center" bgcolor="#FFFFFF" class="td_border"><strong>暂无评论！</strong></td>
                        </tr>
<?php
	}
else{
		if($result){
			while ($row = $db ->fetch_array($result)){

?>
                    <tr>
                      <td width="80" height="30" class="td_border">&nbsp;<input type="checkbox" name="S_ID[]" value="<?php echo $row['S_ID']?>" class="checkbox" id="S_ID"/>
                     <?php echo $row['S_ID']?>、</td>
                      <td width="212" align="left" class="td_border">&nbsp;<a href="?action=review&amp;S_ID=<?php echo $row['S_ID']?>"><?php echo $row['S_Content']?></a></td>
                      <td width="92" align="center" class="td_border"><?php echo $row['S_Name']?></td>
                      
					  <td width="140" class="td_border">&nbsp;<?php
					  if($row['S_SystemID']=="1"){
						  $sql="select S_Name from s_video where S_ID=".$row['S_DateID']."";
						  }
					 else{
						  $sql="select S_Name from s_article where S_ID=".$row['S_DateID']."";	
						 }
					
					 $row2=$db->getrow($sql);
					 if($row2){
						 if($row['S_SystemID']==1){
							$sqlclass="select S_ClassID from s_video where S_ID=".$row['S_DateID']."";
							$vclassid=$db->getrow($sqlclass);
							if($vclassid){
								$videoclassid=$vclassid['S_ClassID'];
								}
							else{
								$videoclassid="";
								}
							  $link=LinkUrl("s_video",$vclassid['S_ClassID'],1,$row['S_DateID']); 
							 }
						 else{
							$sqlclass="select S_ClassID from s_article where S_ID=".$row['S_DateID']."";
							$aclassid=$db->getrow($sqlclass);
							if($aclassid){
								$articleclassid=$aclassid['S_ClassID'];
								}
							else{
								$articleclassid="";
								}							 
							  $link=LinkUrl("s_article",$aclassid['S_ClassID'],0,$row['S_DateID']); 
							 } 
						 echo "<a href=".$link." target=_blank>".$row2['S_Name']."</a>";
						 }
					else{
						echo "=.=!无对应标题";
						}	 
					  ?></td>
                      <td width="91" align="center" class="td_border"><?php echo $row['S_AddTime']?></td>
                      <td width="34" align="center" class="td_border"><a href="?action=check&amp;S_Check=<?php echo $row['S_Check']?>&amp;S_ID=<?php echo $row['S_ID']?>"><?php if($row['S_Check']==0){echo "<img src='../../images/common/yes.gif'/>";}else{echo "<img src='../../images/common/no.gif'/>";}?></a>                      </td>                      
                      <td width="91" align="center" class="td_border"><a href="?action=review&S_ID=<?php echo $row['S_ID']?>">详细</a> &nbsp;<a style="cursor:pointer" onclick="del(<?php echo $row['S_ID']?>)">删除</a></td>
          </tr>
<?php
			}
		}
}
?>
          <tr>
            <td colspan="7">&nbsp;<input type="checkbox"  name="ChkAll" id="ChkAll"   class="checkbox"/>
            全选&nbsp;&nbsp;&nbsp; <input type="button" value="删除所选"  class="rb1"   id="delcheck"/>
            <input type="button" value="审核全部" class="rb1" id="allowall"/>
            <input name="button" type="button" class="rb1"  value="删除全部" id="delall"/>
           &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; <input type="button" id="showreview3" name="showreview3" value="待审评论" class="rb1"/>
			<input type="button" id="showreview2" name="showreview2" value="歌曲评论" class="rb1"/>
			<input type="button" id="showreview1" name="showreview1" value="文章评论" class="rb1"/>
			</td>
          </tr>
          <tr>
          	<td colspan="7" class="td_border" align="right"><?php echo $Arr[0]?></td>
          </tr>
        				</form>
                      </table>
		</div>
	</div>
</div>
<?php		
		
		}
	}//end class

?>        

<?php
$ui=new ui_review;
$action=SafeRequest("action","get");
switch($action){
	case 'main':
		$ui->main("select * from s_review",5,"[全部评论]");
		break;
	case 'listvideo':
		listvideo();
		break;
	case 'listnews':
		listnews();
		break;
	case 'isnocheck':
		isnocheck();
		break;
	case 'checkall':
		checkall();
		break;
	case 'delall':
		delall();
		break;
	case 'deleteall':
		deleteall();
		break;
	case 'review':
		review();
		break;
	case 'saveedit':
		saveedit();
		break;
	case 'check':
		check();
		breal;
	case 'del':
		del();
		break;
	default:
		$ui->main("select * from s_review",25,"[全部评论]");
	}
function saveedit(){
	global $db;	
	$S_ID=SafeRequest("S_ID","get");
	if(!IsNum($S_ID)){die("参数传输错误");}
	$S_Check=SafeRequest("S_Check","post");
	$sql="update  s_review set S_Check=".$S_Check." where S_ID=".$S_ID."";
	if($db->query($sql)){
		//header("Location:admin_review.php");
		die("<script>window.location='admin_review.php'</script>");
		}
	}

function review(){
		global $db;
		global $ui;
		$S_ID=SafeRequest("S_ID","get");
		if(IsNum($S_ID)){
			$sql="SELECT * FROM `s_review` Where S_ID=".$S_ID."";
			$row=$db->Getrow($sql);
				if($row){
					if($row['S_SystemID']==1){
						$Title=$db->getrow("select S_Name from s_video where S_ID=".$row['S_DateID']."");
						if($Title){
							$S_Title=$Title['S_Name'];
							}
						else{
							$S_Title="未知的标题";
							}	
						}
					else{
						$Title=$db->getrow("select S_Name from s_article where S_ID=".$row['S_DateID']."");
						if($Title){
							$S_Title=$Title['S_Name'];
							}
						else{
							$S_Title="未知的标题";
							}	
						}	
				
				$Arr=array($row['S_Name'],$row['S_Content'],$row['S_AddTime'],$row['S_UserIP'],$row['S_Check'],$S_Title);
					}	
				$ui->editboard($Arr,"?action=saveedit&S_ID=".$S_ID."");
			}
	}

function deleteall(){
	global $db;
	$types=SafeRequest("types","get");
	$sql="delete from s_review";
	if($db->query($sql)){
		die("<script>jAlert('恭喜你！操作成功了！','成功提示',function(R){window.location='?action=".$types."';})</script>");
		}
	}

function delall(){
	global $db;
	$types=SafeRequest("types","get");
	$S_ID=RequestBox("S_ID");
	if($S_ID=="0"){
		die("<script>jAlert('请选择要删除的数据?','操作提示',function(R){history.back();})</script>");
		}
	else{
		$sql="delete from s_review where S_ID in ($S_ID)";
		if($db->query($sql)){
			die("<script>jAlert('恭喜你！操作成功了！','成功提示',function(R){window.location='?action=".$types."';})</script>");
			}
		}	
	
	}

function check(){
	global $db;
	$S_ID=SafeRequest("S_ID","get");
	$S_Check=SafeRequest("S_Check","get");
	if($S_Check=='0'){
		$S_Check='1';
	}else{
		$S_Check='0';
		}
	$sql="update s_review set S_Check=$S_Check where S_ID=$S_ID";
	if($db->query($sql)){
		die("<script>window.location='admin_review.php'</script>");
		}	
	}

function checkall(){
	global $db;
	$sql="update s_review set S_Check=0 where S_Check=1";
	if($db->query($sql)){
		die("<script>window.location='admin_review.php'</script>");
		}
	}
	
function del(){
		global $db;
		$S_ID=SafeRequest("S_ID","get");
		$sql="delete from s_review where S_ID='".$S_ID."'";
		if($db->query($sql)){
			echo "<script>window.location='admin_review.php';</script>";
			}
		}
		
function listvideo(){
	global $ui;
	$sql="select * from s_review where S_SystemID=1";
	$ui->main($sql,25,"[舞曲评论]");
	}
function listnews(){
	global $ui;
	$sql="select * from s_review where S_SystemID=2";
	$ui->main($sql,25,"[文章评论]");	
	}
function isnocheck(){
	global $ui;
	$sql="select * from s_review where S_Check=1";
	$ui->main($sql,25,"[待审评论]");	
	}	
?>
<?php include "../admin_bottom.php"; ?>
</body>
</html>