noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
show_pj.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS 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  *   NOALYSS 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 NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 // Verify parameters
00021 /*!\file
00022  * \brief show an attach of an operation
00023  */
00024 require_once '../include/constant.php';
00025 include_once ("ac_common.php");
00026 require_once('class_dossier.php');
00027 $gDossier=dossier::id();
00028 
00029 if ( !isset ($_GET['jrn'] ) ||
00030         !isset($_GET['jr_grpt_id']))
00031 {
00032     echo_error("Missing parameters");
00033 }
00034 
00035 require_once('class_database.php');
00036 
00037 
00038 $jr_grpt_id=$_GET['jr_grpt_id'];
00039 
00040 $cn=new Database($gDossier);
00041 
00042 
00043 include_once ('class_user.php');
00044 global $g_user;
00045 $g_user=new User($cn);
00046 $g_user->Check();
00047 $g_user->check_dossier($gDossier);
00048 
00049 // retrieve the jrn
00050 $r=$cn->exec_sql("select jr_def_id from jrn where jr_grpt_id=$jr_grpt_id");
00051 if ( Database::num_row($r) == 0 )
00052 {
00053     echo_error("Invalid operation id jr_grpt_id=$jr_grpt_id");
00054     exit;
00055 }
00056 $a=Database::fetch_array($r,0);
00057 $jrn=$a['jr_def_id'];
00058 
00059 if ($g_user->check_jrn($jrn) == 'X' )
00060 {
00061     /* Cannot Access */
00062     NoAccess();
00063     exit -1;
00064 }
00065 
00066 $cn->start();
00067 $ret=$cn->exec_sql("select jr_pj,jr_pj_name,jr_pj_type from jrn where jr_grpt_id=$jr_grpt_id");
00068 if ( Database::num_row ($ret) == 0 )
00069     return;
00070 $row=Database::fetch_array($ret,0);
00071 if ( $row['jr_pj']==null )
00072 {
00073     ini_set('zlib.output_compression','Off');
00074     header("Pragma: public");
00075     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00076     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00077     header("Cache-Control: must-revalidate");
00078     header('Content-type: '.'text/plain');
00079     header('Content-Disposition: attachment;filename=vide.txt',FALSE);
00080     header("Accept-Ranges: bytes");
00081     echo "******************";
00082     echo _("Fichier effacé");
00083     echo "******************";
00084     exit();
00085 }
00086 $tmp=tempnam($_ENV['TMP'],'document_');
00087 
00088 $cn->lo_export($row['jr_pj'],$tmp);
00089 
00090 ini_set('zlib.output_compression','Off');
00091 header("Pragma: public");
00092 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00093 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00094 header("Cache-Control: must-revalidate");
00095 header('Content-type: '.$row['jr_pj_type']);
00096 header('Content-Disposition: attachment;filename="'.$row['jr_pj_name'].'"',FALSE);
00097 header("Accept-Ranges: bytes");
00098 $file=fopen($tmp,'r');
00099 while ( !feof ($file) )
00100     echo fread($file,8192);
00101 
00102 fclose($file);
00103 
00104 unlink ($tmp);
00105 
00106 $cn->commit();
 All Data Structures Namespaces Files Functions Variables Enumerations