<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=popbox}-->
<!--{include file=elements/header.js.html type=valid}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>网站管理&nbsp;&gt;&nbsp;属性设置&nbsp;&gt;&nbsp;屏蔽IP列表
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=SiteSet.basicset" class="link">站点信息</a>
				<a href="index.php?r=SiteSet.visitset" class="link">注册和访问</a>
				<a href="index.php?r=SiteSet.chinesewordunit" class="link">关键词屏蔽</a>
				<a href="index.php?r=SiteSet.illegalmobileiplist" class="nolink">屏蔽IP列表</a>
				<a href="index.php?r=SiteSet.legalmobileiplist" class="link">手机网关IP列表</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent2">
					<form name="searchForm" action="index.php" method="get" onSubmit="setDisabled('button', window.document);">
						<input type="hidden" name="r" value="SiteSet.illegalmobileiplist"/>
						<div class="searchbar">
							IP&nbsp;<input type="text" class="text" name="ip" value="<!--{$ip}-->"/>
							&nbsp;<button type="submit" class="but2font">查询</button>
						</div>
					</form>
					<div class="operation">
						<button type="button" class="but2font" onClick="addIp('<!--{$returnParams}-->')">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=SiteSet.deleteillegalmobileip&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定删除？')">删除</button>
					</div>
					<table class="tbl_list" width="100%" cellpadding="0" cellspacing="0" border="0">
						<tr class="thead">
							<td width="5%"><input type="checkbox" class="checkall"/></td>
							<td width="30%">IP</td>
							<td width="35%">备注</td>
							<td width="30%">操作</td>
						</tr>
						<!--{foreach from=$datalist item=item name=list}-->
						<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
							<td><input type="checkbox" name="recordId" value="<!--{$item.id}-->"/></td>
							<td><!--{$item.ip}--></td>
							<td><!--{$item.memo}--></td>
							<td><a href="javascript:updateIp('<!--{$item.id}-->', '<!--{$returnParams}-->')">修改</a></td>
						</tr>
						<!--{foreachelse}-->
						<tr><td colspan="4">没有对应数据</td></tr>
						<!--{/foreach}-->
					</table>
					<div class="operation">
						<button type="button" class="but2font" onClick="addIp('<!--{$returnParams}-->')">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=SiteSet.deleteillegalmobileip&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定删除？')">删除</button>
					</div>
					<div class="page"><!--{$pager}--></div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
function updateIp(id, returnParams){
	$.popbox({title:"修改屏蔽IP", content:popstr_search});
	$.ajax({
		url: "index.php?r=SiteSet.updateillegalmobileip&id="+id,
		data:{returnParams:returnParams},
		type: "get",
		cache: false,
		dataType: "text",
		success: function(data){
			$.popbox.setcontent({title:"修改屏蔽IP", content:data});
		}
	});
}

function addIp(returnParams){
	var str = "<form id=\"ipForm\" action=\"index.php?r=SiteSet.addillegalmobileip\" method=\"post\">";
	str += "<input type=\"hidden\" name=\"returnParams\" value=\""+decodeURIComponent(returnParams)+"\"/>";
	str += "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	str += "<td class=\"td_name\">IP<span class=\"red\">*</span></td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" id=\"ip\" name=\"data[IllegalMobileIp][ip]\"/><img class=\"tiptip\" title=\"IP地址支持“*”号，表示1到256之间的任何一个数字\" src=\"images/quest.gif\"/><span id=\"span_ip\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"td_name\">备注</td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" name=\"data[IllegalMobileIp][memo]\"/></td>";
	str += "</tr><tr>";
	str += "<td class=\"noborder\"></td>";
	str += "<td class=\"noborder\"><button type=\"submit\" class=\"butsubmit\">提交</button></td>";
	str += "</tr></table></form>";
	$.popbox({title:"新增屏蔽IP", content:str});
	ipValid();
	$(".tiptip").tipTip({defaultPosition: "right"});


}

function ipValid(){
	jQuery.validator.addMethod("ip", function(value, element) {
		  return this.optional(element) || (/^(\d+)\.(\d+)\.(\d+)\.([\d|\*]+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && (RegExp.$4<256 || RegExp.$4=="*")));   
		}, "请输入合法的IP信息");
	
	$("#ipForm").validate({
		rules: {
			"data[IllegalMobileIp][ip]" : {
				"required":true,
				"ip":true,
				remote : {
					url : "index.php",
					cache : false,
					data : {
						r : "SiteSet.check_illegal_mobile_ip",
						illegal_ip: function(){
							return $("#ip").val();
						}
					}
				}				
			}
		},
		messages: {
			"data[IllegalMobileIp][ip]" : {
				"required":"请输入IP",
				"remote":"IP已存在"
			}
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		},
		onkeyup: false
	});
}
</script>
</html>