MOON
Server: Apache
System: Linux ip-208-109-13-31.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els4.x86_64 #1 SMP Sat Aug 31 06:58:57 UTC 2024 x86_64
User: durgeshpandey215 (1013)
PHP: 8.1.29
Disabled: NONE
Upload Files
File: /home/durgeshpandey215/public_html/zeeroprice.skilladders.com/upload.php
<? require_once "application_top.php";
//input type file name should be "pic"
//For uploading file we need needThumb,PathThumb,needOriginal,pathOriginal.
$msg = "";
$picName = date("dnHs"); //to add before filename
$needThumb = $needThumb;
$pathThumb = $pathThumb; 
$needOriginal = $needOriginal;
$pathOriginal = $pathOriginal;
if(!function_exists('getExtension')){
function getExtension($str){
	return pathinfo($str, PATHINFO_EXTENSION);
}
}

if(!function_exists('printwatermark')){
function printwatermark($im, $width, $height){
	$image = $im;
	//$imageSize = getimagesize($im);
	
	$watermark = imagecreatefrompng(HTTP_SERVER.'images/watermark.png');

	$watermark_o_width = imagesx($watermark);
	$watermark_o_height = imagesy($watermark);

	$newWatermarkWidth = ($width > 300)? $width/4 : $width/2.5;
	$newWatermarkHeight = $watermark_o_height * $newWatermarkWidth / $watermark_o_width;

	imagecopyresized($image, $watermark, $width - $newWatermarkWidth - 30, $height - $newWatermarkHeight - 30, 0, 0, $newWatermarkWidth, $newWatermarkHeight, imagesx($watermark), imagesy($watermark));
	//Center vertically & horizontly ----- 	imagecopyresized($image, $watermark, $width/2 - $newWatermarkWidth/2, $height/2 - $newWatermarkHeight/2, 0, 0, $newWatermarkWidth, $newWatermarkHeight, imagesx($watermark), imagesy($watermark));
}
}
	$pic = "";
	if($Files_pic_name != ""){
		$filename = stripslashes($Files_pic_name);
		$explodefilename = explode(".",$filename);
		$extension = getExtension($filename);
		$pic = truncate(str_replace(" ","",$explodefilename[0]),'8','') ."-".$picName.".".$extension;
	}else{
		$msg .= "No file to Upload ";
	}
	if(!defined('MAX_SIZE')){
		define ("MAX_SIZE","100000");
	}
	$errors=0;
	$image = $Files_pic_name;
	$uploadedfile = $Files_pic_temp_name;	
	
		//Following function to change the orientation of pics 
		if(!function_exists('adjustPicOrientation')){
		function adjustPicOrientation($full_filename){      
			
			return $full_filename;
		}
		}
		if($uploadedfile){
		$uploadedfile = adjustPicOrientation($uploadedfile);				
		}
	
	if($image)
	{
		$extension = strtolower($extension);
		if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
		{
			$msg .= ' Not a valid image format ';
			$pic="";
			$errors=1;
		}
		else
		{
			$size=filesize($Files_pic_temp_name);

			if ($size > MAX_SIZE*1024)
			{
				$msg .= "You have exceeded the size limit";
				$errors=1;
			}
			
			if(!$errors){
				
				if($extension=="jpg" || $extension=="jpeg" )
				{
				$src = imagecreatefromjpeg($uploadedfile);
				}
				else if($extension=="png")
				{
				$src = imagecreatefrompng($uploadedfile);
				}
				else 
				{
				$src = imagecreatefromgif($uploadedfile);
				}
				
					
				list($width,$height)=getimagesize($uploadedfile);
				
				//printwatermark($src, $width, $height);
				
				if($needThumb){
					$newwidth=300;
					$newheight=($height/$width)*$newwidth;
					$tmp=imagecreatetruecolor($newwidth,$newheight);
					imagealphablending( $tmp, false );
					imagesavealpha( $tmp, true );					
					imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
					
					$uploadpath = $pathThumb . $pic;
					imagepng($tmp,$uploadpath,9);
				}
				
				if($needOriginal){
					if($width<='500'){
						$newwidth=$width;
					}else{
						$newwidth=500;
					}
					
					$newheight=($height/$width)*$newwidth;
					if($newheight>='500'){
						$newheight =500;
						$newwidth=($width/$height)*$newheight;
					}
					
					$tmp=imagecreatetruecolor($newwidth,$newheight);
					imagealphablending( $tmp, false );
					imagesavealpha( $tmp, true );					
					imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
					
					$uploadpath = $pathOriginal . $pic;
					imagepng($tmp,$uploadpath,9);
				}
				
				$result = 1;
				
				imagedestroy($src);
				imagedestroy($tmp);
				
				$msg = "Image uploaded successfully";
			}
		}
	}
	$_SESSION['msg'] =  $msg; 
sleep(1);
?>