Skip to content

Commit

Permalink
UniFi API browser 2.0.8
Browse files Browse the repository at this point in the history
- included PHP API client version 1.1.49
- minor changes and improvements
  • Loading branch information
malle-pietje committed Feb 7, 2020
1 parent 55843a5 commit bb6fa34
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 138 deletions.
3 changes: 1 addition & 2 deletions ajax/fetch_sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
* we first check for connectivity to the host and port provided in the URL
*/
$host = parse_url($controller['url'], PHP_URL_HOST);
$port = parse_url($controller['url'], PHP_URL_PORT);
$port = $port ?: 443;
$port = parse_url($controller['url'], PHP_URL_PORT) ?: 443;

if (!empty($host) && !empty($port)) {
$fp = @fsockopen($host, $port, $errno, $errstr, 2);
Expand Down
3 changes: 1 addition & 2 deletions ajax/show_api_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
* we first check for connectivity to the host and port provided in the URL
*/
$host = parse_url($controller['url'], PHP_URL_HOST);
$port = parse_url($controller['url'], PHP_URL_PORT);
$port = $port ?: 443;
$port = parse_url($controller['url'], PHP_URL_PORT) ?: 443;

if (!empty($host) && !empty($port)) {
$fp = @fsockopen($host, $port, $errno, $errstr, 2);
Expand Down
2 changes: 1 addition & 1 deletion ajax/update_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/**
* we also unset the cookie for access to the UniFi controller
*/
unset($_SESSION['unificookie']);
$_SESSION['unificookie'] = '';
} else {
$results['status'] = 'error';
$results['message'] = 'empty POST';
Expand Down
2 changes: 1 addition & 1 deletion common.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* with this package in the file LICENSE.md
*
*/
define('TOOL_VERSION', '2.0.7');
define('TOOL_VERSION', '2.0.8');

/**
* gather some basic information for the About modal
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.

2 changes: 1 addition & 1 deletion js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var theme = 'bootstrap',
/**
* check whether user has stored a custom theme, if yes we switch to the stored value
*/
if (localStorage.getItem('api_browser_tool_theme') == null || localStorage.getItem('api_browser_tool_theme') === 'bootstrap') {
if (localStorage.getItem('api_browser_tool_theme') === null || localStorage.getItem('api_browser_tool_theme') === 'bootstrap') {
$('#bootstrap').addClass('active').find('a').append(' <i class="fas fa-check"></i>');
} else {
var stored_theme = localStorage.getItem('api_browser_tool_theme');
Expand Down
76 changes: 40 additions & 36 deletions vendor/art-of-wifi/unifi-api-client/examples/test_connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,56 @@
* Check whether the cURL module supports SSL
*/
if (!curl_version()['features'] & CURL_VERSION_SSL) {
print 'SSL is not supported with this cURL installation!' . PHP_EOL;
print PHP_EOL . 'SSL is not supported with this cURL installation!' . PHP_EOL;
}

/**
* create cURL resource
*/
$ch = curl_init();

/**
* Set the required cURL options
*/
curl_setopt($ch, CURLOPT_URL, $controllerurl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if (is_resource($ch)) {
/**
* If we have a resource, we proceed and set the required cURL options
*/
curl_setopt($ch, CURLOPT_URL, $controllerurl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

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

/**
* Be more verbose
*/
curl_setopt($ch, CURLOPT_VERBOSE, true);
/**
* Be more verbose
*/
curl_setopt($ch, CURLOPT_VERBOSE, true);

/**
* $results contains the output as returned by the cURL request,
* returns true when successful, else returns false
*/
print 'verbose output from the cURL request:' . PHP_EOL;
$results = curl_exec($ch);
/**
* $results contains the output as returned by the cURL request,
* returns true when successful, else returns false
*/
print PHP_EOL . 'verbose output from the cURL request:' . PHP_EOL;
$results = curl_exec($ch);

print PHP_EOL . 'curl_getinfo output:' . PHP_EOL;
print_r(curl_getinfo($ch));
print PHP_EOL . 'curl_getinfo output:' . PHP_EOL;
print_r(curl_getinfo($ch));

/**
* If we receive a cURL error, output it before the results
*/
if (curl_errno($ch)) {
print PHP_EOL . 'cURL error: ' . curl_error($ch) . PHP_EOL;
}
/**
* If we receive a cURL error, output it before the results
*/
if (curl_errno($ch)) {
print PHP_EOL . 'cURL error: ' . curl_error($ch) . PHP_EOL;
}

print PHP_EOL . '$results:' . PHP_EOL;
print_r($results);
print PHP_EOL;
print PHP_EOL . '$results:' . PHP_EOL;
print_r($results);
print PHP_EOL;
} else {
print PHP_EOL . 'ERROR: cURL could not be initialized!' . PHP_EOL;
}
Loading

0 comments on commit bb6fa34

Please sign in to comment.