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

show_pj.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
00022 include_once ("ac_common.php");
00023 if ( !isset ($_GET['jrn'] ) ||
00024      !isset($_GET['jr_grpt_id'])) {
00025         echo_error("Missing parameters");
00026 }
00027 
00028 include_once ("postgres.php");
00029 
00030 
00031 $jr_grpt_id=$_GET['jr_grpt_id'];
00032 
00033 $cn=DbConnect($_SESSION['g_dossier']);
00034 
00035 
00036 include ('class_user.php');
00037 $User=new cl_user(DbConnect());
00038 $User->Check();
00039 // retrieve the jrn
00040 $r=ExecSql($cn,"select jr_def_id from jrn where jr_grpt_id=$jr_grpt_id");
00041 if ( pg_num_rows($r) == 0 ) {
00042   echo_error("Invalid operation id jr_grpt_id=$jr_grpt_id");
00043   exit;
00044  }
00045 $a=pg_fetch_array($r,0);
00046 $jrn=$a['jr_def_id'];
00047 
00048 if ($User->AccessJrn($cn,$jrn) == false ){
00049   /* Cannot Access */
00050   NoAccess();
00051   exit -1;
00052  }
00053 
00054 StartSql($cn);
00055 $ret=ExecSql($cn,"select jr_pj,jr_pj_name,jr_pj_type from jrn where jr_grpt_id=$jr_grpt_id");
00056 if ( pg_num_rows ($ret) == 0 )
00057         return;
00058 $row=pg_fetch_array($ret,0);
00059 $tmp=tempnam('/tmp/','document_');
00060 pg_lo_export($cn,$row['jr_pj'],$tmp);
00061 ini_set('zlib.output_compression','Off');
00062 header("Pragma: public");
00063 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00064 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00065 header("Cache-Control: must-revalidate");
00066 header('Content-type: '.$row['jr_pj_type']);
00067 header('Content-Disposition: attachment;filename="'.$row['jr_pj_name'].'"',FALSE);
00068 header("Accept-Ranges: bytes");
00069 $file=fopen($tmp,'r');
00070 while ( !feof ($file) )
00071         echo fread($file,8192);
00072 
00073 fclose($file);
00074 
00075 unlink ($tmp);
00076 
00077 Commit($cn);