mirror of
https://github.com/e107inc/e107.git
synced 2025-06-06 19:06:39 +02:00
Support append on file_put_contents() emulation
This commit is contained in:
parent
74fd54fdf1
commit
6000dba853
@ -12,11 +12,17 @@ if (!function_exists('file_put_contents')) {
|
|||||||
* @param mixed $data
|
* @param mixed $data
|
||||||
* @desc Write a string to a file
|
* @desc Write a string to a file
|
||||||
*/
|
*/
|
||||||
function file_put_contents($filename, $data) {
|
define('FILE_APPEND', 1);
|
||||||
if (($h = @fopen($filename, 'w+')) === false) {
|
function file_put_contents($filename, $data, $flag = false)
|
||||||
|
{
|
||||||
|
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
|
||||||
|
if (($h = @fopen($filename, $mode)) === false)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (($bytes = @fwrite($h, $data)) === false) {
|
if (is_array($data)) $data = implode($data);
|
||||||
|
if (($bytes = @fwrite($h, $data)) === false)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fclose($h);
|
fclose($h);
|
||||||
@ -24,6 +30,8 @@ if (!function_exists('file_put_contents')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('stripos')) {
|
if (!function_exists('stripos')) {
|
||||||
function stripos($haystack, $needle) {
|
function stripos($haystack, $needle) {
|
||||||
$parts = explode(strtolower($needle), strtolower($haystack), 2);
|
$parts = explode(strtolower($needle), strtolower($haystack), 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user