diff --git a/attic/purgeports.inc.php b/attic/purgeports.inc.php
new file mode 100644
index 000000000..462a17b0a
--- /dev/null
+++ b/attic/purgeports.inc.php
@@ -0,0 +1,46 @@
+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))
+{
+ echo("Deleting port " . $port['interface_id'] . " - " . $port['ifDescr']);
+ delete_port($port['interface_id']);
+ echo("
");
+}
+
+?>
\ No newline at end of file
diff --git a/html/pages/locations.inc.php b/html/pages/locations.inc.php
index 4816de54d..1c2355342 100644
--- a/html/pages/locations.inc.php
+++ b/html/pages/locations.inc.php
@@ -7,17 +7,17 @@ foreach (getlocations() as $location)
if ($_SESSION['userlevel'] == '10')
{
- $num = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "'"),0);
- $net = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'network'"),0);
- $srv = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'server'"),0);
- $fwl = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'firewall'"),0);
- $hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND status = '0'"),0);
+ $num = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "'");
+ $net = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'network'");
+ $srv = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'server'");
+ $fwl = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND type = 'firewall'");
+ $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices WHERE location = '" . $location . "' AND status = '0'");
} else {
- $num = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "'"),0);
- $net = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND D.type = 'network'"),0);
- $srv = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'server'"),0);
- $fwl = mysql_result(mysql_query("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'firewall'"),0);
- $hostalerts = mysql_result(mysql_query("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $location . "' AND status = '0'"),0);
+ $num = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "'");
+ $net = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND D.type = 'network'");
+ $srv = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'server'");
+ $fwl = dbFetchCell("SELECT COUNT(D.device_id) FROM devices AS D, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' AND location = '" . $location . "' AND type = 'firewall'");
+ $hostalerts = dbFetchCell("SELECT COUNT(device_id) FROM devices AS D, devices_perms AS P WHERE location = '" . $location . "' AND status = '0'");
}
if ($hostalerts) { $alert = '
'; } else { $alert = ""; }
@@ -40,4 +40,4 @@ foreach (getlocations() as $location)
echo("");
-?>
\ No newline at end of file
+?>
diff --git a/includes/common.php b/includes/common.php
index dac3d5611..a1f84eb67 100644
--- a/includes/common.php
+++ b/includes/common.php
@@ -2,6 +2,25 @@
## Common Functions
+function delete_port($int_id)
+{
+ global $config;
+
+ $interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.interface_id = ? AND D.device_id = P.device_id", array($int_id));
+
+ $interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
+
+ foreach($interface_tables as $table) {
+ dbDelete($table, "`interface_id` = ?", array($int_id));
+ }
+
+ dbDelete('links', "`local_interface_id` = ?", array($int_id));
+ dbDelete('links', "`remote_interface_id` = ?", array($int_id));
+ dbDelete('bill_ports', "`port_id` = ?", array($int_id));
+
+ unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/".$interface['ifIndex'].".rrd");
+}
+
function sgn($int)
{
if ($int < 0)
diff --git a/includes/functions.php b/includes/functions.php
index 2a0d24c67..9655f4435 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -145,25 +145,6 @@ function renamehost($id, $new, $source = 'console')
log_event("Hostname changed -> $new ($source)", $id, 'system');
}
-function delete_port($int_id)
-{
- global $config;
-
- $interface = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE P.interface_id = ? AND D.device_id = P.device_id", array($int_id));
-
- $interface_tables = array('adjacencies', 'ipaddr', 'ip6adjacencies', 'ip6addr', 'mac_accounting', 'bill_ports', 'pseudowires', 'ports');
-
- foreach($interface_tables as $table) {
- dbDelete($table, "`interface_id` = ?", array($int_id));
- }
-
- dbDelete('links', "`local_interface_id` = ?", array($int_id));
- dbDelete('links', "`remote_interface_id` = ?", array($int_id));
- dbDelete('bill_ports', "`port_id` = ?", array($int_id));
-
- unlink(trim($config['rrd_dir'])."/".trim($interface['hostname'])."/".$interface['ifIndex'].".rrd");
-}
-
function delete_device($id)
{
global $config;