Conditions | 4 |
Paths | 4 |
Total Lines | 29 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace Distilleries\Expendable\Http\Controllers\Frontend; |
||
7 | public function getIndex($path = '') |
||
8 | { |
||
9 | |||
10 | $directory = explode('/', $path); |
||
11 | $directory = reset($directory); |
||
12 | $white_liste = config('expendable.folder_whitelist'); |
||
13 | if (in_array($directory, $white_liste)) |
||
14 | { |
||
15 | $path = storage_path($path); |
||
16 | $filesystem = app('files'); |
||
17 | if ($filesystem->isFile($path)) |
||
18 | { |
||
19 | $mimetype = mime_content_type($path); |
||
20 | if (@is_array(getimagesize($path))) |
||
21 | { |
||
22 | return response()->make($filesystem->get($path), 200, array('content-type' => $mimetype)); |
||
23 | } else |
||
24 | { |
||
25 | $name = explode('/', $path); |
||
26 | $name = end($name); |
||
27 | |||
28 | return response()->download($path, $name, array('content-type' => $mimetype)); |
||
29 | } |
||
30 | } |
||
31 | } |
||
32 | |||
33 | |||
34 | return abort(404); |
||
35 | } |
||
36 | } |