Get latest version from Github.

The latest version number will now come from Github instead of phpservermonitor.org.
This commit is contained in:
TimZ99 2019-09-26 14:07:16 +02:00
parent 5c1d6d1f93
commit f84061ee14
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
3 changed files with 10 additions and 9 deletions

View File

@ -476,17 +476,19 @@ function psm_update_available() {
// update last check date
psm_update_conf('last_update_check', time());
$latest = psm_curl_get(PSM_UPDATE_URL);
// extract latest version from Github.
preg_match('/"tag_name":"[v](([\d][.][\d][.][\d])(-?\w*))"/', $latest, $latest);
// add latest version to database
if ($latest !== false && strlen($latest) < 15) {
psm_update_conf('version_update_check', $latest);
if ($latest[2] !== false && strlen($latest[2]) < 15) {
psm_update_conf('version_update_check', $latest[2]);
}
} else {
$latest = psm_get_conf('version_update_check');
}
if ($latest !== false) {
if ($latest[2] !== false) {
$current = psm_get_conf('version');
return version_compare($latest, $current, '>');
return version_compare($latest[2], $current, '>');
} else {
return false;
}

View File

@ -35,13 +35,13 @@ define('PSM_VERSION', '3.4.4');
* URL to check for updates. Will not be checked if turned off on config page.
* @see psm_update_available()
*/
define('PSM_UPDATE_URL', 'http://www.phpservermonitor.org/version.php');
define('PSM_UPDATE_URL', 'https://api.github.com/repos/phpservermon/phpservermon/releases/latest');
/**
* Default update interval (1 week). Only applicable when updates are enabled.
* Default update interval (1 day). Only applicable when updates are enabled.
* @see psm_update_available()
*/
define('PSM_UPDATE_INTERVAL', 7 * 24 * 60 * 60);
define('PSM_UPDATE_INTERVAL', 1 * 24 * 60 * 60);
/**
* Configuration for: Hashing strength

View File

@ -68,8 +68,7 @@
Powered by
<a href="https://github.com/phpservermon/phpservermon/" target="_blank" rel="noopener">
PHP Server Monitor {{ version }}.
</a>
{{ update_available }} <a href="#" class="float-right">{{ label_back_to_top }}</a>
</a><span style="color:red;">{{ update_available|raw }}</span><a href="#" class="float-right">{{ label_back_to_top }}</a>
</span>
</div>
</footer>