diff --git a/README.md b/README.md index 943eb3d..b30d033 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ The UniFi API browser tool offers the following features: - hourly site stats - hourly access point stats - daily site stats + - all sites stats (supported on controller version 5.2.9 and higher) - health metrics - dashboard metrics (supported on controller version 4.9.1.alpha and higher) - port forward stats diff --git a/index.php b/index.php index 0e86afd..b5d952f 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ * Ubiquiti Community forums for this: * https://community.ubnt.com/t5/UniFi-Wireless/UniFi-API-browser-tool-released/m-p/1392651 * - * VERSION: 1.0.3 + * VERSION: 1.0.4 * * ------------------------------------------------------------------------------------ * @@ -25,7 +25,7 @@ * */ -define('API_BROWSER_VERSION', '1.0.3'); +define('API_BROWSER_VERSION', '1.0.4'); /** * to use the PHP $_SESSION array for temporary storage of variables, session_start() is required @@ -51,6 +51,7 @@ $alert_message = ''; $cookietimeout = '1800'; $debug = false; +$detected_controller_version = ''; /** * load the configuration file @@ -105,6 +106,7 @@ unset($_SESSION['site_id']); unset($_SESSION['site_name']); unset($_SESSION['sites']); + unset($_SESSION['detected_controller_version']); } else { if (isset($_SESSION['controller']) && isset($controllers)) { $controller = $_SESSION['controller']; @@ -214,19 +216,19 @@ } /** - * get the version of the controller (if not already stored in $_SESSION or when empty) - * only get the version once a site has been selected + * Get the version of the controller (if not already stored in $_SESSION or when empty) */ - if($site_id != '') { - if (!isset($_SESSION['detected_controller_version']) || $_SESSION['detected_controller_version'] === '') { - $site_info = $unifidata->stat_sysinfo(); - $detected_controller_version = $site_info[0]->version; - $_SESSION['detected_controller_version'] = $detected_controller_version; + if (!isset($_SESSION['detected_controller_version']) || $_SESSION['detected_controller_version'] == '') { + $site_info = $unifidata->stat_sysinfo(); + $detected_controller_version = $site_info[0]->version; + + if ($detected_controller_version == '') { + $_SESSION['detected_controller_version'] = 'undetected'; } else { - $detected_controller_version = $_SESSION['detected_controller_version']; + $_SESSION['detected_controller_version'] = $detected_controller_version; } } else { - $detected_controller_version = 'undetected'; + $detected_controller_version = $_SESSION['detected_controller_version']; } } @@ -364,6 +366,10 @@ $selection = 'self'; $data = $unifidata->list_self(); break; + case 'stat_sites': + $selection = 'all site stats'; + $data = $unifidata->stat_sites(); + break; default: break; } @@ -432,6 +438,14 @@ function print_output($output_format, $data) } } +/** + * function to sort the sites collection + */ +function sites_sort($a, $b) +{ + return strcmp($a->desc, $b->desc); +} + if (isset($_SESSION['controller'])) { /** * log off from the UniFi controller API @@ -454,6 +468,12 @@ function print_output($output_format, $data) body { padding-top: 70px; } + + .scrollable-menu { + height: auto; + max-height: 600px; + overflow-x: hidden; + } @@ -466,7 +486,7 @@ function print_output($output_format, $data) - UniFi API browser +