<?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('2_2');
$ac=CS_Request("ac");
?>
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>csdjcms management</title>
<link href="../res/css/admin_style.css" rel="stylesheet" />
<script language="javascript" src="../res/js/jquery.js"></script>
<style> 
body{width:440px;}
</style>
<script language="javascript">
$(document).ready(function(){
	$("#addip").click(function(){
		var CS_Name=$("#CS_Name").val();
		var CS_Downip=$("#CS_Downip").val();
		var CS_Playip=$("#CS_Playip").val();
	$("#CS_Name").css("border-color","#666 #ccc #ccc #666");
	$("#CS_Playip").css("border-color","#666 #ccc #ccc #666");
	$("#CS_Downip").css("border-color","#666 #ccc #ccc #666");
	if(CS_Name==""){
		$("#CS_Name").css("border","1px solid red");
		$("#Msg").text("请填写组名称！").css("color","red");
		return false;
		}
	else if(CS_Playip==""){
		$("#CS_Playip").css("border","1px solid red");
		$("#Msg").text("请填写视听地址！").css("color","red");
		return false;
		}
	else if(CS_Downip==""){
		$("#CS_Downip").css("border","1px solid red");
		$("#Msg").text("请填写下载地址！").css("color","red");
		return false;
		}
	});
});

function dhcolok(){
    this.parent.$('.webox').css({display:'none'});
    this.parent.$('.background').css({display:'none'});
}
</script>
</head>
<body class="body_none">
<div>
<!-- mod start -->
<form method="post" class="J_ajaxForm" action="?ac=edit" data-role="edit">
<div class="pop_cont pop_table2">
	<table width="100%" style="table-layout:fixed;">
		<col width="90" />
		<col />
		<tr>
			<th>组名称</th>
			<td>
				<span class="must_red">*</span>
				<input type="text" id="CS_Name" name="CS_Name" class="input input_hd length_5" value="">
			</td>
		</tr>
		<tr>
			<th>视听组地址</th>
			<td>
				<span class="must_red">*</span>
				<div class="mb5"><input type="text" id="CS_Playip" name="CS_Playip" class="input length_5" value=""></div>
				<div class="gray">视听组地址</div>
			</td>
		</tr>
		<tr>
			<th>下载组地址</th>
			<td>
				<span class="must_red">*</span>
				<div class="mb5"><input type="text" id="CS_Downip" name="CS_Downip" class="input length_5" value=""></div>
				<div class="gray">下载组地址</div>
			</td>
		</tr>
	</table>
</div>
<!-- mod end -->
<div class="pop_bottom">
    <div class="tips_error" id="Msg"></div>
	<button class="btn fr" onclick="dhcolok();" type="button">取消</button>
	<button class="btn btn_submit J_ajax_submit_btn mr10 fr" id="addip" type="submit">提交</button>
</div>
</form>
<!-- end -->
</div>
<?php
if($ac=='edit'){
    $CS_Name=CS_Request("CS_Name");
    $CS_Playip=CS_Request("CS_Playip");
    $CS_Downip=CS_Request("CS_Downip");

    if(empty($CS_Name)||empty($CS_Playip)||empty($CS_Downip)) exit("<script>document.getElementById('Msg').innerHTML='请把资料填写完整!';</script>");

    $sql="Insert ".Getdbname('fwqip')."  (CS_Name,CS_Playip,CS_Downip) values ('".$CS_Name."','".$CS_Playip."','".$CS_Downip."')";

    if($db->query($sql)){
        echo '<script>document.getElementById("Msg").className="tips_success";$("#Msg").text("恭喜,添加成功!").css("color","#026E12");</script>';
	echo "<script>setTimeout(\"this.parent.$('.webox').css({display:'none'});this.parent.$('.background').css({display:'none'});window.parent.location.reload();\",2000);</script>";
    }else{
        echo '<script>$("#Msg").text("抱歉,添加失败!").css("color","red");</script>';
        echo "<script>setTimeout(\"window.location='javascript:history.go(-1);'\",2000);</script>";
    }
}
?>
</body>
</html>
