#!/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`"

echo -n "
<script language=\"javascript\">
function onAddPipe()
{
	window.location.href = \"/cgi-bin/Setup/pipe_add\";
}
function onDeletePipe(pname)
{
	if (confirm(\"ϵͳɾʹô˹ܵĹȷҪɾ˹ܵ?\")) 
		window.location.href = \"${myself}?action=delete&pname=\" + pname; 
}
</script>
";
if [ "${CGI_action}" = "delete" ]; then
	errmsg=`${FLOWEYE} policy rmvbwo ${CGI_pname}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ʧ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
	fi
fi

echo -n "
<body>
"; cgi_show_title "Զ->ͨ" 
echo -n "
<br>
<table width=800 border=0 cellspacing=1 cellpadding=1> 
<tr id=tblhdr height=22>
	<td width=180 align=center>ͨ</td>
	<td width=120 align=center>ͨ</td>
	<td width=150 align=center>ͨ·</td>
	<td width=150 align=center>ͨ(kb/s)</td>
	<td width=* align=center>
		<input type=button value=\"ͨ>>\" style=\"width:120px;height:21px\" onclick=\"onAddPipe()\"></input>
	</td>
</tr>
";
idname="row1"
${FLOWEYE} policy listbwo | while read pid bridge pname ptype pdir prate plog theothers
do
    echo "<tr id=${idname}>"
    echo "<td align=center>${pname}</td>"
    case "${ptype}" in
    "limit")
    	echo "<td align=center></td>"
        ;;
    "gurantee")
        echo "<td align=center>֤</td>"
        ;;
    "reserve")
	echo "<td align=center>Ԥ</td>"
        ;;
    esac
    if [ ${bridge} -eq 0 ]; then
        echo "<td align=center></td>"
    else
        if [ "${pdir}" = "in" ]; then
            echo "<td align=center>${bridge}-></td>"
	else
            echo "<td align=center>${bridge}-></td>"
        fi
    fi 
    echo "<td align=center>${prate}</td>"
    echo "<td align=center><a style=\"color:#0000ff\" href=\"/cgi-bin/Setup/pipe_edit?pname=${pname}&bridge=${bridge}&ptype=${ptype}&pdir=${pdir}&prate=${prate}&plog=${plog}\">༭</a>&nbsp;&nbsp;&nbsp;<a style=\"color:#0000ff\" href=\"javascript:onDeletePipe('${pname}')\">ɾ</a></td>"
    echo "</tr>"
    if [ "${idname}" = "row1" ]; then
        idname="row2"
    else
        idname="row1"
    fi
done
echo "</table>"

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