#!/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/Route/`basename $0`"

echo -n "
<script language=\"javascript\">
function onAddIflan()
{
	window.location.href = \"/cgi-bin/Route/iflan_add\";
}
function onDeleteIflan(name)
{
	if (confirm(\"ϵͳɾʹӿص·ɲԣȷҪɾ?\"))
		window.location.href = \"${myself}?action=delete&proxyname=\" + name; 
}
</script>
";
if [ "${CGI_action}" = "delete" ]; then
	operator_check "${myself}"
	errmsg=`${FLOWEYE} nat rmvproxy ${CGI_proxyname}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ʧ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
	fi
fi

echo -n "
<body>
"; cgi_show_title "->LANӿ" 
echo -n "
<br>
<table width=1080 border=0 cellspacing=1 cellpadding=1> 
<tr id=tblhdr>
	<td width=130 align=center>ӿ</td>
	<td width=100 align=center></td>
	<td width=100 align=center>״̬</td>
	<td width=120 align=center>IPַ</td>
	<td width=120 align=center></td>
	<td width=120 align=center>VLAN</td>
	<td width=120 align=center>MTU</td>
	<td width=* align=center><a style=\"color:#0000ff\" href=\"javascript:onAddIflan()\">ӽӿ>></a></td>
</tr>
";
idname="row1"
${FLOWEYE} nat listproxy type=routerif | while read type id name state ifname addr netmask vlan mtu theothers
do
    echo "<tr id=${idname} height=22>"
    echo "<td align=center>${name}</td>"
    echo "<td align=center>${ifname}</td>"
    if [ ${state} -eq 1 ]; then
	echo "<td align=center style=\"color:#00ff00\"></td>"
    else
	echo "<td align=center style=\"color:#ff0000\">ͨ</td>"
    fi
    echo "<td align=center>${addr}</td>"
    echo "<td align=center>${netmask}</td>"
    [ "${vlan}" = "0" ] && vlan=""
    echo "<td align=center>${vlan}</td>"
    echo "<td align=center>${mtu}</td>"
    echo "<td align=center><a style=\"color:#0000ff\" href=\"/cgi-bin/Route/iflan_edit?iflanname=${name}\">༭</a>&nbsp;&nbsp;&nbsp;<a style=\"color:#0000ff\" href=\"javascript:onDeleteIflan('${name}')\">ɾ</a></td>"
    echo "</tr>"
    if [ "${idname}" = "row1" ]; then
        idname="row2"
    else
        idname="row1"
    fi
done
echo "</table>"

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