-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathBackpackElfinderController.php
More file actions
62 lines (50 loc) · 1.91 KB
/
Copy pathBackpackElfinderController.php
File metadata and controls
62 lines (50 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Backpack\FileManager;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Log;
class BackpackElfinderController extends \Barryvdh\Elfinder\ElfinderController
{
public function showPopup($input_id)
{
$mimes = request('mimes');
if (config('elfinder.encrypt_mimes', true)) {
if (! isset($mimes)) {
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.');
abort(403, 'Unauthorized action.');
}
try {
$mimes = Crypt::decrypt(urldecode($mimes));
} catch (\Illuminate\Contracts\Encryption\DecryptException $e) {
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.');
abort(403, 'Unauthorized action.');
}
} else {
$mimes = $mimes ? json_decode(urldecode($mimes), true) : '';
}
if (! empty($mimes)) {
request()->merge(['mimes' => urlencode(json_encode($mimes, JSON_UNESCAPED_SLASHES))]);
} else {
request()->merge(['mimes' => '']);
}
return $this->app['view']
->make('backpack.filemanager::standalonepopup')
->with($this->getViewVars())
->with(compact('input_id'));
}
public function showIndex()
{
return $this->app['view']
->make('backpack.filemanager::elfinder')
->with($this->getViewVars());
}
protected function getViewVars()
{
$dir = 'packages/barryvdh/'.$this->package;
$locale = str_replace('-', '_', $this->app->config->get('app.locale'));
if (! file_exists(base_path("vendor/studio-42/elfinder/js/i18n/elfinder.{$locale}.js"))) {
$locale = false;
}
$csrf = true;
return compact('dir', 'locale', 'csrf');
}
}