|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Recca0120\Elfinder\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use Recca0120\Elfinder\Connector; |
|
7
|
|
|
use Illuminate\Routing\Controller; |
|
8
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
9
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory; |
|
10
|
|
|
|
|
11
|
|
|
class ElfinderController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* $responseFactory. |
|
15
|
|
|
* |
|
16
|
|
|
* @var \Illuminate\Contracts\Routing\ResponseFactory |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $responseFactory; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* __construct. |
|
22
|
|
|
* |
|
23
|
|
|
* @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct(ResponseFactory $responseFactory) |
|
26
|
|
|
{ |
|
27
|
|
|
$this->responseFactory = $responseFactory; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* elfinder. |
|
32
|
|
|
* |
|
33
|
|
|
* @param \Illuminate\Http\Request $request |
|
34
|
|
|
* @return \Illuminate\Http\Response |
|
35
|
|
|
*/ |
|
36
|
|
|
public function elfinder(Request $request) |
|
37
|
|
|
{ |
|
38
|
|
|
$token = null; |
|
39
|
|
|
if ($request->hasSession() === true) { |
|
40
|
|
|
$token = $request->session()->token(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return $this->responseFactory->view('elfinder::elfinder', compact('token')); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* connector. |
|
48
|
|
|
* |
|
49
|
|
|
* @param \Recca0120\Elfinder\Connector $elfinder |
|
|
|
|
|
|
50
|
|
|
* @return mixed |
|
51
|
|
|
*/ |
|
52
|
|
|
public function connector(Connector $connector) |
|
53
|
|
|
{ |
|
54
|
|
|
return $connector->run(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* sound. |
|
59
|
|
|
* |
|
60
|
|
|
* @param \Illuminate\Filesystem\Filesystem $files |
|
61
|
|
|
* @param \Illuminate\Http\Request $request |
|
62
|
|
|
* @param string $file |
|
63
|
|
|
* @return \Illuminate\Http\Response |
|
64
|
|
|
*/ |
|
65
|
|
|
public function sound(Filesystem $files, Request $request, $file) |
|
66
|
|
|
{ |
|
67
|
|
|
$filename = __DIR__.'/../../../resources/elfinder/sounds/'.$file; |
|
68
|
|
|
$mimeType = $files->mimeType($filename); |
|
69
|
|
|
$lastModified = $files->lastModified($filename); |
|
70
|
|
|
$eTag = sha1_file($filename); |
|
71
|
|
|
$headers = [ |
|
72
|
|
|
'content-type' => $mimeType, |
|
73
|
|
|
'last-modified' => date('D, d M Y H:i:s ', $lastModified).'GMT', |
|
74
|
|
|
]; |
|
75
|
|
|
|
|
76
|
|
|
if (@strtotime($request->server('HTTP_IF_MODIFIED_SINCE')) === $lastModified || |
|
77
|
|
|
trim($request->server('HTTP_IF_NONE_MATCH'), '"') === $eTag |
|
78
|
|
|
) { |
|
79
|
|
|
$response = $this->responseFactory->make(null, 304, $headers); |
|
80
|
|
|
} else { |
|
81
|
|
|
$response = $this->responseFactory->stream(function () use ($filename) { |
|
82
|
|
|
$out = fopen('php://output', 'wb'); |
|
83
|
|
|
$file = fopen($filename, 'rb'); |
|
84
|
|
|
stream_copy_to_stream($file, $out, filesize($filename)); |
|
85
|
|
|
fclose($out); |
|
86
|
|
|
fclose($file); |
|
87
|
|
|
}, 200, $headers); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
return $response->setEtag($eTag); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.