diff --git a/README.md b/README.md index aaf5ff4..1dbfd6a 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,18 @@ The Unifi API browser tool offers the following features: - hourly access point stats - daily site stats - health metrics +- Hotspot + - stat vouchers + - stat payments + - list hotspot operators - Configuration - list sites on this controller - list site settings - sysinfo + - self - wlan config - list VoIP extension + - list network configuration - list port configurations - list port forwarding rules - dynamic DNS configuration @@ -78,14 +84,14 @@ git clone https://github.com/malle-pietje/Unifi-API-browser.git Alternatively you may choose to download the zip file and unzip it in your directory of choice, then follow the configuration steps below. -### Updates -When you have installed the tool using the `git clone` command you can install updates by going into the directory where the tools has been installed, and by running the `git pull` command from there. - ### Configuration - credentials for access to the Unifi Controller API need to be configured in the file named `config.template.php` which should be copied/renamed to `config.php` before using the Unifi API browser tool - please see the `config.template.php` file for further instructions - after following these steps, you can open the tool in your browser (assuming you installed it in the root folder of your web server as suggested above) by going to this url: `http://serverip/Unifi-API-browser/` +### Updates +If you have installed the tool using the `git clone` command, you can install updates by going into the directory where the tool has been installed, and running the `git pull` command from there. + ### Security notice The use of this tool is **not secured in any way**! Make sure to prevent unauthorised access to it, preventing exposure of details and credentials such as user names and passwords for access to the Unifi controller! diff --git a/config.template.php b/config.template.php index 6af9672..09d2a91 100644 --- a/config.template.php +++ b/config.template.php @@ -29,4 +29,5 @@ $controllerversion = ''; // the version of the Controller software, eg. '4.6.6' (must be at least 4.0.0) $cookietimeout = '3600'; // time of inactivity in seconds, after which the PHP session cookie will be refreshed // this means the site and data collection will need to be selected again +$debug = false; // set to true (without quotes) to enable debug output to the browser and PHP error log ?> \ No newline at end of file diff --git a/index.php b/index.php index a558598..bd5bdb5 100644 --- a/index.php +++ b/index.php @@ -46,6 +46,7 @@ $objectscount = ''; $alertmessage = ''; $cookietimeout = '1800'; +$debug = false; /* load the settings file @@ -81,38 +82,12 @@ /* process the GET variables and store them in the $_SESSION array, if a GET variable is not set, get the value from $_SESSION (if available) +- siteid +Only process these after siteid is set: - action - outputformat - theme -- siteid */ -if (isset($_GET['action'])) { - $action = $_GET['action']; - $_SESSION['action'] = $action; -} else { - if (isset($_SESSION['action'])) { - $action = $_SESSION['action']; - } -} - -if (isset($_GET['outputformat'])) { - $outputformat = $_GET['outputformat']; - $_SESSION['outputformat'] = $outputformat; -} else { - if (isset($_SESSION['outputformat'])) { - $outputformat = $_SESSION['outputformat']; - } -} - -if (isset($_GET['theme'])) { - $theme = $_GET['theme']; - $_SESSION['theme'] = $theme; -} else { - if (isset($_SESSION['theme'])) { - $theme = $_SESSION['theme']; - } -} - if (isset($_GET['siteid'])) { $siteid = $_GET['siteid']; $_SESSION['siteid'] = $siteid; @@ -122,6 +97,33 @@ if (isset($_SESSION['siteid'])) { $siteid = $_SESSION['siteid']; $sitename = $_SESSION['sitename']; + + if (isset($_GET['action'])) { + $action = $_GET['action']; + $_SESSION['action'] = $action; + } else { + if (isset($_SESSION['action'])) { + $action = $_SESSION['action']; + } + } + + if (isset($_GET['outputformat'])) { + $outputformat = $_GET['outputformat']; + $_SESSION['outputformat'] = $outputformat; + } else { + if (isset($_SESSION['outputformat'])) { + $outputformat = $_SESSION['outputformat']; + } + } + + if (isset($_GET['theme'])) { + $theme = $_GET['theme']; + $_SESSION['theme'] = $theme; + } else { + if (isset($_SESSION['theme'])) { + $theme = $_SESSION['theme']; + } + } } } @@ -130,12 +132,10 @@ placed here so they can be overwritten by more "severe" error messages later down */ if ($action === '') { - $alertmessage = ''; + $alertmessage = ''; } if ($siteid === '') { - $alertmessage = ''; + $alertmessage = ''; } /* @@ -144,8 +144,9 @@ */ require('phpapi/class.unifi.php'); -$unifidata = new unifiapi($controlleruser, $controllerpassword, $controllerurl, $siteid, $controllerversion); -$loginresults = $unifidata->login(); +$unifidata = new unifiapi($controlleruser, $controllerpassword, $controllerurl, $siteid, $controllerversion); +$unifidata->debug = $debug; +$loginresults = $unifidata->login(); if($loginresults === 400) { $alertmessage = '