Skip to content

Commit 2e83eed

Browse files
committed
a number of minor changes
changed function to fetch API client version to use Composer\InstalledVersions instead changed 2021 to 2023
1 parent a19bc0e commit 2e83eed

15 files changed

+40
-38
lines changed

ajax/fetch_about_modal_metrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled

ajax/fetch_collection.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled
@@ -16,6 +16,8 @@
1616
require_once '../collections.php';
1717
require_once '../vendor/autoload.php';
1818

19+
use UniFi_API\Client as ApiClient;
20+
1921
/**
2022
* load the configuration file if readable
2123
*/
@@ -124,14 +126,19 @@
124126
/**
125127
* create an instance of the Unifi API client class, log in to the controller and pull the requested data
126128
*/
127-
$unifi_connection = new UniFi_API\Client(trim($controller['user']), trim($controller['password']),
128-
trim(rtrim($controller['url'], "/")), $site_id);
129-
$loginresults = $unifi_connection->login();
129+
$unifi_connection = new ApiClient(
130+
trim($controller['user']),
131+
trim($controller['password']),
132+
trim(rtrim($controller['url'], "/")),
133+
$site_id
134+
);
135+
136+
$login_results = $unifi_connection->login();
130137

131138
/**
132139
* check for login errors
133140
*/
134-
if ($loginresults === 400) {
141+
if ($login_results === 400) {
135142
$results['state'] = 'error';
136143
$results['message'] = 'UniFi controller login failure, please check your credentials in config/config.php!';
137144
} else {

ajax/fetch_sites.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled

ajax/show_api_debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled

ajax/update_controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md

ajax/update_theme.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md

collections.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md

common.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
77
*/
8-
const TOOL_VERSION = '2.0.24';
8+
9+
use Composer\InstalledVersions;
10+
11+
require_once 'vendor/autoload.php';
12+
13+
const TOOL_VERSION = '2.0.25';
914

1015
/**
1116
* gather some basic information for the About modal
@@ -32,21 +37,11 @@
3237
*/
3338

3439
/**
35-
* function which returns the version of the included API client class by
36-
* extracting it from the composer.lock file
40+
* returns the version of the included API client class
41+
*
42+
* @see https://getcomposer.org/doc/07-runtime.md
3743
*/
3844
function getClientVersion()
3945
{
40-
if (is_readable('composer.lock')) {
41-
$composer_lock = file_get_contents('composer.lock');
42-
$json_decoded = json_decode($composer_lock, true);
43-
if (isset($json_decoded['packages'])) {
44-
foreach ($json_decoded['packages'] as $package) {
45-
if ($package['name'] === 'art-of-wifi/unifi-api-client') {
46-
return substr($package['version'], 1);
47-
}
48-
}
49-
}
50-
}
51-
return 'unknown';
46+
return InstalledVersions::getVersion('art-of-wifi/unifi-api-client');
5247
}

config/config-template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md

config/users-template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright (c) 2021, Art of WiFi
3+
* Copyright (c) 2023, Art of WiFi
44
* www.artofwifi.net
55
*
66
* This file is subject to the MIT license that is bundled with this package in the file LICENSE.md
@@ -33,4 +33,4 @@
3333
'user_name' => '', // string, the user name
3434
'password' => '', // string, the SHA512 hash of the password
3535
],
36-
];
36+
];

0 commit comments

Comments
 (0)