#!/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/Pppoe/`basename $0`"
returl="/cgi-bin/Pppoe/ippool_list"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function beforeAddProxy(frm)
{
	var name  = document.getElementsByName(\"name\")[0];
	var start = document.getElementsByName(\"start\")[0];
	var end   = document.getElementsByName(\"end\")[0];
	var ratein= document.getElementsByName(\"ratein\")[0];
	var rateout= document.getElementsByName(\"rateout\")[0];
	name.value = TrimAll(name.value);
	if (!IsName(name.value)) {
		alert(\"в&ַ!\");
		ifname.select();
		return false;
	}
	start.value = TrimAll(start.value);
	if (!IsIPAddr(start.value)) {
		alert(\"ʼַ!\");
		start.select();
		return false;
	}
	end.value = TrimAll(end.value);
	if (!IsIPAddr(end.value)) {
		alert(\"ַ!\");
		end.select();
		return false;
	}
	ratein.value = TrimAll(ratein.value);
	rateout.value = TrimAll(rateout.value);
	return true;
}
function onCancel() 
{
	window.location.href = \"${returl}\";
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	[ "${CGI_ratein}" = "" ] && CGI_ratein="0"
	[ "${CGI_rateout}" = "" ] && CGI_rateout="0"
	errmsg=`${FLOWEYE} pppoeippool set id=${CGI_id} name=${CGI_name} start=${CGI_start} end=${CGI_end} \
ratein=${CGI_ratein} rateout=${CGI_rateout} explogin=${CGI_explogin}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ʧ:${errmsg}"
	else
		afm_load_page 0 "${returl}"
		exit 0
	fi
else
	for nameval in `${FLOWEYE} pppoeippool get id=${CGI_id}`
	do
		eval "CGI_${nameval}"
	done
fi

echo -n "
<body>
"; cgi_show_title "PPPOE->༭ַ" 
echo -n "
<br>
<form method=post onsubmit=\"return beforeAddProxy(this)\" action=\"${myself}\">
<table style=\"font:14px\" width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>û</td>
	<td width=*  align=left><input type=text name=name style=\"width:120px\" value=\"${CGI_name}\" />&nbsp;(Ҫ8ֻ15Ӣַ)</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>ַΧ</td>
        <td align=left>
		<input type=text name=start style=\"width:120px\" value=\"${CGI_start}\" />&nbsp;-&nbsp;
		<input type=text name=end   style=\"width:120px\" value=\"${CGI_end}\" />
	</td>
</tr>
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>û</td>
	<td width=*  align=left><input type=text name=rateout style=\"width:120px\" value=\"${CGI_rateout}\" />&nbsp;(ûkbps,0ʾ)</td>
</tr>
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>û</td>
	<td width=*  align=left><input type=text name=ratein style=\"width:120px\" value=\"${CGI_ratein}\" />&nbsp;(ûkbps,0ʾ)</td>
</tr>
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>˺Źڵ¼</td>
	<td width=*  align=left>
	<select name=explogin style=\"width:120px\" value=\"${CGI_explogin}\">
	"; if [ "${CGI_explogin}" = "0" ]; then 
echo -n "
		<option value=0 selected></option>
		<option value=1></option>
	"; else 
echo -n "
		<option value=0></option>
		<option value=1 selected></option>
	"; fi 
echo -n "
	</select>&nbsp;(˺ŹںǷ¼)
	</td>
</tr>
</table>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#0000ff\">
<tr><td align=right>&nbsp;</td></tr>
</table>
<table style=\"width:600\"> 
<tr>
        <td align=right>
		<input type=hidden name=id value=\"${CGI_id}\" />
		<input type=submit id=newbtn value=\"ύ\"></input>
		<input type=button id=newbtn value=\"ȡ\" onclick=\"onCancel()\"></input>
	</td>
</tr>
</table>
</form>
</body>
</html>
";