diff --git a/html/pages/about.inc.php b/html/pages/about.inc.php index 6df610abec..d65c1b6936 100644 --- a/html/pages/about.inc.php +++ b/html/pages/about.inc.php @@ -38,29 +38,29 @@ along with this program. If not, see htt

Statistics

@@ -121,9 +121,7 @@ $apache_version = str_replace("Apache/", "", $_SERVER['SERVER_SOFTWARE']); $php_version = phpversion(); -$t = mysql_query("select version() as ve"); -$r = mysql_fetch_object($t); -$mysql_version = $r->ve; +$mysql_version = dbFetchCell("SELECT version()"); $netsnmp_version = shell_exec($config['snmpget'] . " --version"); diff --git a/html/pages/addsrv.inc.php b/html/pages/addsrv.inc.php index 04f5ccd37a..cd8e17dec5 100644 --- a/html/pages/addsrv.inc.php +++ b/html/pages/addsrv.inc.php @@ -26,8 +26,7 @@ else closedir($handle); } - $query = mysql_query("SELECT * FROM `devices` ORDER BY `hostname`"); - while ($device = mysql_fetch_assoc($query)) + foreach(dbFetchRows("SELECT * FROM `devices` ORDER BY `hostname`") as $device) { $devicesform .= ""; } @@ -80,4 +79,4 @@ else } -?> \ No newline at end of file +?> diff --git a/html/pages/authlog.inc.php b/html/pages/authlog.inc.php index 18cc76a2fb..7bda044bc1 100644 --- a/html/pages/authlog.inc.php +++ b/html/pages/authlog.inc.php @@ -2,12 +2,9 @@ if ($_SESSION['userlevel'] == '10') { - $query = "SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250"; - $data = mysql_query($query); - echo(""); - while ($entry = mysql_fetch_assoc($data)) + foreach (dbFetchRows("SELECT *,DATE_FORMAT(datetime, '%D %b %Y %T') as humandate FROM `authlog` ORDER BY `datetime` DESC LIMIT 0,250") as $entry) { if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; } @@ -31,4 +28,4 @@ if ($_SESSION['userlevel'] == '10') echo("
"); } -?> \ No newline at end of file +?> diff --git a/html/pages/bill.inc.php b/html/pages/bill.inc.php index a1ed17b5dc..62a5606108 100644 --- a/html/pages/bill.inc.php +++ b/html/pages/bill.inc.php @@ -9,13 +9,12 @@ if ($_SESSION['userlevel'] == "10") if (bill_permitted($bill_id)) { - $bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id"); - $bill_data = mysql_fetch_assoc($bi_q); + $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); - $today = str_replace("-", "", mysql_result(mysql_query("SELECT CURDATE()"), 0)); - $yesterday = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)"), 0)); - $tomorrow = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)"), 0)); - $last_month = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)"), 0)); + $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); @@ -54,13 +53,13 @@ if (bill_permitted($bill_id)) $bill_color = "#0000cc"; } - $fromtext = mysql_result(mysql_query("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"), 0); - $totext = mysql_result(mysql_query("SELECT DATE_FORMAT($dateto, '%M %D %Y')"), 0); - $unixfrom = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$datefrom')"), 0); - $unixto = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$dateto')"), 0); + $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"); + $totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '%M %D %Y')"); + $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); + $unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); - $unix_prev_from = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastfrom')"), 0); - $unix_prev_to = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastto')"), 0); + $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); + $unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); echo("

Bill : " . $bill_name . "

"); @@ -103,11 +102,11 @@ if (bill_permitted($bill_id)) echo("

Billed Ports

