From f304dd424bc3a21feeb446928126ca5895ff883c Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Fri, 29 Nov 2019 07:46:39 +0100 Subject: [PATCH] Fix can't create files on shared folder (Windows) --- .../tecnickcom/tcpdf/include/tcpdf_static.php | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php index 7d2c1f54a3d..67bb255d187 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_static.php @@ -1805,21 +1805,33 @@ class TCPDF_STATIC { return $ret; } - /** - * Wrapper to use fopen only with local files - * @param filename (string) Name of the file to open - * @param $mode (string) - * @return Returns a file pointer resource on success, or FALSE on error. - * @public static - */ - public static function fopenLocal($filename, $mode) { - if (strpos($filename, '://') === false) { - $filename = 'file://'.$filename; - } elseif (stream_is_local($filename) !== true) { - return false; - } - return fopen($filename, $mode); - } + /** + * Wrapper to use fopen only with local files + * @param string $filename The full path to the file to open + * @param string $mode Acceses type for the file ('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+' or 'e') + * @return resource Returns a file pointer resource on success, or FALSE on error. + * @public static + */ + public static function fopenLocal($filename, $mode) + { + if (strpos($filename, '//') === 0) + { + // Share folder on a (windows) server + // e.g.: "//[MyServerName]/[MySharedFolder]/" + // + // nothing to change + } + elseif (strpos($filename, '://') === false) + { + $filename = 'file://'.$filename; + } + elseif (stream_is_local($filename) !== true) + { + return false; + } + + return fopen($filename, $mode); + } /** * Check if the URL exist.