3 namespace BookStack\Http\Controllers;
5 use BookStack\Notifications\TestEmail;
6 use BookStack\Uploads\ImageService;
7 use Illuminate\Http\Request;
9 class MaintenanceController extends Controller
12 * Show the page for application maintenance.
14 public function index()
16 $this->checkPermission('settings-manage');
17 $this->setPageTitle(trans('settings.maint'));
19 // Get application version
20 $version = trim(file_get_contents(base_path('version')));
22 return view('settings.maintenance', ['version' => $version]);
26 * Action to clean-up images in the system.
28 public function cleanupImages(Request $request, ImageService $imageService)
30 $this->checkPermission('settings-manage');
32 $checkRevisions = !($request->get('ignore_revisions', 'false') === 'true');
33 $dryRun = !($request->has('confirm'));
35 $imagesToDelete = $imageService->deleteUnusedImages($checkRevisions, $dryRun);
36 $deleteCount = count($imagesToDelete);
37 if ($deleteCount === 0) {
38 $this->showWarningNotification(trans('settings.maint_image_cleanup_nothing_found'));
39 return redirect('/settings/maintenance')->withInput();
43 session()->flash('cleanup-images-warning', trans('settings.maint_image_cleanup_warning', ['count' => $deleteCount]));
45 $this->showSuccessNotification(trans('settings.maint_image_cleanup_success', ['count' => $deleteCount]));
48 return redirect('/settings/maintenance#image-cleanup')->withInput();
52 * Action to send a test e-mail to the current user.
54 public function sendTestEmail()
56 $this->checkPermission('settings-manage');
59 user()->notify(new TestEmail());
60 $this->showSuccessNotification(trans('settings.maint_send_test_email_success', ['address' => user()->email]));
61 } catch (\Exception $exception) {
62 $errorMessage = trans('errors.maintenance_test_email_failure') . "\n" . $exception->getMessage();
63 $this->showErrorNotification($errorMessage);
66 return redirect('/settings/maintenance#image-cleanup')->withInput();