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/smart-sl.../Nextend/Framewor.../Image
File: ImageEdit.php
}
[500] Fix | Delete
[501] Fix | Delete
return false;
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
return exif_imagetype($filename);
[505] Fix | Delete
}
[506] Fix | Delete
[507] Fix | Delete
public static function isPNG8($path) {
[508] Fix | Delete
$fp = fopen($path, 'r');
[509] Fix | Delete
fseek($fp, 25);
[510] Fix | Delete
$data = fgets($fp, 2);
[511] Fix | Delete
fclose($fp);
[512] Fix | Delete
if (ord($data) == 3) {
[513] Fix | Delete
return true;
[514] Fix | Delete
}
[515] Fix | Delete
[516] Fix | Delete
return false;
[517] Fix | Delete
}
[518] Fix | Delete
[519] Fix | Delete
public static function scaleImageWebp($group, $imageUrlOrPath, $options) {
[520] Fix | Delete
[521] Fix | Delete
$options = array_merge(array(
[522] Fix | Delete
'mode' => 'scale',
[523] Fix | Delete
'scale' => 1,
[524] Fix | Delete
'quality' => 100,
[525] Fix | Delete
'remote' => false
[526] Fix | Delete
), $options);
[527] Fix | Delete
[528] Fix | Delete
if (strpos($imageUrlOrPath, Filesystem::getBasePath()) === 0) {
[529] Fix | Delete
$imageUrl = Url::pathToUri($imageUrlOrPath);
[530] Fix | Delete
} else {
[531] Fix | Delete
$imageUrl = ResourceTranslator::toUrl($imageUrlOrPath);
[532] Fix | Delete
}
[533] Fix | Delete
[534] Fix | Delete
if (!extension_loaded('gd') || $options['mode'] === 'scale' && $options['scale'] <= 0) {
[535] Fix | Delete
return Filesystem::pathToAbsoluteURL($imageUrl);
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
$options['quality'] = max(0, min(100, $options['quality']));
[539] Fix | Delete
$originalImageUrl = $imageUrl;
[540] Fix | Delete
[541] Fix | Delete
[542] Fix | Delete
if (substr($imageUrl, 0, 2) == '//') {
[543] Fix | Delete
$imageUrl = parse_url(Url::getFullUri(), PHP_URL_SCHEME) . ':' . $imageUrl;
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
$imageUrl = Url::relativetoabsolute($imageUrl);
[547] Fix | Delete
$imagePath = Filesystem::absoluteURLToPath($imageUrl);
[548] Fix | Delete
[549] Fix | Delete
$cache = new CacheImage($group);
[550] Fix | Delete
if ($imagePath == $imageUrl) {
[551] Fix | Delete
// The image is not local
[552] Fix | Delete
if (!$options['remote']) {
[553] Fix | Delete
return $originalImageUrl;
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
$pathInfo = pathinfo(parse_url($imageUrl, PHP_URL_PATH));
[557] Fix | Delete
$extension = false;
[558] Fix | Delete
if (isset($pathInfo['extension'])) {
[559] Fix | Delete
$extension = self::validateGDExtension($pathInfo['extension']);
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
$extension = self::checkMetaExtension($imageUrl, $extension);
[563] Fix | Delete
[564] Fix | Delete
if (!$extension || (strtolower($extension) === 'webp' && !function_exists('imagecreatefromwebp')) || !ini_get('allow_url_fopen')) {
[565] Fix | Delete
return $originalImageUrl;
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
return ResourceTranslator::urlToResource(Filesystem::pathToAbsoluteURL($cache->makeCache('webp', array(
[569] Fix | Delete
self::class,
[570] Fix | Delete
'_scaleRemoteImageWebp'
[571] Fix | Delete
), array(
[572] Fix | Delete
$extension,
[573] Fix | Delete
$imageUrl,
[574] Fix | Delete
$options
[575] Fix | Delete
))));
[576] Fix | Delete
[577] Fix | Delete
} else {
[578] Fix | Delete
$extension = false;
[579] Fix | Delete
$imageType = @self::exif_imagetype($imagePath);
[580] Fix | Delete
switch ($imageType) {
[581] Fix | Delete
case IMAGETYPE_JPEG:
[582] Fix | Delete
$extension = 'jpg';
[583] Fix | Delete
break;
[584] Fix | Delete
case IMAGETYPE_PNG:
[585] Fix | Delete
$extension = 'png';
[586] Fix | Delete
break;
[587] Fix | Delete
case IMAGETYPE_WEBP:
[588] Fix | Delete
if (!function_exists('imagecreatefromwebp')) {
[589] Fix | Delete
return $originalImageUrl;
[590] Fix | Delete
}
[591] Fix | Delete
$extension = 'webp';
[592] Fix | Delete
break;
[593] Fix | Delete
}
[594] Fix | Delete
if (!$extension) {
[595] Fix | Delete
return $originalImageUrl;
[596] Fix | Delete
}
[597] Fix | Delete
[598] Fix | Delete
return ResourceTranslator::urlToResource(Filesystem::pathToAbsoluteURL($cache->makeCache('webp', array(
[599] Fix | Delete
self::class,
[600] Fix | Delete
'_scaleImageWebp'
[601] Fix | Delete
), array(
[602] Fix | Delete
$extension,
[603] Fix | Delete
$imagePath,
[604] Fix | Delete
$options
[605] Fix | Delete
))));
[606] Fix | Delete
}
[607] Fix | Delete
}
[608] Fix | Delete
[609] Fix | Delete
public static function _scaleRemoteImageWebp($targetFile, $extension, $imageUrl, $options) {
[610] Fix | Delete
return self::_scaleImageWebp($targetFile, $extension, $imageUrl, $options);
[611] Fix | Delete
}
[612] Fix | Delete
[613] Fix | Delete
public static function _scaleImageWebp($targetFile, $extension, $imagePath, $options) {
[614] Fix | Delete
[615] Fix | Delete
$options = array_merge(array(
[616] Fix | Delete
'focusX' => 50,
[617] Fix | Delete
'focusY' => 50,
[618] Fix | Delete
), $options);
[619] Fix | Delete
[620] Fix | Delete
$targetDir = dirname($targetFile);
[621] Fix | Delete
[622] Fix | Delete
$image = false;
[623] Fix | Delete
[624] Fix | Delete
if ($extension == 'png') {
[625] Fix | Delete
$image = @imagecreatefrompng($imagePath);
[626] Fix | Delete
if (!imageistruecolor($image)) {
[627] Fix | Delete
imagepalettetotruecolor($image);
[628] Fix | Delete
imagealphablending($image, true);
[629] Fix | Delete
imagesavealpha($image, true);
[630] Fix | Delete
}
[631] Fix | Delete
} else if ($extension == 'jpg') {
[632] Fix | Delete
$image = @imagecreatefromjpeg($imagePath);
[633] Fix | Delete
if (function_exists("exif_read_data")) {
[634] Fix | Delete
$exif = @exif_read_data($imagePath);
[635] Fix | Delete
[636] Fix | Delete
$rotated = self::getOrientation($exif, $image);
[637] Fix | Delete
if ($rotated) {
[638] Fix | Delete
imagedestroy($image);
[639] Fix | Delete
$image = $rotated;
[640] Fix | Delete
}
[641] Fix | Delete
}
[642] Fix | Delete
} else if ($extension == 'webp') {
[643] Fix | Delete
//@TODO: should we need to care about rotation?
[644] Fix | Delete
$image = @imagecreatefromwebp($imagePath);
[645] Fix | Delete
if (!imageistruecolor($image)) {
[646] Fix | Delete
imagepalettetotruecolor($image);
[647] Fix | Delete
imagealphablending($image, true);
[648] Fix | Delete
imagesavealpha($image, true);
[649] Fix | Delete
}
[650] Fix | Delete
}
[651] Fix | Delete
[652] Fix | Delete
if ($image) {
[653] Fix | Delete
$originalWidth = imagesx($image);
[654] Fix | Delete
$originalHeight = imagesy($image);
[655] Fix | Delete
switch ($options['mode']) {
[656] Fix | Delete
case 'scale':
[657] Fix | Delete
$targetWidth = round($originalWidth * $options['scale']);
[658] Fix | Delete
$targetHeight = round($originalHeight * $options['scale']);
[659] Fix | Delete
break;
[660] Fix | Delete
case 'resize':
[661] Fix | Delete
$targetWidth = $options['width'];
[662] Fix | Delete
$targetHeight = $options['height'];
[663] Fix | Delete
break;
[664] Fix | Delete
}
[665] Fix | Delete
if ((isset($rotated) && $rotated) || $originalWidth != $targetWidth || $originalHeight != $targetHeight) {
[666] Fix | Delete
$newImage = imagecreatetruecolor($targetWidth, $targetHeight);
[667] Fix | Delete
if ($extension == 'png') {
[668] Fix | Delete
imagesavealpha($newImage, true);
[669] Fix | Delete
imagealphablending($newImage, false);
[670] Fix | Delete
$transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
[671] Fix | Delete
imagefilledrectangle($image, 0, 0, $targetWidth, $targetHeight, $transparent);
[672] Fix | Delete
}
[673] Fix | Delete
[674] Fix | Delete
list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = self::imageMode($targetWidth, $targetHeight, $originalWidth, $originalHeight, 'cover', $options['focusX'], $options['focusY']);
[675] Fix | Delete
imagecopyresampled($newImage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
[676] Fix | Delete
imagedestroy($image);
[677] Fix | Delete
[678] Fix | Delete
} else {
[679] Fix | Delete
$newImage = $image;
[680] Fix | Delete
}
[681] Fix | Delete
[682] Fix | Delete
if (!Filesystem::existsFolder($targetDir)) {
[683] Fix | Delete
Filesystem::createFolder($targetDir);
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
imagewebp($newImage, $targetFile, $options['quality']);
[687] Fix | Delete
imagedestroy($newImage);
[688] Fix | Delete
[689] Fix | Delete
return true;
[690] Fix | Delete
}
[691] Fix | Delete
[692] Fix | Delete
throw new Exception('Unable to scale image: ' . $imagePath);
[693] Fix | Delete
}
[694] Fix | Delete
[695] Fix | Delete
public static function checkMetaExtension($imageUrl, $originalExtension) {
[696] Fix | Delete
if (strpos($imageUrl, 'dst-jpg') !== false) {
[697] Fix | Delete
return 'jpg';
[698] Fix | Delete
} else if (strpos($imageUrl, 'dst-png') !== false) {
[699] Fix | Delete
return 'png';
[700] Fix | Delete
} else if (strpos($imageUrl, 'dst-webp') !== false) {
[701] Fix | Delete
return 'webp';
[702] Fix | Delete
} else {
[703] Fix | Delete
// not Instagram or Facebook url
[704] Fix | Delete
return $originalExtension;
[705] Fix | Delete
}
[706] Fix | Delete
}
[707] Fix | Delete
}
[708] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function