MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/www/fl.machen.ai/test.php
<?php
header('Access-Control-Allow-Origin: *');;
ini_set('display_errors', 1);

$ch = curl_init();

$realFileName = str_replace("||MCH-ECOM||", "&", $_GET["arq"]);
$realName = str_replace("||MCH-ECOM||", "&", $_GET["name"]);


$fileId = curl_escape($ch, $realFileName);
$fileName = curl_escape($ch, $realName);

if (urlencode(urldecode($_GET["arq"])) === $_GET["arq"]){
    //echo 'string urlencoded'.$_GET["arq"];
} else {
    //echo 'string is NOT urlencoded'.$_GET["arq"];
}

$url =  "https://machen.azureedge.net/".$fileId;



curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$res = curl_exec($ch);
$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 



if($rescode === 404){
	$url =  "https://machen.azureedge.net/".urlencode($fileId);
	//print_r($url);
	//exit;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	$res = curl_exec($ch);
	$rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
}

curl_close($ch) ;

$newFileName=str_replace(",", "_", $fileName);
$newFileName=str_replace(" ", "_", $newFileName);

$contentType='application/octet-stream';
if(strpos($fileId, ".pdf")>-1){
    $contentType='application/pdf';
}


// header('Content-Description: File Transfer');
// header('Content-Type: '.$contentType);
header("Content-Disposition: attachment; filename=\"".$realName."\"");
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header("Etag: $fileId.$newFileName"); 
header('Cache-Control: must-revalidate');
header('Pragma: public');

echo $res
?>