function listBillPorts($bill_id) { $res = ""; $res .= "<table>"; $res .= " <tr>"; $res .= " <th>Device</th>"; $res .= " <th>Hardeware</th>"; $res .= " <th>Interface/Port</th>"; $res .= " <th>Speed</th>"; //$res .= " <th>Description</th>"; //$res .= " <th>Notes</th>"; $res .= " </tr>"; foreach (dbFetchRows("SELECT * FROM `bill_ports` as b, `ports` as p, `devices` as d WHERE b.bill_id = ? AND p.port_id = b.port_id AND d.device_id = p.device_id", array($bill_id)) as $row) { if (bill_permitted($bill_id)) { $device['name'] = $row['sysName']; //$device['port'] = $row['ifName']." (".$row['ifDescr'].")"; $device['port'] = $row['ifName']; $device['speed'] = formatRates($row['ifSpeed']); $device['hw'] = $row['hardware']; $device['descr'] = $row['port_descr_descr']; $device['notes'] = $row['port_descr_notres']; $res .= " <tr>"; $res .= " <td>" . $device['name'] . "</td>"; $res .= " <td>" . $device['hw'] . "</td>"; $res .= " <td>" . $device['port'] . "</td>"; $res .= " <td>" . $device['speed'] . "</td>"; //$res .= " <td>".$device['descr']."</td>"; //$res .= " <td>".$device['notes']."</td>"; $res .= " </tr>"; } } $res .= "</table>"; return $res; }
if (!is_file("includes/jpgraph/src/jpgraph.php") || defined('DEFAULT_THEME_CLASS')) { ?> <div class="alert alert-error"> <h4>JpGraph 设置错误</h4> <p><i>JpGraph 已经从 Observium 中移除资料库现在必须单独安装.</i></p> <ul style="margin-left: 30px"> <!-- ugly css hax, someone please FIXME --> <li>请下载 <a href="http://jpgraph.net/download/">http://jpgraph.net/download/</a> 并解压到 html/includes/jpgraph.</li> <li>从配置文件中删除主题定义 html/includes/jpgraph/src/jpg-config.inc.php</li> </ul> </div> <?php } $isAdmin = $_SESSION['userlevel'] == "10" ? true : false; $isUser = bill_permitted($bill_id); if ($vars['addbill'] == "yes" && !empty($vars['bill_name'])) { $updated = '1'; if (isset($vars['bill_quota']) or isset($vars['bill_cdr'])) { if ($vars['bill_type'] == "quota") { if (isset($vars['bill_quota_type'])) { if ($vars['bill_quota_type'] == "MB") { $multiplier = 1 * $config['billing']['base']; } if ($vars['bill_quota_type'] == "GB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base']; } if ($vars['bill_quota_type'] == "TB") { $multiplier = 1 * $config['billing']['base'] * $config['billing']['base'] * $config['billing']['base']; } $bill_quota = is_numeric($vars['bill_quota']) ? $vars['bill_quota'] * $config['billing']['base'] * $multiplier : 0;
} $init_modules = array('web', 'auth'); require realpath(__DIR__ . '/..') . '/includes/init.php'; if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo 'unauthenticated'; exit; } } require $config['install_dir'] . '/html/lib/jpgraph/jpgraph.php'; require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_line.php'; require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_utils.inc.php'; require $config['install_dir'] . '/html/lib/jpgraph/jpgraph_date.php'; if (is_numeric($_GET['bill_id'])) { if (get_client_ip() != $_SERVER['SERVER_ADDR']) { if (bill_permitted($_GET['bill_id'])) { $bill_id = $_GET['bill_id']; } else { echo 'Unauthorised Access Prohibited.'; exit; } } else { $bill_id = $_GET['bill_id']; } } else { echo 'Unauthorised Access Prohibited.'; exit; } $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])) {
<?php $bill_id = mres($vars['bill_id']); if ($_SESSION['userlevel'] >= '10') { include 'pages/bill/actions.inc.php'; } if (bill_permitted($bill_id)) { $bill_data = dbFetchRow('SELECT * FROM bills WHERE bill_id = ?', array($bill_id)); $bill_name = $bill_data['bill_name']; $today = str_replace('-', '', dbFetchCell('SELECT CURDATE()')); $yesterday = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)')); $tomorrow = str_replace('-', '', dbFetchCell('SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)')); $last_month = str_replace('-', '', dbFetchCell('SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)')); $rightnow = $today . date(His); $before = $yesterday . date(His); $lastmonth = $last_month . date(His); $bill_name = $bill_data['bill_name']; $dayofmonth = $bill_data['bill_day']; $day_data = getDates($dayofmonth); $datefrom = $day_data['0']; $dateto = $day_data['1']; $lastfrom = $day_data['2']; $lastto = $day_data['3']; $rate_95th = $bill_data['rate_95th']; $dir_95th = $bill_data['dir_95th']; $total_data = $bill_data['total_data']; $rate_average = $bill_data['rate_average']; if ($rate_95th > $paid_kb) { $over = $rate_95th - $paid_kb; $bill_text = $over . 'Kbit excess.'; $bill_color = '#cc0000';
} elseif ($bittype == "CDR") { $res .= "&95th=yes"; } } else { $res = "<img src=\"bandwidth-graph.php?bill_id=" . $bill_id; } //$res .= "&type=".$type; $res .= "&type=" . $imgtype; $res .= "&x=1050&y=250"; $res .= "&from=" . $from . "&to=" . $to; $res .= "\" style=\"margin: 15px 0px 25px 0px;\" />"; return $res; } echo "\n <table class=\"table table-striped table-bordered table-hover table-condensed table-rounded\">\n <thead>\n <tr style=\"font-weight: bold; \">\n <th width=\"250\">Period</th>\n <th>Type</th>\n <th>Allowed</th>\n <th>Inbound</th>\n <th>Outbound</th>\n <th>Total</th>\n <th>95th %ile</th>\n <th style=\"text-align: center;\">Overusage</th>\n <th colspan=\"2\" style=\"text-align: right;\"><a class=\"btn btn-mini\" style=\"color: #555;\" href=\"" . generate_url($vars, array('detail' => "all")) . "\"><img src=\"images/16/chart_curve.png\" alt=\"Show details\" title=\"Show details\" /> Show all details</a></th>\n </tr>\n </thead>\n <tbody>"; foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 24", array($bill_id)) as $history) { if (bill_permitted($history['bill_id'])) { unset($class); $datefrom = $history['bill_datefrom']; $dateto = $history['bill_dateto']; $type = $history['bill_type']; $percent = $history['bill_percent']; $dir_95th = $history['dir_95th']; $rate_95th = formatRates($history['rate_95th']); $total_data = format_number($history['traf_total'], $config['billing']['base']); if ($type == "CDR") { $allowed = formatRates($history['bill_allowed']); $used = formatRates($history['rate_95th']); $in = formatRates($history['rate_95th_in']); $out = formatRates($history['rate_95th_out']); $overuse = $history['bill_overuse'] <= 0 ? "<span class=\"badge badge-success\">-</span>" : "<span class=\"badge badge-important\">" . formatRates($history['bill_overuse']) . "</span>"; $label = "inverse";
<?php $data = ""; if (isset($_POST['billsearch'])) { $type['cdr'] = $_POST['billingtype'] == "cdr" ? " selected" : ""; $type['quota'] = $_POST['billingtype'] == "quota" ? " selected" : ""; $state['under'] = $_POST['billingstate'] == "under" ? " selected" : ""; $state['over'] = $_POST['billingstate'] == "over" ? " selected" : ""; } if ($isAdmin) { $data .= "<option value=\"\">All Customers</option>"; $data .= "<optgroup label=\"Customer:\">"; foreach (dbFetchRows("SELECT * FROM `bill_perms` GROUP BY `user_id` ORDER BY `user_id` ") as $customers) { if (bill_permitted($customers['bill_id'])) { $customer = dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ? ORDER BY `user_id`", array($customers['user_id'])); $name = empty($customer['realname']) ? $customer['username'] : $customer['realname']; $select = $_POST['billinguser'] == $customer['user_id'] ? " selected" : ""; $data .= "<option value=\"" . $customer['user_id'] . "\"" . $select . ">" . $name . "</option>"; } } $data .= "</optgroup>"; } else { $data .= "<optgroup label=\"Customer:\">"; $data .= "<option value=\"" . $_SESSION['user_id'] . "\" selected>" . $_SESSION['username'] . "</option>"; $data .= "</optgroup>"; } ?> <form class="well form-search" method="post" action="" style="padding-bottom: 10px;"> <fieldset> <strong>Search:</strong>
?> "> </div> <div class="col-sm-6"> </div> </div> <button type="submit" class="btn btn-default"><i class="icon-ok-sign icon-white"></i> <strong>Add Bill</strong></button> </form> <?php } else { include "pages/bills/search.inc.php"; $i = 0; echo "<table border='0' cellspacing='0' cellpadding='5' class='table table-condensed'>\n <tr>\n <th>Billing name</th>\n <th></th>\n <th>Type</th>\n <th>Allowed</th>\n <th>Used</th>\n <th>Overusage</th>\n <th></th>\n <th></th>\n </tr>"; foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) { if (bill_permitted($bill['bill_id'])) { unset($class); $day_data = getDates($bill['bill_day']); $datefrom = $day_data['0']; $dateto = $day_data['1']; # $rate_data = getRates($bill['bill_id'],$datefrom,$dateto); $rate_data = $bill; $rate_95th = $rate_data['rate_95th']; $dir_95th = $rate_data['dir_95th']; $total_data = $rate_data['total_data']; $rate_average = $rate_data['rate_average']; if ($bill['bill_type'] == "cdr") { $type = "CDR"; $allowed = format_si($bill['bill_cdr']) . "bps"; $used = format_si($rate_data['rate_95th']) . "bps"; $percent = round($rate_data['rate_95th'] / $bill['bill_cdr'] * 100, 2);
<?php // Authorises bill viewing and sets $ports as reference to mysql query containing ports for this bill require '../includes/billing.php'; if (is_numeric($_GET['id']) && ($auth || bill_permitted($_GET['id']))) { $bill = dbFetchRow('SELECT * FROM `bills` WHERE bill_id = ?', array($_GET['id'])); $datefrom = date('YmdHis', $_GET['from']); $dateto = date('YmdHis', $_GET['to']); $rates = getRates($_GET['id'], $datefrom, $dateto); $ports = dbFetchRows('SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.port_id = B.port_id AND D.device_id = P.device_id', array($_GET['id'])); $auth = true; }
include $config['html_dir'] . "/includes/authenticate.inc.php"; if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) { if (!$_SESSION['authenticated']) { echo "unauthenticated"; exit; } } require_once $config['html_dir'] . "/includes/jpgraph/src/jpgraph.php"; require_once $config['html_dir'] . "/includes/jpgraph/src/jpgraph_line.php"; require_once $config['html_dir'] . "/includes/jpgraph/src/jpgraph_bar.php"; require_once $config['html_dir'] . "/includes/jpgraph/src/jpgraph_utils.inc.php"; require_once $config['html_dir'] . "/includes/jpgraph/src/jpgraph_date.php"; $vars = get_vars('GET'); if (is_numeric($vars['bill_id'])) { if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR']) { if (bill_permitted($vars['bill_id'])) { $bill_id = $vars['bill_id']; } else { echo "Unauthorised Access Prohibited."; exit; } } else { $bill_id = $vars['bill_id']; } } else { echo "Unauthorised Access Prohibited."; exit; } // Workaround for JPGraph 3.5 on Ubuntu per 0015246 if (!function_exists('imageantialias')) { function imageantialias($image, $enabled)
<?php /** * Observium * * This file is part of Observium. * * @package observium * @subpackage webui * @copyright (C) 2006-2014 Adam Armstrong * */ // Build a list of user ids we can use to search for bills that user is allowed to see. if ($isAdmin) { foreach (dbFetchRows("SELECT * FROM `entity_permissions` WHERE `entity_type` = 'bill' GROUP BY `user_id` ORDER BY `user_id` ") as $customers) { if (bill_permitted($customers['entity_id'])) { $customer = dbFetchRow("SELECT * FROM `users` WHERE `user_id` = ? ORDER BY `user_id`", array($customers['user_id'])); $name = empty($customer['realname']) ? $customer['username'] : $customer['realname']; $select = $vars['billinguser'] == $customer['user_id'] ? " selected" : ""; $users[$customer['user_id']] = $name; } } } else { $users[$_SESSION['user_id']] = $_SESSION['username']; } // Billing name field $search[] = array('type' => 'text', 'name' => '账单名称', 'id' => 'billingname', 'value' => $vars['billingname']); // Billing type field $search[] = array('type' => 'select', 'name' => '所有类型', 'id' => 'billingtype', 'value' => $vars['billingtype'], 'values' => array('cdr' => 'CDR/95th', 'quota' => '限额')); //Billing user field $search[] = array('type' => 'select', 'name' => '用户', 'id' => 'billinguser', 'width' => '130px', 'value' => $vars['billinguser'], 'values' => $users);