|
Ever since the introduction of PHP5, we have been getting a lot of complaints that most webhostings are actually restricting the include() feature of remote files/links. This is actually a default settings in PHP5 to avoid hacks and DDos attacks. This simply means only local files can be included in any PHP applications. First workaround that anyone can think about is to ask our webhosting to enable back this feature, but i am not sure how well this would work!
To burn my time i just wanted to create a PHP application which would simply access pages behind any firewall or proxies. Well trust me this is not any proxy script you might be thinking about or even would want to have. It will just peek the contents of the page if it is blocked by using the include() feature. But as i was coding this simply and messy script i noticed that my host has disabled include() function for remote files.
After digging here and there and also using my basic knowledge of PHP, i came upon the function file_get_contents() which does exactly what i wanted for my script. It works almost the same as an include function but more towards displaying the page contents.
By using this function i managed to complete my simply script called “Peek-Into”. Here is the code i used in my script which simply bypasses the usage of included():
<?php
// code to include a file without using include
$_url = $_POST['url'];
if ( $_url != "" ) {
$url = file_get_contents("$_url");
echo $url;
}
?>
Some might be wondering what is the purpose of this code? Well it is just a part of my code for the script “Peek-Into” which allows you to peek and have a glance of any pages even those blocked behind firewalls. You can check out the demo of my script HERE.
|