Jump to content

CURL Alternates for Users in SAFE MODE


trip

Recommended Posts

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);

$contents = curl_exec($ch);

curl_close($ch);

 

 

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);

Link to comment
https://forums.phpfreaks.com/topic/38723-curl-alternates-for-users-in-safe-mode/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.