#!/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 beforeCommit(frm)
{
	var syslogsvrip = document.getElementsByName(\"logip\")[0];
	var syslogsvrport = document.getElementsByName(\"logport\")[0];
	syslogsvrip.value = TrimAll(syslogsvrip.value);
	if (syslogsvrip.value != \"\" && !IsIPAddr(syslogsvrip.value)) {
		alert(\"ȷIPַ!\");
		syslogsvrip.select();
		return false;
	}
	syslogsvrport.value = TrimAll(syslogsvrport.value);
	if (svrport.value == \"\" && !IsDigitIn(syslogsvrport.value, 1, 65535)) {
		alert(\"Ķ˿ں!\");
		syslogsvrport.select();
		return false;
	}
	
	return true;
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}"
	cfgstr="event=url"
	cfgstr="${cfgstr} logtype=${CGI_logtype} logip=${CGI_logip} logport=${CGI_logport}"
	[ "${CGI_url_once}" != "" ] && cfgstr="${cfgstr} url_once=${CGI_url_once}"
	cfgstr="${cfgstr} url_exttype=${CGI_url_exttype}"
	errmsg=`${FLOWEYE} logger config ${cfgstr}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_load_page 0 "${myself}"
		exit 0
	fi
fi
for nameval in `${FLOWEYE} logger stat event=url`
do
	eval "CGI_${nameval}"
done

echo -n "
<body>
"; cgi_show_title "־->URL־" 
echo -n "
<br>
<table style=\"width:600; border-bottom:1px #787882 solid; font-bold:true;font-size:14px;\">
<tr>
	<td style=\"font:14px\"><b>ǰͳϢ</b></td>
	<td style=\"font:12px;\" align=right width=\"*\"></td>
</tr>
</table>
<br>
<table width=600 border=0 cellspacing=2 cellpadding=1 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=40></td>
	<td width=120 align=left>¼</td>
	<td width=* align=left>${CGI_written}/${CGI_dropped}(ɹ/ʧ)</td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left>¼</td>
	<td width=* align=left>${CGI_sentok}/${CGI_sentfail}(ɹ/ʧ)</td>
</tr>
<tr id=row1>
	<td></td>
	<td align=left>Եļ¼</td>
	<td align=left>${CGI_url_ignore}</td>
</tr>
</table>
<br>
<table style=\"width:600; border-bottom:1px #787882 solid; font-bold:true;font-size:14px;\">
<tr>
	<td style=\"font:14px\"><b>ǰϢ</b></td>
	<td style=\"font:12px;\" align=right width=\"*\"></td>
</tr>
</table>
<br>
<form method=post onsubmit=\"return beforeCommit(this)\" action=\"${myself}\">
<table width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
        <td width=40></td>
        <td align=left width=120>շIP</td>
        <td align=left width=*><input type=text name=logip value=\"${CGI_logip}\" style=\"width:120\" />&nbsp;(xxx.xxx.xxx.xxx)</td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left width=120>շ˿</td>
        <td align=left width=*><input type=text name=logport value=\"${CGI_logport}\" style=\"width:60\" />&nbsp;(1~65535)</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>Ƿ¼־</td>
        <td align=left width=*>
		<select name=logtype value=\"${CGI_logtype}\" style=\"width:120px\"> 
		"; if [ "${CGI_logtype}" = "none" ]; then 
echo -n "
			<option value=\"none\" selected>¼</option>
			<option value=\"syslog\">¼</option>
		"; else 
echo -n "
			<option value=\"none\">¼</option>
			<option value=\"syslog\" selected>¼</option>
		"; fi 
echo -n "
		</select>
	</td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left width=120></td>
        <td align=left width=*><input type=text name=url_once value=\"${CGI_url_once}\" style=\"width:120\" />&nbsp;(100~10000)</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>ļ</td>
        <td align=left width=*>
		<select name=url_exttype style=\"width:120\">
		"; if [ "${CGI_url_exttype}" = "0" ]; then 
echo -n "
                	<option value=0 selected></option>
		"; else 
echo -n "
                	<option value=0></option>
		"; fi 
echo -n "
        ";
                ${FLOWEYE} urlfilter listext | while read id name theothers
                do
			if [ "${id}" = "${CGI_url_exttype}" ]; then
                        	echo "<option value=${id} selected>${name}</option>"
			else
                        	echo "<option value=${id}>${name}</option>"
			fi
                done
        
echo -n "
        </select></td>
</tr>
</table>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#0000ff\">
<tr><td align=right>&nbsp;</td></tr>
</table>
<table style=\"width:600\"> 
<tr><td align=right><input type=submit style=\"width:80\" value=\"ύ\"></input></td></tr>
</table>
</form>
</body>
</html>
";