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

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function Validate(frm)
{
	frm.curpwd.value  = TrimAll(frm.curpwd.value);
	if (frm.curpwd.value == \"\")
	{
		alert(\"뵱ǰ\");
		frm.curpwd.select();
		return false;
	}
	if (confirm(\"ȷҪɾ־?\"))
		return true;
	else
		return false;
}
</script>
";
PASSWDFILE=${PGPATH}/admin/.htpasswd
if [ "${CGI_action}" = "clear" ]; then
	if [ ! -f ${PASSWDFILE} ]; then
		afm_dialog_msg "شϵͳļٻ!"
		afm_load_page 0 "${myself}"
		exit 0
	fi
	curpasswd=`cat ${PASSWDFILE} | grep "admin:" | cut -d':' -f2-`
	if [ "${curpasswd}" != "${CGI_curpwd}" ]; then
		afm_dialog_msg "Բ벻ԣȨ־!"
		afm_load_page 0 "${myself}"
		exit 0
	fi
	# waiting for 10 seconds for scheduler.
	echo "clear_log yes" >> ${EVENTFILE}
	touch ${DATAPATH}/config/clearlog
	echo "<br><p style=\"color:#0000ff\">ɾ־,Ҫ,Ժ......</p>"
	afm_load_page 10 "${myself}?action=afterclear"
	exit 0
fi
if [ "${CGI_action}" = "afterclear" ]; then
	if [ ! -e ${DATAPATH}/config/clearlog ]; then
		afm_dialog_msg "־Ѿɾ!"
	else
		afm_dialog_msg "ɾ־ʧ!"
	fi
fi

echo -n "
<body>
"; cgi_show_title "־-->־" 
echo -n "
<br>
<table width=\"76%\" border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<form method=post onsubmit=\"return Validate(this)\" action=\"${myself}\">
<tr id=row1>
	<td width=40></td>
	<td width=120 align=left>뵱ǰ</td>
	<td width=100 align=left>
		<input type=password class=text name=curpwd style=\"width:100\"></input>
	</td>
	<td align=right width=120px>
		<input type=submit style=\"width:100\" value=\"־\"></input>
		<input type=hidden name=action value=\"clear\"></input>
	</td>
	<td width=*></td>
</tr>
</table>
</form>
</table>
</center>
</body>
</html>
";