Log in

View Full Version : CURL Alternates for Users in SAFE-MODE



trippin
02-15-2007, 03:53 PM
A lot of people have webhosts which run under SAFE-MODE. Usually, these people don't have access to change this setting and the following functions are disabled for these users..

fopen(), fsockopen(), fwrite(), file(), & file_get_contents()

Most PHP scripts found online are written with one or more of these commands. So we must find an alternate to each command using CURL!

I have found an alternate to a few of these but I need Your help to get the others.


CURL ALTERNATES

file() via PHP
$CONTENTS = file('http://example.com/');

file() via CURL
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
$data = curl_exec($ch);
curl_close($ch);
$CONTENTS = array();
$CONTENTS = explode("n", $data);


file_get_contents() via PHP
$file_contents = file_get_contents('http://example.com/');

file_get_contents() via CURL
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://example.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
$file_contents = curl_exec($ch);
curl_close($ch);

trippin
02-19-2007, 04:04 PM
Still no replies? :(

mburt
02-20-2007, 04:09 PM
I got an error for using the file_get_contents method:
Fatal error: Call to undefined function: curl_init() in /usr/export/www/hosting/mburt/testing/dynamic-content.php on line 87

Twey
02-20-2007, 05:59 PM
You don't have CURL installed.