Prima aggiunta lettura vendor

This commit is contained in:
loviuz 2020-08-08 19:10:47 +02:00
parent 0e9ca4b91e
commit 0fca421b77
2 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
[ws] [ws]
receiver_url = "http://localhost/wifi-probe-aggregator/ws/receiver.php" receiver_url = "http://localhost/wifi-probe-aggregator/ws/receiver.php"
reader_url = "http://localhost/wifi-probe-aggregator/ws/reader.php" reader_url = "http://localhost/wifi-probe-aggregator/ws/reader.php"
oui_path = "/var/lib/ieee-data/oui.txt"
[database] [database]
db_host = "localhost" db_host = "localhost"

View File

@ -10,6 +10,8 @@ $result = [];
switch( $_POST['op'] ){ switch( $_POST['op'] ){
case 'get-last-devices': case 'get-last-devices':
$oui = file_get_contents($config['oui_path']);
if (!empty($_POST['date_start']) && !empty($_POST['date_end'])) { if (!empty($_POST['date_start']) && !empty($_POST['date_end'])) {
// Connessione al database // Connessione al database
$mysqli = mysqli_connect($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']); $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; $records[] = $row;
} }