AlecH wrote:This looks like what you are looking for.
Code: Select all
$page = trim($_GET['page'];
if($page == '')
{
$fp = fopen($page, 'r'); // Open Page .txt for reading from beginning
$read = fread($fp, '4000'); // Read from the file pointer
print($read);
}
But that results in a warning about an undefined variable when there is no page variable in the url... The following code on the other hand doesn't have that problem...
Another problem is that the use of this variable, without performing any checks on it, allows a malicious user to request any page he wants.. And as long as the webserver has read access to that file, he'll get to see the contents...
If you really want to do that, at least use
http://www.php.net/real_path to verify if the page comes from a place where it's allowed to request pages from
Anyway, i'm pretty sure the OP did not bother to carefully read the links i posted... So i'll stop bothering about his problems too..