#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html;charset=gb2312
Cache-Control: no-cache

"
echo -n ""; 
. ../common/common.sh 
[ "${CGI_refresh}" = "" ] && CGI_refresh=0
[ "${CGI_topn}" = "" ] && CGI_topn="20"
[ "${CGI_appid}" = "" ] && CGI_appid="http"
[ "${CGI_type}" = "" ] && CGI_type="inner"
[ "${CGI_statype}" = "" ] && CGI_statype="all"
[ "${CGI_bridge}" = "" ] && CGI_bridge="0"
cgipath="/cgi-bin/Monitor/`basename $0`"
cgiargs="refresh=${CGI_refresh}&statype=${CGI_statype}&appid=${CGI_appid}&topn=${CGI_topn}&appname=${CGI_appname}&bridge=${CGI_bridge}"
cgiurl="${cgipath}?${cgiargs}"
[ ${CGI_refresh} -ne 0 ] && afm_load_page  ${CGI_refresh} "${cgiurl}"
[ "${width}" = "" ] && width=700
MOD_TAB_LIST="Э#/cgi-bin/Protocol/sysapp_config?appid=${CGI_appid}&appname=${CGI_appname} \
ͼ#/cgi-bin/Monitor/appview_graph?${cgiargs} \
û#/cgi-bin/Monitor/appview_topip?${cgiargs} \
#/cgi-bin/Monitor/appview_topflowip?${cgiargs} \
йز#/cgi-bin/Monitor/appview_policy?${cgiargs}"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function showip(ipaddr, online, ttl, outbyte, inbyte, outrate, inrate)
{
        var url;
        url = \"/cgi-bin/Monitor/ipview_data?ipaddr=\" + ipaddr +
              \"&online=\" + online + \"&ttl=\" + ttl + \"&outbyte=\" + outbyte +
              \"&inbyte=\" + inbyte + \"&outrate=\" + outrate + \"&inrate=\" + inrate;
        ShowWindow(url, \"\", 650, 800);
}
function showOutip(ipaddr)
{
        var url;
        url = \"/cgi-bin/Monitor/outip_flow?ipaddr=\" + ipaddr; 
        ShowWindow(url, \"\", 650, 800);
}
</script>
<body>
"; cgi_show_title "ӦЭ->`${FLOWEYE} app name ${CGI_appid}`" ${width} 
echo -n "
<br>
"; cgi_show_app_info ${CGI_appid} ${width} 
echo -n "
<br>
"; cgi_print_mod_header "" ${width} 
echo -n "
<table width=\"${width}\" border=0 cellspacing=1 cellpadding=1> 
<form method=post action=\"${cgipath}\">
<tr id=tblhdr height=22>
        <td width=163 align=left><b>û&nbsp;</b>
        <select name=type value=\"${CGI_type}\" style=\"width:100;height:21\">
        ";
                if [ "${CGI_type}" = "inner" ]; then
                        echo "<option value=inner selected>û</option>"
                        echo "<option value=outer>û</option>"
                else
                        echo "<option value=inner>û</option>"
                        echo "<option value=outer selected>û</option>"
                fi
        
echo -n "
        </select></td>
        <td width=183 align=left><b>&nbsp;ʾǰ&nbsp;</b>
        <select name=topn value=\"${CGI_topn}\" style=\"width:70;height:21\">
        ";
                for tm in 10 20 30 50 100 0; do
                        if [  ${tm} -eq 0 ]; then
                                tmdesc=""
                        else
                                tmdesc="${tm}"
                        fi
                        if [ "${CGI_topn}" = "${tm}" ]; then
                                echo "<option selected value=${tm}>${tmdesc}</option>"
                        else
                                echo "<option value=${tm}>${tmdesc}</option>"
                        fi
                done
        
echo -n "
        </select>&nbsp;</td>
        <td width=173 align=left><b>&nbsp;ÿ&nbsp;</b>
        <select name=refresh value=\"${CGI_refresh}\" style=\"width:76;height:21\">
        ";
                for tm in 15 30 45 60 0; do
                        if [ ${tm} -eq 0 ]; then
                                tmdesc="ˢ"
                        else
                                tmdesc="${tm}"
                        fi
                        if [ "${CGI_refresh}" = "${tm}" ]; then
                                echo "<option selected value=${tm}>${tmdesc}</option>"
                        else
                                echo "<option value=${tm}>${tmdesc}</option>"
                        fi
                done
        
echo -n "
        </select>&nbsp;ˢ</td>
        <td width=* class=bgurl2 align=right><input type=submit value=\"  \" style=\"width:70;height:21\"></input>
        <input type=hidden name=appid value=\"${CGI_appid}\"></input></td>
        <input type=hidden name=appname value=\"${CGI_appname}\"></input></td>
</tr>
</form>
</table>
"; wid=$((${width} / 2)) 
echo -n "
<table width=\"${width}\" border=0 cellspacing=1 cellpadding=1> 
<tr id=tblhdr>
        <td width=${wid} align=center><b>IPַ</b></td>
        <td width=* align=center><b></b></td>
</tr>
";
idname="row1"
args="app=${CGI_appid} type=${CGI_type}"
[ ${CGI_topn} -ne 0 ] && args="${args} topn=${CGI_topn}"
if [ "${CGI_type}" = "inner" ]; then
	showip=1
else
	showip=0
fi
${FLOWEYE} flow ipsort ${args} | while read ip count theothers
do 
echo -n "
        <tr id=${idname}>
       	<td align=left>
	"; if [ ${showip} -ne 0 ]; then 
echo -n "
		<a href=\"javascript:showip('${ip}', '${onlinesec}', '${ttl}', '${outbyte}', '${inbyte}', '${outrate}', '${inrate}')\">&nbsp;&nbsp;&nbsp;&nbsp;${ip}</a>
	"; else 
echo -n "
		<a href=\"javascript:showOutip('${ip}')\">&nbsp;&nbsp;&nbsp;&nbsp;${ip}</a>
	"; fi 
echo -n "
	</td>
	
        <td align=right>${count}</td>
";
        if [ "${idname}" = "row1" ]; then
                idname="row2"
        else
                idname="row1"
        fi
done

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