Jump to content

Use curl instead of fopen in Prestashop


Recommended Posts

Hi all.

 

Have the same problem as some other people have posted but so far I can't find anyone that have posted a solution for it.. or it might jag be me that is stupid. The problem is that "fopen" is turned off on my host (www.loopia.se) and they are aware that this causes problems with prestashop and tells you to use curl instead. So far so good - but where in all the prestashop code am I supposed to change this. Is there a smart way to make all fopen requests go via curl instead.

 

The code provided by loopia.se is as follows:

 

"You can also use the following code that replaces the PHP-funkction file_get_contents():"

 

<?php $url = "http://www.example.org/";

$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);

$contents = curl_exec($ch);

if (curl_errno($ch)) {

echo curl_error($ch);

echo "\n<br />";

$contents = '';

} else {

curl_close($ch);

}

 

if (!is_string($contents) || !strlen($contents)) {

echo "Failed to get contents.";

$contents = '';

}

echo $contents;

?>

 

I understand that this does that same thing but it there a smart way to make sure that all fopen request goes to this code instead. Well, if anyone knows this by heart - please post cause this is causing some problems for me :)

 

Best Regards . E

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...