Skip to content

Commit

Permalink
UniFi API browser 2.0.16
Browse files Browse the repository at this point in the history
- updated PHP API client to 1.1.64
- several minor code changes based on Code Inspector feedback
- added check in `index.php` to verify whether `$users` array exists and isn't empty, thanks to @scyto for submitting PR #85
- applied default payload for `stat_monthly_gateway()` to collect all available metrics
  • Loading branch information
malle-pietje committed Jan 21, 2021
1 parent c75e2c5 commit c35123a
Show file tree
Hide file tree
Showing 51 changed files with 369 additions and 346 deletions.
10 changes: 5 additions & 5 deletions ajax/fetch_about_modal_metrics.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
Expand All @@ -11,16 +11,16 @@
/**
* load the files containing shared functions and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once '../common.php';
require_once '../collections.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down
19 changes: 11 additions & 8 deletions ajax/fetch_collection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
Expand All @@ -12,17 +12,17 @@
* load required packages using the composer autoloader together with the files containing shared functions
* and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once('../vendor/autoload.php');
require_once '../common.php';
require_once '../collections.php';
require_once '../vendor/autoload.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down Expand Up @@ -118,7 +118,10 @@
break;
case 'stat_daily_gateway':
$params = [null, null, $gateway_stats_attribs];
}

break;
case 'stat_monthly_gateway':
$params = [null, null, $gateway_stats_attribs]; }
}

if (!empty($method) && !empty($site_id)) {
Expand Down Expand Up @@ -212,4 +215,4 @@
header('Content-Type: application/json; charset=utf-8');
echo (json_encode($results));

$_SESSION['memory_used'] = round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'M';
$_SESSION['memory_used'] = round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'MB';
14 changes: 7 additions & 7 deletions ajax/fetch_sites.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
Expand All @@ -12,17 +12,17 @@
* load required packages using the composer autoloader together with the files containing shared functions
* and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once('../vendor/autoload.php');
require_once '../common.php';
require_once '../collections.php';
require_once '../vendor/autoload.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down Expand Up @@ -141,4 +141,4 @@
header('Content-Type: application/json; charset=utf-8');
echo (json_encode($results));

$_SESSION['memory_used'] = round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'M';
$_SESSION['memory_used'] = round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'MB';
12 changes: 6 additions & 6 deletions ajax/show_api_debug.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
Expand All @@ -12,17 +12,17 @@
* load required packages using the composer autoloader together with the files containing shared functions
* and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once('../vendor/autoload.php');
require_once '../common.php';
require_once '../collections.php';
require_once '../vendor/autoload.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down
14 changes: 6 additions & 8 deletions ajax/update_controller.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
* load required files containing shared functions and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once '../common.php';
require_once '../collections.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down
14 changes: 6 additions & 8 deletions ajax/update_theme.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
* load required files containing shared functions and the collections
*/
require_once('../common.php');
require_once('../collections.php');
require_once '../common.php';
require_once '../collections.php';

/**
* load the configuration file if readable
*/
if (is_file('../config/config.php') && is_readable('../config/config.php')) {
include('../config/config.php');
include '../config/config.php';
} else {
die();
exit;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions collections.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
Expand Down
13 changes: 5 additions & 8 deletions common.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/
define('TOOL_VERSION', '2.0.15');
define('TOOL_VERSION', '2.0.16');

/**
* gather some basic information for the About modal
*/
$curl_info = curl_version();
$unknown_string = 'unknown';

/**
* create the array to pass on to the twig templates
*/
$about_modal_params = [
'os_version' => php_uname('s') . ' ' . php_uname('r'),
'php_version' => phpversion(),
'memory_limit' => ini_get('memory_limit'),
'memory_used' => round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'M',
'memory_limit' => ini_get('memory_limit') . 'B',
'memory_used' => round(memory_get_peak_usage(false) / 1024 / 1024, 2) . 'MB',
'curl_version' => $curl_info['version'],
'openssl_version' => $curl_info['ssl_version'],
'api_client_version' => getClientVersion(),
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions config/config-template.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
Expand Down
6 changes: 2 additions & 4 deletions config/users-template.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
Expand Down
29 changes: 16 additions & 13 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
/**
* Copyright (c) 2019, Art of WiFi
* Copyright (c) 2021, Art of WiFi
* www.artofwifi.net
*
* This file is subject to the MIT license that is bundled
* with this package in the file LICENSE.md
*
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
*/

/**
Expand All @@ -32,9 +30,9 @@
* load required packages using the composer autoloader together with the files containing shared functions
* and the collections
*/
require_once('vendor/autoload.php');
require_once('common.php');
require_once('collections.php');
require_once 'vendor/autoload.php';
require_once 'common.php';
require_once 'collections.php';

/**
* initialize the Twig loader early on in case we need to render the error page
Expand All @@ -47,7 +45,7 @@
* - if not, stop and display an error message
*/
if (is_file('config/config.php') && is_readable('config/config.php')) {
require_once('config/config.php');
require_once 'config/config.php';
} else {
/**
* render the config error page
Expand All @@ -56,7 +54,7 @@
'error_message' => 'The file <b>config/config.php</b> does not exist! Please create one based on the <b>config/config-template.php</b> file!<br>',
]);

exit();
exit;
}

/**
Expand All @@ -81,7 +79,7 @@
'error_message' => 'The <b>PHP curl</b> module is not installed! Please correct this before proceeding!<br>',
]);

exit();
exit;
}

/**
Expand All @@ -96,15 +94,20 @@
'error_message' => 'The current PHP version (' . PHP_VERSION . ') does not meet the minimum required version which is 5.6.0. Please upgrade before proceeding!<br>',
]);

exit();
exit;
}

/**
* load the file containing user accounts, if readable
*/
if (is_file('config/users.php') && is_readable('config/users.php')) {
require_once('config/users.php');
$user_authentication = true;
require_once 'config/users.php';
if (isset($users) && is_array($users) && count($users) > 0) {
$user_authentication = true;
} else {
$user_authentication = false;
error_log('The $users array in the config/users.php file does not exist or is empty, proceeding without user authentication.');
}
} else {
$user_authentication = false;
error_log('The file config/users.php does not exist, proceeding without user authentication.');
Expand Down
Loading

0 comments on commit c35123a

Please sign in to comment.