Exemple #1
0
function download_faxFile()
{
    $oFax = new paloFaxVisor();
    $idFax = getParameter("id");
    $arrFax = $oFax->obtener_fax($idFax);
    $dir_backup = "/var/www/faxes";
    $file_path = $arrFax['faxpath'] . "/fax.pdf";
    $file_name = $arrFax['pdf_file'];
    if (!file_exists("{$dir_backup}/{$file_path}")) {
        header('HTTP/1.1 404 Not Found');
        return "File {$file_path} not found!";
    } else {
        header("Cache-Control: private");
        header("Pragma: cache");
        header('Content-Type: application/pdf');
        header("Content-Length: " . filesize("{$dir_backup}/{$file_path}"));
        header("Content-disposition: attachment; filename={$file_name}");
        readfile("{$dir_backup}/{$file_path}");
    }
}
function download_faxFile($pDB, $credentials)
{
    $pACL = new paloACL($pDB);
    $oFax = new paloFaxVisor($pDB);
    $idFax = getParameter("id");
    $arrFax = $oFax->obtener_fax($idFax);
    if ($arrFax == false) {
        header('HTTP/1.1 404 Not Found');
        return "File {$file_path} not found!";
    }
    $dir_backup = "/var/www/elastixdir/faxdocs";
    $file_path = $arrFax['faxpath'] . "/fax.pdf";
    $file_name = $arrFax['pdf_file'];
    if ($credentials['userlevel'] != 'superadmin') {
        if (!$pACL->userBellowOrganization($arrFax["id_user"], $credentials['id_organization'])) {
            header('HTTP/1.1 404 Not Found');
            return "File {$file_path} not found!";
        }
    }
    if (!file_exists("{$dir_backup}/{$file_path}")) {
        header('HTTP/1.1 404 Not Found');
        return "File {$file_path} not found!";
    } else {
        header("Cache-Control: private");
        header("Pragma: cache");
        header('Content-Type: application/pdf');
        header("Content-Length: " . filesize("{$dir_backup}/{$file_path}"));
        header("Content-disposition: attachment; filename={$file_name}");
        readfile("{$dir_backup}/{$file_path}");
    }
}