<?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("../loginstate.php");
SystemPer('0_1');
$ac=CS_Request("ac");
$op=CS_Request("op");
if(empty($ac)) $ac='main';
?>
<!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" />
<link href="../../public/css/webox.css" rel="stylesheet" />
<script type="text/javascript" src="../res/js/ajax.js"></script>
<script language="javascript" src="../res/js/jquery.js"></script>
<script src="../../public/js/webox.js"></script>
<?php if($ac=="main"){ ?>
<script language="javascript">

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
 
function chgclass(id,cid){
	$.get("../ajax/ajax.php?ac=chgclasslist&id="+id+"&cid="+cid+"&sid=2",function(R){
		$("#class_"+id).html(R);												
	})
}
	
function savechgclass(cid,id){
	$.get("../ajax/ajax.php?ac=savecls&id="+id+"&cid="+cid+"&sid=2",function(R){
		$("#class_"+id).html(R);													  
	});
}
  
function chgtopic(id,cid){
	$.get("../ajax/ajax.php?ac=chgtopiclist&id="+id+"&cid="+cid+"&sid=2",function(R){
		$("#topic_"+id).html(R);												
	})
}
	
function savechgtopic(cid,id){
	$.get("../ajax/ajax.php?ac=savectopic&id="+id+"&cid="+cid+"&sid=2",function(R){
		$("#topic_"+id).html(R);													  
	});
}

function ShowStar(level,ids){
		   var htmlStr=""
			if(level==0){level=0}
			if (level>0){htmlStr+="<img src='../res/images/starno.gif' border='0' style='cursor:pointer;margin-left:2px;' title='取消推荐' onclick='EditReco("+ids+",0)'/>"}
			for(i=1;i<=level;i++){
			htmlStr+= "<img src='../res/images/star0.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+i+"星级' id='star"+ids+"_"+i+"' onclick='EditReco("+ids+","+i+")' />"}
			for(j=level+1;j<=5;j++){
			htmlStr+= "<img src='../res/images/star1.gif' border='0' style='cursor:pointer;margin-left:2px;'  title='推荐为"+j+"星级' id='star"+ids+"_"+j+"' onclick='EditReco("+ids+","+j+")' />"
	}
		   $("#CS_Reco"+ids).html(htmlStr);
		   }
		   
function EditReco(ids,level){
  $.get("../ajax/ajax.php?id="+ids+"&sid=2&tid="+level+"&ac=editreco", 
	  function(obj){
		  if(obj=='ok'){
			  ShowStar(level,ids);
		  }else{
			  $("#CS_Reco"+ids).html("<font color='red'>Error!</font>");		
		  }
	  }
  );
} 

function Htmlgo(id,url){
	$.get(''+url+'&id='+id,function (R){
		if(R!='no'){
			$('#html_'+id).remove();
		}				   
	});
}

function del(_id){ 
  if (confirm("确定删除吗？")){
    window.location='?op=del&id='+_id;
    return true;
  }else{
     return false;
  }		
}
</script>
<?php }else{ ?>
<script type="text/javascript" charset="utf-8" src="../../public/editor/kindeditor.js"></script>
<script type="text/javascript">
     KE.show({
	id : 'CS_Content',
	resizeMode : 1,
	allowPreviewEmoticons : false,
	allowUpload : false,
	items : [
	'source', '|', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
	'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
	'insertunorderedlist', '|', 'image', 'link', 'unlink']
     });
$(document).ready(function(){
	$("#addnews").click(function(){
		var CS_Name=document.getElementById('CS_Namea').value;
		var CS_CID=document.getElementById('CS_CIDa').value;
		var CS_User=document.getElementById('CS_User').value;
		var CS_Content=document.getElementById('CS_Content').value;
	if(CS_Name==""){
		$("#Msg").text("请填写文章名称！").css("color","red");
		return false;
		}
	else if(CS_CID=="0"){
		$("#Msg").text("请选择文章分类！").css("color","red");
		return false;
		}
	else if(CS_User==""){
		$("#Msg").text("请填写文章所属会员！").css("color","red");
		return false;
		}
	else if(CS_Content==""){
		$("#Msg").text("请填写文章内容！").css("color","red");
		return false;
		}
	});
});
</script>
<?php } ?>
</head>
<body>
<div class="wrap">
<?php
   //修改\增加
   if($ac=='edit'){
        global $db;
   	$CS_ID=CS_Request("id");
        if($CS_ID){
	   $row=$db->getrow("SELECT * FROM ".Getdbname('news')." Where CS_ID='".$CS_ID."'");
	   if($row){
		$Arr=array($row['CS_Name'],$row['CS_Color'],$row['CS_Pic'],$row['CS_CID'],$row['CS_TID'],$row['CS_Laiyuan'],$row['CS_User'],$row['CS_Reco'],$row['CS_Hits'],$row['CS_Yhits'],$row['CS_Zhits'],$row['CS_Rhits'],$row['CS_Template'],$row['CS_Title'],$row['CS_Keywords'],$row['CS_Description'],$row['CS_Content']);
                $title="编辑文章";
	   }
        }else{
		$Arr=array('','','','','',CS_WebName,'','0','0','0','0','0','news-show.html','','','','');
                $title="填加文章";
        }
?>
<div class="nav">
	<ul class="cc">
		<li><a href="news.php">文章列表</a></li>
		<li class="current"><a href="news.php?ac=edit"><?php echo $title?></a></li>
		<li><a href="news.php?op=sh">文章审核</a></li>
		<li><a href="news.php?op=tid">推荐的文章</a></li>
		<li><a href="javascript:Popsboxif('文章批量操作',450,520,'news_pl.php');">文章批量操作</a></li>
	</ul>
</div>
<form class="J_ajaxForm" data-role="edit" name="form" action="news.php?ac=edit&op=editdata" method="post">
<div class="h_a"><?php echo $title?></div>
<div class="table_full">
	<table width="100%" class="J_check_wrap">
		<col class="th" />
		<col width="480" />
		<col />
		<tr><input name="id" type="hidden" value="<?php echo $CS_ID?>" />
			<th>文章名称</th>
			<td id="CS_Name">
				<input id="CS_Namea" name="CS_Name" value="<?php echo $Arr[0]?>" type="text" class="input input_hd length_5">&nbsp;
				<input type="checkbox" name="CS_AddTime" class="checkbox" value="1" checked="checked"/>
				更新时间
			</td>
			<td><div class="fun_tips">填写文章名称</div></td>
		</tr>
		<tr>
			<th>名称颜色</th>
			<td>
			<select class="select_2" name="CS_Color" >
  			<?php if(empty($Arr[1])){?>
  			<option  value="">选择颜色</option>
 			 <?php }else{?>
  			<option style="background-color:<?php echo $Arr[1]?>;color: <?php echo $Arr[1]?>" value="<?php echo $Arr[1]?>"></option>
  			<?php }?>
 			 <option style="background-color:#00FF00;color: #00FF00" value="#00FF00">绿色</option>
  			<option style="background-color:#0000CC;color: #0000CC" value="#0000CC">深蓝</option>
  			<option style="background-color:#FFFF00;color: #FFFF00" value="#FFFF00">黄色</option>
  			<option style="background-color:#FF33CC;color: #FF33CC" value="#FF33CC">粉红</option>
  			<option style="background-color:#FF0000;color: #FF0000" value="#FF0000">红色</option>
  			<option style="background-color:#660099;color: #660099" value="#660099">紫色</option>
 			 <option style="background-color:#FFFFFF;color: #FFFFFF" value="">无色</option>									
			</select>
			</td>
			<td><div class="fun_tips">选择名称颜色</div></td>
		</tr>
		<tr>
			<th>文章图片</th>
			<td>
				<input name="CS_Pic" id="CS_Pic" value="<?php echo $Arr[2]?>" type="text" class="input input_hd length_4">
                                &nbsp;<input class="btn" type="button" onclick="Popsboxif('上传图片',470,100,'../upload.php?ac=news');" value="上传图片" />
			</td>
			<td><div class="fun_tips">填写文章图片,比如视频舞曲的图片</div></td>
		</tr>
		<tr>
			<th>文章分类</th>
			<td>
				<select class="select_2" name="CS_CID" id="CS_CIDa">
                                                <option value="0">选择分类</option>
            					 <?php
              						$sqlclass="select * from ".Getdbname('class')." where CS_YID=0 and CS_SID=2 and CS_FID=0";
									$results=$db->query($sqlclass);
									if($results){
										while ($row3=$db->fetch_array($results)){
                                                                                    if($row3['CS_ID']==$Arr[3]){
										         echo "<option value='".$row3['CS_ID']."' selected='selected'>".$row3['CS_Name']."</option>";
                                                                                    }else{
										         echo "<option value='".$row3['CS_ID']."' >".$row3['CS_Name']."</option>";
                                                                                    }
		                                                                     //处理此分类下的子分类
		                                                                     $sql2="select * from ".Getdbname('class')." where CS_FID=".$row3['CS_ID']."";
		                                                                     $class2=$db->query($sql2);
		                                                                     if($class2){
			                                                                     while($row2=$db->fetch_array($class2)){
                                                                                               if($row2['CS_ID']==$Arr[3]){
										                    echo "<option value='".$row2['CS_ID']."' selected='selected'>├ ".$row2['CS_Name']."</option>";
                                                                                               }else{
										                    echo "<option value='".$row2['CS_ID']."' >├ ".$row2['CS_Name']."</option>";
                                                                                               }
			                                                                     }
		                                                                     }
										}
									}
			  
			  			 ?>             
                                         </select>&nbsp;&nbsp;文章专题：
				         <select class="select_2" name="CS_TID">
                                                <option value="0">选择专题</option>
            					 <?php
              						$sqlt="select * from ".Getdbname('topic')." where CS_YID=0 and CS_SID=2";
									$results=$db->query($sqlt);
									if($results){
										while ($row1=$db->fetch_array($results)){
                                                                                    if($row1['CS_ID']==$Arr[4]){
										         echo "<option value='".$row1['CS_ID']."' selected='selected'>".$row1['CS_Name']."</option>";
                                                                                    }else{
										         echo "<option value='".$row1['CS_ID']."' >".$row1['CS_Name']."</option>";
                                                                                    }
										}
									}
			  
			  			 ?>             
                                         </select>
			</td>
			<td><div class="fun_tips">选择文章分类、专题</div></td>
		</tr>
		<tr>
			<th>文章来源</th>
			<td>
				<input name="CS_Laiyuan" value="<?php echo $Arr[5]?>" type="text" class="input input_hd length_4">
			</td>
			<td><div class="fun_tips">填写文章来源</div></td>
		</tr>
		<tr>
			<th>所属会员</th>
			<td>
				<input id="CS_User" name="CS_User" value="<?php echo $Arr[6]?>" type="text" class="input input_hd length_2">
                                &nbsp;&nbsp;推荐星际：
				         <select class="select_2" name="CS_Reco">
                                                <option value="0">不推荐</option>
                                                <option value="1" <?php if($Arr[7]==1) echo "selected='selected'";?>>一星际</option>
                                                <option value="2" <?php if($Arr[7]==2) echo "selected='selected'";?>>二星际</option>
                                                <option value="3" <?php if($Arr[7]==3) echo "selected='selected'";?>>三星际</option>
                                                <option value="4" <?php if($Arr[7]==4) echo "selected='selected'";?>>四星际</option>
                                                <option value="5" <?php if($Arr[7]==5) echo "selected='selected'";?>>五星际</option>           
                                         </select>
			</td>
			<td><div class="fun_tips">所属会员、推荐星际</div></td>
		</tr>
		<tr>
			<th>文章人气</th>
			<td>
				总：<input name="CS_Hits" value="<?php echo $Arr[8]?>" type="text" class="input input_hd length_1">
                                &nbsp;月：<input name="CS_Yhits" value="<?php echo $Arr[9]?>" type="text" class="input input_hd length_1">
                                &nbsp;周：<input name="CS_Zhits" value="<?php echo $Arr[10]?>" type="text" class="input input_hd length_1">
                                &nbsp;日：<input name="CS_Rhits" value="<?php echo $Arr[11]?>" type="text" class="input input_hd length_1">
			</td>
			<td><div class="fun_tips">填写文章人气</div></td>
		</tr>
		<tr>
			<th>内容页模版</th>
			<td>
				<input name="CS_Template" id="CS_Template" value="<?php echo $Arr[12]?>" type="text" class="input input_hd length_2">
                                &nbsp;&nbsp;<input class="btn" type="button" value="浏览" style="width:60px" onclick="Popsboxif('选择模版',450,400,'../skins/skin_re.php');"/>
			</td>
			<td><div class="fun_tips">可以利用这个功能支持所有播放器</div></td>
		</tr>
		<tr>
			<th>SEO标题</th>
			<td>
				<input type="text" name="CS_Title" class="input length_5" value="<?php echo $Arr[13]?>">
                        </td>
			<td><div class="fun_tips">SEO标题-title</div></td>
		</tr>
		<tr>
			<th>SEO关键词</th>
			<td>
				<input type="text" name="CS_Keywords" class="input length_5" value="<?php echo $Arr[14]?>">
                        </td>
			<td><div class="fun_tips">SEO关键词-Keywords</div></td>
		</tr>
		<tr>
			<th>SEO介绍</th>
			<td>
				<input type="text" name="CS_Description" class="input length_5" value="<?php echo $Arr[15]?>">
                        </td>
			<td><div class="fun_tips">SEO介绍-Description</div></td>
		</tr>
		<tr>
			<th>文章内容</th>
			<td>
				<textarea style="width:100%;height:250px;" id="CS_Content" name="CS_Content"><?php echo $Arr[16]?></textarea>

			</td>
			<td><div class="fun_tips">文章歌词或者简介</div></td>
		</tr>
</div>
<div class="btn_wrap">
	<div class="btn_wrap_pd">
		<button type="submit" id="addnews" class="btn btn_submit mr10 J_ajax_submit_btn">提交</button>
                <div class="tips_error" id="Msg"></div>
	</div>
</div>
<?php
         //增加、修改
         if($op=='editdata'){
		global $db;
		$CS_ID=CS_Request("id");
		$CS_Name=CS_Request("CS_Name");
		$CS_Color=CS_Request("CS_Color");
		$CS_Pic=CS_Request("CS_Pic");
		$CS_CID=CS_Request("CS_CID");
		$CS_TID=CS_Request("CS_TID");
		$CS_Laiyuan=CS_Request("CS_Laiyuan");
		$CS_User=CS_Request("CS_User");
		$CS_Reco=CS_Request("CS_Reco");
		$CS_Hits=CS_Request("CS_Hits");
		$CS_Yhits=CS_Request("CS_Yhits");
		$CS_Zhits=CS_Request("CS_Zhits");
		$CS_Rhits=CS_Request("CS_Rhits");
		$CS_Template=CS_Request("CS_Template");
		$CS_Content=CS_Request("CS_Content");
		$CS_AddTime=CS_Request("CS_AddTime");
    		$CS_Title=CS_Request("CS_Title");
    		$CS_Keywords=CS_Request("CS_Keywords");
    	        $CS_Description=CS_Request("CS_Description");
                if(empty($CS_Name)||empty($CS_CID)||empty($CS_User)||empty($CS_Content)){
                          echo '<script>$("#Msg").text("抱歉，资料不完整!").css("color","red");</script>';
                          exit("<script>setTimeout(\"history.back(1);\",20000);</script>");
                }
		//判断增加还是修改
                if($CS_ID){
                       if($CS_AddTime==1){
		            $sql="update ".Getdbname('news')." set CS_AddTime='".date('Y-m-d H:i:s')."',CS_Name='".$CS_Name."',CS_Color='".$CS_Color."',CS_Pic='".$CS_Pic."',CS_CID=".$CS_CID.",CS_TID=".$CS_TID.",CS_Laiyuan='".$CS_Laiyuan."',CS_User='".$CS_User."',CS_Reco=".$CS_Reco.",CS_Hits=".$CS_Hits.",CS_Yhits=".$CS_Yhits.",CS_Zhits=".$CS_Zhits.",CS_Rhits=".$CS_Rhits.",CS_Template='".$CS_Template."',CS_Content='".$CS_Content."',CS_Title='".$CS_Title."',CS_Keywords='".$CS_Keywords."',CS_Description='".$CS_Description."' where CS_ID=".$CS_ID;
                       }else{
		            $sql="update ".Getdbname('news')." set CS_Name='".$CS_Name."',CS_Color='".$CS_Color."',CS_Pic='".$CS_Pic."',CS_CID=".$CS_CID.",CS_TID=".$CS_TID.",CS_Laiyuan='".$CS_Laiyuan."',CS_User='".$CS_User."',CS_Reco=".$CS_Reco.",CS_Hits=".$CS_Hits.",CS_Yhits=".$CS_Yhits.",CS_Zhits=".$CS_Zhits.",CS_Rhits=".$CS_Rhits.",CS_Template='".$CS_Template."',CS_Content='".$CS_Content."',CS_Title='".$CS_Title."',CS_Keywords='".$CS_Keywords."',CS_Description='".$CS_Description."' where CS_ID=".$CS_ID;
                       }
                }else{
		            $sql="Insert ".Getdbname('news')."  (CS_Name,CS_Color,CS_Pic,CS_CID,CS_TID,CS_Laiyuan,CS_User,CS_Reco,CS_Hits,CS_Yhits,CS_Zhits,CS_Rhits,CS_Template,CS_Content,CS_AddTime,CS_Title,CS_Keywords,CS_Description) values ('".$CS_Name."','".$CS_Color."','".$CS_Pic."',".$CS_CID.",".$CS_TID.",'".$CS_Laiyuan."','".$CS_User."',".$CS_Reco.",".$CS_Hits.",".$CS_Yhits.",".$CS_Zhits.",".$CS_Rhits.",'".$CS_Template."','".$CS_Content."','".date('Y-m-d H:i:s')."','".$CS_Title."','".$CS_Keywords."','".$CS_Description."')";
                }
		if($db->query($sql)){
                    echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,数据操作成功!").css("color","#026E12");</script>';
	            echo "<script>setTimeout(\"window.location='news.php'\",2000);</script>";
		}else{
                    echo '<script>$("#Msg").text("抱歉，操作失败!").css("color","red");</script>';
	            echo "<script>setTimeout(\"history.back(1);\",2000);</script>";
                }
         }
   }

   //文章主列表
   if($ac=='main'){
                $op=CS_Request("op");
                $key=CS_Request("key");
                $cid=CS_Request("cid");
                $topic=CS_Request("topic");
		global $db;
                $sql="select * from ".Getdbname('news')." where ";
                if($cid){
                      $sql.="cs_cid=".$cid." and ";
                }
                if($topic){
                      $sql.="cs_tid=".$topic." and ";
                }
                if($op=="sh"){
                      $sql.="cs_yid=1 ";
                }elseif($op=="tid"){
                      $sql.="cs_reco>1 ";
                }else{
                      $sql.="cs_yid=0 ";
                }
                if($key){
                      $sql.="and (CS_Name like '%".$key."%' like '%".$key."%') ";
                }
                $sql.=" order by CS_AddTime desc";
		$newsnum=$db->num_rows($db->query($sql));
		$Arr=getpagerow($sql,20);//sql,每页显示条数
		$result=$db->query($Arr[2]);
		$adminnum=$db->num_rows($result);

?>
<div class="nav">
	<ul class="cc">
		<li<?php if($ac=="" && $op=="") echo ' class="current"';?>><a href="news.php">文章列表</a></li>
		<li<?php if($ac=="edit") echo ' class="current"';?>><a href="news.php?ac=edit">添加文章</a></li>
		<li<?php if($op=="sh") echo ' class="current"';?>><a href="news.php?op=sh">文章审核</a></li>
		<li<?php if($op=="tid") echo ' class="current"';?>><a href="news.php?op=tid">推荐的文章</a></li>
		<li><a href="javascript:Popsboxif('文章批量操作',450,520,'news_pl.php');">文章批量操作</a></li>
	</ul>
</div>
	<div class="h_a">搜索</div>	<form method="get" action="news.php">
	<div class="search_type cc mb10">
		<div class="ul_wrap">
			<ul class="cc">
				<li>
					<label>关键字：</label><input name="key" value="" type="text" class="input length_3" placeholder="文章名搜索">&nbsp;&nbsp;<button class="btn mr20" type="submit">搜索</button>
				</li>
				<li>
					<label>按分类：</label><select class="select_3" onchange="MM_jumpMenu('self',this,0)">
                                                <option value="news.php">选择分类</option>
            					 <?php
              						$sqlclass="select * from ".Getdbname('class')." where CS_YID=0 and CS_SID=2 and CS_FID=0";
									$results=$db->query($sqlclass);
									if($results){
										while ($row3=$db->fetch_array($results)){
       
										         echo "<option value='?cid=".$row3['CS_ID']."' >".$row3['CS_Name']."</option>";

		                                                                     //处理此分类下的子分类
		                                                                     $sql2="select * from ".Getdbname('class')." where CS_FID=".$row3['CS_ID']."";
		                                                                     $class2=$db->query($sql2);
		                                                                     if($class2){
			                                                                     while($row2=$db->fetch_array($class2)){
										                    echo "<option value='?cid=".$row2['CS_ID']."' >├ ".$row2['CS_Name']."</option>";
			                                                                     }
		                                                                     }
										}
									}
			  
			  			 ?>            
                                         </select>
				</li>
				<li>
					<label>按专题：</label><select class="select_3" onchange="MM_jumpMenu('self',this,0)">
                                                <option value="news.php">选择专题</option>
            					 <?php
              						$sqltopic="select * from ".Getdbname('topic')." where CS_SID=2 ";
									$results=$db->query($sqltopic);
									if($results){
										while ($row5=$db->fetch_array($results)){
										    echo "<option value='?topic=".$row5['CS_ID']."' >".$row5['CS_Name']."</option>";
										}
									}
			  
			  			 ?>             
                                         </select>
				</li>
			</ul>
		</div>
	</div>
</form>
<form class="J_ajaxForm" action="news.php?op=delall" method="post" name="formb">
<div class="table_list">
<?php
	if($adminnum==0){
                echo "<table width=\"100%\">
				<tbody>
					<tr><td class=\"tac\">啊哦，没有符合条件的内容！</td></tr>
				</tbody>
		</table>";

        }else{
                echo "<table width=\"100%\" id=\"dellist\">
		<thead>
			<tr>
				<td><label>选</label></td>
				<td>名称</td>
				<td><span>会员</span></td>
				<td><span>日人气</span></td>
				<td><span>总人气</span></td>
				<td><span>文章分类</span></td>
				<td><span>专题</span></td>
				<td><span>推荐星际</span></td>
				<td><span>审核</span></td>
				<td><span>发布时间</span></td>
				<td>编辑/删除</td>
			</tr>
		</thead>";
        }
        if($result){
	     while ($row = $db ->fetch_array($result)){
                $class=$db->getrow("select CS_Name from ".Getdbname('class')." where CS_ID=".$row['CS_CID']."");
			if(date("Y-m-d",strtotime($row['CS_AddTime']))==date('Y-m-d')){
				$addtime="<font color=red>".date("Y-m-d",strtotime($row['CS_AddTime']))."</font>";
			}else{
				$addtime=date("Y-m-d",strtotime($row['CS_AddTime']));
			}
                        if($row['CS_TID']!=0){
				$tpic="<img src=\"../res/images/topicyes.gif\" onclick=\"chgtopic(".$row['CS_ID'].",".$row['CS_TID'].")\" title=\"修改专题\" style=\"cursor:pointer\">";
			}else{
				$tpic="<img src=\"../res/images/topicno.gif\" onclick=\"chgtopic(".$row['CS_ID'].",".$row['CS_TID'].")\" title=\"修改专题\" style=\"cursor:pointer\">";
			}
			if($row['CS_YID']==1){
                                $shenhe='<a href="news.php?op=shenhe&id='.$row["CS_ID"].'&yid=0" title="点击审核文章"><img src="../res/images/no.gif"/></a>';
                        }else{
                                $shenhe='<a title="点击取消审核该文章" href="news.php?op=shenhe&id='.$row["CS_ID"].'&yid=1"><img src="../res/images/yes.gif"/></a>';
                        }
                        if($op!="sh" && CS_Webmode==3){
		             $html=HtmlShow($row['CS_ID'],'../html/html_news.php?ac=ids&id='.$row['CS_ID'].'',LinkUrl('show','news','id',$row['CS_CID'],$row['CS_ID']));
                        }else{
		             $html='';
                        }
                  echo "<tr>
				<td><input type=\"checkbox\" class=\"J_check\" name=\"CS_ID[]\" value=\"".$row['CS_ID']."\" id=\"CS_ID\"/>&nbsp;".$row['CS_ID']."</td>
				<td><a href=\"".LinkUrl('show','news','id',$row['CS_CID'],$row['CS_ID'])."\" target=\"play\"><font color=".$row['CS_Color'].">".getlen('len',35,$row['CS_Name'])."</font></a>".$html."</td>
				<td><a href=\"".userlink('index',getuser('uid',$row['CS_User']))."\" target=\"user\">".$row['CS_User']."</a></td>
				<td>".$row['CS_Rhits']."</td>
				<td>".$row['CS_Hits']."</td>
				<td><span id=\"class_".$row['CS_ID']."\">".$class['CS_Name']."<img src=\"../res/images/edit.gif\" title=\"修改分类\" onclick=\"chgclass(".$row['CS_ID'].",".$row['CS_CID'].")\" style=\"cursor:pointer\"></span></td>
				<td><span id=\"topic_".$row['CS_ID']."\">".$tpic."</span></td>
				<td id=\"CS_Reco".$row['CS_ID']."\"><script language=\"javascript\">ShowStar(".$row['CS_Reco'].",".$row['CS_ID'].")</script></td>
				<td>".$shenhe."</td>
				<td>".$addtime."</td>
				<td><a href=\"?ac=edit&id=".$row['CS_ID']."\">编辑</a> &nbsp;&nbsp;<a style=\"cursor:pointer;\"  onclick=\"del(".$row['CS_ID'].")\">删除</a></td>
			</tr>";
             }
        }
?>
	</table>
			<div class="p10">
				<div class="pages">
				     <?php if($newsnum>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)">
            <?php if(CS_Webmode==3){ ?>
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="批量生成" onClick="MarkInfo(this.form,'news')">
            <?php } ?>
		<input name="button2" type="button" class="btn btn_submit J_ajax_submit_btn" value="批量修改" onClick="EditInfo(this.form,'news')">
                <div class="tips_error" id="Msg"></div>
	</div>
</div>
</form>
<?php
          //审核
          if($op=='shenhe'){
		global $db;
		$CS_ID=CS_Request("id");
		$CS_YID=CS_Request("yid");
                $sql="update ".Getdbname('news')." set CS_YID=".$CS_YID." where CS_ID=".$CS_ID;
		if($db->query($sql)){
			echo "<script>window.location='javascript:history.go(-1);';</script>";
		}
          }

          //删除
          if($op=='del'){
		global $db;
		$CS_ID=CS_Request("id");
                $clsid=$db->Getrow("select CS_CID from ".Getdbname('news')." where CS_ID=".$CS_ID."");
                $sql="delete from ".Getdbname('news')." where CS_ID=".$CS_ID;
		if($db->query($sql)){
			if(CS_Webmode==3){
				$fileurl=LinkUrl('show','news','id',$clsid['CS_CID'],$CS_ID);
				$fileurl="../../".substr($fileurl,strlen(CS_WebPath));
				if(file_exists($fileurl)){
					unlink($fileurl);
				}	
			}
                        $db->query("delete from ".Getdbname('dt')." where CS_DID=".$CS_ID." and CS_CID=5");
                        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++){
			if(CS_Webmode==3){
		          $clsid=$db->Getrow("select CS_CID from ".Getdbname('news')." where CS_ID=".$Arr[$i]."");
				$fileurl=LinkUrl('show','news','id',$clsid['CS_CID'],$Arr[$i]);
				$fileurl="../../".substr($fileurl,strlen(CS_WebPath));
				if(file_exists($fileurl)){
					unlink($fileurl);
				}	
			}
			$db->query("delete from ".Getdbname('dt')." where CS_DID=".$Arr[$i]." and CS_CID=5");
			$db->query("delete from ".Getdbname('news')." 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>";
          }
   }
?>
</div>
</body>
</html>
