Files
luos/workflow/engine/methods/processes/processes_GetFile.php

41 lines
1.2 KiB
PHP
Raw Normal View History

<?php
global $RBAC;
$RBAC->allows(basename(__FILE__), $_GET['MAIN_DIRECTORY']);
$mainDirectory = !empty($_GET['MAIN_DIRECTORY']) ? $_GET['MAIN_DIRECTORY'] : '';
$proUid = !empty($_GET['PRO_UID']) ? $_GET['PRO_UID'] : '';
2019-01-16 12:21:17 -04:00
$currentDirectory = !empty($_GET['CURRENT_DIRECTORY']) ? $_GET['CURRENT_DIRECTORY'] . PATH_SEP : '';
$file = !empty($_GET['FILE']) ? $_GET['FILE'] : '';
$extension = (!empty($_GET['sFilextension']) && $_GET['sFilextension'] === 'javascript') ? '.js' : '';
2019-01-16 12:21:17 -04:00
// Validate the main directory
switch ($mainDirectory) {
case 'mailTemplates':
$directory = PATH_DATA_MAILTEMPLATES;
break;
case 'public':
$directory = PATH_DATA_PUBLIC;
break;
default:
die();
break;
}
2019-01-16 12:21:17 -04:00
// Validate if process exists, an exception is throwed if not exists
$process = new Process();
$process->load($proUid);
// Validate directory and file requested
$filter = new InputFilter();
$currentDirectory = $filter->validatePath($currentDirectory);
$file = $filter->validatePath($file);
// Build requested path
2017-10-11 13:26:34 -04:00
$directory .= $proUid . PATH_SEP . $currentDirectory;
$file .= $extension;
2019-01-16 12:21:17 -04:00
// Stream the file if path exists
if (file_exists($directory . $file)) {
G::streamFile($directory . $file, true);
}