<?php
/*
'**************************************************************************************************
' 软件名称: 程氏音乐系统 Content Management chshdjcms
' 版本编号: V 3.0
' 官方网站: http://www.chshcms.com
' 官方论坛：http://bbs.chshcms.com
' 版权所有: 程氏网络科技    程氏(QQ:848769359)
' 郑重声明:
'    1、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、程氏网络科技保留此软件的法律追究权利
'**************************************************************************************************
*/
include_once("../../lib/cs_conn.php");
include_once("../../lib/cs_common.php");
include_once("../loginstate.php");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Cache-Control: no-cache, must-revalidate"); 
header("Pragma: no-cache");
$action=CS_Request("ac");
$str="";
switch($action){
		case 'chgtopiclist':
			TopicList();
			break;
		case 'savectopic':
			TopicEdit();
			break;
		case 'editreco':
			EditReco();
			break;
		case 'chgclasslist':
			ChgClassList();
			break;
		case 'savecls':
			SaveCls();
			break;
		case 'editreco':
			EditReco();
			break;
		case 'bdlist':
			Bdlist();
			break;
		case 'zdlist':
			ZDlist();
			break;
	}

function ZDlist(){
	global $db;
	$bname=CS_Request("name");

	$sql="SHOW FULL COLUMNS FROM $bname";
	$result=$db->query($sql);
        $columnNum=$db->num_rows($result);
        $i=0;
        echo "<div style=\"border:1px solid #ababab;width:500px;background-color:#FEFFF0;margin-top:6px;padding:3px;line-height:160%\">表(".$bname.")含有的字段：<br>";
        while ( $i < $columnNum ) {
             $colname = $db->fetch_array ( $result );
             echo "<a href=\"javascript:rpfield('".$colname[Field]."')\">".$colname[Field]."</a>  ";
             $i ++; 
        }
        echo "</div>";
}

function ChgClassList(){
	global $db;
	$CS_ID=CS_Request("id");
	$CS_CID=CS_Request("cid");
	$CS_SID=CS_Request("sid");
	$sql="select CS_Name,CS_ID from ".Getdbname('class')." where CS_SID=".$CS_SID;
	$str="<select onchange=\"savechgclass(this.value,".$CS_ID.")\">\r\n";
	$result=$db->query($sql);
	if($result){
		while($row=$db->fetch_array($result)){
			if($CS_CID==$row['CS_ID']){
				$isselect="selected";
			}else{
				$isselect="";
			}	
		$str.="<option value=\"".$row['CS_ID']."\"  ".$isselect.">".$row['CS_Name']."</option>\r\n";
		}
	}
	$str.="</select>\r\n";
	echo $str;
}

function SaveCls(){
	global $db;
	$CS_ID=CS_Request("id");
	$CS_CID=CS_Request("cid");
	$CS_SID=CS_Request("sid");
	if($CS_SID==1){
		$sql="update ".Getdbname('dance')." set CS_CID=".$CS_CID." where CS_ID=".$CS_ID;
	}elseif($CS_SID==2){
		$sql="update ".Getdbname('news')." set CS_CID=".$CS_CID." where CS_ID=".$CS_ID;
	}elseif($CS_SID==3){
		$sql="update ".Getdbname('topic')." set CS_CID=".$CS_CID." where CS_ID=".$CS_ID;
	}
	if($db->query($sql)){
		echo "<font color=green>修改成功!</font>";
	}else{
		echo "<font color=red>修改出错!</font>";
	}	
}

function TopicList(){
	global $db;
	$CS_ID=CS_Request("id");
	$CS_CID=CS_Request("cid");
	$CS_SID=CS_Request("sid");
	$sql="select CS_Name,CS_ID from ".Getdbname('topic')." where CS_SID=".$CS_SID;
	$str="<select onchange=\"savechgtopic(this.value,".$CS_ID.")\">\r\n";
	$result=$db->query($sql);
        $num=$db->num_rows($result);
        if($num==0) $str.="<option value=\"0\">当前没有专集</option>";
	if($result){
		while($row=$db->fetch_array($result)){
			if($CS_CID==$row['CS_ID']){
				$isselect="selected";
			}else{
				$isselect="";
			}	
		$str.="<option value=\"".$row['CS_ID']."\"  ".$isselect.">".$row['CS_Name']."</option>\r\n";
		}
	}
	$str.="</select>\r\n";
	echo $str;
}

function TopicEdit(){
	global $db;
	$CS_ID=CS_Request("id");
	$CS_CID=CS_Request("cid");
	$CS_SID=CS_Request("sid");
	if($CS_SID==1){
		$sql="update ".Getdbname('dance')." set CS_TID=".$CS_CID." where CS_ID=".$CS_ID;
	}elseif($CS_SID==2){
		$sql="update ".Getdbname('news')." set CS_TID=".$CS_CID." where CS_ID=".$CS_ID;
	}
	if($db->query($sql)){
		echo "<font color=green>修改成功!</font>";
	}else{
		echo "<font color=red>修改出错!</font>";
	}	
}

function EditReco(){
	global $db;
	$CS_ID=CS_Request("id");
	$CS_TID=CS_Request("tid");
	$CS_SID=CS_Request("sid");
	if($CS_TID==""){$CS_TID==0;}
	if($CS_SID==2){
		$table=Getdbname('news');
	}elseif($CS_SID==3){
		$table=Getdbname('topic');
	}else{
		$table=Getdbname('dance');
	}	
	$sql="update ".$table." set CS_Reco=".$CS_TID." where CS_ID=".$CS_ID;
	if($db->query($sql)){
		echo "ok";
	}
}

function Bdlist(){
	global $db;
	$CS_ID=CS_Request("cid");
	$isbind=0;
	$sql="select * from ".Getdbname('class')." where CS_SID=1";
	$result=$db->query($sql);
	if($result){
		while($row=$db->fetch_array($result)){
			if(stristr($row['CS_CSID'],",".$CS_ID.",")){
				$isbind=$row['CS_ID'];
			}
		}
	}	
	if($isbind==0){
		echo "<img src=../res/images/cno.gif>";
	}else{
		echo "<img src=../res/images/cyes.gif>";
	}
}
?>
