diff --git a/html/bandwidth-graph.php b/html/bandwidth-graph.php index 9f5d9df3ed..d43f2bd85f 100644 --- a/html/bandwidth-graph.php +++ b/html/bandwidth-graph.php @@ -68,8 +68,20 @@ else { exit; } -$start = $_GET['from']; -$end = $_GET['to']; +if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) { + $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to` FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id'])); + if (is_null($histrow)) { + header("HTTP/1.0 404 Not Found"); + exit(); + } + $start = $histrow['from']; + $end = $histrow['to']; +} +else { + $start = $_GET[from]; + $end = $_GET[to]; +} + $xsize = (is_numeric($_GET['x']) ? $_GET['x'] : '800' ); $ysize = (is_numeric($_GET['y']) ? $_GET['y'] : '250' ); // $count = (is_numeric($_GET['count']) ? $_GET['count'] : "0" ); diff --git a/html/billing-graph.php b/html/billing-graph.php index 7545b8719c..b87f62859b 100644 --- a/html/billing-graph.php +++ b/html/billing-graph.php @@ -67,8 +67,27 @@ else { exit; } -$start = $_GET[from]; -$end = $_GET[to]; +$rate_data = dbFetchRow('SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1', array($bill_id)); +$bill_name = $rate_data['bill_name']; + +if (is_numeric($_GET['bill_id']) && is_numeric($_GET[bill_hist_id])) { + $histrow = dbFetchRow('SELECT UNIX_TIMESTAMP(bill_datefrom) as `from`, UNIX_TIMESTAMP(bill_dateto) AS `to`, rate_95th, rate_average FROM bill_history WHERE bill_id = ? AND bill_hist_id = ?', array($_GET['bill_id'], $_GET['bill_hist_id'])); + if (is_null($histrow)) { + header("HTTP/1.0 404 Not Found"); + exit(); + } + $start = $histrow['from']; + $end = $histrow['to']; + $rate_95th = $histrow['rate_95th']; + $rate_average = $histrow['rate_average']; +} +else { + $start = $_GET[from]; + $end = $_GET[to]; + $rate_95th = $rate_data['rate_95th']; + $rate_average = $rate_data['rate_average']; +} + $xsize = $_GET[x]; $ysize = $_GET[y]; $count = $_GET[count]; @@ -87,15 +106,6 @@ $dur = ($end - $start); $datefrom = date('Ymthis', $start); $dateto = date('Ymthis', $end); -// $rate_data = getRates($bill_id,$datefrom,$dateto); -$rate_data = dbFetchRow('SELECT * from `bills` WHERE `bill_id`= ? LIMIT 1', array($bill_id)); -$rate_95th = $rate_data['rate_95th']; -$rate_average = $rate_data['rate_average']; - -// $bi_a = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); -// $bill_name = $bi_a['bill_name']; -$bill_name = $rate_data['bill_name']; - $dur = ($end - $start); $counttot = dbFetchCell('SELECT count(`delta`) FROM `bill_data` WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME( ? ) AND `timestamp` <= FROM_UNIXTIME( ? )', array($bill_id, $start, $end)); diff --git a/html/pages/bill/history.inc.php b/html/pages/bill/history.inc.php index 95de8a76b2..41819c4ad0 100644 --- a/html/pages/bill/history.inc.php +++ b/html/pages/bill/history.inc.php @@ -22,7 +22,7 @@ $img['his'] .= '" style="margin: 15px 5px 25px 5px;" />'; '; return $res; @@ -119,9 +119,9 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY '; if ($vars['detail'] == $history['bill_hist_id'] || $vars['detail'] == 'all') { - $img['bitrate'] = showDetails($bill_id, 'bitrate', strtotime($datefrom), strtotime($dateto), $type); - $img['bw_day'] = showDetails($bill_id, 'day', strtotime($datefrom), strtotime($dateto)); - $img['bw_hour'] = showDetails($bill_id, 'hour', strtotime($datefrom), strtotime($dateto)); + $img['bitrate'] = showDetails($bill_id, 'bitrate', $history['bill_hist_id'], $type); + $img['bw_day'] = showDetails($bill_id, 'day', $history['bill_hist_id']); + $img['bw_hour'] = showDetails($bill_id, 'hour', $history['bill_hist_id']); echo '