#!/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 ""; 
. ../common/common.sh
myself="/cgi-bin/Maintain/`basename $0`"

echo -n "
<script languate=\"javascript\">
function Validate(frm)
{
	var dbfile = document.getElementsByName(\"sigdbfile\")[0];
	if (confirm(\"ȷҪϴ½?\"))
		return true;
	else
		return false;
}
</script>
";
fontsz=13
APPWEBDIR="/usr/appweb"
if [ "${CGI_action}" = "upload" ]; then
	operator_check "${myself}"
	# verify the archive
	fileok=`tar ztvf ${CGI_sigdbfile} | grep "appweb/bin/appwebs"`
	if [ "${fileok}" = "" ]; then
		afm_dialog_msg "ϴļʽ!"
		afm_load_page 0 "${myself}"
		exit 0
	fi
	# Stop appweb
	errmsg=`killall appwebs 2>&1`
	sleep 1
	echo "<br><b><p style=\"color:#0000ff;font:${fontsz}\">ʼ.....</p></b></br>"
	mkdir -p ${APPWEBDIR}
	errmsg=`tar xzvf ${CGI_sigdbfile} -C ${APPWEBDIR} 2>&1`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ѹ·ʱ⣬ϵȷϵͳȷ!"
		rm -rf ${CGI_sigdbfile}
		afm_load_page 0 "${myself}"
		sync
		exit 0
	else
		errmsg=`mv ${APPWEBDIR}/*.so* /usr/lib/ 2>&1`
		rm -rf ${CGI_sigdbfile}
		sync
	fi
	# start appwebs service
	mkdir -p /usr/ramdisk/tmp
	${APPWEBDIR}/appweb/bin/appwebs --config ${APPWEBDIR}/appweb/appweb.conf &
	echo "<br><b><p style=\"color:#0000ff;font:${fontsz}\">ɹ,Ϊȷ飬ʹIE7ʹ½!</p></b></br>"
	. ${PGETC}/ifadmin.conf
	afm_dialog_msg "½ʹ80˿ڣʹhttp://${ADMIN_IP}!"
	afm_load_page 0 "${myself}"
	exit 0
fi

echo -n "
<body>
"; 
cgi_show_title "ϵͳ->½"
[ -f ${PGPATH}/etc/panabit.inf ] && . ${PGPATH}/etc/panabit.inf
if [ ${JOS_RELEASE} -ne 0 ]; then
	for nameval in `${FLOWEYE} key info`; do
		eval "${nameval}"
	done
else 
	cantupgrade=0
fi
if [ "${cantupgrade}" = "1" ]; then
	echo "<br><p style=\"color:#ff0000;font-size:15px\">ЧޣϵһȡLicense!</p></br>"
	exit 0
fi

echo -n "
<br>
<table style=\"width:750; font-size:14px;font-bold:true; color:#ff0000\">
<tr>
	<td width=20></td>
	<td ><b>ע: ½ʶ˿Ϊ80˿!!!</b></td>
</tr>
</table>
<br>
<form method=post onsubmit=\"return Validate(this)\" action=\"${myself}\" enctype=\"multipart/form-data\">
<table width=750 border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr height=22>
	<td width=20></td>
	<td width=140 style=\"font-size:14px;font-bold:true;\" align=left>½·</td>
	<td width=* class=cssTDArial align=left>
		<input type=file name=sigdbfile style=\"width:480px\">
	</td>
	<td align=right>
		<input type=hidden name=action value=upload></input>
		<input type=submit style=\"width:100\" value=\"½\"></input>
	</td>
</tr>
</table>
</form>
</body>
</html>
";