View Single Post
Old 11-25-2006, 09:21 AM   #1 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 705
DJMaze is on a distinguished road
TIP: How to get arround allow_url_fopen=Off

PHP has a INI setting called allow_url_fopen, and when that is set to Off you're not able to use http & ftp streams with include or fopen().

Don't worry because as of PHP 4.3.2 there are new functions to create your own stream wrappers like stream_wrapper_register and stream_wrapper_unregister

Thanks to the new features we can get around it on hosts that disallow url_fopen for security reasons
To achieve this we need to write our own stream wrapper that uses fsockopen

My http stream wrapper can be found here http://cvs.moocms.com/moo/moo_core/l...eam/http.php?v

and here's how to use it
PHP Code:
if (!ini_get('allow_url_fopen'))
{
    include(
'moo_core/libraries/stream/http.php');
    
stream_wrapper_unregister('http');
    
stream_wrapper_register('http''lib_stream_http');

Warning: by doing this you are re-opening the implemented security risks. therefore you should be very carefull with include() and require() functionality.
Therefore it's advisable NOT to use stream_wrapper_register if you're a PHP newbie and just use

PHP Code:
$fp = new lib_stream_http
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote