@@ -277,10 +277,10 @@ discard block |
||
| 277 | 277 | return $this; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - /** |
|
| 281 | - * Get the uploade file array |
|
| 282 | - * @return array |
|
| 283 | - */ |
|
| 280 | + /** |
|
| 281 | + * Get the uploade file array |
|
| 282 | + * @return array |
|
| 283 | + */ |
|
| 284 | 284 | public function getUploadedFileData() { |
| 285 | 285 | return $this->uploadedFileData; |
| 286 | 286 | } |
@@ -320,10 +320,10 @@ discard block |
||
| 320 | 320 | return $this; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Get the filename |
|
| 325 | - * @return string |
|
| 326 | - */ |
|
| 323 | + /** |
|
| 324 | + * Get the filename |
|
| 325 | + * @return string |
|
| 326 | + */ |
|
| 327 | 327 | public function getFilename() { |
| 328 | 328 | return $this->filename; |
| 329 | 329 | } |
@@ -352,23 +352,23 @@ discard block |
||
| 352 | 352 | return $this; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - /** |
|
| 356 | - * Get the max file size |
|
| 357 | - * @return double|int |
|
| 358 | - */ |
|
| 355 | + /** |
|
| 356 | + * Get the max file size |
|
| 357 | + * @return double|int |
|
| 358 | + */ |
|
| 359 | 359 | public function getMaxFileSize() { |
| 360 | 360 | return $this->maxFileSize; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - /** |
|
| 364 | - * Append a mime type to allowed mime types |
|
| 365 | - * |
|
| 366 | - * @since 1.0 |
|
| 367 | - * @version 1.0.1 |
|
| 368 | - * @param string $mime |
|
| 369 | - * @return object |
|
| 370 | - * @method boolean setAllowMimeType |
|
| 371 | - */ |
|
| 363 | + /** |
|
| 364 | + * Append a mime type to allowed mime types |
|
| 365 | + * |
|
| 366 | + * @since 1.0 |
|
| 367 | + * @version 1.0.1 |
|
| 368 | + * @param string $mime |
|
| 369 | + * @return object |
|
| 370 | + * @method boolean setAllowMimeType |
|
| 371 | + */ |
|
| 372 | 372 | public function setAllowMimeType($mime) { |
| 373 | 373 | $this->allowedMimeTypes[] = strtolower($mime); |
| 374 | 374 | $this->file['allowed_mime_types'][] = strtolower($mime); |
@@ -485,10 +485,10 @@ discard block |
||
| 485 | 485 | return $this; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - /** |
|
| 489 | - * Get the upload function name like "copy", "move_uploaded_file" |
|
| 490 | - * @return string |
|
| 491 | - */ |
|
| 488 | + /** |
|
| 489 | + * Get the upload function name like "copy", "move_uploaded_file" |
|
| 490 | + * @return string |
|
| 491 | + */ |
|
| 492 | 492 | public function getUploadFunction() { |
| 493 | 493 | return $this->uploadFunction; |
| 494 | 494 | } |
@@ -506,10 +506,10 @@ discard block |
||
| 506 | 506 | return $this; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - /** |
|
| 510 | - * Get the allow overwriting |
|
| 511 | - * @return boolean |
|
| 512 | - */ |
|
| 509 | + /** |
|
| 510 | + * Get the allow overwriting |
|
| 511 | + * @return boolean |
|
| 512 | + */ |
|
| 513 | 513 | public function isAllowOverwriting() { |
| 514 | 514 | return $this->overwriteFile ; |
| 515 | 515 | } |
@@ -614,14 +614,14 @@ discard block |
||
| 614 | 614 | return $this->error; |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - /** |
|
| 618 | - * Retrive status of upload |
|
| 619 | - * |
|
| 620 | - * @since 1.0 |
|
| 621 | - * @version 1.0 |
|
| 622 | - * @return boolean |
|
| 623 | - * @method boolean getStatus |
|
| 624 | - */ |
|
| 617 | + /** |
|
| 618 | + * Retrive status of upload |
|
| 619 | + * |
|
| 620 | + * @since 1.0 |
|
| 621 | + * @version 1.0 |
|
| 622 | + * @return boolean |
|
| 623 | + * @method boolean getStatus |
|
| 624 | + */ |
|
| 625 | 625 | public function getStatus() { |
| 626 | 626 | return $this->file['status']; |
| 627 | 627 | } |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | && is_file($file); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - /** |
|
| 658 | - * Set the filename if is empty using the uploaded data information |
|
| 659 | - * |
|
| 660 | - * @return object the current instance |
|
| 661 | - */ |
|
| 657 | + /** |
|
| 658 | + * Set the filename if is empty using the uploaded data information |
|
| 659 | + * |
|
| 660 | + * @return object the current instance |
|
| 661 | + */ |
|
| 662 | 662 | protected function setFilenameUsingUploadedData() { |
| 663 | 663 | // set original filename if not have a new name |
| 664 | 664 | if (empty($this->filename)) { |
@@ -742,12 +742,12 @@ discard block |
||
| 742 | 742 | return $this->maxFileSize >= $size; |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - /** |
|
| 746 | - * Check the file overwritting |
|
| 747 | - * @since 1.0 |
|
| 748 | - * @version 1.0 |
|
| 749 | - * @return boolean |
|
| 750 | - */ |
|
| 745 | + /** |
|
| 746 | + * Check the file overwritting |
|
| 747 | + * @since 1.0 |
|
| 748 | + * @version 1.0 |
|
| 749 | + * @return boolean |
|
| 750 | + */ |
|
| 751 | 751 | protected function checkFileOverwritting() { |
| 752 | 752 | if ($this->fileExists($this->destinationDirectory . $this->filename)) { |
| 753 | 753 | return $this->overwriteFile; |
@@ -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) { |