<?php

/*
'**************************************************************************************************
' 程序名称: CCTVAI开源音乐管理系统
' 官方网站: http://www.cctvai.com
' 联系 Q Q: 1542367792
' QQ交流群：136687984
' 版本：(终结版)
' 备注：未经书面授权，不得向任何第三方提供本软件系统！
' 功能，模板，插件，扩展，定制请联系QQ：1542367792
'**************************************************************************************************
*/
error_reporting(0);
include "../../include/cctvai.conn.php";
include "../function_common.php";
admincheck(1);
/*if(Smallfivesolution()==$_SERVER['SERVER_NAME']) {
} else {
	echo Smallfivesq();
	exit();
}*/
$action=SafeRequest("action", "get");
if($action=="unite") {
	global $db;
	$cd_level=SafeRequest("cd_level", "post");
	$cd_name=SafeRequest("cd_name", "post");
	$cd_experience=SafeRequest("cd_experience", "post");
	$cd_experienceup=SafeRequest("cd_experienceup", "post");
	$cd_pic=SafeRequest("cd_pic", "post");
	if($cd_level=="") {
		showmessage("出错了，等级不能为空！", "experience.php", 1);
	}
	if($cd_name=="") {
		showmessage("出错了，等级名称不能为空！", "experience.php", 1);
	}
	if($cd_experience=="") {
		showmessage("出错了，经验介于不能为空！", "experience.php", 1);
	}
	if($cd_experienceup=="") {
		showmessage("出错了，经验介于不能为空！", "experience.php", 1);
	}
	$sql="Insert " . tname('experience') . " (cd_level,cd_name,cd_experience,cd_experienceup,cd_pic) values ('" . $cd_level . "','" . $cd_name . "','" . $cd_experience . "','" . $cd_experienceup . "','" . $cd_pic . "')";
	$db->query($sql);
	showmessage("恭喜您，添加经验等级组成功！", "experience.php", 0);
} elseif($action=="editsave") {
	global $db;
	$CD_ID=RequestBox("cd_id");
	if($CD_ID=="0") {
		showmessage("出错了，请选择要编辑的经验等级组！", "experience.php", 1);
	} else {
		$ID=explode(",", $CD_ID);

		for($i=0; $i<count($ID); $i++) {
			$cd_level=SafeRequest("cd_level" . $ID[$i] . "", "post");
			$cd_name=SafeRequest("cd_name" . $ID[$i] . "", "post");
			$cd_experience=SafeRequest("cd_experience" . $ID[$i] . "", "post");
			$cd_experienceup=SafeRequest("cd_experienceup" . $ID[$i] . "", "post");
			$cd_pic=SafeRequest("cd_pic" . $ID[$i] . "", "post");
			if($cd_level=="") {
				showmessage("出错了，等级名称不能为空！", "experience.php", 1);
			}
			if($cd_name=="") {
				showmessage("出错了，等级名称不能为空！", "experience.php", 1);
			}
			if($cd_experience=="") {
				showmessage("出错了，经验介于不能为空！", "experience.php", 1);
			}
			if($cd_experienceup=="") {
				showmessage("出错了，经验介于不能为空！", "experience.php", 1);
			}
			$sql="update " . tname('experience') . " set cd_level='" . $cd_level . "',cd_name='" . $cd_name . "',cd_experience='" . $cd_experience . "',cd_experienceup='" . $cd_experienceup . "',cd_pic='" . $cd_pic . "' where CD_ID=" . $ID[$i] . "";
			$db->query($sql);
		}
		showmessage("恭喜您，编辑经验等级组成功！", "experience.php", 0);
	}
} elseif($action=="del") {
	global $db;
	$CD_ID=SafeRequest("cd_id", "get");
	$array=array(
		'1',
		'2',
		'3',
		'4',
		'5',
		'6'
	);
	if(in_array($CD_ID, $array)) {
		showmessage("删除失败,系统自带等级经验组您只可以编辑不可删除。", "experience.php", 0);
	}
	$sql="delete from " . tname('experience') . " where CD_ID='" . $CD_ID . "'";
	if($db->query($sql)) {
		die("<script>window.location='experience.php'</script>");
	}
}
?>
<!DOCTYPE html>
<html>
 <head> 
  <meta charset="gbk" /> 
  <meta name="renderer" content="webkit" /> 
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> 
  <title>后台管理中心</title> 
  <link href="../css/add.css" rel="stylesheet" /> 
  <style type="text/css">
