ID: 37662
Updated by: [EMAIL PROTECTED]
Reported By: mg at evolution515 dot net
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Debian/Sarge
PHP Version: 5.1.4
New Comment:
Works _perfectly fine_.
Please either provide a short reproduce script (do you really need
those classes to read a file, eh?) or just debug your code yourself.
Previous Comments:
------------------------------------------------------------------------
[2006-06-01 09:23:38] mg at evolution515 dot net
And copy /usr/share/misc/magic to your working dir so the script find a
file! (Otherweise the script won't exit in with PHPCLI)
------------------------------------------------------------------------
[2006-06-01 09:20:57] mg at evolution515 dot net
Ok, changed to PHP/5.1.4-1.dotdeb.1. Still the error.
CLI as libapache2 produce the same error.
$ php BUG.php
strpos() has been successfuly run!
Fatal error: Call to undefined function () in
/home/www/Projekte/flyerpilot.de/htdocs.dev/MimeMagic/BUG.php on line
41
OK COPY AND PASTE FOLLWING SCRIPT AND TRY AGAIN!
--------------------------------------------------
<?php
class MagicReader {
private $magicBuffer = '';
private $magicFile;
private $fp;
function __construct($filename=null) {
if (is_string($filename))
$this->openMagicFile($filename);
$this->convert();
$this->closeMagicFile();
}
function openMagicFile($filename) {
$this->magicFile = @fopen($filename, 'r');
return $this->magicFile;
}
function closeMagicFile() {
return @fclose($this->magicFile);
}
function convert() {
while ($line = $this->readLine()) {
echo $line;
die();
}
}
private function readLine()
{
while (([EMAIL PROTECTED]($this->magicFile)) ||
(strlen($this->magicBuffer)>0))
{
$lfPos = strpos($this->magicBuffer, "\r"); // cahnge
this value to
R!
if ($lfPos !==false) {
$this->magicBuffer = substr($this->magicBuffer,
$lfPos);
return substr($this->magicBuffer, $lfPos)."|";
}
$this->magicBuffer = @fread($this->magicFile, 4096);
}
// if we reached this position we are at the end of the file!
$out = $this->magicBuffer; // assign return output
if (empty($this->magicBuffer)) {// if buffer is already empty
we are
really at the end
return false;
}
$this->magicBuffer = ''; // clear out buffer
return $out;
}
function __destruct() {
$this->closeMagicFile();
}
}
$str = "That's a\rlittle Test!";
echo (strpos($str, "\r")) ? "strpos() has been successfuly run!" :
"nothing found but successfuly run!";
$reader = new MagicReader("magic");
?>
------------------------------------------------------------------------
[2006-06-01 08:54:06] [EMAIL PROTECTED]
Bug update collision, setting back to bogus.
------------------------------------------------------------------------
[2006-06-01 08:47:33] [EMAIL PROTECTED]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
------------------------------------------------------------------------
[2006-06-01 08:42:38] [EMAIL PROTECTED]
# php /tmp/2.php
strpos() has been successfuly run!
I'm sure you don't need a class to check if strpos() finds '\r' or '\n'
in strings.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/37662
--
Edit this bug report at http://bugs.php.net/?id=37662&edit=1