aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_write_file.php')
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_write_file.php32
1 files changed, 15 insertions, 17 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php b/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
index e5d19ce8d..f46fe2b6c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
@@ -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