Bug #12098: fseek bug
| From: | volkov at coke dot kmr dot kuzbass dot net | Date: | Thu, 12 Jul 2001 12:07:32 +0000 |
| Subject: | Bug #12098: fseek bug | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-59830@lists.php.net to get a copy of this message | ||
From: volkov@coke.kmr.kuzbass.net
Operating system: Win2000 prof
PHP version: 4.0.6
PHP Bug Type: Filesystem function related
Bug description: fseek bug
function conf_append($file,$in,$top="<?php\r\n",$bottom=");?>")
{
$ya=file_exists($file)?1:0;
eval("if(\$ourfile=fopen(\$file,'".($ya?'r':'a')."+b'))
{".($ya?"fseek(\$ourfile,-strlen(\$bottom),SEEK_END);":"")."
fwrite(\$ourfile,".(!$ya?"\$top.":"")."\$in.\$bottom);
fclose(\$ourfile);}");
}
We can't change pointer file position when we open it
with 'a+', but may when 'r+'/ So we need for create open with 'a+',
and if
file exists 'r+'
--
Edit bug report at: http://bugs.php.net/?id=12098&edit=1