Updated version and event detection

This commit is contained in:
Julian Prieber 2022-10-19 15:05:59 +02:00
parent 2377f0b749
commit 6624bbdaa9
2 changed files with 16 additions and 32 deletions

View File

@ -236,29 +236,24 @@ if($url1sb == '200' or $url2sb == '200') {
@endif @endif
@endif @endif
@elseif(env('NOTIFY_UPDATES') == 'true' or env('NOTIFY_UPDATES') === 'major' or env('NOTIFY_UPDATES') === 'all') @elseif(env('NOTIFY_UPDATES') == 'true' or env('NOTIFY_UPDATES') === 'major' or env('NOTIFY_UPDATES') === 'all')
<?php // Checks if URL exists
try {
function URL_exists(string $urlsb): bool
{
return str_contains(get_headers($urlsb)[0], "200 OK");
}
// Sets $ServerExists to true if URL exists
if (URL_exists("https://julianprieber.github.io/littlelink-custom/version.json")){
$ServerExists = "true";
}
} catch (exception $e) {
$ServerExists = "false";
}
?>
<! Checks if file version.json exists AND if version.json exists on server to continue (without this PHP will throw ErrorException ) > <! Checks if file version.json exists AND if version.json exists on server to continue (without this PHP will throw ErrorException ) >
@if(file_exists(base_path("version.json")) and $ServerExists == 'true') @if(file_exists(base_path("version.json")))
<?php // Requests newest version from server and sets it as variable <?php // Requests newest version from server and sets it as variable
$Vgit = file_get_contents("https://julianprieber.github.io/littlelink-custom/version.json");
try{
$Vgit = file_get_contents("https://version.littlelink-custom.com/");
// Requests current version from the local version file and sets it as variable // Requests current version from the local version file and sets it as variable
$Vlocal = file_get_contents(base_path("version.json")); $Vlocal = file_get_contents(base_path("version.json"));
}
catch (Exception $e){
$Vgit = "0";
$Vlocal = "0";
}
?> ?>
<! If user has role admin AND newest GitHub release version is higher than the local one an update notice will be displayed > <! If user has role admin AND newest GitHub release version is higher than the local one an update notice will be displayed >
@ -317,22 +312,10 @@ $userdbs = DB::table('users')->where('id', $littlelink_current)->get();
@endif @endif
<! #### begin event detection #### > <! #### begin event detection #### >
@if(env('NOTIFY_EVENTS') === true)
<?php <?php
try{ try{
function URL_event_exists(string $urlsb): bool $GetEventJson = file_get_contents("https://event.littlelink-custom.com/");
{
return str_contains(get_headers($urlsb)[0], "200 OK");
}
if (URL_event_exists("https://julianprieber.github.io/littlelink-custom-events/event.json")){
$EventServerExists = "true";
}
} catch (exception $e) {
$EventServerExists = "false";
}
?>
@if(env('NOTIFY_EVENTS') === true and $EventServerExists == 'true')
<?php
$GetEventJson = file_get_contents("https://julianprieber.github.io/littlelink-custom-events/event.json");
$EventJson = json_decode($GetEventJson, true); $EventJson = json_decode($GetEventJson, true);
if(isset($_COOKIE['HideEvent']) == NULL) { if(isset($_COOKIE['HideEvent']) == NULL) {
setcookie("HideEvent",$_COOKIE['ID'] = "0", time()+60*60*24*5, "/"); setcookie("HideEvent",$_COOKIE['ID'] = "0", time()+60*60*24*5, "/");
@ -367,6 +350,7 @@ if(localStorage.getItem("firstTime")==null){
} }
</script> </script>
@endif @endif
<?php } catch (Exception $e){} ?>
@endif @endif
<! #### end event detection #### > <! #### end event detection #### >
@yield('content') @yield('content')

View File

@ -4,7 +4,7 @@
<div class="container"> <div class="container">
<?php // Requests newest version from server and sets it as variable <?php // Requests newest version from server and sets it as variable
$Vgit = file_get_contents("https://julianprieber.github.io/littlelink-custom/version.json"); $Vgit = file_get_contents("https://version.littlelink-custom.com/");
// Requests current version from the local version file and sets it as variable // Requests current version from the local version file and sets it as variable
$Vlocal = file_get_contents(base_path("version.json")); $Vlocal = file_get_contents(base_path("version.json"));