@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Ion Auth Lang - Italian |
4 | 4 | * |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | // Account Creation |
18 | -$lang['account_creation_successful'] = 'Account creato con successo.'; |
|
19 | -$lang['account_creation_unsuccessful'] = 'Impossibile creare l\'account.'; |
|
20 | -$lang['account_creation_duplicate_email'] = 'Email già in uso o non valida.'; |
|
21 | -$lang['account_creation_duplicate_identity'] = 'Nome utente già in uso o non valido.'; |
|
18 | +$lang['account_creation_successful'] = 'Account creato con successo.'; |
|
19 | +$lang['account_creation_unsuccessful'] = 'Impossibile creare l\'account.'; |
|
20 | +$lang['account_creation_duplicate_email'] = 'Email già in uso o non valida.'; |
|
21 | +$lang['account_creation_duplicate_identity'] = 'Nome utente già in uso o non valido.'; |
|
22 | 22 | |
23 | 23 | // TODO Please Translate |
24 | 24 | $lang['account_creation_missing_default_group'] = 'Default group is not set'; |
@@ -27,24 +27,24 @@ discard block |
||
27 | 27 | |
28 | 28 | // Password |
29 | 29 | $lang['password_change_successful'] = 'Password modificata con successo.'; |
30 | -$lang['password_change_unsuccessful'] = 'Impossibile modificare la password.'; |
|
30 | +$lang['password_change_unsuccessful'] = 'Impossibile modificare la password.'; |
|
31 | 31 | $lang['forgot_password_successful'] = 'Email di reset della password inviata.'; |
32 | -$lang['forgot_password_unsuccessful'] = 'Impossibile resettare la password.'; |
|
32 | +$lang['forgot_password_unsuccessful'] = 'Impossibile resettare la password.'; |
|
33 | 33 | |
34 | 34 | // Activation |
35 | -$lang['activate_successful'] = 'Account attivato.'; |
|
36 | -$lang['activate_unsuccessful'] = 'Impossibile attivare l\'account.'; |
|
37 | -$lang['deactivate_successful'] = 'Account disattivato.'; |
|
38 | -$lang['deactivate_unsuccessful'] = 'Impossibile disattivare l\'account.'; |
|
39 | -$lang['activation_email_successful'] = 'Email di attivazione inviata.'; |
|
40 | -$lang['activation_email_unsuccessful'] = 'Impossibile inviare l\'email di attivazione.'; |
|
41 | -$lang['deactivate_current_user_unsuccessful']= 'You cannot De-Activate your self.'; |
|
35 | +$lang['activate_successful'] = 'Account attivato.'; |
|
36 | +$lang['activate_unsuccessful'] = 'Impossibile attivare l\'account.'; |
|
37 | +$lang['deactivate_successful'] = 'Account disattivato.'; |
|
38 | +$lang['deactivate_unsuccessful'] = 'Impossibile disattivare l\'account.'; |
|
39 | +$lang['activation_email_successful'] = 'Email di attivazione inviata.'; |
|
40 | +$lang['activation_email_unsuccessful'] = 'Impossibile inviare l\'email di attivazione.'; |
|
41 | +$lang['deactivate_current_user_unsuccessful'] = 'You cannot De-Activate your self.'; |
|
42 | 42 | |
43 | 43 | // Login / Logout |
44 | -$lang['login_successful'] = 'Login effettuato con successo.'; |
|
45 | -$lang['login_unsuccessful'] = 'Login non corretto.'; |
|
46 | -$lang['login_unsuccessful_not_active'] = 'Account is inactive'; |
|
47 | -$lang['login_timeout'] = 'Temporarily Locked Out. Try again later.'; |
|
44 | +$lang['login_successful'] = 'Login effettuato con successo.'; |
|
45 | +$lang['login_unsuccessful'] = 'Login non corretto.'; |
|
46 | +$lang['login_unsuccessful_not_active'] = 'Account is inactive'; |
|
47 | +$lang['login_timeout'] = 'Temporarily Locked Out. Try again later.'; |
|
48 | 48 | $lang['logout_successful'] = 'Logout effettuato con successo.'; |
49 | 49 | |
50 | 50 | // Account Changes |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | $lang['group_delete_successful'] = 'Group deleted'; |
61 | 61 | $lang['group_delete_unsuccessful'] = 'Unable to delete group'; |
62 | 62 | $lang['group_delete_notallowed'] = 'Can\'t delete the administrators\' group'; |
63 | -$lang['group_name_required'] = 'Group name is a required field'; |
|
63 | +$lang['group_name_required'] = 'Group name is a required field'; |
|
64 | 64 | $lang['group_name_admin_not_alter'] = 'Admin group name can not be changed'; |
65 | 65 | |
66 | 66 | // Activation Email |
67 | -$lang['email_activation_subject'] = 'Attivazione Account'; |
|
67 | +$lang['email_activation_subject'] = 'Attivazione Account'; |
|
68 | 68 | $lang['email_activate_heading'] = 'Activate account for %s'; |
69 | 69 | $lang['email_activate_subheading'] = 'Please click this link to %s.'; |
70 | 70 | $lang['email_activate_link'] = 'Activate Your Account'; |
71 | 71 | // Forgot Password Email |
72 | -$lang['email_forgotten_password_subject'] = 'Verifica il cambio password dimenticata'; |
|
72 | +$lang['email_forgotten_password_subject'] = 'Verifica il cambio password dimenticata'; |
|
73 | 73 | $lang['email_forgot_password_heading'] = 'Reset Password for %s'; |
74 | 74 | $lang['email_forgot_password_subheading'] = 'Please click this link to %s.'; |
75 | 75 | $lang['email_forgot_password_link'] = 'Reset Your Password'; |
76 | 76 | // New Password Email |
77 | -$lang['email_new_password_subject'] = 'Nuova Password'; |
|
77 | +$lang['email_new_password_subject'] = 'Nuova Password'; |
|
78 | 78 | $lang['email_new_password_heading'] = 'New Password for %s'; |
79 | 79 | $lang['email_new_password_subheading'] = 'Your password has been reset to: %s'; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Name: Ion Auth Lang - Italian |
4 | 6 | * |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Auth Lang - Italian |
4 | 4 | * |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $lang['forgot_password_username_identity_label'] = 'Username'; |
139 | 139 | $lang['forgot_password_email_identity_label'] = 'Email'; |
140 | 140 | $lang['forgot_password_email_not_found'] = 'Indirizzo email non presente nel database.'; |
141 | -$lang['forgot_password_identity_not_found'] = 'No record of that username address.'; |
|
141 | +$lang['forgot_password_identity_not_found'] = 'No record of that username address.'; |
|
142 | 142 | |
143 | 143 | // Reset Password |
144 | 144 | $lang['reset_password_heading'] = 'Cambia Password'; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Name: Auth Lang - Italian |
4 | 6 | * |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | | salt_prefix: Used for bcrypt. Versions of PHP before 5.3.7 only support "$2a$" as the salt prefix |
67 | 67 | | Versions 5.3.7 or greater should use the default of "$2y$". |
68 | 68 | */ |
69 | -$config['hash_method'] = 'bcrypt'; // sha1 or bcrypt, bcrypt is STRONGLY recommended |
|
70 | -$config['default_rounds'] = 8; // This does not apply if random_rounds is set to true |
|
69 | +$config['hash_method'] = 'bcrypt'; // sha1 or bcrypt, bcrypt is STRONGLY recommended |
|
70 | +$config['default_rounds'] = 8; // This does not apply if random_rounds is set to true |
|
71 | 71 | $config['random_rounds'] = FALSE; |
72 | 72 | $config['min_rounds'] = 5; |
73 | 73 | $config['max_rounds'] = 9; |
@@ -82,24 +82,24 @@ discard block |
||
82 | 82 | | The controller should check this function and act |
83 | 83 | | appropriately. If this variable set to 0, there is no maximum. |
84 | 84 | */ |
85 | -$config['site_title'] = "Manga Tracker"; // Site Title, example.com |
|
86 | -$config['admin_email'] = "[email protected]"; // Admin Email, [email protected] //FIXME: This is being used for a lot of things it shouldn't be. We need a diff config option. |
|
87 | -$config['default_group'] = 'members'; // Default group, use name |
|
88 | -$config['admin_group'] = 'admin'; // Default administrators group, use name |
|
89 | -$config['identity'] = 'email'; // [NOTE: username can be used too] You can use any unique column in your table as identity column. The values in this column, alongside password, will be used for login purposes |
|
90 | -$config['min_password_length'] = 6; // Minimum Required Length of Password |
|
91 | -$config['max_password_length'] = 64; // Maximum Allowed Length of Password |
|
92 | -$config['email_activation'] = FALSE; // Email Activation for registration |
|
93 | -$config['manual_activation'] = FALSE; // Manual Activation for registration |
|
94 | -$config['remember_users'] = TRUE; // Allow users to be remembered and enable auto-login |
|
85 | +$config['site_title'] = "Manga Tracker"; // Site Title, example.com |
|
86 | +$config['admin_email'] = "[email protected]"; // Admin Email, [email protected] //FIXME: This is being used for a lot of things it shouldn't be. We need a diff config option. |
|
87 | +$config['default_group'] = 'members'; // Default group, use name |
|
88 | +$config['admin_group'] = 'admin'; // Default administrators group, use name |
|
89 | +$config['identity'] = 'email'; // [NOTE: username can be used too] You can use any unique column in your table as identity column. The values in this column, alongside password, will be used for login purposes |
|
90 | +$config['min_password_length'] = 6; // Minimum Required Length of Password |
|
91 | +$config['max_password_length'] = 64; // Maximum Allowed Length of Password |
|
92 | +$config['email_activation'] = FALSE; // Email Activation for registration |
|
93 | +$config['manual_activation'] = FALSE; // Manual Activation for registration |
|
94 | +$config['remember_users'] = TRUE; // Allow users to be remembered and enable auto-login |
|
95 | 95 | $config['user_expire'] = 259200; /*3DAYS*/ // How long to remember the user (seconds). Set to zero for no expiration |
96 | -$config['user_extend_on_login'] = TRUE; // Extend the users cookies every time they auto-login |
|
97 | -$config['track_login_attempts'] = FALSE; // Track the number of failed login attempts for each user or ip. //CHECK: Should this be true? |
|
98 | -$config['track_login_ip_address'] = TRUE; // Track login attempts by IP Address, if FALSE will track based on identity. (Default: TRUE) |
|
99 | -$config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts. |
|
100 | -$config['lockout_time'] = 600; // The number of seconds to lockout an account due to exceeded attempts |
|
96 | +$config['user_extend_on_login'] = TRUE; // Extend the users cookies every time they auto-login |
|
97 | +$config['track_login_attempts'] = FALSE; // Track the number of failed login attempts for each user or ip. //CHECK: Should this be true? |
|
98 | +$config['track_login_ip_address'] = TRUE; // Track login attempts by IP Address, if FALSE will track based on identity. (Default: TRUE) |
|
99 | +$config['maximum_login_attempts'] = 3; // The maximum number of failed login attempts. |
|
100 | +$config['lockout_time'] = 600; // The number of seconds to lockout an account due to exceeded attempts |
|
101 | 101 | $config['forgot_password_expiration'] = 43200000; /*12HR*/ // The number of milliseconds after which a forgot password request will expire. If set to 0, forgot password requests will not expire. |
102 | -$config['recheck_timer'] = 0; // The number of seconds after which the session is checked again against database to see if the user still exists and is active. Leave 0 if you don't want session recheck. if you really think you need to recheck the session against database, we would recommend a higher value, as this would affect performance. |
|
102 | +$config['recheck_timer'] = 0; // The number of seconds after which the session is checked again against database to see if the user still exists and is active. Leave 0 if you don't want session recheck. if you really think you need to recheck the session against database, we would recommend a higher value, as this would affect performance. |
|
103 | 103 | |
104 | 104 | /* |
105 | 105 | | ------------------------------------------------------------------------- |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | | Message Delimiters. |
177 | 177 | | ------------------------------------------------------------------------- |
178 | 178 | */ |
179 | -$config['delimiters_source'] = 'config'; // "config" = use the settings defined here, "form_validation" = use the settings defined in CI's form validation library |
|
180 | -$config['message_start_delimiter'] = '<p>'; // Message start delimiter |
|
181 | -$config['message_end_delimiter'] = '</p>'; // Message end delimiter |
|
182 | -$config['error_start_delimiter'] = '<p>'; // Error message start delimiter |
|
183 | -$config['error_end_delimiter'] = '</p>'; // Error message end delimiter |
|
179 | +$config['delimiters_source'] = 'config'; // "config" = use the settings defined here, "form_validation" = use the settings defined in CI's form validation library |
|
180 | +$config['message_start_delimiter'] = '<p>'; // Message start delimiter |
|
181 | +$config['message_end_delimiter'] = '</p>'; // Message end delimiter |
|
182 | +$config['error_start_delimiter'] = '<p>'; // Error message start delimiter |
|
183 | +$config['error_end_delimiter'] = '</p>'; // Error message end delimiter |
|
184 | 184 | |
185 | 185 | /* End of file ion_auth.php */ |
186 | 186 | /* Location: ./application/config/ion_auth.php */ |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Ion Auth |
4 | 4 | * |
@@ -13,84 +13,84 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function __construct($params=array('rounds'=>7, 'salt_prefix'=>'$2y$')) { |
15 | 15 | |
16 | - if(CRYPT_BLOWFISH != 1) { |
|
17 | - throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt"); |
|
18 | - } |
|
16 | + if(CRYPT_BLOWFISH != 1) { |
|
17 | + throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt"); |
|
18 | + } |
|
19 | 19 | |
20 | - $this->rounds = $params['rounds']; |
|
21 | - $this->salt_prefix = $params['salt_prefix']; |
|
20 | + $this->rounds = $params['rounds']; |
|
21 | + $this->salt_prefix = $params['salt_prefix']; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function hash($input) { |
25 | - $hash = crypt($input, $this->getSalt()); |
|
25 | + $hash = crypt($input, $this->getSalt()); |
|
26 | 26 | |
27 | - if(strlen($hash) > 13) { |
|
28 | - return $hash; |
|
29 | - } |
|
27 | + if(strlen($hash) > 13) { |
|
28 | + return $hash; |
|
29 | + } |
|
30 | 30 | |
31 | - return false; |
|
31 | + return false; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param $input |
36 | 36 | * @param $existingHash |
37 | 37 | * @return bool |
38 | - */ |
|
38 | + */ |
|
39 | 39 | public function verify($input, $existingHash) { |
40 | - $hash = crypt($input, $existingHash); |
|
41 | - return $this->hashEquals($existingHash, $hash); |
|
40 | + $hash = crypt($input, $existingHash); |
|
41 | + return $this->hashEquals($existingHash, $hash); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | - * Polyfill for hash_equals() |
|
46 | - * Code mainly taken from hash_equals() compat function of CodeIgniter 3 |
|
47 | - * |
|
48 | - * @param string $known_string |
|
49 | - * @param string $user_string |
|
50 | - * @return bool |
|
51 | - */ |
|
45 | + * Polyfill for hash_equals() |
|
46 | + * Code mainly taken from hash_equals() compat function of CodeIgniter 3 |
|
47 | + * |
|
48 | + * @param string $known_string |
|
49 | + * @param string $user_string |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | 52 | private function hashEquals($known_string, $user_string) |
53 | 53 | { |
54 | - // For CI3 or PHP >= 5.6 |
|
55 | - if (function_exists('hash_equals')) |
|
56 | - { |
|
57 | - return hash_equals($known_string, $user_string); |
|
58 | - } |
|
54 | + // For CI3 or PHP >= 5.6 |
|
55 | + if (function_exists('hash_equals')) |
|
56 | + { |
|
57 | + return hash_equals($known_string, $user_string); |
|
58 | + } |
|
59 | 59 | |
60 | - // For CI2 with PHP < 5.6 |
|
61 | - // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php |
|
62 | - if ( ! is_string($known_string)) |
|
63 | - { |
|
64 | - trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING); |
|
65 | - return FALSE; |
|
66 | - } |
|
67 | - elseif ( ! is_string($user_string)) |
|
68 | - { |
|
69 | - trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING); |
|
70 | - return FALSE; |
|
71 | - } |
|
72 | - elseif (($length = strlen($known_string)) !== strlen($user_string)) |
|
73 | - { |
|
74 | - return FALSE; |
|
75 | - } |
|
76 | - |
|
77 | - $diff = 0; |
|
78 | - for ($i = 0; $i < $length; $i++) |
|
79 | - { |
|
80 | - $diff |= ord($known_string[$i]) ^ ord($user_string[$i]); |
|
81 | - } |
|
82 | - |
|
83 | - return ($diff === 0); |
|
60 | + // For CI2 with PHP < 5.6 |
|
61 | + // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php |
|
62 | + if ( ! is_string($known_string)) |
|
63 | + { |
|
64 | + trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING); |
|
65 | + return FALSE; |
|
66 | + } |
|
67 | + elseif ( ! is_string($user_string)) |
|
68 | + { |
|
69 | + trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING); |
|
70 | + return FALSE; |
|
71 | + } |
|
72 | + elseif (($length = strlen($known_string)) !== strlen($user_string)) |
|
73 | + { |
|
74 | + return FALSE; |
|
75 | + } |
|
76 | + |
|
77 | + $diff = 0; |
|
78 | + for ($i = 0; $i < $length; $i++) |
|
79 | + { |
|
80 | + $diff |= ord($known_string[$i]) ^ ord($user_string[$i]); |
|
81 | + } |
|
82 | + |
|
83 | + return ($diff === 0); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | private function getSalt() { |
87 | - $salt = sprintf($this->salt_prefix.'%02d$', $this->rounds); |
|
87 | + $salt = sprintf($this->salt_prefix.'%02d$', $this->rounds); |
|
88 | 88 | |
89 | - $bytes = $this->getRandomBytes(16); |
|
89 | + $bytes = $this->getRandomBytes(16); |
|
90 | 90 | |
91 | - $salt .= $this->encodeBytes($bytes); |
|
91 | + $salt .= $this->encodeBytes($bytes); |
|
92 | 92 | |
93 | - return $salt; |
|
93 | + return $salt; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | private $randomState; |
@@ -99,78 +99,78 @@ discard block |
||
99 | 99 | /** |
100 | 100 | * @param $count |
101 | 101 | * @return string |
102 | - */ |
|
102 | + */ |
|
103 | 103 | private function getRandomBytes($count) { |
104 | - $bytes = ''; |
|
105 | - |
|
106 | - if(function_exists('openssl_random_pseudo_bytes') && |
|
107 | - (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { // OpenSSL slow on Win |
|
108 | - $bytes = openssl_random_pseudo_bytes($count); |
|
109 | - } |
|
110 | - |
|
111 | - if($bytes === '' && @is_readable('/dev/urandom') && |
|
112 | - ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) { |
|
113 | - $bytes = fread($hRand, $count); |
|
114 | - fclose($hRand); |
|
115 | - } |
|
116 | - |
|
117 | - if(strlen($bytes) < $count) { |
|
118 | - $bytes = ''; |
|
119 | - |
|
120 | - if($this->randomState === null) { |
|
121 | - $this->randomState = microtime(); |
|
122 | - if(function_exists('getmypid')) { |
|
123 | - $this->randomState .= getmypid(); |
|
124 | - } |
|
125 | - } |
|
126 | - |
|
127 | - for($i = 0; $i < $count; $i += 16) { |
|
128 | - $this->randomState = md5(microtime() . $this->randomState); |
|
129 | - |
|
130 | - if (PHP_VERSION >= '5') { |
|
131 | - $bytes .= md5($this->randomState, true); |
|
132 | - } else { |
|
133 | - $bytes .= pack('H*', md5($this->randomState)); |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $bytes = substr($bytes, 0, $count); |
|
138 | - } |
|
139 | - |
|
140 | - return $bytes; |
|
104 | + $bytes = ''; |
|
105 | + |
|
106 | + if(function_exists('openssl_random_pseudo_bytes') && |
|
107 | + (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { // OpenSSL slow on Win |
|
108 | + $bytes = openssl_random_pseudo_bytes($count); |
|
109 | + } |
|
110 | + |
|
111 | + if($bytes === '' && @is_readable('/dev/urandom') && |
|
112 | + ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) { |
|
113 | + $bytes = fread($hRand, $count); |
|
114 | + fclose($hRand); |
|
115 | + } |
|
116 | + |
|
117 | + if(strlen($bytes) < $count) { |
|
118 | + $bytes = ''; |
|
119 | + |
|
120 | + if($this->randomState === null) { |
|
121 | + $this->randomState = microtime(); |
|
122 | + if(function_exists('getmypid')) { |
|
123 | + $this->randomState .= getmypid(); |
|
124 | + } |
|
125 | + } |
|
126 | + |
|
127 | + for($i = 0; $i < $count; $i += 16) { |
|
128 | + $this->randomState = md5(microtime() . $this->randomState); |
|
129 | + |
|
130 | + if (PHP_VERSION >= '5') { |
|
131 | + $bytes .= md5($this->randomState, true); |
|
132 | + } else { |
|
133 | + $bytes .= pack('H*', md5($this->randomState)); |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $bytes = substr($bytes, 0, $count); |
|
138 | + } |
|
139 | + |
|
140 | + return $bytes; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | 144 | * @param $input |
145 | 145 | * @return string |
146 | - */ |
|
146 | + */ |
|
147 | 147 | private function encodeBytes($input) { |
148 | - // The following is code from the PHP Password Hashing Framework |
|
149 | - $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
150 | - |
|
151 | - $output = ''; |
|
152 | - $i = 0; |
|
153 | - do { |
|
154 | - $c1 = ord($input[$i++]); |
|
155 | - $output .= $itoa64[$c1 >> 2]; |
|
156 | - $c1 = ($c1 & 0x03) << 4; |
|
157 | - if ($i >= 16) { |
|
158 | - $output .= $itoa64[$c1]; |
|
159 | - break; |
|
160 | - } |
|
161 | - |
|
162 | - $c2 = ord($input[$i++]); |
|
163 | - $c1 |= $c2 >> 4; |
|
164 | - $output .= $itoa64[$c1]; |
|
165 | - $c1 = ($c2 & 0x0f) << 2; |
|
166 | - |
|
167 | - $c2 = ord($input[$i++]); |
|
168 | - $c1 |= $c2 >> 6; |
|
169 | - $output .= $itoa64[$c1]; |
|
170 | - $output .= $itoa64[$c2 & 0x3f]; |
|
171 | - } while (1); |
|
172 | - |
|
173 | - return $output; |
|
148 | + // The following is code from the PHP Password Hashing Framework |
|
149 | + $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
150 | + |
|
151 | + $output = ''; |
|
152 | + $i = 0; |
|
153 | + do { |
|
154 | + $c1 = ord($input[$i++]); |
|
155 | + $output .= $itoa64[$c1 >> 2]; |
|
156 | + $c1 = ($c1 & 0x03) << 4; |
|
157 | + if ($i >= 16) { |
|
158 | + $output .= $itoa64[$c1]; |
|
159 | + break; |
|
160 | + } |
|
161 | + |
|
162 | + $c2 = ord($input[$i++]); |
|
163 | + $c1 |= $c2 >> 4; |
|
164 | + $output .= $itoa64[$c1]; |
|
165 | + $c1 = ($c2 & 0x0f) << 2; |
|
166 | + |
|
167 | + $c2 = ord($input[$i++]); |
|
168 | + $c1 |= $c2 >> 6; |
|
169 | + $output .= $itoa64[$c1]; |
|
170 | + $output .= $itoa64[$c2 & 0x3f]; |
|
171 | + } while (1); |
|
172 | + |
|
173 | + return $output; |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | |
4 | 4 | class Bcrypt { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param array $params |
12 | 12 | * @throws Exception |
13 | 13 | */ |
14 | - public function __construct($params=array('rounds'=>7, 'salt_prefix'=>'$2y$')) { |
|
14 | + public function __construct($params = array('rounds'=>7, 'salt_prefix'=>'$2y$')) { |
|
15 | 15 | |
16 | 16 | if(CRYPT_BLOWFISH != 1) { |
17 | 17 | throw new Exception("bcrypt not supported in this installation. See http://php.net/crypt"); |
@@ -52,30 +52,30 @@ discard block |
||
52 | 52 | private function hashEquals($known_string, $user_string) |
53 | 53 | { |
54 | 54 | // For CI3 or PHP >= 5.6 |
55 | - if (function_exists('hash_equals')) |
|
55 | + if(function_exists('hash_equals')) |
|
56 | 56 | { |
57 | 57 | return hash_equals($known_string, $user_string); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // For CI2 with PHP < 5.6 |
61 | 61 | // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php |
62 | - if ( ! is_string($known_string)) |
|
62 | + if(!is_string($known_string)) |
|
63 | 63 | { |
64 | 64 | trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING); |
65 | 65 | return FALSE; |
66 | 66 | } |
67 | - elseif ( ! is_string($user_string)) |
|
67 | + elseif(!is_string($user_string)) |
|
68 | 68 | { |
69 | 69 | trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING); |
70 | 70 | return FALSE; |
71 | 71 | } |
72 | - elseif (($length = strlen($known_string)) !== strlen($user_string)) |
|
72 | + elseif(($length = strlen($known_string)) !== strlen($user_string)) |
|
73 | 73 | { |
74 | 74 | return FALSE; |
75 | 75 | } |
76 | 76 | |
77 | 77 | $diff = 0; |
78 | - for ($i = 0; $i < $length; $i++) |
|
78 | + for($i = 0; $i < $length; $i++) |
|
79 | 79 | { |
80 | 80 | $diff |= ord($known_string[$i]) ^ ord($user_string[$i]); |
81 | 81 | } |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | for($i = 0; $i < $count; $i += 16) { |
128 | - $this->randomState = md5(microtime() . $this->randomState); |
|
128 | + $this->randomState = md5(microtime().$this->randomState); |
|
129 | 129 | |
130 | - if (PHP_VERSION >= '5') { |
|
130 | + if(PHP_VERSION >= '5') { |
|
131 | 131 | $bytes .= md5($this->randomState, true); |
132 | 132 | } else { |
133 | 133 | $bytes .= pack('H*', md5($this->randomState)); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | $c1 = ord($input[$i++]); |
155 | 155 | $output .= $itoa64[$c1 >> 2]; |
156 | 156 | $c1 = ($c1 & 0x03) << 4; |
157 | - if ($i >= 16) { |
|
157 | + if($i >= 16) { |
|
158 | 158 | $output .= $itoa64[$c1]; |
159 | 159 | break; |
160 | 160 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $c1 |= $c2 >> 6; |
169 | 169 | $output .= $itoa64[$c1]; |
170 | 170 | $output .= $itoa64[$c2 & 0x3f]; |
171 | - } while (1); |
|
171 | + } while(1); |
|
172 | 172 | |
173 | 173 | return $output; |
174 | 174 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | |
4 | 6 | class Bcrypt { |
@@ -49,34 +51,26 @@ discard block |
||
49 | 51 | * @param string $user_string |
50 | 52 | * @return bool |
51 | 53 | */ |
52 | - private function hashEquals($known_string, $user_string) |
|
53 | - { |
|
54 | + private function hashEquals($known_string, $user_string) { |
|
54 | 55 | // For CI3 or PHP >= 5.6 |
55 | - if (function_exists('hash_equals')) |
|
56 | - { |
|
56 | + if (function_exists('hash_equals')) { |
|
57 | 57 | return hash_equals($known_string, $user_string); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // For CI2 with PHP < 5.6 |
61 | 61 | // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php |
62 | - if ( ! is_string($known_string)) |
|
63 | - { |
|
62 | + if ( ! is_string($known_string)) { |
|
64 | 63 | trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING); |
65 | 64 | return FALSE; |
66 | - } |
|
67 | - elseif ( ! is_string($user_string)) |
|
68 | - { |
|
65 | + } elseif ( ! is_string($user_string)) { |
|
69 | 66 | trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING); |
70 | 67 | return FALSE; |
71 | - } |
|
72 | - elseif (($length = strlen($known_string)) !== strlen($user_string)) |
|
73 | - { |
|
68 | + } elseif (($length = strlen($known_string)) !== strlen($user_string)) { |
|
74 | 69 | return FALSE; |
75 | 70 | } |
76 | 71 | |
77 | 72 | $diff = 0; |
78 | - for ($i = 0; $i < $length; $i++) |
|
79 | - { |
|
73 | + for ($i = 0; $i < $length; $i++) { |
|
80 | 74 | $diff |= ord($known_string[$i]) ^ ord($user_string[$i]); |
81 | 75 | } |
82 | 76 | |
@@ -104,7 +98,8 @@ discard block |
||
104 | 98 | $bytes = ''; |
105 | 99 | |
106 | 100 | if(function_exists('openssl_random_pseudo_bytes') && |
107 | - (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { // OpenSSL slow on Win |
|
101 | + (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { |
|
102 | +// OpenSSL slow on Win |
|
108 | 103 | $bytes = openssl_random_pseudo_bytes($count); |
109 | 104 | } |
110 | 105 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return $hash; |
29 | 29 | } |
30 | 30 | |
31 | - return false; |
|
31 | + return FALSE; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if(strlen($bytes) < $count) { |
118 | 118 | $bytes = ''; |
119 | 119 | |
120 | - if($this->randomState === null) { |
|
120 | + if($this->randomState === NULL) { |
|
121 | 121 | $this->randomState = microtime(); |
122 | 122 | if(function_exists('getmypid')) { |
123 | 123 | $this->randomState .= getmypid(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $this->randomState = md5(microtime() . $this->randomState); |
129 | 129 | |
130 | 130 | if (PHP_VERSION >= '5') { |
131 | - $bytes .= md5($this->randomState, true); |
|
131 | + $bytes .= md5($this->randomState, TRUE); |
|
132 | 132 | } else { |
133 | 133 | $bytes .= pack('H*', md5($this->randomState)); |
134 | 134 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Sekati CodeIgniter Asset Helper |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @return string |
52 | 52 | */ |
53 | 53 | |
54 | -if (!function_exists('asset_url')) { |
|
54 | +if(!function_exists('asset_url')) { |
|
55 | 55 | function asset_url() |
56 | 56 | { |
57 | 57 | //get an instance of CI so we can access our configuration |
58 | - $CI =& get_instance(); |
|
58 | + $CI = & get_instance(); |
|
59 | 59 | |
60 | 60 | //return the full asset path |
61 | 61 | return $CI->config->slash_item('static_url')/* . $CI->config->item('asset_path')*/; |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | * @access public |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -if (!function_exists('css_url')) { |
|
71 | +if(!function_exists('css_url')) { |
|
72 | 72 | function css_url() |
73 | 73 | { |
74 | - $CI =& get_instance(); |
|
74 | + $CI = & get_instance(); |
|
75 | 75 | |
76 | - return $CI->config->slash_item('static_url') . $CI->config->item('css_path'); |
|
76 | + return $CI->config->slash_item('static_url').$CI->config->item('css_path'); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * @access public |
84 | 84 | * @return string |
85 | 85 | */ |
86 | -if (!function_exists('less_url')) { |
|
86 | +if(!function_exists('less_url')) { |
|
87 | 87 | function less_url() |
88 | 88 | { |
89 | - $CI =& get_instance(); |
|
89 | + $CI = & get_instance(); |
|
90 | 90 | |
91 | - return $CI->config->slash_item('static_url') . $CI->config->item('less_path'); |
|
91 | + return $CI->config->slash_item('static_url').$CI->config->item('less_path'); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | * @access public |
99 | 99 | * @return string |
100 | 100 | */ |
101 | -if (!function_exists('js_url')) { |
|
101 | +if(!function_exists('js_url')) { |
|
102 | 102 | function js_url() |
103 | 103 | { |
104 | - $CI =& get_instance(); |
|
104 | + $CI = & get_instance(); |
|
105 | 105 | |
106 | - return $CI->config->slash_item('static_url') . $CI->config->item('js_path'); |
|
106 | + return $CI->config->slash_item('static_url').$CI->config->item('js_path'); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | * @access public |
114 | 114 | * @return string |
115 | 115 | */ |
116 | -if (!function_exists('img_url')) { |
|
116 | +if(!function_exists('img_url')) { |
|
117 | 117 | function img_url() |
118 | 118 | { |
119 | - $CI =& get_instance(); |
|
119 | + $CI = & get_instance(); |
|
120 | 120 | |
121 | - return $CI->config->slash_item('static_url') . $CI->config->item('img_path'); |
|
121 | + return $CI->config->slash_item('static_url').$CI->config->item('img_path'); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | * @access public |
129 | 129 | * @return string |
130 | 130 | */ |
131 | -if (!function_exists('swf_url')) { |
|
131 | +if(!function_exists('swf_url')) { |
|
132 | 132 | function swf_url() |
133 | 133 | { |
134 | - $CI =& get_instance(); |
|
134 | + $CI = & get_instance(); |
|
135 | 135 | |
136 | - return $CI->config->slash_item('static_url') . $CI->config->item('swf_path'); |
|
136 | + return $CI->config->slash_item('static_url').$CI->config->item('swf_path'); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | * @access public |
144 | 144 | * @return string |
145 | 145 | */ |
146 | -if (!function_exists('upload_url')) { |
|
146 | +if(!function_exists('upload_url')) { |
|
147 | 147 | function upload_url() |
148 | 148 | { |
149 | - $CI =& get_instance(); |
|
149 | + $CI = & get_instance(); |
|
150 | 150 | |
151 | - return base_url() . $CI->config->item('upload_path'); |
|
151 | + return base_url().$CI->config->item('upload_path'); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | * @access public |
159 | 159 | * @return string |
160 | 160 | */ |
161 | -if (!function_exists('download_url')) { |
|
161 | +if(!function_exists('download_url')) { |
|
162 | 162 | function download_url() |
163 | 163 | { |
164 | - $CI =& get_instance(); |
|
164 | + $CI = & get_instance(); |
|
165 | 165 | |
166 | - return base_url() . $CI->config->item('download_path'); |
|
166 | + return base_url().$CI->config->item('download_path'); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * @access public |
174 | 174 | * @return string |
175 | 175 | */ |
176 | -if (!function_exists('xml_url')) { |
|
176 | +if(!function_exists('xml_url')) { |
|
177 | 177 | function xml_url() |
178 | 178 | { |
179 | - $CI =& get_instance(); |
|
179 | + $CI = & get_instance(); |
|
180 | 180 | |
181 | - return base_url() . $CI->config->item('xml_path'); |
|
181 | + return base_url().$CI->config->item('xml_path'); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @access public |
193 | 193 | * @return string |
194 | 194 | */ |
195 | -if (!function_exists('asset_path')) { |
|
195 | +if(!function_exists('asset_path')) { |
|
196 | 196 | function asset_path() |
197 | 197 | { |
198 | 198 | //get an instance of CI so we can access our configuration |
199 | - $CI =& get_instance(); |
|
199 | + $CI = & get_instance(); |
|
200 | 200 | |
201 | - return FCPATH . $CI->config->item('asset_path'); |
|
201 | + return FCPATH.$CI->config->item('asset_path'); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @access public |
209 | 209 | * @return string |
210 | 210 | */ |
211 | -if (!function_exists('css_path')) { |
|
211 | +if(!function_exists('css_path')) { |
|
212 | 212 | function css_path() |
213 | 213 | { |
214 | 214 | //get an instance of CI so we can access our configuration |
215 | - $CI =& get_instance(); |
|
215 | + $CI = & get_instance(); |
|
216 | 216 | |
217 | - return FCPATH . $CI->config->item('css_path'); |
|
217 | + return FCPATH.$CI->config->item('css_path'); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | * @access public |
225 | 225 | * @return string |
226 | 226 | */ |
227 | -if (!function_exists('less_path')) { |
|
227 | +if(!function_exists('less_path')) { |
|
228 | 228 | function less_path() |
229 | 229 | { |
230 | 230 | //get an instance of CI so we can access our configuration |
231 | - $CI =& get_instance(); |
|
231 | + $CI = & get_instance(); |
|
232 | 232 | |
233 | - return FCPATH . $CI->config->item('less_path'); |
|
233 | + return FCPATH.$CI->config->item('less_path'); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | * @access public |
241 | 241 | * @return string |
242 | 242 | */ |
243 | -if (!function_exists('js_path')) { |
|
243 | +if(!function_exists('js_path')) { |
|
244 | 244 | function js_path() |
245 | 245 | { |
246 | 246 | //get an instance of CI so we can access our configuration |
247 | - $CI =& get_instance(); |
|
247 | + $CI = & get_instance(); |
|
248 | 248 | |
249 | - return FCPATH . $CI->config->item('js_path'); |
|
249 | + return FCPATH.$CI->config->item('js_path'); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | * @access public |
257 | 257 | * @return string |
258 | 258 | */ |
259 | -if (!function_exists('img_path')) { |
|
259 | +if(!function_exists('img_path')) { |
|
260 | 260 | function img_path() |
261 | 261 | { |
262 | 262 | //get an instance of CI so we can access our configuration |
263 | - $CI =& get_instance(); |
|
263 | + $CI = & get_instance(); |
|
264 | 264 | |
265 | - return FCPATH . $CI->config->item('img_path'); |
|
265 | + return FCPATH.$CI->config->item('img_path'); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | * @access public |
273 | 273 | * @return string |
274 | 274 | */ |
275 | -if (!function_exists('swf_path')) { |
|
275 | +if(!function_exists('swf_path')) { |
|
276 | 276 | function swf_path() |
277 | 277 | { |
278 | - $CI =& get_instance(); |
|
278 | + $CI = & get_instance(); |
|
279 | 279 | |
280 | - return FCPATH . $CI->config->item('swf_path'); |
|
280 | + return FCPATH.$CI->config->item('swf_path'); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | * @access public |
288 | 288 | * @return string |
289 | 289 | */ |
290 | -if (!function_exists('xml_path')) { |
|
290 | +if(!function_exists('xml_path')) { |
|
291 | 291 | function xml_path() |
292 | 292 | { |
293 | - $CI =& get_instance(); |
|
293 | + $CI = & get_instance(); |
|
294 | 294 | |
295 | - return FCPATH . $CI->config->item('xml_path'); |
|
295 | + return FCPATH.$CI->config->item('xml_path'); |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * @access public |
303 | 303 | * @return string |
304 | 304 | */ |
305 | -if (!function_exists('upload_path')) { |
|
305 | +if(!function_exists('upload_path')) { |
|
306 | 306 | function upload_path() |
307 | 307 | { |
308 | - $CI =& get_instance(); |
|
308 | + $CI = & get_instance(); |
|
309 | 309 | |
310 | - return FCPATH . $CI->config->item('upload_path'); |
|
310 | + return FCPATH.$CI->config->item('upload_path'); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | * @access public |
318 | 318 | * @return string |
319 | 319 | */ |
320 | -if (!function_exists('upload_path_relative')) { |
|
320 | +if(!function_exists('upload_path_relative')) { |
|
321 | 321 | function upload_path_relative() |
322 | 322 | { |
323 | - $CI =& get_instance(); |
|
323 | + $CI = & get_instance(); |
|
324 | 324 | |
325 | - return './' . $CI->config->item('upload_path'); |
|
325 | + return './'.$CI->config->item('upload_path'); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
@@ -332,12 +332,12 @@ discard block |
||
332 | 332 | * @access public |
333 | 333 | * @return string |
334 | 334 | */ |
335 | -if (!function_exists('download_path')) { |
|
335 | +if(!function_exists('download_path')) { |
|
336 | 336 | function download_path() |
337 | 337 | { |
338 | - $CI =& get_instance(); |
|
338 | + $CI = & get_instance(); |
|
339 | 339 | |
340 | - return FCPATH . $CI->config->item('download_path'); |
|
340 | + return FCPATH.$CI->config->item('download_path'); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
@@ -347,12 +347,12 @@ discard block |
||
347 | 347 | * @access public |
348 | 348 | * @return string |
349 | 349 | */ |
350 | -if (!function_exists('download_path_relative')) { |
|
350 | +if(!function_exists('download_path_relative')) { |
|
351 | 351 | function download_path_relative() |
352 | 352 | { |
353 | - $CI =& get_instance(); |
|
353 | + $CI = & get_instance(); |
|
354 | 354 | |
355 | - return './' . $CI->config->item('download_path'); |
|
355 | + return './'.$CI->config->item('download_path'); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @return string |
371 | 371 | */ |
372 | -if (!function_exists('css')) { |
|
372 | +if(!function_exists('css')) { |
|
373 | 373 | function css($file, $media = 'all') |
374 | 374 | { |
375 | - return '<link rel="stylesheet" type="text/css" href="' . css_url() . $file . '" media="' . $media . '">' . "\n"; |
|
375 | + return '<link rel="stylesheet" type="text/css" href="'.css_url().$file.'" media="'.$media.'">'."\n"; |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | |
@@ -385,10 +385,10 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return string |
387 | 387 | */ |
388 | -if (!function_exists('less')) { |
|
388 | +if(!function_exists('less')) { |
|
389 | 389 | function less($file) |
390 | 390 | { |
391 | - return '<link rel="stylesheet/less" type="text/css" href="' . less_url() . $file . '">' . "\n"; |
|
391 | + return '<link rel="stylesheet/less" type="text/css" href="'.less_url().$file.'">'."\n"; |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -402,14 +402,14 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return string |
404 | 404 | */ |
405 | -if (!function_exists('js')) { |
|
405 | +if(!function_exists('js')) { |
|
406 | 406 | function js($file, $atts = array()) |
407 | 407 | { |
408 | - $element = '<script type="text/javascript" src="' . js_url() . $file . '"'; |
|
408 | + $element = '<script type="text/javascript" src="'.js_url().$file.'"'; |
|
409 | 409 | |
410 | - foreach ($atts as $key => $val) |
|
411 | - $element .= ' ' . $key . '="' . $val . '"'; |
|
412 | - $element .= '></script>' . "\n"; |
|
410 | + foreach($atts as $key => $val) |
|
411 | + $element .= ' '.$key.'="'.$val.'"'; |
|
412 | + $element .= '></script>'."\n"; |
|
413 | 413 | |
414 | 414 | return $element; |
415 | 415 | } |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return string |
427 | 427 | */ |
428 | -if (!function_exists('img')) { |
|
428 | +if(!function_exists('img')) { |
|
429 | 429 | function img($file, $atts = array()) |
430 | 430 | { |
431 | - $url = '<img src="' . img_url() . $file . '"'; |
|
432 | - foreach ($atts as $key => $val) |
|
433 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
431 | + $url = '<img src="'.img_url().$file.'"'; |
|
432 | + foreach($atts as $key => $val) |
|
433 | + $url .= ' '.$key.'="'.$val.'"'; |
|
434 | 434 | $url .= " />\n"; |
435 | 435 | |
436 | 436 | return $url; |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | * |
447 | 447 | * @return string |
448 | 448 | */ |
449 | -if (!function_exists('jquery')) { |
|
449 | +if(!function_exists('jquery')) { |
|
450 | 450 | function jquery($version = '') |
451 | 451 | { |
452 | 452 | // Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline |
453 | - $out = '<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js"></script>' . "\n"; |
|
454 | - $out .= '<script>window.jQuery || document.write(\'<script src="' . js_url() . 'jquery-' . $version . '.min.js"><\/script>\')</script>' . "\n"; |
|
453 | + $out = '<script src="//ajax.googleapis.com/ajax/libs/jquery/'.$version.'/jquery.min.js"></script>'."\n"; |
|
454 | + $out .= '<script>window.jQuery || document.write(\'<script src="'.js_url().'jquery-'.$version.'.min.js"><\/script>\')</script>'."\n"; |
|
455 | 455 | |
456 | 456 | return $out; |
457 | 457 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return string |
468 | 468 | */ |
469 | -if (!function_exists('google_analytics')) { |
|
469 | +if(!function_exists('google_analytics')) { |
|
470 | 470 | function google_analytics($ua = '') |
471 | 471 | { |
472 | 472 | // Change UA-XXXXX-X to be your site's ID |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** |
4 | 6 | * Sekati CodeIgniter Asset Helper |
@@ -52,8 +54,7 @@ discard block |
||
52 | 54 | */ |
53 | 55 | |
54 | 56 | if (!function_exists('asset_url')) { |
55 | - function asset_url() |
|
56 | - { |
|
57 | + function asset_url() { |
|
57 | 58 | //get an instance of CI so we can access our configuration |
58 | 59 | $CI =& get_instance(); |
59 | 60 | |
@@ -69,8 +70,7 @@ discard block |
||
69 | 70 | * @return string |
70 | 71 | */ |
71 | 72 | if (!function_exists('css_url')) { |
72 | - function css_url() |
|
73 | - { |
|
73 | + function css_url() { |
|
74 | 74 | $CI =& get_instance(); |
75 | 75 | |
76 | 76 | return $CI->config->slash_item('static_url') . $CI->config->item('css_path'); |
@@ -84,8 +84,7 @@ discard block |
||
84 | 84 | * @return string |
85 | 85 | */ |
86 | 86 | if (!function_exists('less_url')) { |
87 | - function less_url() |
|
88 | - { |
|
87 | + function less_url() { |
|
89 | 88 | $CI =& get_instance(); |
90 | 89 | |
91 | 90 | return $CI->config->slash_item('static_url') . $CI->config->item('less_path'); |
@@ -99,8 +98,7 @@ discard block |
||
99 | 98 | * @return string |
100 | 99 | */ |
101 | 100 | if (!function_exists('js_url')) { |
102 | - function js_url() |
|
103 | - { |
|
101 | + function js_url() { |
|
104 | 102 | $CI =& get_instance(); |
105 | 103 | |
106 | 104 | return $CI->config->slash_item('static_url') . $CI->config->item('js_path'); |
@@ -114,8 +112,7 @@ discard block |
||
114 | 112 | * @return string |
115 | 113 | */ |
116 | 114 | if (!function_exists('img_url')) { |
117 | - function img_url() |
|
118 | - { |
|
115 | + function img_url() { |
|
119 | 116 | $CI =& get_instance(); |
120 | 117 | |
121 | 118 | return $CI->config->slash_item('static_url') . $CI->config->item('img_path'); |
@@ -129,8 +126,7 @@ discard block |
||
129 | 126 | * @return string |
130 | 127 | */ |
131 | 128 | if (!function_exists('swf_url')) { |
132 | - function swf_url() |
|
133 | - { |
|
129 | + function swf_url() { |
|
134 | 130 | $CI =& get_instance(); |
135 | 131 | |
136 | 132 | return $CI->config->slash_item('static_url') . $CI->config->item('swf_path'); |
@@ -144,8 +140,7 @@ discard block |
||
144 | 140 | * @return string |
145 | 141 | */ |
146 | 142 | if (!function_exists('upload_url')) { |
147 | - function upload_url() |
|
148 | - { |
|
143 | + function upload_url() { |
|
149 | 144 | $CI =& get_instance(); |
150 | 145 | |
151 | 146 | return base_url() . $CI->config->item('upload_path'); |
@@ -159,8 +154,7 @@ discard block |
||
159 | 154 | * @return string |
160 | 155 | */ |
161 | 156 | if (!function_exists('download_url')) { |
162 | - function download_url() |
|
163 | - { |
|
157 | + function download_url() { |
|
164 | 158 | $CI =& get_instance(); |
165 | 159 | |
166 | 160 | return base_url() . $CI->config->item('download_path'); |
@@ -174,8 +168,7 @@ discard block |
||
174 | 168 | * @return string |
175 | 169 | */ |
176 | 170 | if (!function_exists('xml_url')) { |
177 | - function xml_url() |
|
178 | - { |
|
171 | + function xml_url() { |
|
179 | 172 | $CI =& get_instance(); |
180 | 173 | |
181 | 174 | return base_url() . $CI->config->item('xml_path'); |
@@ -193,8 +186,7 @@ discard block |
||
193 | 186 | * @return string |
194 | 187 | */ |
195 | 188 | if (!function_exists('asset_path')) { |
196 | - function asset_path() |
|
197 | - { |
|
189 | + function asset_path() { |
|
198 | 190 | //get an instance of CI so we can access our configuration |
199 | 191 | $CI =& get_instance(); |
200 | 192 | |
@@ -209,8 +201,7 @@ discard block |
||
209 | 201 | * @return string |
210 | 202 | */ |
211 | 203 | if (!function_exists('css_path')) { |
212 | - function css_path() |
|
213 | - { |
|
204 | + function css_path() { |
|
214 | 205 | //get an instance of CI so we can access our configuration |
215 | 206 | $CI =& get_instance(); |
216 | 207 | |
@@ -225,8 +216,7 @@ discard block |
||
225 | 216 | * @return string |
226 | 217 | */ |
227 | 218 | if (!function_exists('less_path')) { |
228 | - function less_path() |
|
229 | - { |
|
219 | + function less_path() { |
|
230 | 220 | //get an instance of CI so we can access our configuration |
231 | 221 | $CI =& get_instance(); |
232 | 222 | |
@@ -241,8 +231,7 @@ discard block |
||
241 | 231 | * @return string |
242 | 232 | */ |
243 | 233 | if (!function_exists('js_path')) { |
244 | - function js_path() |
|
245 | - { |
|
234 | + function js_path() { |
|
246 | 235 | //get an instance of CI so we can access our configuration |
247 | 236 | $CI =& get_instance(); |
248 | 237 | |
@@ -257,8 +246,7 @@ discard block |
||
257 | 246 | * @return string |
258 | 247 | */ |
259 | 248 | if (!function_exists('img_path')) { |
260 | - function img_path() |
|
261 | - { |
|
249 | + function img_path() { |
|
262 | 250 | //get an instance of CI so we can access our configuration |
263 | 251 | $CI =& get_instance(); |
264 | 252 | |
@@ -273,8 +261,7 @@ discard block |
||
273 | 261 | * @return string |
274 | 262 | */ |
275 | 263 | if (!function_exists('swf_path')) { |
276 | - function swf_path() |
|
277 | - { |
|
264 | + function swf_path() { |
|
278 | 265 | $CI =& get_instance(); |
279 | 266 | |
280 | 267 | return FCPATH . $CI->config->item('swf_path'); |
@@ -288,8 +275,7 @@ discard block |
||
288 | 275 | * @return string |
289 | 276 | */ |
290 | 277 | if (!function_exists('xml_path')) { |
291 | - function xml_path() |
|
292 | - { |
|
278 | + function xml_path() { |
|
293 | 279 | $CI =& get_instance(); |
294 | 280 | |
295 | 281 | return FCPATH . $CI->config->item('xml_path'); |
@@ -303,8 +289,7 @@ discard block |
||
303 | 289 | * @return string |
304 | 290 | */ |
305 | 291 | if (!function_exists('upload_path')) { |
306 | - function upload_path() |
|
307 | - { |
|
292 | + function upload_path() { |
|
308 | 293 | $CI =& get_instance(); |
309 | 294 | |
310 | 295 | return FCPATH . $CI->config->item('upload_path'); |
@@ -318,8 +303,7 @@ discard block |
||
318 | 303 | * @return string |
319 | 304 | */ |
320 | 305 | if (!function_exists('upload_path_relative')) { |
321 | - function upload_path_relative() |
|
322 | - { |
|
306 | + function upload_path_relative() { |
|
323 | 307 | $CI =& get_instance(); |
324 | 308 | |
325 | 309 | return './' . $CI->config->item('upload_path'); |
@@ -333,8 +317,7 @@ discard block |
||
333 | 317 | * @return string |
334 | 318 | */ |
335 | 319 | if (!function_exists('download_path')) { |
336 | - function download_path() |
|
337 | - { |
|
320 | + function download_path() { |
|
338 | 321 | $CI =& get_instance(); |
339 | 322 | |
340 | 323 | return FCPATH . $CI->config->item('download_path'); |
@@ -348,8 +331,7 @@ discard block |
||
348 | 331 | * @return string |
349 | 332 | */ |
350 | 333 | if (!function_exists('download_path_relative')) { |
351 | - function download_path_relative() |
|
352 | - { |
|
334 | + function download_path_relative() { |
|
353 | 335 | $CI =& get_instance(); |
354 | 336 | |
355 | 337 | return './' . $CI->config->item('download_path'); |
@@ -370,8 +352,7 @@ discard block |
||
370 | 352 | * @return string |
371 | 353 | */ |
372 | 354 | if (!function_exists('css')) { |
373 | - function css($file, $media = 'all') |
|
374 | - { |
|
355 | + function css($file, $media = 'all') { |
|
375 | 356 | return '<link rel="stylesheet" type="text/css" href="' . css_url() . $file . '" media="' . $media . '">' . "\n"; |
376 | 357 | } |
377 | 358 | } |
@@ -386,8 +367,7 @@ discard block |
||
386 | 367 | * @return string |
387 | 368 | */ |
388 | 369 | if (!function_exists('less')) { |
389 | - function less($file) |
|
390 | - { |
|
370 | + function less($file) { |
|
391 | 371 | return '<link rel="stylesheet/less" type="text/css" href="' . less_url() . $file . '">' . "\n"; |
392 | 372 | } |
393 | 373 | } |
@@ -403,12 +383,12 @@ discard block |
||
403 | 383 | * @return string |
404 | 384 | */ |
405 | 385 | if (!function_exists('js')) { |
406 | - function js($file, $atts = array()) |
|
407 | - { |
|
386 | + function js($file, $atts = array()) { |
|
408 | 387 | $element = '<script type="text/javascript" src="' . js_url() . $file . '"'; |
409 | 388 | |
410 | - foreach ($atts as $key => $val) |
|
411 | - $element .= ' ' . $key . '="' . $val . '"'; |
|
389 | + foreach ($atts as $key => $val) { |
|
390 | + $element .= ' ' . $key . '="' . $val . '"'; |
|
391 | + } |
|
412 | 392 | $element .= '></script>' . "\n"; |
413 | 393 | |
414 | 394 | return $element; |
@@ -426,11 +406,11 @@ discard block |
||
426 | 406 | * @return string |
427 | 407 | */ |
428 | 408 | if (!function_exists('img')) { |
429 | - function img($file, $atts = array()) |
|
430 | - { |
|
409 | + function img($file, $atts = array()) { |
|
431 | 410 | $url = '<img src="' . img_url() . $file . '"'; |
432 | - foreach ($atts as $key => $val) |
|
433 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
411 | + foreach ($atts as $key => $val) { |
|
412 | + $url .= ' ' . $key . '="' . $val . '"'; |
|
413 | + } |
|
434 | 414 | $url .= " />\n"; |
435 | 415 | |
436 | 416 | return $url; |
@@ -447,8 +427,7 @@ discard block |
||
447 | 427 | * @return string |
448 | 428 | */ |
449 | 429 | if (!function_exists('jquery')) { |
450 | - function jquery($version = '') |
|
451 | - { |
|
430 | + function jquery($version = '') { |
|
452 | 431 | // Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline |
453 | 432 | $out = '<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js"></script>' . "\n"; |
454 | 433 | $out .= '<script>window.jQuery || document.write(\'<script src="' . js_url() . 'jquery-' . $version . '.min.js"><\/script>\')</script>' . "\n"; |
@@ -467,8 +446,7 @@ discard block |
||
467 | 446 | * @return string |
468 | 447 | */ |
469 | 448 | if (!function_exists('google_analytics')) { |
470 | - function google_analytics($ua = '') |
|
471 | - { |
|
449 | + function google_analytics($ua = '') { |
|
472 | 450 | // Change UA-XXXXX-X to be your site's ID |
473 | 451 | $out = "<!-- Google Webmaster Tools & Analytics -->\n"; |
474 | 452 | $out .= '<script type="text/javascript">'; |
@@ -11,14 +11,14 @@ |
||
11 | 11 | |
12 | 12 | $config['gravatar_base_url'] = 'http://www.gravatar.com/'; |
13 | 13 | $config['gravatar_secure_base_url'] = 'https://secure.gravatar.com/'; |
14 | -$config['gravatar_image_extension'] = '.png'; // '', '.png' or '.jpg'. |
|
14 | +$config['gravatar_image_extension'] = '.png'; // '', '.png' or '.jpg'. |
|
15 | 15 | $config['gravatar_image_size'] = 44; |
16 | 16 | |
17 | 17 | $config['gravatar_default_image'] = 'identicon'; // '', '404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'. |
18 | 18 | //$config['gravatar_default_image'] = BASE_URL.'assets/img/lib/default-person.png'; // Another possible option: a custon image. |
19 | 19 | |
20 | 20 | $config['gravatar_force_default_image'] = false; |
21 | -$config['gravatar_rating'] = ''; // '', 'g' (default), 'pg', 'r', 'x'. |
|
21 | +$config['gravatar_rating'] = ''; // '', 'g' (default), 'pg', 'r', 'x'. |
|
22 | 22 | |
23 | 23 | // Useragent string for server-made requests. |
24 | 24 | // It is for not getting 403 forbidden response. |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Gravatar Library for CodeIgniter - Configuration |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $config['gravatar_default_image'] = 'identicon'; // '', '404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'. |
18 | 18 | //$config['gravatar_default_image'] = BASE_URL.'assets/img/lib/default-person.png'; // Another possible option: a custon image. |
19 | 19 | |
20 | -$config['gravatar_force_default_image'] = false; |
|
20 | +$config['gravatar_force_default_image'] = FALSE; |
|
21 | 21 | $config['gravatar_rating'] = ''; // '', 'g' (default), 'pg', 'r', 'x'. |
22 | 22 | |
23 | 23 | // Useragent string for server-made requests. |
@@ -23,487 +23,487 @@ |
||
23 | 23 | |
24 | 24 | class Gravatar { |
25 | 25 | |
26 | - protected $defaults; |
|
27 | - |
|
28 | - protected $gravatar_base_url; |
|
29 | - protected $gravatar_secure_base_url; |
|
30 | - protected $gravatar_image_extension; |
|
31 | - protected $gravatar_image_size; |
|
32 | - protected $gravatar_default_image; |
|
33 | - protected $gravatar_force_default_image; |
|
34 | - protected $gravatar_rating ; |
|
35 | - protected $gravatar_useragent; |
|
26 | + protected $defaults; |
|
27 | + |
|
28 | + protected $gravatar_base_url; |
|
29 | + protected $gravatar_secure_base_url; |
|
30 | + protected $gravatar_image_extension; |
|
31 | + protected $gravatar_image_size; |
|
32 | + protected $gravatar_default_image; |
|
33 | + protected $gravatar_force_default_image; |
|
34 | + protected $gravatar_rating ; |
|
35 | + protected $gravatar_useragent; |
|
36 | 36 | |
37 | - protected $last_error = GRAVATAR_NO_ERROR; |
|
38 | - |
|
39 | - protected $is_https; |
|
40 | - protected $curl_exists; |
|
41 | - protected $allow_url_fopen; |
|
42 | - |
|
43 | - public function __construct($config = array()) { |
|
44 | - |
|
45 | - $this->defaults = array( |
|
46 | - 'gravatar_base_url' => 'http://www.gravatar.com/', |
|
47 | - 'gravatar_secure_base_url' => 'https://secure.gravatar.com/', |
|
48 | - 'gravatar_image_extension' => '.png', |
|
49 | - 'gravatar_image_size' => 80, |
|
50 | - 'gravatar_default_image' => '', |
|
51 | - 'gravatar_force_default_image' => false, |
|
52 | - 'gravatar_rating' => '', |
|
53 | - 'gravatar_useragent' => 'PHP Gravatar Library', |
|
54 | - ); |
|
55 | - |
|
56 | - $this->is_https = $this->is_https(); |
|
57 | - $this->curl_exists = function_exists('curl_init'); |
|
58 | - $allow_url_fopen = @ini_get('allow_url_fopen'); |
|
59 | - $allow_url_fopen = $allow_url_fopen === false || in_array(strtolower($allow_url_fopen), array('on', 'true', '1')); |
|
60 | - $this->allow_url_fopen = $allow_url_fopen; |
|
61 | - |
|
62 | - if (!is_array($config)) { |
|
63 | - $config = array(); |
|
64 | - } |
|
65 | - |
|
66 | - $this->defaults = array_merge($this->defaults, $config); |
|
67 | - $this->initialize($this->defaults); |
|
68 | - } |
|
69 | - |
|
70 | - public function initialize($config = array()) { |
|
71 | - |
|
72 | - if (!is_array($config)) { |
|
73 | - $config = array(); |
|
74 | - } |
|
75 | - |
|
76 | - foreach ($config as $key => $value) { |
|
77 | - $this->{$key} = $value; |
|
78 | - } |
|
79 | - |
|
80 | - $this->gravatar_base_url = (string) $this->gravatar_base_url; |
|
81 | - $this->gravatar_secure_base_url = (string) $this->gravatar_secure_base_url; |
|
82 | - $this->gravatar_image_extension = (string) $this->gravatar_image_extension; |
|
83 | - |
|
84 | - $this->gravatar_image_size = (int) $this->gravatar_image_size; |
|
85 | - |
|
86 | - if ($this->gravatar_image_size <= 0) { |
|
87 | - $this->gravatar_image_size = 80; |
|
88 | - } |
|
89 | - |
|
90 | - $this->gravatar_default_image = (string) $this->gravatar_default_image; |
|
91 | - $this->gravatar_force_default_image = !empty($this->gravatar_force_default_image); |
|
92 | - $this->gravatar_rating = (string) $this->gravatar_rating; |
|
93 | - $this->gravatar_useragent = (string) $this->gravatar_useragent; |
|
94 | - |
|
95 | - return $this; |
|
96 | - } |
|
97 | - |
|
98 | - public function reset() { |
|
99 | - |
|
100 | - $this->initialize($this->defaults); |
|
101 | - |
|
102 | - return $this; |
|
103 | - } |
|
104 | - |
|
105 | - public function get_defaults() { |
|
106 | - |
|
107 | - return $this->defaults; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Creates a URL for requesting a Gravatar image. |
|
112 | - * @link http://en.gravatar.com/site/implement/images/ |
|
113 | - * |
|
114 | - * @param string $email A registered email. |
|
115 | - * @param int $size The requested size of the avarar in pixels (a square image). |
|
116 | - * @param string $default_image The fallback image option: '', '404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'. |
|
117 | - * @param bool $force_default_image Enforces the fallback image to be shown. |
|
118 | - * @param string $rating The level of allowed self-rate of the avatar: '', 'g' (default), 'pg', 'r', 'x'. |
|
119 | - * @return string Returns the URL of the avatar to be requested. |
|
120 | - * |
|
121 | - * When optional parameters are not set, their default values are taken |
|
122 | - * from the configuration file application/config/gravatar.php |
|
123 | - */ |
|
124 | - public function get($email, $size = null, $default_image = null, $force_default_image = null, $rating = null) { |
|
125 | - |
|
126 | - $url = ($this->is_https ? $this->gravatar_secure_base_url : $this->gravatar_base_url).'avatar/'.$this->create_hash($email).$this->gravatar_image_extension; |
|
127 | - |
|
128 | - $query = array(); |
|
129 | - |
|
130 | - $size = (int) $size; |
|
37 | + protected $last_error = GRAVATAR_NO_ERROR; |
|
38 | + |
|
39 | + protected $is_https; |
|
40 | + protected $curl_exists; |
|
41 | + protected $allow_url_fopen; |
|
42 | + |
|
43 | + public function __construct($config = array()) { |
|
44 | + |
|
45 | + $this->defaults = array( |
|
46 | + 'gravatar_base_url' => 'http://www.gravatar.com/', |
|
47 | + 'gravatar_secure_base_url' => 'https://secure.gravatar.com/', |
|
48 | + 'gravatar_image_extension' => '.png', |
|
49 | + 'gravatar_image_size' => 80, |
|
50 | + 'gravatar_default_image' => '', |
|
51 | + 'gravatar_force_default_image' => false, |
|
52 | + 'gravatar_rating' => '', |
|
53 | + 'gravatar_useragent' => 'PHP Gravatar Library', |
|
54 | + ); |
|
55 | + |
|
56 | + $this->is_https = $this->is_https(); |
|
57 | + $this->curl_exists = function_exists('curl_init'); |
|
58 | + $allow_url_fopen = @ini_get('allow_url_fopen'); |
|
59 | + $allow_url_fopen = $allow_url_fopen === false || in_array(strtolower($allow_url_fopen), array('on', 'true', '1')); |
|
60 | + $this->allow_url_fopen = $allow_url_fopen; |
|
61 | + |
|
62 | + if (!is_array($config)) { |
|
63 | + $config = array(); |
|
64 | + } |
|
65 | + |
|
66 | + $this->defaults = array_merge($this->defaults, $config); |
|
67 | + $this->initialize($this->defaults); |
|
68 | + } |
|
69 | + |
|
70 | + public function initialize($config = array()) { |
|
71 | + |
|
72 | + if (!is_array($config)) { |
|
73 | + $config = array(); |
|
74 | + } |
|
75 | + |
|
76 | + foreach ($config as $key => $value) { |
|
77 | + $this->{$key} = $value; |
|
78 | + } |
|
79 | + |
|
80 | + $this->gravatar_base_url = (string) $this->gravatar_base_url; |
|
81 | + $this->gravatar_secure_base_url = (string) $this->gravatar_secure_base_url; |
|
82 | + $this->gravatar_image_extension = (string) $this->gravatar_image_extension; |
|
83 | + |
|
84 | + $this->gravatar_image_size = (int) $this->gravatar_image_size; |
|
85 | + |
|
86 | + if ($this->gravatar_image_size <= 0) { |
|
87 | + $this->gravatar_image_size = 80; |
|
88 | + } |
|
89 | + |
|
90 | + $this->gravatar_default_image = (string) $this->gravatar_default_image; |
|
91 | + $this->gravatar_force_default_image = !empty($this->gravatar_force_default_image); |
|
92 | + $this->gravatar_rating = (string) $this->gravatar_rating; |
|
93 | + $this->gravatar_useragent = (string) $this->gravatar_useragent; |
|
94 | + |
|
95 | + return $this; |
|
96 | + } |
|
97 | + |
|
98 | + public function reset() { |
|
99 | + |
|
100 | + $this->initialize($this->defaults); |
|
101 | + |
|
102 | + return $this; |
|
103 | + } |
|
104 | + |
|
105 | + public function get_defaults() { |
|
106 | + |
|
107 | + return $this->defaults; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Creates a URL for requesting a Gravatar image. |
|
112 | + * @link http://en.gravatar.com/site/implement/images/ |
|
113 | + * |
|
114 | + * @param string $email A registered email. |
|
115 | + * @param int $size The requested size of the avarar in pixels (a square image). |
|
116 | + * @param string $default_image The fallback image option: '', '404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'. |
|
117 | + * @param bool $force_default_image Enforces the fallback image to be shown. |
|
118 | + * @param string $rating The level of allowed self-rate of the avatar: '', 'g' (default), 'pg', 'r', 'x'. |
|
119 | + * @return string Returns the URL of the avatar to be requested. |
|
120 | + * |
|
121 | + * When optional parameters are not set, their default values are taken |
|
122 | + * from the configuration file application/config/gravatar.php |
|
123 | + */ |
|
124 | + public function get($email, $size = null, $default_image = null, $force_default_image = null, $rating = null) { |
|
125 | + |
|
126 | + $url = ($this->is_https ? $this->gravatar_secure_base_url : $this->gravatar_base_url).'avatar/'.$this->create_hash($email).$this->gravatar_image_extension; |
|
127 | + |
|
128 | + $query = array(); |
|
129 | + |
|
130 | + $size = (int) $size; |
|
131 | 131 | |
132 | - if ($size <= 0) { |
|
133 | - $size = $this->gravatar_image_size; |
|
134 | - } |
|
132 | + if ($size <= 0) { |
|
133 | + $size = $this->gravatar_image_size; |
|
134 | + } |
|
135 | 135 | |
136 | - if ($size > 0) { |
|
137 | - $query['s'] = $size; |
|
138 | - } |
|
136 | + if ($size > 0) { |
|
137 | + $query['s'] = $size; |
|
138 | + } |
|
139 | 139 | |
140 | - if (isset($default_image)) { |
|
141 | - $default_image = (string) $default_image; |
|
142 | - } else { |
|
143 | - $default_image = $this->gravatar_default_image; |
|
144 | - } |
|
140 | + if (isset($default_image)) { |
|
141 | + $default_image = (string) $default_image; |
|
142 | + } else { |
|
143 | + $default_image = $this->gravatar_default_image; |
|
144 | + } |
|
145 | 145 | |
146 | - if ($default_image != '') { |
|
147 | - $query['d'] = $default_image; |
|
148 | - } |
|
146 | + if ($default_image != '') { |
|
147 | + $query['d'] = $default_image; |
|
148 | + } |
|
149 | 149 | |
150 | - if (isset($force_default_image)) { |
|
151 | - $force_default_image = !empty($force_default_image); |
|
152 | - } else { |
|
153 | - $force_default_image = $this->gravatar_force_default_image; |
|
154 | - } |
|
150 | + if (isset($force_default_image)) { |
|
151 | + $force_default_image = !empty($force_default_image); |
|
152 | + } else { |
|
153 | + $force_default_image = $this->gravatar_force_default_image; |
|
154 | + } |
|
155 | 155 | |
156 | - if ($force_default_image) { |
|
157 | - $query['f'] = 'y'; |
|
158 | - } |
|
156 | + if ($force_default_image) { |
|
157 | + $query['f'] = 'y'; |
|
158 | + } |
|
159 | 159 | |
160 | - if (isset($rating)) { |
|
161 | - $rating = (string) $rating; |
|
162 | - } else { |
|
163 | - $rating = $this->gravatar_rating; |
|
164 | - } |
|
160 | + if (isset($rating)) { |
|
161 | + $rating = (string) $rating; |
|
162 | + } else { |
|
163 | + $rating = $this->gravatar_rating; |
|
164 | + } |
|
165 | 165 | |
166 | - if ($rating != '') { |
|
167 | - $query['r'] = $rating; |
|
168 | - } |
|
166 | + if ($rating != '') { |
|
167 | + $query['r'] = $rating; |
|
168 | + } |
|
169 | 169 | |
170 | - if (!empty($query)) { |
|
171 | - $url = $url.'?'.http_build_query($query); |
|
172 | - } |
|
170 | + if (!empty($query)) { |
|
171 | + $url = $url.'?'.http_build_query($query); |
|
172 | + } |
|
173 | 173 | |
174 | - return $url; |
|
175 | - } |
|
174 | + return $url; |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * Executes a request for Gravatar profile data and returns it as a multidimensional array. |
|
179 | - * @link https://en.gravatar.com/site/implement/profiles/ |
|
180 | - * |
|
181 | - * @param string $email A registered email. |
|
182 | - * @return array/null Received profile data. |
|
183 | - */ |
|
184 | - public function get_profile_data($email) { |
|
177 | + /** |
|
178 | + * Executes a request for Gravatar profile data and returns it as a multidimensional array. |
|
179 | + * @link https://en.gravatar.com/site/implement/profiles/ |
|
180 | + * |
|
181 | + * @param string $email A registered email. |
|
182 | + * @return array/null Received profile data. |
|
183 | + */ |
|
184 | + public function get_profile_data($email) { |
|
185 | 185 | |
186 | - $result = $this->execute_profile_request($email, 'php'); |
|
186 | + $result = $this->execute_profile_request($email, 'php'); |
|
187 | 187 | |
188 | - if ($this->last_error != GRAVATAR_NO_ERROR) { |
|
189 | - return null; |
|
190 | - } |
|
188 | + if ($this->last_error != GRAVATAR_NO_ERROR) { |
|
189 | + return null; |
|
190 | + } |
|
191 | 191 | |
192 | - $result = @ unserialize($result); |
|
192 | + $result = @ unserialize($result); |
|
193 | 193 | |
194 | - if ($result === false) { |
|
194 | + if ($result === false) { |
|
195 | 195 | |
196 | - $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
|
197 | - return null; |
|
198 | - } |
|
196 | + $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
|
197 | + return null; |
|
198 | + } |
|
199 | 199 | |
200 | - if (!is_array($result)) { |
|
200 | + if (!is_array($result)) { |
|
201 | 201 | |
202 | - $this->last_error = GRAVATAR_PROFILE_DOES_NOT_EXIST; |
|
203 | - return null; |
|
204 | - } |
|
202 | + $this->last_error = GRAVATAR_PROFILE_DOES_NOT_EXIST; |
|
203 | + return null; |
|
204 | + } |
|
205 | 205 | |
206 | - if (!isset($result['entry']) || !isset($result['entry'][0])) { |
|
206 | + if (!isset($result['entry']) || !isset($result['entry'][0])) { |
|
207 | 207 | |
208 | - $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
|
209 | - return null; |
|
210 | - } |
|
208 | + $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
|
209 | + return null; |
|
210 | + } |
|
211 | 211 | |
212 | - return $result['entry'][0]; |
|
213 | - } |
|
212 | + return $result['entry'][0]; |
|
213 | + } |
|
214 | 214 | |
215 | - /** |
|
216 | - * Executes a request for Gravatar profile data and returns raw received response. |
|
217 | - * @link https://en.gravatar.com/site/implement/profiles/ |
|
218 | - * |
|
219 | - * @param string $email A registered email. |
|
220 | - * @param string $format '', 'json', 'xml', 'php', 'vcf', 'qr'. |
|
221 | - * @return string/null Received profile raw data. |
|
222 | - */ |
|
223 | - public function execute_profile_request($email, $format = null) { |
|
215 | + /** |
|
216 | + * Executes a request for Gravatar profile data and returns raw received response. |
|
217 | + * @link https://en.gravatar.com/site/implement/profiles/ |
|
218 | + * |
|
219 | + * @param string $email A registered email. |
|
220 | + * @param string $format '', 'json', 'xml', 'php', 'vcf', 'qr'. |
|
221 | + * @return string/null Received profile raw data. |
|
222 | + */ |
|
223 | + public function execute_profile_request($email, $format = null) { |
|
224 | 224 | |
225 | - $this->last_error = GRAVATAR_NO_ERROR; |
|
225 | + $this->last_error = GRAVATAR_NO_ERROR; |
|
226 | 226 | |
227 | - if (function_exists('valid_email')) { |
|
227 | + if (function_exists('valid_email')) { |
|
228 | 228 | |
229 | - if (!valid_email($email)) { |
|
229 | + if (!valid_email($email)) { |
|
230 | 230 | |
231 | - $this->last_error = GRAVATAR_INVALID_EMAIL; |
|
232 | - return null; |
|
233 | - } |
|
231 | + $this->last_error = GRAVATAR_INVALID_EMAIL; |
|
232 | + return null; |
|
233 | + } |
|
234 | 234 | |
235 | - } else { |
|
235 | + } else { |
|
236 | 236 | |
237 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
237 | + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
238 | 238 | |
239 | - $this->last_error = GRAVATAR_INVALID_EMAIL; |
|
240 | - return null; |
|
241 | - } |
|
242 | - } |
|
239 | + $this->last_error = GRAVATAR_INVALID_EMAIL; |
|
240 | + return null; |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | - $format = trim($format); |
|
244 | + $format = trim($format); |
|
245 | 245 | |
246 | - if ($format != '') { |
|
247 | - $format = '.'.ltrim($format, '.'); |
|
248 | - } |
|
246 | + if ($format != '') { |
|
247 | + $format = '.'.ltrim($format, '.'); |
|
248 | + } |
|
249 | 249 | |
250 | - $result = null; |
|
250 | + $result = null; |
|
251 | 251 | |
252 | - if ($this->curl_exists) { |
|
252 | + if ($this->curl_exists) { |
|
253 | 253 | |
254 | - $url = $this->gravatar_secure_base_url.$this->create_hash($email).$format; |
|
254 | + $url = $this->gravatar_secure_base_url.$this->create_hash($email).$format; |
|
255 | 255 | |
256 | - $ch = curl_init(); |
|
256 | + $ch = curl_init(); |
|
257 | 257 | |
258 | - $options = array( |
|
259 | - CURLOPT_USERAGENT, $this->gravatar_useragent, |
|
260 | - CURLOPT_RETURNTRANSFER => true, |
|
261 | - CURLOPT_POST => true, |
|
262 | - CURLOPT_POSTFIELDS => array(), |
|
263 | - CURLOPT_URL => $url, |
|
264 | - CURLOPT_TIMEOUT => 3, |
|
265 | - ); |
|
258 | + $options = array( |
|
259 | + CURLOPT_USERAGENT, $this->gravatar_useragent, |
|
260 | + CURLOPT_RETURNTRANSFER => true, |
|
261 | + CURLOPT_POST => true, |
|
262 | + CURLOPT_POSTFIELDS => array(), |
|
263 | + CURLOPT_URL => $url, |
|
264 | + CURLOPT_TIMEOUT => 3, |
|
265 | + ); |
|
266 | 266 | |
267 | - if (!ini_get('safe_mode') && !ini_get('open_basedir')) { |
|
268 | - $options[CURLOPT_FOLLOWLOCATION] = true; |
|
269 | - } |
|
267 | + if (!ini_get('safe_mode') && !ini_get('open_basedir')) { |
|
268 | + $options[CURLOPT_FOLLOWLOCATION] = true; |
|
269 | + } |
|
270 | 270 | |
271 | - curl_setopt_array($ch, $options); |
|
271 | + curl_setopt_array($ch, $options); |
|
272 | 272 | |
273 | - $result = curl_exec($ch); |
|
273 | + $result = curl_exec($ch); |
|
274 | 274 | |
275 | - $code = @ curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
275 | + $code = @ curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
276 | 276 | |
277 | - @ curl_close($ch); |
|
277 | + @ curl_close($ch); |
|
278 | 278 | |
279 | - if ($code != 200) { |
|
279 | + if ($code != 200) { |
|
280 | 280 | |
281 | - $this->last_error = GRAVATAR_CANT_CONNECT; |
|
282 | - return null; |
|
283 | - } |
|
281 | + $this->last_error = GRAVATAR_CANT_CONNECT; |
|
282 | + return null; |
|
283 | + } |
|
284 | 284 | |
285 | - } elseif ($this->allow_url_fopen) { |
|
285 | + } elseif ($this->allow_url_fopen) { |
|
286 | 286 | |
287 | - $url = $this->gravatar_base_url.$this->create_hash($email).$format; |
|
287 | + $url = $this->gravatar_base_url.$this->create_hash($email).$format; |
|
288 | 288 | |
289 | - $options = array( |
|
290 | - 'http' => array( |
|
291 | - 'method' => 'GET', |
|
292 | - 'useragent' => $this->gravatar_useragent, |
|
293 | - ), |
|
294 | - ); |
|
289 | + $options = array( |
|
290 | + 'http' => array( |
|
291 | + 'method' => 'GET', |
|
292 | + 'useragent' => $this->gravatar_useragent, |
|
293 | + ), |
|
294 | + ); |
|
295 | 295 | |
296 | - $context = stream_context_create($options); |
|
296 | + $context = stream_context_create($options); |
|
297 | 297 | |
298 | - $result = @ file_get_contents($url, false, $context); |
|
298 | + $result = @ file_get_contents($url, false, $context); |
|
299 | 299 | |
300 | - } else { |
|
300 | + } else { |
|
301 | 301 | |
302 | - $this->last_error = GRAVATAR_CANT_CONNECT; |
|
303 | - return null; |
|
304 | - } |
|
302 | + $this->last_error = GRAVATAR_CANT_CONNECT; |
|
303 | + return null; |
|
304 | + } |
|
305 | 305 | |
306 | - if ($result === false) { |
|
306 | + if ($result === false) { |
|
307 | 307 | |
308 | - $this->last_error = GRAVATAR_CANT_CONNECT; |
|
309 | - return null; |
|
310 | - } |
|
308 | + $this->last_error = GRAVATAR_CANT_CONNECT; |
|
309 | + return null; |
|
310 | + } |
|
311 | 311 | |
312 | - return $result; |
|
313 | - } |
|
312 | + return $result; |
|
313 | + } |
|
314 | 314 | |
315 | - /** |
|
316 | - * Returns the error code as a result of the last profile request operation. |
|
317 | - * |
|
318 | - * @return int GRAVATAR_NO_ERROR - the last operation was successfull, |
|
319 | - * other returned value indicates failure. |
|
320 | - */ |
|
321 | - public function last_error() { |
|
315 | + /** |
|
316 | + * Returns the error code as a result of the last profile request operation. |
|
317 | + * |
|
318 | + * @return int GRAVATAR_NO_ERROR - the last operation was successfull, |
|
319 | + * other returned value indicates failure. |
|
320 | + */ |
|
321 | + public function last_error() { |
|
322 | 322 | |
323 | - return $this->last_error; |
|
324 | - } |
|
323 | + return $this->last_error; |
|
324 | + } |
|
325 | 325 | |
326 | - /** |
|
327 | - * Creates a hash value from a provided e-mail address. |
|
328 | - * @link https://en.gravatar.com/site/implement/hash/ |
|
329 | - * |
|
330 | - * @param string $email A registered email. |
|
331 | - * @return string/null The hash for accessing the avatar or profile data. |
|
332 | - */ |
|
333 | - public function create_hash($email) { |
|
334 | - |
|
335 | - return md5(strtolower(trim($email))); |
|
336 | - } |
|
337 | - |
|
338 | - protected function is_https() { |
|
339 | - |
|
340 | - if (function_exists('is_https')) { |
|
341 | - return is_https(); |
|
342 | - } |
|
343 | - |
|
344 | - if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
345 | - return true; |
|
346 | - } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
347 | - return true; |
|
348 | - } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
|
349 | - return true; |
|
350 | - } |
|
351 | - |
|
352 | - return false; |
|
353 | - } |
|
354 | - |
|
355 | - //-------------------------------------------------------------------------- |
|
356 | - // The following original methods are kept here for backward compatibility. |
|
357 | - // Consider them as deprecated. |
|
358 | - //-------------------------------------------------------------------------- |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Set the email to be used, converting it into an md5 hash as required by gravatar.com |
|
363 | - * |
|
364 | - * @param string $email |
|
365 | - * |
|
366 | - * @return string|null Email hash or if email didn't validate then return NULL |
|
367 | - * |
|
368 | - * @deprecated |
|
369 | - */ |
|
370 | - public function set_email($email) |
|
371 | - { |
|
372 | - $email = trim(strtolower($email)); |
|
373 | - |
|
374 | - if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
375 | - { |
|
376 | - return md5($email); |
|
377 | - } |
|
378 | - |
|
379 | - return NULL; |
|
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * get_gravatar_url |
|
384 | - * |
|
385 | - * @see http://en.gravatar.com/site/implement/images/ for available options |
|
386 | - * |
|
387 | - * @param string $rating defaults to g |
|
388 | - * @param string $size defaults to 80 |
|
389 | - * @param string $default_image default sets can be found on the above link |
|
390 | - * @param boolean $secure set to TRUE if a secure url is required |
|
391 | - * |
|
392 | - * @return string gratavar url |
|
393 | - * |
|
394 | - * @deprecated |
|
395 | - */ |
|
396 | - public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) |
|
397 | - { |
|
398 | - $hash = $this->set_email($email); |
|
399 | - |
|
400 | - if ($hash === NULL) |
|
401 | - { |
|
402 | - // $hash has to be set to a value so the gravatar site can return a default image |
|
403 | - $hash = 'invalid_email'; |
|
404 | - } |
|
405 | - |
|
406 | - $query_string = NULL; |
|
407 | - $options = array(); |
|
408 | - |
|
409 | - if ($rating !== NULL) |
|
410 | - { |
|
411 | - $options['r'] = $rating; |
|
412 | - } |
|
413 | - |
|
414 | - if ($size !== NULL) |
|
415 | - { |
|
416 | - $options['s'] = $size; |
|
417 | - } |
|
418 | - |
|
419 | - if ($default_image !== NULL) |
|
420 | - { |
|
421 | - $options['d'] = urlencode($default_image); |
|
422 | - } |
|
423 | - |
|
424 | - if (count($options) > 0) |
|
425 | - { |
|
426 | - $query_string = '?'. http_build_query($options); |
|
427 | - } |
|
428 | - |
|
429 | - if ($secure !== NULL) |
|
430 | - { |
|
431 | - $base = $this->gravatar_secure_base_url; |
|
432 | - } |
|
433 | - else |
|
434 | - { |
|
435 | - $base = $this->gravatar_base_url; |
|
436 | - } |
|
437 | - |
|
438 | - return $base .'avatar/'. $hash . $query_string; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Grab the full profile data for a given email from gravatar.com in xml format |
|
443 | - * |
|
444 | - * @param string $email |
|
445 | - * @param string fetch_method defaults to file, 'curl' is the other option |
|
446 | - * |
|
447 | - * @return object|null $xml->entry on success, NULL on an error |
|
448 | - * |
|
449 | - * @deprecated |
|
450 | - */ |
|
451 | - public function get_profile($email, $fetch_method = 'file') |
|
452 | - { |
|
453 | - $hash = $this->set_email($email); |
|
454 | - |
|
455 | - if ($hash === NULL) |
|
456 | - { |
|
457 | - // A hash value of NULL will return no xml so the method returns NULL |
|
458 | - return NULL; |
|
459 | - } |
|
460 | - |
|
461 | - libxml_use_internal_errors(TRUE); |
|
462 | - |
|
463 | - if ($fetch_method === 'file') |
|
464 | - { |
|
465 | - if (ini_get('allow_url_fopen') == FALSE) |
|
466 | - { |
|
467 | - return NULL; |
|
468 | - } |
|
469 | - |
|
470 | - $str = file_get_contents($this->gravatar_base_url . $hash .'.xml'); |
|
471 | - } |
|
472 | - |
|
473 | - if ($fetch_method === 'curl') |
|
474 | - { |
|
475 | - if ( ! function_exists('curl_init')) |
|
476 | - { |
|
477 | - return NULL; |
|
478 | - } |
|
479 | - |
|
480 | - $ch = curl_init(); |
|
481 | - $options = array( |
|
482 | - CURLOPT_RETURNTRANSFER => TRUE, |
|
483 | - CURLOPT_POST => TRUE, |
|
484 | - CURLOPT_URL => $this->gravatar_secure_base_url . $hash .'.xml', |
|
485 | - CURLOPT_TIMEOUT => 3 |
|
486 | - ); |
|
487 | - curl_setopt_array($ch, $options); |
|
488 | - $str = curl_exec($ch); |
|
489 | - } |
|
490 | - |
|
491 | - $xml = simplexml_load_string($str); |
|
492 | - |
|
493 | - if ($xml === FALSE) |
|
494 | - { |
|
495 | - $errors = array(); |
|
496 | - foreach(libxml_get_errors() as $error) |
|
497 | - { |
|
498 | - $errors[] = $error->message.'\n'; |
|
499 | - } |
|
500 | - $error_string = implode('\n', $errors); |
|
501 | - throw new Exception('Failed loading XML\n'. $error_string); |
|
502 | - } |
|
503 | - else |
|
504 | - { |
|
505 | - return $xml->entry; |
|
506 | - } |
|
507 | - } |
|
326 | + /** |
|
327 | + * Creates a hash value from a provided e-mail address. |
|
328 | + * @link https://en.gravatar.com/site/implement/hash/ |
|
329 | + * |
|
330 | + * @param string $email A registered email. |
|
331 | + * @return string/null The hash for accessing the avatar or profile data. |
|
332 | + */ |
|
333 | + public function create_hash($email) { |
|
334 | + |
|
335 | + return md5(strtolower(trim($email))); |
|
336 | + } |
|
337 | + |
|
338 | + protected function is_https() { |
|
339 | + |
|
340 | + if (function_exists('is_https')) { |
|
341 | + return is_https(); |
|
342 | + } |
|
343 | + |
|
344 | + if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
345 | + return true; |
|
346 | + } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
347 | + return true; |
|
348 | + } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
|
349 | + return true; |
|
350 | + } |
|
351 | + |
|
352 | + return false; |
|
353 | + } |
|
354 | + |
|
355 | + //-------------------------------------------------------------------------- |
|
356 | + // The following original methods are kept here for backward compatibility. |
|
357 | + // Consider them as deprecated. |
|
358 | + //-------------------------------------------------------------------------- |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Set the email to be used, converting it into an md5 hash as required by gravatar.com |
|
363 | + * |
|
364 | + * @param string $email |
|
365 | + * |
|
366 | + * @return string|null Email hash or if email didn't validate then return NULL |
|
367 | + * |
|
368 | + * @deprecated |
|
369 | + */ |
|
370 | + public function set_email($email) |
|
371 | + { |
|
372 | + $email = trim(strtolower($email)); |
|
373 | + |
|
374 | + if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
375 | + { |
|
376 | + return md5($email); |
|
377 | + } |
|
378 | + |
|
379 | + return NULL; |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * get_gravatar_url |
|
384 | + * |
|
385 | + * @see http://en.gravatar.com/site/implement/images/ for available options |
|
386 | + * |
|
387 | + * @param string $rating defaults to g |
|
388 | + * @param string $size defaults to 80 |
|
389 | + * @param string $default_image default sets can be found on the above link |
|
390 | + * @param boolean $secure set to TRUE if a secure url is required |
|
391 | + * |
|
392 | + * @return string gratavar url |
|
393 | + * |
|
394 | + * @deprecated |
|
395 | + */ |
|
396 | + public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) |
|
397 | + { |
|
398 | + $hash = $this->set_email($email); |
|
399 | + |
|
400 | + if ($hash === NULL) |
|
401 | + { |
|
402 | + // $hash has to be set to a value so the gravatar site can return a default image |
|
403 | + $hash = 'invalid_email'; |
|
404 | + } |
|
405 | + |
|
406 | + $query_string = NULL; |
|
407 | + $options = array(); |
|
408 | + |
|
409 | + if ($rating !== NULL) |
|
410 | + { |
|
411 | + $options['r'] = $rating; |
|
412 | + } |
|
413 | + |
|
414 | + if ($size !== NULL) |
|
415 | + { |
|
416 | + $options['s'] = $size; |
|
417 | + } |
|
418 | + |
|
419 | + if ($default_image !== NULL) |
|
420 | + { |
|
421 | + $options['d'] = urlencode($default_image); |
|
422 | + } |
|
423 | + |
|
424 | + if (count($options) > 0) |
|
425 | + { |
|
426 | + $query_string = '?'. http_build_query($options); |
|
427 | + } |
|
428 | + |
|
429 | + if ($secure !== NULL) |
|
430 | + { |
|
431 | + $base = $this->gravatar_secure_base_url; |
|
432 | + } |
|
433 | + else |
|
434 | + { |
|
435 | + $base = $this->gravatar_base_url; |
|
436 | + } |
|
437 | + |
|
438 | + return $base .'avatar/'. $hash . $query_string; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Grab the full profile data for a given email from gravatar.com in xml format |
|
443 | + * |
|
444 | + * @param string $email |
|
445 | + * @param string fetch_method defaults to file, 'curl' is the other option |
|
446 | + * |
|
447 | + * @return object|null $xml->entry on success, NULL on an error |
|
448 | + * |
|
449 | + * @deprecated |
|
450 | + */ |
|
451 | + public function get_profile($email, $fetch_method = 'file') |
|
452 | + { |
|
453 | + $hash = $this->set_email($email); |
|
454 | + |
|
455 | + if ($hash === NULL) |
|
456 | + { |
|
457 | + // A hash value of NULL will return no xml so the method returns NULL |
|
458 | + return NULL; |
|
459 | + } |
|
460 | + |
|
461 | + libxml_use_internal_errors(TRUE); |
|
462 | + |
|
463 | + if ($fetch_method === 'file') |
|
464 | + { |
|
465 | + if (ini_get('allow_url_fopen') == FALSE) |
|
466 | + { |
|
467 | + return NULL; |
|
468 | + } |
|
469 | + |
|
470 | + $str = file_get_contents($this->gravatar_base_url . $hash .'.xml'); |
|
471 | + } |
|
472 | + |
|
473 | + if ($fetch_method === 'curl') |
|
474 | + { |
|
475 | + if ( ! function_exists('curl_init')) |
|
476 | + { |
|
477 | + return NULL; |
|
478 | + } |
|
479 | + |
|
480 | + $ch = curl_init(); |
|
481 | + $options = array( |
|
482 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
483 | + CURLOPT_POST => TRUE, |
|
484 | + CURLOPT_URL => $this->gravatar_secure_base_url . $hash .'.xml', |
|
485 | + CURLOPT_TIMEOUT => 3 |
|
486 | + ); |
|
487 | + curl_setopt_array($ch, $options); |
|
488 | + $str = curl_exec($ch); |
|
489 | + } |
|
490 | + |
|
491 | + $xml = simplexml_load_string($str); |
|
492 | + |
|
493 | + if ($xml === FALSE) |
|
494 | + { |
|
495 | + $errors = array(); |
|
496 | + foreach(libxml_get_errors() as $error) |
|
497 | + { |
|
498 | + $errors[] = $error->message.'\n'; |
|
499 | + } |
|
500 | + $error_string = implode('\n', $errors); |
|
501 | + throw new Exception('Failed loading XML\n'. $error_string); |
|
502 | + } |
|
503 | + else |
|
504 | + { |
|
505 | + return $xml->entry; |
|
506 | + } |
|
507 | + } |
|
508 | 508 | |
509 | 509 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | protected $gravatar_image_size; |
32 | 32 | protected $gravatar_default_image; |
33 | 33 | protected $gravatar_force_default_image; |
34 | - protected $gravatar_rating ; |
|
34 | + protected $gravatar_rating; |
|
35 | 35 | protected $gravatar_useragent; |
36 | 36 | |
37 | 37 | protected $last_error = GRAVATAR_NO_ERROR; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $allow_url_fopen = $allow_url_fopen === false || in_array(strtolower($allow_url_fopen), array('on', 'true', '1')); |
60 | 60 | $this->allow_url_fopen = $allow_url_fopen; |
61 | 61 | |
62 | - if (!is_array($config)) { |
|
62 | + if(!is_array($config)) { |
|
63 | 63 | $config = array(); |
64 | 64 | } |
65 | 65 | |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | |
70 | 70 | public function initialize($config = array()) { |
71 | 71 | |
72 | - if (!is_array($config)) { |
|
72 | + if(!is_array($config)) { |
|
73 | 73 | $config = array(); |
74 | 74 | } |
75 | 75 | |
76 | - foreach ($config as $key => $value) { |
|
76 | + foreach($config as $key => $value) { |
|
77 | 77 | $this->{$key} = $value; |
78 | 78 | } |
79 | 79 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $this->gravatar_image_size = (int) $this->gravatar_image_size; |
85 | 85 | |
86 | - if ($this->gravatar_image_size <= 0) { |
|
86 | + if($this->gravatar_image_size <= 0) { |
|
87 | 87 | $this->gravatar_image_size = 80; |
88 | 88 | } |
89 | 89 | |
@@ -129,45 +129,45 @@ discard block |
||
129 | 129 | |
130 | 130 | $size = (int) $size; |
131 | 131 | |
132 | - if ($size <= 0) { |
|
132 | + if($size <= 0) { |
|
133 | 133 | $size = $this->gravatar_image_size; |
134 | 134 | } |
135 | 135 | |
136 | - if ($size > 0) { |
|
136 | + if($size > 0) { |
|
137 | 137 | $query['s'] = $size; |
138 | 138 | } |
139 | 139 | |
140 | - if (isset($default_image)) { |
|
140 | + if(isset($default_image)) { |
|
141 | 141 | $default_image = (string) $default_image; |
142 | 142 | } else { |
143 | 143 | $default_image = $this->gravatar_default_image; |
144 | 144 | } |
145 | 145 | |
146 | - if ($default_image != '') { |
|
146 | + if($default_image != '') { |
|
147 | 147 | $query['d'] = $default_image; |
148 | 148 | } |
149 | 149 | |
150 | - if (isset($force_default_image)) { |
|
150 | + if(isset($force_default_image)) { |
|
151 | 151 | $force_default_image = !empty($force_default_image); |
152 | 152 | } else { |
153 | 153 | $force_default_image = $this->gravatar_force_default_image; |
154 | 154 | } |
155 | 155 | |
156 | - if ($force_default_image) { |
|
156 | + if($force_default_image) { |
|
157 | 157 | $query['f'] = 'y'; |
158 | 158 | } |
159 | 159 | |
160 | - if (isset($rating)) { |
|
160 | + if(isset($rating)) { |
|
161 | 161 | $rating = (string) $rating; |
162 | 162 | } else { |
163 | 163 | $rating = $this->gravatar_rating; |
164 | 164 | } |
165 | 165 | |
166 | - if ($rating != '') { |
|
166 | + if($rating != '') { |
|
167 | 167 | $query['r'] = $rating; |
168 | 168 | } |
169 | 169 | |
170 | - if (!empty($query)) { |
|
170 | + if(!empty($query)) { |
|
171 | 171 | $url = $url.'?'.http_build_query($query); |
172 | 172 | } |
173 | 173 | |
@@ -185,25 +185,25 @@ discard block |
||
185 | 185 | |
186 | 186 | $result = $this->execute_profile_request($email, 'php'); |
187 | 187 | |
188 | - if ($this->last_error != GRAVATAR_NO_ERROR) { |
|
188 | + if($this->last_error != GRAVATAR_NO_ERROR) { |
|
189 | 189 | return null; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $result = @ unserialize($result); |
193 | 193 | |
194 | - if ($result === false) { |
|
194 | + if($result === false) { |
|
195 | 195 | |
196 | 196 | $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
197 | 197 | return null; |
198 | 198 | } |
199 | 199 | |
200 | - if (!is_array($result)) { |
|
200 | + if(!is_array($result)) { |
|
201 | 201 | |
202 | 202 | $this->last_error = GRAVATAR_PROFILE_DOES_NOT_EXIST; |
203 | 203 | return null; |
204 | 204 | } |
205 | 205 | |
206 | - if (!isset($result['entry']) || !isset($result['entry'][0])) { |
|
206 | + if(!isset($result['entry']) || !isset($result['entry'][0])) { |
|
207 | 207 | |
208 | 208 | $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
209 | 209 | return null; |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | |
225 | 225 | $this->last_error = GRAVATAR_NO_ERROR; |
226 | 226 | |
227 | - if (function_exists('valid_email')) { |
|
227 | + if(function_exists('valid_email')) { |
|
228 | 228 | |
229 | - if (!valid_email($email)) { |
|
229 | + if(!valid_email($email)) { |
|
230 | 230 | |
231 | 231 | $this->last_error = GRAVATAR_INVALID_EMAIL; |
232 | 232 | return null; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | |
235 | 235 | } else { |
236 | 236 | |
237 | - if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
237 | + if(!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
238 | 238 | |
239 | 239 | $this->last_error = GRAVATAR_INVALID_EMAIL; |
240 | 240 | return null; |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | |
244 | 244 | $format = trim($format); |
245 | 245 | |
246 | - if ($format != '') { |
|
246 | + if($format != '') { |
|
247 | 247 | $format = '.'.ltrim($format, '.'); |
248 | 248 | } |
249 | 249 | |
250 | 250 | $result = null; |
251 | 251 | |
252 | - if ($this->curl_exists) { |
|
252 | + if($this->curl_exists) { |
|
253 | 253 | |
254 | 254 | $url = $this->gravatar_secure_base_url.$this->create_hash($email).$format; |
255 | 255 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | CURLOPT_TIMEOUT => 3, |
265 | 265 | ); |
266 | 266 | |
267 | - if (!ini_get('safe_mode') && !ini_get('open_basedir')) { |
|
267 | + if(!ini_get('safe_mode') && !ini_get('open_basedir')) { |
|
268 | 268 | $options[CURLOPT_FOLLOWLOCATION] = true; |
269 | 269 | } |
270 | 270 | |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | |
277 | 277 | @ curl_close($ch); |
278 | 278 | |
279 | - if ($code != 200) { |
|
279 | + if($code != 200) { |
|
280 | 280 | |
281 | 281 | $this->last_error = GRAVATAR_CANT_CONNECT; |
282 | 282 | return null; |
283 | 283 | } |
284 | 284 | |
285 | - } elseif ($this->allow_url_fopen) { |
|
285 | + } elseif($this->allow_url_fopen) { |
|
286 | 286 | |
287 | 287 | $url = $this->gravatar_base_url.$this->create_hash($email).$format; |
288 | 288 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | return null; |
304 | 304 | } |
305 | 305 | |
306 | - if ($result === false) { |
|
306 | + if($result === false) { |
|
307 | 307 | |
308 | 308 | $this->last_error = GRAVATAR_CANT_CONNECT; |
309 | 309 | return null; |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | |
338 | 338 | protected function is_https() { |
339 | 339 | |
340 | - if (function_exists('is_https')) { |
|
340 | + if(function_exists('is_https')) { |
|
341 | 341 | return is_https(); |
342 | 342 | } |
343 | 343 | |
344 | - if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
344 | + if(!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
|
345 | 345 | return true; |
346 | - } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
346 | + } elseif(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
|
347 | 347 | return true; |
348 | - } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
|
348 | + } elseif(!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
|
349 | 349 | return true; |
350 | 350 | } |
351 | 351 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | { |
372 | 372 | $email = trim(strtolower($email)); |
373 | 373 | |
374 | - if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
374 | + if(!filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
375 | 375 | { |
376 | 376 | return md5($email); |
377 | 377 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | { |
398 | 398 | $hash = $this->set_email($email); |
399 | 399 | |
400 | - if ($hash === NULL) |
|
400 | + if($hash === NULL) |
|
401 | 401 | { |
402 | 402 | // $hash has to be set to a value so the gravatar site can return a default image |
403 | 403 | $hash = 'invalid_email'; |
@@ -406,27 +406,27 @@ discard block |
||
406 | 406 | $query_string = NULL; |
407 | 407 | $options = array(); |
408 | 408 | |
409 | - if ($rating !== NULL) |
|
409 | + if($rating !== NULL) |
|
410 | 410 | { |
411 | 411 | $options['r'] = $rating; |
412 | 412 | } |
413 | 413 | |
414 | - if ($size !== NULL) |
|
414 | + if($size !== NULL) |
|
415 | 415 | { |
416 | 416 | $options['s'] = $size; |
417 | 417 | } |
418 | 418 | |
419 | - if ($default_image !== NULL) |
|
419 | + if($default_image !== NULL) |
|
420 | 420 | { |
421 | 421 | $options['d'] = urlencode($default_image); |
422 | 422 | } |
423 | 423 | |
424 | - if (count($options) > 0) |
|
424 | + if(count($options) > 0) |
|
425 | 425 | { |
426 | - $query_string = '?'. http_build_query($options); |
|
426 | + $query_string = '?'.http_build_query($options); |
|
427 | 427 | } |
428 | 428 | |
429 | - if ($secure !== NULL) |
|
429 | + if($secure !== NULL) |
|
430 | 430 | { |
431 | 431 | $base = $this->gravatar_secure_base_url; |
432 | 432 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $base = $this->gravatar_base_url; |
436 | 436 | } |
437 | 437 | |
438 | - return $base .'avatar/'. $hash . $query_string; |
|
438 | + return $base.'avatar/'.$hash.$query_string; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | { |
453 | 453 | $hash = $this->set_email($email); |
454 | 454 | |
455 | - if ($hash === NULL) |
|
455 | + if($hash === NULL) |
|
456 | 456 | { |
457 | 457 | // A hash value of NULL will return no xml so the method returns NULL |
458 | 458 | return NULL; |
@@ -460,19 +460,19 @@ discard block |
||
460 | 460 | |
461 | 461 | libxml_use_internal_errors(TRUE); |
462 | 462 | |
463 | - if ($fetch_method === 'file') |
|
463 | + if($fetch_method === 'file') |
|
464 | 464 | { |
465 | - if (ini_get('allow_url_fopen') == FALSE) |
|
465 | + if(ini_get('allow_url_fopen') == FALSE) |
|
466 | 466 | { |
467 | 467 | return NULL; |
468 | 468 | } |
469 | 469 | |
470 | - $str = file_get_contents($this->gravatar_base_url . $hash .'.xml'); |
|
470 | + $str = file_get_contents($this->gravatar_base_url.$hash.'.xml'); |
|
471 | 471 | } |
472 | 472 | |
473 | - if ($fetch_method === 'curl') |
|
473 | + if($fetch_method === 'curl') |
|
474 | 474 | { |
475 | - if ( ! function_exists('curl_init')) |
|
475 | + if(!function_exists('curl_init')) |
|
476 | 476 | { |
477 | 477 | return NULL; |
478 | 478 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | $options = array( |
482 | 482 | CURLOPT_RETURNTRANSFER => TRUE, |
483 | 483 | CURLOPT_POST => TRUE, |
484 | - CURLOPT_URL => $this->gravatar_secure_base_url . $hash .'.xml', |
|
484 | + CURLOPT_URL => $this->gravatar_secure_base_url.$hash.'.xml', |
|
485 | 485 | CURLOPT_TIMEOUT => 3 |
486 | 486 | ); |
487 | 487 | curl_setopt_array($ch, $options); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | $xml = simplexml_load_string($str); |
492 | 492 | |
493 | - if ($xml === FALSE) |
|
493 | + if($xml === FALSE) |
|
494 | 494 | { |
495 | 495 | $errors = array(); |
496 | 496 | foreach(libxml_get_errors() as $error) |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $errors[] = $error->message.'\n'; |
499 | 499 | } |
500 | 500 | $error_string = implode('\n', $errors); |
501 | - throw new Exception('Failed loading XML\n'. $error_string); |
|
501 | + throw new Exception('Failed loading XML\n'.$error_string); |
|
502 | 502 | } |
503 | 503 | else |
504 | 504 | { |
@@ -367,12 +367,10 @@ discard block |
||
367 | 367 | * |
368 | 368 | * @deprecated |
369 | 369 | */ |
370 | - public function set_email($email) |
|
371 | - { |
|
370 | + public function set_email($email) { |
|
372 | 371 | $email = trim(strtolower($email)); |
373 | 372 | |
374 | - if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
375 | - { |
|
373 | + if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { |
|
376 | 374 | return md5($email); |
377 | 375 | } |
378 | 376 | |
@@ -393,12 +391,10 @@ discard block |
||
393 | 391 | * |
394 | 392 | * @deprecated |
395 | 393 | */ |
396 | - public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) |
|
397 | - { |
|
394 | + public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) { |
|
398 | 395 | $hash = $this->set_email($email); |
399 | 396 | |
400 | - if ($hash === NULL) |
|
401 | - { |
|
397 | + if ($hash === NULL) { |
|
402 | 398 | // $hash has to be set to a value so the gravatar site can return a default image |
403 | 399 | $hash = 'invalid_email'; |
404 | 400 | } |
@@ -406,32 +402,25 @@ discard block |
||
406 | 402 | $query_string = NULL; |
407 | 403 | $options = array(); |
408 | 404 | |
409 | - if ($rating !== NULL) |
|
410 | - { |
|
405 | + if ($rating !== NULL) { |
|
411 | 406 | $options['r'] = $rating; |
412 | 407 | } |
413 | 408 | |
414 | - if ($size !== NULL) |
|
415 | - { |
|
409 | + if ($size !== NULL) { |
|
416 | 410 | $options['s'] = $size; |
417 | 411 | } |
418 | 412 | |
419 | - if ($default_image !== NULL) |
|
420 | - { |
|
413 | + if ($default_image !== NULL) { |
|
421 | 414 | $options['d'] = urlencode($default_image); |
422 | 415 | } |
423 | 416 | |
424 | - if (count($options) > 0) |
|
425 | - { |
|
417 | + if (count($options) > 0) { |
|
426 | 418 | $query_string = '?'. http_build_query($options); |
427 | 419 | } |
428 | 420 | |
429 | - if ($secure !== NULL) |
|
430 | - { |
|
421 | + if ($secure !== NULL) { |
|
431 | 422 | $base = $this->gravatar_secure_base_url; |
432 | - } |
|
433 | - else |
|
434 | - { |
|
423 | + } else { |
|
435 | 424 | $base = $this->gravatar_base_url; |
436 | 425 | } |
437 | 426 | |
@@ -448,32 +437,26 @@ discard block |
||
448 | 437 | * |
449 | 438 | * @deprecated |
450 | 439 | */ |
451 | - public function get_profile($email, $fetch_method = 'file') |
|
452 | - { |
|
440 | + public function get_profile($email, $fetch_method = 'file') { |
|
453 | 441 | $hash = $this->set_email($email); |
454 | 442 | |
455 | - if ($hash === NULL) |
|
456 | - { |
|
443 | + if ($hash === NULL) { |
|
457 | 444 | // A hash value of NULL will return no xml so the method returns NULL |
458 | 445 | return NULL; |
459 | 446 | } |
460 | 447 | |
461 | 448 | libxml_use_internal_errors(TRUE); |
462 | 449 | |
463 | - if ($fetch_method === 'file') |
|
464 | - { |
|
465 | - if (ini_get('allow_url_fopen') == FALSE) |
|
466 | - { |
|
450 | + if ($fetch_method === 'file') { |
|
451 | + if (ini_get('allow_url_fopen') == FALSE) { |
|
467 | 452 | return NULL; |
468 | 453 | } |
469 | 454 | |
470 | 455 | $str = file_get_contents($this->gravatar_base_url . $hash .'.xml'); |
471 | 456 | } |
472 | 457 | |
473 | - if ($fetch_method === 'curl') |
|
474 | - { |
|
475 | - if ( ! function_exists('curl_init')) |
|
476 | - { |
|
458 | + if ($fetch_method === 'curl') { |
|
459 | + if ( ! function_exists('curl_init')) { |
|
477 | 460 | return NULL; |
478 | 461 | } |
479 | 462 | |
@@ -490,18 +473,14 @@ discard block |
||
490 | 473 | |
491 | 474 | $xml = simplexml_load_string($str); |
492 | 475 | |
493 | - if ($xml === FALSE) |
|
494 | - { |
|
476 | + if ($xml === FALSE) { |
|
495 | 477 | $errors = array(); |
496 | - foreach(libxml_get_errors() as $error) |
|
497 | - { |
|
478 | + foreach(libxml_get_errors() as $error) { |
|
498 | 479 | $errors[] = $error->message.'\n'; |
499 | 480 | } |
500 | 481 | $error_string = implode('\n', $errors); |
501 | 482 | throw new Exception('Failed loading XML\n'. $error_string); |
502 | - } |
|
503 | - else |
|
504 | - { |
|
483 | + } else { |
|
505 | 484 | return $xml->entry; |
506 | 485 | } |
507 | 486 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed.'); |
|
1 | +<?php defined('BASEPATH') or exit('No direct script access allowed.'); |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Gravatar Library for CodeIgniter |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | */ |
16 | 16 | |
17 | 17 | // Gravatar pofile error results. |
18 | -defined('GRAVATAR_NO_ERROR') OR define('GRAVATAR_NO_ERROR', 0); |
|
19 | -defined('GRAVATAR_CANT_CONNECT') OR define('GRAVATAR_CANT_CONNECT', 1); |
|
20 | -defined('GRAVATAR_INVALID_EMAIL') OR define('GRAVATAR_INVALID_EMAIL', 2); |
|
21 | -defined('GRAVATAR_PROFILE_DOES_NOT_EXIST') OR define('GRAVATAR_PROFILE_DOES_NOT_EXIST', 3); |
|
22 | -defined('GRAVATAR_INCORRECT_FORMAT') OR define('GRAVATAR_INCORRECT_FORMAT', 4); |
|
18 | +defined('GRAVATAR_NO_ERROR') or define('GRAVATAR_NO_ERROR', 0); |
|
19 | +defined('GRAVATAR_CANT_CONNECT') or define('GRAVATAR_CANT_CONNECT', 1); |
|
20 | +defined('GRAVATAR_INVALID_EMAIL') or define('GRAVATAR_INVALID_EMAIL', 2); |
|
21 | +defined('GRAVATAR_PROFILE_DOES_NOT_EXIST') or define('GRAVATAR_PROFILE_DOES_NOT_EXIST', 3); |
|
22 | +defined('GRAVATAR_INCORRECT_FORMAT') or define('GRAVATAR_INCORRECT_FORMAT', 4); |
|
23 | 23 | |
24 | 24 | class Gravatar { |
25 | 25 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'gravatar_image_extension' => '.png', |
49 | 49 | 'gravatar_image_size' => 80, |
50 | 50 | 'gravatar_default_image' => '', |
51 | - 'gravatar_force_default_image' => false, |
|
51 | + 'gravatar_force_default_image' => FALSE, |
|
52 | 52 | 'gravatar_rating' => '', |
53 | 53 | 'gravatar_useragent' => 'PHP Gravatar Library', |
54 | 54 | ); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $this->is_https = $this->is_https(); |
57 | 57 | $this->curl_exists = function_exists('curl_init'); |
58 | 58 | $allow_url_fopen = @ini_get('allow_url_fopen'); |
59 | - $allow_url_fopen = $allow_url_fopen === false || in_array(strtolower($allow_url_fopen), array('on', 'true', '1')); |
|
59 | + $allow_url_fopen = $allow_url_fopen === FALSE || in_array(strtolower($allow_url_fopen), array('on', 'true', '1')); |
|
60 | 60 | $this->allow_url_fopen = $allow_url_fopen; |
61 | 61 | |
62 | 62 | if (!is_array($config)) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * When optional parameters are not set, their default values are taken |
122 | 122 | * from the configuration file application/config/gravatar.php |
123 | 123 | */ |
124 | - public function get($email, $size = null, $default_image = null, $force_default_image = null, $rating = null) { |
|
124 | + public function get($email, $size = NULL, $default_image = NULL, $force_default_image = NULL, $rating = NULL) { |
|
125 | 125 | |
126 | 126 | $url = ($this->is_https ? $this->gravatar_secure_base_url : $this->gravatar_base_url).'avatar/'.$this->create_hash($email).$this->gravatar_image_extension; |
127 | 127 | |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | $result = $this->execute_profile_request($email, 'php'); |
187 | 187 | |
188 | 188 | if ($this->last_error != GRAVATAR_NO_ERROR) { |
189 | - return null; |
|
189 | + return NULL; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $result = @ unserialize($result); |
193 | 193 | |
194 | - if ($result === false) { |
|
194 | + if ($result === FALSE) { |
|
195 | 195 | |
196 | 196 | $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
197 | - return null; |
|
197 | + return NULL; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | if (!is_array($result)) { |
201 | 201 | |
202 | 202 | $this->last_error = GRAVATAR_PROFILE_DOES_NOT_EXIST; |
203 | - return null; |
|
203 | + return NULL; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | if (!isset($result['entry']) || !isset($result['entry'][0])) { |
207 | 207 | |
208 | 208 | $this->last_error = GRAVATAR_INCORRECT_FORMAT; |
209 | - return null; |
|
209 | + return NULL; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | return $result['entry'][0]; |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param string $format '', 'json', 'xml', 'php', 'vcf', 'qr'. |
221 | 221 | * @return string/null Received profile raw data. |
222 | 222 | */ |
223 | - public function execute_profile_request($email, $format = null) { |
|
223 | + public function execute_profile_request($email, $format = NULL) { |
|
224 | 224 | |
225 | 225 | $this->last_error = GRAVATAR_NO_ERROR; |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | if (!valid_email($email)) { |
230 | 230 | |
231 | 231 | $this->last_error = GRAVATAR_INVALID_EMAIL; |
232 | - return null; |
|
232 | + return NULL; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } else { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
238 | 238 | |
239 | 239 | $this->last_error = GRAVATAR_INVALID_EMAIL; |
240 | - return null; |
|
240 | + return NULL; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $format = '.'.ltrim($format, '.'); |
248 | 248 | } |
249 | 249 | |
250 | - $result = null; |
|
250 | + $result = NULL; |
|
251 | 251 | |
252 | 252 | if ($this->curl_exists) { |
253 | 253 | |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | |
258 | 258 | $options = array( |
259 | 259 | CURLOPT_USERAGENT, $this->gravatar_useragent, |
260 | - CURLOPT_RETURNTRANSFER => true, |
|
261 | - CURLOPT_POST => true, |
|
260 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
261 | + CURLOPT_POST => TRUE, |
|
262 | 262 | CURLOPT_POSTFIELDS => array(), |
263 | 263 | CURLOPT_URL => $url, |
264 | 264 | CURLOPT_TIMEOUT => 3, |
265 | 265 | ); |
266 | 266 | |
267 | 267 | if (!ini_get('safe_mode') && !ini_get('open_basedir')) { |
268 | - $options[CURLOPT_FOLLOWLOCATION] = true; |
|
268 | + $options[CURLOPT_FOLLOWLOCATION] = TRUE; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | curl_setopt_array($ch, $options); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | if ($code != 200) { |
280 | 280 | |
281 | 281 | $this->last_error = GRAVATAR_CANT_CONNECT; |
282 | - return null; |
|
282 | + return NULL; |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | } elseif ($this->allow_url_fopen) { |
@@ -295,18 +295,18 @@ discard block |
||
295 | 295 | |
296 | 296 | $context = stream_context_create($options); |
297 | 297 | |
298 | - $result = @ file_get_contents($url, false, $context); |
|
298 | + $result = @ file_get_contents($url, FALSE, $context); |
|
299 | 299 | |
300 | 300 | } else { |
301 | 301 | |
302 | 302 | $this->last_error = GRAVATAR_CANT_CONNECT; |
303 | - return null; |
|
303 | + return NULL; |
|
304 | 304 | } |
305 | 305 | |
306 | - if ($result === false) { |
|
306 | + if ($result === FALSE) { |
|
307 | 307 | |
308 | 308 | $this->last_error = GRAVATAR_CANT_CONNECT; |
309 | - return null; |
|
309 | + return NULL; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | return $result; |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | } |
343 | 343 | |
344 | 344 | if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { |
345 | - return true; |
|
345 | + return TRUE; |
|
346 | 346 | } elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { |
347 | - return true; |
|
347 | + return TRUE; |
|
348 | 348 | } elseif (!empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') { |
349 | - return true; |
|
349 | + return TRUE; |
|
350 | 350 | } |
351 | 351 | |
352 | - return false; |
|
352 | + return FALSE; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | //-------------------------------------------------------------------------- |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | if (!function_exists('gravatar')) { |
9 | 9 | |
10 | - // This helper function has been added here for compatibility with PyroCMS. |
|
11 | - function gravatar($email = '', $size = 50, $rating = 'g', $url_only = false, $default = false) { |
|
10 | + // This helper function has been added here for compatibility with PyroCMS. |
|
11 | + function gravatar($email = '', $size = 50, $rating = 'g', $url_only = false, $default = false) { |
|
12 | 12 | |
13 | - $ci = & get_instance(); |
|
14 | - $ci->load->library('gravatar'); |
|
13 | + $ci = & get_instance(); |
|
14 | + $ci->load->library('gravatar'); |
|
15 | 15 | |
16 | - if (@ (string) $default == '') { |
|
17 | - $default = null; |
|
18 | - } |
|
16 | + if (@ (string) $default == '') { |
|
17 | + $default = null; |
|
18 | + } |
|
19 | 19 | |
20 | - $gravatar_url = $ci->gravatar->get($email, $size, $default, null, $rating); |
|
20 | + $gravatar_url = $ci->gravatar->get($email, $size, $default, null, $rating); |
|
21 | 21 | |
22 | - if ($url_only) { |
|
23 | - return $gravatar_url; |
|
24 | - } |
|
22 | + if ($url_only) { |
|
23 | + return $gravatar_url; |
|
24 | + } |
|
25 | 25 | |
26 | - return '<img src="'.$gravatar_url.'" alt="Gravatar" class="gravatar" />'; |
|
27 | - } |
|
26 | + return '<img src="'.$gravatar_url.'" alt="Gravatar" class="gravatar" />'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @license The MIT License, http://opensource.org/licenses/MIT |
6 | 6 | */ |
7 | 7 | |
8 | -if (!function_exists('gravatar')) { |
|
8 | +if(!function_exists('gravatar')) { |
|
9 | 9 | |
10 | 10 | // This helper function has been added here for compatibility with PyroCMS. |
11 | 11 | function gravatar($email = '', $size = 50, $rating = 'g', $url_only = false, $default = false) { |
@@ -13,13 +13,13 @@ discard block |
||
13 | 13 | $ci = & get_instance(); |
14 | 14 | $ci->load->library('gravatar'); |
15 | 15 | |
16 | - if (@ (string) $default == '') { |
|
16 | + if(@ (string) $default == '') { |
|
17 | 17 | $default = null; |
18 | 18 | } |
19 | 19 | |
20 | 20 | $gravatar_url = $ci->gravatar->get($email, $size, $default, null, $rating); |
21 | 21 | |
22 | - if ($url_only) { |
|
22 | + if($url_only) { |
|
23 | 23 | return $gravatar_url; |
24 | 24 | } |
25 | 25 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * @author Ivan Tcholakov <[email protected]>, 2015 |
@@ -8,16 +8,16 @@ discard block |
||
8 | 8 | if (!function_exists('gravatar')) { |
9 | 9 | |
10 | 10 | // This helper function has been added here for compatibility with PyroCMS. |
11 | - function gravatar($email = '', $size = 50, $rating = 'g', $url_only = false, $default = false) { |
|
11 | + function gravatar($email = '', $size = 50, $rating = 'g', $url_only = FALSE, $default = FALSE) { |
|
12 | 12 | |
13 | 13 | $ci = & get_instance(); |
14 | 14 | $ci->load->library('gravatar'); |
15 | 15 | |
16 | 16 | if (@ (string) $default == '') { |
17 | - $default = null; |
|
17 | + $default = NULL; |
|
18 | 18 | } |
19 | 19 | |
20 | - $gravatar_url = $ci->gravatar->get($email, $size, $default, null, $rating); |
|
20 | + $gravatar_url = $ci->gravatar->get($email, $size, $default, NULL, $rating); |
|
21 | 21 | |
22 | 22 | if ($url_only) { |
23 | 23 | return $gravatar_url; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Auth Lang - English |
4 | 4 | * |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $lang['forgot_password_username_identity_label'] = 'Username'; |
135 | 135 | $lang['forgot_password_email_identity_label'] = 'Email'; |
136 | 136 | $lang['forgot_password_email_not_found'] = 'No record of that email address.'; |
137 | -$lang['forgot_password_identity_not_found'] = 'No record of that username address.'; |
|
137 | +$lang['forgot_password_identity_not_found'] = 'No record of that username address.'; |
|
138 | 138 | |
139 | 139 | // Reset Password |
140 | 140 | $lang['reset_password_heading'] = 'Change Password'; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Name: Auth Lang - English |
4 | 6 | * |