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 if ( isNumber($jr_grpt_id) != 1 ) die (_('Données invalides'));
00049 
00050 // retrieve the jrn
00051 $r=$cn->exec_sql("select jr_def_id from jrn where jr_grpt_id=$jr_grpt_id");
00052 if ( Database::num_row($r) == 0 )
00053 {
00054     echo_error("Invalid operation id jr_grpt_id=$jr_grpt_id");
00055     exit;
00056 }
00057 $a=Database::fetch_array($r,0);
00058 $jrn=$a['jr_def_id'];
00059 
00060 if ($g_user->check_jrn($jrn) == 'X' )
00061 {
00062     /* Cannot Access */
00063     NoAccess();
00064     exit -1;
00065 }
00066 
00067 $cn->start();
00068 $ret=$cn->exec_sql("select jr_pj,jr_pj_name,jr_pj_type from jrn where jr_grpt_id=$jr_grpt_id");
00069 if ( Database::num_row ($ret) == 0 )
00070     return;
00071 $row=Database::fetch_array($ret,0);
00072 if ( $row['jr_pj']==null )
00073 {
00074     ini_set('zlib.output_compression','Off');
00075     header("Pragma: public");
00076     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00077     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00078     header("Cache-Control: must-revalidate");
00079     header('Content-type: '.'text/plain');
00080     header('Content-Disposition: attachment;filename=vide.txt',FALSE);
00081     header("Accept-Ranges: bytes");
00082     echo "******************";
00083     echo _("Fichier effacé");
00084     echo "******************";
00085     exit();
00086 }
00087 $tmp=tempnam($_ENV['TMP'],'document_');
00088 
00089 $cn->lo_export($row['jr_pj'],$tmp);
00090 
00091 ini_set('zlib.output_compression','Off');
00092 header("Pragma: public");
00093 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00094 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00095 header("Cache-Control: must-revalidate");
00096 header('Content-type: '.$row['jr_pj_type']);
00097 header('Content-Disposition: attachment;filename="'.$row['jr_pj_name'].'"',FALSE);
00098 header("Accept-Ranges: bytes");
00099 $file=fopen($tmp,'r');
00100 while ( !feof ($file) )
00101     echo fread($file,8192);
00102 
00103 fclose($file);
00104 
00105 unlink ($tmp);
00106 
00107 $cn->commit();
 All Data Structures Namespaces Files Functions Variables Enumerations