#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html;charset=gb2312
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];
	var dns = document.getElementsByName(\"dns\")[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);
	dns.value = TrimAll(dns.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"
	[ "${CGI_dns}" = "" ] && CGI_dns="0.0.0.0"
	errmsg=`${FLOWEYE} pppoeippool set id=${CGI_id} name=${CGI_name} start=${CGI_start} end=${CGI_end} \
ratein=${CGI_ratein} rateout=${CGI_rateout} dns=${CGI_dns} clntepa=${CGI_clntepa}`
	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>ûDNS</TD> 
		<td width=*  align=left><input type=text name=dns style=\"width:180px\" value=\"${CGI_dns}\" />&nbsp;(,Ÿ,114.114.114.114,8.8.8.8)
	</td>
	</td>
</tr>
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>Թ˺</td>
	<td width=*  align=left>
	<select name=clntepa style=\"width:120px\" value=\"${CGI_clntepa}\">
	"; 
		case "${CGI_clntepa}" in
		"reject")
			echo "<option value=reject selected>½</option>"
			echo "<option value=login>ɵ½</option>"
			echo "<option value=pass>ɵ½Ҳ</option>"
			;;
		"login")
			echo "<option value=reject>½</option>"
			echo "<option value=login selected>ɵ½</option>"
			echo "<option value=pass>ɵ½Ҳ</option>"
			;;
		"pass")
			echo "<option value=reject>½</option>"
			echo "<option value=login>ɵ½</option>"
			echo "<option value=pass selected>ɵ½Ҳ</option>"
			;;
		esac
	
echo -n "
	</select>
	</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>
";