From 3b85a62d457db5b83e6804a0c03550894438e19d Mon Sep 17 00:00:00 2001 From: sandb Date: Fri, 12 Feb 2010 23:24:19 +0100 Subject: [PATCH] support for simple fixed translation table --- config.php | 2 +- js/input.php | 10 ---------- lib/trans.php | 6 ++++++ macs.php | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 11 deletions(-) delete mode 100644 js/input.php create mode 100644 lib/trans.php diff --git a/config.php b/config.php index 885f96a..9e24e6d 100644 --- a/config.php +++ b/config.php @@ -1,6 +1,6 @@ [ "00:01:e8:04:99:be", -"00:04:23:ac:54:f9", -"00:0a:e4:3b:fa:33", -"00:11:85:6a:1f:ec", -"00:13:77:bd:ec:2b", -"00:16:d3:82:ab:ca", -"00:1a:4b:7a:eb:14", -"00:21:70:8a:87:68", -"00:21:70:b0:c5:49", -"08:8c:88:1b:07:31", ] diff --git a/lib/trans.php b/lib/trans.php new file mode 100644 index 0000000..8c08404 --- /dev/null +++ b/lib/trans.php @@ -0,0 +1,6 @@ + '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 f81f2a2..5586166 100644 --- a/macs.php +++ b/macs.php @@ -25,9 +25,19 @@ header("Pragma: no-cache"); require_once("config.php"); require_once("lib/util.php"); +require_once("lib/trans.php"); // [ "00:01:e8:04:99:be", "00:05:4e:40:1e:97", "00:0c:f1:16:10:ba", "00:0c:f1:1d:dc:70", "00:0e:35:96:c7:ff", "00:11:85:6a:1f:ec", ] + +function translator($mac) { + global $mac_translation_table; + if (array_key_exists($mac, $mac_translation_table)) + return $mac_translation_table[$mac]; + return $mac; +} + + class Macs { private $macs; @@ -62,6 +72,10 @@ class Macs { private function cleanUp() { $this->macs = array_unique($this->macs); } + + private function translate() { + $this->macs = array_map("translator", $this->macs); + } private function createJson() { if (count($this->macs) < 1) { @@ -77,6 +91,7 @@ class Macs { public function run() { $this->readFiles(OUTPUT_SERVER_DIRECTORY); $this->cleanUp(); + $this->translate(); $this->createJson(); }