<?php
/*
'**************************************************************************************************
' 软件名称: 搜一次 Content Management System
' 版本编号: Version 1.X
' 官方网站: http://www.yixiu.cc
' 官方论、任何个人或组织不得在未经授权的情况下删除、修改、拷贝本软件及其他副本上一切关于版权的信息；
'    2、搜一次网络事业部保留此软件的法律追究权利
'*********************************坛：http://bbs.yixiu.cc
' 版权所有: 搜一次运营团队
' 郑重声明:
'    1*****************************************************************
*/
include "../../admin_loginstate.php";
include "../../../include/conn.php";
include "../../../include/function.php";
include "../../admin_version.php";

if(strtolower($_SERVER['REQUEST_METHOD'])=='post'){
	if(!empty($_POST['class']) && is_array($_POST['class'])){
		foreach($_POST['class'] as $key=>$value){
			$key = intval($key);
			$value = explode(',',$value);
			$value = array_filter($value,'arrayFilter');
			$value = array_unique($value);
			$value = implode(',',$value);
			$db->query('update `s_class` set collectbind=\''.$value.'\' where S_ID='.$key);
		}
		echo '操作成功';
	}else{
		echo '操作失败';
	}
	echo '<script type="text/javascript">setTimeout("window.location.href=\'\'", 1000); </script>';
	exit;
} else {
	$sql = 'select S_ID as id,S_Name as name,collectbind from s_class where S_SystemID=1';
	$query = $db->query($sql);
	$data = array();
	while($row = $db->fetch_array($query)){
		$data[$row['id']] = array($row['name'], $row['collectbind']);
	}
}

function arrayFilter(&$value){
	$value = (string)$value;
	$value = trim(strip_tags($value));
	return empty($value) ? false : $value;
}

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link  href="../../images/style.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="../../images/alerts.css" rel="stylesheet" media="screen" />
<title>自定义采集</title>
<script type="text/javascript">var tentpath='/';</script>
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/alerts.js"></script>
</head>

<body>
<div class="r_main">
	<div class="r_content">
		<div class="r_content_1">
				<form method="post" name="formb" action="" >
				<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="tb_style" >
					<tr>
						<td width="60" height="30" bgcolor="#FFFFFF" class="td_border">&nbsp; 编号</td>
						<td width="105" bgcolor="#FFFFFF" class="td_border">&nbsp;分类名</td>
						<td width="390"  bgcolor="#FFFFFF" class="td_border">&nbsp;绑定分类信息</td>
						<td class="td_border">说明</td>
					</tr>
					<?php if(!empty($data)): $i=1;foreach ($data as $key=>$item) {?>
						<tr>
							<td height="30" bgcolor="#FFFFFF" class="td_border"><?php echo $key;?></td>
							<td bgcolor="#FFFFFF" class="td_border"><?php echo $item[0];?></td>
							<td bgcolor="#FFFFFF" class="td_border"><input type="text" name="class[<?php echo $key;?>]" value="<?php echo $item[1];?>" size="50" /></td>
							<?php if ($i==1): ?><td bgcolor="#FFFFFF" class="td_border" rowspan="2">
								1、多个绑定请用半角逗号,分隔<br />
								2、请不要重复绑定<br />
								3、请不要输入任何特殊字符，会一律被屏蔽掉<br />
								4、绑定数据保存在s_class表的collectbind字段中</td><?php endif;?>
						</tr>
					<?php $i++;} ?>
					  <tr>
						<td height="30"  colspan="4" class="td_border">
						   &nbsp; &nbsp; <input name="submit" type="submit" class="rb1" id="export" value="提交绑定"/></td>
			      	</tr>
					
					<?php else:?>
							<tr>
                            	<td colspan="3" class="td_border" height="30" align=center><b>暂无对应列表,请添加</b>！</td>
                            </tr> 					
					<?php endif;?>
			  </table>
			  </form>
				</div>
		</div>
</div>
 
<?php require_once("../../admin_bottom.php");?>      
      
</body>
</html>