@@ -1,55 +1,55 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * elFinder Plugin Watermark |
|
4 | - * |
|
5 | - * Print watermark on file upload. |
|
6 | - * |
|
7 | - * ex. binding, configure on connector options |
|
8 | - * $opts = array( |
|
9 | - * 'bind' => array( |
|
10 | - * 'upload.presave' => array( |
|
11 | - * 'Plugin.Watermark.onUpLoadPreSave' |
|
12 | - * ) |
|
13 | - * ), |
|
14 | - * // global configure (optional) |
|
15 | - * 'plugin' => array( |
|
16 | - * 'Watermark' => array( |
|
17 | - * 'enable' => true, // For control by volume driver |
|
18 | - * 'source' => 'logo.png', // Path to Water mark image |
|
19 | - * 'marginRight' => 5, // Margin right pixel |
|
20 | - * 'marginBottom' => 5, // Margin bottom pixel |
|
21 | - * 'quality' => 95, // JPEG image save quality |
|
22 | - * 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
23 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
24 | - * 'targetMinPixel' => 200 // Target image minimum pixel size |
|
25 | - * ) |
|
26 | - * ), |
|
27 | - * // each volume configure (optional) |
|
28 | - * 'roots' => array( |
|
29 | - * array( |
|
30 | - * 'driver' => 'LocalFileSystem', |
|
31 | - * 'path' => '/path/to/files/', |
|
32 | - * 'URL' => 'http://localhost/to/files/' |
|
33 | - * 'plugin' => array( |
|
34 | - * 'Watermark' => array( |
|
35 | - * 'enable' => true, // For control by volume driver |
|
36 | - * 'source' => 'logo.png', // Path to Water mark image |
|
37 | - * 'marginRight' => 5, // Margin right pixel |
|
38 | - * 'marginBottom' => 5, // Margin bottom pixel |
|
39 | - * 'quality' => 95, // JPEG image save quality |
|
40 | - * 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
41 | - * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
42 | - * 'targetMinPixel' => 200 // Target image minimum pixel size |
|
43 | - * ) |
|
44 | - * ) |
|
45 | - * ) |
|
46 | - * ) |
|
47 | - * ); |
|
48 | - * |
|
49 | - * @package elfinder |
|
50 | - * @author Naoki Sawada |
|
51 | - * @license New BSD |
|
52 | - */ |
|
3 | + * elFinder Plugin Watermark |
|
4 | + * |
|
5 | + * Print watermark on file upload. |
|
6 | + * |
|
7 | + * ex. binding, configure on connector options |
|
8 | + * $opts = array( |
|
9 | + * 'bind' => array( |
|
10 | + * 'upload.presave' => array( |
|
11 | + * 'Plugin.Watermark.onUpLoadPreSave' |
|
12 | + * ) |
|
13 | + * ), |
|
14 | + * // global configure (optional) |
|
15 | + * 'plugin' => array( |
|
16 | + * 'Watermark' => array( |
|
17 | + * 'enable' => true, // For control by volume driver |
|
18 | + * 'source' => 'logo.png', // Path to Water mark image |
|
19 | + * 'marginRight' => 5, // Margin right pixel |
|
20 | + * 'marginBottom' => 5, // Margin bottom pixel |
|
21 | + * 'quality' => 95, // JPEG image save quality |
|
22 | + * 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
23 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
24 | + * 'targetMinPixel' => 200 // Target image minimum pixel size |
|
25 | + * ) |
|
26 | + * ), |
|
27 | + * // each volume configure (optional) |
|
28 | + * 'roots' => array( |
|
29 | + * array( |
|
30 | + * 'driver' => 'LocalFileSystem', |
|
31 | + * 'path' => '/path/to/files/', |
|
32 | + * 'URL' => 'http://localhost/to/files/' |
|
33 | + * 'plugin' => array( |
|
34 | + * 'Watermark' => array( |
|
35 | + * 'enable' => true, // For control by volume driver |
|
36 | + * 'source' => 'logo.png', // Path to Water mark image |
|
37 | + * 'marginRight' => 5, // Margin right pixel |
|
38 | + * 'marginBottom' => 5, // Margin bottom pixel |
|
39 | + * 'quality' => 95, // JPEG image save quality |
|
40 | + * 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
41 | + * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
42 | + * 'targetMinPixel' => 200 // Target image minimum pixel size |
|
43 | + * ) |
|
44 | + * ) |
|
45 | + * ) |
|
46 | + * ) |
|
47 | + * ); |
|
48 | + * |
|
49 | + * @package elfinder |
|
50 | + * @author Naoki Sawada |
|
51 | + * @license New BSD |
|
52 | + */ |
|
53 | 53 | class elFinderPluginWatermark { |
54 | 54 | |
55 | 55 | private $opts = array(); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | public function __construct($opts) { |
59 | 59 | $defaults = array( |
60 | - 'enable' => true, // For control by volume driver |
|
60 | + 'enable' => true, // For control by volume driver |
|
61 | 61 | 'source' => 'logo.png', // Path to Water mark image |
62 | - 'marginRight' => 5, // Margin right pixel |
|
63 | - 'marginBottom' => 5, // Margin bottom pixel |
|
64 | - 'quality' => 95, // JPEG image save quality |
|
65 | - 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
66 | - 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) |
|
62 | + 'marginRight' => 5, // Margin right pixel |
|
63 | + 'marginBottom' => 5, // Margin bottom pixel |
|
64 | + 'quality' => 95, // JPEG image save quality |
|
65 | + 'transparency' => 70, // Water mark image transparency ( other than PNG ) |
|
66 | + 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field ) |
|
67 | 67 | 'targetMinPixel' => 200 // Target image minimum pixel size |
68 | 68 | ); |
69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $opts = array_merge($this->opts, $volOpts); |
80 | 80 | } |
81 | 81 | |
82 | - if (! $opts['enable']) { |
|
82 | + if (!$opts['enable']) { |
|
83 | 83 | return false; |
84 | 84 | } |
85 | 85 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | // check water mark image |
97 | - if (! file_exists($opts['source'])) { |
|
98 | - $opts['source'] = dirname(__FILE__) . "/" . $opts['source']; |
|
97 | + if (!file_exists($opts['source'])) { |
|
98 | + $opts['source'] = dirname(__FILE__)."/".$opts['source']; |
|
99 | 99 | } |
100 | 100 | if (is_readable($opts['source'])) { |
101 | 101 | $watermarkImgInfo = @getimagesize($opts['source']); |
102 | - if (! $watermarkImgInfo) { |
|
102 | + if (!$watermarkImgInfo) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | IMAGETYPE_PNG => IMG_PNG, |
120 | 120 | IMAGETYPE_WBMP => IMG_WBMP, |
121 | 121 | ); |
122 | - if (! ($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
122 | + if (!($opts['targetType'] & $imgTypes[$srcImgInfo[2]])) { |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
@@ -192,14 +192,14 @@ discard block |
||
192 | 192 | break; |
193 | 193 | case 'image/jpeg': |
194 | 194 | if (@imagetypes() & IMG_JPG) { |
195 | - $oWatermarkImg = @imagecreatefromjpeg($watermark) ; |
|
195 | + $oWatermarkImg = @imagecreatefromjpeg($watermark); |
|
196 | 196 | } else { |
197 | 197 | $ermsg = 'JPEG images are not supported'; |
198 | 198 | } |
199 | 199 | break; |
200 | 200 | case 'image/png': |
201 | 201 | if (@imagetypes() & IMG_PNG) { |
202 | - $oWatermarkImg = @imagecreatefrompng($watermark) ; |
|
202 | + $oWatermarkImg = @imagecreatefrompng($watermark); |
|
203 | 203 | } else { |
204 | 204 | $ermsg = 'PNG images are not supported'; |
205 | 205 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | break; |
218 | 218 | } |
219 | 219 | |
220 | - if (! $ermsg) { |
|
220 | + if (!$ermsg) { |
|
221 | 221 | switch ($srcImgInfo['mime']) { |
222 | 222 | case 'image/gif': |
223 | 223 | if (@imagetypes() & IMG_GIF) { |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | break; |
229 | 229 | case 'image/jpeg': |
230 | 230 | if (@imagetypes() & IMG_JPG) { |
231 | - $oSrcImg = @imagecreatefromjpeg($src) ; |
|
231 | + $oSrcImg = @imagecreatefromjpeg($src); |
|
232 | 232 | } else { |
233 | 233 | $ermsg = 'JPEG images are not supported'; |
234 | 234 | } |
235 | 235 | break; |
236 | 236 | case 'image/png': |
237 | 237 | if (@imagetypes() & IMG_PNG) { |
238 | - $oSrcImg = @imagecreatefrompng($src) ; |
|
238 | + $oSrcImg = @imagecreatefrompng($src); |
|
239 | 239 | } else { |
240 | 240 | $ermsg = 'PNG images are not supported'; |
241 | 241 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | if ($srcImgInfo['mime'] === 'image/png') { |
262 | 262 | if (function_exists('imagecolorallocatealpha')) { |
263 | 263 | $bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127); |
264 | - imagefill($oSrcImg, 0, 0 , $bg); |
|
264 | + imagefill($oSrcImg, 0, 0, $bg); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 |
@@ -104,20 +104,24 @@ |
||
104 | 104 | private function normalize($str, $opts) { |
105 | 105 | if ($opts['nfc'] || $opts['nfkc']) { |
106 | 106 | if (class_exists('Normalizer')) { |
107 | - if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
108 | - $str = Normalizer::normalize($str, Normalizer::FORM_C); |
|
109 | - if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
110 | - $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
|
107 | + if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) { |
|
108 | + $str = Normalizer::normalize($str, Normalizer::FORM_C); |
|
109 | + } |
|
110 | + if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) { |
|
111 | + $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
|
112 | + } |
|
111 | 113 | } else { |
112 | 114 | if (! class_exists('I18N_UnicodeNormalizer')) { |
113 | 115 | @ include_once 'I18N/UnicodeNormalizer.php'; |
114 | 116 | } |
115 | 117 | if (class_exists('I18N_UnicodeNormalizer')) { |
116 | 118 | $normalizer = new I18N_UnicodeNormalizer(); |
117 | - if ($opts['nfc']) |
|
118 | - $str = $normalizer->normalize($str, 'NFC'); |
|
119 | - if ($opts['nfkc']) |
|
120 | - $str = $normalizer->normalize($str, 'NFKC'); |
|
119 | + if ($opts['nfc']) { |
|
120 | + $str = $normalizer->normalize($str, 'NFC'); |
|
121 | + } |
|
122 | + if ($opts['nfkc']) { |
|
123 | + $str = $normalizer->normalize($str, 'NFKC'); |
|
124 | + } |
|
121 | 125 | } |
122 | 126 | } |
123 | 127 | } |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | |
59 | 59 | public function __construct($opts) { |
60 | 60 | $defaults = array( |
61 | - 'enable' => true, // For control by volume driver |
|
62 | - 'nfc' => true, // Canonical Decomposition followed by Canonical Composition |
|
63 | - 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
61 | + 'enable' => true, // For control by volume driver |
|
62 | + 'nfc' => true, // Canonical Decomposition followed by Canonical Composition |
|
63 | + 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
64 | 64 | 'lowercase' => false, // Make chars lowercase |
65 | 65 | 'convmap' => array()// Convert map ('FROM' => 'TO') array |
66 | 66 | ); |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | |
71 | 71 | public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { |
72 | 72 | $opts = $this->getOpts($volume); |
73 | - if (! $opts['enable']) { |
|
73 | + if (!$opts['enable']) { |
|
74 | 74 | return false; |
75 | 75 | } |
76 | 76 | |
77 | 77 | if (isset($args['name'])) { |
78 | 78 | if (is_array($args['name'])) { |
79 | - foreach($args['name'] as $i => $name) { |
|
79 | + foreach ($args['name'] as $i => $name) { |
|
80 | 80 | $args['name'][$i] = $this->normalize($name, $opts); |
81 | 81 | } |
82 | 82 | } else { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | |
89 | 89 | public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) { |
90 | 90 | $opts = $this->getOpts($volume); |
91 | - if (! $opts['enable']) { |
|
91 | + if (!$opts['enable']) { |
|
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | private function normalize($str, $opts) { |
114 | 114 | if ($opts['nfc'] || $opts['nfkc']) { |
115 | 115 | if (class_exists('Normalizer', false)) { |
116 | - if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
116 | + if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
117 | 117 | $str = Normalizer::normalize($str, Normalizer::FORM_C); |
118 | - if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
118 | + if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
119 | 119 | $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
120 | 120 | } else { |
121 | - if (! class_exists('I18N_UnicodeNormalizer', false)) { |
|
121 | + if (!class_exists('I18N_UnicodeNormalizer', false)) { |
|
122 | 122 | @ include_once 'I18N/UnicodeNormalizer.php'; |
123 | 123 | } |
124 | 124 | if (class_exists('I18N_UnicodeNormalizer', false)) { |
@@ -1,57 +1,57 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * elFinder Plugin Normalizer |
|
4 | - * |
|
5 | - * UTF-8 Normalizer of file-name and file-path etc. |
|
6 | - * nfc(NFC): Canonical Decomposition followed by Canonical Composition |
|
7 | - * nfkc(NFKC): Compatibility Decomposition followed by Canonical |
|
8 | - * |
|
9 | - * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0) |
|
10 | - * or PEAR package "I18N_UnicodeNormalizer" |
|
11 | - * |
|
12 | - * ex. binding, configure on connector options |
|
13 | - * $opts = array( |
|
14 | - * 'bind' => array( |
|
15 | - * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array( |
|
16 | - * 'Plugin.Normalizer.cmdPreprocess' |
|
17 | - * ), |
|
18 | - * 'upload.presave' => array( |
|
19 | - * 'Plugin.Normalizer.onUpLoadPreSave' |
|
20 | - * ) |
|
21 | - * ), |
|
22 | - * // global configure (optional) |
|
23 | - * 'plugin' => array( |
|
24 | - * 'Normalizer' => array( |
|
25 | - * 'enable' => true, |
|
26 | - * 'nfc' => true, |
|
27 | - * 'nfkc' => true, |
|
28 | - * 'lowercase' => false, |
|
29 | - * 'convmap' => array() |
|
30 | - * ) |
|
31 | - * ), |
|
32 | - * // each volume configure (optional) |
|
33 | - * 'roots' => array( |
|
34 | - * array( |
|
35 | - * 'driver' => 'LocalFileSystem', |
|
36 | - * 'path' => '/path/to/files/', |
|
37 | - * 'URL' => 'http://localhost/to/files/' |
|
38 | - * 'plugin' => array( |
|
39 | - * 'Normalizer' => array( |
|
40 | - * 'enable' => true, |
|
41 | - * 'nfc' => true, |
|
42 | - * 'nfkc' => true, |
|
43 | - * 'lowercase' => false, |
|
44 | - * 'convmap' => array() |
|
45 | - * ) |
|
46 | - * ) |
|
47 | - * ) |
|
48 | - * ) |
|
49 | - * ); |
|
50 | - * |
|
51 | - * @package elfinder |
|
52 | - * @author Naoki Sawada |
|
53 | - * @license New BSD |
|
54 | - */ |
|
3 | + * elFinder Plugin Normalizer |
|
4 | + * |
|
5 | + * UTF-8 Normalizer of file-name and file-path etc. |
|
6 | + * nfc(NFC): Canonical Decomposition followed by Canonical Composition |
|
7 | + * nfkc(NFKC): Compatibility Decomposition followed by Canonical |
|
8 | + * |
|
9 | + * This plugin require Class "Normalizer" (PHP 5 >= 5.3.0, PECL intl >= 1.0.0) |
|
10 | + * or PEAR package "I18N_UnicodeNormalizer" |
|
11 | + * |
|
12 | + * ex. binding, configure on connector options |
|
13 | + * $opts = array( |
|
14 | + * 'bind' => array( |
|
15 | + * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array( |
|
16 | + * 'Plugin.Normalizer.cmdPreprocess' |
|
17 | + * ), |
|
18 | + * 'upload.presave' => array( |
|
19 | + * 'Plugin.Normalizer.onUpLoadPreSave' |
|
20 | + * ) |
|
21 | + * ), |
|
22 | + * // global configure (optional) |
|
23 | + * 'plugin' => array( |
|
24 | + * 'Normalizer' => array( |
|
25 | + * 'enable' => true, |
|
26 | + * 'nfc' => true, |
|
27 | + * 'nfkc' => true, |
|
28 | + * 'lowercase' => false, |
|
29 | + * 'convmap' => array() |
|
30 | + * ) |
|
31 | + * ), |
|
32 | + * // each volume configure (optional) |
|
33 | + * 'roots' => array( |
|
34 | + * array( |
|
35 | + * 'driver' => 'LocalFileSystem', |
|
36 | + * 'path' => '/path/to/files/', |
|
37 | + * 'URL' => 'http://localhost/to/files/' |
|
38 | + * 'plugin' => array( |
|
39 | + * 'Normalizer' => array( |
|
40 | + * 'enable' => true, |
|
41 | + * 'nfc' => true, |
|
42 | + * 'nfkc' => true, |
|
43 | + * 'lowercase' => false, |
|
44 | + * 'convmap' => array() |
|
45 | + * ) |
|
46 | + * ) |
|
47 | + * ) |
|
48 | + * ) |
|
49 | + * ); |
|
50 | + * |
|
51 | + * @package elfinder |
|
52 | + * @author Naoki Sawada |
|
53 | + * @license New BSD |
|
54 | + */ |
|
55 | 55 | class elFinderPluginNormalizer |
56 | 56 | { |
57 | 57 | private $opts = array(); |
@@ -1,48 +1,48 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * elFinder Plugin Sanitizer |
|
4 | - * |
|
5 | - * Sanitizer of file-name and file-path etc. |
|
6 | - * |
|
7 | - * ex. binding, configure on connector options |
|
8 | - * $opts = array( |
|
9 | - * 'bind' => array( |
|
10 | - * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array( |
|
11 | - * 'Plugin.Sanitizer.cmdPreprocess' |
|
12 | - * ), |
|
13 | - * 'upload.presave' => array( |
|
14 | - * 'Plugin.Sanitizer.onUpLoadPreSave' |
|
15 | - * ) |
|
16 | - * ), |
|
17 | - * // global configure (optional) |
|
18 | - * 'plugin' => array( |
|
19 | - * 'Sanitizer' => array( |
|
20 | - * 'enable' => true, |
|
21 | - * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
22 | - * 'replace' => '_' // replace to this |
|
23 | - * ) |
|
24 | - * ), |
|
25 | - * // each volume configure (optional) |
|
26 | - * 'roots' => array( |
|
27 | - * array( |
|
28 | - * 'driver' => 'LocalFileSystem', |
|
29 | - * 'path' => '/path/to/files/', |
|
30 | - * 'URL' => 'http://localhost/to/files/' |
|
31 | - * 'plugin' => array( |
|
32 | - * 'Sanitizer' => array( |
|
33 | - * 'enable' => true, |
|
34 | - * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
35 | - * 'replace' => '_' // replace to this |
|
36 | - * ) |
|
37 | - * ) |
|
38 | - * ) |
|
39 | - * ) |
|
40 | - * ); |
|
41 | - * |
|
42 | - * @package elfinder |
|
43 | - * @author Naoki Sawada |
|
44 | - * @license New BSD |
|
45 | - */ |
|
3 | + * elFinder Plugin Sanitizer |
|
4 | + * |
|
5 | + * Sanitizer of file-name and file-path etc. |
|
6 | + * |
|
7 | + * ex. binding, configure on connector options |
|
8 | + * $opts = array( |
|
9 | + * 'bind' => array( |
|
10 | + * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre' => array( |
|
11 | + * 'Plugin.Sanitizer.cmdPreprocess' |
|
12 | + * ), |
|
13 | + * 'upload.presave' => array( |
|
14 | + * 'Plugin.Sanitizer.onUpLoadPreSave' |
|
15 | + * ) |
|
16 | + * ), |
|
17 | + * // global configure (optional) |
|
18 | + * 'plugin' => array( |
|
19 | + * 'Sanitizer' => array( |
|
20 | + * 'enable' => true, |
|
21 | + * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
22 | + * 'replace' => '_' // replace to this |
|
23 | + * ) |
|
24 | + * ), |
|
25 | + * // each volume configure (optional) |
|
26 | + * 'roots' => array( |
|
27 | + * array( |
|
28 | + * 'driver' => 'LocalFileSystem', |
|
29 | + * 'path' => '/path/to/files/', |
|
30 | + * 'URL' => 'http://localhost/to/files/' |
|
31 | + * 'plugin' => array( |
|
32 | + * 'Sanitizer' => array( |
|
33 | + * 'enable' => true, |
|
34 | + * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
35 | + * 'replace' => '_' // replace to this |
|
36 | + * ) |
|
37 | + * ) |
|
38 | + * ) |
|
39 | + * ) |
|
40 | + * ); |
|
41 | + * |
|
42 | + * @package elfinder |
|
43 | + * @author Naoki Sawada |
|
44 | + * @license New BSD |
|
45 | + */ |
|
46 | 46 | class elFinderPluginSanitizer |
47 | 47 | { |
48 | 48 | private $opts = array(); |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | public function __construct($opts) { |
51 | 51 | $defaults = array( |
52 | - 'enable' => true, // For control by volume driver |
|
53 | - 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars |
|
52 | + 'enable' => true, // For control by volume driver |
|
53 | + 'targets' => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars |
|
54 | 54 | 'replace' => '_' // replace to this |
55 | 55 | ); |
56 | 56 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | |
60 | 60 | public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { |
61 | 61 | $opts = $this->getOpts($volume); |
62 | - if (! $opts['enable']) { |
|
62 | + if (!$opts['enable']) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
66 | 66 | if (isset($args['name'])) { |
67 | 67 | if (is_array($args['name'])) { |
68 | - foreach($args['name'] as $i => $name) { |
|
68 | + foreach ($args['name'] as $i => $name) { |
|
69 | 69 | $args['name'][$i] = $this->sanitizeFileName($name, $opts); |
70 | 70 | } |
71 | 71 | } else { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) { |
79 | 79 | $opts = $this->getOpts($volume); |
80 | - if (! $opts['enable']) { |
|
80 | + if (!$opts['enable']) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | private function sanitizeFileName($filename, $opts, $allows = array()) { |
103 | - $targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets']; |
|
103 | + $targets = $allows ? array_diff($opts['targets'], $allows) : $opts['targets']; |
|
104 | 104 | return str_replace($targets, $opts['replace'], $filename); |
105 | 105 | } |
106 | 106 | } |