Skip to content

Commit 5671a85

Browse files
committed
Added automatic updater for Windows
1 parent e28a831 commit 5671a85

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

resources/views/update.blade.php

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@
1818
<img class="logo-img" src="{{ asset('littlelink/images/just-gear.svg') }}" alt="Logo">
1919
<div class="logo-centered">l</div>
2020
</div>
21-
<h1>Updater</h1>
21+
<h1>Windows Updater</h1>
2222
@if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
23-
<h4 class="">The updater only works on Linux based systems.</h4>
24-
<a class="btn" href="https://littlelink-custom.com/update"><button><i class="fa-solid fa-download btn"></i> Update manually</button></a>
23+
@if(env('JOIN_BETA') === true)
24+
<p><?php echo "latest beta version= " . file_get_contents("https://update.littlelink-custom.com/beta/vbeta.json"); ?></p>
25+
<p><?php if(file_exists(base_path("vbeta.json"))) {echo "Installed beta version= " . file_get_contents(base_path("vbeta.json"));} else {echo "Installed beta version= none";} ?></p>
26+
<p><?php if($Vgit > $Vlocal) {echo "You need to update to the latest mainline release";} else {echo "You're running the latest mainline release";} ?></p>
27+
@else
28+
<h4 class="">You can update your installation automatically or download the update and install it manually:</h4>
29+
<h5 class="">Windows users can use the alternative updater. This updater won't create a backup. Use at your own discretion.</h5>
30+
@endif
31+
<br><div class="row">
32+
&ensp;<a class="btn" href="{{url()->current()}}/?updating-windows"><button><i class="fa-solid fa-user-gear btn"></i> Update automatically</button></a>&ensp;
33+
&ensp;<a class="btn" href="https://littlelink-custom.com/update" target="_blank"><button><i class="fa-solid fa-download btn"></i> Update manually</button></a>&ensp;
34+
</div>
2535
@else
2636
@if(env('JOIN_BETA') === true)
2737
<p><?php echo "latest beta version= " . file_get_contents("https://update.littlelink-custom.com/beta/vbeta.json"); ?></p>
@@ -42,6 +52,57 @@
4252

4353
@endif
4454

55+
56+
@if($_SERVER['QUERY_STRING'] === 'updating-windows' and strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
57+
<?php //updating on Windows ?>
58+
<div class="logo-container fadein">
59+
<img class="logo-img loading" src="{{ asset('littlelink/images/just-gear.svg') }}" alt="Logo">
60+
<div class="logo-centered">l</div>
61+
</div>
62+
<h1 class="loadingtxt">Updating</h1>
63+
@Push('updater-head')
64+
<meta http-equiv="refresh" content="2; URL={{url()->current()}}/?updating-windows-bat" />
65+
@endpush
66+
@endif
67+
68+
@if($_SERVER['QUERY_STRING'] === 'updating-windows-bat' and strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
69+
<?php //updating on Windows ?>
70+
<?php
71+
72+
73+
// Download the zip file
74+
75+
$latestversion = trim(file_get_contents("https://raw.githubusercontent.com/JulianPrieber/littlelink-custom/main/version.json"));
76+
77+
if(env('JOIN_BETA') === true){
78+
$fileUrl = 'https://update.littlelink-custom.com/beta/'. $latestversion . '.zip';
79+
} else {
80+
$fileUrl = 'https://update.littlelink-custom.com/'. $latestversion . '.zip';
81+
}
82+
83+
$curl = curl_init();
84+
curl_setopt($curl, CURLOPT_URL, $fileUrl);
85+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
86+
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
87+
$result = curl_exec($curl);
88+
curl_close($curl);
89+
90+
file_put_contents(base_path('storage/update.zip'), $result);
91+
92+
93+
$zip = new ZipArchive;
94+
$zip->open(base_path() . '/storage/update.zip');
95+
$zip->extractTo(base_path());
96+
$zip->close();
97+
unlink(base_path() . '/storage/update.zip');
98+
99+
echo "<meta http-equiv=\"refresh\" content=\"0; " . url()->current() . "/?finishing\" />";
100+
101+
?>
102+
103+
104+
@endif
105+
45106
@if($_SERVER['QUERY_STRING'] === 'backup')
46107
<?php //creating backup... ?>
47108
@Push('updater-head')

0 commit comments

Comments
 (0)