Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once '../include/constant.php';
00025 require_once('class_database.php');
00026 require_once("ac_common.php");
00027
00028 require_once('class_dossier.php');
00029 $gDossier=dossier::id();
00030 $cn=new Database($gDossier);
00031
00032
00033 require_once ('class_user.php');
00034 global $g_user;
00035 $g_user=new User($cn);
00036 $g_user->Check();
00037 if ( $g_user->check_module("CFGDOC") == 0 ) exit();
00038
00039 $r=$cn->exec_sql("select md_id,md_lob,md_filename,md_mimetype
00040 from document_modele where md_id=$1",array($_REQUEST['md_id']));
00041 if ( Database::num_row($r) == 0 )
00042 {
00043 echo_error("Invalid Document");
00044 exit;
00045 }
00046 $row=Database::fetch_array($r,0);
00047
00048
00049 $cn->start();
00050
00051 $tmp=tempnam($_ENV['TMP'],'document_');
00052 $cn->lo_export($row['md_lob'],$tmp);
00053 ini_set('zlib.output_compression','Off');
00054 header("Pragma: public");
00055 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00056 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00057 header("Cache-Control: must-revalidate");
00058 header('Content-type: '.$row['md_mimetype']);
00059 header('Content-Disposition: attachment;filename="'.$row['md_filename'].'"',FALSE);
00060 header("Accept-Ranges: bytes");
00061 $file=fopen($tmp,'r');
00062 while ( !feof ($file) )
00063 echo fread($file,8192);
00064
00065 fclose($file);
00066
00067 unlink ($tmp);
00068
00069 $cn->commit();