RE: [PHP] Anyway to open a PHP file and view its code in thebrowser?

From: Date: Thu, 14 Feb 2002 22:18:30 +0000
Subject: RE: [PHP] Anyway to open a PHP file and view its code in thebrowser?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-84834@lists.php.net to get a copy of this message
Oh duh. Before I was passing the whole URL and there must be some kind of security measure in place so that users can't view the code of remote scripts. That makes sense. It's working fine using the relative path on the local directory which is all I need. -- <? //peekaboo.php if (isset($script)) { $fp = fopen($script, "r"); while (!feof($fp)) { $out .= fread($fp, 100000); $out = $out."\n"; } fclose($fp); } header("Content-type: text/html"); echo "Now display source code for: $script<br>"; echo "<textarea cols=50 rows=10>$out</textarea>"; ?> -- This works.. <p><a href="peekaboo.php?script=myscript.php">View Source for Myscript.php</a> This doesn't work.. <p><a href="peekaboo.php?script=http://www.mydomain/myscript.php">View Source for Myscript.php</a> Thanks for your help. It's always the little things that'll get ya. :) -- Kevin Stone <kevin@helpelf.com> > -----Original Message----- > From: Lars Torben Wilson [mailto:torben@pinc.com] On Behalf Of Lars Torben > Wilson > Sent: Thursday, February 14, 2002 1:55 PM > To: Kevin Stone > Cc: php-general@lists.php.net > Subject: Re: [PHP] Anyway to open a PHP file and view its code in > thebrowser? > > On Thu, 2002-02-14 at 12:26, Kevin Stone wrote: > > How can I open a local PHP script and view its code to the browser? The > > Readfile() method appears to parse and execute the code. The Fopen() > > method appears to parse and then not execute the code, leaving a blank > > screen, or at the very least displaying any non-PHP text existing in the > > script. This is obviously rare question because I can't find any > > references on this list or on Usenet. Is there a trick to this? Or is > > it simply not possible. > > No, readfile() and fopen() should both do what you want. If not, it's a > bug, and it would be a bit of a showstopper--which leads me to believe > that something else is going on, or someone would've noticed by now. :) > But we do miss things, so can you post a short sample script? > > > Much Thanks, > > Kevin Stone <Kevin@helpelf.com> > -- > Torben Wilson <torben@php.net> > http://www.thebuttlesschaps.com > http://www.hybrid17.com > http://www.inflatableeye.com > +1.604.709.0506

« previous php.general (#84834) next »