#!/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="IP location query"
	LANG_002="Query"
	LANG_003="Upgrade"
	LANG_004="IP library not installed"
	LANG_005="Please enter the path of upgrade package!"
	LANG_006="Error"
	LANG_007="Upgrade"
	LANG_008="Current library file version"
fi
CGI_browsertitle="${LANG_001:=IPλòѯ}"
. ../../common/common.sh
apppath="/cgi-bin/App/ipdb"
myself="${apppath}/`basename $0`"
MOD_TAB_LIST="${LANG_002:=IPѯ}#${apppath}/webmain ${LANG_003:=}#${apppath}/update"
curver=`${FLOWEYE} ipdb stat | grep "^version=" | cut -d'=' -f2`
[ "${curver}" = "NULL" ] && curver="${LANG_004:=IPδװ}"

echo -n "
<script languate=\"javascript\">
function Validate(frm)
{
	var dbfile = document.getElementsByName(\"cfgfile\")[0];
	if (dbfile.value == \"\") {
		alert(\"${LANG_005:=ļ·!}\");
		return false;
	}
	return true;
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	errmsg=`${FLOWEYE} ipdb load file=${CGI_cfgfile}`
	if [ "$?" = "0" ]; then
		mv ${CGI_cfgfile} ${PGETC}/ip.dat
		sync
		curver=`${FLOWEYE} ipdb stat | grep "^version=" | cut -d'=' -f2`
	else
		rm -rf ${CGI_cfgfile}
		afm_dialog_msg "${LANG_006:=}:${errmsg}"
	fi
fi

echo -n "
<body>
"; cgi_print_mod_header "${LANG_003:=}" "100%" 
echo -n "
<br>
<table width=\"100%\" border=0 cellspacing=1 cellpadding=3 style=\"font-size:13px;font-bold:true;\">
<tr>
    <td width=20></td>
    <td align=left>${LANG_008:=ǰļ汾}${curver}</td>
</tr>
</table>
<br>
<form method=post onsubmit=\"return Validate(this)\" action=\"${myself}\" enctype=\"multipart/form-data\">
<table width=100% border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr>
	<td width=20></td>
	<td width=* class=cssTDArial align=left>
		<input type=file name=cfgfile style=\"width:260\" />
		<input type=submit style=\"width:80\" value=\"${LANG_007:=}\" class=\"btns\"></input>
		<input type=hidden name=action value=upload></input>
	</td>
</tr>
</table>
</form>
</body>
</html>
";