"); - $ports = mysql_query("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D - WHERE B.bill_id = '".$bill_id."' AND P.interface_id = B.port_id - AND D.device_id = P.device_id"); + $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D + WHERE B.bill_id = ? AND P.interface_id = B.port_id + AND D.device_id = P.device_id", array($bill_id)); - while ($port = mysql_fetch_assoc($ports)) + foreach ($ports as $port) { echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); } @@ -184,8 +183,8 @@ if (bill_permitted($bill_id)) $bi .= "&from=" . $unixfrom . "&to=" . $unixto; $bi .= "&width=715&height=200&total=1'>"; - $lastmonth = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"), 0); - $yesterday = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"), 0); + $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); + $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); $rightnow = date(U); diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index 9adaf2ec74..037ad5ebdd 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -4,14 +4,10 @@ if ($_POST['addbill'] == "yes") { $updated = '1'; - $sql = "INSERT INTO `bills` (`bill_name`,`bill_type`,`bill_cdr`,`bill_day`,`bill_gb`, `bill_custid`, `bill_ref`, `bill_notes`) - VALUES ('" . mres($_POST['bill_name']) . "','" . mres($_POST['bill_type']) . "', - '" . mres($_POST['bill_cdr']) . "','" . mres($_POST['bill_day']) . "', - '" . mres($_POST['bill_quota']) . "','" . mres($_POST['bill_custid']) . "', - '" . mres($_POST['bill_ref']) . "','" . mres($_POST['bill_notes']) . "' )"; + $insert = array('bill_name' => $_POST['bill_name'], 'bill_type' => $_POST['bill_type'], 'bill_cdr' => $_POST['bill_cdr'], 'bill_day' => $_POST['bill_day'], 'bill_gb' => $_POST['bill_quota'], + 'bill_custid' => $_POST['bill_custid'], 'bill_ref' => $_POST['bill_ref'], 'bill_notes' => $_POST['bill_notes']); - $query = mysql_query($sql); - $affected = mysql_affected_rows() . "records affected"; + $affected = dbInsert($insert, 'bills'); $message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!"; $message_break .= "
"; @@ -119,11 +115,9 @@ if ($_GET['opta'] == "add") print_optionbar_end(); - $sql = "SELECT * FROM `bills` ORDER BY `bill_name`"; - $query = mysql_query($sql); echo(""); $i=1; - while ($bill = mysql_fetch_assoc($query)) + foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) { #echo("
");
     #print_r($permissions);
diff --git a/html/pages/customers.inc.php b/html/pages/customers.inc.php
index fd9c5cd5b6..4dc274c561 100644
--- a/html/pages/customers.inc.php
+++ b/html/pages/customers.inc.php
@@ -1,8 +1,5 @@
 ");
 
 echo("
@@ -19,7 +16,7 @@ echo("
 
 $i = 1;
 
-while ($customer = mysql_fetch_assoc($cust_query))
+foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer)
 {
   $i++;
 
@@ -72,4 +69,4 @@ while ($customer = mysql_fetch_assoc($cust_query))
 
 echo("
"); -?> \ No newline at end of file +?> diff --git a/html/pages/pseudowires.inc.php b/html/pages/pseudowires.inc.php index 637b74bc3d..3f0e49f05b 100644 --- a/html/pages/pseudowires.inc.php +++ b/html/pages/pseudowires.inc.php @@ -12,10 +12,7 @@ list($opta, $optb, $optc, $optd, $opte) = explode("/", $_GET['opta']); echo(""); -$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr"; -$query = mysql_query($sql); - -while ($pw_a = mysql_fetch_assoc($query)) +foreach (dbFetchRows("SELECT * FROM pseudowires AS P, ports AS I, devices AS D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id ORDER BY D.hostname,I.ifDescr") as $pw_a) { $i = 0; while ($i < count($linkdone)) @@ -25,10 +22,8 @@ while ($pw_a = mysql_fetch_assoc($query)) $i++; } - $pw_b = mysql_fetch_assoc(mysql_query("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = '".$pw_a['peer_device_id']."' AND - D.device_id = I.device_id AND - P.cpwVcID = '".$pw_a['cpwVcID']."' AND - P.interface_id = I.interface_id")); + $pw_b = dbFetchRow("SELECT * from `devices` AS D, `ports` AS I, `pseudowires` AS P WHERE D.device_id = ? AND D.device_id = I.device_id + AND P.cpwVcID = ? AND P.interface_id = I.interface_id", array($pw_a['peer_device_id'], $pw_a['cpwVcID'])); if (!port_permitted($pw_a['interface_id'])) { $skip = "yes"; } if (!port_permitted($pw_b['interface_id'])) { $skip = "yes"; } @@ -88,4 +83,4 @@ while ($pw_a = mysql_fetch_assoc($query)) echo("
"); -?> \ No newline at end of file +?> diff --git a/html/pages/purgeports.inc.php b/html/pages/purgeports.inc.php index 462a17b0ac..200bfd8db7 100644 --- a/html/pages/purgeports.inc.php +++ b/html/pages/purgeports.inc.php @@ -1,46 +1,10 @@ Deleting IPv4 address " . $ipaddr['addr'] . "/" . $ipaddr['cidr']); - mysql_query("DELETE FROM addr WHERE id = '".$addr['id']."'"); - echo(""); - } - - $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); - while ($ip6addr = mysql_fetch_assoc($ip6addrs)) - { - echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); - mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); - echo("
"); - } - - $ip6addr = mysql_query("SELECT * FROM `ip6addr` WHERE `interface_id` = '$interface_id'"); - while ($ip6addr = mysql_fetch_assoc($ip6addrs)) - { - echo("
Deleting IPv6 address " . $ip6addr['ip6_comp_addr'] . "/" . $ip6addr['ip6_prefixlen']); - mysql_query("DELETE FROM ip6addr WHERE ip6_addr_id = '".$ip6addr['ip6_addr_id']."'"); - echo("
"); - } - - mysql_query("DELETE FROM `pseudowires` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `mac_accounting` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `links` WHERE `local_interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `links` WHERE `remote_interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `ports_perms` WHERE `interface_id` = '$interface_id'"); - mysql_query("DELETE FROM `ports` WHERE `interface_id` = '$interface_id'"); -} - -$ports = mysql_query("SELECT * FROM `ports` WHERE `deleted` = '1'"); -while ($port = mysql_fetch_assoc($ports)) +foreach (dbFetchRows("SELECT * FROM `ports` WHERE `deleted` = '1'") as $port) { echo("
Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']); delete_port($port['interface_id']); echo("
"); } -?> \ No newline at end of file +?>