#!/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 Validate(frm)
{
	var ttl = document.getElementsByName(\"ipmac_ttl\")[0];
	ttl.value = TrimAll(ttl.value);
	if (ttl.value == \"\" || !IsDigit(ttl.value)) {
		alert(\"ʱ!\");
		ttl.select();
		return false;
	}
	if (ttl.value < 60) {
		alert(\"ʱ䲻С60!\");
		ttl.select();
		return false;
	}
	return true;
}
function editIPgrp()
{
	var whitetbl = document.getElementsByName(\"ipmac_whitetbl\")[0];
	if (whitetbl.value == \"0\") {
		alert(\"ѡٱ༭!\");
		return;
	}
	var url = \"/cgi-bin/Protocol/ipgrp_list?ipgrp=\" + whitetbl.value;
	ShowWindow(url, \"\", 840, 620);
}
</script>
"; 
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	[ "${CGI_ipmac_gateway}" = "" ] && CGI_ipmac_gateway="0.0.0.0"
	args="ipmac_enable=${CGI_ipmac_enable}"
	args="${args} ipmac_deny_dynamic=${CGI_ipmac_deny_dynamic}"
	args="${args} ipmac_ttl=${CGI_ipmac_ttl}"
	args="${args} ipmac_whitetbl=${CGI_ipmac_whitetbl}"
	args="${args} ipmac_gateway=${CGI_ipmac_gateway}"
	errmsg=`${FLOWEYE} ipmac set ${args}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ: ${errmsg}"
	else
		afm_dialog_msg "ɹ!"
	fi
fi
for nameval in `${FLOWEYE} ipmac stat`
do
	eval "${nameval}"
done

echo -n "
<body>
"; cgi_show_title "MACܿ->" 
echo -n "
<br>
<form method=post onsubmit=\"return Validate(this)\" action=\"${myself}\">
<table width=700 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=40></td>
	<td width=100 align=left>MAC</td>
	<td width=* align=left>
		<select name=ipmac_enable value=${ipmac_enable} style=\"width:120\">
		";
			if [ ${ipmac_enable} -eq 0 ]; then
				echo "<option value=1></option>"
				echo "<option value=0 selected>ر</option>"
			else
				echo "<option value=1 selected></option>"
				echo "<option value=0>ر</option>"
			fi
		
echo -n "
		</select>
	</td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left>δMACIP</td>
	<td width=* align=left>
		<select name=ipmac_deny_dynamic value=${ipmac_deny_dynamic} style=\"width:120\">
		";
			if [ ${ipmac_deny_dynamic} -eq 0 ]; then
				echo "<option value=1>ܾͨ</option>"
				echo "<option value=0 selected>ͨ</option>"
			else
				echo "<option value=1 selected>ܾͨ</option>"
				echo "<option value=0>ͨ</option>"
			fi
		
echo -n "
		</select>
	</td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left></td>
	<td width=* align=left>
		<select name=ipmac_whitetbl value=${ipmac_whitetbl} style=\"width:120\">
		";
			if [ "${ipmac_whitetbl}" = "0" ]; then
				echo "<option value=0 selected>IPȺ</option>"
			else
				echo "<option value=0>IPȺ</option>"
			fi
			
			${FLOWEYE} table list | while read tblid tblname
			do
				if [ "${ipmac_whitetbl}" = "${tblid}" ]; then
					echo "<option value=${tblid} selected>${tblname}</option>"
				else
					echo "<option value=${tblid}>${tblname}</option>"
				fi
			done
		
echo -n "
		</select>(еIP\"δMACIP\"ѡ, <a style=\"color:#0000ff\" href=\"javascript:editIPgrp()\">༭</a>)
	</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>IPַ</td>
	<td width=* align=left>
		<input type=text name=ipmac_gateway style=\"width:120px\" value=\"${ipmac_gateway}\"></input>(Ϊ˱ûа󶨵ܾ˷ǰIPַ粻ͨ,صַ)
	</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>̬ϻʱ</td>
	<td width=* align=left>
		<input type=text name=ipmac_ttl style=\"width:120px\" value=\"${ipmac_ttl}\"></input>()
	</td>
</tr>
</table>
<table style=\"width:700; border-bottom:1px #787882 solid; color:#0000ff\">
<tr><td align=right>&nbsp;</td></tr>
</table>
<table style=\"width:700\"> 
<tr>
        <td align=right>
		<input type=submit style=\"width:80\" value=\"ύ\"></input>
	</td>
</tr>
</table>
</form>
</body>
</html>
";