[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 143/151: Fix : when exporting files for creat
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 143/151: Fix : when exporting files for creating a PDF in ANC , the filename can be a problem if he contains some char. |
Date: |
Sat, 4 Feb 2017 17:14:35 +0000 (UTC) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit c9bf802d8159bf273e2060d28a1b4cf73c545ca2
Author: Dany De Bontridder <address@hidden>
Date: Sat Jan 28 09:41:13 2017 +0100
Fix : when exporting files for creating a PDF in ANC , the filename can be
a problem if he contains some char.
---
include/class/class_document_export.php | 15 +++++++++------
include/lib/user_common.php | 16 +++++++++++++++-
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/include/class/class_document_export.php
b/include/class/class_document_export.php
index 57fbabc..05a95fa 100644
--- a/include/class/class_document_export.php
+++ b/include/class/class_document_export.php
@@ -128,18 +128,19 @@ class Document_Export
if ($file[0]['jr_pj'] == '')
continue;
- $cn->lo_export($file[0]['jr_pj'], $this->store_convert . '/' .
$file[0]['jr_pj_name']);
+ $filename=clean_filename($file[0]['jr_pj_name']);
+ $cn->lo_export($file[0]['jr_pj'], $this->store_convert . '/' .
$filename);
// Convert this file into PDF
if ($file[0]['jr_pj_type'] != 'application/pdf')
{
$status = 0;
- $arg="
".escapeshellarg($this->store_convert.DIRECTORY_SEPARATOR.$file[0]['jr_pj_name']);
+ $arg="
".escapeshellarg($this->store_convert.DIRECTORY_SEPARATOR.$filename);
echo "arg = [".$arg."]";
passthru(OFFICE . " " . $arg , $status);
if ($status <> 0)
{
- $this->feedback[$cnt_feedback]['file'] =
$file[0]['jr_pj_name'];
+ $this->feedback[$cnt_feedback]['file'] = $filename;
$this->feedback[$cnt_feedback]['message'] = ' cannot
convert to PDF';
$this->feedback[$cnt_feedback]['error'] = $status;
$cnt_feedback++;
@@ -169,8 +170,8 @@ class Document_Export
//
// remove extension
- $ext = strrpos($file[0]['jr_pj_name'], ".");
- $file_pdf = substr($file[0]['jr_pj_name'], 0, $ext);
+ $ext = strrpos($filename, ".");
+ $file_pdf = substr($filename, 0, $ext);
$file_pdf .=".pdf";
//-----------------------------------
@@ -248,14 +249,16 @@ class Document_Export
// Move the PDF into another temp directory
$this->move_file($output, 'stamp_' . $file_pdf);
}
+
+ // concatenate all pdf into one
$this->concatenate_pdf();
+
ob_clean();
$this->send_pdf();
// remove files from "conversion folder"
$this->clean_folder();
- // concatenate all pdf into one
}
/**
* @brief check that the files are installed
diff --git a/include/lib/user_common.php b/include/lib/user_common.php
index 7475f1a..6fc4a09 100644
--- a/include/lib/user_common.php
+++ b/include/lib/user_common.php
@@ -245,4 +245,18 @@ function check_parameter($p_array,$p_needed)
}
}
}
-?>
+/**
+ * sanitize the filename remove character which could be a problem,
+ * @param string $p_filename the filename to clean
+ * @return string Filename without bad char.
+ */
+function clean_filename($p_filename)
+{
+ $filename=$p_filename;
+ foreach (array('/','*','<','>',';',',','\\',':','(',')',' ','[',']') as
$i) {
+ $filename= str_replace($i, "-",$filename);
+ }
+ return $filename;
+
+}
+?>
\ No newline at end of file
- [Noalyss-commit] [noalyss] 109/151: Add a class to manage the Param table (CRUD), (continued)
- [Noalyss-commit] [noalyss] 109/151: Add a class to manage the Param table (CRUD), Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 113/151: Correct doxygen doc, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 131/151: Doxygen, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 120/151: Add managetable.js to the script to load, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 128/151: Security : add security, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 130/151: #1380 : change the name of the function Acc_Ledger::button_copy_operation, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 132/151: Correct Doxygen documentation, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 96/151: Documentation and clean code, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 112/151: Improve Doxygen doc, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 73/151: Export en PDF d'operation, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 143/151: Fix : when exporting files for creating a PDF in ANC , the filename can be a problem if he contains some char.,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 116/151: Manage_Table , the js and php code are been splitted in 2 files , the ajax calls are nearly done , doxygen for these files is correct, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 101/151: Deprecated HtmlInput::make_object must be replace by json_encode, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 99/151: Improve Sorttable, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 110/151: Add property in Manage_Table VISIBLE UPDATABLE, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 125/151: Test ManageTable ; fix parseXML function, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 144/151: Merge branch 'master' of ns3:/srv/git/noalyss, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 09/151: Experiment less, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 123/151: Test ManageTable ; fix parseXML function, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 126/151: Correct js : this of the object is not callable from a nested function, Dany De Bontridder, 2017/02/04
- [Noalyss-commit] [noalyss] 135/151: Fix bug : duplicate doesn't take in account the TVA_ID, Dany De Bontridder, 2017/02/04