Re: Anyway to open a PHP file and view its code in the browser?
| From: | Christopher William Wesley | Date: | Thu, 14 Feb 2002 23:11:13 +0000 |
| Subject: | Re: Anyway to open a PHP file and view its code in the browser? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84844@lists.php.net to get a copy of this message | ||
Create a script to which you can pass a file namem and calls show_source()
on the file name.
http://www.php.net/manual/en/function.show-source.php
Be very careful to check the input, such that the file name parameter
which eventually gets passed to show_source() cannot be one which you do
not want to be displayed to everyone in the world.
When using the function to show off living code, I make sure the only
files that can be viewed are files in specific directories. I also make
sure the file exists in the file system ... displaying an appropriate
messages when the file will not be diplayed.
g.luck,
~Chris /"\
\ / September 11, 2001
X We Are All New Yorkers
/ \ rm -rf /bin/laden
On Thu, 14 Feb 2002, 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.
>
> Much Thanks,
> Kevin Stone <Kevin@helpelf.com>
>