diff --git a/app/dashboard/widgets/mac-lookup.php b/app/dashboard/widgets/mac-lookup.php
new file mode 100644
index 000000000..d2d74fc09
--- /dev/null
+++ b/app/dashboard/widgets/mac-lookup.php
@@ -0,0 +1,59 @@
+check_user_session();
+
+# if direct request that redirect to tools page
+if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
+ header("Location: " . create_link("tools", "mac-lookup"));
+}
+?>
+
+
+
+
\ No newline at end of file
diff --git a/app/tools/mac-lookup/results.php b/app/tools/mac-lookup/results.php
index 881dcb3c2..1b01352de 100644
--- a/app/tools/mac-lookup/results.php
+++ b/app/tools/mac-lookup/results.php
@@ -1,28 +1,34 @@
check_user_session();
// trim and escape
-$mac = escape_input(trim($_POST['mac']));
+$mac = isset($_POST['mac']) ? escape_input(trim($_POST['mac'])) : "";
// validate
-if($User->validate_mac ($mac)===false) {
- $Result->show("warning", _("Invalid MAC address provided")." - ".$mac, false);
-}
-else {
+if ($User->validate_mac($mac) === false) {
+ $Result->show("warning", _("Invalid MAC address provided") . " - " . $mac, false);
+} else {
// check
- $mac_vendor = $User->get_mac_address_vendor_details ($mac);
+ $mac_vendor = $User->get_mac_address_vendor_details($mac, $prefix);
// print
- if($mac_vendor=="") {
- $Result->show("info", _("No matches found for prefix")." ".$mac, false);
- }
- else {
- $mac = strtoupper($User->reformat_mac_address ($mac, 1));
- $mac_partial = explode(":", $mac);
+ if ($mac_vendor == "") {
+ $Result->show("info", _("No matches found for prefix") . " " . $mac, false);
+ } else {
+ $mac = strtoupper($User->reformat_mac_address($mac, 1));
+
// print
- print "Vendor: ".$mac_vendor."
";
- print "Prefix: ".$mac_partial[0].":".$mac_partial[1].":".$mac_partial[2]."
";
- print "MAC: ".$mac;
+ print "Vendor: " . escape_input($mac_vendor) . "
";
+ print "Prefix: " . escape_input($prefix) . "
";
+ print "MAC: " . $mac;
}
-}
\ No newline at end of file
+}
diff --git a/db/SCHEMA.sql b/db/SCHEMA.sql
index 7ef3ebc4d..4d7038681 100755
--- a/db/SCHEMA.sql
+++ b/db/SCHEMA.sql
@@ -588,7 +588,8 @@ VALUES
(15, 'Locations', 'Shows map of locations', 'locations', NULL, 'yes', '6', 'no', 'yes'),
(16, 'Bandwidth calculator', 'Calculate bandwidth', 'bw_calculator', NULL, 'no', '6', 'no', 'yes'),
(17, 'Customers', 'Shows customer list', 'customers', NULL, 'yes', '6', 'no', 'yes'),
- (18, 'User Instructions', 'Shows user instructions', 'instructions', NULL, 'yes', '6', 'no', 'yes');
+ (18, 'User Instructions', 'Shows user instructions', 'instructions', NULL, 'yes', '6', 'no', 'yes'),
+ (19, 'MAC lookup', 'Shows MAC address vendor', 'mac-lookup', NULL, 'yes', '6', 'no', 'yes');
@@ -1058,4 +1059,4 @@ CREATE TABLE `nominatim_cache` (
# ------------------------------------------------------------
UPDATE `settings` SET `version` = "1.5";
-UPDATE `settings` SET `dbversion` = 38;
+UPDATE `settings` SET `dbversion` = 39;
diff --git a/functions/classes/class.Common.php b/functions/classes/class.Common.php
index 478c5e543..5872d2cb1 100644
--- a/functions/classes/class.Common.php
+++ b/functions/classes/class.Common.php
@@ -1798,9 +1798,10 @@ public function show_mac_and_vendor($mac) {
*
* @method get_mac_address_vendor
* @param string $mac
+ * @param string &$prefix
* @return string
*/
- public function get_mac_address_vendor_details($mac) {
+ public function get_mac_address_vendor_details($mac, &$prefix=null) {
if (strlen($mac) < 4 || !$this->validate_mac($mac)) {
return "";
}
@@ -1818,6 +1819,7 @@ public function get_mac_address_vendor_details($mac) {
while (strlen($search_mac) > 0) {
if (isset($this->mac_address_vendors[$search_mac])) {
+ $prefix = implode(":", str_split(strtoupper($search_mac), 2));
return $this->mac_address_vendors[$search_mac];
}
diff --git a/functions/upgrade_queries/upgrade_queries_1.5.php b/functions/upgrade_queries/upgrade_queries_1.5.php
index cf441cc37..6b7a6968c 100644
--- a/functions/upgrade_queries/upgrade_queries_1.5.php
+++ b/functions/upgrade_queries/upgrade_queries_1.5.php
@@ -170,7 +170,6 @@
// Truncated change log errors, module defaults, MariaDB Galera compatibility
$upgrade_queries["1.5.38"] = [];
-
$upgrade_queries["1.5.38"][] = "ALTER TABLE `logs` CHANGE `command` `command` text DEFAULT NULL;";
$upgrade_queries["1.5.38"][] = "ALTER TABLE `logs` CHANGE `details` `details` text DEFAULT NULL;";
$upgrade_queries["1.5.38"][] = "ALTER TABLE `changelog` CHANGE `caction` `caction` ENUM('add','edit','delete','truncate','resize','perm_change') NOT NULL DEFAULT 'edit';";
@@ -179,6 +178,11 @@
$upgrade_queries["1.5.38"][] = "ALTER TABLE `users` CHANGE `module_permissions` `module_permissions` varchar(255) DEFAULT '{\"vlan\":\"1\",\"l2dom\":\"1\",\"vrf\":\"1\",\"pdns\":\"1\",\"circuits\":\"1\",\"racks\":\"1\",\"nat\":\"1\",\"pstn\":\"1\",\"customers\":\"1\",\"locations\":\"1\",\"devices\":\"1\",\"routing\":\"1\",\"vaults\":\"1\"}';";
$upgrade_queries["1.5.38"][] = "ALTER TABLE `firewallZoneSubnet` ADD PRIMARY KEY (`zoneId`,`subnetId`);";
$upgrade_queries["1.5.38"][] = "ALTER TABLE `circuitsLogicalMapping` ADD PRIMARY KEY (`logicalCircuit_id`, `circuit_id`);";
-
$upgrade_queries["1.5.38"][] = "-- Database version bump";
-$upgrade_queries["1.5.38"][] = "UPDATE `settings` set `dbversion` = '38';";
\ No newline at end of file
+$upgrade_queries["1.5.38"][] = "UPDATE `settings` set `dbversion` = '38';";
+
+// MAC lookup widget
+$upgrade_queries["1.5.39"] = [];
+$upgrade_queries["1.5.39"][] = "INSERT INTO `widgets` (`wtitle`, `wdescription`, `wfile`, `wparams`, `whref`, `wsize`, `wadminonly`, `wactive`) VALUES ('MAC lookup', 'Shows MAC address vendor', 'mac-lookup', NULL, 'yes', '6', 'no', 'yes');";
+$upgrade_queries["1.5.39"][] = "-- Database version bump";
+$upgrade_queries["1.5.39"][] = "UPDATE `settings` set `dbversion` = '39';";
diff --git a/misc/CHANGELOG b/misc/CHANGELOG
index 96525356a..9893a6a36 100755
--- a/misc/CHANGELOG
+++ b/misc/CHANGELOG
@@ -11,6 +11,7 @@
+ Added Vaults (Certificate andf password storing);
+ Added Tools->Duplicate subnets & IP page;
+ Added config.php offline_mode to disable server-side Internet lookups (#3462);
+ + Added MAC vendor lookup widget;
Enhancements, changes:
----------------------------