コード例 #1
0
ファイル: statistics.php プロジェクト: precurse/netharbour
function zoomGraph($devices)
{
    //some time stuff
    $now = time();
    $day = time() - 24 * 60 * 60;
    $twoday = time() - 2 * 24 * 60 * 60;
    $week = time() - 7 * 24 * 60 * 60;
    $month = time() - 31 * 24 * 60 * 60;
    $year = time() - 365 * 24 * 60 * 60;
    $file = "deviceid" . $deviceID . "_" . $name;
    switch ($_GET['from']) {
        case 'day':
            $from = $day;
            break;
        case 'week':
            $from = $week;
            break;
        case 'month':
            $from = $month;
            break;
        case 'year':
            $from = $year;
            break;
    }
    echo "<table id='dataTable' style='width:1024px;'>";
    if (isset($_GET['aggr_id'])) {
        $type = $_GET['type'];
        $type = str_replace(" ", "%20", $type);
        $oriName = $_GET['aggr_id'];
        $name = str_replace(" ", "%20", $oriName);
        $graphLink = "rrdgraph.php?type=aggr_traf&aggr_id=" . $name . "&from=" . $from . "&to=" . $now . "&title=" . $name . "&height=150&width=900";
        echo "<tr><th>" . $oriName . "<br></b></p></font></th></tr>";
        echo "<tr><td><img id='zoom' src='" . $graphLink . "'>\r\n\t\t\t\t<form method='GET' action='' enctype='multipart/form-data' id='range_form'>";
        echo '<input type="hidden" name="epoch_start" value="' . $from . '" id="epoch_start" />
				<input type="hidden" name="rrdfile" value="' . $name . '" id="rrdfile" />
				<input type="hidden" name="type" value="' . $type . '" id="type" />
				<input type="hidden" name="epoch_end" value="' . $now . '" id="epoch_end" />
				<input type="hidden" name="width" value="900" id="width" />
				<input type="hidden" name="height" value="150" id="height" />
				</form>
				</td>
				</tr>';
    } else {
        $deviceID = $_GET['ID'];
        $interfaces = $devices->get_interfaces();
        $interfaceID = $_GET['interID'];
        $port = new Port($interfaceID);
        $deviceID = $devices->get_device_id();
        $oriName = $port->get_name();
        $nameTitle = str_replace(" ", "%20", $oriName);
        $name = str_replace(" ", "-", $oriName);
        $name = str_replace("/", "-", $name);
        $type = $_GET['type'];
        $graph = $type;
        switch ($type) {
            case "traffic":
                $graph = 'Bits Per Second';
                break;
            case "errors":
                $graph = 'Errors';
                break;
            case "unicastpkts":
                $graph = 'Unicast Packets';
                break;
            case "nonunicastpkts":
                $graph = 'Non Unicast Packets';
                break;
        }
        $type = str_replace(" ", "%20", $type);
        $graph = str_replace(" ", "%20", $graph);
        $graphLink = "rrdgraph.php?file=deviceid" . $deviceID . "_" . $name . ".rrd&title=" . $nameTitle . "---" . $graph . "&height=150&width=900&type=" . $type;
        $file = "deviceid" . $deviceID . "_" . $name . ".rrd&title=" . $oriName;
        $graphLink .= "&from=" . $from . "&to" . $now;
        echo "<tr><th>" . $oriName . " | " . $devices->get_name() . " | " . $port->get_descr() . " - " . $port->get_alias() . "<br></b></p></font></th></tr>";
        echo "<tr><td><img id='zoom' src='" . $graphLink . "'>\r\n\t\t\t\t<form method='GET' action='' enctype='multipart/form-data' id='range_form'>";
        echo '<input type="hidden" name="epoch_start" value="' . $from . '" id="epoch_start" />
				<input type="hidden" name="rrdfile" value="' . $file . '" id="rrdfile" />
				<input type="hidden" name="type" value="' . $type . '" id="type" />
				<input type="hidden" name="epoch_end" value="' . $now . '" id="epoch_end" />
				<input type="hidden" name="width" value="900" id="width" />
				<input type="hidden" name="height" value="150" id="height" />
				</form>
				</td>
				</tr>';
    }
    echo "</table>";
}