Added option for deleting themes

This commit is contained in:
Julian Prieber 2022-07-04 23:41:28 +02:00
parent e863e8a105
commit 1ee73d0554
4 changed files with 90 additions and 0 deletions

View File

@ -240,4 +240,64 @@ class AdminController extends Controller
return view('/panel/backups');
}
//Delete custom theme
public function deleteTheme(request $request)
{
$del = $request->deltheme;
$folderName = base_path() . '/themes/' . $del;
function removeFolder($folderName) {
if (is_dir($folderName))
$folderHandle = opendir($folderName);
if (!$folderHandle)
return false;
while($file = readdir($folderHandle)) {
if ($file != "." && $file != "..") {
if (!is_dir($folderName."/".$file))
unlink($folderName."/".$file);
else
removeFolder($folderName.'/'.$file);
}
}
closedir($folderHandle);
rmdir($folderName);
}
removeFolder($folderName);
return Redirect('/panel/theme');
}
//Shows config file editor page
public function showThemes(request $request)
{
return view('/panel/theme');
}
}

View File

@ -0,0 +1,26 @@
@extends('layouts.sidebar')
@section('content')
<h2 class="mb-4"><i class="bi bi-brush"> Delete a theme</i></h2>
<form action="{{ route('deleteTheme') }}" enctype="multipart/form-data" method="post">
@csrf
<div class="form-group col-lg-8">
<h3>Delete theme</h3>
<select class="form-control" name="deltheme">
<?php if ($handle = opendir('themes')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo '<option>'; print_r($entry); echo '</option>'; }}} ?>
</select>
</div>
<button type="submit" class="mt-3 ml-3 btn btn-info">Delete theme</button>
</form>
</details>
<br><br><a class="btn btn-primary" href="{{ url('/studio/theme') }}"> Back</a>
@endsection

View File

@ -52,6 +52,8 @@
<label>Upload theme</label>
<input type="file" accept=".zip" class="form-control-file" name="zip">
</div>
<style>.deltheme{color:tomato;font-size:120%;}.deltheme:hover{color:red;text-decoration:underline;}</style>
<a class="deltheme" href="{{ url('/panel/theme') }}">&emsp; Delete themes</a>
<div class="row">
<button type="submit" class="mt-3 ml-3 btn btn-info">Upload theme</button>
<button class="mt-3 ml-3 btn btn-primary" title="Download more themes"><a href="https://littlelink-custom.com/themes.php" target="_blank" style="color:#FFFFFF;">Download themes</a></button>

View File

@ -110,6 +110,8 @@ Route::get('/panel/site', [AdminController::class, 'showSite'])->name('showSite'
Route::post('/panel/site', [AdminController::class, 'editSite'])->name('editSite');
Route::get('/panel/phpinfo', [AdminController::class, 'phpinfo'])->name('phpinfo');
Route::get('/panel/backups', [AdminController::class, 'showBackups'])->name('showBackups');
Route::post('/panel/theme', [AdminController::class, 'deleteTheme'])->name('deleteTheme');
Route::get('/panel/theme', [AdminController::class, 'showThemes'])->name('showThemes');
Route::get('/update', function () {return view('update', []);});
Route::get('/updating', function (\Codedge\Updater\UpdaterManager $updater) {