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/themify-.../themify
File: img.php
}
[500] Fix | Delete
$im = imagecreatefromjpeg($res);
[501] Fix | Delete
break;
[502] Fix | Delete
case 'png':
[503] Fix | Delete
if(!function_exists('imagecreatefrompng')){
[504] Fix | Delete
return $url;
[505] Fix | Delete
}
[506] Fix | Delete
if(function_exists('imagepalettetotruecolor')){
[507] Fix | Delete
$im = imagecreatefrompng($res);
[508] Fix | Delete
if($im!==false && (!imagepalettetotruecolor($im) || !imagealphablending($im, true) || !imagesavealpha($im, true))){
[509] Fix | Delete
imagedestroy($im);
[510] Fix | Delete
$im=null;
[511] Fix | Delete
}
[512] Fix | Delete
}
[513] Fix | Delete
else{
[514] Fix | Delete
$pngimg = imagecreatefrompng($res);
[515] Fix | Delete
if($pngimg!==false) {
[516] Fix | Delete
// get dimens of image
[517] Fix | Delete
$w = imagesx($pngimg);
[518] Fix | Delete
$h = imagesy($pngimg);
[519] Fix | Delete
if ($w !== false && $h !== false) {
[520] Fix | Delete
$im = imagecreatetruecolor($w, $h);
[521] Fix | Delete
if ($im !== false && imagealphablending($im, false) && imagesavealpha($im, true)) {
[522] Fix | Delete
// By default, the canvas is black, so make it transparent
[523] Fix | Delete
$trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
[524] Fix | Delete
if($trans===false || !imagefilledrectangle($im, 0, 0, $w - 1, $h - 1, $trans) || !imagecopy($im, $pngimg, 0, 0, 0, 0, $w, $h)) {
[525] Fix | Delete
imagedestroy($im);
[526] Fix | Delete
$im=null;
[527] Fix | Delete
}
[528] Fix | Delete
}
[529] Fix | Delete
}
[530] Fix | Delete
imagedestroy($pngimg);
[531] Fix | Delete
}
[532] Fix | Delete
$pngimg=null;
[533] Fix | Delete
}
[534] Fix | Delete
break;
[535] Fix | Delete
default:
[536] Fix | Delete
return $url;
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
if(empty($im)){
[540] Fix | Delete
return $url;
[541] Fix | Delete
}
[542] Fix | Delete
$res=$resUrl;
[543] Fix | Delete
$quality = array( 0 => 40, 1 => 50, 2 => 60, 3 => 70, 4 => 80, 5 => 90, 6 => 100 );
[544] Fix | Delete
$webp =imagewebp($im, $res, $quality[ $webp_quality ] );
[545] Fix | Delete
if(!$webp){
[546] Fix | Delete
Themify_Filesystem::delete($res,'f');
[547] Fix | Delete
}
[548] Fix | Delete
imagedestroy($im);
[549] Fix | Delete
$im=null;
[550] Fix | Delete
}
[551] Fix | Delete
return !empty($webp)?str_replace($upload_dir['basedir'],$upload_dir['baseurl'],$res):$url;
[552] Fix | Delete
}
[553] Fix | Delete
else{
[554] Fix | Delete
return $url;
[555] Fix | Delete
}
[556] Fix | Delete
}
[557] Fix | Delete
[558] Fix | Delete
function themify_get_video_size(string $url):?array{
[559] Fix | Delete
$k=$url.'_size';
[560] Fix | Delete
$found=Themify_Storage::get($k);
[561] Fix | Delete
if($found===false){
[562] Fix | Delete
$found=null;
[563] Fix | Delete
$attachment_id=themify_get_attachment_id_from_url($url);
[564] Fix | Delete
if($attachment_id>0){
[565] Fix | Delete
$meta=wp_get_attachment_metadata( $attachment_id );
[566] Fix | Delete
if(empty($meta)){
[567] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/media.php';
[568] Fix | Delete
$meta=wp_read_video_metadata(get_attached_file($attachment_id));
[569] Fix | Delete
}
[570] Fix | Delete
if(!empty($meta)){
[571] Fix | Delete
$found=array(
[572] Fix | Delete
'w'=>isset($meta['width'])?$meta['width']:'',
[573] Fix | Delete
'h'=>isset($meta['height'])?$meta['height']:'',
[574] Fix | Delete
's'=>isset($meta['filesize'])?$meta['filesize']:'',
[575] Fix | Delete
'f'=>isset($meta['fileformat'])?$meta['fileformat']:'',
[576] Fix | Delete
'l'=>isset($meta['length_formatted'])?$meta['length_formatted']:'',
[577] Fix | Delete
't'=>isset($meta['mime_type'])?$meta['mime_type']:''
[578] Fix | Delete
);
[579] Fix | Delete
Themify_Storage::set($k,$found,MONTH_IN_SECONDS*6);
[580] Fix | Delete
}
[581] Fix | Delete
}
[582] Fix | Delete
}
[583] Fix | Delete
else{
[584] Fix | Delete
$found=json_decode($found,true);
[585] Fix | Delete
if($found===null && Themify_Storage::delete($k)!==false){
[586] Fix | Delete
return themify_get_video_size($url);
[587] Fix | Delete
}
[588] Fix | Delete
}
[589] Fix | Delete
return $found;
[590] Fix | Delete
}
[591] Fix | Delete
[592] Fix | Delete
function themify_get_image_size(?string $url,bool $isLocal=false,int $color=0){//@todo move to class
[593] Fix | Delete
if(!isset($url[2]) || strtok(pathinfo($url,PATHINFO_EXTENSION),'?')==='svg'){
[594] Fix | Delete
return false;
[595] Fix | Delete
}
[596] Fix | Delete
if(strpos($url,'x',3)!==false){
[597] Fix | Delete
preg_match('/\-(\d+x\d+)\./i',$url,$m,0,3);
[598] Fix | Delete
if(isset($m[1])){
[599] Fix | Delete
$m=explode('x',$m[1]);
[600] Fix | Delete
$size= array('w'=>$m[0],'h'=>$m[1]);
[601] Fix | Delete
if($color===0){
[602] Fix | Delete
return $size;
[603] Fix | Delete
}
[604] Fix | Delete
}
[605] Fix | Delete
unset($m);
[606] Fix | Delete
}
[607] Fix | Delete
elseif(strpos($url,'gravatar.com')!==false){
[608] Fix | Delete
$parts = parse_url($url,PHP_URL_QUERY);
[609] Fix | Delete
if(!empty($parts)){
[610] Fix | Delete
parse_str($parts, $query_params);
[611] Fix | Delete
if(!empty($query_params['s'])){
[612] Fix | Delete
return array('w'=>$query_params['s'],'h'=>$query_params['s']);
[613] Fix | Delete
}
[614] Fix | Delete
}
[615] Fix | Delete
}
[616] Fix | Delete
$k=$url.'_size';
[617] Fix | Delete
if(!isset($size) || $color>0){
[618] Fix | Delete
$found=Themify_Storage::get($k);
[619] Fix | Delete
if($found!==''){
[620] Fix | Delete
if(strpos($found,':')!==false){
[621] Fix | Delete
$found=explode(':',$found)[1];
[622] Fix | Delete
}
[623] Fix | Delete
$found=explode('-',$found);
[624] Fix | Delete
if(isset($found[1])){
[625] Fix | Delete
$size= array('w'=>$found[0],'h'=>$found[1]);
[626] Fix | Delete
if($color===0){
[627] Fix | Delete
return $size;
[628] Fix | Delete
}
[629] Fix | Delete
if(isset($found[2])){
[630] Fix | Delete
$size['c']=explode(',',$found[2]);
[631] Fix | Delete
return $size;
[632] Fix | Delete
}
[633] Fix | Delete
}
[634] Fix | Delete
}
[635] Fix | Delete
}
[636] Fix | Delete
$url= urldecode($url);
[637] Fix | Delete
if($isLocal===false){
[638] Fix | Delete
if(defined('THEME_URI') && strpos($url,THEME_URI)!==false){
[639] Fix | Delete
$url=str_replace(THEME_URI,THEME_DIR,$url);
[640] Fix | Delete
$isLocal=true;
[641] Fix | Delete
}
[642] Fix | Delete
else{
[643] Fix | Delete
$upload_dir = themify_upload_dir();
[644] Fix | Delete
if(strpos($url,$upload_dir['baseurl'])!==false){
[645] Fix | Delete
$isLocal=true;
[646] Fix | Delete
$url=str_replace($upload_dir['baseurl'],$upload_dir['basedir'],$url);
[647] Fix | Delete
}
[648] Fix | Delete
unset($upload_dir);
[649] Fix | Delete
}
[650] Fix | Delete
}
[651] Fix | Delete
if(empty($size)){
[652] Fix | Delete
if (class_exists('Themify_Get_Image_Size',false) || is_file( THEMIFY_DIR . '/class-themify-get-image-size.php' ) ) {
[653] Fix | Delete
if($isLocal===false) {
[654] Fix | Delete
static $is = null;
[655] Fix | Delete
if ($is === null) {
[656] Fix | Delete
$is = apply_filters('tf_disable_remote_size', true);
[657] Fix | Delete
}
[658] Fix | Delete
if ($is === false) {
[659] Fix | Delete
return false;
[660] Fix | Delete
}
[661] Fix | Delete
}
[662] Fix | Delete
require_once THEMIFY_DIR . '/class-themify-get-image-size.php';
[663] Fix | Delete
$size=Themify_Get_Image_Size::getSize($url,$isLocal);
[664] Fix | Delete
}
[665] Fix | Delete
else{
[666] Fix | Delete
$size=false;
[667] Fix | Delete
}
[668] Fix | Delete
if($size===false && $isLocal===true && function_exists('getimagesize')){
[669] Fix | Delete
$size=getimagesize($url);
[670] Fix | Delete
$size=empty($size)?false:array('w'=>$size[0],'h'=>$size[1]);
[671] Fix | Delete
}
[672] Fix | Delete
}
[673] Fix | Delete
if($size!==false){
[674] Fix | Delete
$value=$size['w'].'-'.$size['h'];
[675] Fix | Delete
if($color>0 && $isLocal===true ){
[676] Fix | Delete
$colors=themify_get_image_color($url,$size['w'],$size['h'],$color);
[677] Fix | Delete
[678] Fix | Delete
if(!empty($colors)){
[679] Fix | Delete
$size['c']=$colors;
[680] Fix | Delete
$value.='-'.implode(',',$colors);
[681] Fix | Delete
}
[682] Fix | Delete
}
[683] Fix | Delete
Themify_Storage::set($k,$value);
[684] Fix | Delete
}
[685] Fix | Delete
return $size;
[686] Fix | Delete
}
[687] Fix | Delete
[688] Fix | Delete
function themify_get_image_color(string $dir,int $w,int $h,int $rows=4):array{//@todo move to class
[689] Fix | Delete
$colors=[];
[690] Fix | Delete
if($w<=2560 || $h<=2560){
[691] Fix | Delete
$isImagIck=null;
[692] Fix | Delete
if(class_exists('Imagick',false)){
[693] Fix | Delete
try {
[694] Fix | Delete
$im = new Imagick($dir);
[695] Fix | Delete
$isImagIck=true;
[696] Fix | Delete
}
[697] Fix | Delete
catch(Throwable $e) {
[698] Fix | Delete
if(isset($im)){
[699] Fix | Delete
$im->clear();
[700] Fix | Delete
$im=null;
[701] Fix | Delete
}
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
}
[705] Fix | Delete
if(!isset($im)){
[706] Fix | Delete
$ext=strtok(pathinfo($dir,PATHINFO_EXTENSION),'?');
[707] Fix | Delete
if ( $ext === 'png' ) {
[708] Fix | Delete
if(function_exists('imagecreatefrompng')){
[709] Fix | Delete
$im = imagecreatefrompng($dir);
[710] Fix | Delete
}
[711] Fix | Delete
}
[712] Fix | Delete
elseif($ext==='jpg' || $ext==='jpeg'){
[713] Fix | Delete
if(function_exists('imagecreatefromjpeg')){
[714] Fix | Delete
$im = imagecreatefromjpeg($dir);
[715] Fix | Delete
}
[716] Fix | Delete
}
[717] Fix | Delete
elseif($ext==='gif'){
[718] Fix | Delete
if(function_exists('imagecreatefromgif')){
[719] Fix | Delete
$im = imagecreatefromgif($dir);
[720] Fix | Delete
}
[721] Fix | Delete
}
[722] Fix | Delete
elseif($ext==='webp'){
[723] Fix | Delete
if(function_exists('imagecreatefromwebp')){
[724] Fix | Delete
$im = imagecreatefromwebp($dir);
[725] Fix | Delete
}
[726] Fix | Delete
}
[727] Fix | Delete
elseif($ext==='bmp' && function_exists('imagecreatefrombmp')){
[728] Fix | Delete
$im = imagecreatefrombmp($dir);
[729] Fix | Delete
}
[730] Fix | Delete
unset($ext);
[731] Fix | Delete
}
[732] Fix | Delete
if(!empty($im)){
[733] Fix | Delete
$box_w=floor($w/$rows);
[734] Fix | Delete
$box_h=floor($h/$rows);
[735] Fix | Delete
$half_w=(int)($box_w/2);
[736] Fix | Delete
$half_h=(int)($box_h/2);
[737] Fix | Delete
for($y=1;$y<=$rows;++$y){
[738] Fix | Delete
$y_coord=$y*$box_h-$half_h;
[739] Fix | Delete
for($x=1;$x<=$rows;++$x){
[740] Fix | Delete
$x_coord=$x*$box_w-$half_w;
[741] Fix | Delete
if($isImagIck===true){
[742] Fix | Delete
try {
[743] Fix | Delete
$tmp=$im->getImagePixelColor($x_coord,$y_coord)->getColor(0);
[744] Fix | Delete
$color=array('red'=>$tmp['r'],'green'=>$tmp['g'],'blue'=>$tmp['b']);
[745] Fix | Delete
}
[746] Fix | Delete
catch(Throwable $e) {
[747] Fix | Delete
[748] Fix | Delete
}
[749] Fix | Delete
}
[750] Fix | Delete
else{
[751] Fix | Delete
$color=imagecolorsforindex($im, imagecolorat($im, $x_coord,$y_coord));
[752] Fix | Delete
}
[753] Fix | Delete
if(isset($color)){
[754] Fix | Delete
if ($color['red']>=256){
[755] Fix | Delete
$color['red']=240;
[756] Fix | Delete
}
[757] Fix | Delete
if ($color['green']>=256){
[758] Fix | Delete
$color['green']=240;
[759] Fix | Delete
}
[760] Fix | Delete
if ($color['blue']>=256){
[761] Fix | Delete
$color['blue']=240;
[762] Fix | Delete
}
[763] Fix | Delete
$colors[]=substr('0'.dechex($color['red']),-2).substr('0'.dechex($color['green']),-2).substr('0'.dechex($color['blue']),-2);
[764] Fix | Delete
}
[765] Fix | Delete
}
[766] Fix | Delete
}
[767] Fix | Delete
if(isset($im)){
[768] Fix | Delete
if($isImagIck===true){
[769] Fix | Delete
$im->clear();
[770] Fix | Delete
}
[771] Fix | Delete
else{
[772] Fix | Delete
imagedestroy($im);
[773] Fix | Delete
}
[774] Fix | Delete
$im=null;
[775] Fix | Delete
}
[776] Fix | Delete
}
[777] Fix | Delete
}
[778] Fix | Delete
return $colors;
[779] Fix | Delete
}
[780] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function