Edit report at http://bugs.php.net/bug.php?id=52984&edit=1

 ID:                 52984
 Comment by:         craig at logicshock dot co dot uk
 Reported by:        craig at logicshock dot co dot uk
 Summary:            PHP executing text from .php file opened with
                     fopen().
 Status:             Bogus
 Type:               Bug
 Package:            *Directory/Filesystem functions
 Operating System:   Ubuntu 8.10/9.04, Windows 7 x86
 PHP Version:        Irrelevant
 Block user comment: N

 New Comment:

Ok, the browser result is:

<html><body> 

// This is a test comment, doesnt matter that it is not in the php tags
because 

this 

// file SHOULD NEVER BE EXECUTED!

";

 

?>

</body></html> 



It shows that the browser is only getting 'part' of the text as a
response.



And the complete test code is:



<?php

        

        echo ls_execute();

        

        function ls_execute()

        {

                $fp = fopen('code.php', 'r') or die('Cannot open that source 

resource');

                while(!feof($fp))

                {

                        $data .= fread($fp,128);

                }

                fclose($fp);

                return  $data;

        }

?>


Previous Comments:
------------------------------------------------------------------------
[2010-10-04 13:54:49] [email protected]

Ah :)



Just reading again your report. You are calling the script from a
webserver right? Via your browser? Then show the source of the page,
that should give you the answer.

------------------------------------------------------------------------
[2010-10-04 13:53:32] [email protected]

Please paste the exact scripts you are using to test. There is no bug
like or we would have hundred of bugs reports about it already. And it
works just fine here (BSD, windows, linux), iirc.

------------------------------------------------------------------------
[2010-10-04 13:52:40] craig at logicshock dot co dot uk

Another update, in the source file that is read using fopen, if I change
the <?php 

to < ?php the function works as expected, so, somewhere along the line
PHP is 

finding the <?php in the text and is recognising it as PHP code where it
should 

only be treating it as plain text. 



Also, changing the file extension make no difference

------------------------------------------------------------------------
[2010-10-04 13:25:32] craig at logicshock dot co dot uk

As an update, I altered the code.php file to see if the contents made a
difference. 

The changed file is:





// This is a test comment, doesnt matter that it is not in the php tags
because this 

// file SHOULD NEVER BE EXECUTED!

<?php



        echo " This is a test<?php ?>";

 

?>



Now, the resulting output should be that exact text as the reading
script is only reading the text, not executing it. However the result is
instead:



// This is a test comment, doesnt matter that it is not in the php tags
because this // file SHOULD NEVER BE EXECUTED! "; ?>



There is something wrong here, because it is reading parts and not
others....  To be sure I tried it on my Windows machine (PHP 5.3.1) ,
and again on two of my Linux servers (PHP 5.2.6 & 

5.3.3), the result is the same on all three.



I still cannot see any coding error. Surely this is a bug?

------------------------------------------------------------------------
[2010-10-04 12:53:20] craig at logicshock dot co dot uk

The actual code is shown here, am I missing a mistake here then? 

The original code was a lot bigger but I broke it down to the code shown
below to 

help isolate the problem. I had a colleague look too, he also couldn't
see 

anything wrong, still I will check the code again just in case my last
12 months 

of forced ASP.net has made me overlook something.



There was an echo added, I forgot to show that in the first post here,
so added it 

as an edit, shown below.

------------------------------------------------------------------------


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/bug.php?id=52984


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52984&edit=1

Reply via email to