<%@ page language="C#" autoeventwireup="true" inherits="admin_ipConfig, kfenlei" %><%@ Register Src="inc/adminTop.ascx" TagName="adminTop" TagPrefix="qth8" %>
<!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>
<title>框分类信息系统 后台管理</title>
<link href="css.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center">
<div class="main" align="left">
<qth8:adminTop ID="AdminTop1" runat="server" />
<div class="d01">
<div class="tabTitle">IP限制</div>
<form action="action.aspx?s=editIpConfig" class="layui-form" method="post" name="ipConfig" id="ipConfig">
<table width="100%" border="0" class="layui-table" cellspacing="0" cellpadding="0">
<input type="hidden" name="address" id="address" value="<%=sAddress%>" />
<tr>
<td class="head" width="200">IP限制</td>
<td>发布信息：<input type="radio" value="1" name="post" lay-filter="post" title="开启" /><input type="radio" value="0" name="post" lay-filter="post" title="关闭" />
<br />用户注册：<input type="radio" value="1" name="user" lay-filter="user" title="开启" /><input type="radio" value="0" name="user" lay-filter="user" title="关闭" />
<br />评&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;论：<input type="radio" value="1" name="review" lay-filter="review" title="开启" /><input type="radio" value="0" name="review" lay-filter="review" title="关闭" />
<script language="javascript" type="text/javascript">
layui.use(['form','laydate'], function(){
var form = layui.form();
form.render();
form.on('radio(review)', function(data){
$("#ipConfig").submit();
});
form.on('radio(post)', function(data){
$("#ipConfig").submit();
});
form.on('radio(user)', function(data){
$("#ipConfig").submit();
});
});
</script>

<script type="text/javascript">
layui.use(['form','laydate'], function(){
var form = layui.form();
form.render();
form.on('select(class01)', function(data){
	setWeather($('#class01').val(),'2');
});
});
function setWeather(fCityName,fCityClass)
{
	$.get("action.aspx?s=getHtml&url=http://www.kfenlei.com/weather/city/city"+fCityName+".xml",
	function(data,status)
	{
		var city=data.split(",");
		selectBorough=document.getElementById("class0"+fCityClass);
		selectBoroughLangth=selectBorough.options.length;
		for(t=0;t<selectBoroughLangth;t++)
		{
			selectBorough.remove(0);
		}
		boroughOption=document.createElement("option");
		boroughOption.appendChild(document.createTextNode("请选择"));
		boroughOption.setAttribute("value", "");
		selectBorough.appendChild(boroughOption);
		for(i=0;i<city.length;i++)
		{
			arrayBorough=city[i].split("|");
			boroughOption=document.createElement("option");
			boroughOption.appendChild(document.createTextNode(arrayBorough[1]));
			boroughOption.setAttribute("value", arrayBorough[0]);
			selectBorough.appendChild(boroughOption);
			var form = layui.form();
			form.render();
		}
	});	
}
$(function(){
setWeather('','1');
});
</script>
</td>
</tr>
<tr>
<td class="head">不受限地区</td>
<td>
<div id="addressList"></div>
<div class="clear"></div>
<div class="fl5"><select id="class01" lay-filter="class01" onchange="setWeather(this.value,'2')">
<option value="">请选择</option>
</select></div>
<div class="fl5"><select id="class02">
<option value="">请选择</option>
</select>
</div><input type="button" value="添加" class="layui-btn" onclick="add()" /></td>
</tr>
</table>
</form>
<div class="tabTitle">IP白名单</div>
<form id="Form1" action="action.aspx?s=addIpConfig" class="layui-form" method="post" name="link"><input type="hidden" name="class" value="0" />
<table width="100%" border="0" class="layui-table" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td width="300">开始IP</td><td width="300">结束IP</td><td></td>
</tr>
</thead>
<tr>
<td><input name="startIp" value="" size="30" class="layui-input" /></td><td><input name="endIp" size="30" value="" class="layui-input" /></td><td><input type="submit" value="添加" class="layui-btn layui-btn-small" /></td>
</tr>
<%=sIpList1 %>
</table>
</form>
<div class="tabTitle">IP黑名单</div>
<form id="Form1" action="action.aspx?s=addIpConfig" method="post" name="link"><input type="hidden" name="class" value="1" />
<table width="100%" border="0" class="layui-table" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td width="300">开始IP</td><td width="300">结束IP</td><td></td>
</tr>
</thead>
<tr>
<td><input name="startIp" value="" size="30" class="layui-input" /></td><td><input name="endIp" size="30" value="" class="layui-input" /></td><td><input type="submit" value="添加" class="layui-btn layui-btn-small" /></td>
</tr>
<%=sIpList2 %>
</table>
</form>
<script type="text/javascript">
function add()
{
	var vl=$("#class02").find("option:selected").text();
	if(vl==""||vl=="请选择")
	{
		vl=$("#class01").find("option:selected").text();
	}
	
	if(vl!=""&&vl!="请选择")
	{
		$("#address").val($("#address").val()+vl+",");
	update();
	ipConfig.submit();
	}
	else
	{
		alert("请选择地区!");
	}
}

function del(num)
	{
		var sList="";
		var slideArr=$("#address").val().split(",");
		for(i=0;i<(slideArr.length-1);i++)
		{
			if(i!=num)
			{
				sList+=slideArr[i]+",";
			}
			
		}
		$("#address").val(sList);
		update();
		ipConfig.submit();
}
function update()
{
	$("#addressList").html("");
		var sList="";
		var slideArr=$("#address").val().split(",");
		for(i=0;i<slideArr.length;i++)
		{
			if(slideArr[i]!="")
			{
				sList+="<div class=\"ipConfigList\"><div class=\"ip\">"+slideArr[i]+"</div><div class=\"layui-btn layui-btn-small\" onclick=\"del("+i+")\">删除</div></div>";
			}
			
		}
		$("#addressList").html(sList);
}
update();
</script>
<div></div>
</div>
</div>
</div>
</body>
<script>
ckRadio("user","<%=sUser%>");
ckRadio("post","<%=sPost%>");
ckRadio("review","<%=sReview%>");
</script>
</html>
