Skip to content

Commit

Permalink
Merge pull request #28 from nguyenanhung/develop
Browse files Browse the repository at this point in the history
Update avatar
  • Loading branch information
nguyenanhung authored Jul 24, 2023
2 parents 953a7d6 + 69e6352 commit 3fc1957
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions helpers/gravatar_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}
14 changes: 10 additions & 4 deletions helpers/request_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/BaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 3fc1957

Please sign in to comment.