When I use this code below:
[highlight="php"]
<?php
// Open a site and read the contents
$read = fopen("http://www.gmail.com";, "r")
or die("Couldn't open file");
// Read the bytes
$contents = fread($read,10000000);
// Display the contents
echo "$contents";
?>
[/highlight]
I see the actual page..... How do I see just the source though?
PHP reading a webpage Source vs Content
Started by Frantic, Oct 31 2007 11:13 AM
9 replies to this topic
#1
Posted 31 October 2007 - 11:13 AM
|
|
|
#2
Posted 31 October 2007 - 01:07 PM
It's been a while, but I believe $contents does contain the actual source code, its just when you echo it, the browser parses it.
Try a
Try a
echo htmlentities($contents);If that doesn't work, you can always set the header to output text.
#3
Guest_Jordan_*
Posted 01 November 2007 - 04:10 AM
Guest_Jordan_*
You also seem to have an error on line 4:
[highlight="php"]
$read = fopen("http://www.gmail.com";, "r")
[/highlight]
See your extra ";" at the end of gmail.com?
[highlight="php"]
$read = fopen("http://www.gmail.com";, "r")
[/highlight]
See your extra ";" at the end of gmail.com?
#4
Posted 09 November 2007 - 02:12 PM
Quote
It's been a while, but I believe $contents does contain the actual source code, its just when you echo it, the browser parses it.
#5
Posted 10 November 2007 - 05:43 PM
I didn't know that you could read PHP source code with other PHP scripts! Kind of scary actually because then there is no real way to hide MySQL passwords! :eek:
EDIT: I tried both of those methods and they just show the HTML.
EDIT: I tried both of those methods and they just show the HTML.
#6
Posted 11 November 2007 - 12:51 PM
ETbyrne said:
EDIT: I tried both of those methods and they just show the HTML.
Thats what its suppose to do.
#7
Posted 11 November 2007 - 04:37 PM
#8
Guest_Jaan_*
Posted 11 November 2007 - 09:50 PM
Guest_Jaan_*
<?php
// Open a site and read the contents
$read = fopen("http://www.yoursite.xxx", "r")
or die("Couldn't open file");
// Read the bytes
$contents = fread($read,10000000);
$contents = htmlentities($contents);
// Display the contents
echo "<pre>$contents</pre>";
?>
here's your full script.. works perfectly :)
#9
Posted 12 November 2007 - 02:46 PM
Quote
I didn't know that you could read PHP source code with other PHP scripts! Kind of scary actually because then there is no real way to hide MySQL passwords!
WOW! Thats something completely different. You will NEVER be able to read a PHP source from another script over HTTP! EVER!
#10
Posted 13 November 2007 - 03:05 PM
Yeah the idea kind of scared me when I didn't read the first post correctly, but then I remembered how PHP works:
1. The user requests a page from the server.
2. If the page has PHP source code in it the server executes it.
3. The server sends the finished page to the user.
So the user never has a chance to see the source code.
1. The user requests a page from the server.
2. If the page has PHP source code in it the server executes it.
3. The server sends the finished page to the user.
So the user never has a chance to see the source code.
My website > www.evanbot.com


Sign In
Create Account


Back to top









