Updated update notification system

Made NOTIFY_UPDATES=all and NOTIFY_UPDATES=major use the same version source file to prevent GitHub API limit from being reached.
This commit is contained in:
Julian Prieber 2022-05-28 15:49:29 +02:00
parent 9a99d858e0
commit 0e257ef8ab
2 changed files with 10 additions and 6 deletions

View File

@ -2,7 +2,11 @@
declare(strict_types=1);
$Vgit = file_get_contents("https://julianprieber.github.io/littlelink-custom/version.json");
if (env('JOIN_BETA') === true) {
$Vgit = file_get_contents("https://julianprieber.github.io/littlelink-custom/version.json");
} else {
$Vgit = '0';
}
if ($Vgit > $Vlocal) {
$userver = 'https://update.littlelink-custom.com/';

View File

@ -194,13 +194,13 @@ if ($url1sb->successful() or $url2sb->successful()) {
<div class="row">
<! #### begin update detection #### >
@if(env('NOTIFY_UPDATES') == 'all' or env('NOTIFY_UPDATES') == 'true')
@if(env('NOTIFY_UPDATES') == 'old')
<! Checks if file version.json exists to continue (without this PHP will throw ErrorException ) >
@if(file_exists(base_path("version.json")))
<?php // Requests newest version from server and sets it as variable
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)');
$json = file_get_contents("https://api.github.com/repos/julianprieber/littlelink-custom/releases/latest") ;
$json = file_get_contents("https://api.github.com/repos/julianprieber/littlelink-custom/releases/latest");
$myObj = json_decode($json);
$Vgit = $myObj->tag_name;
@ -213,7 +213,7 @@ if ($url1sb->successful() or $url2sb->successful()) {
<a style="color:#007bff" class="nav-link" href="{{ url('update') }}" title="Click here to learn more about how to update">An update is available</a>
@endif
@endif
@elseif(env('NOTIFY_UPDATES') == 'major')
@else
<?php // Checks if URL exists
try {
function URL_exists(string $url): bool