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 [EMAIL PROTECTED] -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Anyway to open a PHP file and view its code in thebrowser?
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, 10); $out = $out.\n; } fclose($fp); } header(Content-type: text/html); echo Now display source code for: $scriptbr; echo textarea cols=50 rows=10$out/textarea; ? -- This works.. pa href=peekaboo.php?script=myscript.phpView Source for Myscript.php/a This doesn't work.. pa 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 [EMAIL PROTECTED] -Original Message- From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]] On Behalf Of Lars Torben Wilson Sent: Thursday, February 14, 2002 1:55 PM To: Kevin Stone Cc: [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Anyway to open a PHP file and view its code in thebrowser?
yeah - going through a seb server, you're going to get the executed version of the code and not the code itself. -Original Message- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Friday, February 15, 2002 9:19 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Anyway to open a PHP file and view its code in thebrowser? 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, 10); $out = $out.\n; } fclose($fp); } header(Content-type: text/html); echo Now display source code for: $scriptbr; echo textarea cols=50 rows=10$out/textarea; ? -- This works.. pa href=peekaboo.php?script=myscript.phpView Source for Myscript.php/a This doesn't work.. pa 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 [EMAIL PROTECTED] -Original Message- From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]] On Behalf Of Lars Torben Wilson Sent: Thursday, February 14, 2002 1:55 PM To: Kevin Stone Cc: [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Anyway to open a PHP file and view its code in thebrowser?
On Thu, 2002-02-14 at 14:18, Kevin Stone wrote: 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. Actually, it's not a security measure. It's just that when you fopen() a string which starts with 'http://', a remote request is made to get the page just as if a browser had done it--so you get whatever a browser would get if you entered that string into its Location line. By opening the file locally, you're just reading it off the disc as per normal, so you don't get any parsing. Torben -- ? //peekaboo.php if (isset($script)) { $fp = fopen($script, r); while (!feof($fp)) { $out .= fread($fp, 10); $out = $out.\n; } fclose($fp); } header(Content-type: text/html); echo Now display source code for: $scriptbr; echo textarea cols=50 rows=10$out/textarea; ? -- This works.. pa href=peekaboo.php?script=myscript.phpView Source for Myscript.php/a This doesn't work.. pa 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 [EMAIL PROTECTED] -Original Message- From: Lars Torben Wilson [mailto:[EMAIL PROTECTED]] On Behalf Of Lars Torben Wilson Sent: Thursday, February 14, 2002 1:55 PM To: Kevin Stone Cc: [EMAIL PROTECTED] 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 [EMAIL PROTECTED] -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Torben Wilson [EMAIL PROTECTED] http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php