AutoRotate/.htaccess000055500000000355150732266000010436 0ustar00 Order allow,deny Deny from all AutoRotate/plugin.php000064400000012752150732266000010652 0ustar00 array( * 'upload.presave' => array( * 'Plugin.AutoRotate.onUpLoadPreSave' * ) * ), * // global configure (optional) * 'plugin' => array( * 'AutoRotate' => array( * 'enable' => true, // For control by volume driver * 'quality' => 95, // JPEG image save quality * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ), * // each volume configure (optional) * 'roots' => array( * array( * 'driver' => 'LocalFileSystem', * 'path' => '/path/to/files/', * 'URL' => 'http://localhost/to/files/' * 'plugin' => array( * 'AutoRotate' => array( * 'enable' => true, // For control by volume driver * 'quality' => 95, // JPEG image save quality * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ) * ) * ) * ); * * @package elfinder * @author Naoki Sawada * @license New BSD */ class elFinderPluginAutoRotate extends elFinderPlugin { public function __construct($opts) { $defaults = array( 'enable' => true, // For control by volume driver 'quality' => 95, // JPEG image save quality 'offDropWith' => null, // To disable it if it is dropped with pressing the meta key // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value // In case of using any key, specify it as an array 'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId" ); $this->opts = array_merge($defaults, $opts); } public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) { if (!$src) { return false; } $opts = $this->getCurrentOpts($volume); if (!$this->iaEnabled($opts, $elfinder)) { return false; } $imageType = null; $srcImgInfo = null; if (extension_loaded('fileinfo') && function_exists('mime_content_type')) { $mime = mime_content_type($src); if (substr($mime, 0, 5) !== 'image') { return false; } } if (extension_loaded('exif') && function_exists('exif_imagetype')) { $imageType = exif_imagetype($src); if ($imageType === false) { return false; } } else { $srcImgInfo = getimagesize($src); if ($srcImgInfo === false) { return false; } $imageType = $srcImgInfo[2]; } // check target image type if ($imageType !== IMAGETYPE_JPEG) { return false; } if (!$srcImgInfo) { $srcImgInfo = getimagesize($src); } return $this->rotate($volume, $src, $srcImgInfo, $opts['quality']); } private function rotate($volume, $src, $srcImgInfo, $quality) { if (!function_exists('exif_read_data')) { return false; } $degree = 0; $errlev =error_reporting(); error_reporting($errlev ^ E_WARNING); $exif = exif_read_data($src); error_reporting($errlev); if ($exif && !empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 8: $degree = 270; break; case 3: $degree = 180; break; case 6: $degree = 90; break; } } if (!$degree) { return false; } $opts = array( 'degree' => $degree, 'jpgQuality' => $quality, 'checkAnimated' => true ); return $volume->imageUtil('rotate', $src, $opts); } } Normalizer/.htaccess000055500000000355150732266000010471 0ustar00 Order allow,deny Deny from all Normalizer/plugin.php000064400000017533150732266000010707 0ustar00= 5.3.0, PECL intl >= 1.0.0) * or PEAR package "I18N_UnicodeNormalizer" * ex. binding, configure on connector options * $opts = array( * 'bind' => array( * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => array( * 'Plugin.Normalizer.cmdPreprocess' * ), * 'upload.presave paste.copyfrom' => array( * 'Plugin.Normalizer.onUpLoadPreSave' * ) * ), * // global configure (optional) * 'plugin' => array( * 'Normalizer' => array( * 'enable' => true, * 'nfc' => true, * 'nfkc' => true, * 'umlauts' => false, * 'lowercase' => false, * 'convmap' => array() * ) * ), * // each volume configure (optional) * 'roots' => array( * array( * 'driver' => 'LocalFileSystem', * 'path' => '/path/to/files/', * 'URL' => 'http://localhost/to/files/' * 'plugin' => array( * 'Normalizer' => array( * 'enable' => true, * 'nfc' => true, * 'nfkc' => true, * 'umlauts' => false, * 'lowercase' => false, * 'convmap' => array() * ) * ) * ) * ) * ); * * @package elfinder * @author Naoki Sawada * @license New BSD */ class elFinderPluginNormalizer extends elFinderPlugin { private $replaced = array(); private $keyMap = array( 'ls' => 'intersect', 'upload' => 'renames', 'mkdir' => array('name', 'dirs') ); public function __construct($opts) { $defaults = array( 'enable' => true, // For control by volume driver 'nfc' => true, // Canonical Decomposition followed by Canonical Composition 'nfkc' => true, // Compatibility Decomposition followed by Canonical 'umlauts' => false, // Convert umlauts with their closest 7 bit ascii equivalent 'lowercase' => false, // Make chars lowercase 'convmap' => array()// Convert map ('FROM' => 'TO') array ); $this->opts = array_merge($defaults, $opts); } public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { $opts = $this->getCurrentOpts($volume); if (!$opts['enable']) { return false; } $this->replaced[$cmd] = array(); $key = (isset($this->keyMap[$cmd])) ? $this->keyMap[$cmd] : 'name'; if (is_array($key)) { $keys = $key; } else { $keys = array($key); } foreach ($keys as $key) { if (isset($args[$key])) { if (is_array($args[$key])) { foreach ($args[$key] as $i => $name) { if ($cmd === 'mkdir' && $key === 'dirs') { // $name need '/' as prefix see #2607 $name = '/' . ltrim($name, '/'); $_names = explode('/', $name); $_res = array(); foreach ($_names as $_name) { $_res[] = $this->normalize($_name, $opts); } $this->replaced[$cmd][$name] = $args[$key][$i] = join('/', $_res); } else { $this->replaced[$cmd][$name] = $args[$key][$i] = $this->normalize($name, $opts); } } } else if ($args[$key] !== '') { $name = $args[$key]; $this->replaced[$cmd][$name] = $args[$key] = $this->normalize($name, $opts); } } } if ($cmd === 'ls' || $cmd === 'mkdir') { if (!empty($this->replaced[$cmd])) { // un-regist for legacy settings $elfinder->unbind($cmd, array($this, 'cmdPostprocess')); $elfinder->bind($cmd, array($this, 'cmdPostprocess')); } } return true; } public function cmdPostprocess($cmd, &$result, $args, $elfinder, $volume) { if ($cmd === 'ls') { if (!empty($result['list']) && !empty($this->replaced['ls'])) { foreach ($result['list'] as $hash => $name) { if ($keys = array_keys($this->replaced['ls'], $name)) { if (count($keys) === 1) { $result['list'][$hash] = $keys[0]; } else { $result['list'][$hash] = $keys; } } } } } else if ($cmd === 'mkdir') { if (!empty($result['hashes']) && !empty($this->replaced['mkdir'])) { foreach ($result['hashes'] as $name => $hash) { if ($keys = array_keys($this->replaced['mkdir'], $name)) { $result['hashes'][$keys[0]] = $hash; } } } } } // NOTE: $thash is directory hash so it unneed to process at here public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) { $opts = $this->getCurrentOpts($volume); if (!$opts['enable']) { return false; } $name = $this->normalize($name, $opts); return true; } protected function normalize($str, $opts) { if ($opts['nfc'] || $opts['nfkc']) { if (class_exists('Normalizer', false)) { if ($opts['nfc'] && !Normalizer::isNormalized($str, Normalizer::FORM_C)) $str = Normalizer::normalize($str, Normalizer::FORM_C); if ($opts['nfkc'] && !Normalizer::isNormalized($str, Normalizer::FORM_KC)) $str = Normalizer::normalize($str, Normalizer::FORM_KC); } else { if (!class_exists('I18N_UnicodeNormalizer', false)) { if (is_readable('I18N/UnicodeNormalizer.php')) { include_once 'I18N/UnicodeNormalizer.php'; } else { trigger_error('Plugin Normalizer\'s options "nfc" or "nfkc" require PHP class "Normalizer" or PEAR package "I18N_UnicodeNormalizer"', E_USER_WARNING); } } if (class_exists('I18N_UnicodeNormalizer', false)) { $normalizer = new I18N_UnicodeNormalizer(); if ($opts['nfc']) $str = $normalizer->normalize($str, 'NFC'); if ($opts['nfkc']) $str = $normalizer->normalize($str, 'NFKC'); } } } if ($opts['umlauts']) { if (strpos($str = htmlentities($str, ENT_QUOTES, 'UTF-8'), '&') !== false) { $str = html_entity_decode(preg_replace('~&([a-z]{1,2})(?:acute|caron|cedil|circ|grave|lig|orn|ring|slash|tilde|uml);~i', '$1', $str), ENT_QUOTES, 'utf-8'); } } if ($opts['convmap'] && is_array($opts['convmap'])) { $str = strtr($str, $opts['convmap']); } if ($opts['lowercase']) { if (function_exists('mb_strtolower')) { $str = mb_strtolower($str, 'UTF-8'); } else { $str = strtolower($str); } } return $str; } } .htaccess000055500000000355150732266000006347 0ustar00 Order allow,deny Deny from all AutoResize/.htaccess000055500000000355150732266000010441 0ustar00 Order allow,deny Deny from all AutoResize/plugin.php000064400000015464150732266000010660 0ustar00 array( * 'upload.presave' => array( * 'Plugin.AutoResize.onUpLoadPreSave' * ) * ), * // global configure (optional) * 'plugin' => array( * 'AutoResize' => array( * 'enable' => true, // For control by volume driver * 'maxWidth' => 1024, // Path to Water mark image * 'maxHeight' => 1024, // Margin right pixel * 'quality' => 95, // JPEG image save quality * 'preserveExif' => false, // Preserve EXIF data (Imagick only) * 'forceEffect' => false, // For change quality or make progressive JPEG of small images * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ), * // each volume configure (optional) * 'roots' => array( * array( * 'driver' => 'LocalFileSystem', * 'path' => '/path/to/files/', * 'URL' => 'http://localhost/to/files/' * 'plugin' => array( * 'AutoResize' => array( * 'enable' => true, // For control by volume driver * 'maxWidth' => 1024, // Path to Water mark image * 'maxHeight' => 1024, // Margin right pixel * 'quality' => 95, // JPEG image save quality * 'preserveExif' => false, // Preserve EXIF data (Imagick only) * 'forceEffect' => false, // For change quality or make progressive JPEG of small images * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ) * ) * ) * ); * * @package elfinder * @author Naoki Sawada * @license New BSD */ class elFinderPluginAutoResize extends elFinderPlugin { public function __construct($opts) { $defaults = array( 'enable' => true, // For control by volume driver 'maxWidth' => 1024, // Path to Water mark image 'maxHeight' => 1024, // Margin right pixel 'quality' => 95, // JPEG image save quality 'preserveExif' => false, // Preserve EXIF data (Imagick only) 'forceEffect' => false, // For change quality or make progressive JPEG of small images 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field ) 'offDropWith' => null, // To disable it if it is dropped with pressing the meta key // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value // In case of using any key, specify it as an array 'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId" ); $this->opts = array_merge($defaults, $opts); } public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) { if (!$src) { return false; } $opts = $this->getCurrentOpts($volume); if (!$this->iaEnabled($opts, $elfinder)) { return false; } $imageType = null; $srcImgInfo = null; if (extension_loaded('fileinfo') && function_exists('mime_content_type')) { $mime = mime_content_type($src); if (substr($mime, 0, 5) !== 'image') { return false; } } if (extension_loaded('exif') && function_exists('exif_imagetype')) { $imageType = exif_imagetype($src); if ($imageType === false) { return false; } } else { $srcImgInfo = getimagesize($src); if ($srcImgInfo === false) { return false; } $imageType = $srcImgInfo[2]; } // check target image type $imgTypes = array( IMAGETYPE_GIF => IMG_GIF, IMAGETYPE_JPEG => IMG_JPEG, IMAGETYPE_PNG => IMG_PNG, IMAGETYPE_BMP => IMG_WBMP, IMAGETYPE_WBMP => IMG_WBMP ); if (!isset($imgTypes[$imageType]) || !($opts['targetType'] & $imgTypes[$imageType])) { return false; } if (!$srcImgInfo) { $srcImgInfo = getimagesize($src); } if ($opts['forceEffect'] || $srcImgInfo[0] > $opts['maxWidth'] || $srcImgInfo[1] > $opts['maxHeight']) { return $this->resize($volume, $src, $srcImgInfo, $opts['maxWidth'], $opts['maxHeight'], $opts['quality'], $opts['preserveExif']); } return false; } private function resize($volume, $src, $srcImgInfo, $maxWidth, $maxHeight, $jpgQuality, $preserveExif) { $zoom = min(($maxWidth / $srcImgInfo[0]), ($maxHeight / $srcImgInfo[1])); $width = round($srcImgInfo[0] * $zoom); $height = round($srcImgInfo[1] * $zoom); $unenlarge = true; $checkAnimated = true; return $volume->imageUtil('resize', $src, compact('width', 'height', 'jpgQuality', 'preserveExif', 'unenlarge', 'checkAnimated')); } } Sanitizer/.htaccess000055500000000355150732266000010317 0ustar00 Order allow,deny Deny from all Sanitizer/plugin.php000064400000013415150732266000010530 0ustar00 array( * 'upload.pre mkdir.pre mkfile.pre rename.pre archive.pre ls.pre' => array( * 'Plugin.Sanitizer.cmdPreprocess' * ), * 'upload.presave paste.copyfrom' => array( * 'Plugin.Sanitizer.onUpLoadPreSave' * ) * ), * // global configure (optional) * 'plugin' => array( * 'Sanitizer' => array( * 'enable' => true, * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars * 'replace' => '_', // replace to this * 'callBack' => null // Or @callable sanitize function * ) * ), * // each volume configure (optional) * 'roots' => array( * array( * 'driver' => 'LocalFileSystem', * 'path' => '/path/to/files/', * 'URL' => 'http://localhost/to/files/' * 'plugin' => array( * 'Sanitizer' => array( * 'enable' => true, * 'targets' => array('\\','/',':','*','?','"','<','>','|'), // target chars * 'replace' => '_', // replace to this * 'callBack' => null // Or @callable sanitize function * ) * ) * ) * ) * ); * * @package elfinder * @author Naoki Sawada * @license New BSD */ class elFinderPluginSanitizer extends elFinderPlugin { private $replaced = array(); private $keyMap = array( 'ls' => 'intersect', 'upload' => 'renames', 'mkdir' => array('name', 'dirs') ); public function __construct($opts) { $defaults = array( 'enable' => true, // For control by volume driver 'targets' => array('\\', '/', ':', '*', '?', '"', '<', '>', '|'), // target chars 'replace' => '_', // replace to this 'callBack' => null // Or callable sanitize function ); $this->opts = array_merge($defaults, $opts); } public function cmdPreprocess($cmd, &$args, $elfinder, $volume) { $opts = $this->getCurrentOpts($volume); if (!$opts['enable']) { return false; } $this->replaced[$cmd] = array(); $key = (isset($this->keyMap[$cmd])) ? $this->keyMap[$cmd] : 'name'; if (is_array($key)) { $keys = $key; } else { $keys = array($key); } foreach ($keys as $key) { if (isset($args[$key])) { if (is_array($args[$key])) { foreach ($args[$key] as $i => $name) { if ($cmd === 'mkdir' && $key === 'dirs') { // $name need '/' as prefix see #2607 $name = '/' . ltrim($name, '/'); $_names = explode('/', $name); $_res = array(); foreach ($_names as $_name) { $_res[] = $this->sanitizeFileName($_name, $opts); } $this->replaced[$cmd][$name] = $args[$key][$i] = join('/', $_res); } else { $this->replaced[$cmd][$name] = $args[$key][$i] = $this->sanitizeFileName($name, $opts); } } } else if ($args[$key] !== '') { $name = $args[$key]; $this->replaced[$cmd][$name] = $args[$key] = $this->sanitizeFileName($name, $opts); } } } if ($cmd === 'ls' || $cmd === 'mkdir') { if (!empty($this->replaced[$cmd])) { // un-regist for legacy settings $elfinder->unbind($cmd, array($this, 'cmdPostprocess')); $elfinder->bind($cmd, array($this, 'cmdPostprocess')); } } return true; } public function cmdPostprocess($cmd, &$result, $args, $elfinder, $volume) { if ($cmd === 'ls') { if (!empty($result['list']) && !empty($this->replaced['ls'])) { foreach ($result['list'] as $hash => $name) { if ($keys = array_keys($this->replaced['ls'], $name)) { if (count($keys) === 1) { $result['list'][$hash] = $keys[0]; } else { $result['list'][$hash] = $keys; } } } } } else if ($cmd === 'mkdir') { if (!empty($result['hashes']) && !empty($this->replaced['mkdir'])) { foreach ($result['hashes'] as $name => $hash) { if ($keys = array_keys($this->replaced['mkdir'], $name)) { $result['hashes'][$keys[0]] = $hash; } } } } } // NOTE: $thash is directory hash so it unneed to process at here public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) { $opts = $this->getCurrentOpts($volume); if (!$opts['enable']) { return false; } $name = $this->sanitizeFileName($name, $opts); return true; } protected function sanitizeFileName($filename, $opts) { if (!empty($opts['callBack']) && is_callable($opts['callBack'])) { return call_user_func_array($opts['callBack'], array($filename, $opts)); } return str_replace($opts['targets'], $opts['replace'], $filename); } } Watermark/.htaccess000055500000000355150732266000010304 0ustar00 Order allow,deny Deny from all Watermark/logo.png000064400000021343150732266000010153 0ustar00PNG  IHDRxx9d6"IDATxP@f&m۶-ٶm۶m۶g[uM27LWe;Io8+ +Š Ub,&M2)D!Z'ʂ8E@ et: 0GҲU/v{/; \%_2`EBŐ=$7x|mx&ۆNN8~4Kn,lUH2__F߾} ?~ITʩŖ6E#lY}ц__Gm_jAyS'MZ=*㳆aVgTsMaա[ШT}%W$!bLܧد NkPe8z&׍ϟ?Ô4JK\^/7[ 0w5 7!}΂c{M9=7o,p9tƊNk<2wL\Zʭ?uZb⨮YCM1\&Uf}#ϟ=Ӫ䟺&3Kh@Bgx Шu48uR~*.lmOqHyݵHR'KInU#L+p罺w\C޼yzrSK˔gĂ7 i.1.<ˋ7d˖ҥLH0}h޴1O\"ׯ_ >~5$sK-;I4ϼ:A|M+4A2x`o;y:,]jT By*̛Ò9.N -rHM$Qϓr0yy=‹lN}•+W< ~ | P׆ L2>#6Ej<;D+œ]W-kfrd,@:= Kr|£W/J:xQ(r5dk?v,Y-,wn ~NE (đ=.ʭJy Ǐ°uiǎn7Mrt1/;#gt2x>KjZ56X2>n;TlЀJV8.v;2A72c 6(d9-oso)S ~% >}HHdO,{4ͧgO7T?ki֧g7f$IĪimg`Ɋ:k[~>wPq,Yt]n/wnw7]躻ߺ'Tgez3/דS^=NqFO`+,'~ꥦ?kKή 5#kp*r8\y+'ߠ0GЎ/g_x/ȵ: 8fdh¨07t Z d7Qt H}M',Nή:R){vށb5 5@sgϢ[7Scz (o@z?p4'8-3 5\h]^Ddmm9o:&x߾.c(/6o\)Y񲭍N!Z S`oڰA E ޴aA>?WW/v >lmRI2e@\}|+/('m>,]u)97\]_HMG-e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7 ISW:!n~}~T ;ei7N0Gո1: wܨ*6 v$5 =7>z uqPW]9.#8,Bռ̞5T.k1c?r 5 ;R( A@0ջ:ӆeXh`խTIC}lIFc | LhTIZ| B;$V\Ɠ8yQdc70l!ΆG@"x Vt.>A]C)oZČhȒ5ّK? jkky-Z 6tPq8PQJWp l*6E'޷ۢT0Y~|4N((+.΂S}ӥ~ ^7v<=!d73'hc\HSe} 0 /\ ~dx@lܓRjR&"&ƃj4LNHP#qN2%1Y3P,ŀKGϼҢD3Vl0+ ßS#AVՒNӇʞ> KmQd:g'~4jT0K h[QV^͜>U}%K5ʩcaG2w7iE:fmg2vv4PcGzW wO֭gΞ)5vfa^f#QƮ&H\{uh OvDT]f\;u|=Eݿo RՏ혻k(dO٭YT'J3ǂ۲+4Ei;S#G7? ՜3Vv_ܲFI͛7W^ï"@JANKGg:-~(afO:y\0=Ϣ䭏( fҙgV/=Zٳg|]EsaƋUvOC?'TcgnYjc(&0:뻭umߵkZY}޾m 'vٜUkUɈ.޼)ٔM? ['w ^j@0q܎9 ~!?PP&ƦY *f~5(nOQZ Fɷoߨqv0˖,i€= rmmU7my _m5KJ=ƭыS>lopNhhh %,l/Wg?{̛K8e;9>.l)&tQqZ8I+IW*[-p5b˗. 20$5ཱིD''[,bXh+?=UKpp6!jjzWZ}< tWGp)<FP=?X_66h%6v)^G{ӣg<%l+;paS*Yid3YfU3˴-`ޅ&(sdAU{90V_&1yP Ƥ>r y9h!o;[5 G1eY!ocax&/ Xp"i[*C9lF x6G{;t=QH_=cw#zy7:7mpِj Yi)c-:,}x Kx%6T2Ҡ;sn\y[f}M;Cƅ }#eW _37>~Ի7+[3`3K:@̱ԁ`a xUO_rIENDB`Watermark/plugin.php000064400000043500150732266000010513 0ustar00 array( * 'upload.presave' => array( * 'Plugin.Watermark.onUpLoadPreSave' * ) * ), * // global configure (optional) * 'plugin' => array( * 'Watermark' => array( * 'enable' => true, // For control by volume driver * 'source' => 'logo.png', // Path to Water mark image * 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1) * 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom) * 'marginX' => 5, // Margin horizontal pixel * 'marginY' => 5, // Margin vertical pixel * 'quality' => 95, // JPEG image save quality * 'transparency' => 70, // Water mark image transparency ( other than PNG ) * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) * 'targetMinPixel' => 200, // Target image minimum pixel size * 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field ) * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ), * // each volume configure (optional) * 'roots' => array( * array( * 'driver' => 'LocalFileSystem', * 'path' => '/path/to/files/', * 'URL' => 'http://localhost/to/files/' * 'plugin' => array( * 'Watermark' => array( * 'enable' => true, // For control by volume driver * 'source' => 'logo.png', // Path to Water mark image * 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1) * 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom) * 'marginX' => 5, // Margin horizontal pixel * 'marginY' => 5, // Margin vertical pixel * 'quality' => 95, // JPEG image save quality * 'transparency' => 70, // Water mark image transparency ( other than PNG ) * 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) * 'targetMinPixel' => 200, // Target image minimum pixel size * 'interlace' => IMG_GIF|IMG_JPG, // Set interlacebit image formats ( bit-field ) * 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key * // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value * // In case of using any key, specify it as an array * ) * ) * ) * ) * ); * * @package elfinder * @author Naoki Sawada * @license New BSD */ class elFinderPluginWatermark extends elFinderPlugin { private $watermarkImgInfo = null; public function __construct($opts) { $defaults = array( 'enable' => true, // For control by volume driver 'source' => 'logo.png', // Path to Water mark image 'ratio' => 0.2, // Ratio to original image (ratio > 0 and ratio <= 1) 'position' => 'RB', // Position L(eft)/C(enter)/R(ight) and T(op)/M(edium)/B(ottom) 'marginX' => 5, // Margin horizontal pixel 'marginY' => 5, // Margin vertical pixel 'quality' => 95, // JPEG image save quality 'transparency' => 70, // Water mark image transparency ( other than PNG ) 'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field ) 'targetMinPixel' => 200, // Target image minimum pixel size 'interlace' => IMG_GIF | IMG_JPG, // Set interlacebit image formats ( bit-field ) 'offDropWith' => null, // To disable it if it is dropped with pressing the meta key // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value // In case of using any key, specify it as an array 'marginRight' => 0, // Deprecated - marginX should be used 'marginBottom' => 0, // Deprecated - marginY should be used 'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId" ); $this->opts = array_merge($defaults, $opts); } public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume) { if (!$src) { return false; } $opts = $this->getCurrentOpts($volume); if (!$this->iaEnabled($opts, $elfinder)) { return false; } $imageType = null; $srcImgInfo = null; if (extension_loaded('fileinfo') && function_exists('mime_content_type')) { $mime = mime_content_type($src); if (substr($mime, 0, 5) !== 'image') { return false; } } if (extension_loaded('exif') && function_exists('exif_imagetype')) { $imageType = exif_imagetype($src); if ($imageType === false) { return false; } } else { $srcImgInfo = getimagesize($src); if ($srcImgInfo === false) { return false; } $imageType = $srcImgInfo[2]; } // check target image type $imgTypes = array( IMAGETYPE_GIF => IMG_GIF, IMAGETYPE_JPEG => IMG_JPEG, IMAGETYPE_PNG => IMG_PNG, IMAGETYPE_BMP => IMG_WBMP, IMAGETYPE_WBMP => IMG_WBMP ); if (!isset($imgTypes[$imageType]) || !($opts['targetType'] & $imgTypes[$imageType])) { return false; } // check Animation Gif if ($imageType === IMAGETYPE_GIF && elFinder::isAnimationGif($src)) { return false; } // check Animation Png if ($imageType === IMAGETYPE_PNG && elFinder::isAnimationPng($src)) { return false; } // check water mark image if (!file_exists($opts['source'])) { $opts['source'] = dirname(__FILE__) . "/" . $opts['source']; } if (is_readable($opts['source'])) { $watermarkImgInfo = getimagesize($opts['source']); if (!$watermarkImgInfo) { return false; } } else { return false; } if (!$srcImgInfo) { $srcImgInfo = getimagesize($src); } $watermark = $opts['source']; $quality = $opts['quality']; $transparency = $opts['transparency']; // check target image size if ($opts['targetMinPixel'] > 0 && $opts['targetMinPixel'] > min($srcImgInfo[0], $srcImgInfo[1])) { return false; } $watermark_width = $watermarkImgInfo[0]; $watermark_height = $watermarkImgInfo[1]; // Specified as a ratio to the image size if ($opts['ratio'] && $opts['ratio'] > 0 && $opts['ratio'] <= 1) { $maxW = $srcImgInfo[0] * $opts['ratio'] - ($opts['marginX'] * 2); $maxH = $srcImgInfo[1] * $opts['ratio'] - ($opts['marginY'] * 2); $dx = $dy = 0; if (($maxW >= $watermarkImgInfo[0] && $maxH >= $watermarkImgInfo[0]) || ($maxW <= $watermarkImgInfo[0] && $maxH <= $watermarkImgInfo[0])) { $dx = abs($srcImgInfo[0] - $watermarkImgInfo[0]); $dy = abs($srcImgInfo[1] - $watermarkImgInfo[1]); } else if ($maxW < $watermarkImgInfo[0]) { $dx = -1; } else { $dy = -1; } if ($dx < $dy) { $ww = $maxW; $wh = $watermarkImgInfo[1] * ($ww / $watermarkImgInfo[0]); } else { $wh = $maxH; $ww = $watermarkImgInfo[0] * ($wh / $watermarkImgInfo[1]); } $watermarkImgInfo[0] = $ww; $watermarkImgInfo[1] = $wh; } else { $opts['ratio'] = null; } $opts['position'] = strtoupper($opts['position']); // Set vertical position if (strpos($opts['position'], 'T') !== false) { // Top $dest_x = $opts['marginX']; } else if (strpos($opts['position'], 'M') !== false) { // Middle $dest_x = ($srcImgInfo[0] - $watermarkImgInfo[0]) / 2; } else { // Bottom $dest_x = $srcImgInfo[0] - $watermarkImgInfo[0] - max($opts['marginBottom'], $opts['marginX']); } // Set horizontal position if (strpos($opts['position'], 'L') !== false) { // Left $dest_y = $opts['marginY']; } else if (strpos($opts['position'], 'C') !== false) { // Middle $dest_y = ($srcImgInfo[1] - $watermarkImgInfo[1]) / 2; } else { // Right $dest_y = $srcImgInfo[1] - $watermarkImgInfo[1] - max($opts['marginRight'], $opts['marginY']); } // check interlace $opts['interlace'] = ($opts['interlace'] & $imgTypes[$imageType]); // Repeated use of Imagick::compositeImage() may cause PHP to hang, so disable it //if (class_exists('Imagick', false)) { // return $this->watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts); //} else { elFinder::expandMemoryForGD(array($watermarkImgInfo, $srcImgInfo)); return $this->watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts); //} } private function watermarkPrint_imagick($src, $watermarkSrc, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $opts) { try { // Open the original image $img = new Imagick($src); // Open the watermark $watermark = new Imagick($watermarkSrc); // zoom if ($opts['ratio']) { $watermark->scaleImage($watermarkImgInfo[0], $watermarkImgInfo[1]); } // Set transparency if (strtoupper($watermark->getImageFormat()) !== 'PNG') { $watermark->setImageOpacity($transparency / 100); } // Overlay the watermark on the original image $img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y); // Set quality if (strtoupper($img->getImageFormat()) === 'JPEG') { $img->setImageCompression(imagick::COMPRESSION_JPEG); $img->setCompressionQuality($quality); } // set interlace $opts['interlace'] && $img->setInterlaceScheme(Imagick::INTERLACE_PLANE); $result = $img->writeImage($src); $img->clear(); $img->destroy(); $watermark->clear(); $watermark->destroy(); return $result ? true : false; } catch (Exception $e) { $ermsg = $e->getMessage(); $ermsg && trigger_error($ermsg); return false; } } private function watermarkPrint_gd($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo, $srcImgInfo, $opts) { $watermark_width = $watermarkImgInfo[0]; $watermark_height = $watermarkImgInfo[1]; $ermsg = ''; switch ($watermarkImgInfo['mime']) { case 'image/gif': if (imagetypes() & IMG_GIF) { $oWatermarkImg = imagecreatefromgif($watermark); } else { $ermsg = 'GIF images are not supported as watermark image'; } break; case 'image/jpeg': if (imagetypes() & IMG_JPG) { $oWatermarkImg = imagecreatefromjpeg($watermark); } else { $ermsg = 'JPEG images are not supported as watermark image'; } break; case 'image/png': if (imagetypes() & IMG_PNG) { $oWatermarkImg = imagecreatefrompng($watermark); } else { $ermsg = 'PNG images are not supported as watermark image'; } break; case 'image/wbmp': if (imagetypes() & IMG_WBMP) { $oWatermarkImg = imagecreatefromwbmp($watermark); } else { $ermsg = 'WBMP images are not supported as watermark image'; } break; default: $oWatermarkImg = false; $ermsg = $watermarkImgInfo['mime'] . ' images are not supported as watermark image'; break; } if (!$ermsg) { // zoom if ($opts['ratio']) { $tmpImg = imagecreatetruecolor($watermarkImgInfo[0], $watermarkImgInfo[1]); imagealphablending($tmpImg, false); imagesavealpha($tmpImg, true); imagecopyresampled($tmpImg, $oWatermarkImg, 0, 0, 0, 0, $watermarkImgInfo[0], $watermarkImgInfo[1], imagesx($oWatermarkImg), imagesy($oWatermarkImg)); imageDestroy($oWatermarkImg); $oWatermarkImg = $tmpImg; $tmpImg = null; } switch ($srcImgInfo['mime']) { case 'image/gif': if (imagetypes() & IMG_GIF) { $oSrcImg = imagecreatefromgif($src); } else { $ermsg = 'GIF images are not supported as source image'; } break; case 'image/jpeg': if (imagetypes() & IMG_JPG) { $oSrcImg = imagecreatefromjpeg($src); } else { $ermsg = 'JPEG images are not supported as source image'; } break; case 'image/png': if (imagetypes() & IMG_PNG) { $oSrcImg = imagecreatefrompng($src); } else { $ermsg = 'PNG images are not supported as source image'; } break; case 'image/wbmp': if (imagetypes() & IMG_WBMP) { $oSrcImg = imagecreatefromwbmp($src); } else { $ermsg = 'WBMP images are not supported as source image'; } break; default: $oSrcImg = false; $ermsg = $srcImgInfo['mime'] . ' images are not supported as source image'; break; } } if ($ermsg || false === $oSrcImg || false === $oWatermarkImg) { $ermsg && trigger_error($ermsg); return false; } if ($srcImgInfo['mime'] === 'image/png') { if (function_exists('imagecolorallocatealpha')) { $bg = imagecolorallocatealpha($oSrcImg, 255, 255, 255, 127); imagefill($oSrcImg, 0, 0, $bg); } } if ($watermarkImgInfo['mime'] === 'image/png') { imagecopy($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); } else { imagecopymerge($oSrcImg, $oWatermarkImg, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency); } // set interlace $opts['interlace'] && imageinterlace($oSrcImg, true); switch ($srcImgInfo['mime']) { case 'image/gif': imagegif($oSrcImg, $src); break; case 'image/jpeg': imagejpeg($oSrcImg, $src, $quality); break; case 'image/png': if (function_exists('imagesavealpha') && function_exists('imagealphablending')) { imagealphablending($oSrcImg, false); imagesavealpha($oSrcImg, true); } imagepng($oSrcImg, $src); break; case 'image/wbmp': imagewbmp($oSrcImg, $src); break; } imageDestroy($oSrcImg); imageDestroy($oWatermarkImg); return true; } }