From c28ce28aabd046b0fddbf05395aa81f812eb771c Mon Sep 17 00:00:00 2001 From: sandb Date: Sun, 14 Nov 2010 01:13:12 +0100 Subject: [PATCH] removed known macs functionality --- lib/trans.php | 59 --------------------------------------------------- macs.php | 9 ++++---- 2 files changed, 4 insertions(+), 64 deletions(-) delete mode 100644 lib/trans.php diff --git a/lib/trans.php b/lib/trans.php deleted file mode 100644 index d9e7b10..0000000 --- a/lib/trans.php +++ /dev/null @@ -1,59 +0,0 @@ -query("select * from knownmacs"); - if (!$q) return $results; - while($row = $q->fetch_array(SQLITE_ASSOC)) { - $results[$row['mac']] = $row['name']; - } - return $results; -} - -function known_macs_get_by_user($userid) { - $results = array(); - $db = get_db(); - $q = $db->query("select * from knownmacs where userid = \"userid\""); - if (!$q) return $results; - while($row = $q->fetch_array(SQLITE_ASSOC)) { - $results[$row['mac']] = $row['name']; - } - return $results; -} - -function known_macs_upsert($mac, $name, $show) { - $db = get_db(); - $mac = $db->escape_string($mac); - $name = $db->escape_string($name); - $show = $db->escape_string($show); - return $db->exec("insert into knownmacs or replace (mac, name, show) values (\"$mac\", \"$name\", \"$show\")"); -} - -function known_macs_translate($macs) { - $known_macs = known_macs_get(); - $results = array(); - foreach($macs as $mac) { - - // no translation info? return as-is - if (!array_key_exists($mac, $known_macs)) { - $results[] = $mac; - continue; - } - - // private mac? skip - if ($known_macs[$mac] == NULL) continue; - - // return translation - $results[] = $known_macs[$mac]; - - } - return $results; -} - -//$mac_translation_table=array( -// '00:30:05:25:b2:f5' => 'appelblauwzeegroen', //192.168.42.11 appelblauwzeegroen FreeBSD 8.0 00:30:05:25:B2:F5 man-ip: 172.16.1.11 -// '00:08:02:c8:56:1f' => 'gitorious', //192.168.42.44 gitorious Ubuntu 8.04 00:08:02:C8:56:1F man-ip: 172.16.1.44 -// '00:0f:66:c8:ac:db' => 'openwrt' //192.168.42.13 openwrt Openwrt 00:0F:66:C8:AC:DB man-ip: 172.16.1.1 -//); diff --git a/macs.php b/macs.php index 24ea293..8b0bfeb 100644 --- a/macs.php +++ b/macs.php @@ -24,7 +24,6 @@ header("Cache-Control: no-cache"); header("Pragma: no-cache"); require_once("config.php"); -require_once("lib/trans.php"); require_once("lib/macs.php"); // for debug purposes, increases the numbers of macs artificially @@ -37,12 +36,12 @@ function multiply() { } } } + $macs = macs_get(); -$macs = known_macs_translate($macs); if (count($macs) > 0) { - //multiply(); - echo '["'.implode('", "', $macs).'"]'; +//multiply(); + echo('["'.implode('", "', $macs).'"]'); } else { - echo '[]'; + echo('[]'); } macs_purge();