diff --git a/config.template.php b/config.template.php
index 8940ba3..d460f43 100644
--- a/config.template.php
+++ b/config.template.php
@@ -2,7 +2,7 @@
/*
The MIT License (MIT)
-Copyright (c) 2015, Slooffmaster
+Copyright (c) 2016, Slooffmaster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -23,14 +23,15 @@
THE SOFTWARE.
*/
-$controlleruser = ''; // the user name for access to the Unifi Controller
-$controllerpassword = ''; // the password for access to the Unifi Controller
-$controllerurl = ''; // full url to the Unifi Controller, eg. 'https://22.22.11.11:8443'
-$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
-$theme = 'bootstrap'; // your default theme of choice, pick one from the list below
- // bootstrap/cerulean/cosmo/cyborg/darkly/flatly/journal/lumen/paper/
- // readable/sandstone/simplex/slate/spacelab/superhero/united/yeti
-$debug = false; // set to true (without quotes) to enable debug output to the browser and PHP error log
+$controlleruser = ''; // the user name for access to the Unifi Controller
+$controllerpassword = ''; // the password for access to the Unifi Controller
+$controllerurl = ''; // full url to the Unifi Controller, eg. 'https://22.22.11.11:8443'
+$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
+ // after the cookie refresh the site and data collection will need to be selected again
+$theme = 'bootstrap'; /* your default theme of choice, pick one from the list below
+ bootstrap, cerulean, cosmo, cyborg, darkly, flatly, journal, lumen, paper
+ readable, sandstone, simplex, slate, spacelab, superhero, united, yeti
+ */
+$debug = false; // set to true (without quotes) to enable debug output to the browser and the PHP error log
?>
\ No newline at end of file
diff --git a/index.php b/index.php
index e37d5a4..1e5c6f0 100644
--- a/index.php
+++ b/index.php
@@ -14,13 +14,13 @@
Ubiquiti Community forums for this:
https://community.ubnt.com/t5/UniFi-Wireless/Unifi-API-browser-tool-released/m-p/1392651
-VERSION: 1.0.1
+VERSION: 1.0.2
------------------------------------------------------------------------------------
The MIT License (MIT)
-Copyright (c) 2015, Slooffmaster
+Copyright (c) 2016, Slooffmaster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -56,14 +56,14 @@
assign variables which are required later on together with their default values
*/
$action = '';
-$siteid = '';
-$sitename = '';
+$site_id = '';
+$site_name = '';
$selection = '';
-$outputformat = 'json';
+$output_format = 'json';
$theme = 'bootstrap';
$data = '';
-$objectscount = '';
-$alertmessage = '';
+$objects_count = '';
+$alert_message = '';
$cookietimeout = '1800';
$debug = false;
@@ -73,7 +73,7 @@
- if the config.php file is unreadable or does not exist, an alert is displayed on the page
*/
if(!is_readable('config.php')) {
- $alertmessage = '
The file config.php is not readable or does not exist.'
+ $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 modify'
. 'the contents as required.
';
}
@@ -102,21 +102,21 @@
/*
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:
+- site_id
+Only process these after site_id is set:
- action
-- outputformat
+- output_format
- theme
*/
-if (isset($_GET['siteid'])) {
- $siteid = $_GET['siteid'];
- $_SESSION['siteid'] = $siteid;
- $sitename = $_GET['sitename'];
- $_SESSION['sitename'] = $sitename;
+if (isset($_GET['site_id'])) {
+ $site_id = $_GET['site_id'];
+ $_SESSION['site_id'] = $site_id;
+ $site_name = $_GET['site_name'];
+ $_SESSION['site_name'] = $site_name;
} else {
- if (isset($_SESSION['siteid'])) {
- $siteid = $_SESSION['siteid'];
- $sitename = $_SESSION['sitename'];
+ if (isset($_SESSION['site_id'])) {
+ $site_id = $_SESSION['site_id'];
+ $site_name = $_SESSION['site_name'];
if (isset($_GET['action'])) {
$action = $_GET['action'];
@@ -127,12 +127,12 @@
}
}
- if (isset($_GET['outputformat'])) {
- $outputformat = $_GET['outputformat'];
- $_SESSION['outputformat'] = $outputformat;
+ if (isset($_GET['output_format'])) {
+ $output_format = $_GET['output_format'];
+ $_SESSION['output_format'] = $output_format;
} else {
- if (isset($_SESSION['outputformat'])) {
- $outputformat = $_SESSION['outputformat'];
+ if (isset($_SESSION['output_format'])) {
+ $output_format = $_SESSION['output_format'];
}
}
@@ -152,11 +152,11 @@
placed here so they can be overwritten by more "severe" error messages later down
*/
if ($action === '') {
- $alertmessage = '
Please select a data collection/API endpoint from the drop-down menus'
+ $alert_message = '
Please select a data collection/API endpoint from the drop-down menus'
. '
';
}
-if ($siteid === '') {
- $alertmessage = '
Please select a site from the drop-down menu '
+if ($site_id === '') {
+ $alert_message = '
Please select a site from the drop-down menu '
. '
HTTP response status: 400'
. ' This is probably caused by a Unifi controller login failure, please check your credentials in '
. 'config.php
';
}
@@ -190,7 +190,7 @@
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
*/
-if($siteid != '') {
+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;
@@ -205,8 +205,8 @@
/*
execute timing of controller login
*/
-$time_1 = microtime(true);
-$timeafterlogin = $time_1 - $time_start;
+$time_1 = microtime(true);
+$time_after_login = $time_1 - $time_start;
/*
select the required call to the Unifi Controller API based on the selected action
@@ -344,7 +344,7 @@
count the number of objects collected from the controller
*/
if($action!=''){
- $objectscount = count($data);
+ $objects_count = count($data);
}
/*
@@ -359,28 +359,28 @@
/*
execute timing of data collection from controller
*/
-$time_2 = microtime(true);
-$timeafterload = $time_2 - $time_start;
+$time_2 = microtime(true);
+$time_after_load = $time_2 - $time_start;
/*
calculate all the timings/percentages
*/
-$time_end = microtime(true);
-$timetotal = $time_end - $time_start;
-$loginperc = ($timeafterlogin/$timetotal)*100;
-$loadperc = (($timeafterload - $timeafterlogin)/$timetotal)*100;
-$remainperc = 100-$loginperc-$loadperc;
+$time_end = microtime(true);
+$time_total = $time_end - $time_start;
+$login_perc = ($time_after_login/$time_total)*100;
+$load_perc = (($time_after_load - $time_after_login)/$time_total)*100;
+$remain_perc = 100-$login_perc-$load_perc;
/*
shared functions
*/
-function print_output($outputformat, $data)
+function print_output($output_format, $data)
{
/*
function to print the output
- switch depending on the selected $outputformat
+ switch depending on the selected $output_format
*/
- switch ($outputformat) {
+ switch ($output_format) {
case 'json':
echo json_encode($data, JSON_PRETTY_PRINT);
break;
@@ -407,7 +407,7 @@ function to print the output
/*
log off from the Unifi controller API
*/
-$logoutresults = $unifidata->logout();
+$logout_results = $unifidata->logout();
?>
@@ -422,9 +422,9 @@ function to print the output
@@ -450,13 +450,13 @@ function to print the output