PDA

View Full Version : don't process my fopen()/fread()



mlk
July 19th, 2007, 10:16 AM
Hello. I'm trying to build a php sandbox with a small UI from http://codepress.org/

however I've encountered a small problem, when I fetch the php pages I want to edit thru fopen() they naturally come out processed. Is there anyway I can have them in clear ? as if they were .txt files ?



$file = "http://mysite.com/myfile.php";
$fp = fopen($file,'r') or die('Failed to open');
$contents = fread($fp,filesize($file));
fclose($fp);
//code to display $contents


I know it's a huge security hole but I'm only using it on local server with proper protections. I have a feeling what I want to do is against php's base design

cheers

mlk

eirche
July 19th, 2007, 10:19 AM
use file_get_contents()
http://ca.php.net/manual/en/function.file-get-contents.php

mlk
July 19th, 2007, 10:29 AM
that was uber fast ! :|

thanks =)

mlk
July 19th, 2007, 11:14 AM
...it doesn't work. The php file is being processed. I want to see its source. I'm still wondering if that's remotely possible

eirche
July 19th, 2007, 11:20 AM
drop the "http://mysite.com/", file_get_contents("../myfolder/myfile.php")

icio
July 19th, 2007, 11:37 AM
When you use the 'http://', you're asking apache for the while, which serves the file via the PHP processor.

You need to get the file from the file-system instead, using a relative or absolute file path like eirche said above.

mlk
July 19th, 2007, 02:26 PM
hah thanks for the enlightement

you guys rock