Webmastersite.net
Register Log In

disabling allow_url_fopen
functionality question

Comments on disabling allow_url_fopen

Zihrena
Member

Usergroup: Customer
Joined: Dec 27, 2003

Total Topics: 9
Total Comments: 18
Zihrena
Posted Jun 16, 2005 - 1:58 PM:

My hosting provider has just announced that for security reasons they are going to disable the allow_url_fopen function in our PHP installation. I see there are past posts in the forum regarding the fact that disabling allow_url_fopen interferes with the link checkers, but does anyone now if there is any other aspect of the directory that will be effected? Is there anyone out there running WSN Links on a system with allow_url_fopen disabled, who could let me know if their directory runs properly otherwise?

Thanks in advance.
Paul
developer

Usergroup: Administrator
Joined: Dec 20, 2001
Location: Diamond Springs, California

Total Topics: 61
Total Comments: 7868
Paul
Posted Jun 16, 2005 - 7:17 PM:

It affects all spots that try to load a url. That could include link checks, meta description buttons, possibly even html/static generation.

CURL will be supported as of 3.20, and you can replace your geturl() function to make it work in 3.16. It's in filefunctions.php.


function geturl($url)
{
global $switches;
if (extension_loaded('curl'))
{
$user_agent = 'Mozilla/4.0 (compatible; MSIE 6.02; PHP)';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($ch);
curl_close ($ch);
return $result;
}


if (version_compare("4.3.0", phpversion(), "<"))
{
$filecontents = @file_get_contents($url);
}
else
{
$fd = @fopen($url, 'rb');
$filecontents = "";
do
{
$data = @fread($fd, 8192);
if (strlen($data) == 0)
{
break;
}
$filecontents .= $data;
} while(true);
@fclose ($fd);
}
return $filecontents;
}


Of course, this still requires that your host support CURL if it doesn't support fopen urls.
Search thread for
Download thread as
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5



This thread is closed, so you cannot post a reply.