| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* E2Pdf Server Helper |
| 5 |
* @copyright Copyright 2017 https://e2pdf.com |
| 6 |
* @license GPLv3 |
| 7 |
* @version 1 |
| 8 |
* @link https://e2pdf.com |
| 9 |
* @since 1.26.19 |
| 10 |
*/ |
| 11 |
if (!defined('ABSPATH')) { |
| 12 |
die('Access denied.'); |
| 13 |
} |
| 14 |
|
| 15 |
class Helper_E2pdf_Server { |
| 16 |
|
| 17 |
public function get($key = false) { |
| 18 |
if ($key) { |
| 19 |
return isset($_SERVER[$key]) ? wp_strip_all_tags(wp_unslash($_SERVER[$key])) : ''; |
| 20 |
} |
| 21 |
return ''; |
| 22 |
} |
| 23 |
|
| 24 |
public function isMobile() { |
| 25 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 26 |
if (stripos($userAgent, 'Mobile') !== false || stripos($userAgent, 'Android') !== false) { |
| 27 |
return true; |
| 28 |
} |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
public function isIOS() { |
| 33 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 34 |
if (stripos($userAgent, 'iPhone') !== false || stripos($userAgent, 'iPad') !== false || stripos($userAgent, 'iPod') !== false) { |
| 35 |
return true; |
| 36 |
} |
| 37 |
return false; |
| 38 |
} |
| 39 |
|
| 40 |
public function isSafari() { |
| 41 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 42 |
if (stripos($userAgent, 'AppleWebKit') !== false && stripos($userAgent, 'Safari') !== false && stripos($userAgent, 'CriOS') === false) { |
| 43 |
return true; |
| 44 |
} |
| 45 |
return false; |
| 46 |
} |
| 47 |
|
| 48 |
public function isChrome() { |
| 49 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 50 |
if (stripos($userAgent, 'CriOS') !== false || stripos($userAgent, 'Chrome') !== false) { |
| 51 |
return true; |
| 52 |
} |
| 53 |
return false; |
| 54 |
} |
| 55 |
|
| 56 |
public function isOpera() { |
| 57 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 58 |
if (stripos($userAgent, 'OPR') !== false || stripos($userAgent, 'OPT') !== false) { |
| 59 |
return true; |
| 60 |
} |
| 61 |
return false; |
| 62 |
} |
| 63 |
|
| 64 |
public function isFirefox() { |
| 65 |
$userAgent = $this->get('HTTP_USER_AGENT'); |
| 66 |
if (stripos($userAgent, 'FxiOS') !== false || stripos($userAgent, 'Firefox') !== false) { |
| 67 |
return true; |
| 68 |
} |
| 69 |
return false; |
| 70 |
} |
| 71 |
|
| 72 |
public function isLoaderSupported() { |
| 73 |
if ($this->isIOS() && $this->isFirefox()) { |
| 74 |
return false; |
| 75 |
} elseif ($this->isMobile() && $this->isOpera()) { |
| 76 |
return false; |
| 77 |
} |
| 78 |
return true; |
| 79 |
} |
| 80 |
|
| 81 |
public function isPrintingSupported() { |
| 82 |
if ($this->isMobile() || $this->isIOS()) { |
| 83 |
return false; |
| 84 |
} |
| 85 |
return true; |
| 86 |
} |
| 87 |
|
| 88 |
public function isViewerSupported() { |
| 89 |
if ($this->isMobile() && $this->isChrome()) { |
| 90 |
return false; |
| 91 |
} elseif ($this->isIOS() && $this->isChrome()) { |
| 92 |
return false; |
| 93 |
} |
| 94 |
return true; |
| 95 |
} |
| 96 |
} |
| 97 |
|