Example #1
0
if ($row['jr_pj'] == null) {
    ini_set('zlib.output_compression', 'Off');
    header("Pragma: public");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: must-revalidate");
    header('Content-type: ' . 'text/plain');
    header('Content-Disposition: attachment;filename=vide.txt', FALSE);
    header("Accept-Ranges: bytes");
    echo "******************";
    echo _("Fichier effacé");
    echo "******************";
    exit;
}
$tmp = tempnam($_ENV['TMP'], 'document_');
$cn->lo_export($row['jr_pj'], $tmp);
ini_set('zlib.output_compression', 'Off');
header("Pragma: public");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate");
header('Content-type: ' . $row['jr_pj_type']);
header('Content-Disposition: attachment;filename="' . $row['jr_pj_name'] . '"', FALSE);
header("Accept-Ranges: bytes");
$file = fopen($tmp, 'r');
while (!feof($file)) {
    echo fread($file, 8192);
}
fclose($file);
unlink($tmp);
$cn->commit();
$g_user = new User($cn);
$g_user->Check();
set_language();
if ($g_user->check_module("CFGDOC") == 0) {
    exit;
}
// retrieve the document
$r = $cn->exec_sql("select md_id,md_lob,md_filename,md_mimetype\n                 from document_modele where md_id=\$1", array($_REQUEST['md_id']));
if (Database::num_row($r) == 0) {
    echo_error("Invalid Document");
    exit;
}
$row = Database::fetch_array($r, 0);
$cn->start();
$tmp = tempnam($_ENV['TMP'], 'document_');
$cn->lo_export($row['md_lob'], $tmp);
ini_set('zlib.output_compression', 'Off');
header("Pragma: public");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate");
header('Content-type: ' . $row['md_mimetype']);
header('Content-Disposition: attachment;filename="' . $row['md_filename'] . '"', FALSE);
header("Accept-Ranges: bytes");
$file = fopen($tmp, 'r');
while (!feof($file)) {
    echo fread($file, 8192);
}
fclose($file);
unlink($tmp);
$cn->commit();