diff --git a/index.php b/index.php
index f036195..d754736 100644
--- a/index.php
+++ b/index.php
@@ -10,7 +10,7 @@
* the currently supported data collections/API endpoints in the README.md file
* - this tool currently supports versions 4.x and 5.x of the UniFi Controller software
*
- * VERSION: 1.0.17
+ * VERSION: 1.0.18
*
* ------------------------------------------------------------------------------------
*
@@ -20,7 +20,14 @@
* with this package in the file LICENSE.md
*
*/
-define('API_BROWSER_VERSION', '1.0.17');
+define('API_BROWSER_VERSION', '1.0.18');
+
+/**
+ * check whether the PHP curl module is available
+ */
+if (!function_exists('curl_version')) {
+ exit('The PHP curl module is not installed! Please correct this before you proceed! ');
+}
/**
* in order to use the PHP $_SESSION array for temporary storage of variables, session_start() is required
@@ -61,7 +68,7 @@
* - allows override of several of the previously declared variables
* - if the config.php file is unreadable or does not exist, an alert is displayed on the page
*/
-if(!is_readable('config.php')) {
+if (!is_readable('config.php')) {
$alert_message = '
The file config.php is not readable or does not exist.'
. ' If you have not yet done so, please copy/rename the config.template.php file to config.php and follow '
. 'the instructions inside to enter your credentials and controller details.
HTTP response status: 400'
. ' This is probably caused by a UniFi controller login failure, please check your credentials in '
. 'config.php. After correcting your credentials, please restart your browser or use the Reset PHP session function in the dropdown '
. 'menu on the right, before attempting to use the API browser tool again.
';
- }
- /**
- * Get the list of sites managed by the UniFi controller (if not already stored in the $_SESSION array)
- */
- if (!isset($_SESSION['sites']) || empty($_SESSION['sites'])) {
- $sites = $unifidata->list_sites();
- $_SESSION['sites'] = $sites;
+ /**
+ * to prevent unwanted errors we assign empty values to the following variables
+ */
+ $sites = [];
+ $detected_controller_version = 'undetected';
} else {
- $sites = $_SESSION['sites'];
- }
+ /**
+ * Get the list of sites managed by the UniFi controller (if not already stored in the $_SESSION array)
+ */
+ if (!isset($_SESSION['sites']) || empty($_SESSION['sites'])) {
+ $sites = $unifidata->list_sites();
+ if (is_array($sites)) {
+ $_SESSION['sites'] = $sites;
+ } else {
+ $sites = [];
- /**
- * Get the version of the UniFi controller (if not already stored in the $_SESSION array or when 'undetected')
- */
- if (!isset($_SESSION['detected_controller_version']) || $_SESSION['detected_controller_version'] === 'undetected') {
- $site_info = $unifidata->stat_sysinfo();
+ $alert_message = '
No sites available'
+ . ' This is probably caused by incorrect access rights in the UniFi controller for the credentials provided in '
+ . 'config.php. After updating your credentials, please restart your browser or use the Reset PHP session function in the dropdown '
+ . 'menu on the right, before attempting to use the API browser tool again.