403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/(Del)gepgroup.hk/webadmin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)gepgroup.hk/webadmin//function_file_upload.php
<?php
function file_upload_closure_source(&$message, $attribute, $closure_source, $destination_dir, $file_name_func=NULL)
{
	$destination = NULL;
	
	if ($file_name_func === NULL)
	{
		$file_name_func = function($file_info)
		{
			return $file_info['filename'];
		};
	}
	
	$tmp_file_info = $_FILES[$attribute];
	
	if (is_uploaded_file($closure_source($tmp_file_info['tmp_name'])))
	{
		$destination = false;
		
		$is_valid = true;
		if (!file_exists($destination_dir))
		{
			$is_valid = mkdir($destination_dir, 0775, true);
			if (!$is_valid)
				$message = "Create directory fail.";
		}
		
		if ($is_valid)
		{
			//$file_name = $_FILES[$attribute]['name'];
			
			$file_info = pathinfo($closure_source($tmp_file_info['name']));
			
			//$dirname = $file_info['dirname'];
			//$basename = $file_info['basename'];
			//$extension = $file_info['extension'];
			//$filename = $file_info['filename'];
			
			$file_name = $file_name_func($file_info);
			$file_destination = "$destination_dir/$file_name";
			
			// If no Permission, that means temp file need linux root account, then use following code
			//if (!copy($_FILES[$attribute]['tmp_name'], $file_destination))
			//	$message = 'Could not copy file: ' . $file_name;
			
			if (move_uploaded_file($closure_source($tmp_file_info['tmp_name']), $file_destination))
				$destination = $file_destination;
			else
			{
				$upload_errors = array(
					UPLOAD_ERR_OK => "No errors.",
					UPLOAD_ERR_INI_SIZE => "Larger than upload_max_filesize.",
					UPLOAD_ERR_FORM_SIZE => "Larger than form MAX_FILE_SIZE.",
					UPLOAD_ERR_PARTIAL => "Partial upload.",
					UPLOAD_ERR_NO_FILE => "No file.",
					UPLOAD_ERR_NO_TMP_DIR => "No temporary directory.",
					UPLOAD_ERR_CANT_WRITE => "Can't write to disk.",
					UPLOAD_ERR_EXTENSION => "File upload stopped by extension.",
					UPLOAD_ERR_EMPTY => "File is empty." // add this to avoid an offset
				); 
				$message = $upload_errors[$closure_source($tmp_file_info['error'])];
			}
		}
	}
	
	return $destination;
}

function file_upload(&$message, $attribute, $destination_dir, $file_name_func=NULL)
{
	return file_upload_closure_source($message, $attribute,
		function($tmp_file_info) {
			return $tmp_file_info;
		}, $destination_dir, $file_name_func);
}

function image_upload_closure_source(&$message, $attribute, $closure_source, $destination_dir, $file_name_func=NULL, $types=NULL)
{
	$destination = NULL;
	$is_input_types_empty = $types === NULL;
	
	if ($is_input_types_empty)
	{
		$types = array(
			"image/bmp",
			"image/BMP",
			"image/gif",
			"image/GIF",
			"image/jpg",
			"image/JPG",
			"image/jpeg",
			"image/JPEG",
			"image/pjpeg",
			"image/PJEG",
			"image/png",
			"image/x-png",
			"image/PNG",
			"image/X-PNG",
		);
	}
	
	$tmp_file_info = $_FILES[$attribute];
	if (is_uploaded_file($closure_source($tmp_file_info['tmp_name'])))
	{
		$destination = false;
		if (in_array($closure_source($tmp_file_info['type']), $types))
			$destination = file_upload_closure_source($message, $attribute, $closure_source, $destination_dir, $file_name_func, $types);
		elseif ($is_input_types_empty)
			$message = "Files must be BMP, JPEG, GIF, or PNG";
		else
			$message = "File type not supported";
	}
	
	return $destination;
}

function image_upload(&$message, $attribute, $destination_dir, $file_name_func=NULL, $types=NULL)
{
	return image_upload_closure_source($message, $attribute,
		function($tmp_file_info) {
			return $tmp_file_info;
		}, $destination_dir, $file_name_func, $types);
}
?>

Youez - 2016 - github.com/yon3zu
LinuXploit