Skip to content

Commit e4f682c

Browse files
committed
Added page to download updater backups
1 parent c739d7b commit e4f682c

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

app/Http/Controllers/AdminController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,10 @@ public function editENV(request $request)
234234
return view('/panel/config');
235235
}
236236

237+
//Shows config file editor page
238+
public function showBackups(request $request)
239+
{
240+
return view('/panel/backups');
241+
}
242+
237243
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@extends('layouts.sidebar')
2+
3+
@section('content')
4+
<style>.buttondm{display:inline-block;text-decoration:none;height:48px;text-align:center;vertical-align:middle;font-size:18px;width:300px;font-weight:700;line-height:48px;letter-spacing:.1px;white-space:wrap;border-radius:8px;cursor:pointer}.button-hover,.credit-hover{display:inline-block;-webkit-transform:perspective(1px) translateZ(0);transform:perspective(1px) translateZ(0);box-shadow:0 0 1px rgba(0,0,0,0);-webkit-transition-duration:.3s;transition-duration:.3s;-webkit-transition-property:transform;transition-property:transform}.button-hover:active,.credit-hover:active,.button-hover:focus,.credit-hover:focus,.button-hover:hover,.credit-hover:hover{-webkit-transform:scale(1.06);transform:scale(1.06)}.container{align-items:center;display:flex;flex-direction:column;justify-content:center;height:50%;width:100%}</style>
5+
<!-- Custom icons font-awesome -->
6+
<script src="https://kit.fontawesome.com/c4a5e06183.js" crossorigin="anonymous"></script>
7+
@if (file_exists(base_path('storage/updater-backups/')) and is_dir(base_path('storage/updater-backups/')))
8+
@if($_SERVER['QUERY_STRING'] != '')
9+
<?php
10+
$filename = $_SERVER['QUERY_STRING'];
11+
12+
$filepath = base_path('storage/updater-backups/') . $filename;
13+
14+
$strFile = file_get_contents($filepath);
15+
16+
header("Content-type: application/force-download");
17+
header('Content-Disposition: attachment; filename="'.$filename.'"');
18+
19+
header('Content-Length: ' . filesize($filepath));
20+
echo $strFile;
21+
while (ob_get_level()) {
22+
ob_end_clean();
23+
}
24+
readfile($filepath);
25+
exit;
26+
?>
27+
@endif
28+
29+
<div class="container">
30+
<br><br><h3>Download your updater backups:</h3>
31+
<hp>The server will never store more that two backups at a time.</hp><br><br><br>
32+
<?php
33+
$test="test";
34+
if ($handle = opendir('storage/updater-backups')) {
35+
while (false !== ($entry = readdir($handle))) {
36+
if ($entry != "." && $entry != "..") {
37+
echo '<div class="button-entrance"><a class="buttondm button-hover icon-hover" style="color:#ffffff; background-color:#000;" href="' . url()->current() . '/?' . $entry . '"><i style="color: " class="icon hvr-icon fa fa-download"></i>&nbsp; '; print_r($entry); echo '</a></div><br>';
38+
}}} ?>
39+
</div>
40+
41+
@else
42+
<div class="container">
43+
<h3>No backups found</h3></div>
44+
@endif
45+
@endsection

resources/views/vendor/env-editor/components/_backup.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<template id="env-editor-backups">
33
<div>
44
<div class="h5 my-4">{{__($translatePrefix.'title')}}</div>
5+
<div class="h5 my-4">You can find your updater backups <span><a href="{{ url('panel/backups') }}">here</a></span></div>
56
<div>
67
<button class="btn-info btn " @click="createBackUp">{{__($translatePrefix.'btn.backUpCurrentEnv')}}</button>
78
<a class="btn-info btn" href="{{route(config($package.'.route.name').'.download')}}">{{__($translatePrefix.'btn.downloadCurrentEnv')}}</a>

routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
Route::get('/panel/site', [AdminController::class, 'showSite'])->name('showSite');
110110
Route::post('/panel/site', [AdminController::class, 'editSite'])->name('editSite');
111111
Route::get('/panel/phpinfo', [AdminController::class, 'phpinfo'])->name('phpinfo');
112+
Route::get('/panel/backups', [AdminController::class, 'showBackups'])->name('showBackups');
112113
Route::get('/update', function () {return view('update', []);});
113114

114115
Route::get('/updating', function (\Codedge\Updater\UpdaterManager $updater) {

0 commit comments

Comments
 (0)