From 050cbb350c3bcf26b445727ae2319f1b8a1bcdb5 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Fri, 9 Jan 2015 14:20:31 +0200 Subject: [PATCH] v1.0.1: 400 bad request error within execute_profile_request() has been fixed. --- libraries/Gravatar.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libraries/Gravatar.php b/libraries/Gravatar.php index 501eab3..917049d 100644 --- a/libraries/Gravatar.php +++ b/libraries/Gravatar.php @@ -8,7 +8,7 @@ * * Code repository: @link https://github.com/ivantcholakov/Codeigniter-Gravatar * - * @version 1.0 + * @version 1.0.1 * * @license The MIT License (MIT) * @link http://opensource.org/licenses/MIT @@ -231,14 +231,29 @@ public function execute_profile_request($email, $format = null) { CURLOPT_USERAGENT, $this->useragent, CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, + CURLOPT_POSTFIELDS => array(), CURLOPT_URL => $url, CURLOPT_TIMEOUT => 3, ); + if (!ini_get('safe_mode') && !ini_get('open_basedir')) { + $options[CURLOPT_FOLLOWLOCATION] = true; + } + curl_setopt_array($ch, $options); $result = curl_exec($ch); + $code = @ curl_getinfo($ch, CURLINFO_HTTP_CODE); + + @ curl_close($ch); + + if ($code != 200) { + + $this->last_error = GRAVATAR_CANT_CONNECT; + return null; + } + } elseif ($this->allow_url_fopen) { $url = $this->base_url.$this->create_hash($email).$format;