2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2017-05-30 09:59:09 -04:00
|
|
|
$RBAC->allows(basename(__FILE__), 'downloadFileHash');
|
2012-10-17 12:03:40 -04:00
|
|
|
|
2016-08-30 13:33:46 -04:00
|
|
|
if (!isset($_GET["file_hash"])) {
|
2014-03-06 12:39:16 -04:00
|
|
|
throw new Exception("Invalid Request, param 'file_hash' was not sent.");
|
|
|
|
|
}
|
2012-10-17 12:03:40 -04:00
|
|
|
|
2014-03-06 12:39:16 -04:00
|
|
|
$httpStream = new \ProcessMaker\Util\IO\HttpStream();
|
|
|
|
|
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
|
2017-05-24 15:19:33 -04:00
|
|
|
$fileName = urldecode(base64_decode($_GET["file_hash"]));
|
|
|
|
|
$processFile = $outputDir . $fileName;
|
2012-10-17 12:03:40 -04:00
|
|
|
|
2017-05-24 15:19:33 -04:00
|
|
|
//Verify if the file related to process exist in the corresponding path
|
|
|
|
|
$fileInformation = pathinfo($processFile);
|
|
|
|
|
$processFile = $outputDir . $fileInformation['basename'];
|
|
|
|
|
if (!file_exists($processFile)) {
|
|
|
|
|
throw new Exception("Error, couldn't find request file: $fileName");
|
2012-10-17 12:03:40 -04:00
|
|
|
}
|
2017-05-24 15:19:33 -04:00
|
|
|
$fileExtension = $fileInformation['extension'];
|
|
|
|
|
$httpStream->loadFromFile($processFile);
|
2014-03-06 12:39:16 -04:00
|
|
|
$httpStream->setHeader("Content-Type", "application/$fileExtension");
|
|
|
|
|
$httpStream->send();
|