Skip to content

Commit bb6fa34

Browse files
committed
UniFi API browser 2.0.8
- included PHP API client version 1.1.49 - minor changes and improvements
1 parent 55843a5 commit bb6fa34

File tree

9 files changed

+151
-138
lines changed

9 files changed

+151
-138
lines changed

ajax/fetch_sites.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
* we first check for connectivity to the host and port provided in the URL
4848
*/
4949
$host = parse_url($controller['url'], PHP_URL_HOST);
50-
$port = parse_url($controller['url'], PHP_URL_PORT);
51-
$port = $port ?: 443;
50+
$port = parse_url($controller['url'], PHP_URL_PORT) ?: 443;
5251

5352
if (!empty($host) && !empty($port)) {
5453
$fp = @fsockopen($host, $port, $errno, $errstr, 2);

ajax/show_api_debug.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
* we first check for connectivity to the host and port provided in the URL
3939
*/
4040
$host = parse_url($controller['url'], PHP_URL_HOST);
41-
$port = parse_url($controller['url'], PHP_URL_PORT);
42-
$port = $port ?: 443;
41+
$port = parse_url($controller['url'], PHP_URL_PORT) ?: 443;
4342

4443
if (!empty($host) && !empty($port)) {
4544
$fp = @fsockopen($host, $port, $errno, $errstr, 2);

ajax/update_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
/**
4747
* we also unset the cookie for access to the UniFi controller
4848
*/
49-
unset($_SESSION['unificookie']);
49+
$_SESSION['unificookie'] = '';
5050
} else {
5151
$results['status'] = 'error';
5252
$results['message'] = 'empty POST';

common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* with this package in the file LICENSE.md
88
*
99
*/
10-
define('TOOL_VERSION', '2.0.7');
10+
define('TOOL_VERSION', '2.0.8');
1111

1212
/**
1313
* gather some basic information for the About modal

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/custom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var theme = 'bootstrap',
2424
/**
2525
* check whether user has stored a custom theme, if yes we switch to the stored value
2626
*/
27-
if (localStorage.getItem('api_browser_tool_theme') == null || localStorage.getItem('api_browser_tool_theme') === 'bootstrap') {
27+
if (localStorage.getItem('api_browser_tool_theme') === null || localStorage.getItem('api_browser_tool_theme') === 'bootstrap') {
2828
$('#bootstrap').addClass('active').find('a').append(' <i class="fas fa-check"></i>');
2929
} else {
3030
var stored_theme = localStorage.getItem('api_browser_tool_theme');

vendor/art-of-wifi/unifi-api-client/examples/test_connection.php

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,56 @@
1717
* Check whether the cURL module supports SSL
1818
*/
1919
if (!curl_version()['features'] & CURL_VERSION_SSL) {
20-
print 'SSL is not supported with this cURL installation!' . PHP_EOL;
20+
print PHP_EOL . 'SSL is not supported with this cURL installation!' . PHP_EOL;
2121
}
2222

2323
/**
2424
* create cURL resource
2525
*/
2626
$ch = curl_init();
2727

28-
/**
29-
* Set the required cURL options
30-
*/
31-
curl_setopt($ch, CURLOPT_URL, $controllerurl);
32-
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
33-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
34-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
28+
if (is_resource($ch)) {
29+
/**
30+
* If we have a resource, we proceed and set the required cURL options
31+
*/
32+
curl_setopt($ch, CURLOPT_URL, $controllerurl);
33+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
34+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
35+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
3536

36-
/**
37-
* This cURL option can have a value of 0-6
38-
* see this URL for more details:
39-
* http://php.net/manual/en/function.curl-setopt.php
40-
* 0 is the default value and is used by the PHP API client class
41-
*/
42-
curl_setopt($ch, CURLOPT_SSLVERSION, 0);
37+
/**
38+
* This cURL option can have a value of 0-6
39+
* see this URL for more details:
40+
* http://php.net/manual/en/function.curl-setopt.php
41+
* 0 is the default value and is used by the PHP API client class
42+
*/
43+
curl_setopt($ch, CURLOPT_SSLVERSION, 0);
4344

44-
/**
45-
* Be more verbose
46-
*/
47-
curl_setopt($ch, CURLOPT_VERBOSE, true);
45+
/**
46+
* Be more verbose
47+
*/
48+
curl_setopt($ch, CURLOPT_VERBOSE, true);
4849

49-
/**
50-
* $results contains the output as returned by the cURL request,
51-
* returns true when successful, else returns false
52-
*/
53-
print 'verbose output from the cURL request:' . PHP_EOL;
54-
$results = curl_exec($ch);
50+
/**
51+
* $results contains the output as returned by the cURL request,
52+
* returns true when successful, else returns false
53+
*/
54+
print PHP_EOL . 'verbose output from the cURL request:' . PHP_EOL;
55+
$results = curl_exec($ch);
5556

56-
print PHP_EOL . 'curl_getinfo output:' . PHP_EOL;
57-
print_r(curl_getinfo($ch));
57+
print PHP_EOL . 'curl_getinfo output:' . PHP_EOL;
58+
print_r(curl_getinfo($ch));
5859

59-
/**
60-
* If we receive a cURL error, output it before the results
61-
*/
62-
if (curl_errno($ch)) {
63-
print PHP_EOL . 'cURL error: ' . curl_error($ch) . PHP_EOL;
64-
}
60+
/**
61+
* If we receive a cURL error, output it before the results
62+
*/
63+
if (curl_errno($ch)) {
64+
print PHP_EOL . 'cURL error: ' . curl_error($ch) . PHP_EOL;
65+
}
6566

66-
print PHP_EOL . '$results:' . PHP_EOL;
67-
print_r($results);
68-
print PHP_EOL;
67+
print PHP_EOL . '$results:' . PHP_EOL;
68+
print_r($results);
69+
print PHP_EOL;
70+
} else {
71+
print PHP_EOL . 'ERROR: cURL could not be initialized!' . PHP_EOL;
72+
}

0 commit comments

Comments
 (0)