From e32977ffff167001f92430d7d63d2c86773cd075 Mon Sep 17 00:00:00 2001 From: "Ing. Petr Suchy" Date: Fri, 7 Feb 2020 07:43:16 +0100 Subject: [PATCH 01/14] *fix - check and update latest version --- src/includes/functions.inc.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 3036c8fa..226b620f 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -555,22 +555,32 @@ namespace { // update last check date psm_update_conf('last_update_check', time()); $latest = psm_curl_get(PSM_UPDATE_URL); + if ($latest['info'] === false || (int)$latest['info']['http_code'] >= 300) { + // error + return false; + } // extract latest version from Github. - preg_match('/"tag_name":"[v](([\d][.][\d][.][\d])(-?\w*))"/', $latest, $latest); - // add latest version to database - if (!empty($latest) && strlen($latest[2]) < 15) { - psm_update_conf('version_update_check', $latest[2]); + $githubInfo = json_decode($latest['exec']); + if (property_exists($githubInfo, 'tag_name') === false) { + // version not found + return false; + } + $tagName = $githubInfo->tag_name; + $latestVersion = str_replace('v', '', $tagName); + // check from old version ... maybe has reason but I don't think so ... + if (empty($latestVersion) === true || strlen($latestVersion) >= 15) { + // weird version + return false; + } + // add latest version to database + psm_update_conf('version_update_check', $latestVersion); } else { - $latest[2] = psm_get_conf('version_update_check'); + $latestVersion = psm_get_conf('version_update_check'); } - if (!empty($latest)) { - $current = psm_get_conf('version'); - return version_compare($latest[2], $current, '>'); - } else { - return false; - } + $current = psm_get_conf('version'); + return version_compare($latestVersion, $current, '>'); } /** From 8fa1bf6c0d7a628a7d3c19cbae4711b358dcb53a Mon Sep 17 00:00:00 2001 From: "Ing. Petr Suchy" Date: Fri, 7 Feb 2020 07:59:50 +0100 Subject: [PATCH 02/14] *edit - check ssl just when other error is not already in --- src/psm/Util/Server/Updater/StatusUpdater.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index da0cb72e..7b54cbe0 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -366,8 +366,10 @@ class StatusUpdater } } - // Check ssl cert - $this->checkSsl($this->server, $this->error, $result); + // Check ssl cert just when other error is not already in... + if ($result !== false) { + $this->checkSsl($this->server, $this->error, $result); + } // check if server is available and rerun if asked. if (!$result && $run < $max_runs) { From 5934e9a25c1bedda308c1c5c38f28510deec5751 Mon Sep 17 00:00:00 2001 From: "Ing. Petr Suchy" Date: Fri, 7 Feb 2020 08:03:12 +0100 Subject: [PATCH 03/14] *fix - checkSsl should check PHP_VERSION and not PHP_RELEASE_VERSION --- src/psm/Util/Server/Updater/StatusUpdater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 7b54cbe0..635dcd02 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -406,7 +406,7 @@ class StatusUpdater */ private function checkSsl($server, &$error, &$result) { - if (version_compare(PHP_RELEASE_VERSION, '7.1', '<')) { + if (version_compare(PHP_VERSION, '7.1', '<')) { $error = "The server you're running PSM on must use PHP 7.1 or higher to test the SSL expiration."; return; } From 51dbbf9510b64dab76fcd9b1ae80872d40c81aef Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Sat, 8 Feb 2020 20:57:53 +0100 Subject: [PATCH 04/14] Refactor --- src/includes/functions.inc.php | 39 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 226b620f..f054ff9f 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -555,28 +555,27 @@ namespace { // update last check date psm_update_conf('last_update_check', time()); $latest = psm_curl_get(PSM_UPDATE_URL); - if ($latest['info'] === false || (int)$latest['info']['http_code'] >= 300) { - // error - return false; - } - // extract latest version from Github. - $githubInfo = json_decode($latest['exec']); - if (property_exists($githubInfo, 'tag_name') === false) { - // version not found - return false; - } - $tagName = $githubInfo->tag_name; - $latestVersion = str_replace('v', '', $tagName); - // check from old version ... maybe has reason but I don't think so ... - if (empty($latestVersion) === true || strlen($latestVersion) >= 15) { - // weird version - return false; - + if ($latest['info'] === false || (int)$latest['info']['http_code'] >= 300) { + // error + return false; } - // add latest version to database - psm_update_conf('version_update_check', $latestVersion); + // extract latest version from Github. + $githubInfo = json_decode($latest['exec']); + if (property_exists($githubInfo, 'tag_name') === false) { + // version not found + return false; + } + $tagName = $githubInfo->tag_name; + $latestVersion = str_replace('v', '', $tagName); + // check from old version ... maybe has reason but I don't think so ... + if (empty($latestVersion) === true || strlen($latestVersion) >= 15) { + // weird version + return false; + } + // add latest version to database + psm_update_conf('version_update_check', $latestVersion); } else { - $latestVersion = psm_get_conf('version_update_check'); + $latestVersion = psm_get_conf('version_update_check'); } $current = psm_get_conf('version'); From 7ffc75598a6685dc89b3e693fc02cef92dcf88d4 Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Sun, 9 Feb 2020 15:10:07 +0100 Subject: [PATCH 05/14] Refactor --- src/psm/Util/Server/Updater/StatusUpdater.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 635dcd02..41f9aea3 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -367,9 +367,9 @@ class StatusUpdater } // Check ssl cert just when other error is not already in... - if ($result !== false) { - $this->checkSsl($this->server, $this->error, $result); - } + if ($result !== false) { + $this->checkSsl($this->server, $this->error, $result); + } // check if server is available and rerun if asked. if (!$result && $run < $max_runs) { From ed6ef89df5a9f07f3119f4c2565bbcc995ece53f Mon Sep 17 00:00:00 2001 From: TimZ99 Date: Sun, 9 Feb 2020 15:15:13 +0100 Subject: [PATCH 06/14] Hotfix - sslCheck warning days Minimum amount of days the ssl cert needs to be valid before expiration wasn't used. --- src/psm/Util/Server/Updater/StatusUpdater.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 41f9aea3..22bcab59 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -415,14 +415,21 @@ class StatusUpdater $server['ssl_cert_expiry_days'] > 0 ) { $cert_expiration_date = strtotime($this->curl_info['certinfo'][0]['Expire date']); - $expiration_time = round((int)($cert_expiration_date - time()) / 86400); + $expiration_time = + round((int)($cert_expiration_date - time()) / 86400); $latest_time = time() + (86400 * $server['ssl_cert_expiry_days']); - if ($expiration_time >= 0) { + + if ($expiration_time - $server['ssl_cert_expiry_days'] < 0) { + // Cert is not expired, but date is withing user set range $this->header = psm_get_lang('servers', 'ssl_cert_expiring') . " " . psm_date($this->curl_info['certinfo'][0]['Expire date']) . "\n\n" . $this->header; + $save['ssl_cert_expired_time'] = $expiration_time - $server['ssl_cert_expiry_days']; + } elseif ($expiration_time >= 0) { + // Cert is not expired $save['ssl_cert_expired_time'] = null; } else { + // Cert is expired $error = psm_get_lang('servers', 'ssl_cert_expired') . " " . psm_timespan($cert_expiration_date) . ".\n\n" . $error; From 1d779760ceac1de7d9089e6ec9459ba9bc22af58 Mon Sep 17 00:00:00 2001 From: Michael <33117529+mtelgkamp@users.noreply.github.com> Date: Sun, 9 Feb 2020 15:40:45 +0100 Subject: [PATCH 07/14] Improve accessibility of cards and tableview (#851) To enable keyboard users to show server details the links are added as HTML `a` Tags not only for