Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

show_document_modele.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 1.1 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 // Verify parameters
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 // retrieve the document
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);