#!/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/Route/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function beforeEditWG(frm)
{
	var weight = document.getElementsByName(\"weight\")[0];
	weight.value = TrimAll(weight.value);
	if (!IsDigitIn(weight.value, 1, 100)) {
		alert(\"ȷȨֵ!\");
		weight.select();
		return false;
	}
	return true;
}
function onCancel() 
{
	window.location.href = \"/cgi-bin/Route/proxy_list\";
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	errmsg=`${FLOWEYE} nat setwg id=${CGI_id} proxy=${CGI_proxy} weight=${CGI_weight}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ʧ:${errmsg}"
	else
		afm_load_page 0 "/cgi-bin/Route/proxy_list"
		exit 0
	fi
fi

echo -n "
<body>
"; cgi_show_title "ӿ·->${CGI_name}->༭·" 
echo -n "
<br>
<form method=post onsubmit=\"return beforeEditWG(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=400 align=left><b>${CGI_name}</b></td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>WAN·</td>
        <td align=left><b>${CGI_proxy}</b></td>
</tr>
<tr id=row1>
	<td width=40></td>
        <td width=80 align=left>·Ȩ</td>
	<td width=400 align=left><input type=text name=weight style=\"width:120px\" value=\"${CGI_weight}\" />&nbsp;(1~10)</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=hidden name=name value=\"${CGI_name}\" />
		<input type=hidden name=proxy value=\"${CGI_proxy}\" />
		<input type=submit id=newbtn value=\"ύ\" />
		<input type=button id=newbtn value=\"ȡ\" onclick=\"onCancel()\" />
	</td>
</tr>
</table>
</form>
</body>
</html>
";