@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
3 | 3 | /** |
4 | 4 | * TNH Framework |
5 | 5 | * |
@@ -28,68 +28,68 @@ discard block |
||
28 | 28 | * SOFTWARE. |
29 | 29 | */ |
30 | 30 | |
31 | - class Browser { |
|
32 | - |
|
33 | - /** |
|
34 | - * List of know platforms |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - private $platforms = array( |
|
38 | - '/windows nt 10/i' => 'Windows 10', |
|
39 | - '/windows phone 10/i' => 'Windows Phone 10', |
|
40 | - '/windows phone 8.1/i' => 'Windows Phone 8.1', |
|
41 | - '/windows phone 8/i' => 'Windows Phone 8', |
|
42 | - '/windows nt 6.3/i' => 'Windows 8.1', |
|
43 | - '/windows nt 6.2/i' => 'Windows 8', |
|
44 | - '/windows nt 6.1/i' => 'Windows 7', |
|
45 | - '/windows nt 6.0/i' => 'Windows Vista', |
|
46 | - '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', |
|
47 | - '/windows nt 5.1/i' => 'Windows XP', |
|
48 | - '/windows xp/i' => 'Windows XP', |
|
49 | - '/windows nt 5.0/i' => 'Windows 2000', |
|
50 | - '/windows me/i' => 'Windows ME', |
|
51 | - '/win98/i' => 'Windows 98', |
|
52 | - '/win95/i' => 'Windows 95', |
|
53 | - '/win16/i' => 'Windows 3.11', |
|
54 | - '/ipad/i' => 'iPad', |
|
31 | + class Browser { |
|
32 | + |
|
33 | + /** |
|
34 | + * List of know platforms |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + private $platforms = array( |
|
38 | + '/windows nt 10/i' => 'Windows 10', |
|
39 | + '/windows phone 10/i' => 'Windows Phone 10', |
|
40 | + '/windows phone 8.1/i' => 'Windows Phone 8.1', |
|
41 | + '/windows phone 8/i' => 'Windows Phone 8', |
|
42 | + '/windows nt 6.3/i' => 'Windows 8.1', |
|
43 | + '/windows nt 6.2/i' => 'Windows 8', |
|
44 | + '/windows nt 6.1/i' => 'Windows 7', |
|
45 | + '/windows nt 6.0/i' => 'Windows Vista', |
|
46 | + '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', |
|
47 | + '/windows nt 5.1/i' => 'Windows XP', |
|
48 | + '/windows xp/i' => 'Windows XP', |
|
49 | + '/windows nt 5.0/i' => 'Windows 2000', |
|
50 | + '/windows me/i' => 'Windows ME', |
|
51 | + '/win98/i' => 'Windows 98', |
|
52 | + '/win95/i' => 'Windows 95', |
|
53 | + '/win16/i' => 'Windows 3.11', |
|
54 | + '/ipad/i' => 'iPad', |
|
55 | 55 | '/ipod/i' => 'iPod', |
56 | 56 | '/iphone/i' => 'iPhone', |
57 | 57 | '/macintosh|mac os x/i' => 'Mac OS X', |
58 | - '/mac_powerpc/i' => 'Mac OS 9', |
|
59 | - '/android/i' => 'Android', |
|
60 | - '/ubuntu/i' => 'Ubuntu', |
|
61 | - '/linux/i' => 'Linux', |
|
62 | - '/blackberry/i' => 'BlackBerry', |
|
63 | - '/webos/i' => 'Mobile' |
|
64 | - ); |
|
65 | - |
|
66 | - /** |
|
67 | - * List of know browsers |
|
68 | - * @var array |
|
69 | - */ |
|
70 | - private $browsers = array( |
|
71 | - '/mobile/i' => 'Handheld Browser', |
|
72 | - '/msie/i' => 'Internet Explorer', |
|
73 | - '/firefox/i' => 'Firefox', |
|
74 | - '/chrome/i' => 'Chrome', |
|
75 | - '/safari/i' => 'Safari', |
|
76 | - '/edge/i' => 'Edge', |
|
77 | - '/opera/i' => 'Opera', |
|
78 | - '/netscape/i' => 'Netscape', |
|
79 | - '/maxthon/i' => 'Maxthon', |
|
80 | - '/konqueror/i' => 'Konqueror' |
|
81 | - ); |
|
82 | - |
|
83 | - /** |
|
84 | - * Agent string |
|
85 | - * @var string |
|
86 | - */ |
|
87 | - private $agent = ''; |
|
88 | - |
|
89 | - /** |
|
90 | - * Browser name |
|
91 | - * @var string |
|
92 | - */ |
|
58 | + '/mac_powerpc/i' => 'Mac OS 9', |
|
59 | + '/android/i' => 'Android', |
|
60 | + '/ubuntu/i' => 'Ubuntu', |
|
61 | + '/linux/i' => 'Linux', |
|
62 | + '/blackberry/i' => 'BlackBerry', |
|
63 | + '/webos/i' => 'Mobile' |
|
64 | + ); |
|
65 | + |
|
66 | + /** |
|
67 | + * List of know browsers |
|
68 | + * @var array |
|
69 | + */ |
|
70 | + private $browsers = array( |
|
71 | + '/mobile/i' => 'Handheld Browser', |
|
72 | + '/msie/i' => 'Internet Explorer', |
|
73 | + '/firefox/i' => 'Firefox', |
|
74 | + '/chrome/i' => 'Chrome', |
|
75 | + '/safari/i' => 'Safari', |
|
76 | + '/edge/i' => 'Edge', |
|
77 | + '/opera/i' => 'Opera', |
|
78 | + '/netscape/i' => 'Netscape', |
|
79 | + '/maxthon/i' => 'Maxthon', |
|
80 | + '/konqueror/i' => 'Konqueror' |
|
81 | + ); |
|
82 | + |
|
83 | + /** |
|
84 | + * Agent string |
|
85 | + * @var string |
|
86 | + */ |
|
87 | + private $agent = ''; |
|
88 | + |
|
89 | + /** |
|
90 | + * Browser name |
|
91 | + * @var string |
|
92 | + */ |
|
93 | 93 | private $browserName = ''; |
94 | 94 | |
95 | 95 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | private $isFacebook = false; |
130 | 130 | |
131 | - /** |
|
131 | + /** |
|
132 | 132 | * Class constructor |
133 | 133 | */ |
134 | 134 | public function __construct($userAgent = '') { |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | return $this->isFacebook; |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Returns a formatted string with a summary of the details of the browser. |
|
236 | - * @codeCoverageIgnore |
|
237 | - * |
|
238 | - * @return string formatted string with a summary of the browser |
|
239 | - */ |
|
234 | + /** |
|
235 | + * Returns a formatted string with a summary of the details of the browser. |
|
236 | + * @codeCoverageIgnore |
|
237 | + * |
|
238 | + * @return string formatted string with a summary of the browser |
|
239 | + */ |
|
240 | 240 | public function __toString() { |
241 | 241 | return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
242 | 242 | "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
@@ -248,70 +248,70 @@ discard block |
||
248 | 248 | /** |
249 | 249 | * Determine the user's platform |
250 | 250 | */ |
251 | - protected function checkPlatform() { |
|
252 | - foreach ($this->platforms as $regex => $value) { |
|
253 | - if (preg_match($regex, $this->agent) ) { |
|
254 | - $this->platform = $value; |
|
255 | - break; |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
251 | + protected function checkPlatform() { |
|
252 | + foreach ($this->platforms as $regex => $value) { |
|
253 | + if (preg_match($regex, $this->agent) ) { |
|
254 | + $this->platform = $value; |
|
255 | + break; |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | 261 | * Routine to determine the browser type |
262 | 262 | */ |
263 | - protected function checkBrowser() { |
|
264 | - foreach ($this->browsers as $regex => $value) { |
|
265 | - if (preg_match($regex, $this->agent ) ) { |
|
266 | - $this->browserName = $value; |
|
267 | - break; |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
263 | + protected function checkBrowser() { |
|
264 | + foreach ($this->browsers as $regex => $value) { |
|
265 | + if (preg_match($regex, $this->agent ) ) { |
|
266 | + $this->browserName = $value; |
|
267 | + break; |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | 273 | * Routine to determine the browser version |
274 | 274 | */ |
275 | - protected function checkBrowserVersion(){ |
|
276 | - $detected = $this->getBrowser(); |
|
277 | - $detect = array_search($detected, $this->browsers); |
|
278 | - $browser = str_replace(array('/i','/'), '', $detect); |
|
279 | - $regex = "/(?<browser>version|{$browser})[\/]+(?<version>[0-9.|a-zA-Z.]*)/i"; |
|
280 | - if (preg_match_all($regex, $this->agent, $matches)) { |
|
281 | - $found = array_search($browser, $matches['browser']); |
|
282 | - $this->version = $matches['version'][$found]; |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
275 | + protected function checkBrowserVersion(){ |
|
276 | + $detected = $this->getBrowser(); |
|
277 | + $detect = array_search($detected, $this->browsers); |
|
278 | + $browser = str_replace(array('/i','/'), '', $detect); |
|
279 | + $regex = "/(?<browser>version|{$browser})[\/]+(?<version>[0-9.|a-zA-Z.]*)/i"; |
|
280 | + if (preg_match_all($regex, $this->agent, $matches)) { |
|
281 | + $found = array_search($browser, $matches['browser']); |
|
282 | + $this->version = $matches['version'][$found]; |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | 287 | * Determine if the browser is Mobile or not |
288 | 288 | */ |
289 | - protected function checkMobile() { |
|
290 | - if (preg_match('/(android|avantgo|blackberry|bolt|boost|cricket' |
|
289 | + protected function checkMobile() { |
|
290 | + if (preg_match('/(android|avantgo|blackberry|bolt|boost|cricket' |
|
291 | 291 | . '|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i', $this->agent) ) { |
292 | - $this->isMobile = true; |
|
293 | - } |
|
294 | - } |
|
292 | + $this->isMobile = true; |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
296 | + /** |
|
297 | 297 | * Determine if the browser is Tablet or not |
298 | 298 | */ |
299 | - protected function checkTablet() { |
|
300 | - if (preg_match('/tablet|ipad/i', $this->agent) ) { |
|
301 | - $this->isTablet = true; |
|
302 | - } |
|
303 | - } |
|
299 | + protected function checkTablet() { |
|
300 | + if (preg_match('/tablet|ipad/i', $this->agent) ) { |
|
301 | + $this->isTablet = true; |
|
302 | + } |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
305 | + /** |
|
306 | 306 | * Determine if the browser is Robot or not |
307 | 307 | */ |
308 | - protected function checkBot() { |
|
309 | - if (preg_match('/bot/i', $this->agent) ) { |
|
310 | - $this->isRobot = true; |
|
311 | - } |
|
312 | - } |
|
308 | + protected function checkBot() { |
|
309 | + if (preg_match('/bot/i', $this->agent) ) { |
|
310 | + $this->isRobot = true; |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
314 | + /** |
|
315 | 315 | * Detect if URL is loaded from FacebookExternalHit |
316 | 316 | */ |
317 | 317 | protected function checkFacebook() { |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | |
327 | - /** |
|
328 | - * Protected routine to calculate and determine what |
|
329 | - * the browser is in use (including platform) |
|
330 | - */ |
|
327 | + /** |
|
328 | + * Protected routine to calculate and determine what |
|
329 | + * the browser is in use (including platform) |
|
330 | + */ |
|
331 | 331 | protected function determine() { |
332 | 332 | $this->checkPlatform(); |
333 | 333 | $this->checkBrowser(); |
@@ -338,4 +338,4 @@ discard block |
||
338 | 338 | $this->checkFacebook(); |
339 | 339 | } |
340 | 340 | |
341 | - } |
|
341 | + } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | //record the class instance |
93 | 93 | $classes[$class] = isset($params) ? new $class($params) : new $class(); |
94 | - return $classes[$class]; |
|
94 | + return $classes[$class]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -179,17 +179,17 @@ discard block |
||
179 | 179 | die(); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Function defined for PHP error message handling |
|
184 | - * |
|
185 | - * @param int $errno the type of error for example: E_USER_ERROR, E_USER_WARNING, etc. |
|
186 | - * @param string $errstr the error message |
|
187 | - * @param string $errfile the file where the error occurred |
|
188 | - * @param int $errline the line number where the error occurred |
|
189 | - * @codeCoverageIgnore |
|
190 | - * |
|
191 | - * @return boolean |
|
192 | - */ |
|
182 | + /** |
|
183 | + * Function defined for PHP error message handling |
|
184 | + * |
|
185 | + * @param int $errno the type of error for example: E_USER_ERROR, E_USER_WARNING, etc. |
|
186 | + * @param string $errstr the error message |
|
187 | + * @param string $errfile the file where the error occurred |
|
188 | + * @param int $errline the line number where the error occurred |
|
189 | + * @codeCoverageIgnore |
|
190 | + * |
|
191 | + * @return boolean |
|
192 | + */ |
|
193 | 193 | function fw_error_handler($errno, $errstr, $errfile, $errline) { |
194 | 194 | $isError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errno) === $errno); |
195 | 195 | if ($isError) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | E_RECOVERABLE_ERROR => 'Catchable Fatal Error' |
213 | 213 | ); |
214 | 214 | if (isset($errorsType[$errno])) { |
215 | - $errorType = $errorsType[$errno]; |
|
215 | + $errorType = $errorsType[$errno]; |
|
216 | 216 | } |
217 | 217 | $errorText = 'An error is occurred in the file ' . $errfile . ' at line ' . $errline . ' raison : ' . $errstr; |
218 | 218 | if ((error_reporting() & $errno) !== $errno) { |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | $addresses = array(); |
396 | 396 | foreach ($pairs as $name => $email) { |
397 | 397 | if (is_numeric($name)) { |
398 | - $name = null; |
|
398 | + $name = null; |
|
399 | 399 | } |
400 | 400 | $addresses[] = $this->formatHeader($email, $name); |
401 | 401 | } |
@@ -837,10 +837,10 @@ discard block |
||
837 | 837 | return $headers; |
838 | 838 | } |
839 | 839 | |
840 | - /** |
|
841 | - * Get the attachment message for send or the simple message |
|
842 | - * @return string |
|
843 | - */ |
|
840 | + /** |
|
841 | + * Get the attachment message for send or the simple message |
|
842 | + * @return string |
|
843 | + */ |
|
844 | 844 | protected function getMessageWithAttachmentForSend() { |
845 | 845 | $message = $this->getWrapMessage(); |
846 | 846 | if ($this->hasAttachments()) { |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | */ |
871 | 871 | protected function sendHelloCommand() { |
872 | 872 | $responseCode = $this->sendCommand('EHLO ' . $this->getSmtpClientHostname()) |
873 | - ->getSmtpResponseCode(); |
|
873 | + ->getSmtpResponseCode(); |
|
874 | 874 | if ($responseCode !== 250) { |
875 | 875 | $this->error = $this->smtpResponse; |
876 | 876 | return false; |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | $message = $this->getMessageWithAttachmentForSend(); |
1018 | 1018 | $headers = $this->getHeadersForSend(); |
1019 | 1019 | $this->logger->info('Sending new mail using mail protocol, the information are listed below: ' |
1020 | - . 'destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message); |
|
1020 | + . 'destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message); |
|
1021 | 1021 | $result = mail($to, $this->subject, $message, $headers, $this->params); |
1022 | 1022 | if (!$result) { |
1023 | 1023 | $this->error = 'Error when sending mail using mail protocol'; |
@@ -1025,10 +1025,10 @@ discard block |
||
1025 | 1025 | return $result; |
1026 | 1026 | } |
1027 | 1027 | |
1028 | - /** |
|
1029 | - * Send mail using "smtp" protocol |
|
1030 | - * @return boolean |
|
1031 | - */ |
|
1028 | + /** |
|
1029 | + * Send mail using "smtp" protocol |
|
1030 | + * @return boolean |
|
1031 | + */ |
|
1032 | 1032 | protected function sendSmtp() { |
1033 | 1033 | if (!$this->smtpConnection()) { |
1034 | 1034 | return false; |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | $message = $this->getMessageWithAttachmentForSend(); |
1039 | 1039 | $headers = $this->getHeadersForSend(); |
1040 | 1040 | $this->logger->info('Sending new mail using SMTP protocol, the information are listed below: ' |
1041 | - . 'destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message); |
|
1041 | + . 'destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message); |
|
1042 | 1042 | $recipients = array_merge($this->to, $this->cc, $this->bcc); |
1043 | 1043 | $commands = array( |
1044 | 1044 | 'mail_from' => array('MAIL FROM: <' . $this->from . '>', 'MAIL_FROM', 250), |
@@ -1089,17 +1089,17 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | |
1092 | - /** |
|
1093 | - * Return the client hostname for SMTP |
|
1094 | - * |
|
1095 | - * There are only two legal types of hostname - either a fully |
|
1096 | - * qualified domain name (eg: "mail.example.com") or an IP literal |
|
1097 | - * (eg: "[1.2.3.4]"). |
|
1098 | - * |
|
1099 | - * @link https://tools.ietf.org/html/rfc5321#section-2.3.5 |
|
1100 | - * @link http://cbl.abuseat.org/namingproblems.html |
|
1101 | - * @return string |
|
1102 | - */ |
|
1092 | + /** |
|
1093 | + * Return the client hostname for SMTP |
|
1094 | + * |
|
1095 | + * There are only two legal types of hostname - either a fully |
|
1096 | + * qualified domain name (eg: "mail.example.com") or an IP literal |
|
1097 | + * (eg: "[1.2.3.4]"). |
|
1098 | + * |
|
1099 | + * @link https://tools.ietf.org/html/rfc5321#section-2.3.5 |
|
1100 | + * @link http://cbl.abuseat.org/namingproblems.html |
|
1101 | + * @return string |
|
1102 | + */ |
|
1103 | 1103 | protected function getSmtpClientHostname() { |
1104 | 1104 | $globals = &class_loader('GlobalVar', 'classes'); |
1105 | 1105 | if ($globals->server('SERVER_NAME')) { |
@@ -79,7 +79,7 @@ |
||
79 | 79 | if ($cookieLang && $this->isValid($cookieLang)) { |
80 | 80 | $this->current = $cookieLang; |
81 | 81 | $this->logger->info('Language from cookie [' . $cfgKey . '] is valid so ' |
82 | - .'we will set the language using the cookie value [' . $cookieLang . ']'); |
|
82 | + .'we will set the language using the cookie value [' . $cookieLang . ']'); |
|
83 | 83 | } else { |
84 | 84 | $this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']'); |
85 | 85 | $this->current = $this->getDefault(); |