noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
show_document_modele.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 send the document template
00023  */
00024 require_once '../include/constant.php';
00025 require_once('class_database.php');
00026 require_once("ac_common.php");
00027 
00028 require_once('class_dossier.php');
00029 $gDossier=dossier::id();
00030 $cn=new Database($gDossier);
00031 
00032 
00033 require_once ('class_user.php');
00034 global $g_user;
00035 $g_user=new User($cn);
00036 $g_user->Check();
00037 if ( $g_user->check_module("CFGDOC") == 0 ) exit();
00038 // retrieve the document
00039 $r=$cn->exec_sql("select md_id,md_lob,md_filename,md_mimetype
00040                  from document_modele where md_id=$1",array($_REQUEST['md_id']));
00041 if ( Database::num_row($r) == 0 )
00042 {
00043     echo_error("Invalid Document");
00044     exit;
00045 }
00046 $row=Database::fetch_array($r,0);
00047 
00048 
00049 $cn->start();
00050 
00051 $tmp=tempnam($_ENV['TMP'],'document_');
00052 $cn->lo_export($row['md_lob'],$tmp);
00053 ini_set('zlib.output_compression','Off');
00054 header("Pragma: public");
00055 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
00056 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
00057 header("Cache-Control: must-revalidate");
00058 header('Content-type: '.$row['md_mimetype']);
00059 header('Content-Disposition: attachment;filename="'.$row['md_filename'].'"',FALSE);
00060 header("Accept-Ranges: bytes");
00061 $file=fopen($tmp,'r');
00062 while ( !feof ($file) )
00063     echo fread($file,8192);
00064 
00065 fclose($file);
00066 
00067 unlink ($tmp);
00068 
00069 $cn->commit();
 All Data Structures Namespaces Files Functions Variables Enumerations