$value) { if ($value != '') { switch ($var) { case 'device': case 'device_id': $where .= generate_query_values_and($value, 'device_id'); break; case 'address': if (isset($vars['searchby']) && $vars['searchby'] === 'ip') { $value = trim($value); $where .= generate_query_values_and($value, 'ipv4_addr', '%LIKE%'); } elseif (isset($vars['searchby']) && $vars['searchby'] === 'mac') { $value = str_replace([':', ' ', '-', '.', '0x'], '', $value); $where .= generate_query_values_and($value, 'M.mac_addr', '%LIKE%'); } else { $value = trim($value); $where .= generate_query_values_and($value, 'username', '%LIKE%'); } break; } } } // Check permissions $query_permitted = generate_query_permitted(['device'], ['device_table' => 'M']); $query = 'FROM `wifi_sessions` AS M '; $query .= 'LEFT JOIN `wifi_radios` AS I ON I.`wifi_radio_id` = M.`radio_id` '; $query .= $where . $query_permitted; $query_count = 'SELECT COUNT(`wifi_session_id`) ' . $query; $query = 'SELECT *, M.`mac_addr` AS `session_mac` ' . $query; $query .= ' ORDER BY M.`timestamp` DESC'; $query .= " LIMIT $start,$pagesize"; // Query wireless sessions table $entries = dbFetchRows($query, $param); // Query wireless sessions table count if ($pagination) { $count = dbFetchCell($query_count, $param); } $aps_db = dbFetchRows("SELECT `wifi_accesspoint_id`, `name`, `ap_number` FROM `wifi_accesspoints`"); foreach ($aps_db as $ap_db) { $aps_sorted_db[$ap_db['wifi_accesspoint_id']] = $ap_db; } $list = ['device' => FALSE, 'port' => FALSE]; // A radio is like a port if (!isset($vars['device']) || empty($vars['device']) || $vars['page'] == 'search') { $list['device'] = TRUE; } if (!isset($vars['port']) || empty($vars['port']) || $vars['page'] == 'search') { $list['port'] = TRUE; } $string = generate_box_open(); $string .= '' . PHP_EOL; if (!$short) { $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; if ($list['device']) { $string .= ' ' . PHP_EOL; } if ($list['port']) { $string .= ' ' . PHP_EOL; } $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; } $string .= ' ' . PHP_EOL; foreach ($entries as $entry) { $ap_id = $entry['accesspoint_id']; $interface = $aps_sorted_db[$ap_id]['name']; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; $string .= ' ' . PHP_EOL; if ($list['device']) { $dev = device_by_id_cache($entry['device_id']); $string .= ' ' . PHP_EOL; } if ($list['port']) { $string .= ' ' . PHP_EOL; } $string .= ' ' . PHP_EOL; } $string .= ' ' . PHP_EOL; $string .= '
MAC AddressIP AddressUsernameSSID/VLANLast SeenDeviceInterface/AP
' . generate_popup_link('mac', format_mac($entry['session_mac'])) . '' . generate_popup_link('ip', $entry['ipv4_addr']) . '' . $entry['username'] . '' . $entry['ssid'] . '' . $entry['timestamp'] . '' . generate_device_link($dev) . '' . $interface . '
'; $string .= generate_box_close(); // Print pagination header if ($pagination) { $string = pagination($vars, $count) . $string . pagination($vars, $count); } // Print wireless sessions echo $string; } // EOF