#!/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 "<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">
<head><title></title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">
<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">
<META HTTP-EQUIV=\"Cache-Control\" content=\"no-cache\">
</head><body>
";
FLOWEYE=/usr/ramdisk/bin/floweye
case "${CGI_cmd}" in
"1")
	if [ "${CGI_state}" != "0" -a "${CGI_state}" != "1" ]; then
		echo "INVSTATE"
	else
		if [ "${CGI_state}" = "0" ]; then
			errmsg=`${FLOWEYE} usrauth config yunnan_dropall=1`
		else
			errmsg=`${FLOWEYE} usrauth config yunnan_dropall=0`
		fi
		if [ "$?" != "0" ]; then
			echo "${errmsg}"
		else
			echo "SUCCESS"
		fi
	fi
	;;
"2")
	if [ "${CGI_ip}" != "" -a "${CGI_state}" != "" ]; then
		errmsg=`${FLOWEYE} usrinfo login name="[_*YUNNAN*_]" passwd=${CGI_state} loginip=${CGI_ip}`
		if [ "$?" != "0" ]; then
			echo "${errmsg}"
		else
			echo "SUCCESS"
		fi
	else
		echo "INVALIDARG"
	fi
	;;
"3")
	if [ "${CGI_url}" != "" -a "${CGI_state}" != "" ]; then
		if [ "${CGI_state}" = "0" ]; then
			errmsg=`${FLOWEYE} dns add -1 ${CGI_url}`
		else
			errmsg=`${FLOWEYE} dns remove -1 ${CGI_url}`
		fi
		if [ "$?" != "0" ]; then
			echo "${errmsg}"
		else
			echo "SUCCESS"
		fi
	else
		echo "INVALIDARG"
	fi
	;;
*)
	echo "INVCMD"
	;;
	
esac

echo -n "
</body>
</html>
";