noalyss Version-9
export_receipt.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 show an attach of an operation
23 */
24if ( ! defined ('ALLOWED')) die (_('Non autorisé'));
25
26include_once NOALYSS_INCLUDE.'/lib/ac_common.php';
28
29try
30{
31 $jr_id=$http->get('jr_id',"number");
32}
33catch (Exception $exc)
34{
35 error_log($exc->getTraceAsString());
36 return;
37}
39
40$r=$cn->exec_sql("select jr_def_id from jrn where jr_id=$1",array($jr_id));
41
42if ( Database::num_row($r) == 0 )
43{
44 echo_error("Invalid operation id jr_id=$jr_id");
45 exit;
46}
48$jrn=$a['jr_def_id'];
49global $g_user;
50if ($g_user->check_jrn($jrn) == 'X' )
51{
52 /* Cannot Access */
53 NoAccess();
54 exit -1;
55}
56
57$cn->start();
58$ret=$cn->exec_sql("select jr_pj,jr_pj_name,jr_pj_type,jr_pj_number from jrn where jr_id=$1",
59 array($jr_id));
60
61if ( Database::num_row ($ret) == 0 )
62 return;
63
65
66if ( $row['jr_pj']==null )
67{
68 ini_set('zlib.output_compression','Off');
69 header("Pragma: public");
70 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
71 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
72 header("Cache-Control: must-revalidate");
73 header('Content-type: '.'text/plain');
74 header('Content-Disposition: attachment;filename=vide.txt',FALSE);
75 header("Accept-Ranges: bytes");
76 echo "******************";
77 echo _("Fichier effacé");
78 echo "******************";
79 exit();
80}
81$tmp=tempnam($_ENV['TMP'],'document_');
82
83$new_name=$row['jr_pj_name'];
86if ( ! empty($receipt_number) && strpos($new_name,$receipt_number) === false ) {
87
89}
90
91$cn->lo_export($row['jr_pj'],$tmp);
92
93ini_set('zlib.output_compression','Off');
94header("Pragma: public");
95header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
96header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
97header("Cache-Control: must-revalidate");
98header('Content-type: '.$row['jr_pj_type']);
99header('Content-Disposition: attachment;filename="'.$new_name.'"',FALSE);
100header("Accept-Ranges: bytes");
101$file=fopen($tmp,'r');
102while ( !feof ($file) )
103 echo fread($file,8192);
104
105fclose($file);
106
107unlink ($tmp);
108
109$cn->commit();
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
NoAccess($js=1)
Echo no access and stop.
Definition: ac_common.php:480
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
$jr_id
Definition: ajax_ledger.php:44
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
static connect()
manage the http input (get , post, request) and extract from an array
for($e=0; $e< count($afiche); $e++) exit
global $g_user
if( $row['jr_pj']==null) $tmp
if(Database::num_row($r)==0) $a
$new_name
$receipt_number
catch(Exception $exc) $cn
clean_filename($p_filename)
sanitize the filename remove character which could be a problem,