Added option to reset favicon and logo

This commit is contained in:
Julian Prieber 2022-11-30 12:10:45 +01:00
parent 35590314f4
commit fed93daf48
3 changed files with 49 additions and 4 deletions

View File

@ -243,7 +243,7 @@ class AdminController extends Controller
return view('panel/site', $message);
}
//Save home message and logo
//Save home message, logo and favicon
public function editSite(request $request)
{
$message = $request->message;
@ -282,6 +282,38 @@ class AdminController extends Controller
return back();
}
//Delete avatar
public function delAvatar()
{
// Delete existing image
$directory = base_path('/littlelink/images/');
$files = scandir($directory);
$pathinfo = "error.error";
foreach($files as $file) {
if (strpos($file, "avatar".'.') !== false) {
$pathinfo = "avatar". "." . pathinfo($file, PATHINFO_EXTENSION);
}}
if(file_exists(base_path('/littlelink/images/').$pathinfo)){File::delete(base_path('/littlelink/images/').$pathinfo);}
return back();
}
//Delete favicon
public function delFavicon()
{
// Delete existing image
$directory = base_path('/littlelink/images/');
$files = scandir($directory);
$pathinfo = "error.error";
foreach($files as $file) {
if (strpos($file, "favicon".'.') !== false) {
$pathinfo = "favicon". "." . pathinfo($file, PATHINFO_EXTENSION);
}}
if(file_exists(base_path('/littlelink/images/').$pathinfo)){File::delete(base_path('/littlelink/images/').$pathinfo);}
return back();
}
//View any of the pages: contact, terms, privacy
public function pages(request $request)
{

View File

@ -3,7 +3,18 @@
@section('content')
<script src="{{ asset('resources/ckeditor/ckeditor.js') }}"></script>
@php
function findFileSite($name){
$directory = base_path('/littlelink/images/');
$files = scandir($directory);
$pathinfo = "error.error";
foreach($files as $file) {
if (strpos($file, $name.'.') !== false) {
$pathinfo = $name. "." . pathinfo($file, PATHINFO_EXTENSION);
}}
return $pathinfo;
}
@endphp
<section class="shadow text-gray-400">
<h2 class="mb-4 card-header"><i class="bi bi-person"> Site</i></h2>
<div class="card-body p-0 p-md-3">
@ -11,11 +22,11 @@
<form action="{{ route('editSite') }}" enctype="multipart/form-data" method="post">
@csrf
<div class="form-group col-lg-8">
<label>Site logo</label>
<label>Site logo</label>@if(file_exists(base_path("littlelink/images/").findFileSite('avatar')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delAvatar') }}"><i class="bi bi-trash-fill"></i></a>@endif
<input type="file" class="form-control-file" name="image">
</div>
<div class="form-group col-lg-8">
<label>Favicon</label>
<label>Favicon</label>@if(file_exists(base_path("littlelink/images/").findFileSite('favicon')))<a title="Remove icon" class="hvr-grow p-1 text-danger" style="padding-left:5px;" href="{{ route('delFavicon') }}"><i class="bi bi-trash-fill"></i></a>@endif
<input type="file" class="form-control-file" name="icon">
</div>
<div class="form-group col-lg-8">

View File

@ -146,6 +146,8 @@ Route::group([
Route::post('/panel/env', [AdminController::class, 'editENV'])->name('editENV');
Route::get('/panel/site', [AdminController::class, 'showSite'])->name('showSite');
Route::post('/panel/site', [AdminController::class, 'editSite'])->name('editSite');
Route::get('/panel/site/delavatar', [AdminController::class, 'delAvatar'])->name('delAvatar');
Route::get('/panel/site/delfavicon', [AdminController::class, 'delFavicon'])->name('delFavicon');
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');