From 69e635247aa3de52391e57d6df2ea262a4419f5f Mon Sep 17 00:00:00 2001 From: nguyenanhung Date: Mon, 24 Jul 2023 10:06:40 +0700 Subject: [PATCH] Update avatar --- helpers/gravatar_helper.php | 4 ++-- helpers/request_helper.php | 14 ++++++++++---- src/BaseHelper.php | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/helpers/gravatar_helper.php b/helpers/gravatar_helper.php index 91b1981..1cd313f 100644 --- a/helpers/gravatar_helper.php +++ b/helpers/gravatar_helper.php @@ -28,7 +28,7 @@ function bear_framework_gravatar_init($username = 'nguyenanhung') $file = md5($url); $cms = &get_instance(); - $cms->load->driver('cache', ['adapter' => 'file', 'backup' => 'dummy']); + $cms->load->driver('cache', array('adapter' => 'file', 'backup' => 'dummy')); if (!$res = $cms->cache->get($file)) { $respond = sendSimpleGetRequest($url); $res = json_decode($respond, false); @@ -52,6 +52,6 @@ function bear_framework_gravatar_init($username = 'nguyenanhung') */ function bear_framework_show_gravatar($username = 'nguyenanhung', $size = 300) { - return bear_framework_gravatar_init($username)->entry[0]->thumbnailUrl . '?' . http_build_query(['size' => $size]); + return bear_framework_gravatar_init($username)->entry[0]->thumbnailUrl . '?' . http_build_query(array('size' => $size)); } } diff --git a/helpers/request_helper.php b/helpers/request_helper.php index 0131ed3..91fcddd 100644 --- a/helpers/request_helper.php +++ b/helpers/request_helper.php @@ -22,7 +22,12 @@ */ function sendSimpleGetRequest($url = '', $data = array(), $method = 'GET') { - $target = (!empty($data) && (is_array($data) || is_object($data))) ? $url . '?' . http_build_query($data) : $url; + if ((!empty($data) && (is_array($data) || is_object($data)))) { + $target = $url . '?' . http_build_query($data); + } else { + $target = $url; + } + $defaultUA = 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15'; $method = strtoupper($method); $curl = curl_init(); curl_setopt_array($curl, array( @@ -31,9 +36,10 @@ function sendSimpleGetRequest($url = '', $data = array(), $method = 'GET') CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, - CURLOPT_CUSTOMREQUEST => $method, - CURLOPT_POSTFIELDS => "", - CURLOPT_HTTPHEADER => array(), + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array($defaultUA), )); $response = curl_exec($curl); $err = curl_error($curl); diff --git a/src/BaseHelper.php b/src/BaseHelper.php index 29ae2ac..5196116 100644 --- a/src/BaseHelper.php +++ b/src/BaseHelper.php @@ -19,8 +19,8 @@ */ class BaseHelper { - const VERSION = '1.4.2'; - const LAST_MODIFIED = '2023-07-20'; + const VERSION = '1.4.3'; + const LAST_MODIFIED = '2023-07-24'; const PROJECT_NAME = 'CodeIgniter - Basic Helper'; const AUTHOR_NAME = 'Hung Nguyen'; const AUTHOR_FULL_NAME = 'Hung Nguyen';