]> git.mxchange.org Git - friendica.git/blobdiff - library/Smarty/libs/sysplugins/smarty_internal_write_file.php
reverting tinymce changes, updating smarty to 3.1.19
[friendica.git] / library / Smarty / libs / sysplugins / smarty_internal_write_file.php
index e5d19ce8d6842c3314a5c45066a1358f6e1fbca7..f46fe2b6c77177f3a2eb28044db608c42212cb71 100644 (file)
@@ -2,25 +2,27 @@
 /**
  * Smarty write file plugin
  *
- * @package Smarty
+ * @package    Smarty
  * @subpackage PluginsInternal
- * @author Monte Ohrt
+ * @author     Monte Ohrt
  */
 
 /**
  * Smarty Internal Write File Class
  *
- * @package Smarty
+ * @package    Smarty
  * @subpackage PluginsInternal
  */
-class Smarty_Internal_Write_File {
-
+class Smarty_Internal_Write_File
+{
     /**
      * Writes file in a safe way to disk
      *
-     * @param string $_filepath complete filepath
-     * @param string $_contents file content
-     * @param Smarty $smarty    smarty instance
+     * @param  string $_filepath complete filepath
+     * @param  string $_contents file content
+     * @param  Smarty $smarty    smarty instance
+     *
+     * @throws SmartyException
      * @return boolean true
      */
     public static function writeFile($_filepath, $_contents, Smarty $smarty)
@@ -38,17 +40,16 @@ class Smarty_Internal_Write_File {
         }
 
         // write to tmp file, then move to overt file lock race condition
-        $_tmp_file = $_dirpath . DS . uniqid('wrt', true);
+        $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true));
         if (!file_put_contents($_tmp_file, $_contents)) {
             error_reporting($_error_reporting);
             throw new SmartyException("unable to write file {$_tmp_file}");
-            return false;
-        }
-        
+       }
+
         /*
          * Windows' rename() fails if the destination exists,
          * Linux' rename() properly handles the overwrite.
-         * Simply unlink()ing a file might cause other processes 
+         * Simply unlink()ing a file might cause other processes
          * currently reading that file to fail, but linux' rename()
          * seems to be smart enough to handle that for us.
          */
@@ -71,7 +72,6 @@ class Smarty_Internal_Write_File {
         if (!$success) {
             error_reporting($_error_reporting);
             throw new SmartyException("unable to write file {$_filepath}");
-            return false;
         }
 
         if ($smarty->_file_perms !== null) {
@@ -80,9 +80,7 @@ class Smarty_Internal_Write_File {
             umask($old_umask);
         }
         error_reporting($_error_reporting);
+
         return true;
     }
-
 }
-
-?>
\ No newline at end of file