#!/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 "";
if [ "${PALANG}" = "en" ]; then 
	LANG_001="Last Day/Bps(in)"
	LANG_002="Bps(in)"
	LANG_003="Last Day/Bps(out)"
	LANG_004="Last Day/Connection"
	LANG_005="Bps(out)"
	LANG_006="Connection"
	LANG_007="Last 3 Days"
	LANG_008="History"
	LANG_009="Configure"
	LANG_0010="Realtime"
	LANG_0011="TopFlow"
	LANG_0012="Chart"
	LANG_0013="LogShow"
	LANG_0014="GameCloud->History"
fi
CGI_browsertitle="${LANG_0014:=Ϸ->ʷ}" 
. ../../common/common.sh 
[ "${width}" = "" ] && width=700
title1="${LANG_001:=һ}"
tmend1=`date +%s`
hours1=24
type1="inbps"
text1="${LANG_002:=}"
title2="${LANG_003:=һ}"
tmend2=`date +%s`
hours2=24
type2="outbps"
text2="${LANG_005:=}"
title3="${LANG_004:=һ}"
tmend3=`date +%s`
hours3=24
type3="flow"
text3="${LANG_006:=}"
CGI_proxyname=`${FLOWEYE} gamecloud stat | grep "^pxyname=" | cut -d'=' -f2`
pxyid=`${FLOWEYE} gamecloud stat | grep "^pxyid=" | cut -d'=' -f2`
URLROOT="/cgi-bin/App/gamecloud"
MOD_TAB_LIST="${LANG_009:=}#${URLROOT}/webmain ${LANG_0010:=ʵʱ}#${URLROOT}/gamecloud_rtgraph ${LANG_0011:=}#${URLROOT}/gamecloud_topflow"
MOD_TAB_LIST="${MOD_TAB_LIST} ${LANG_0012:=ʷ}#${URLROOT}/gamecloud_graph ${LANG_0013:=·־}#${URLROOT}/gamecloud_logshow" 

