From 0fca421b7732853d1f5101c54e0248d36bdb0723 Mon Sep 17 00:00:00 2001 From: loviuz Date: Sat, 8 Aug 2020 19:10:47 +0200 Subject: [PATCH] Prima aggiunta lettura vendor --- config.ini.example | 1 + ws/reader.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/config.ini.example b/config.ini.example index 06a6026..816dbae 100755 --- a/config.ini.example +++ b/config.ini.example @@ -1,6 +1,7 @@ [ws] receiver_url = "http://localhost/wifi-probe-aggregator/ws/receiver.php" reader_url = "http://localhost/wifi-probe-aggregator/ws/reader.php" +oui_path = "/var/lib/ieee-data/oui.txt" [database] db_host = "localhost" diff --git a/ws/reader.php b/ws/reader.php index e33b39b..e2a1254 100644 --- a/ws/reader.php +++ b/ws/reader.php @@ -10,6 +10,8 @@ $result = []; switch( $_POST['op'] ){ case 'get-last-devices': + $oui = file_get_contents($config['oui_path']); + if (!empty($_POST['date_start']) && !empty($_POST['date_end'])) { // Connessione al database $mysqli = mysqli_connect($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']); @@ -55,6 +57,15 @@ switch( $_POST['op'] ){ } } + // Lettura vendor + $mac = str_replace( ':', '-', substr($row['mac'], 0, 8) ); + + $row['vendor'] = ''; + + if( preg_match( '/^'.preg_quote($mac).'([\s\t]+)\(hex\)(.+?)$/im', $oui, $m) ){ + $row['vendor'] = trim($m[2]); + } + $records[] = $row; }