00001 <?php 00016 function smarty_core_write_file($params, &$smarty) 00017 { 00018 $_dirname = dirname($params['filename']); 00019 00020 if ($params['create_dirs']) { 00021 $_params = array('dir' => $_dirname); 00022 require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php'); 00023 smarty_core_create_dir_structure($_params, $smarty); 00024 } 00025 00026 // write to tmp file, then rename it to avoid file locking race condition 00027 $_tmp_file = tempnam($_dirname, 'wrt'); 00028 00029 if (!($fd = @fopen($_tmp_file, 'wb'))) { 00030 $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt'); 00031 if (!($fd = @fopen($_tmp_file, 'wb'))) { 00032 $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); 00033 return false; 00034 } 00035 } 00036 00037 fwrite($fd, $params['contents']); 00038 fclose($fd); 00039 00040 if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) { 00041 // On platforms and filesystems that cannot overwrite with rename() 00042 // delete the file before renaming it -- because windows always suffers 00043 // this, it is short-circuited to avoid the initial rename() attempt 00044 @unlink($params['filename']); 00045 @rename($_tmp_file, $params['filename']); 00046 } 00047 @chmod($params['filename'], $smarty->_file_perms); 00048 00049 return true; 00050 } 00051 00052 /* vim: set expandtab: */ 00053 00054 ?>
| Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|
