Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeDriver.class.php
$this->convEncOut();
[5500] Fix | Delete
if (!$ret) {
[5501] Fix | Delete
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']));
[5502] Fix | Delete
}
[5503] Fix | Delete
} else {
[5504] Fix | Delete
if ($this->convEncOut(!$this->_unlink($this->convEncIn($path)))) {
[5505] Fix | Delete
return $this->setError(elFinder::ERROR_RM, $this->path($stat['hash']));
[5506] Fix | Delete
}
[5507] Fix | Delete
$this->clearstatcache();
[5508] Fix | Delete
}
[5509] Fix | Delete
[5510] Fix | Delete
$this->removed[] = $stat;
[5511] Fix | Delete
return true;
[5512] Fix | Delete
}
[5513] Fix | Delete
[5514] Fix | Delete
[5515] Fix | Delete
/************************* thumbnails **************************/
[5516] Fix | Delete
[5517] Fix | Delete
/**
[5518] Fix | Delete
* Return thumbnail file name for required file
[5519] Fix | Delete
*
[5520] Fix | Delete
* @param array $stat file stat
[5521] Fix | Delete
*
[5522] Fix | Delete
* @return string
[5523] Fix | Delete
* @author Dmitry (dio) Levashov
[5524] Fix | Delete
**/
[5525] Fix | Delete
protected function tmbname($stat)
[5526] Fix | Delete
{
[5527] Fix | Delete
$name = $stat['hash'] . (isset($stat['ts']) ? $stat['ts'] : '') . '.png';
[5528] Fix | Delete
if (strlen($name) > 255) {
[5529] Fix | Delete
$name = $this->id . md5($stat['hash']) . $stat['ts'] . '.png';
[5530] Fix | Delete
}
[5531] Fix | Delete
return $name;
[5532] Fix | Delete
}
[5533] Fix | Delete
[5534] Fix | Delete
/**
[5535] Fix | Delete
* Return thumnbnail name if exists
[5536] Fix | Delete
*
[5537] Fix | Delete
* @param string $path file path
[5538] Fix | Delete
* @param array $stat file stat
[5539] Fix | Delete
*
[5540] Fix | Delete
* @return string|false
[5541] Fix | Delete
* @author Dmitry (dio) Levashov
[5542] Fix | Delete
**/
[5543] Fix | Delete
protected function gettmb($path, $stat)
[5544] Fix | Delete
{
[5545] Fix | Delete
if ($this->tmbURL && $this->tmbPath) {
[5546] Fix | Delete
// file itself thumnbnail
[5547] Fix | Delete
if (strpos($path, $this->tmbPath) === 0) {
[5548] Fix | Delete
return basename($path);
[5549] Fix | Delete
}
[5550] Fix | Delete
[5551] Fix | Delete
$name = $this->tmbname($stat);
[5552] Fix | Delete
$tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
[5553] Fix | Delete
if (file_exists($tmb)) {
[5554] Fix | Delete
if ($this->options['tmbGcMaxlifeHour'] && $this->options['tmbGcPercentage'] > 0) {
[5555] Fix | Delete
touch($tmb);
[5556] Fix | Delete
}
[5557] Fix | Delete
return $name;
[5558] Fix | Delete
}
[5559] Fix | Delete
}
[5560] Fix | Delete
return false;
[5561] Fix | Delete
}
[5562] Fix | Delete
[5563] Fix | Delete
/**
[5564] Fix | Delete
* Return true if thumnbnail for required file can be created
[5565] Fix | Delete
*
[5566] Fix | Delete
* @param string $path thumnbnail path
[5567] Fix | Delete
* @param array $stat file stat
[5568] Fix | Delete
* @param bool $checkTmbPath
[5569] Fix | Delete
*
[5570] Fix | Delete
* @return string|bool
[5571] Fix | Delete
* @author Dmitry (dio) Levashov
[5572] Fix | Delete
**/
[5573] Fix | Delete
protected function canCreateTmb($path, $stat, $checkTmbPath = true)
[5574] Fix | Delete
{
[5575] Fix | Delete
static $gdMimes = null;
[5576] Fix | Delete
static $imgmgPS = null;
[5577] Fix | Delete
if ($gdMimes === null) {
[5578] Fix | Delete
$_mimes = array('image/jpeg', 'image/png', 'image/gif', 'image/x-ms-bmp');
[5579] Fix | Delete
if (function_exists('imagecreatefromwebp')) {
[5580] Fix | Delete
$_mimes[] = 'image/webp';
[5581] Fix | Delete
}
[5582] Fix | Delete
$gdMimes = array_flip($_mimes);
[5583] Fix | Delete
$imgmgPS = array_flip(array('application/postscript', 'application/pdf'));
[5584] Fix | Delete
}
[5585] Fix | Delete
if ((!$checkTmbPath || $this->tmbPathWritable)
[5586] Fix | Delete
&& (!$this->tmbPath || strpos($path, $this->tmbPath) === false) // do not create thumnbnail for thumnbnail
[5587] Fix | Delete
) {
[5588] Fix | Delete
$mime = strtolower($stat['mime']);
[5589] Fix | Delete
list($type) = explode('/', $mime);
[5590] Fix | Delete
if (!empty($this->imgConverter)) {
[5591] Fix | Delete
if (isset($this->imgConverter[$mime])) {
[5592] Fix | Delete
return true;
[5593] Fix | Delete
}
[5594] Fix | Delete
if (isset($this->imgConverter[$type])) {
[5595] Fix | Delete
return true;
[5596] Fix | Delete
}
[5597] Fix | Delete
}
[5598] Fix | Delete
return $this->imgLib
[5599] Fix | Delete
&& (
[5600] Fix | Delete
($type === 'image' && ($this->imgLib === 'gd' ? isset($gdMimes[$stat['mime']]) : true))
[5601] Fix | Delete
||
[5602] Fix | Delete
(ELFINDER_IMAGEMAGICK_PS && isset($imgmgPS[$stat['mime']]) && $this->imgLib !== 'gd')
[5603] Fix | Delete
);
[5604] Fix | Delete
}
[5605] Fix | Delete
return false;
[5606] Fix | Delete
}
[5607] Fix | Delete
[5608] Fix | Delete
/**
[5609] Fix | Delete
* Return true if required file can be resized.
[5610] Fix | Delete
* By default - the same as canCreateTmb
[5611] Fix | Delete
*
[5612] Fix | Delete
* @param string $path thumnbnail path
[5613] Fix | Delete
* @param array $stat file stat
[5614] Fix | Delete
*
[5615] Fix | Delete
* @return string|bool
[5616] Fix | Delete
* @author Dmitry (dio) Levashov
[5617] Fix | Delete
**/
[5618] Fix | Delete
protected function canResize($path, $stat)
[5619] Fix | Delete
{
[5620] Fix | Delete
return $this->canCreateTmb($path, $stat, false);
[5621] Fix | Delete
}
[5622] Fix | Delete
[5623] Fix | Delete
/**
[5624] Fix | Delete
* Create thumnbnail and return it's URL on success
[5625] Fix | Delete
*
[5626] Fix | Delete
* @param string $path file path
[5627] Fix | Delete
* @param $stat
[5628] Fix | Delete
*
[5629] Fix | Delete
* @return false|string
[5630] Fix | Delete
* @internal param string $mime file mime type
[5631] Fix | Delete
* @throws elFinderAbortException
[5632] Fix | Delete
* @throws ImagickException
[5633] Fix | Delete
* @author Dmitry (dio) Levashov
[5634] Fix | Delete
*/
[5635] Fix | Delete
protected function createTmb($path, $stat)
[5636] Fix | Delete
{
[5637] Fix | Delete
if (!$stat || !$this->canCreateTmb($path, $stat)) {
[5638] Fix | Delete
return false;
[5639] Fix | Delete
}
[5640] Fix | Delete
[5641] Fix | Delete
$name = $this->tmbname($stat);
[5642] Fix | Delete
$tmb = $this->tmbPath . DIRECTORY_SEPARATOR . $name;
[5643] Fix | Delete
[5644] Fix | Delete
$maxlength = -1;
[5645] Fix | Delete
$imgConverter = null;
[5646] Fix | Delete
[5647] Fix | Delete
// check imgConverter
[5648] Fix | Delete
$mime = strtolower($stat['mime']);
[5649] Fix | Delete
list($type) = explode('/', $mime);
[5650] Fix | Delete
if (isset($this->imgConverter[$mime])) {
[5651] Fix | Delete
$imgConverter = $this->imgConverter[$mime]['func'];
[5652] Fix | Delete
if (!empty($this->imgConverter[$mime]['maxlen'])) {
[5653] Fix | Delete
$maxlength = intval($this->imgConverter[$mime]['maxlen']);
[5654] Fix | Delete
}
[5655] Fix | Delete
} else if (isset($this->imgConverter[$type])) {
[5656] Fix | Delete
$imgConverter = $this->imgConverter[$type]['func'];
[5657] Fix | Delete
if (!empty($this->imgConverter[$type]['maxlen'])) {
[5658] Fix | Delete
$maxlength = intval($this->imgConverter[$type]['maxlen']);
[5659] Fix | Delete
}
[5660] Fix | Delete
}
[5661] Fix | Delete
if ($imgConverter && !is_callable($imgConverter)) {
[5662] Fix | Delete
return false;
[5663] Fix | Delete
}
[5664] Fix | Delete
[5665] Fix | Delete
// copy image into tmbPath so some drivers does not store files on local fs
[5666] Fix | Delete
if (($src = $this->fopenCE($path, 'rb')) == false) {
[5667] Fix | Delete
return false;
[5668] Fix | Delete
}
[5669] Fix | Delete
[5670] Fix | Delete
if (($trg = fopen($tmb, 'wb')) == false) {
[5671] Fix | Delete
$this->fcloseCE($src, $path);
[5672] Fix | Delete
return false;
[5673] Fix | Delete
}
[5674] Fix | Delete
[5675] Fix | Delete
stream_copy_to_stream($src, $trg, $maxlength);
[5676] Fix | Delete
[5677] Fix | Delete
$this->fcloseCE($src, $path);
[5678] Fix | Delete
fclose($trg);
[5679] Fix | Delete
[5680] Fix | Delete
// call imgConverter
[5681] Fix | Delete
if ($imgConverter) {
[5682] Fix | Delete
if (!call_user_func_array($imgConverter, array($tmb, $stat, $this))) {
[5683] Fix | Delete
file_exists($tmb) && unlink($tmb);
[5684] Fix | Delete
return false;
[5685] Fix | Delete
}
[5686] Fix | Delete
}
[5687] Fix | Delete
[5688] Fix | Delete
$result = false;
[5689] Fix | Delete
[5690] Fix | Delete
$tmbSize = $this->tmbSize;
[5691] Fix | Delete
[5692] Fix | Delete
if ($this->imgLib === 'imagick') {
[5693] Fix | Delete
try {
[5694] Fix | Delete
$imagickTest = new imagick($tmb . '[0]');
[5695] Fix | Delete
$imagickTest->clear();
[5696] Fix | Delete
$imagickTest = true;
[5697] Fix | Delete
} catch (Exception $e) {
[5698] Fix | Delete
$imagickTest = false;
[5699] Fix | Delete
}
[5700] Fix | Delete
}
[5701] Fix | Delete
[5702] Fix | Delete
if (($this->imgLib === 'imagick' && !$imagickTest) || ($s = getimagesize($tmb)) === false) {
[5703] Fix | Delete
if ($this->imgLib === 'imagick') {
[5704] Fix | Delete
$bgcolor = $this->options['tmbBgColor'];
[5705] Fix | Delete
if ($bgcolor === 'transparent') {
[5706] Fix | Delete
$bgcolor = 'rgba(255, 255, 255, 0.0)';
[5707] Fix | Delete
}
[5708] Fix | Delete
try {
[5709] Fix | Delete
$imagick = new imagick();
[5710] Fix | Delete
$imagick->setBackgroundColor(new ImagickPixel($bgcolor));
[5711] Fix | Delete
$imagick->readImage($this->getExtentionByMime($stat['mime'], ':') . $tmb . '[0]');
[5712] Fix | Delete
try {
[5713] Fix | Delete
$imagick->trimImage(0);
[5714] Fix | Delete
} catch (Exception $e) {
[5715] Fix | Delete
}
[5716] Fix | Delete
$imagick->setImageFormat('png');
[5717] Fix | Delete
$imagick->writeImage($tmb);
[5718] Fix | Delete
$imagick->clear();
[5719] Fix | Delete
if (($s = getimagesize($tmb)) !== false) {
[5720] Fix | Delete
$result = true;
[5721] Fix | Delete
}
[5722] Fix | Delete
} catch (Exception $e) {
[5723] Fix | Delete
}
[5724] Fix | Delete
} else if ($this->imgLib === 'convert') {
[5725] Fix | Delete
$convParams = $this->imageMagickConvertPrepare($tmb, 'png', 100, array(), $stat['mime']);
[5726] Fix | Delete
$cmd = sprintf('%s -colorspace sRGB -trim -- %s %s', ELFINDER_CONVERT_PATH, $convParams['quotedPath'], $convParams['quotedDstPath']);
[5727] Fix | Delete
$result = false;
[5728] Fix | Delete
if ($this->procExec($cmd) === 0) {
[5729] Fix | Delete
if (($s = getimagesize($tmb)) !== false) {
[5730] Fix | Delete
$result = true;
[5731] Fix | Delete
}
[5732] Fix | Delete
}
[5733] Fix | Delete
}
[5734] Fix | Delete
if (!$result) {
[5735] Fix | Delete
// fallback imgLib to GD
[5736] Fix | Delete
if (function_exists('gd_info') && ($s = getimagesize($tmb))) {
[5737] Fix | Delete
$this->imgLib = 'gd';
[5738] Fix | Delete
} else {
[5739] Fix | Delete
file_exists($tmb) && unlink($tmb);
[5740] Fix | Delete
return false;
[5741] Fix | Delete
}
[5742] Fix | Delete
}
[5743] Fix | Delete
}
[5744] Fix | Delete
[5745] Fix | Delete
/* If image smaller or equal thumbnail size - just fitting to thumbnail square */
[5746] Fix | Delete
if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) {
[5747] Fix | Delete
$result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
[5748] Fix | Delete
} else {
[5749] Fix | Delete
[5750] Fix | Delete
if ($this->options['tmbCrop']) {
[5751] Fix | Delete
[5752] Fix | Delete
$result = $tmb;
[5753] Fix | Delete
/* Resize and crop if image bigger than thumbnail */
[5754] Fix | Delete
if (!(($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) {
[5755] Fix | Delete
$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png');
[5756] Fix | Delete
}
[5757] Fix | Delete
[5758] Fix | Delete
if ($result && ($s = getimagesize($tmb)) != false) {
[5759] Fix | Delete
$x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0;
[5760] Fix | Delete
$y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0;
[5761] Fix | Delete
$result = $this->imgCrop($result, $tmbSize, $tmbSize, $x, $y, 'png');
[5762] Fix | Delete
} else {
[5763] Fix | Delete
$result = false;
[5764] Fix | Delete
}
[5765] Fix | Delete
[5766] Fix | Delete
} else {
[5767] Fix | Delete
$result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png');
[5768] Fix | Delete
}
[5769] Fix | Delete
[5770] Fix | Delete
if ($result) {
[5771] Fix | Delete
if ($s = getimagesize($tmb)) {
[5772] Fix | Delete
if ($s[0] !== $tmbSize || $s[1] !== $tmbSize) {
[5773] Fix | Delete
$result = $this->imgSquareFit($result, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png');
[5774] Fix | Delete
}
[5775] Fix | Delete
}
[5776] Fix | Delete
}
[5777] Fix | Delete
}
[5778] Fix | Delete
[5779] Fix | Delete
if (!$result) {
[5780] Fix | Delete
unlink($tmb);
[5781] Fix | Delete
return false;
[5782] Fix | Delete
}
[5783] Fix | Delete
[5784] Fix | Delete
return $name;
[5785] Fix | Delete
}
[5786] Fix | Delete
[5787] Fix | Delete
/**
[5788] Fix | Delete
* Resize image
[5789] Fix | Delete
*
[5790] Fix | Delete
* @param string $path image file
[5791] Fix | Delete
* @param int $width new width
[5792] Fix | Delete
* @param int $height new height
[5793] Fix | Delete
* @param bool $keepProportions crop image
[5794] Fix | Delete
* @param bool $resizeByBiggerSide resize image based on bigger side if true
[5795] Fix | Delete
* @param string $destformat image destination format
[5796] Fix | Delete
* @param int $jpgQuality JEPG quality (1-100)
[5797] Fix | Delete
* @param array $options Other extra options
[5798] Fix | Delete
*
[5799] Fix | Delete
* @return string|false
[5800] Fix | Delete
* @throws elFinderAbortException
[5801] Fix | Delete
* @author Dmitry (dio) Levashov
[5802] Fix | Delete
* @author Alexey Sukhotin
[5803] Fix | Delete
*/
[5804] Fix | Delete
protected function imgResize($path, $width, $height, $keepProportions = false, $resizeByBiggerSide = true, $destformat = null, $jpgQuality = null, $options = array())
[5805] Fix | Delete
{
[5806] Fix | Delete
if (($s = getimagesize($path)) == false) {
[5807] Fix | Delete
return false;
[5808] Fix | Delete
}
[5809] Fix | Delete
[5810] Fix | Delete
if (!$jpgQuality) {
[5811] Fix | Delete
$jpgQuality = $this->options['jpgQuality'];
[5812] Fix | Delete
}
[5813] Fix | Delete
[5814] Fix | Delete
list($orig_w, $orig_h) = array($s[0], $s[1]);
[5815] Fix | Delete
list($size_w, $size_h) = array($width, $height);
[5816] Fix | Delete
[5817] Fix | Delete
if (empty($options['unenlarge']) || $orig_w > $size_w || $orig_h > $size_h) {
[5818] Fix | Delete
if ($keepProportions == true) {
[5819] Fix | Delete
/* Resizing by biggest side */
[5820] Fix | Delete
if ($resizeByBiggerSide) {
[5821] Fix | Delete
if ($orig_w > $orig_h) {
[5822] Fix | Delete
$size_h = round($orig_h * $width / $orig_w);
[5823] Fix | Delete
$size_w = $width;
[5824] Fix | Delete
} else {
[5825] Fix | Delete
$size_w = round($orig_w * $height / $orig_h);
[5826] Fix | Delete
$size_h = $height;
[5827] Fix | Delete
}
[5828] Fix | Delete
} else {
[5829] Fix | Delete
if ($orig_w > $orig_h) {
[5830] Fix | Delete
$size_w = round($orig_w * $height / $orig_h);
[5831] Fix | Delete
$size_h = $height;
[5832] Fix | Delete
} else {
[5833] Fix | Delete
$size_h = round($orig_h * $width / $orig_w);
[5834] Fix | Delete
$size_w = $width;
[5835] Fix | Delete
}
[5836] Fix | Delete
}
[5837] Fix | Delete
}
[5838] Fix | Delete
} else {
[5839] Fix | Delete
$size_w = $orig_w;
[5840] Fix | Delete
$size_h = $orig_h;
[5841] Fix | Delete
}
[5842] Fix | Delete
[5843] Fix | Delete
elFinder::extendTimeLimit(300);
[5844] Fix | Delete
switch ($this->imgLib) {
[5845] Fix | Delete
case 'imagick':
[5846] Fix | Delete
[5847] Fix | Delete
try {
[5848] Fix | Delete
$img = new imagick($path);
[5849] Fix | Delete
} catch (Exception $e) {
[5850] Fix | Delete
return false;
[5851] Fix | Delete
}
[5852] Fix | Delete
[5853] Fix | Delete
// Imagick::FILTER_BOX faster than FILTER_LANCZOS so use for createTmb
[5854] Fix | Delete
// resize bench: http://app-mgng.rhcloud.com/9
[5855] Fix | Delete
// resize sample: http://www.dylanbeattie.net/magick/filters/result.html
[5856] Fix | Delete
$filter = ($destformat === 'png' /* createTmb */) ? Imagick::FILTER_BOX : Imagick::FILTER_LANCZOS;
[5857] Fix | Delete
[5858] Fix | Delete
$ani = ($img->getNumberImages() > 1);
[5859] Fix | Delete
if ($ani && is_null($destformat)) {
[5860] Fix | Delete
$img = $img->coalesceImages();
[5861] Fix | Delete
do {
[5862] Fix | Delete
$img->resizeImage($size_w, $size_h, $filter, 1);
[5863] Fix | Delete
} while ($img->nextImage());
[5864] Fix | Delete
$img->optimizeImageLayers();
[5865] Fix | Delete
$result = $img->writeImages($path, true);
[5866] Fix | Delete
} else {
[5867] Fix | Delete
if ($ani) {
[5868] Fix | Delete
$img->setFirstIterator();
[5869] Fix | Delete
}
[5870] Fix | Delete
if (strtoupper($img->getImageFormat()) === 'JPEG') {
[5871] Fix | Delete
$img->setImageCompression(imagick::COMPRESSION_JPEG);
[5872] Fix | Delete
$img->setImageCompressionQuality($jpgQuality);
[5873] Fix | Delete
if (isset($options['preserveExif']) && !$options['preserveExif']) {
[5874] Fix | Delete
try {
[5875] Fix | Delete
$orientation = $img->getImageOrientation();
[5876] Fix | Delete
} catch (ImagickException $e) {
[5877] Fix | Delete
$orientation = 0;
[5878] Fix | Delete
}
[5879] Fix | Delete
$img->stripImage();
[5880] Fix | Delete
if ($orientation) {
[5881] Fix | Delete
$img->setImageOrientation($orientation);
[5882] Fix | Delete
}
[5883] Fix | Delete
}
[5884] Fix | Delete
if ($this->options['jpgProgressive']) {
[5885] Fix | Delete
$img->setInterlaceScheme(Imagick::INTERLACE_PLANE);
[5886] Fix | Delete
}
[5887] Fix | Delete
}
[5888] Fix | Delete
$img->resizeImage($size_w, $size_h, $filter, true);
[5889] Fix | Delete
if ($destformat) {
[5890] Fix | Delete
$result = $this->imagickImage($img, $path, $destformat, $jpgQuality);
[5891] Fix | Delete
} else {
[5892] Fix | Delete
$result = $img->writeImage($path);
[5893] Fix | Delete
}
[5894] Fix | Delete
}
[5895] Fix | Delete
[5896] Fix | Delete
$img->clear();
[5897] Fix | Delete
[5898] Fix | Delete
return $result ? $path : false;
[5899] Fix | Delete
[5900] Fix | Delete
break;
[5901] Fix | Delete
[5902] Fix | Delete
case 'convert':
[5903] Fix | Delete
extract($this->imageMagickConvertPrepare($path, $destformat, $jpgQuality, $s));
[5904] Fix | Delete
/**
[5905] Fix | Delete
* @var string $ani
[5906] Fix | Delete
* @var string $index
[5907] Fix | Delete
* @var string $coalesce
[5908] Fix | Delete
* @var string $deconstruct
[5909] Fix | Delete
* @var string $jpgQuality
[5910] Fix | Delete
* @var string $quotedPath
[5911] Fix | Delete
* @var string $quotedDstPath
[5912] Fix | Delete
* @var string $interlace
[5913] Fix | Delete
*/
[5914] Fix | Delete
$filter = ($destformat === 'png' /* createTmb */) ? '-filter Box' : '-filter Lanczos';
[5915] Fix | Delete
$strip = (isset($options['preserveExif']) && !$options['preserveExif']) ? ' -strip' : '';
[5916] Fix | Delete
$cmd = sprintf('%s %s%s%s%s%s %s -geometry %dx%d! %s %s', ELFINDER_CONVERT_PATH, $quotedPath, $coalesce, $jpgQuality, $strip, $interlace, $filter, $size_w, $size_h, $deconstruct, $quotedDstPath);
[5917] Fix | Delete
[5918] Fix | Delete
$result = false;
[5919] Fix | Delete
if ($this->procExec($cmd) === 0) {
[5920] Fix | Delete
$result = true;
[5921] Fix | Delete
}
[5922] Fix | Delete
return $result ? $path : false;
[5923] Fix | Delete
[5924] Fix | Delete
break;
[5925] Fix | Delete
[5926] Fix | Delete
case 'gd':
[5927] Fix | Delete
elFinder::expandMemoryForGD(array($s, array($size_w, $size_h)));
[5928] Fix | Delete
$img = $this->gdImageCreate($path, $s['mime']);
[5929] Fix | Delete
[5930] Fix | Delete
if ($img && false != ($tmp = imagecreatetruecolor($size_w, $size_h))) {
[5931] Fix | Delete
[5932] Fix | Delete
$bgNum = false;
[5933] Fix | Delete
if ($s[2] === IMAGETYPE_GIF && (!$destformat || $destformat === 'gif')) {
[5934] Fix | Delete
$bgIdx = imagecolortransparent($img);
[5935] Fix | Delete
if ($bgIdx !== -1) {
[5936] Fix | Delete
$c = imagecolorsforindex($img, $bgIdx);
[5937] Fix | Delete
$bgNum = imagecolorallocate($tmp, $c['red'], $c['green'], $c['blue']);
[5938] Fix | Delete
imagefill($tmp, 0, 0, $bgNum);
[5939] Fix | Delete
imagecolortransparent($tmp, $bgNum);
[5940] Fix | Delete
}
[5941] Fix | Delete
}
[5942] Fix | Delete
if ($bgNum === false) {
[5943] Fix | Delete
$this->gdImageBackground($tmp, 'transparent');
[5944] Fix | Delete
}
[5945] Fix | Delete
[5946] Fix | Delete
if (!imagecopyresampled($tmp, $img, 0, 0, 0, 0, $size_w, $size_h, $s[0], $s[1])) {
[5947] Fix | Delete
return false;
[5948] Fix | Delete
}
[5949] Fix | Delete
[5950] Fix | Delete
$result = $this->gdImage($tmp, $path, $destformat, $s['mime'], $jpgQuality);
[5951] Fix | Delete
[5952] Fix | Delete
imagedestroy($img);
[5953] Fix | Delete
imagedestroy($tmp);
[5954] Fix | Delete
[5955] Fix | Delete
return $result ? $path : false;
[5956] Fix | Delete
[5957] Fix | Delete
}
[5958] Fix | Delete
break;
[5959] Fix | Delete
}
[5960] Fix | Delete
[5961] Fix | Delete
return false;
[5962] Fix | Delete
}
[5963] Fix | Delete
[5964] Fix | Delete
/**
[5965] Fix | Delete
* Crop image
[5966] Fix | Delete
*
[5967] Fix | Delete
* @param string $path image file
[5968] Fix | Delete
* @param int $width crop width
[5969] Fix | Delete
* @param int $height crop height
[5970] Fix | Delete
* @param bool $x crop left offset
[5971] Fix | Delete
* @param bool $y crop top offset
[5972] Fix | Delete
* @param string $destformat image destination format
[5973] Fix | Delete
* @param int $jpgQuality JEPG quality (1-100)
[5974] Fix | Delete
*
[5975] Fix | Delete
* @return string|false
[5976] Fix | Delete
* @throws elFinderAbortException
[5977] Fix | Delete
* @author Dmitry (dio) Levashov
[5978] Fix | Delete
* @author Alexey Sukhotin
[5979] Fix | Delete
*/
[5980] Fix | Delete
protected function imgCrop($path, $width, $height, $x, $y, $destformat = null, $jpgQuality = null)
[5981] Fix | Delete
{
[5982] Fix | Delete
if (($s = getimagesize($path)) == false) {
[5983] Fix | Delete
return false;
[5984] Fix | Delete
}
[5985] Fix | Delete
[5986] Fix | Delete
if (!$jpgQuality) {
[5987] Fix | Delete
$jpgQuality = $this->options['jpgQuality'];
[5988] Fix | Delete
}
[5989] Fix | Delete
[5990] Fix | Delete
elFinder::extendTimeLimit(300);
[5991] Fix | Delete
switch ($this->imgLib) {
[5992] Fix | Delete
case 'imagick':
[5993] Fix | Delete
[5994] Fix | Delete
try {
[5995] Fix | Delete
$img = new imagick($path);
[5996] Fix | Delete
} catch (Exception $e) {
[5997] Fix | Delete
return false;
[5998] Fix | Delete
}
[5999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function