Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php defined("\102\101\123\105\120\101\124\110") or die("\116\157\40\144\x69\x72\x65\143..

Decoded Output download

<?php
 defined("BASEPATH") or die("No direct script access allowed"); class CI_Image_lib { public $image_library = "gd2"; public $library_path = ''; public $dynamic_output = FALSE; public $source_image = ''; public $new_image = ''; public $width = ''; public $height = ''; public $quality = 90; public $create_thumb = FALSE; public $thumb_marker = "_thumb"; public $maintain_ratio = TRUE; public $master_dim = "auto"; public $rotation_angle = ''; public $x_axis = ''; public $y_axis = ''; public $wm_text = ''; public $wm_type = "text"; public $wm_x_transp = 4; public $wm_y_transp = 4; public $wm_overlay_path = ''; public $wm_font_path = ''; public $wm_font_size = 17; public $wm_vrt_alignment = "B"; public $wm_hor_alignment = "C"; public $wm_padding = 0; public $wm_hor_offset = 0; public $wm_vrt_offset = 0; protected $wm_font_color = "#ffffff"; protected $wm_shadow_color = ''; public $wm_shadow_distance = 2; public $wm_opacity = 50; public $source_folder = ''; public $dest_folder = ''; public $mime_type = ''; public $orig_width = ''; public $orig_height = ''; public $image_type = ''; public $size_str = ''; public $full_src_path = ''; public $full_dst_path = ''; public $file_permissions = 420; public $create_fnc = "imagecreatetruecolor"; public $copy_fnc = "imagecopyresampled"; public $error_msg = array(); protected $wm_use_drop_shadow = FALSE; public $wm_use_truetype = FALSE; public function __construct($props = array()) { if (count($props) > 0) { $this->initialize($props); } ini_set("gd.jpeg_ignore_warning", 1); log_message("info", "Image Lib Class Initialized"); } public function clear() { $props = array("thumb_marker", "library_path", "source_image", "new_image", "width", "height", "rotation_angle", "x_axis", "y_axis", "wm_text", "wm_overlay_path", "wm_font_path", "wm_shadow_color", "source_folder", "dest_folder", "mime_type", "orig_width", "orig_height", "image_type", "size_str", "full_src_path", "full_dst_path"); foreach ($props as $val) { $this->{$val} = ''; } $this->image_library = "gd2"; $this->dynamic_output = FALSE; $this->quality = 90; $this->create_thumb = FALSE; $this->thumb_marker = "_thumb"; $this->maintain_ratio = TRUE; $this->master_dim = "auto"; $this->wm_type = "text"; $this->wm_x_transp = 4; $this->wm_y_transp = 4; $this->wm_font_size = 17; $this->wm_vrt_alignment = "B"; $this->wm_hor_alignment = "C"; $this->wm_padding = 0; $this->wm_hor_offset = 0; $this->wm_vrt_offset = 0; $this->wm_font_color = "#ffffff"; $this->wm_shadow_distance = 2; $this->wm_opacity = 50; $this->create_fnc = "imagecreatetruecolor"; $this->copy_fnc = "imagecopyresampled"; $this->error_msg = array(); $this->wm_use_drop_shadow = FALSE; $this->wm_use_truetype = FALSE; } public function initialize($props = array()) { if (count($props) > 0) { foreach ($props as $key => $val) { if (property_exists($this, $key)) { if (in_array($key, array("wm_font_color", "wm_shadow_color"), TRUE)) { if (preg_match("/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i", $val, $matches)) { $val = strlen($matches[1]) === 6 ? "#" . $matches[1] : "#" . $matches[1][0] . $matches[1][0] . $matches[1][1] . $matches[1][1] . $matches[1][2] . $matches[1][2]; } else { continue; } } elseif (in_array($key, array("width", "height"), TRUE) && !ctype_digit((string) $val)) { continue; } $this->{$key} = $val; } } } if ($this->source_image === '') { $this->set_error("imglib_source_image_required"); return FALSE; } if (!function_exists("getimagesize")) { $this->set_error("imglib_gd_required_for_props"); return FALSE; } $this->image_library = strtolower($this->image_library); if (($full_source_path = realpath($this->source_image)) !== FALSE) { $full_source_path = str_replace("\", "/", $full_source_path); } else { $full_source_path = $this->source_image; } $x = explode("/", $full_source_path); $this->source_image = end($x); $this->source_folder = str_replace($this->source_image, '', $full_source_path); if (!$this->get_image_properties($this->source_folder . $this->source_image)) { return FALSE; } if ($this->new_image === '') { $this->dest_image = $this->source_image; $this->dest_folder = $this->source_folder; } elseif (strpos($this->new_image, "/") === FALSE && strpos($this->new_image, "\") === FALSE) { $this->dest_image = $this->new_image; $this->dest_folder = $this->source_folder; } else { if (!preg_match("#\.(jpg|jpeg|gif|png)$#i", $this->new_image)) { $this->dest_image = $this->source_image; $this->dest_folder = $this->new_image; } else { $x = explode("/", str_replace("\", "/", $this->new_image)); $this->dest_image = end($x); $this->dest_folder = str_replace($this->dest_image, '', $this->new_image); } $this->dest_folder = realpath($this->dest_folder) . "/"; } if ($this->create_thumb === FALSE or $this->thumb_marker === '') { $this->thumb_marker = ''; } $xp = $this->explode_name($this->dest_image); $filename = $xp["name"]; $file_ext = $xp["ext"]; $this->full_src_path = $this->source_folder . $this->source_image; $this->full_dst_path = $this->dest_folder . $filename . $this->thumb_marker . $file_ext; if ($this->maintain_ratio === TRUE && ($this->width !== 0 or $this->height !== 0)) { $this->image_reproportion(); } if ($this->width === '') { $this->width = $this->orig_width; } if ($this->height === '') { $this->height = $this->orig_height; } $this->quality = trim(str_replace("%", '', $this->quality)); if ($this->quality === '' or $this->quality === 0 or !ctype_digit($this->quality)) { $this->quality = 90; } is_numeric($this->x_axis) or $this->x_axis = 0; is_numeric($this->y_axis) or $this->y_axis = 0; if ($this->wm_overlay_path !== '') { $this->wm_overlay_path = str_replace("\", "/", realpath($this->wm_overlay_path)); } if ($this->wm_shadow_color !== '') { $this->wm_use_drop_shadow = TRUE; } elseif ($this->wm_use_drop_shadow === TRUE && $this->wm_shadow_color === '') { $this->wm_use_drop_shadow = FALSE; } if ($this->wm_font_path !== '') { $this->wm_use_truetype = TRUE; } return TRUE; } public function resize() { $protocol = $this->image_library === "gd2" ? "image_process_gd" : "image_process_" . $this->image_library; return $this->{$protocol}("resize"); } public function crop() { $protocol = $this->image_library === "gd2" ? "image_process_gd" : "image_process_" . $this->image_library; return $this->{$protocol}("crop"); } public function rotate() { $degs = array(90, 180, 270, "vrt", "hor"); if ($this->rotation_angle === '' or !in_array($this->rotation_angle, $degs)) { $this->set_error("imglib_rotation_angle_required"); return FALSE; } if ($this->rotation_angle === 90 or $this->rotation_angle === 270) { $this->width = $this->orig_height; $this->height = $this->orig_width; } else { $this->width = $this->orig_width; $this->height = $this->orig_height; } if ($this->image_library === "imagemagick" or $this->image_library === "netpbm") { $protocol = "image_process_" . $this->image_library; return $this->{$protocol}("rotate"); } return ($this->rotation_angle === "hor" or $this->rotation_angle === "vrt") ? $this->image_mirror_gd() : $this->image_rotate_gd(); } public function image_process_gd($action = "resize") { $v2_override = FALSE; if ($this->dynamic_output === FALSE && $this->orig_width === $this->width && $this->orig_height === $this->height) { if ($this->source_image !== $this->new_image && @copy($this->full_src_path, $this->full_dst_path)) { chmod($this->full_dst_path, $this->file_permissions); } return TRUE; } if ($action === "crop") { $this->orig_width = $this->width; $this->orig_height = $this->height; if ($this->gd_version() !== FALSE) { $gd_version = str_replace("0", '', $this->gd_version()); $v2_override = $gd_version == 2; } } else { $this->x_axis = 0; $this->y_axis = 0; } if (!($src_img = $this->image_create_gd())) { return FALSE; } if ($this->image_library === "gd2" && function_exists("imagecreatetruecolor")) { $create = "imagecreatetruecolor"; $copy = "imagecopyresampled"; } else { $create = "imagecreate"; $copy = "imagecopyresized"; } $dst_img = $create($this->width, $this->height); if ($this->image_type === 3) { imagealphablending($dst_img, FALSE); imagesavealpha($dst_img, TRUE); } $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } elseif (!$this->image_save_gd($dst_img)) { return FALSE; } imagedestroy($dst_img); imagedestroy($src_img); if ($this->dynamic_output !== TRUE) { chmod($this->full_dst_path, $this->file_permissions); } return TRUE; } public function image_process_imagemagick($action = "resize") { if ($this->library_path === '') { $this->set_error("imglib_libpath_invalid"); return FALSE; } if (!preg_match("/convert$/i", $this->library_path)) { $this->library_path = rtrim($this->library_path, "/") . "/convert"; } $cmd = $this->library_path . " -quality " . $this->quality; if ($action === "crop") { $cmd .= " -crop " . $this->width . "x" . $this->height . "+" . $this->x_axis . "+" . $this->y_axis; } elseif ($action === "rotate") { $cmd .= ($this->rotation_angle === "hor" or $this->rotation_angle === "vrt") ? " -flop" : " -rotate " . $this->rotation_angle; } else { if ($this->maintain_ratio === TRUE) { $cmd .= " -resize " . $this->width . "x" . $this->height; } else { $cmd .= " -resize " . $this->width . "x" . $this->height . "\!"; } } $cmd .= " " . escapeshellarg($this->full_src_path) . " " . escapeshellarg($this->full_dst_path) . " 2>&1"; $retval = 1; if (function_usable("exec")) { @exec($cmd, $output, $retval); } if ($retval > 0) { $this->set_error("imglib_image_process_failed"); return FALSE; } chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_process_netpbm($action = "resize") { if ($this->library_path === '') { $this->set_error("imglib_libpath_invalid"); return FALSE; } switch ($this->image_type) { case 1: $cmd_in = "giftopnm"; $cmd_out = "ppmtogif"; break; case 2: $cmd_in = "jpegtopnm"; $cmd_out = "ppmtojpeg"; break; case 3: $cmd_in = "pngtopnm"; $cmd_out = "ppmtopng"; break; case 18: $cmd_in = "webptopnm"; $cmd_out = "ppmtowebp"; break; } if ($action === "crop") { $cmd_inner = "pnmcut -left " . $this->x_axis . " -top " . $this->y_axis . " -width " . $this->width . " -height " . $this->height; } elseif ($action === "rotate") { switch ($this->rotation_angle) { case 90: $angle = "r270"; break; case 180: $angle = "r180"; break; case 270: $angle = "r90"; break; case "vrt": $angle = "tb"; break; case "hor": $angle = "lr"; break; } $cmd_inner = "pnmflip -" . $angle . " "; } else { $cmd_inner = "pnmscale -xysize " . $this->width . " " . $this->height; } $cmd = $this->library_path . $cmd_in . " " . escapeshellarg($this->full_src_path) . " | " . $cmd_inner . " | " . $cmd_out . " > " . $this->dest_folder . "netpbm.tmp"; $retval = 1; if (function_usable("exec")) { @exec($cmd, $output, $retval); } if ($retval > 0) { $this->set_error("imglib_image_process_failed"); return FALSE; } copy($this->dest_folder . "netpbm.tmp", $this->full_dst_path); unlink($this->dest_folder . "netpbm.tmp"); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_rotate_gd() { if (!($src_img = $this->image_create_gd())) { return FALSE; } $white = imagecolorallocate($src_img, 255, 255, 255); $dst_img = imagerotate($src_img, $this->rotation_angle, $white); if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } elseif (!$this->image_save_gd($dst_img)) { return FALSE; } imagedestroy($dst_img); imagedestroy($src_img); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_mirror_gd() { if (!($src_img = $this->image_create_gd())) { return FALSE; } $width = $this->orig_width; $height = $this->orig_height; if ($this->rotation_angle === "hor") { for ($i = 0; $i < $height; $i++) { $left = 0; $right = $width - 1; while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); $cr = imagecolorat($src_img, $right, $i); imagesetpixel($src_img, $left, $i, $cr); imagesetpixel($src_img, $right, $i, $cl); $left++; $right--; } } } else { for ($i = 0; $i < $width; $i++) { $top = 0; $bottom = $height - 1; while ($top < $bottom) { $ct = imagecolorat($src_img, $i, $top); $cb = imagecolorat($src_img, $i, $bottom); imagesetpixel($src_img, $i, $top, $cb); imagesetpixel($src_img, $i, $bottom, $ct); $top++; $bottom--; } } } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } elseif (!$this->image_save_gd($src_img)) { return FALSE; } imagedestroy($src_img); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function watermark() { return $this->wm_type === "overlay" ? $this->overlay_watermark() : $this->text_watermark(); } public function overlay_watermark() { if (!function_exists("imagecolortransparent")) { $this->set_error("imglib_gd_required"); return FALSE; } $this->get_image_properties(); $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props["image_type"]; $wm_width = $props["width"]; $wm_height = $props["height"]; $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); $src_img = $this->image_create_gd($this->full_src_path); $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); if ($this->wm_vrt_alignment === "B") { $this->wm_vrt_offset = $this->wm_vrt_offset * -1; } if ($this->wm_hor_alignment === "R") { $this->wm_hor_offset = $this->wm_hor_offset * -1; } $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; if ($this->wm_vrt_alignment === "M") { $y_axis += $this->orig_height / 2 - $wm_height / 2; } elseif ($this->wm_vrt_alignment === "B") { $y_axis += $this->orig_height - $wm_height; } if ($this->wm_hor_alignment === "C") { $x_axis += $this->orig_width / 2 - $wm_width / 2; } elseif ($this->wm_hor_alignment === "R") { $x_axis += $this->orig_width - $wm_width; } if ($wm_img_type === 3) { @imagealphablending($src_img, TRUE); } $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp); $alpha = ($rgba & 2130706432) >> 24; if ($alpha > 0) { imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height); } else { imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp)); imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity); } if ($this->image_type === 3) { imagealphablending($src_img, FALSE); imagesavealpha($src_img, TRUE); } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } elseif (!$this->image_save_gd($src_img)) { return FALSE; } imagedestroy($src_img); imagedestroy($wm_img); return TRUE; } public function text_watermark() { if (!($src_img = $this->image_create_gd())) { return FALSE; } if ($this->wm_use_truetype === TRUE && !file_exists($this->wm_font_path)) { $this->set_error("imglib_missing_font"); return FALSE; } $this->get_image_properties(); if ($this->wm_vrt_alignment === "B") { $this->wm_vrt_offset = $this->wm_vrt_offset * -1; } if ($this->wm_hor_alignment === "R") { $this->wm_hor_offset = $this->wm_hor_offset * -1; } if ($this->wm_use_truetype === TRUE) { if (empty($this->wm_font_size)) { $this->wm_font_size = 17; } if (function_exists("imagettfbbox")) { $temp = imagettfbbox($this->wm_font_size, 0, $this->wm_font_path, $this->wm_text); $temp = $temp[2] - $temp[0]; $fontwidth = $temp / strlen($this->wm_text); } else { $fontwidth = $this->wm_font_size - $this->wm_font_size / 4; } $fontheight = $this->wm_font_size; $this->wm_vrt_offset += $this->wm_font_size; } else { $fontwidth = imagefontwidth($this->wm_font_size); $fontheight = imagefontheight($this->wm_font_size); } $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; if ($this->wm_use_drop_shadow === FALSE) { $this->wm_shadow_distance = 0; } $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); if ($this->wm_vrt_alignment === "M") { $y_axis += $this->orig_height / 2 + $fontheight / 2; } elseif ($this->wm_vrt_alignment === "B") { $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - $fontheight / 2; } if ($this->wm_hor_alignment === "R") { $x_axis += $this->orig_width - $fontwidth * strlen($this->wm_text) - $this->wm_shadow_distance; } elseif ($this->wm_hor_alignment === "C") { $x_axis += floor(($this->orig_width - $fontwidth * strlen($this->wm_text)) / 2); } if ($this->wm_use_drop_shadow) { $x_shad = $x_axis + $this->wm_shadow_distance; $y_shad = $y_axis + $this->wm_shadow_distance; $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2])); if ($this->wm_use_truetype) { imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); } else { imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); } } $txt_color = str_split(substr($this->wm_font_color, 1, 6), 2); $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2])); if ($this->wm_use_truetype) { imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); } else { imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } if ($this->image_type === 3) { imagealphablending($src_img, FALSE); imagesavealpha($src_img, TRUE); } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } else { $this->image_save_gd($src_img); } imagedestroy($src_img); return TRUE; } public function image_create_gd($path = '', $image_type = '') { if ($path === '') { $path = $this->full_src_path; } if ($image_type === '') { $image_type = $this->image_type; } switch ($image_type) { case 1: if (!function_exists("imagecreatefromgif")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_gif_not_supported")); return FALSE; } return imagecreatefromgif($path); case 2: if (!function_exists("imagecreatefromjpeg")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_jpg_not_supported")); return FALSE; } return imagecreatefromjpeg($path); case 3: if (!function_exists("imagecreatefrompng")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_png_not_supported")); return FALSE; } return imagecreatefrompng($path); case 18: if (!function_exists("imagecreatefromwebp")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_webp_not_supported")); return FALSE; } return imagecreatefromwebp($path); default: $this->set_error(array("imglib_unsupported_imagecreate")); return FALSE; } } public function image_save_gd($resource) { switch ($this->image_type) { case 1: if (!function_exists("imagegif")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_gif_not_supported")); return FALSE; } if (!@imagegif($resource, $this->full_dst_path)) { $this->set_error("imglib_save_failed"); return FALSE; } break; case 2: if (!function_exists("imagejpeg")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_jpg_not_supported")); return FALSE; } if (!@imagejpeg($resource, $this->full_dst_path, $this->quality)) { $this->set_error("imglib_save_failed"); return FALSE; } break; case 3: if (!function_exists("imagepng")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_png_not_supported")); return FALSE; } if (!@imagepng($resource, $this->full_dst_path)) { $this->set_error("imglib_save_failed"); return FALSE; } break; case 18: if (!function_exists("imagewebp")) { $this->set_error(array("imglib_unsupported_imagecreate", "imglib_webp_not_supported")); return FALSE; } if (!@imagewebp($resource, $this->full_dst_path)) { $this->set_error("imglib_save_failed"); return FALSE; } break; default: $this->set_error(array("imglib_unsupported_imagecreate")); return FALSE; break; } return TRUE; } public function image_display_gd($resource) { $filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image); $charset = strtoupper(config_item("charset")); $utf8_filename = $charset !== "UTF-8" ? get_instance()->utf8->convert_to_utf8($filename, $charset) : $filename; isset($utf8_filename[0]) && ($utf8_filename = " filename*=UTF-8''" . rawurlencode($utf8_filename)); header("Content-Disposition: filename="" . $filename . "";" . $utf8_filename); header("Content-Type: " . $this->mime_type); header("Content-Transfer-Encoding: binary"); header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT"); switch ($this->image_type) { case 1: imagegif($resource); break; case 2: imagejpeg($resource, NULL, $this->quality); break; case 3: imagepng($resource); break; case 18: imagewebp($resource); break; default: echo "Unable to display the image"; break; } } public function image_reproportion() { if ($this->width === 0 && $this->height === 0 or $this->orig_width === 0 or $this->orig_height === 0 or !ctype_digit((string) $this->width) && !ctype_digit((string) $this->height) or !ctype_digit((string) $this->orig_width) or !ctype_digit((string) $this->orig_height)) { return; } $this->width = (int) $this->width; $this->height = (int) $this->height; if ($this->master_dim !== "width" && $this->master_dim !== "height") { if ($this->width > 0 && $this->height > 0) { $this->master_dim = $this->orig_height / $this->orig_width - $this->height / $this->width < 0 ? "width" : "height"; } else { $this->master_dim = $this->height === 0 ? "width" : "height"; } } elseif ($this->master_dim === "width" && $this->width === 0 or $this->master_dim === "height" && $this->height === 0) { return; } if ($this->master_dim === "width") { $this->height = (int) ceil($this->width * $this->orig_height / $this->orig_width); } else { $this->width = (int) ceil($this->orig_width * $this->height / $this->orig_height); } } public function get_image_properties($path = '', $return = FALSE) { if ($path === '') { $path = $this->full_src_path; } if (!file_exists($path)) { $this->set_error("imglib_invalid_path"); return FALSE; } $vals = getimagesize($path); if ($vals === FALSE) { $this->set_error("imglib_invalid_image"); return FALSE; } $types = array(1 => "gif", 2 => "jpeg", 3 => "png"); $mime = isset($types[$vals[2]]) ? "image/" . $types[$vals[2]] : "image/jpg"; if ($return === TRUE) { return array("width" => $vals[0], "height" => $vals[1], "image_type" => $vals[2], "size_str" => $vals[3], "mime_type" => $mime); } $this->orig_width = $vals[0]; $this->orig_height = $vals[1]; $this->image_type = $vals[2]; $this->size_str = $vals[3]; $this->mime_type = $mime; return TRUE; } public function size_calculator($vals) { if (!is_array($vals)) { return; } $allowed = array("new_width", "new_height", "width", "height"); foreach ($allowed as $item) { if (empty($vals[$item])) { $vals[$item] = 0; } } if ($vals["width"] === 0 or $vals["height"] === 0) { return $vals; } if ($vals["new_width"] === 0) { $vals["new_width"] = ceil($vals["width"] * $vals["new_height"] / $vals["height"]); } elseif ($vals["new_height"] === 0) { $vals["new_height"] = ceil($vals["new_width"] * $vals["height"] / $vals["width"]); } return $vals; } public function explode_name($source_image) { $ext = strrchr($source_image, "."); $name = $ext === FALSE ? $source_image : substr($source_image, 0, -strlen($ext)); return array("ext" => $ext, "name" => $name); } public function gd_loaded() { if (!extension_loaded("gd")) { return function_exists("dl") && @dl("gd.so"); } return TRUE; } public function gd_version() { if (function_exists("gd_info")) { $gd_version = @gd_info(); return preg_replace("/\D/", '', $gd_version["GD Version"]); } return FALSE; } public function set_error($msg) { $CI =& get_instance(); $CI->lang->load("imglib"); if (is_array($msg)) { foreach ($msg as $val) { $msg = $CI->lang->line($val) === FALSE ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message("error", $msg); } } else { $msg = $CI->lang->line($msg) === FALSE ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message("error", $msg); } } public function display_errors($open = "<p>", $close = "</p>") { return count($this->error_msg) > 0 ? $open . implode($close . $open, $this->error_msg) . $close : ''; } } ?>

Did this file decode correctly?

Original Code

<?php
 defined("\102\101\123\105\120\101\124\110") or die("\116\157\40\144\x69\x72\x65\143\x74\40\163\x63\x72\x69\x70\x74\x20\x61\143\x63\x65\x73\163\40\x61\154\154\157\x77\145\x64"); class CI_Image_lib { public $image_library = "\x67\x64\62"; public $library_path = ''; public $dynamic_output = FALSE; public $source_image = ''; public $new_image = ''; public $width = ''; public $height = ''; public $quality = 90; public $create_thumb = FALSE; public $thumb_marker = "\x5f\x74\150\x75\155\142"; public $maintain_ratio = TRUE; public $master_dim = "\x61\165\x74\x6f"; public $rotation_angle = ''; public $x_axis = ''; public $y_axis = ''; public $wm_text = ''; public $wm_type = "\x74\x65\170\x74"; public $wm_x_transp = 4; public $wm_y_transp = 4; public $wm_overlay_path = ''; public $wm_font_path = ''; public $wm_font_size = 17; public $wm_vrt_alignment = "\x42"; public $wm_hor_alignment = "\x43"; public $wm_padding = 0; public $wm_hor_offset = 0; public $wm_vrt_offset = 0; protected $wm_font_color = "\43\x66\146\x66\146\x66\146"; protected $wm_shadow_color = ''; public $wm_shadow_distance = 2; public $wm_opacity = 50; public $source_folder = ''; public $dest_folder = ''; public $mime_type = ''; public $orig_width = ''; public $orig_height = ''; public $image_type = ''; public $size_str = ''; public $full_src_path = ''; public $full_dst_path = ''; public $file_permissions = 420; public $create_fnc = "\x69\155\141\x67\145\x63\x72\145\141\x74\145\164\162\165\145\x63\157\x6c\157\x72"; public $copy_fnc = "\151\155\x61\x67\x65\143\x6f\x70\x79\162\145\163\x61\x6d\160\x6c\x65\144"; public $error_msg = array(); protected $wm_use_drop_shadow = FALSE; public $wm_use_truetype = FALSE; public function __construct($props = array()) { if (count($props) > 0) { $this->initialize($props); } ini_set("\147\x64\56\152\x70\x65\x67\137\x69\x67\x6e\157\x72\145\x5f\167\141\162\x6e\151\156\147", 1); log_message("\151\x6e\x66\157", "\111\155\x61\x67\145\x20\x4c\x69\142\x20\103\x6c\141\x73\163\40\x49\x6e\151\x74\151\141\154\x69\x7a\x65\144"); } public function clear() { $props = array("\164\x68\165\155\142\x5f\x6d\141\162\153\145\162", "\x6c\x69\142\162\x61\162\171\137\160\141\x74\x68", "\x73\157\165\162\x63\145\x5f\151\155\141\x67\145", "\x6e\x65\x77\137\x69\x6d\x61\147\x65", "\167\x69\x64\164\150", "\x68\x65\x69\147\150\x74", "\x72\x6f\x74\x61\x74\x69\x6f\156\137\x61\x6e\x67\x6c\145", "\170\x5f\141\x78\x69\163", "\x79\x5f\x61\x78\151\x73", "\x77\155\x5f\164\x65\x78\164", "\167\x6d\x5f\x6f\166\145\162\154\x61\x79\137\160\x61\x74\150", "\x77\155\137\146\157\x6e\x74\137\x70\x61\x74\x68", "\167\155\x5f\163\x68\x61\x64\157\x77\137\143\157\154\157\x72", "\163\157\165\162\143\x65\x5f\x66\x6f\154\144\145\162", "\x64\x65\163\x74\137\x66\x6f\154\144\145\162", "\x6d\151\155\145\x5f\x74\x79\160\x65", "\157\162\151\x67\137\167\151\x64\164\x68", "\x6f\162\151\147\137\x68\145\x69\x67\150\x74", "\x69\155\x61\x67\x65\x5f\x74\171\x70\145", "\163\x69\172\x65\137\163\x74\162", "\x66\165\154\154\137\x73\x72\x63\137\160\x61\164\x68", "\146\x75\x6c\x6c\137\144\x73\164\137\160\141\164\x68"); foreach ($props as $val) { $this->{$val} = ''; } $this->image_library = "\x67\x64\x32"; $this->dynamic_output = FALSE; $this->quality = 90; $this->create_thumb = FALSE; $this->thumb_marker = "\x5f\x74\x68\x75\x6d\x62"; $this->maintain_ratio = TRUE; $this->master_dim = "\x61\165\164\x6f"; $this->wm_type = "\x74\145\x78\164"; $this->wm_x_transp = 4; $this->wm_y_transp = 4; $this->wm_font_size = 17; $this->wm_vrt_alignment = "\102"; $this->wm_hor_alignment = "\103"; $this->wm_padding = 0; $this->wm_hor_offset = 0; $this->wm_vrt_offset = 0; $this->wm_font_color = "\43\146\146\146\146\146\x66"; $this->wm_shadow_distance = 2; $this->wm_opacity = 50; $this->create_fnc = "\x69\155\x61\147\145\x63\162\145\x61\x74\x65\x74\162\165\145\x63\x6f\x6c\x6f\x72"; $this->copy_fnc = "\151\x6d\x61\x67\x65\143\x6f\160\171\x72\145\x73\141\155\x70\154\145\144"; $this->error_msg = array(); $this->wm_use_drop_shadow = FALSE; $this->wm_use_truetype = FALSE; } public function initialize($props = array()) { if (count($props) > 0) { foreach ($props as $key => $val) { if (property_exists($this, $key)) { if (in_array($key, array("\x77\x6d\137\146\157\x6e\164\x5f\143\157\x6c\157\x72", "\167\155\137\x73\x68\x61\144\157\x77\x5f\143\157\154\x6f\162"), TRUE)) { if (preg_match("\x2f\x5e\x23\x3f\50\133\x30\55\x39\141\x2d\146\135\x7b\x33\175\x7c\133\60\x2d\71\x61\x2d\146\135\173\x36\175\x29\x24\57\151", $val, $matches)) { $val = strlen($matches[1]) === 6 ? "\x23" . $matches[1] : "\x23" . $matches[1][0] . $matches[1][0] . $matches[1][1] . $matches[1][1] . $matches[1][2] . $matches[1][2]; } else { continue; } } elseif (in_array($key, array("\167\x69\144\x74\150", "\x68\x65\151\x67\x68\164"), TRUE) && !ctype_digit((string) $val)) { continue; } $this->{$key} = $val; } } } if ($this->source_image === '') { $this->set_error("\151\x6d\x67\154\x69\x62\137\163\x6f\x75\x72\143\x65\x5f\151\x6d\141\x67\x65\137\162\145\x71\x75\x69\162\145\144"); return FALSE; } if (!function_exists("\x67\145\164\x69\155\x61\x67\145\163\151\x7a\x65")) { $this->set_error("\151\x6d\147\154\151\x62\x5f\147\144\137\162\x65\161\x75\x69\162\x65\144\x5f\x66\x6f\x72\x5f\x70\x72\157\x70\x73"); return FALSE; } $this->image_library = strtolower($this->image_library); if (($full_source_path = realpath($this->source_image)) !== FALSE) { $full_source_path = str_replace("\134", "\x2f", $full_source_path); } else { $full_source_path = $this->source_image; } $x = explode("\57", $full_source_path); $this->source_image = end($x); $this->source_folder = str_replace($this->source_image, '', $full_source_path); if (!$this->get_image_properties($this->source_folder . $this->source_image)) { return FALSE; } if ($this->new_image === '') { $this->dest_image = $this->source_image; $this->dest_folder = $this->source_folder; } elseif (strpos($this->new_image, "\57") === FALSE && strpos($this->new_image, "\x5c") === FALSE) { $this->dest_image = $this->new_image; $this->dest_folder = $this->source_folder; } else { if (!preg_match("\x23\x5c\x2e\50\152\x70\x67\174\152\160\145\x67\174\x67\151\146\x7c\160\x6e\147\x29\x24\x23\x69", $this->new_image)) { $this->dest_image = $this->source_image; $this->dest_folder = $this->new_image; } else { $x = explode("\x2f", str_replace("\x5c", "\57", $this->new_image)); $this->dest_image = end($x); $this->dest_folder = str_replace($this->dest_image, '', $this->new_image); } $this->dest_folder = realpath($this->dest_folder) . "\x2f"; } if ($this->create_thumb === FALSE or $this->thumb_marker === '') { $this->thumb_marker = ''; } $xp = $this->explode_name($this->dest_image); $filename = $xp["\156\x61\x6d\x65"]; $file_ext = $xp["\145\170\164"]; $this->full_src_path = $this->source_folder . $this->source_image; $this->full_dst_path = $this->dest_folder . $filename . $this->thumb_marker . $file_ext; if ($this->maintain_ratio === TRUE && ($this->width !== 0 or $this->height !== 0)) { $this->image_reproportion(); } if ($this->width === '') { $this->width = $this->orig_width; } if ($this->height === '') { $this->height = $this->orig_height; } $this->quality = trim(str_replace("\x25", '', $this->quality)); if ($this->quality === '' or $this->quality === 0 or !ctype_digit($this->quality)) { $this->quality = 90; } is_numeric($this->x_axis) or $this->x_axis = 0; is_numeric($this->y_axis) or $this->y_axis = 0; if ($this->wm_overlay_path !== '') { $this->wm_overlay_path = str_replace("\x5c", "\x2f", realpath($this->wm_overlay_path)); } if ($this->wm_shadow_color !== '') { $this->wm_use_drop_shadow = TRUE; } elseif ($this->wm_use_drop_shadow === TRUE && $this->wm_shadow_color === '') { $this->wm_use_drop_shadow = FALSE; } if ($this->wm_font_path !== '') { $this->wm_use_truetype = TRUE; } return TRUE; } public function resize() { $protocol = $this->image_library === "\x67\144\62" ? "\x69\155\x61\x67\145\137\x70\x72\x6f\143\145\x73\x73\137\x67\144" : "\151\155\x61\x67\145\x5f\160\162\157\x63\x65\x73\163\x5f" . $this->image_library; return $this->{$protocol}("\x72\145\x73\151\172\145"); } public function crop() { $protocol = $this->image_library === "\x67\x64\x32" ? "\151\x6d\141\147\145\137\160\x72\x6f\143\x65\x73\163\x5f\x67\144" : "\151\x6d\x61\x67\145\x5f\x70\162\x6f\x63\145\163\x73\137" . $this->image_library; return $this->{$protocol}("\143\x72\x6f\x70"); } public function rotate() { $degs = array(90, 180, 270, "\x76\x72\x74", "\150\157\162"); if ($this->rotation_angle === '' or !in_array($this->rotation_angle, $degs)) { $this->set_error("\151\x6d\x67\x6c\x69\x62\137\162\x6f\164\x61\164\151\157\x6e\137\x61\x6e\x67\x6c\145\137\x72\145\161\165\151\162\x65\144"); return FALSE; } if ($this->rotation_angle === 90 or $this->rotation_angle === 270) { $this->width = $this->orig_height; $this->height = $this->orig_width; } else { $this->width = $this->orig_width; $this->height = $this->orig_height; } if ($this->image_library === "\x69\x6d\141\x67\x65\x6d\141\147\x69\x63\x6b" or $this->image_library === "\156\x65\164\x70\x62\155") { $protocol = "\x69\155\x61\147\x65\x5f\x70\x72\157\x63\145\163\x73\137" . $this->image_library; return $this->{$protocol}("\162\x6f\x74\141\x74\x65"); } return ($this->rotation_angle === "\x68\x6f\x72" or $this->rotation_angle === "\x76\162\164") ? $this->image_mirror_gd() : $this->image_rotate_gd(); } public function image_process_gd($action = "\x72\x65\x73\x69\x7a\x65") { $v2_override = FALSE; if ($this->dynamic_output === FALSE && $this->orig_width === $this->width && $this->orig_height === $this->height) { if ($this->source_image !== $this->new_image && @copy($this->full_src_path, $this->full_dst_path)) { chmod($this->full_dst_path, $this->file_permissions); } return TRUE; } if ($action === "\x63\162\x6f\160") { $this->orig_width = $this->width; $this->orig_height = $this->height; if ($this->gd_version() !== FALSE) { $gd_version = str_replace("\60", '', $this->gd_version()); $v2_override = $gd_version == 2; } } else { $this->x_axis = 0; $this->y_axis = 0; } if (!($src_img = $this->image_create_gd())) { return FALSE; } if ($this->image_library === "\147\x64\62" && function_exists("\x69\155\x61\147\x65\x63\162\145\141\164\145\164\162\x75\145\143\x6f\154\157\x72")) { $create = "\x69\x6d\141\147\x65\x63\162\145\x61\x74\x65\164\162\x75\145\143\x6f\x6c\157\162"; $copy = "\x69\155\141\147\x65\x63\x6f\160\x79\x72\x65\163\x61\x6d\160\154\145\144"; } else { $create = "\151\155\141\x67\x65\x63\162\145\x61\164\145"; $copy = "\151\155\x61\x67\x65\x63\x6f\160\171\x72\x65\163\151\172\145\x64"; } $dst_img = $create($this->width, $this->height); if ($this->image_type === 3) { imagealphablending($dst_img, FALSE); imagesavealpha($dst_img, TRUE); } $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } elseif (!$this->image_save_gd($dst_img)) { return FALSE; } imagedestroy($dst_img); imagedestroy($src_img); if ($this->dynamic_output !== TRUE) { chmod($this->full_dst_path, $this->file_permissions); } return TRUE; } public function image_process_imagemagick($action = "\162\x65\163\151\172\x65") { if ($this->library_path === '') { $this->set_error("\151\x6d\147\154\x69\142\x5f\x6c\x69\x62\160\141\164\x68\137\x69\156\x76\141\154\151\x64"); return FALSE; } if (!preg_match("\x2f\x63\157\x6e\166\x65\162\x74\x24\57\151", $this->library_path)) { $this->library_path = rtrim($this->library_path, "\x2f") . "\x2f\143\x6f\x6e\166\x65\x72\x74"; } $cmd = $this->library_path . "\x20\x2d\161\x75\141\154\151\x74\171\40" . $this->quality; if ($action === "\143\162\x6f\160") { $cmd .= "\40\55\x63\162\x6f\160\40" . $this->width . "\170" . $this->height . "\x2b" . $this->x_axis . "\x2b" . $this->y_axis; } elseif ($action === "\162\x6f\x74\141\x74\x65") { $cmd .= ($this->rotation_angle === "\150\157\162" or $this->rotation_angle === "\x76\162\164") ? "\40\x2d\146\154\157\x70" : "\40\x2d\x72\157\164\141\x74\x65\x20" . $this->rotation_angle; } else { if ($this->maintain_ratio === TRUE) { $cmd .= "\40\x2d\162\145\x73\x69\172\145\x20" . $this->width . "\x78" . $this->height; } else { $cmd .= "\40\x2d\162\x65\x73\x69\172\x65\40" . $this->width . "\170" . $this->height . "\x5c\x21"; } } $cmd .= "\x20" . escapeshellarg($this->full_src_path) . "\x20" . escapeshellarg($this->full_dst_path) . "\40\x32\76\x26\61"; $retval = 1; if (function_usable("\145\170\145\143")) { @exec($cmd, $output, $retval); } if ($retval > 0) { $this->set_error("\x69\x6d\x67\154\x69\x62\x5f\151\x6d\141\147\145\x5f\x70\162\157\143\145\163\x73\x5f\x66\x61\x69\x6c\145\x64"); return FALSE; } chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_process_netpbm($action = "\162\x65\163\151\x7a\x65") { if ($this->library_path === '') { $this->set_error("\151\155\x67\154\x69\x62\x5f\x6c\151\142\160\x61\x74\x68\x5f\x69\156\x76\141\x6c\151\x64"); return FALSE; } switch ($this->image_type) { case 1: $cmd_in = "\147\151\146\164\157\160\156\155"; $cmd_out = "\160\x70\155\164\157\x67\151\x66"; break; case 2: $cmd_in = "\x6a\160\x65\147\164\x6f\160\x6e\155"; $cmd_out = "\160\x70\155\164\157\152\160\x65\147"; break; case 3: $cmd_in = "\160\156\x67\x74\x6f\x70\x6e\x6d"; $cmd_out = "\x70\x70\x6d\164\157\160\x6e\147"; break; case 18: $cmd_in = "\167\x65\x62\x70\164\x6f\160\x6e\155"; $cmd_out = "\160\x70\x6d\x74\157\x77\x65\142\x70"; break; } if ($action === "\143\x72\157\160") { $cmd_inner = "\160\156\x6d\x63\x75\164\x20\55\x6c\145\146\x74\x20" . $this->x_axis . "\40\55\x74\157\160\x20" . $this->y_axis . "\x20\55\x77\x69\x64\164\x68\x20" . $this->width . "\x20\x2d\x68\x65\151\147\x68\164\40" . $this->height; } elseif ($action === "\x72\x6f\164\x61\x74\x65") { switch ($this->rotation_angle) { case 90: $angle = "\162\62\x37\x30"; break; case 180: $angle = "\162\61\70\x30"; break; case 270: $angle = "\x72\71\60"; break; case "\166\x72\164": $angle = "\164\x62"; break; case "\x68\157\162": $angle = "\154\x72"; break; } $cmd_inner = "\x70\156\x6d\146\x6c\151\160\40\x2d" . $angle . "\x20"; } else { $cmd_inner = "\x70\156\155\x73\x63\x61\x6c\145\x20\55\x78\x79\x73\x69\x7a\x65\x20" . $this->width . "\x20" . $this->height; } $cmd = $this->library_path . $cmd_in . "\x20" . escapeshellarg($this->full_src_path) . "\x20\x7c\x20" . $cmd_inner . "\40\174\40" . $cmd_out . "\x20\x3e\40" . $this->dest_folder . "\156\x65\x74\x70\x62\155\x2e\x74\155\160"; $retval = 1; if (function_usable("\145\170\x65\x63")) { @exec($cmd, $output, $retval); } if ($retval > 0) { $this->set_error("\151\155\x67\154\151\142\137\151\x6d\x61\x67\x65\137\160\162\157\x63\x65\163\163\137\x66\141\x69\x6c\x65\x64"); return FALSE; } copy($this->dest_folder . "\156\x65\164\160\142\155\56\x74\155\x70", $this->full_dst_path); unlink($this->dest_folder . "\156\x65\x74\160\x62\155\56\164\x6d\x70"); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_rotate_gd() { if (!($src_img = $this->image_create_gd())) { return FALSE; } $white = imagecolorallocate($src_img, 255, 255, 255); $dst_img = imagerotate($src_img, $this->rotation_angle, $white); if ($this->dynamic_output === TRUE) { $this->image_display_gd($dst_img); } elseif (!$this->image_save_gd($dst_img)) { return FALSE; } imagedestroy($dst_img); imagedestroy($src_img); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function image_mirror_gd() { if (!($src_img = $this->image_create_gd())) { return FALSE; } $width = $this->orig_width; $height = $this->orig_height; if ($this->rotation_angle === "\x68\157\x72") { for ($i = 0; $i < $height; $i++) { $left = 0; $right = $width - 1; while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); $cr = imagecolorat($src_img, $right, $i); imagesetpixel($src_img, $left, $i, $cr); imagesetpixel($src_img, $right, $i, $cl); $left++; $right--; } } } else { for ($i = 0; $i < $width; $i++) { $top = 0; $bottom = $height - 1; while ($top < $bottom) { $ct = imagecolorat($src_img, $i, $top); $cb = imagecolorat($src_img, $i, $bottom); imagesetpixel($src_img, $i, $top, $cb); imagesetpixel($src_img, $i, $bottom, $ct); $top++; $bottom--; } } } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } elseif (!$this->image_save_gd($src_img)) { return FALSE; } imagedestroy($src_img); chmod($this->full_dst_path, $this->file_permissions); return TRUE; } public function watermark() { return $this->wm_type === "\157\166\x65\162\x6c\x61\171" ? $this->overlay_watermark() : $this->text_watermark(); } public function overlay_watermark() { if (!function_exists("\x69\155\x61\147\x65\143\157\154\x6f\162\x74\x72\141\x6e\x73\160\x61\162\x65\156\x74")) { $this->set_error("\151\x6d\x67\154\x69\x62\137\147\x64\x5f\162\145\161\165\x69\x72\145\x64"); return FALSE; } $this->get_image_properties(); $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props["\x69\x6d\141\147\x65\x5f\x74\x79\x70\145"]; $wm_width = $props["\x77\151\x64\164\150"]; $wm_height = $props["\x68\145\x69\x67\150\164"]; $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); $src_img = $this->image_create_gd($this->full_src_path); $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); if ($this->wm_vrt_alignment === "\x42") { $this->wm_vrt_offset = $this->wm_vrt_offset * -1; } if ($this->wm_hor_alignment === "\x52") { $this->wm_hor_offset = $this->wm_hor_offset * -1; } $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; if ($this->wm_vrt_alignment === "\115") { $y_axis += $this->orig_height / 2 - $wm_height / 2; } elseif ($this->wm_vrt_alignment === "\x42") { $y_axis += $this->orig_height - $wm_height; } if ($this->wm_hor_alignment === "\x43") { $x_axis += $this->orig_width / 2 - $wm_width / 2; } elseif ($this->wm_hor_alignment === "\122") { $x_axis += $this->orig_width - $wm_width; } if ($wm_img_type === 3) { @imagealphablending($src_img, TRUE); } $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp); $alpha = ($rgba & 2130706432) >> 24; if ($alpha > 0) { imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height); } else { imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp)); imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity); } if ($this->image_type === 3) { imagealphablending($src_img, FALSE); imagesavealpha($src_img, TRUE); } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } elseif (!$this->image_save_gd($src_img)) { return FALSE; } imagedestroy($src_img); imagedestroy($wm_img); return TRUE; } public function text_watermark() { if (!($src_img = $this->image_create_gd())) { return FALSE; } if ($this->wm_use_truetype === TRUE && !file_exists($this->wm_font_path)) { $this->set_error("\151\155\x67\x6c\x69\142\137\155\x69\163\163\151\156\147\137\x66\157\x6e\164"); return FALSE; } $this->get_image_properties(); if ($this->wm_vrt_alignment === "\x42") { $this->wm_vrt_offset = $this->wm_vrt_offset * -1; } if ($this->wm_hor_alignment === "\x52") { $this->wm_hor_offset = $this->wm_hor_offset * -1; } if ($this->wm_use_truetype === TRUE) { if (empty($this->wm_font_size)) { $this->wm_font_size = 17; } if (function_exists("\151\155\141\147\145\164\164\146\142\142\x6f\x78")) { $temp = imagettfbbox($this->wm_font_size, 0, $this->wm_font_path, $this->wm_text); $temp = $temp[2] - $temp[0]; $fontwidth = $temp / strlen($this->wm_text); } else { $fontwidth = $this->wm_font_size - $this->wm_font_size / 4; } $fontheight = $this->wm_font_size; $this->wm_vrt_offset += $this->wm_font_size; } else { $fontwidth = imagefontwidth($this->wm_font_size); $fontheight = imagefontheight($this->wm_font_size); } $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; if ($this->wm_use_drop_shadow === FALSE) { $this->wm_shadow_distance = 0; } $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]); $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]); if ($this->wm_vrt_alignment === "\115") { $y_axis += $this->orig_height / 2 + $fontheight / 2; } elseif ($this->wm_vrt_alignment === "\x42") { $y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - $fontheight / 2; } if ($this->wm_hor_alignment === "\x52") { $x_axis += $this->orig_width - $fontwidth * strlen($this->wm_text) - $this->wm_shadow_distance; } elseif ($this->wm_hor_alignment === "\103") { $x_axis += floor(($this->orig_width - $fontwidth * strlen($this->wm_text)) / 2); } if ($this->wm_use_drop_shadow) { $x_shad = $x_axis + $this->wm_shadow_distance; $y_shad = $y_axis + $this->wm_shadow_distance; $drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2); $drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2])); if ($this->wm_use_truetype) { imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); } else { imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); } } $txt_color = str_split(substr($this->wm_font_color, 1, 6), 2); $txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2])); if ($this->wm_use_truetype) { imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); } else { imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } if ($this->image_type === 3) { imagealphablending($src_img, FALSE); imagesavealpha($src_img, TRUE); } if ($this->dynamic_output === TRUE) { $this->image_display_gd($src_img); } else { $this->image_save_gd($src_img); } imagedestroy($src_img); return TRUE; } public function image_create_gd($path = '', $image_type = '') { if ($path === '') { $path = $this->full_src_path; } if ($image_type === '') { $image_type = $this->image_type; } switch ($image_type) { case 1: if (!function_exists("\x69\155\141\x67\145\143\162\x65\x61\164\x65\x66\x72\157\x6d\147\x69\146")) { $this->set_error(array("\x69\x6d\147\x6c\151\x62\x5f\x75\156\163\165\x70\160\x6f\162\x74\x65\144\137\151\155\x61\147\145\143\162\x65\x61\164\145", "\x69\x6d\x67\x6c\151\x62\137\147\x69\x66\137\x6e\157\164\x5f\163\x75\x70\160\x6f\x72\164\145\144")); return FALSE; } return imagecreatefromgif($path); case 2: if (!function_exists("\x69\155\x61\147\x65\143\162\145\x61\164\x65\146\162\157\x6d\x6a\x70\x65\147")) { $this->set_error(array("\151\x6d\147\154\151\142\137\165\156\x73\165\x70\x70\157\x72\164\x65\x64\137\x69\155\x61\x67\145\143\x72\145\x61\x74\145", "\151\x6d\147\154\151\142\137\152\160\x67\x5f\156\x6f\164\137\163\165\160\x70\x6f\x72\164\145\x64")); return FALSE; } return imagecreatefromjpeg($path); case 3: if (!function_exists("\151\x6d\x61\x67\x65\x63\162\145\141\x74\145\146\x72\157\155\160\156\147")) { $this->set_error(array("\x69\x6d\147\x6c\151\x62\137\x75\x6e\x73\x75\x70\160\157\x72\164\145\144\137\x69\x6d\x61\147\145\143\x72\145\x61\x74\145", "\x69\x6d\147\x6c\x69\142\x5f\160\x6e\147\x5f\156\157\164\x5f\x73\165\x70\160\x6f\162\164\x65\x64")); return FALSE; } return imagecreatefrompng($path); case 18: if (!function_exists("\x69\155\x61\x67\x65\143\x72\145\141\164\145\x66\x72\157\x6d\167\145\142\160")) { $this->set_error(array("\x69\155\x67\x6c\x69\142\137\x75\156\163\x75\160\160\157\x72\164\145\x64\x5f\151\x6d\x61\147\145\x63\162\145\141\164\145", "\x69\x6d\x67\x6c\151\x62\x5f\167\145\142\x70\137\x6e\x6f\x74\x5f\163\x75\160\160\157\x72\164\145\144")); return FALSE; } return imagecreatefromwebp($path); default: $this->set_error(array("\x69\x6d\147\x6c\x69\x62\x5f\x75\x6e\x73\x75\x70\160\x6f\162\x74\x65\144\137\x69\x6d\141\x67\145\x63\162\145\141\x74\x65")); return FALSE; } } public function image_save_gd($resource) { switch ($this->image_type) { case 1: if (!function_exists("\x69\155\x61\147\145\147\x69\x66")) { $this->set_error(array("\151\155\147\x6c\x69\142\137\x75\x6e\163\x75\160\160\157\x72\x74\x65\x64\x5f\151\x6d\141\147\x65\x63\x72\145\x61\x74\x65", "\x69\155\147\154\x69\x62\137\x67\x69\x66\x5f\156\x6f\164\x5f\163\165\160\x70\157\x72\x74\145\x64")); return FALSE; } if (!@imagegif($resource, $this->full_dst_path)) { $this->set_error("\x69\x6d\147\x6c\151\x62\x5f\163\x61\166\x65\x5f\x66\141\151\154\x65\x64"); return FALSE; } break; case 2: if (!function_exists("\x69\x6d\141\147\x65\x6a\x70\x65\147")) { $this->set_error(array("\x69\155\x67\154\151\142\x5f\165\x6e\163\165\160\160\157\162\164\x65\x64\137\151\155\141\147\145\x63\x72\x65\141\x74\145", "\151\x6d\x67\x6c\151\x62\x5f\152\160\x67\137\x6e\157\164\x5f\x73\x75\x70\160\x6f\162\164\x65\x64")); return FALSE; } if (!@imagejpeg($resource, $this->full_dst_path, $this->quality)) { $this->set_error("\x69\155\147\x6c\151\142\x5f\163\141\x76\145\x5f\146\141\x69\154\145\144"); return FALSE; } break; case 3: if (!function_exists("\151\155\141\x67\145\160\156\147")) { $this->set_error(array("\151\x6d\147\154\x69\x62\x5f\165\x6e\x73\165\160\160\157\x72\x74\145\x64\137\x69\155\x61\147\x65\143\x72\145\141\x74\x65", "\x69\x6d\x67\x6c\x69\x62\137\160\x6e\x67\x5f\x6e\x6f\164\x5f\x73\x75\x70\x70\x6f\162\x74\x65\144")); return FALSE; } if (!@imagepng($resource, $this->full_dst_path)) { $this->set_error("\x69\x6d\147\154\151\x62\x5f\x73\x61\x76\145\x5f\146\x61\x69\154\145\x64"); return FALSE; } break; case 18: if (!function_exists("\x69\x6d\141\x67\145\167\145\142\x70")) { $this->set_error(array("\x69\155\x67\154\151\142\137\x75\156\163\165\160\x70\157\162\x74\x65\x64\137\x69\x6d\x61\x67\145\x63\x72\145\x61\x74\x65", "\151\x6d\x67\154\151\142\137\167\145\x62\160\x5f\156\x6f\164\x5f\163\x75\x70\x70\157\x72\x74\145\144")); return FALSE; } if (!@imagewebp($resource, $this->full_dst_path)) { $this->set_error("\151\155\147\154\151\142\x5f\163\x61\x76\145\x5f\x66\x61\x69\x6c\145\x64"); return FALSE; } break; default: $this->set_error(array("\x69\155\147\154\x69\142\x5f\x75\156\163\165\160\x70\157\162\164\145\144\x5f\x69\x6d\141\x67\x65\143\x72\x65\x61\x74\x65")); return FALSE; break; } return TRUE; } public function image_display_gd($resource) { $filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image); $charset = strtoupper(config_item("\143\150\x61\x72\163\145\164")); $utf8_filename = $charset !== "\125\x54\106\x2d\x38" ? get_instance()->utf8->convert_to_utf8($filename, $charset) : $filename; isset($utf8_filename[0]) && ($utf8_filename = "\x20\x66\151\154\145\x6e\141\155\145\x2a\x3d\125\124\x46\x2d\x38\x27\x27" . rawurlencode($utf8_filename)); header("\103\157\x6e\x74\x65\156\164\55\104\x69\x73\x70\x6f\x73\151\164\x69\157\x6e\72\40\146\x69\x6c\x65\x6e\x61\155\x65\75\x22" . $filename . "\x22\73" . $utf8_filename); header("\x43\x6f\156\164\145\x6e\164\x2d\x54\171\160\145\72\40" . $this->mime_type); header("\103\157\156\x74\145\x6e\164\55\x54\162\141\156\x73\x66\145\162\55\x45\x6e\143\157\x64\x69\156\x67\72\x20\x62\x69\156\141\x72\x79"); header("\x4c\141\163\164\55\115\x6f\x64\151\x66\151\145\x64\x3a\x20" . gmdate("\104\54\40\x64\x20\115\40\131\x20\x48\x3a\x69\72\x73", time()) . "\40\x47\115\124"); switch ($this->image_type) { case 1: imagegif($resource); break; case 2: imagejpeg($resource, NULL, $this->quality); break; case 3: imagepng($resource); break; case 18: imagewebp($resource); break; default: echo "\x55\156\141\x62\x6c\x65\40\x74\x6f\x20\144\151\163\160\154\141\171\x20\164\x68\145\40\151\x6d\x61\x67\145"; break; } } public function image_reproportion() { if ($this->width === 0 && $this->height === 0 or $this->orig_width === 0 or $this->orig_height === 0 or !ctype_digit((string) $this->width) && !ctype_digit((string) $this->height) or !ctype_digit((string) $this->orig_width) or !ctype_digit((string) $this->orig_height)) { return; } $this->width = (int) $this->width; $this->height = (int) $this->height; if ($this->master_dim !== "\x77\x69\x64\x74\x68" && $this->master_dim !== "\x68\x65\151\x67\150\164") { if ($this->width > 0 && $this->height > 0) { $this->master_dim = $this->orig_height / $this->orig_width - $this->height / $this->width < 0 ? "\x77\x69\x64\164\150" : "\x68\x65\151\147\150\x74"; } else { $this->master_dim = $this->height === 0 ? "\167\x69\x64\164\150" : "\150\145\151\147\x68\x74"; } } elseif ($this->master_dim === "\x77\x69\144\164\150" && $this->width === 0 or $this->master_dim === "\150\x65\x69\x67\x68\x74" && $this->height === 0) { return; } if ($this->master_dim === "\167\x69\x64\x74\x68") { $this->height = (int) ceil($this->width * $this->orig_height / $this->orig_width); } else { $this->width = (int) ceil($this->orig_width * $this->height / $this->orig_height); } } public function get_image_properties($path = '', $return = FALSE) { if ($path === '') { $path = $this->full_src_path; } if (!file_exists($path)) { $this->set_error("\x69\155\147\154\151\x62\x5f\151\156\x76\x61\154\151\x64\x5f\x70\141\164\150"); return FALSE; } $vals = getimagesize($path); if ($vals === FALSE) { $this->set_error("\151\x6d\147\154\x69\x62\137\x69\156\x76\141\x6c\x69\144\x5f\x69\x6d\x61\x67\145"); return FALSE; } $types = array(1 => "\147\151\x66", 2 => "\152\x70\x65\147", 3 => "\x70\156\147"); $mime = isset($types[$vals[2]]) ? "\151\155\x61\147\x65\x2f" . $types[$vals[2]] : "\x69\155\x61\147\145\57\152\x70\147"; if ($return === TRUE) { return array("\x77\151\144\x74\150" => $vals[0], "\x68\x65\x69\147\150\x74" => $vals[1], "\151\x6d\141\147\145\137\x74\x79\x70\x65" => $vals[2], "\163\151\x7a\145\x5f\x73\x74\162" => $vals[3], "\155\x69\155\145\137\x74\x79\x70\x65" => $mime); } $this->orig_width = $vals[0]; $this->orig_height = $vals[1]; $this->image_type = $vals[2]; $this->size_str = $vals[3]; $this->mime_type = $mime; return TRUE; } public function size_calculator($vals) { if (!is_array($vals)) { return; } $allowed = array("\156\145\167\x5f\x77\x69\x64\x74\150", "\156\x65\x77\137\150\145\x69\147\150\x74", "\x77\151\144\x74\x68", "\x68\145\x69\x67\150\164"); foreach ($allowed as $item) { if (empty($vals[$item])) { $vals[$item] = 0; } } if ($vals["\x77\x69\144\x74\150"] === 0 or $vals["\150\145\x69\147\150\x74"] === 0) { return $vals; } if ($vals["\x6e\x65\x77\x5f\167\151\144\164\x68"] === 0) { $vals["\x6e\x65\167\137\167\x69\144\164\x68"] = ceil($vals["\167\x69\x64\x74\150"] * $vals["\156\x65\167\x5f\150\145\151\147\x68\x74"] / $vals["\x68\145\x69\x67\150\x74"]); } elseif ($vals["\156\x65\x77\x5f\150\145\x69\147\150\x74"] === 0) { $vals["\156\x65\x77\x5f\150\x65\151\147\150\164"] = ceil($vals["\x6e\x65\167\137\167\151\144\164\x68"] * $vals["\x68\x65\151\x67\150\164"] / $vals["\x77\x69\x64\x74\150"]); } return $vals; } public function explode_name($source_image) { $ext = strrchr($source_image, "\56"); $name = $ext === FALSE ? $source_image : substr($source_image, 0, -strlen($ext)); return array("\145\170\x74" => $ext, "\156\x61\155\x65" => $name); } public function gd_loaded() { if (!extension_loaded("\x67\x64")) { return function_exists("\x64\x6c") && @dl("\147\144\x2e\x73\157"); } return TRUE; } public function gd_version() { if (function_exists("\147\144\137\x69\156\x66\x6f")) { $gd_version = @gd_info(); return preg_replace("\57\x5c\104\x2f", '', $gd_version["\107\104\x20\x56\x65\162\163\x69\x6f\156"]); } return FALSE; } public function set_error($msg) { $CI =& get_instance(); $CI->lang->load("\x69\155\x67\x6c\x69\142"); if (is_array($msg)) { foreach ($msg as $val) { $msg = $CI->lang->line($val) === FALSE ? $val : $CI->lang->line($val); $this->error_msg[] = $msg; log_message("\x65\x72\162\157\x72", $msg); } } else { $msg = $CI->lang->line($msg) === FALSE ? $msg : $CI->lang->line($msg); $this->error_msg[] = $msg; log_message("\x65\162\162\x6f\x72", $msg); } } public function display_errors($open = "\x3c\x70\x3e", $close = "\74\57\x70\x3e") { return count($this->error_msg) > 0 ? $open . implode($close . $open, $this->error_msg) . $close : ''; } }

Function Calls

defined 1

Variables

None

Stats

MD5 f0eee1e6fe80818f77ee66bf270cd53a
Eval Count 0
Decode Time 282 ms