.table2{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table2 td{font-size: 12px;border-top: 1px solid #ddd;padding: 8px;vertical-align: top;}
.table2 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table2 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
.table3{width: 100%;max-width: 100%;border-collapse: collapse;border-spacing: 0;}
.table3 tr:hover{text-decoration: none;background-color: #e6f2fb;}
.table3 td{font-size: 12px;line-height:25px;border-top: 1px solid #ddd;padding: 5px;vertical-align: top;border-right: solid 1px #ddd;}
.table3 th{border-bottom: 2px solid #ddd;vertical-align: bottom;padding: 2px;text-align: left;}
</style> 
  <script language="javascript">
function CheckAll(form) {
	for (var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if (e.name != 'chkall')
			e.checked = form.chkall.checked;
	}
}
</script> 
 </head> 
 <body> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong>会员经验等级组</strong> 
    </div> 
    <form name="form" method="post" action="experience.php?action=editsave"> 
     <table class="table2" id="dellist"> 
      <tbody> 
       <tr> 
        <td width="60" align="left"> 序号</td> 
        <td width="160" align="left">等级</td> 
        <td width="160" align="left">头衔名称</td> 
        <td width="160" align="left">经验介于</td> 
        <td width="160" align="left">等级图标</td> 
		<td width="160" align="left"></td> 
        <td align="left">操作</td> 
       </tr> 
<?php
global $db;
$sql="select * from " . tname('experience') . " order by cd_id desc";
$result=$db->query($sql);
$videonum=$db->num_rows($result);
if($videonum==0)
	echo "<tr><td height='30' colspan='9' align='center' bgcolor='#FFFFFF' class='td_border'><br><br>没有数据<br><br><br></td></tr>";
if($result) {
	while($row=$db->fetch_array($result)) {
?>
       <tr>
        <td align="left"><input type="checkbox" name="cd_id[]" id="cd_id" value="<?php echo $row['cd_id']?>" class="checkbox"/><?php echo $row['cd_id']?></td>
        <td align="left"><input id="cd_level" name="cd_level<?php echo $row['cd_id']?>" value="<?php echo $row['cd_level']?>" type="text" class="input input_hd length_1"></td>
        <td align="left"><input type="text" class="input input_hd length_2" name="cd_name<?php echo $row['cd_id']?>" value="<?php echo $row['cd_name']?>"/></td>
        <td align="left">
        <input id="cd_experience" name="cd_experience<?php echo $row['cd_id']?>" value="<?php echo $row['cd_experience']?>" type="text" class="input input_hd length_1">&nbsp;&nbsp; ~ 
        <input id="cd_experienceup" name="cd_experienceup<?php echo $row['cd_id']?>" value="<?php echo $row['cd_experienceup']?>" type="text" class="input input_hd length_1">&nbsp;&nbsp;</td>
        <td align="left"><input type="text" class="input input_hd length_6" name="cd_pic<?php echo $row['cd_id']?>" value="<?php echo $row['cd_pic']?>"/></td>
		<td align="left"><img src="<?php echo cd_webpath.$row['cd_pic']; ?>"></td>
        <td align="left"><a onClick="return confirm('确定删除吗？不可恢复！');" href="?action=del&cd_id=<?php echo $row['cd_id']?>" class="btn" style="font-size: 12px;padding: 3px 8px;">删除</a></td>
       </tr>
<?php
}
}
?>
       <tr> 
        <td height="35" colspan="8" align="left" bgcolor="#FAFBF7" class="td_border"><label for="chkall"><input type="checkbox" id="chkall" onClick="CheckAll(this.form)" class="checkbox" />&nbsp;全选</label>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <input type="submit" name="Submit" value="修改所选栏目" class="btn btn_submit mr10 J_ajax_submit_btn" /></td> 
       </tr> 
      </tbody> 
     </table> 
    </form> 
   </div> 
  </div> 
  <!--添加栏目--> 
  <div class="contents"> 
   <div class="panel"> 
    <div class="panel-head"> 
     <strong>添加经验等级组</strong> 
    </div> 
    <form action="?action=unite" name="unite" id="unite" method="post"> 
     <table width="100%"> 
      <tbody>
       <tr> 
        <td height="50" align="left"> &nbsp;等级：<input type="text" class="input input_hd length_1" name="cd_level" id="cd_level" value="" />　 &nbsp;等级名称：<input type="text" class="input input_hd length_2" name="cd_name" id="cd_name" value="" />　 经验介于： <input id="cd_experience" name="cd_experience" value="" type="text" class="input input_hd length_1" />&nbsp;&nbsp; ~ <input id="cd_experienceup" name="cd_experienceup" value="" type="text" class="input input_hd length_1" />&nbsp;&nbsp; &nbsp;等级图标：<input id="cd_pic" name="cd_pic" value="" type="text" class="input input_hd length_6" />&nbsp;&nbsp; <input type="submit" value="确定提交" name="submit" class="btn btn_submit mr10 J_ajax_submit_btn" /> </td> 
       </tr> 
      </tbody>
     </table> 
    </form> 
   </div> 
  </div>  
 </body>
</html>