We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -1,14 +1,10 @@ |
||
| 1 | 1 | <?php namespace Backpack\BackupManager\app\Http\Controllers; |
| 2 | 2 | |
| 3 | -use App\Http\Requests; |
|
| 4 | 3 | use App\Http\Controllers\Controller; |
| 5 | -use Illuminate\Http\Request; |
|
| 6 | -use Auth; |
|
| 7 | -use App; |
|
| 8 | -use Storage; |
|
| 9 | -use Carbon\Carbon; |
|
| 10 | 4 | use Artisan; |
| 5 | +use Illuminate\Http\Request; |
|
| 11 | 6 | use Log; |
| 7 | +use Storage; |
|
| 12 | 8 | |
| 13 | 9 | class BackupController extends Controller { |
| 14 | 10 | |
@@ -12,101 +12,101 @@ |
||
| 12 | 12 | |
| 13 | 13 | class BackupController extends Controller { |
| 14 | 14 | |
| 15 | - public function index() |
|
| 16 | - { |
|
| 17 | - if (!count(config('laravel-backup.backup.destination.disks'))) { |
|
| 18 | - dd(trans('backpack::backup.no_disks_configured')); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - $this->data['backups'] = []; |
|
| 22 | - |
|
| 23 | - foreach (config('laravel-backup.backup.destination.disks') as $disk_name) { |
|
| 24 | - $disk = Storage::disk($disk_name); |
|
| 25 | - $adapter = $disk->getDriver()->getAdapter(); |
|
| 26 | - $files = $disk->files(); |
|
| 27 | - |
|
| 28 | - // make an array of backup files, with their filesize and creation date |
|
| 29 | - foreach ($files as $k => $f) { |
|
| 30 | - // only take the zip files into account |
|
| 31 | - if (substr($f, -4) == '.zip' && $disk->exists($f)) { |
|
| 32 | - $this->data['backups'][] = [ |
|
| 33 | - 'file_path' => $f, |
|
| 34 | - 'file_name' => str_replace('backups/', '', $f), |
|
| 35 | - 'file_size' => $disk->size($f), |
|
| 36 | - 'last_modified' => $disk->lastModified($f), |
|
| 37 | - 'disk' => $disk_name, |
|
| 38 | - 'download' => ($adapter instanceof \League\Flysystem\Adapter\Local)?true:false |
|
| 39 | - ]; |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - // reverse the backups, so the newest one would be on top |
|
| 45 | - $this->data['backups'] = array_reverse($this->data['backups']); |
|
| 46 | - $this->data['title'] = 'Backups'; |
|
| 47 | - |
|
| 48 | - return view("backupmanager::backup", $this->data); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function create() |
|
| 52 | - { |
|
| 53 | - try { |
|
| 54 | - ini_set('max_execution_time', 300); |
|
| 55 | - // start the backup process |
|
| 56 | - Artisan::call('backup:run'); |
|
| 57 | - $output = Artisan::output(); |
|
| 58 | - |
|
| 59 | - // log the results |
|
| 60 | - Log::info("Backpack\BackupManager -- new backup started from admin interface \r\n".$output); |
|
| 61 | - // return the results as a response to the ajax call |
|
| 62 | - echo($output); |
|
| 63 | - } catch (Exception $e) { |
|
| 64 | - Response::make($e->getMessage(), 500); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return 'success'; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Downloads a backup zip file. |
|
| 72 | - */ |
|
| 73 | - public function download($file_name) |
|
| 74 | - { |
|
| 75 | - $disk = Storage::disk(\Request::input('disk')); |
|
| 76 | - $adapter = $disk->getDriver()->getAdapter(); |
|
| 77 | - |
|
| 78 | - if ($adapter instanceof \League\Flysystem\Adapter\Local) { |
|
| 79 | - $storage_path = $disk->getDriver()->getAdapter()->getPathPrefix(); |
|
| 80 | - |
|
| 81 | - if ($disk->exists($file_name)) { |
|
| 82 | - return response()->download($storage_path.$file_name); |
|
| 83 | - } |
|
| 84 | - else |
|
| 85 | - { |
|
| 86 | - abort(404, trans('backpack::backup.backup_doesnt_exist')); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - else |
|
| 90 | - { |
|
| 91 | - abort(404, trans('backpack::backup.only_local_downloads_supported')); |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Deletes a backup file. |
|
| 97 | - */ |
|
| 98 | - public function delete($file_name) |
|
| 99 | - { |
|
| 100 | - $disk = Storage::disk(\Request::input('disk')); |
|
| 101 | - |
|
| 102 | - if ($disk->exists($file_name)) { |
|
| 103 | - $disk->delete($file_name); |
|
| 104 | - |
|
| 105 | - return 'success'; |
|
| 106 | - } |
|
| 107 | - else |
|
| 108 | - { |
|
| 109 | - abort(404, trans('backpack::backup.backup_doesnt_exist')); |
|
| 110 | - } |
|
| 111 | - } |
|
| 15 | + public function index() |
|
| 16 | + { |
|
| 17 | + if (!count(config('laravel-backup.backup.destination.disks'))) { |
|
| 18 | + dd(trans('backpack::backup.no_disks_configured')); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + $this->data['backups'] = []; |
|
| 22 | + |
|
| 23 | + foreach (config('laravel-backup.backup.destination.disks') as $disk_name) { |
|
| 24 | + $disk = Storage::disk($disk_name); |
|
| 25 | + $adapter = $disk->getDriver()->getAdapter(); |
|
| 26 | + $files = $disk->files(); |
|
| 27 | + |
|
| 28 | + // make an array of backup files, with their filesize and creation date |
|
| 29 | + foreach ($files as $k => $f) { |
|
| 30 | + // only take the zip files into account |
|
| 31 | + if (substr($f, -4) == '.zip' && $disk->exists($f)) { |
|
| 32 | + $this->data['backups'][] = [ |
|
| 33 | + 'file_path' => $f, |
|
| 34 | + 'file_name' => str_replace('backups/', '', $f), |
|
| 35 | + 'file_size' => $disk->size($f), |
|
| 36 | + 'last_modified' => $disk->lastModified($f), |
|
| 37 | + 'disk' => $disk_name, |
|
| 38 | + 'download' => ($adapter instanceof \League\Flysystem\Adapter\Local)?true:false |
|
| 39 | + ]; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + // reverse the backups, so the newest one would be on top |
|
| 45 | + $this->data['backups'] = array_reverse($this->data['backups']); |
|
| 46 | + $this->data['title'] = 'Backups'; |
|
| 47 | + |
|
| 48 | + return view("backupmanager::backup", $this->data); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function create() |
|
| 52 | + { |
|
| 53 | + try { |
|
| 54 | + ini_set('max_execution_time', 300); |
|
| 55 | + // start the backup process |
|
| 56 | + Artisan::call('backup:run'); |
|
| 57 | + $output = Artisan::output(); |
|
| 58 | + |
|
| 59 | + // log the results |
|
| 60 | + Log::info("Backpack\BackupManager -- new backup started from admin interface \r\n".$output); |
|
| 61 | + // return the results as a response to the ajax call |
|
| 62 | + echo($output); |
|
| 63 | + } catch (Exception $e) { |
|
| 64 | + Response::make($e->getMessage(), 500); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return 'success'; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Downloads a backup zip file. |
|
| 72 | + */ |
|
| 73 | + public function download($file_name) |
|
| 74 | + { |
|
| 75 | + $disk = Storage::disk(\Request::input('disk')); |
|
| 76 | + $adapter = $disk->getDriver()->getAdapter(); |
|
| 77 | + |
|
| 78 | + if ($adapter instanceof \League\Flysystem\Adapter\Local) { |
|
| 79 | + $storage_path = $disk->getDriver()->getAdapter()->getPathPrefix(); |
|
| 80 | + |
|
| 81 | + if ($disk->exists($file_name)) { |
|
| 82 | + return response()->download($storage_path.$file_name); |
|
| 83 | + } |
|
| 84 | + else |
|
| 85 | + { |
|
| 86 | + abort(404, trans('backpack::backup.backup_doesnt_exist')); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + else |
|
| 90 | + { |
|
| 91 | + abort(404, trans('backpack::backup.only_local_downloads_supported')); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Deletes a backup file. |
|
| 97 | + */ |
|
| 98 | + public function delete($file_name) |
|
| 99 | + { |
|
| 100 | + $disk = Storage::disk(\Request::input('disk')); |
|
| 101 | + |
|
| 102 | + if ($disk->exists($file_name)) { |
|
| 103 | + $disk->delete($file_name); |
|
| 104 | + |
|
| 105 | + return 'success'; |
|
| 106 | + } |
|
| 107 | + else |
|
| 108 | + { |
|
| 109 | + abort(404, trans('backpack::backup.backup_doesnt_exist')); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | 'create_error_message' => 'Copia de siguranță NU a putut fi creată.', |
| 34 | 34 | 'create_warning_title' => 'Eroare necunoscută', |
| 35 | 35 | 'create_warning_message' => 'Copia de siguranță e posibil să NU fi fost creată. Verificați fișierele de log pentru detalii.', |
| 36 | - 'location' => 'Locație', |
|
| 36 | + 'location' => 'Locație', |
|
| 37 | 37 | 'no_disks_configured' => 'Nu există niciun disc in config/laravel-backups.php', |
| 38 | 38 | ]; |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | 'create_error_message' => 'The backup was file could NOT be created.', |
| 34 | 34 | 'create_warning_title' => 'Unknown error', |
| 35 | 35 | 'create_warning_message' => 'Your backup may NOT have been created. Please check log files for details.', |
| 36 | - 'location' => 'Location', |
|
| 36 | + 'location' => 'Location', |
|
| 37 | 37 | 'no_disks_configured' => 'No backup disks configured in config/laravel-backup.php', |
| 38 | 38 | 'backup_doesnt_exist' => "The backup file doesn't exist.", |
| 39 | 39 | 'only_local_downloads_supported' => "Only downloads from the Local filesystem are supported.", |