#!/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`"
MOD_TAB_LIST="ӭҳ#/cgi-bin/Pppoe/notify_welcome #/cgi-bin/Pppoe/notify_time ʾ#/cgi-bin/Pppoe/notify_expire"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function beforeCommit(frm)
{
	var welcome = document.getElementsByName(\"welcomemsg\")[0];
	var expired = document.getElementsByName(\"expiredmsg\")[0];
	var intime  = document.getElementsByName(\"intimemsg\")[0];
	if (welcome.value == \"\") {
		alert(\"ҳ治Ϊ!\");
		welcome.select();
	}
	if (expired.value == \"\") {
		alert(\"ҳ治Ϊ!\");
		expired.select();
	}
	if (intime.value == \"\") {
		alert(\"ҳ治Ϊ!\");
		intime.select();
	}
	
	return true;
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	echo "${CGI_welcomemsg}" > ${PGETC}/pppoe_welcome.html
	echo "${CGI_expiredmsg}" > ${PGETC}/pppoe_expired.html
	echo "${CGI_intimemsg}"  > ${PGETC}/pppoe_intime.html
	cmdstrs="${cmdstrs} welcome_enable=${CGI_welcome_enable}"
	cmdstrs="${cmdstrs} intime_enable=${CGI_intime_enable}"
	cmdstrs="${cmdstrs} intime_days=${CGI_intime_days}"
	cmdstrs="${cmdstrs} intime_hours=${CGI_intime_hours}"
	cmdstrs="${cmdstrs} loadmsg=1"
	
	errmsg=`${FLOWEYE} pppoesvr config ${cmdstrs}`
	[ "$?" != "0" ] && afm_dialog_msg "ʧ:${errmsg}"
fi
CGI_expiredmsg=`${FLOWEYE} pppoesvr config showexpiredmsg=1`
CGI_welcomemsg=`${FLOWEYE} pppoesvr config showwelcomemsg=1`
CGI_intimemsg=`${FLOWEYE}  pppoesvr config showintimemsg=1`
for nameval in `${FLOWEYE} pppoesvr stat`
do
	eval "CGI_${nameval}"
done

echo -n "
<body>
"; cgi_show_title "PPPOE->ҳ֪ͨ" 
echo -n "
<br>
<form method=post onsubmit=\"return beforeCommit(this)\" action=\"${myself}\">
<table style=\"width:800; font-bold:true; font-size:14px; color:#CE6C04\">
<tr>
        <td align=left><b>¼ӭҳ</b></td>
	<td width=* align=right>
		<select name=welcome_enable value=\"${CGI_welcome_enable}\" style=\"width:80\">
		";
			if [ "${CGI_welcome_enable}" = "1" ]; then
				echo "<option value=0></option>"
				echo "<option value=1 selected></option>"
			else
				echo "<option value=0 selected></option>"
				echo "<option value=1></option>"
			fi
		
echo -n "
		</select>
	</td>
</tr>
</table>
<table width=800 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=* align=left><textarea name=welcomemsg rows=9 style=\"width:800\">${CGI_welcomemsg}</textarea></td>
</tr>
</table>
<br>
<table style=\"width:800; font-bold:true; font-size:14px; color:#CE6C04\">
<tr>
        <td align=left><b>ҳ</b></td>
	<td width=* align=right>
		ǰ<input type=text name=intime_days value=\"${CGI_intime_days}\" style=\"width:50\"></input>&nbsp;&nbsp;
		ÿ<input type=text name=intime_hours value=\"${CGI_intime_hours}\" style=\"width:50\"></input>Сʱһ&nbsp;&nbsp;
		<select name=intime_enable value=\"${CGI_intime_enable}\" style=\"width:80\">
		";
			if [ "${CGI_intime_enable}" = "1" ]; then
				echo "<option value=0></option>"
				echo "<option value=1 selected></option>"
			else
				echo "<option value=0 selected></option>"
				echo "<option value=1></option>"
			fi
		
echo -n "
		</select>
	</td>
</tr>
</table>
<table width=800 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=* align=left><textarea name=intimemsg rows=9 style=\"width:800\">${CGI_intimemsg}</textarea></td>
</tr>
</table>
<br>
<table style=\"width:800; font-bold:true; font-size:14px; color:#CE6C04\">
<tr>
        <td align=left><b>ʾҳ</b></td>
</tr>
</table>
<table width=800 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=* align=left><textarea name=expiredmsg rows=9 style=\"width:800\">${CGI_expiredmsg}</textarea></td>
</tr>
</table>
<br>
<table style=\"width:800\"> 
<tr>
        <td align=right>
		<input type=submit style=\"width:80\" value=\"ύ\" />
	</td>
</tr>
</table>
</form>
</body>
</html>
";