tempnam() seems to be borken on many installation.

now we try tempnam first and if that fails we generate our own
temp-filename with uniqid()
This commit is contained in:
messju
2004-08-29 13:16:30 +00:00
parent e99e825c50
commit 1a3c4eb890
2 changed files with 9 additions and 4 deletions

2
NEWS
View File

@@ -1,3 +1,5 @@
- fall back to old uniqid()-behaviour when tempnam() fails in
core.write_file.php (messju)
- fix capitalize modifier, don't rely on buggy ucwords (Monte)
- make html_select_date work with negative timestamps, also
force year range to include given date unless explicitly

View File

@@ -25,11 +25,14 @@ function smarty_core_write_file($params, &$smarty)
// write to tmp file, then rename it to avoid
// file locking race condition
$_tmp_file = tempnam($_dirname, 'write_');
$_tmp_file = tempnam($_dirname, 'wrt');
if (!($fd = @fopen($_tmp_file, 'w'))) {
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
return false;
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
return false;
}
}
fwrite($fd, $params['contents']);