#!/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 "";
if [ "${PALANG}" = "en" ]; then 
	LANG_001="Configure"
	LANG_002="Realtime"
	LANG_003="TopFlow"
	LANG_004="Trend"
	LANG_005="LogShow"
	LANG_006="ID"
	LANG_007="Time"
	LANG_008="Content"
	LANG_009="Insufficient operation rights"
	LANG_0010="operation failed"
	LANG_0011="Successful operation"
	LANG_0012="Egress line binding"
	LANG_0013="Optional exit line"
	LANG_0014="View"
	LANG_0015="Submit"
	LANG_0016="Cancel"
fi
. ../../common/common.sh
myself="/cgi-bin/App/gamecloud/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script type=\"text/javascript\">
function showProxy()
{
		var proxyname = document.getElementsByName(\"cloudwan\")[0].value;
        var url = \"/cgi-bin/Monitor/proxy_show?proxyname=\" + proxyname;
        ShowWindow(url, \"\", 620, 700);
}
</script>
<body>
";
# account support
ADMIN_NAME="admin"
[ "${TOPSEC}" != "" ] && ADMIN_NAME="superman"
operator_check()
{
        local user=$1
        [ "${user}" = "" ] && user=${ADMIN_NAME}
        if [ "${PANABIT_USER}" != "${ADMIN_NAME}" -a "${PANABIT_USER}" != "${user}" ]; then
				afm_dialog_msg "${LANG_009:=Ȩ޲㣡}"
				afm_load_page 0 "${myself}"
                exit 0
        fi
}
if [ "${REQUEST_METHOD}" = "POST" ]; then
	case "${CGI_act}" in
	
		"save")
			operator_check
			arg=""
			[ "${CGI_enable}" != "" ] && arg="${arg} enable=${CGI_enable}"
			[ "${CGI_cloudwan}" != "" ] && arg="${arg} ifname=${CGI_cloudwan}"
			
			if [ "${arg}" != "" ]; then
				errmsg=`${FLOWEYE} gamecloud config ${arg}`
				if [ "$?" != "0" ]; then
					afm_dialog_msg "${LANG_0010:=ʧ}${errmsg}"
					afm_load_page 0 "${myself}"
					exit 0;
				fi
			fi
			afm_dialog_msg "${LANG_0011:=ɹ}"
			afm_load_page 0 "${myself}"
			exit 0;
		;;
	esac
fi

echo -n "
<br>
<table class=\"title\" style=\"width:600; border-bottom:1px #787882 solid; color:#0000ff\">
<tr><td><b>·</b></td><td style=\"font-size:12px;color:#185A73\" align=\"right\" width=\"*\"></td></tr>
</table>
<br>
<form method=\"post\" action=\"${myself}\">
<table width=\"600\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" bgcolor=\"#ffffff\">
<tr id=\"row1\">
	<td width=20></td>
	<td width=100 align=\"left\">${LANG_0012:=ѡ·}</td>
	<td width=\"*\" align=\"left\" colspan=\"2\">
		<select name=cloudwan style=\"width:100\">
";
		ifname="`${FLOWEYE} gamecloud stat | grep ^ifname= | cut -d'=' -f2`"
		${FLOWEYE} nat listproxy type=proxy.pppoe.dhcp | while read type id name theothers
		do
				if [ "${ifname}" = "${name}" ]; then
						echo "<option value=\"${name}\" selected>${name}</option>"
				else
						echo "<option value=\"${name}\">${name}</option>"
				fi
		done

echo -n "
		</select>&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"javascript:showProxy();\">${LANG_0013:=鿴}</a>
	</td>
</tr>
</table>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#0000ff\">
<tbody><tr><td align=\"right\">&nbsp;</td></tr>
</tbody></table>
<br>
<table style=\"width:600\"> 
<tr>
        <td align=\"right\">
		<input type=\"hidden\" name=\"act\" value=\"save\"></input>
		<input type=\"submit\" id=\"newbtn\" style=\"width:80\" value=\"${LANG_0014:=ύ}\">
		<!-- <input type=\"button\" id=\"newbtn\" style=\"width:80\" value=\"${LANG_0015:=ȡ}\" onclick=\"onCancel()\"> -->
	</td>
</tr>
</table>
</form>
</body>
</html>";