Forum Moderators: coopster

Message Too Old, No Replies

Can PHP read another url

Get URL without processing the php

         

HeadBut

4:56 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



Is there a function in php that can get a url and not parse the php if it is a .php file?
Like:
$Capturedhtml = file_get_contents($GetURL);
will this work on a .php without parsing the php?

thanks

ogletree

4:59 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PHP is server side so if you are looking at a webpage with php you won't see any php. Matter of fact my sites you can't even tell that I used PHP. I use .html as my extension. You would have to be on their server to see the php.

HeadBut

6:01 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



So, I can use: $Capturedhtml = file_get_contents($GetURL);
and not worry that it will parse any php it finds?

thanks

Bonusbana

6:03 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



Yes you can.

coopster

6:22 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If it is indeed a url, the php will be parsed. That is the nature of a web server when it receives a request via the HTTP protocol. If you want the raw contents of the file, you'll need to read it via other means than HTTP.

HeadBut

8:04 pm on Feb 28, 2005 (gmt 0)

10+ Year Member



OK, I understand that the machine that serves the file (via http) will parse it. But will my server that receives the (post parsed) file then again parse whatever is left?

coopster

8:15 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



There won't be anything left to parse as the server that dished up the page and delivered it to your script will have already parsed any and all PHP.

ergophobe

10:54 pm on Feb 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How much control do you have over the remote server?

In other words, can you put a show_source.php file on that server and then send the name of the file for which you want the source as a GET param?

If the referrer is not on a white list, the request gets refused.

If it is on the whitelist, show_source.php fetches the file locally, and sends you the source code as output.

Obviously people could always spoof the referrer, so you would need to protect files with DB passwords and such.