Jump to content

cURL iställer för fopen


correadde

Recommended Posts

Hej!

 

Vårat webhotell kör med cURL och har fopen avstängd.

Så är det någon som ver hur jag ska göra för att köra prestashop med cURL istället för fopen?

 

MVH Andreas

Jag tror även Loopia har fopen stängt men trots detta fungerar det finfint. Du kan dock inte ta del av nåt flöde på förstasidan i adminpanelen men det är ju ganska strunt samma.

Edited by Noyes (see edit history)
Link to comment
Share on other sites

Jo fast problemet är att när vi laddar upp produkter med .csv filer så kommer inte bilderna upp på sidan det bör väl bero på att fopen är OFF för innan så hade vi webhotellet hos Surftown dom har fopen ON och där va det inga som hällst problem :/

 

MVH Andreas

Link to comment
Share on other sites

Ja precis sen vi bytte från surftown så fungerar ingenting riktigt irriterande :blink:

Men enligt vad jag läst så skall man visst kunna använda den koden nedan men vart skall man ändra det står ju bara "filename.php" :mellow:

 

 

It looks like the PrestaShop develoment team need to modify the filename.php as my host suggested below. The reason is that I requested my host to have a custom php.ini in my web home directory where the allow_url_fopen is set to be enabled for "Friendly URL" (see the PrestaShop wiki on External Or Friendly URLs http://www.prestasho..._Friendly_URLs/), but once the custom php.ini is put into my web's home directory /public_html/, the public access to my website becomes extremely slow where the connection to the database is basically shut down and sometimes the browser shows up "Link to database can not be established." So I requested my host to look into this slow database connection problem and the tech support replied that the slow database connection is caused by the enabled allow_url_fopen. See the detailed solution for this Friendly URL my host suggested below in the tech support reply message:

 

my host tech support's message:

 

"Hello,

 

We could see that "allow_url_fopen" and "allow_url_include" are enabled in the server which caused the issue. We disabled it. Proof is attached along with this.

 

Since URL file-access is disabled you may get some error like "URL file-access is disabled in the server configuration filename.php". Please don't enable allow_url_fopen as it is very high security risk. But you can use a function in curl instead of "file_get_contents()" which will perform the same task for you.

 

Please contact your developer and modify the code in your filename.php as

follows.

 

Instead of:

----------------------------------------------------

<?php

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

 

// display file

echo $file_contents;

?>

----------------------------------------------------

 

Use this:

----------------------------------------------------

<?php

$ch = curl_init();

$timeout = 5; // set to zero for no timeout

curl_setopt ($ch, CURLOPT_URL, 'http://example.com');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$file_contents = curl_exec($ch);

curl_close($ch);

// display file

echo $file_contents;

?>

----------------------------------------------------

 

If you are getting some errors with the code above, use this:

 

----------------------------------------------------

<?php

$site_url = 'http://example.com';

$ch = curl_init();

$timeout = 5; // set to zero for no timeout

curl_setopt ($ch, CURLOPT_URL, $site_url);

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

ob_start();

curl_exec($ch);

curl_close($ch);

$file_contents = ob_get_contents();

ob_end_clean();

echo $file_contents;

?>

----------------------------------------------------

 

In case you have any more queries, please don't hesitate to contact us with all the required details. We'll be happy to assist you further.

Link to comment
Share on other sites

Tror inte att dom menar att det finns en fil som heter filename.php som du ska ändra. Dom syftar väl snarare på vilken fil det är du har ändrat i för att ha slöat ner alltihop. Ett tips är att besöka General Discussion (engelska delen av forumet) och fråga där. Känns som du har större chans få ett vettigt svar. Lycka till!

Edited by Noyes (see edit history)
Link to comment
Share on other sites

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...