#!/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/Setup/`basename $0`"
if [ "${REQUEST_METHOD}" != "POST" ]; then
	for nameval in `${FLOWEYE} policy getrule group=${CGI_group} id=${CGI_polno}`
	do
		eval "CGI_${nameval}"
	done
fi

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
";
echo "var actionlist = ["
${FLOWEYE} policy listbwo | while read id name theoterhs
do
	[ "${id}" = "id" ] && continue
        echo "[ \"0\", \"both\", \"limit\", \"${name}\", \"${name}\" ],"
done
${FLOWEYE} nat listproxy type=proxy.pppoe | while read type id name ifname addr gateway
do
        echo "[ \"0\", \"both\", \"proxy\", \"${name}\", \"${name}\" ],"
        echo "[ \"0\", \"both\", \"route\", \"${name}\", \"${name}\" ],"
done
if [ ${JOS_RELEASE} -ne 0 ]; then
        ${FLOWEYE} if list | while read ifname theothers
        do
                echo "[ \"0\", \"both\", \"dup\", \"${ifname}\", \"${ifname}\" ],"
        done
fi
echo "[ \"NULL\", \"NULL\", \"NULL\", \"NULL\", \"NULL\" ]"
echo " ]; "

echo -n "
function beforeAddRule(frm)
{
	var rngs;
	var polno   = document.getElementsByName(\"polno\")[0];
	var iprate  = document.getElementsByName(\"iprate\")[0];
	var intype  = document.getElementsByName(\"intype\")[0];
	var outtype = document.getElementsByName(\"outtype\")[0];
	var inipnet = document.getElementsByName(\"inipnet\")[0];
	var iniprng = document.getElementsByName(\"iniprng\")[0];
	var outipnet= document.getElementsByName(\"outipnet\")[0];
	var outiprng= document.getElementsByName(\"outiprng\")[0];
	var tos     = document.getElementsByName(\"tos\")[0];
	var pri     = document.getElementsByName(\"priority\")[0];
        var inport  = document.getElementsByName(\"inport\")[0];
        var outport = document.getelementsByName(\"outport\")[0];
	polno.value = TrimAll(polno.value);
	if (!IsDigitIn(polno.value, 1, 65535)) {
		alert(\"űǽ165535֮һ!\");
		polno.select();
		return false;
	}
	inipnet.value = TrimAll(inipnet.value);
	iniprng.value = TrimAll(iniprng.value);
	if (intype.value == \"net\") {
		if (!IsIPAddr(inipnet.value)) {
			alert(\"ȷIPַʽΪx.x.x.x/n\");
			inipnet.select();
			return false;
		}
	}
	else
	if (intype.value == \"range\") {
		rngs = iniprng.value.split(\"-\");
		if (rngs.length != 2 || !IsIPAddr(rngs[0]) || !IsIPAddr(rngs[1])) {
			alert(\"ȷIPΣʽΪx.x.x.x-y.y.y.y\");
			iniprng.select();
			return false;
		}
	}
        inport.value = TrimAll(inport.value);
        if (inport.value == \"\") inport.value = \"0\";
        rngs = inport.value.split(\"-\");
        if (rngs.length == 2) {
                if (!IsDigitIn(rngs[0], 0, 65535) || !IsDigitIn(rngs[1], 0, 65535)) {
                        alert(\"˿!\");
                        inport.select();
                        return false;
                }
        }
        else {
                if (!IsDigitIn(inport.value, 0, 65535)) {
                        alert(\"˿!\");
                        inport.select();
                        return false;
                }
        }
	outipnet.value = TrimAll(outipnet.value);
	outiprng.value = TrimAll(outiprng.value);
	if (outtype.value == \"net\") {
		if (!IsIPAddr(outipnet.value)) {
			alert(\"ȷIPַʽΪx.x.x.x/n\");
			outipnet.select();
			return false;
		}
	}
	else
	if (outtype.value == \"range\") {
		rngs = outiprng.value.split(\"-\");
		if (rngs.length != 2 || !IsIPAddr(rngs[0]) || !IsIPAddr(rngs[1])) {
			alert(\"ȷIPΣʽΪx.x.x.x-y.y.y.y\");
			outiprng.select();
			return false;
		}
	}
        outport.value = TrimAll(outport.value);
        if (outport.value == \"\") outport.value = \"0\";
        rngs = outport.value.split(\"-\");
        if (rngs.length == 2) {
                if (!IsDigitIn(rngs[0], 0, 65535) || !IsDigitIn(rngs[1], 0, 65535)) {
                        alert(\"˿!\");
                        outport.select();
                        return false;
                }
        }
        else {
                if (!IsDigitIn(outport.value, 0, 65535)) {
                        alert(\"˿!\");
                        outport.select();
                        return false;
                }
        }
		
	iprate.value = TrimAll(iprate.value);
	if (iprate.value == \"\")
		iprate.value = \"0\";
	tos.value = TrimAll(tos.value);
	if (tos.value == \"\") tos.value = \"0\";
	if (!IsDigitIn(tos.value, 0, 63)) {
		alert(\"0~63!\");
		tos.select();
		return false;
	}
	pri.value = TrimAll(pri.value);
	if (pri.value == \"\") pri.value = \"0\";
	if (!IsDigitIn(pri.value, 0, ${MAXPRI})) {
		alert(\"0~${MAXPRI}!\");
		pri.select();
		return false;
	}
	
	return true;
}
function OnCancel(polgrpid)
{
	"; if [ "${CGI_policystat}" != "" ]; then 
echo -n "
		window.location.href = \"/cgi-bin/Monitor/policy_stat\";
	"; else 
echo -n "
		window.location.href = \"/cgi-bin/Setup/policy_getgrp?policy=\" + polgrpid;
	"; fi 
echo -n "
}
function onDirChanged(obj, value)
{
        var action = document.getElementsByName(\"action\")[0];
	if (value == \"NULL\") value = action.value;
        action.options.length = 0;
        opt = document.createElement(\"option\");
        opt.value = \"permit\";
        opt.text  = \"\";
        action.options.add(opt);
        opt = document.createElement(\"option\");
        opt.value = \"deny\";
        opt.text  = \"\";
        action.options.add(opt);
        for (var i = 0; i < actionlist.length; i++) {
                if (actionlist[i][0] == \"NULL\")
                        break;
                if (actionlist[i][2] == \"proxy\") {
                        if (obj.value == \"out\") {
                                opt = document.createElement(\"option\");
                                opt.value = \"PROXY-\" + actionlist[i][3];
                                opt.text  = \"PROXY->\" + actionlist[i][4];
                                action.options.add(opt);
                        }
                }
		else
                if (actionlist[i][2] == \"route\") {
                        if (obj.value == \"out\") {
                                opt = document.createElement(\"option\");
                                opt.value = \"ROUTE-\" + actionlist[i][3];
                                opt.text  = \"ת->\" + actionlist[i][4];
                                action.options.add(opt);
                        }
                }
		else
                if (actionlist[i][2] == \"dup\") {
			opt = document.createElement(\"option\");
			opt.value = \"DUP-\" + actionlist[i][3];
			opt.text  = \"ݾ->\" + actionlist[i][4];
			action.options.add(opt);
                }
                else {
                        opt = document.createElement(\"option\");
                        opt.value = actionlist[i][3];
                        opt.text  = actionlist[i][4];
                        action.options.add(opt);
                }
        }
       	for (i = 0; i < action.options.length; i++) {
               	if (action.options[i].value == value) {
                       	action.selectedIndex = i;
                       	break;
               	}
	}
        if (action.selectedIndex < 0)
                action.selectedIndex = 0;
}
function onIntypeChanged(obj)
{
	var net = document.getElementsByName(\"inipnet\")[0];
	var rng = document.getElementsByName(\"iniprng\")[0];
	var tbl = document.getElementsByName(\"iniptbl\")[0];
	net.style.display = \"none\";
	rng.style.display = \"none\";
	tbl.style.display = \"none\";
	if (obj.value == \"net\") 
		net.style.display = \"block\";
	else
	if (obj.value == \"range\") 
		rng.style.display = \"block\";
	else
	if (obj.value == \"table\") 
		tbl.style.display = \"block\";
}
function onOuttypeChanged(obj)
{
	var net = document.getElementsByName(\"outipnet\")[0];
	var rng = document.getElementsByName(\"outiprng\")[0];
	var tbl = document.getElementsByName(\"outiptbl\")[0];
	net.style.display = \"none\";
	rng.style.display = \"none\";
	tbl.style.display = \"none\";
	if (obj.value == \"net\") 
		net.style.display = \"block\";
	else
	if (obj.value == \"range\") 
		rng.style.display = \"block\";
	else
	if (obj.value == \"table\") 
		tbl.style.display = \"block\";
}
function onActionChanged(obj)
{
	var nextact = document.getElementsByName(\"matchact\")[0];
	var iprate  = document.getElementsByName(\"iprate\")[0];
	var dscp = document.getElementsByName(\"tos\")[0];
	var priority = document.getElementsByName(\"priority\")[0];
        if (obj.value == \"deny\") {
                nextact.disabled = true;
                iprate.disabled  = true;
                dscp.disabled = true;
                priority.disabled = true;
        }
        else
        if (obj.value == \"permit\") {
                nextact.disabled = false;
                iprate.disabled  = false;
                dscp.disabled = false;
                priority.disabled = true;
        }
        else {
                var actions = obj.value.split(\"-\");
                if (actions.length >= 2 &&
                   (actions[0] == \"PROXY\" || 
		    actions[0] == \"DUP\" || actions[0] == \"ROUTE\")) {
                        nextact.disabled = false;
                        iprate.disabled  = false;
                        dscp.disabled = false;
                        priority.disabled = true;
                }
                else {
                        nextact.disabled = false;
                        iprate.disabled  = false;
                        dscp.disabled = false;
                        priority.disabled = false;
                }
        }
	var josrel = \"${JOS_RELEASE}\";
	if (josrel == \"0\") {
		dscp.disabled = true;
	}
}
function selectApp(appid)
{
	var ar;
	var url;
	var retval;
	var appid;
	var appname;
	
	url = \"/cgi-bin/Setup/app_select\";
	retval = ShowDialog(url, \"\", 400, 600);
	if (retval == \"NONE\") return;
	ar = retval.split(\",\");
	if (ar.length != 2) {
		alert(\"Чķֵ\");
		return;
	}
	appid = document.getElementsByName(\"appid\")[0];
	appname = document.getElementsByName(\"appname\")[0];
	appid.value = ar[0];
	appname.value = ar[1];
}
function onLoad()
{
	var dir = document.getElementsByName(\"dir\")[0];
	var action = document.getElementsByName(\"action\")[0];
	onDirChanged(dir, \"${CGI_action}\");
	onActionChanged(action);
}
</script>
";
if [ "${REQUEST_METHOD}" = "POST" ]; then
	operator_check "${myself}?group=${CGI_policy}&polno=${CGI_polno}"
	case "${CGI_intype}" in
	"any")
		CGI_inip="any"
		;;
	"net")
		CGI_inip="${CGI_inipnet}"
		;;
	"range")
		CGI_inip="${CGI_iniprng}"
		;;
	"table")
		CGI_inip="${CGI_iniptbl}"
		;;
	esac
        if [ "${CGI_inport}" != "" -a "${CGI_inport}" != "0" ]; then
                CGI_inip="${CGI_inip}:${CGI_inport}"
        fi
	case "${CGI_outtype}" in
	"any")
		CGI_outip="any"
		;;
	"net")
		CGI_outip="${CGI_outipnet}"
		;;
	"range")
		CGI_outip="${CGI_outiprng}"
		;;
	"table")
		CGI_outip="${CGI_outiptbl}"
		;;
	esac
        if [ "${CGI_outport}" != "" -a "${CGI_outport}" != "0" ]; then
                CGI_outip="${CGI_outip}:${CGI_outport}"
        fi
	case "${CGI_matchact}" in
	"next")
		CGI_next="1"
		;;
	"stop")
		CGI_next="0"
		;;
	"")
		CGI_next="0"
		;;
	esac
	[ "${CGI_natip}" = "" ] && CGI_natip="0"
	[ "${CGI_tos}" = "" ] && CGI_tos="0"
	[ "${CGI_priority}" = "" ] && CGI_priority="0"
	[ "${CGI_iprate}" = "" ] && CGI_iprate="0"
	[ "${CGI_bridge}" = "" ] && CGI_bridge="any"
	[ "${CGI_hasms}" = "" ] && CGI_hasms="0"
	if [ "${CGI_proto}" != "any" ]; then
                theapid="${CGI_appid}.${CGI_proto}"
        else
                theapid="${CGI_appid}"
        fi
	errmsg=`${FLOWEYE} policy setrule group=${CGI_group} id=${CGI_polno} bridge=${CGI_bridge} dir=${CGI_dir} \
app=${theapid} inip=${CGI_inip} outip=${CGI_outip} action=${CGI_action} iprate=${CGI_iprate} next=${CGI_next} \
tos=${CGI_tos} pri=${CGI_priority} natip=${CGI_natip} hasms=${CGI_hasms}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		WEB_LOGGER "޸" "group=${CGI_group},id=${CGI_polno}"
		if [ "${CGI_policystat}" != "" ]; then
			afm_load_page 0 "/cgi-bin/Monitor/policy_stat"
		else
			afm_load_page 0 "/cgi-bin/Setup/policy_getgrp?policy=${CGI_group}"
		fi
		exit 0
	fi
fi

echo -n "
<body onload=\"onLoad()\">
<script type=\"text/javascript\" src=\"/img/wz_tooltip.js\"></script>
<span id=\"hlpdir\" style=\"display:none\">\"\"ʾ,\"\"ʾ</span>
<span id=\"hlprate\" style=\"display:none\">IPֻIPЧ,0ʾ,һΧֵ10-100</span>
<span id=\"hlpnext\" style=\"display:none\">\"ƥ\"ʾһƥƥĲ<br>\"ֹͣƥ\"ʾƥĲ<br>Ϊ\"\"ʱѡЧ</span>
<span id=\"hlptos\" style=\"display:none\">DSCPʱֻӵĵһƥ䣬ӺİDSCPֵ͵һһ</span>
<span id=\"hlppri\" style=\"display:none\">ԽСȼԽ;0ʾŶֱͨ</span>
<span id=\"hlpnatip\" style=\"display:none\">ͨIPСû0ʾ,Ϊ255</span>
"; 
grpname=`${FLOWEYE} policy listgrp | grep "^${CGI_group} " | cut -d' ' -f2`
cgi_show_title "-><b style=\"color:#ff0000\">${grpname}</b>->޸Ĳ" 
tblexists=`${FLOWEYE} table list`

echo -n "
<br>
<form method=post onsubmit=\"return beforeAddRule(this)\" action=\"${myself}\">
<table width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=70></td>
        <td width=120 align=left>Աʶ</td>
	<td width=130 align=left><b>${grpname}->${CGI_polno}</b><input type=hidden name=polno value=\"${CGI_polno}\"></input></td>
	<td width=* align=left></td>
</tr>
</table>
<br>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#000000\">
<tr><td align=left style=\"font-size:11px\"><b>ƥ</b></td></tr>
</table>
<br>
<table width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
        <td width=70></td>
        <td width=120 align=left>·</td>
        <td width=130 align=left>
                <select name=bridge style=\"width:130\" value=\"${CGI_bridge}\">
                "; if [ "${CGI_bridge}" = "any" ]; then 
echo -n "
                        <option value=any selected></option>
                "; else 
echo -n "
                        <option value=any></option>
                "; fi 
echo -n "
                "; for link in `${FLOWEYE} policy listlink | awk '{print $1}'`
                    do
                        if [ "${link}" = "${CGI_bridge}" ]; then
                                echo "<option value=\"${link}\" selected>${link}</option>"
                        else
                                echo "<option value=\"${link}\">${link}</option>"
                        fi
                    done 
		    ${FLOWEYE} nat listwg | while read id name theothers
		    do
			if [ "${CGI_bridge}" = "_wg.${name}" ]; then
				echo "<option value=\"_wg.${name}\" selected>${name}</option>"
			else
				echo "<option value=\"_wg.${name}\">${name}</option>"
			fi
		    done 
echo -n "
                </select>
        </td>
        <td width=* align=left></td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left></td>
        <td align=left>
                <select name=dir style=\"width:130\" value=\"${CGI_dir}\" onchange=\"javascript:onDirChanged(this, 'NULL')\">
                "; if [ "${CGI_dir}" = "both" ]; then 
echo -n "
                <option value=\"both\" selected></option>
                "; else 
echo -n "
                <option value=\"both\"></option>
                "; fi 
echo -n "
                "; if [ "${CGI_dir}" = "in" ]; then 
echo -n "
                <option value=\"in\" selected></option>
                "; else 
echo -n "
                <option value=\"in\"></option>
                "; fi 
echo -n "
                "; if [ "${CGI_dir}" = "out" ]; then 
echo -n "
                <option value=\"out\" selected></option>
                "; else 
echo -n "
                <option value=\"out\"></option>
                "; fi 
echo -n "
        </td>
        <td width=* align=left></td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>IP</td>
        <td align=left>
		<select name=intype style=\"width:130\" value=\"${CGI_intype}\" onchange=\"onIntypeChanged(this)\">
		"; cgi_show_iptype "${CGI_intype}" 
echo -n "
		</select>
	</td>
	<td width=* align=left>
	";
		rngdisplay="none"
		netdisplay="none"
		tbldisplay="none"
		case "${CGI_intype}" in
		"net")
			netdisplay="block"
			;;
		"iprange")
			rngdisplay="block"
			;;
		"table")
			tbldisplay="block"
			;;
		esac
		inipval="${CGI_inip}"
		[ "${CGI_inip}" = "any" ] && inipval=""
		echo "<input type=text name=inipnet value=\"${inipval}\" style=\"width:120px;display:${netdisplay}\"></input>"
		echo "<input type=text name=iniprng value=\"${inipval}\" style=\"width:160px;display:${rngdisplay}\"></input>"
		echo "<select name=iniptbl value=\"${inipval}\" style=\"width:120px;display:${tbldisplay}\">"
		${FLOWEYE} table list | while read tblid tblname
		do
			if [ "${CGI_inip}" = "${tblid}" -o "${CGI_inip}" = "${tblname}" ]; then
				echo "<option value=\"${tblid}\" selected>${tblname}</option>"
			else
				echo "<option value=\"${tblid}\">${tblname}</option>"
			fi
		done
		echo "</select>"
	
echo -n "
	
	</td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left>˿</td>
        <td><input type=text name=inport value=\"${CGI_inport}\" style=\"width:130\"></input></td>
        <td width=* align=left><a style=\"color:#0000ff\">808000-8100,0ʾ˿</a></td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>ַ</td>
        <td align=left>
		<select name=outtype style=\"width:130\" value=\"${CGI_outtype}\" onchange=\"onOuttypeChanged(this)\">
		"; cgi_show_iptype "${CGI_outtype}" 
echo -n "
		</select>
	</td>
	<td width=* align=left>
	";
		rngdisplay="none"
		netdisplay="none"
		tbldisplay="none"
		case "${CGI_outtype}" in
		"net")
			netdisplay="block"
			;;
		"iprange")
			rngdisplay="block"
			;;
		"table")
			tbldisplay="block"
			;;
		esac
		outipval="${CGI_outip}"
		[ "${CGI_outip}" = "any" ] && outipval=""
		echo "<input type=text name=outipnet value=\"${outipval}\" style=\"width:120px;display:${netdisplay}\"></input>"
		echo "<input type=text name=outiprng value=\"${outipval}\" style=\"width:160px;display:${rngdisplay}\"></input>"
		echo "<select name=outiptbl value=\"${outipval}\" style=\"width:120px;display:${tbldisplay}\">"
		${FLOWEYE} table list | while read tblid tblname
		do
			if [ "${CGI_outip}" = "${tblid}" -o "${CGI_outip}" = "${tblname}" ]; then
				echo "<option value=\"${tblid}\" selected>${tblname}</option>"
			else
				echo "<option value=\"${tblid}\">${tblname}</option>"
			fi
		done
		echo "</select>"
	
echo -n "
	</td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left>˿</td>
        <td><input type=text name=outport value=\"${CGI_outport}\" style=\"width:130\"></input></td>
        <td width=* align=left><a style=\"color:#0000ff\">808000-8100,0ʾ˿</a></td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left>Э</td>
        <td>
                <select name=proto value=\"${CGI_proto}\" style=\"width:130\">
                ";
                        case "${CGI_proto}" in
                        "tcp"|"TCP")
                                echo "<option value=any></option>"
                                echo "<option value=TCP selected>TCP</option>"
                                echo "<option value=UDP>UDP</option>"
                                ;;
                        "udp"|"UDP")
                                echo "<option value=any></option>"
                                echo "<option value=TCP>TCP</option>"
                                echo "<option value=UDP selected>UDP</option>"
                                ;;
                        *)
                                echo "<option value=any selected></option>"
                                echo "<option value=TCP>TCP</option>"
                                echo "<option value=UDP>UDP</option>"
                                ;;
                        esac
                
echo -n "
                </select>
        </td>
        <td width=* align=left></td>
</tr>
";
[ "${CGI_appid}" = "" ] && CGI_appid="any"
appname=`${FLOWEYE} app name ${CGI_appid}`

echo -n "
<tr id=row1>
	<td></td>
        <td align=left>ӦЭ</td>
        <td align=left>
		<input type=hidden name=appid value=\"${CGI_appid}\"></input>
		<input type=text name=appname value=\"${appname}\" disabled style=\"width:130\">
	</td>
	<td width=* class=cssTDArial align=left>
	  <input type=button name=tmp value=\"ѡЭ...\" style=\"width:100px\" onclick=\"selectApp('${CGI_appid}')\"></input>
	</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>û</td>
        <td><input type=text name=natip value=\"${CGI_natip}\" style=\"width:130\"></input></td>
	<td width=* align=left>
		<a style=\"color:#0000ff\" onmouseover=\"TagToTip('hlpnatip')\" onmouseout=\"UnTip()\">(,0~255)</a>
	</td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left>ƶ豸</td>
        <td><select name=hasms value=\"${CGI_hasms}\" style=\"width:130\">
	";
		if [ "${CGI_hasms}" = "0" ]; then
			echo "<option value=0 selected></option>"
			echo "<option value=1></option>"
		else
			echo "<option value=0></option>"
			echo "<option value=1 selected></option>"
		fi
	
echo -n "
	</select></td>
	<td width=* align=left><a style=\"color:#0000ff\">Ƿƶ豸ͨIP</a></td>
</tr>
</table>
</table>
<br>
<table style=\"width:600; border-bottom:1px #787882 solid; color:#000000\">
<tr><td align=left style=\"font-size:11px\"><b>ִж</b></td></tr>
</table>
<br>
<table width=600 border=0 cellspacing=0 cellpadding=3 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=70></td>
        <td width=120 align=left>ִж</td>
        <td width=130 align=left><select name=action value=${CGI_action} onchange=\"onActionChanged(this)\" style=\"width:130\"></td>
	<td width=* align=left></td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left>ȼ</td>
        <td><input type=text name=priority value=\"${CGI_priority}\" style=\"width:130\"></input></td> 
        <td width=* align=left>
                <a style=\"color:#0000ff\" onmouseover=\"TagToTip('hlppri')\" onmouseout=\"UnTip()\">[0~${MAXPRI}]</a>
        </td>
</tr>
"; [ "${CGI_iprate}" = "" ] && CGI_iprate="0" 
echo -n "
<tr id=row1>
	<td></td>
        <td align=left>IP</td>
        <td>";
		disabled=""
		[ "${CGI_action}" = "deny" ] && disabled="disabled" 
echo -n "
		<input type=text name=iprate ${disabled} value=\"${CGI_iprate}\" style=\"width:130\"></input>
	</td>
	<td width=* align=left><a style=\"color:#0000ff\" onmouseover=\"TagToTip('hlprate')\" onmouseout=\"UnTip()\">[kbits/s1010-100]</a></td>
</tr>
<tr id=row1>
        <td></td>
        <td align=left>DSCP</td>
        <td><input type=text name=tos value=\"${CGI_tos}\" style=\"width:130\"></input></td> 
        <td width=* align=left>
                <a style=\"color:#0000ff\" onmouseover=\"TagToTip('hlptos')\" onmouseout=\"UnTip()\">[0~63,0ʾ]</a>
        </td>
</tr>
<tr id=row1>
	<td></td>
        <td align=left></td>
        <td>";
		disabled=""
		[ "${CGI_action}" = "deny" ] && disabled="disabled" 
echo -n "
		<select name=matchact ${disabled} value=${CGI_matchact} style=\"width:130\">
		";
			if [ "${CGI_matchact}" = "stop" ]; then
				echo "<option value=stop selected>ֹͣƥ</option>"
				echo "<option value=next>ƥ</option>"
			else
				echo "<option value=stop>ֹͣƥ</option>"
				echo "<option value=next selected>ƥ</option>"
			fi
		
echo -n "
		</select>
	</td>
	<td width=* align=left>
		<a style=\"color:#0000ff\" onmouseover=\"TagToTip('hlpnext')\" onmouseout=\"UnTip()\">[]</a>
	</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 id=newbtn style=\"width:80\" value=\"ύ\"></input>
		<input type=button id=newbtn style=\"width:80\" value=\"ȡ\" onclick=\"OnCancel('${CGI_group}')\"></input>
		<input type=hidden name=policy value=\"${CGI_group}\"></input>
		<input type=hidden name=group value=\"${CGI_group}\"></input>
		<input type=hidden name=policystat value=\"${CGI_policystat}\"></input>
	</td>
</tr>
</table>
</form>
</body>
</html>
";