Al-HUWAITI Shell
Al-huwaiti


Server : LiteSpeed
System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64
User : u615232177 ( 615232177)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /home/u615232177/domains/adesmiley.com/public_html/admin41345/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/u615232177/domains/adesmiley.com/public_html/admin41345/upload_image.php
<?php 
//make a directory where advert pictures will be 
/*
if (!file_exists("../product_images/")) {
    mkdir("../product_images/", 0777, true);
}
*/

// SOURCE + DESTINATION
$source = $_FILES["file"]["tmp_name"];
//$destination = substr(md5(rand()), 0, 11);
$destination = $_FILES["file"]["name"];
$error = "";

// CHECK IF FILE ALREADY EXIST
/*
if (file_exists($destination)) {
  $error = $destination . " already exist.";
  $_SESSION["action"] = "true";
		$message="File already exists.";
		echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=$page_name&m=$message\">";
		$errors = 1;
		exit();
}
*/

// ALLOWED FILE EXTENSIONS
if ($error == "") {
  $allowed = ["jpg", "jpeg", "png", "gif"];
  $ext = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));
  if (!in_array($ext, $allowed)) {
    $error = "$ext file type not allowed - " . $_FILES["file"]["name"];
	$_SESSION["action"] = "true";
		$message="This file type is not allowed. Only jpg, png or gif please.";
		//echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=$page_name&m=$message\">";
		$errors = 1;
		exit();
  }
}

// LEGIT IMAGE FILE CHECK
if ($error == "") {
  if (getimagesize($_FILES["file"]["tmp_name"]) == false) {
    $error = $_FILES["file"]["name"] . " is not a valid image file.";
	$_SESSION["action"] = "true";
		$message="This file is not a valid image file.";
		echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=$page_name&m=$message\">";
		$errors = 1;
		exit();
  }
}


// FILE SIZE CHECK
if ($error == "") {
  // 1,000,000 = 1MB
  if ($_FILES["file"]["size"] > 5000000) {
    $error = $_FILES["file"]["name"] . " - file size too big!";
	$_SESSION["action"] = "true";
		$message="Maximum file size allowed is 5mb.";
		echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=$page_name&m=$message\">";
		$errors = 1;
		exit();
  }
}

// ALL CHECKS OK - MOVE FILE
if ($error == "") {
	
  if (!move_uploaded_file( $_FILES['file']['tmp_name'], "assets/img/gallery/$destination") ) {
    $error = "Error moving $source to $destination";
  }
}

//-----------------cropping part of the script ---------------------------

//first check if its png or jpg or jpeg
$file_extension = strtolower(pathinfo($_FILES["file"]["name"], PATHINFO_EXTENSION));

//the image we want to use as water mark
$watermarkImagePath = 'assets/img/watermark.png';
$watermark_png_Img = imagecreatefrompng($watermarkImagePath); 

if ($file_extension == "png"){
	$new = imagecreatefrompng("assets/img/gallery/$destination");
    $crop_width = imagesx($new);
    $crop_height = imagesy($new);           
    $size = min($crop_width, $crop_height);
               
	if($crop_width >= $crop_height) {
		$newx= ($crop_width-$crop_height)/2;
		$im2 = imagecrop($new, ['x' => $newx, 'y' => 0, 'width' => $size, 'height' => $size]);
	}
	else {
		$newy= ($crop_height-$crop_width)/2;
		$im2 = imagecrop($new, ['x' => 0, 'y' => $newy, 'width' => $size, 'height' => $size]);
	}                
   
   // Set the margins for the watermark 
$marge_right = 10; 
$marge_bottom = 10; 
               
$water_width = imagesx($watermark_png_Img);
$water_height = imagesy($watermark_png_Img);
  
$dime_x = imagesx($im2) - imagesx($watermark_png_Img) - $marge_right;
$dime_y = imagesy($im2) - imagesy($watermark_png_Img) - $marge_bottom;
// Copy the watermark image onto our photo using the margin offsets and  
// the photo width to calculate the positioning of the watermark. 
imagecopy($im2, $watermark_png_Img, $dime_x ,$dime_y , 0, 0, $water_width, $water_height); 
                 
// Save image and free memory 
imagepng($im2, "assets/img/gallery/$destination"); 
imagedestroy($im2); 
}

if ($file_extension == "jpg" OR $file_extension =="jpeg"){
	$new = imagecreatefromjpeg("assets/img/gallery/$destination");
    $crop_width = imagesx($new);
    $crop_height = imagesy($new);       
    $size = min($crop_width, $crop_height);
               
	if($crop_width >= $crop_height) {
		$newx= ($crop_width-$crop_height)/2;
		$im2 = imagecrop($new, ['x' => $newx, 'y' => 0, 'width' => $size, 'height' => $size]);
	}
	else {
		$newy= ($crop_height-$crop_width)/2;
		$im2 = imagecrop($new, ['x' => 0, 'y' => $newy, 'width' => $size, 'height' => $size]);
	}   

// Set the margins for the watermark 
$marge_right = 10; 
$marge_bottom = 10; 
               
$water_width = imagesx($watermark_png_Img);
$water_height = imagesy($watermark_png_Img);
  
$dime_x = imagesx($im2) - imagesx($watermark_png_Img) - $marge_right;
$dime_y = imagesy($im2) - imagesy($watermark_png_Img) - $marge_bottom;
// Copy the watermark image onto our photo using the margin offsets and  
// the photo width to calculate the positioning of the watermark. 
imagecopy($im2, $watermark_png_Img, $dime_x ,$dime_y , 0, 0, $water_width, $water_height); 
                 
// Save image and free memory 
imagejpeg($im2, "assets/img/gallery/$destination"); 
imagedestroy($im2); 
	 
}
     
?>

Al-HUWAITI Shell