From 217ad6106cf8fc5d79f0877fdc083edede4f612d Mon Sep 17 00:00:00 2001 From: fSerny Date: Thu, 26 Jan 2012 10:44:36 +0000 Subject: [PATCH] [-] BO : AdminModule replacing cURL by file_get_content with POST stream_context git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12708 b9a71923-0436-4b27-9f14-aed3839534dd --- .../template/controllers/modules/filters.tpl | 1 - controllers/admin/AdminModulesController.php | 38 +++++++++---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/modules/filters.tpl b/admin-dev/themes/default/template/controllers/modules/filters.tpl index d2755dde6..8c8c19fc3 100644 --- a/admin-dev/themes/default/template/controllers/modules/filters.tpl +++ b/admin-dev/themes/default/template/controllers/modules/filters.tpl @@ -32,7 +32,6 @@
{l s='If you want to be able to fully use the AdminModules pannel and have free modules available, you should enable the following configuration on your server :'}
{if $check_url_fopen eq 'ko'}- {l s='Enable allow_url_fopen'}
{/if} - {if $check_curl eq 'ko'}- {l s='Enable php curl extension'}
{/if} {if $check_openssl eq 'ko'}- {l s='Enable php openssl extension'}
{/if}
diff --git a/controllers/admin/AdminModulesController.php b/controllers/admin/AdminModulesController.php index 2f16c3e87..96270f1b1 100644 --- a/controllers/admin/AdminModulesController.php +++ b/controllers/admin/AdminModulesController.php @@ -192,27 +192,24 @@ class AdminModulesControllerCore extends AdminController } } - // Make the request - if (is_callable('curl_exec') && count($protocolsList) > 0) - { - foreach ($protocolsList as $protocol => $port) - { - // Curl Request - $ch = curl_init($protocol.$this->addons_url); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_TIMEOUT, 3); - curl_setopt($ch, CURLOPT_PORT, $port); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); - $content = curl_exec($ch); - // If content returned, we cache it - if ($content) - return $content; - } + // Make the request + $opts = array( + 'http'=>array( + 'method'=> 'POST', + 'content' => $postData, + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'timeout' => 5, + ) + ); + $context = stream_context_create($opts); + foreach ($protocolsList as $protocol => $port) + { + $content = file_get_contents($protocol.$this->addons_url, false, $context); + + // If content returned, we cache it + if ($content) + return $content; } // No content, return false @@ -1061,7 +1058,6 @@ class AdminModulesControllerCore extends AdminController $tpl_vars['list_modules_authors'] = $this->modules_authors; $tpl_vars['check_url_fopen'] = (ini_get('allow_url_fopen') ? 'ok' : 'ko'); - $tpl_vars['check_curl'] = (extension_loaded('curl') ? 'ok' : 'ko'); $tpl_vars['check_openssl'] = (extension_loaded('openssl') ? 'ok' : 'ko'); if ($this->logged_on_addons)