| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/theavaaddams.com/public_html/free2/fnc/ |
Upload File : |
<?php
function SaveImage($type, $im, $filename, $quality, $to_file = true) {
$res = null;
// ImageGIF is not included into some GD2 releases, so it might not work
// output png if gifs are not supported
if(!function_exists('imagegif')) $type = 3;
switch ($type) {
case 1:
if ($to_file) {
$res = ImageGIF($im,$filename);
}
else {
header("Content-type: image/gif");
$res = ImageGIF($im);
}
break;
case 2:
if ($to_file) {
$res = ImageJPEG($im,$filename,$quality);
}
else {
header("Content-type: image/jpeg");
$res = ImageJPEG($im, NULL, $quality);
}
break;
case 3:
if (PHP_VERSION >= '5.1.2') {
// Convert to PNG quality.
// PNG quality: 0 (best quality, bigger file) to 9 (worst quality, smaller file)
$quality = 9 - min( round($quality / 10), 9 );
if ($to_file) {
$res = ImagePNG($im, $filename, $quality);
}
else {
header("Content-type: image/png");
$res = ImagePNG($im, NULL, $quality);
}
}
else {
if ($to_file) {
$res = ImagePNG($im, $filename);
}
else {
header("Content-type: image/png");
$res = ImagePNG($im);
}
}
break;
}
return $res;
}
function ImageCreateFromType($type,$filename) {
$im = null;
switch ($type) {
case 1:
$im = ImageCreateFromGif($filename);
break;
case 2:
$im = ImageCreateFromJpeg($filename);
break;
case 3:
$im = ImageCreateFromPNG($filename);
break;
}
return $im;
}
// generate thumb from image and save it
function GenerateThumbFile($from_name, $to_name, $max_x, $max_y) {
global $save_to_file, $image_type, $image_quality;
// if src is URL then download file first
$temp = false;
if (substr($from_name,0,7) == 'http://') {
$tmpfname = tempnam("tmp/", "TmP-");
$temp = @fopen($tmpfname, "w");
if ($temp) {
@fwrite($temp, @file_get_contents($from_name)) or die("Cannot download image");
@fclose($temp);
$from_name = $tmpfname;
}
else {
die("Cannot create temp file");
}
}
// get source image size (width/height/type)
// orig_img_type 1 = GIF, 2 = JPG, 3 = PNG
list($orig_x, $orig_y, $orig_img_type, $img_sizes) = @GetImageSize($from_name);
// should we override thumb image type?
$image_type = ($image_type != -1 ? $image_type : $orig_img_type);
// check for allowed image types
if ($orig_img_type < 1 or $orig_img_type > 3) {
if(is_file($from_name)) {
@unlink($from_name);
} else if(is_dir($from_name)) {
@rm_recursive($from_name);
}
return false;
}
if ($orig_x > $max_x or $orig_y > $max_y) {
// resize
$per_x = $orig_x / $max_x;
$per_y = $orig_y / $max_y;
if ($per_y > $per_x) {
$max_x = $orig_x / $per_y;
}
else {
$max_y = $orig_y / $per_x;
}
}
else {
// keep original sizes, i.e. just copy
if ($save_to_file) {
@copy($from_name, $to_name);
}
else {
switch ($image_type) {
case 1:
header("Content-type: image/gif");
readfile($from_name);
break;
case 2:
header("Content-type: image/jpeg");
readfile($from_name);
break;
case 3:
header("Content-type: image/png");
readfile($from_name);
break;
}
}
return;
}
if ($image_type == 1) {
// should use this function for gifs (gifs are palette images)
$ni = imagecreate($max_x, $max_y);
}
else {
// Create a new true color image
$ni = ImageCreateTrueColor($max_x,$max_y);
}
// Fill image with white background (255,255,255)
$white = imagecolorallocate($ni, 255, 255, 255);
imagefilledrectangle( $ni, 0, 0, $max_x, $max_y, $white);
// Create a new image from source file
$im = ImageCreateFromType($orig_img_type,$from_name);
// Copy the palette from one image to another
imagepalettecopy($ni,$im);
// Copy and resize part of an image with resampling
imagecopyresampled(
$ni, $im, // destination, source
0, 0, 0, 0, // dstX, dstY, srcX, srcY
$max_x, $max_y, // dstW, dstH
$orig_x, $orig_y); // srcW, srcH
// save thumb file
SaveImage($image_type, $ni, $to_name, $image_quality, $save_to_file);
if($temp) {
unlink($tmpfname); // this removes the file
}
}
?>