noalyss Version-9
export_document_template.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19// Copyright Author Dany De Bontridder danydb@aevalys.eu
20// Verify parameters
21/*! \file
22 * \brief send the document template
23 */
24require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
25
26if ( $g_user->check_module("CFGDOC") == 0 ) exit();
27// retrieve the document
28$r=$cn->exec_sql("select md_id,md_lob,md_filename,md_mimetype
29 from document_modele where md_id=$1",array($_REQUEST['md_id']));
30if ( Database::num_row($r) == 0 )
31{
32 echo_error("Invalid Document");
33 exit;
34}
36
37
38$cn->start();
39
40$tmp=tempnam($_ENV['TMP'],'document_');
41$cn->lo_export($row['md_lob'],$tmp);
42ini_set('zlib.output_compression','Off');
43header("Pragma: public");
44header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
45header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
46header("Cache-Control: must-revalidate");
47header('Content-type: '.$row['md_mimetype']);
48header('Content-Disposition: attachment;filename="'.$row['md_filename'].'"',FALSE);
49header("Accept-Ranges: bytes");
50$file=fopen($tmp,'r');
51while ( !feof ($file) )
52 echo fread($file,8192);
53
54fclose($file);
55
56unlink ($tmp);
57
58$cn->commit();
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
Definition: ac_common.php:169
global $g_user
if no group available , then stop
$_REQUEST['ac']
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
if(Database::num_row($r)==0) $row
for($e=0; $e< count($afiche); $e++) exit