@@ -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 | } |
@@ -1,55 +1,55 @@ |
||
| 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 | - * ) |
|
| 30 | - * ), |
|
| 31 | - * // each volume configure (optional) |
|
| 32 | - * 'roots' => array( |
|
| 33 | - * array( |
|
| 34 | - * 'driver' => 'LocalFileSystem', |
|
| 35 | - * 'path' => '/path/to/files/', |
|
| 36 | - * 'URL' => 'http://localhost/to/files/' |
|
| 37 | - * 'plugin' => array( |
|
| 38 | - * 'Normalizer' => array( |
|
| 39 | - * 'enable' => true, |
|
| 40 | - * 'nfc' => true, |
|
| 41 | - * 'nfkc' => true, |
|
| 42 | - * 'lowercase' => false |
|
| 43 | - * ) |
|
| 44 | - * ) |
|
| 45 | - * ) |
|
| 46 | - * ) |
|
| 47 | - * ); |
|
| 48 | - * |
|
| 49 | - * @package elfinder |
|
| 50 | - * @author Naoki Sawada |
|
| 51 | - * @license New BSD |
|
| 52 | - */ |
|
| 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 | + * ) |
|
| 30 | + * ), |
|
| 31 | + * // each volume configure (optional) |
|
| 32 | + * 'roots' => array( |
|
| 33 | + * array( |
|
| 34 | + * 'driver' => 'LocalFileSystem', |
|
| 35 | + * 'path' => '/path/to/files/', |
|
| 36 | + * 'URL' => 'http://localhost/to/files/' |
|
| 37 | + * 'plugin' => array( |
|
| 38 | + * 'Normalizer' => array( |
|
| 39 | + * 'enable' => true, |
|
| 40 | + * 'nfc' => true, |
|
| 41 | + * 'nfkc' => true, |
|
| 42 | + * 'lowercase' => false |
|
| 43 | + * ) |
|
| 44 | + * ) |
|
| 45 | + * ) |
|
| 46 | + * ) |
|
| 47 | + * ); |
|
| 48 | + * |
|
| 49 | + * @package elfinder |
|
| 50 | + * @author Naoki Sawada |
|
| 51 | + * @license New BSD |
|
| 52 | + */ |
|
| 53 | 53 | class elFinderPluginNormalizer |
| 54 | 54 | { |
| 55 | 55 | private $opts = array(); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $defaults = array( |
| 59 | 59 | 'enable' => true, // For control by volume driver |
| 60 | 60 | 'nfc' => true, // Canonical Decomposition followed by Canonical Composition |
| 61 | - 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
| 61 | + 'nfkc' => true, // Compatibility Decomposition followed by Canonical |
|
| 62 | 62 | 'lowercase' => false // Make chars lowercase |
| 63 | 63 | ); |
| 64 | 64 | |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { |
| 69 | 69 | $opts = $this->getOpts($volume); |
| 70 | - if (! $opts['enable']) { |
|
| 70 | + if (!$opts['enable']) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if (isset($args['name'])) { |
| 75 | 75 | if (is_array($args['name'])) { |
| 76 | - foreach($args['name'] as $i => $name) { |
|
| 76 | + foreach ($args['name'] as $i => $name) { |
|
| 77 | 77 | $args['name'][$i] = $this->normalize($name, $opts); |
| 78 | 78 | } |
| 79 | 79 | } else { |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) { |
| 87 | 87 | $opts = $this->getOpts($volume); |
| 88 | - if (! $opts['enable']) { |
|
| 88 | + if (!$opts['enable']) { |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | private function normalize($str, $opts) { |
| 111 | 111 | if ($opts['nfc'] || $opts['nfkc']) { |
| 112 | 112 | if (class_exists('Normalizer', false)) { |
| 113 | - if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
| 113 | + if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
| 114 | 114 | $str = Normalizer::normalize($str, Normalizer::FORM_C); |
| 115 | - if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
| 115 | + if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
| 116 | 116 | $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
| 117 | 117 | } else { |
| 118 | - if (! class_exists('I18N_UnicodeNormalizer', false)) { |
|
| 118 | + if (!class_exists('I18N_UnicodeNormalizer', false)) { |
|
| 119 | 119 | @ include_once 'I18N/UnicodeNormalizer.php'; |
| 120 | 120 | } |
| 121 | 121 | if (class_exists('I18N_UnicodeNormalizer', false)) { |
@@ -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 | } |