Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 11-25-2006, 09:21 AM   #1 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
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
Old 11-25-2006, 06:30 PM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Note: my stream wrapper is moved to http://cvs.moocms.com/moo/moo_core/l...ers/http.php?v

Second note: As of PHP 6 it save to use the above mentioned hack because it has a new ini directive called allow_url_include :p
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 11-26-2006, 08:05 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
great to know. thanks for posting the info DJM.
__________________
Mike
sde is offline   Reply With Quote
Old 11-27-2006, 11:34 AM   #4 (permalink)
expx
Recruit
 
Join Date: Nov 2006
Posts: 3
expx is on a distinguished road
hey, I have never really actually programmed php, but I have a phpBB forum, and I have a MOD for my forum which needs to use the fsockopen function. However my host does not allow me to use this function. So this wrapper looks great but I am not sure exactly how to use it.

The script which tries to use the fsockopen function is in my /phpBB2 directory, so do I just put this wrapper into that directory as 'wrapper.php' or something?

and then the part in my script which uses the function is:

Code:
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
so how can I use the wrapper to do the same thing? Any advice would be great, thank you.
expx is offline   Reply With Quote
Old 11-27-2006, 01:29 PM   #5 (permalink)
expx
Recruit
 
Join Date: Nov 2006
Posts: 3
expx is on a distinguished road
uhh ignore the post above, i realised that this isn't for getting round fsockopen :[
expx is offline   Reply With Quote
Old 11-28-2006, 12:56 AM   #6 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 651
DJMaze is on a distinguished road
Quote:
Originally Posted by expx View Post
I have a MOD for my forum which needs to use the fsockopen function. However my host does not allow me to use this function.
Probably your webhost is either:
A. an asshole
B. free

In the cases you should either:
A. move to a good host
B. raise some money

Why?
A. the scary person doesn't understand the purpose of a good server hosting and just locked down everything
B. free host = free bandwidth = limited therefore it's locked down to prevent resource abuse
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 11-28-2006, 04:33 AM   #7 (permalink)
expx
Recruit
 
Join Date: Nov 2006
Posts: 3
expx is on a distinguished road
Quote:
Originally Posted by DJMaze View Post
Probably your webhost is either:
A. an asshole
B. free

In the cases you should either:
A. move to a good host
B. raise some money

Why?
A. the scary person doesn't understand the purpose of a good server hosting and just locked down everything
B. free host = free bandwidth = limited therefore it's locked down to prevent resource abuse
I paid for this host, and they are so SH!T! hostultra.com is their address, and I bought my domain with them too, and I can't move to a better host because they don't allow me to take my registered domain with me. I read that loads of people had similar problems, I made a mistake signing up with them!
expx is offline   Reply With Quote
Old 11-28-2006, 05:09 AM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,444
sde is on a distinguished road
can't you just get a new domain? if you don't own your domain, you're basically working for them and paying them for it. by the time you get sick of it and leave them, you will be leaving them with a domain that is worth at least something since it has been up for a while.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TIP #4: Pointer Rambo gets busted. Valmont Standard C, C++ 0 04-18-2005 03:21 PM
TIP #3: PRE/POST increment analisys. Valmont Standard C, C++ 5 04-15-2005 11:01 AM
Tip (5 minute solution): The Stopwatch Valmont Standard C, C++ 0 03-18-2005 08:27 AM
Tip (5 minute solution): The Facade Pattern Valmont Standard C, C++ 3 02-25-2005 12:27 AM


All times are GMT -8. The time now is 04:02 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting