00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026 include_once ("postgres.php");
00027 require_once("ac_common.php");
00028
00029
00030 $cn=DbConnect($_SESSION['g_dossier']);
00031
00032
00033 include ('class_user.php');
00034 $User=new cl_user(DbConnect());
00037 $User->Check();
00038
00039 $r=ExecSql($cn,"select md_id,md_lob,md_filename,md_mimetype
00040 from document_modele where md_id=".$_REQUEST['md_id']);
00041 if ( pg_num_rows($r) == 0 ) {
00042 echo_error("Invalid Document");
00043 exit;
00044 }
00045 $row=pg_fetch_array($r,0);
00046
00047
00048 StartSql($cn);
00049
00050 $tmp=tempnam('/tmp/','document_');
00051 pg_lo_export($cn,$row['md_lob'],$tmp);
00052 ini_set('zlib.output_compression','Off');
00053 header("Pragma: public");
00054 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00055 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00056 header("Cache-Control: must-revalidate");
00057 header('Content-type: '.$row['md_mimetype']);
00058 header('Content-Disposition: attachment;filename="'.$row['md_filename'].'"',FALSE);
00059 header("Accept-Ranges: bytes");
00060 $file=fopen($tmp,'r');
00061 while ( !feof ($file) )
00062 echo fread($file,8192);
00063
00064 fclose($file);
00065
00066 unlink ($tmp);
00067
00068 Commit($cn);