#!/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="CMCC WebPortal"
	LANG_002="Input Waitting time"
	LANG_003="Error"
	LANG_004="Success"
	LANG_005="Enable"
	LANG_006="Disable"
	LANG_007="Server"
	LANG_008="Submit"
	LANG_009="Authentication waiting time"
	LANG_010="Seconds. After this time, resources will be released automatically if there is no response"
	LANG_011="CMCC WebPortal"
fi
CGI_browsertitle="${LANG_001:=йƶWebPortalӿ}"
. ../../common/common.sh 
myself="/cgi-bin/App/cmccwp/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function beforeCommit(frm)
{
	var cookie_ttl = document.getElementsByName(\"ttl\")[0];
	cookie_ttl.value = TrimAll(cookie_ttl.value);
	if (!IsDigit(cookie_ttl.value)) {
		alert(\"${lANG_002:=!}\");
		cookie_ttl.select();
		return false;
	}
	return true;
}
</script>
"; 
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	[ "${CGI_ttl}" = "" ] && CGI_ttl=5
	cmdargs="enable=${CGI_enable} ttl=${CGI_ttl} radsvrid=${CGI_radsvrid}"
	errmsg=`${FLOWEYE} cmccwp config ${cmdargs}`
	if [ "$?" != "0" ]; then 
		afm_dialog_msg "${LANG_003:=ִ}: ${errmsg}"
	else
		afm_dialog_msg "${LANG_004:=ɹ}"
	fi
else
	for nameval in `${FLOWEYE} cmccwp stat`
	do
		name=`echo ${nameval} | cut -d'=' -f1`
		val=`echo ${nameval} | cut -d'=' -f2-`
		export CGI_${name}="${val}"
	done
fi

echo -n "
<body>
<br><br>
<form method=post onsubmit=\"return beforeCommit(this)\" action=\"${myself}\">
<table width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=20></td>
	<td width=120 align=left>${LANG_011:=WebPortalӿ}</td>
	<td width=120 align=left>
		<select name=enable value=${CGI_enable} style=\"width:100%\">
		"; if [ ${CGI_enable} -eq 0 ]; then 
echo -n "
			<option value=1>${LANG_005:=}</option>
			<option value=0 selected>${LANG_006:=}</option>
		"; else 
echo -n "
			<option value=1 selected>${LANG_005:=}</option>
			<option value=0>${LANG_006:=}</option>
		"; fi 
echo -n "
		</select>
	</td>
	<td width=*></td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left>${LANG_007:=֤}</td>
	<td align=left>
                <select name=radsvrid style=\"width:120\" value=\"${CGI_radsvrid}\">
                ";
                        ${FLOWEYE} radsvr list | while read id ip name theothers
                        do
                                if [ "${CGI_radsvrid}" = "${id}" ]; then
                                        echo "<option value=${id} selected>${name}</option>"
                                else
                                        echo "<option value=${id}>${name}</option>"
                                fi
                        done
                
echo -n "
                </select>
	</td>
	<td></td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left>${LANG_009:=֤ȴʱ}</td>
	<td align=left><input type=text name=ttl style=\"width:120\" value=\"${CGI_ttl}\" /></td>
	<td>(${LANG_010:=룬ʱûӦԶͷԴ})</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=submit style=\"width:80\" value=\"${LANG_008:=ύ}\"></input>
        </td>
</tr>
</table>
</form>
</body>
</html>
";