HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/OneDrive/Desktop/wordpress/wp-content/pluginsBK/myeasybackup/meb_download.php
<?php
/**
 * Download a data set
 *
 * @package myEASYbackup
 * @author Ugo Grandolini
 * @version 0.0.5
 */

#
#	0.0.3: BEG
#-------------
/*
var_dump($_SERVER);

	["HTTP_REFERER"]=>string(71) "http://example.com/.../..."
	["HTTP_HOST"]=>   string(7) "example.com"
	["SERVER_NAME"]=> string(7) "example.com"

	["SERVER_ADDR"]=> string(9) "127.0.0.1"
	["REMOTE_ADDR"]=> string(9) "127.0.0.1"
*/

$tmp = explode('://', $_SERVER['HTTP_REFERER']);
$path = explode('/', $tmp[1]);
$referer = $path[0];

if(	($_SERVER['HTTP_HOST'] != $_SERVER['SERVER_NAME'])
		||
	($_SERVER['HTTP_HOST'] != $referer)
		||
	($_SERVER['SERVER_NAME'] != $referer) )
{

//echo 'HTTP_HOST:'.$_SERVER['HTTP_HOST'].'!='.'SERVER_NAME:'.$_SERVER['SERVER_NAME'].'<br>'
//	.'HTTP_HOST:'.$_SERVER['HTTP_HOST'].'!=referer:'.$referer.'<br>'
//	.'SERVER_NAME:'.$_SERVER['SERVER_NAME'].'!=referer:'.$referer.'<br>'
//	.'HTTP_REFERER:'.$_SERVER['HTTP_REFERER']
//;

	echo 'Nice try, you cheeky monkey!';	#	0.0.5
	return;
}
#-------------
#	0.0.3: END
#

define('MEBAK_ISDOWNLOAD', true);
require_once('meb-config.php');

//$file_name = $_GET['dwnfile'];	#	0.0.5
$file_name = $_POST['dwn_file'];	#	0.0.5

$file = MEBAK_BACKUP_PATH . '/' . $file_name;

if(file_exists($file))
{
	$bytes = filesize($file);

	header('Pragma: public');
	header('Expires: 0');
	header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	header('Cache-Control: private',false);
	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
	header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

	//header('Content-Type: application/x-download');		#	0.0.5: IE fix
	header('Content-Type: application/zip');				#	0.0.5: IE fix
	header('Content-Type: application/force-download');		#	0.0.5: IE fix

	header('Content-Transfer-Encoding: binary');
	header('Content-Length: '.(string) $bytes);
	header('Content-Disposition: attachment; filename="'.$file_name.'"');

	#
	#	start the download
	#
	//set_time_limit(0);			#	0.0.4: moved to meb-config.php
	readfile($file);
}

?>