褰揚HP琚绂佺敤鐨凱HP鍑芥暟:tempnam() 鍚

2022 年 11 月 14 日2420

褰揚HP琚绂佺敤鐨凱HP鍑芥暟:tempnam() 鍚,tempnam()鍙寤虹珛涓涓涓存椂妗o紝妗e悕涓嶄細涓庡悓鐩褰曚腑鐨勬。妗堥噸瑕嗐

銆銆浼犲洖瀛椾覆灏辨槸寤虹珛鐨勪复鏃舵。鍚嶃傝嫢鍙戠敓閿欒鍒欎紶鍥炵┖瀛椾覆銆


銆銆43^43B^43B32F4B%%index.htm.php鐨勪复鏃舵。,鎵浠,tempnam()琚绂佺敤鍚,褰撶劧涓嶈兘鑷鍔ㄥ垱寤虹被浼%%

銆銆43^43B^43B32F4B%%index.htm.php鐨勪复鏃舵。,鑷鐒惰嚜鍔ㄥ垱寤虹被浼%%


銆銆smarty涓浣跨敤tempnam鍑芥暟鐨勭▼搴忔槸internals/core.write_file.php,濡備笅浠g爜:


PHP浠g爜:


// write to tmp file, then rename it to avoid
// file locking race condition
$_tmp_file = tempnam($_dirname, wrt);
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]);
fclose($fd);

0 0