<?php 
include("config.php");			//调用配置文件
include("conn/conn.php");		//链接数据库
$fp=@fopen($_POST[tb_channel_address],"r");		//判断指定的文件是否存在
if($fp==false) {
	echo "<script>alert('该文件不存在！'); history.back();</script>";
}else{

$sql1="select * from tb_channel where  tb_channel_address='".$_POST[tb_channel_address]."'";
$ret1=$conn -> Execute($sql1);
$array=$ret1->GetRows();
if(count($array)<=0){		//判断该频道是否已经被订阅

$sql="select * from tb_channel_group ";
$ret=$conn -> Execute($sql);		//读取数据库中频道组的数据
$array=array();						//订阅空数组
$arrayes=array();					//订阅空数组
while(!$ret -> EOF){				//配合wihle语句循环输出结果
array_push($array,$ret->fields[0]);		//将指定字段的值写入到数组中
array_push($arrayes,$ret->fields[1]);	//将指定字段的值写入到数组中
	$ret -> movenext();										//指针下移
} 

$arrays=array_combine($array,$arrayes);	//创建一个数组，用$array数组的值作为键名，用$arrayes数组的值作为值
$smarty->assign("channel_groups",$arrays);	//定义模板变量
$smarty->assign("channel_group",1);
$smarty->assign("tb_channel_address",$_POST[tb_channel_address]);
$smarty->display("insert_channel_ok.tpl");	//指定模板页
}else{
echo "<script>alert('该频道已经被订阅！'); history.back();</script>";

}
}
fclose($fp);
?>
  