From:             nightstorm at tlen dot pl
Operating system: Windows XP
PHP version:      5CVS-2003-10-24 (dev)
PHP Bug Type:     Filesystem function related
Bug description:  fopen('file', 'r'); doesn't move to the end of the file

Description:
------------
I tried to write something like a simple package system, which loads the
files into an array, serializes it, and compresses. But I noticed that
each file didn't have first 334 characters. I wrote a simple code to check
it and I stated this is a PHP bug. I experimented with many variants -
changing the way of loading (file_get_contents(), file() etc.), using
fseek($fp, 0, SEEK_SET); and also moving to the other directory, or
loading other files. There is the funniest part of this story. I've got a
template system, which loads templates also by fopen(), but I noticed that
these files are not cutted. I copied some code from parser and set it to
open a file in main project directory ( / ) - it was cutted. Then i
checked with files form /templates - these aren't cutted. I checked phpBB
2 - also: files from /templates weren't cutted, but from other
directories, and the root - were. And only for these files, which were
created there. So if I copied any file from for example root to
/templates, it wouldn't work. I looked into "file attributes" and
everything was the same in each file: read only on, archivization off,
indexing on. I totally don't know, what's going on. fseek($fp, 0,
SEEK_SET); should set the beginning of the file, but it is moving me into
334th character; fseek($fp, 1, SEEK_SET); works correctly. rewind($fp)
also doesn't work. ftell($fp); returns 0.

System:
Windows XP Pro, NTFS partition
Apache 2.0.4
PHP 5.0.0-dev latest snapshot

Reproduce code:
---------------
$f = fopen('../../engine/fws.php', 'r');
echo '<pre>';
while(!feof($f)){
        echo fread($f, 256);
}
fclose($f);
echo '</pre>';
        

Expected result:
----------------
<?php
/*
*****************************************************************************
*           Fillar WebSystem 1.0.0
*   ========================================
*         Fillar Systems 2002/2003
*       Site Engine/Discussion Board
*****************************************************************************
*
*   -> Main interface
*   -> Written by Tomasz "Zyx" Jędrzejewski
*   -> Date started: 1-7-2003
*
*       -> Version: 1.0.0
*****************************************************************************
*/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *

***************************************************************************/
....

Actual result:
--------------
 Main interface
*   -> Written by Tomasz "Zyx" Jędrzejewski
*   -> Date started: 1-7-2003
*
*       -> Version: 1.0.0
*****************************************************************************
*/
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *

***************************************************************************/
 ....

-- 
Edit bug report at http://bugs.php.net/?id=25977&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25977&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25977&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25977&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25977&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25977&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25977&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25977&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25977&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25977&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25977&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25977&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25977&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25977&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25977&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25977&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25977&r=float

Reply via email to