#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html
Cache-Control: no-cache

"
echo -n "";
. ../common/common.sh 
myself="/cgi-bin/Setup/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script languate=javascript>
function onIPChanged(ipobj)
{
	var ip = document.getElementsByName(\"ipobj\")[0];
	ip.value = ipobj.value;
	document.getElementsByName(\"addip\")[0].disabled = false;
}
function onProtectChanged(obj)
{
	if (obj.value == 1)
		window.location.href = \"${myself}\" + \"?action=ipverify&ipverify=enable\";
	else
		window.location.href = \"${myself}\" + \"?action=ipverify&ipverify=disable\";
}
function onAddIP(ipgrp)
{
	var ipobj = document.getElementsByName(\"ipobj\")[0];
	ipobj.value = TrimAll(ipobj.value);
	if (ipobj.value == \"\") {
		alert(\"IPַ,10.1.1.110.1.1.0/2410.1.1.1-10.1.1.127!\");
		ipobj.select();
		return false;
	}
	window.location.href = \"${myself}\" + \"?action=addip&ipgrp=\" + ipgrp +\"&ipobj=\" + ipobj.value;
}
function onRmvIP(ipgrp)
{
	var ipobj = document.getElementsByName(\"ipobj\")[0];
	ipobj.value = TrimAll(ipobj.value);
	if (ipobj.value == \"\") {
		alert(\"ѡҪɾIPַ!\");
		return false;
	}
	window.location.href = \"${myself}\" + \"?action=rmvip&ipgrp=\" + ipgrp +\"&ipobj=\" + ipobj.value;
}
</script>
";
if [ "${CGI_action}" = "addip" ]; then
	errmsg=`${FLOWEYE} table addip 0 ${CGI_ipobj}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
		afm_load_page 0 "${myself}"
		exit 0
	fi
fi
if [ "${CGI_action}" = "rmvip" ]; then
	errmsg=`${FLOWEYE} table rmvip 0 ${CGI_ipobj}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
		afm_load_page 0 "${myself}"
		exit 0
	fi
fi
if [ "${CGI_action}" = "ipverify" ]; then
	errmsg=`${FLOWEYE} ipverify ${CGI_ipverify}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	fi
fi

echo -n "
<body>
"; cgi_show_title "->αIP" 
echo -n "
<br>
<table style=\"width:800; border-bottom:1px #787882 solid; font:bold  14px; color:#0000ff\">
<tr>
	<td style=\"font:14px\"><b>һЩ˵</b></td>
	<td style=\"font:12px;\" align=right width=\"*\"></td>
</tr>
</table>
<br>
<table width=800 border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=80></td>
	<td width=* style=\"color:#0000ff;font:13px\">1. ľʱⷢʹķǷݰ</td>
</tr>
<tr id=row1>
	<td width=80></td>
	<td width=* style=\"color:#0000ff;font:13px\">2. ЩǷݰУкܶԴַģǺϷַ</td>
</tr>
<tr id=row1>
	<td width=80></td>
	<td width=* style=\"color:#0000ff;font:13px\">3. ЩǷݰǽӳأ·ǽϵͳ</td>
</tr>
<tr id=row1>
	<td width=80></td>
	<td width=* style=\"color:#0000ff;font:13px\">4. Ϊ˹ǷݰƵģΪϵͳȷˣϵͳЩIPϷIP</td>
</tr>
</table>
<br>
<table class=bgurl width=800 border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr id=row1 height=250>
	<td width=80 align=center valign=center style=\"color:#0000ff;font:bold\">&nbsp;&nbsp;ϷIP&nbsp;&nbsp;</td> 
	<td width=250><select style=\"width:100%;height:100%\" name=iplist size=30 onchange=\"onIPChanged(this)\"> ";
		${FLOWEYE} table get 0 | while read ipobj
		do
			echo "<option value=\"${ipobj}\">${ipobj}</option>"
		done 
echo -n "</select>
	</td>
	<td align=top valign=top width=*>
	    &nbsp;&nbsp;<input type=text style=\"width:200\" name=ipobj></input>
	    <input type=button style=\"width:80;height:22px\" value=\"IP\" onclick=\"onAddIP('${CGI_ipgrp}')\"></input> &nbsp;&nbsp;
	    <input type=button name=addip disabled style=\"width:80;height:22px\" value=\"ɾIP\" onclick=\"onRmvIP('${CGI_ipgrp}')\"></input>
	</td>
</tr>
<tr id=row1>
	<td align=center valign=center style=\"color:#0000ff;font:bold\">&nbsp;&nbsp;αIP&nbsp;&nbsp;</td>
	<td><select style=\"width:100%;height:100%\" name=ipprotect onchange=\"onProtectChanged(this)\"> ";
		for expval in `${FLOWEYE} ipverify stat` 
		do
			eval "${expval}"
		done
		if [ ${ipverify_enable} -eq 0 ]; then
			echo "<option value=0 selected>ر</option>"
			echo "<option value=1></option>"
		else
			echo "<option value=0>ر</option>"
			echo "<option value=1 selected></option>"
		fi 
echo -n "</select>
	</td>
	<td></td>
</tr>
</table>
</body>
</html>
";