echo -n "
<script type=\"text/javascript\" src=\"/img/highcharts.js\"></script>
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function MyShowWindow(url, args, width, height)
{
        var left = (window.screen.width - width) / 2;
        var top  = (window.screen.height - height) / 2;
        if (args == \"\")
                args = \"scrollbars=1,toolbar=0,menubar=0,status=0,location=0\";
        else
                args += \",location=0\";
        args += \",top=\" + top + \",left=\" + left + \",height=\" + height + \",width=\" + width;
        window.open(url, \"_blank\", args);
}
function popupurl(url, width, height)
{
        MyShowWindow(url, \"scrollbars=1,resizable=1\", width, height);
}
function createChart(chartdiv, charttitle, charttype, charttmend, charthours)
{
        var options_chart = ({
                chart: {
                        type: 'area',
                        renderTo:chartdiv
                },
                title: {
                        enabled: false,
                        text:'',
                        x: -20
                },
                xAxis: {
                        type: 'datetime',
                        tickPixelInterval: 50,
                        labels: {
                                style: {
                                        font: 'normal 9px Arial',
                                        fontSize:'10px'
                                }
                        }
                },
                yAxis: {
                        min: 0,
                        tickPixelInterval:30,
                        labels: {
                                style: {
                                        font: 'normal 9px Arial'
                                }
                        },
                        title: {
                                text: charttitle
                        },
                        plotLines: [{ value: 0, width: 1, color: \"#808080\" }]
                },
                plotOptions:{
                        area:{stacking:false,lineWidth:1,marker:{enabled:false}},
                        spline:{
                                marker:{
                                        radius:0,
                                        lineWidth:1
                                },
                                lineWidth:1
                        }
                },
                tooltip: {
                        formatter:function(){
                                var dd = new Date(this.x);
                                var str = \"ʱ䣺\"+dd.getDate()+'/'+dd.getHours()+':'+dd.getMinutes();
                                return str+'<br>'+this.series.name+' '+ (this.y);
                        }
                },
                legend: {
                        enabled:false,
                        layout: \"vertical\",
                        align: \"right\",
                        verticalAlign: \"middle\",
                        borderWidth: 0
                },
                credits:{enabled: false},
                series: [{name:charttitle, type: 'spline', color:'#9CC6F0', data: []}]
    });
        $.ajax({
                url: '/cgi-bin/Monitor/ajax_proxy_graph',
                type:'post',
                dataType:'json',
                data: {type:charttype,hours:charthours,tmend:charttmend, pxyid:'${pxyid}'},
                success:function(json){
                        options_chart.series[0].data = json.rows;
                        new Highcharts.Chart(options_chart);
                }
    });
}
function onloaddoc()
{
        Highcharts.setOptions({ global: { useUTC: false } });
        createChart(\"chart1\", \"${text1}\", \"${type1}\", \"${tmend1}\", ${hours1});
        createChart(\"chart2\", \"${text2}\", \"${type2}\", \"${tmend2}\", ${hours2});
";
if [ "${type}" = "proxy" -o "${type}" = "pppoe" ]; then 

echo -n "
        createChart(\"chart3\", \"${text3}\", \"${type3}\", \"${tmend3}\", ${hours3});
";
fi 

echo -n "
}
</script>
<body onload=\"onloaddoc()\">
"; cgi_print_mod_header "${LANG_0012:=ʷ}" "100%" 
echo -n "
<script type=\"text/javascript\" src=\"/img/wz_tooltip.js\"></script>
<span id=\"hlp3day\" style=\"display:none\">鿴ͼ</span>
<span id=\"hlpall\" style=\"display:none\">鿴һܡһµͼ</span>
<br>
<table style=\"width:${width}; font-bold:true;font-size:14px; color:#CE6C04\">
<tr>    
        <td align=left><b>${title1}</b></td>
        <td align=right>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_3daygraph?proxyname=${CGI_proxyname}&type=inbps', 620, 700)\"
            onmouseover=\"TagToTip('hlp3day')\" onmouseout=\"UnTip()\">${LANG_007:=նԱ}</a>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_mongraph?proxyname=${CGI_proxyname}&type=inbps', 620, 700)\"
            onmouseover=\"TagToTip('hlpall')\" onmouseout=\"UnTip()\">${LANG_008:=ʷͼ}</a>
        </td>
</tr>
</table>
<table width=${width} border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr><td id=\"chart1\" style=\"border:1px dotted #000;height:220px;\"></td></tr>
</table>
<br> 
<table style=\"width:${width}; font-bold:true;font-size:14px; color:#CE6C04\">
<tr>    
        <td align=left><b>${title2}</b></td>
        <td align=right>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_3daygraph?proxyname=${CGI_proxyname}&type=outbps', 620, 700)\"
            onmouseover=\"TagToTip('hlp3day')\" onmouseout=\"UnTip()\">${LANG_007:=նԱ}</a>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_mongraph?proxyname=${CGI_proxyname}&type=outbps', 620, 700)\"
            onmouseover=\"TagToTip('hlpall')\" onmouseout=\"UnTip()\">${LANG_008:=ʷͼ}</a>
        </td>
</tr>   
</table>
<table width=${width} border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr><td id=\"chart2\" style=\"border:1px dotted #000;height:220px;\"></td></tr>
</table>
";
if [ "${type}" = "proxy" -o "${type}" = "pppoe" ]; then 

echo -n "
<br>
<table style=\"width:${width}; font-bold:true;font-size:14px; color:#CE6C04\">
<tr>
        <td align=left><b>${title3}</b></td>
        <td align=right>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_3daygraph?proxyname=${CGI_proxyname}&type=flow', 620, 700)\"
            onmouseover=\"TagToTip('hlp3day')\" onmouseout=\"UnTip()\">${LANG_007:=նԱ}</a>
        <a href=\"javascript:popupurl('/cgi-bin/Monitor/proxy_mongraph?proxyname=${CGI_proxyname}&type=flow', 620, 700)\"
            onmouseover=\"TagToTip('hlpall')\" onmouseout=\"UnTip()\">${LANG_008:=ʷͼ}</a>
        </td>
</tr>
</table>
<table width=${width} border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr><td id=\"chart3\" style=\"border:1px dotted #000;height:220px;\"></td></tr>
</table>
";
fi 

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