PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.3
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.3
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / webp / class-wpo-server-info.php

class-wpo-server-info.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.3, at webp/class-wpo-server-info.php

105 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('WPO_PLUGIN_MAIN_PATH')) die('No direct access allowed');
3
4 class WPO_Server_Info {
5
6 private static $_instance = null;
7
8 /**
9 * @var $_server_name Web server engine name
10 */
11 private $_server_name;
12
13 /**
14 * @var $_rewrite_status Web server's URL rewrite ability
15 */
16 private $_rewrite_status;
17
18 /**
19 * Setup server information
20 */
21 public function __construct() {
22 $this->set_server_name();
23 $this->set_rewrite_status();
24 }
25
26 /**
27 * Gets singleton instance
28 *
29 * @return object
30 */
31 public static function get_instance() {
32 if (null === self::$_instance) {
33 self::$_instance = new self();
34 }
35 return self::$_instance;
36 }
37
38 /**
39 * Detect and set web server names
40 */
41 private function set_server_name() {
42 global $is_apache, $is_nginx, $is_iis7, $is_IIS;
43
44 if ($is_apache) {
45 $this->_server_name = 'apache';
46 }
47
48 if ($is_iis7) {
49 $this->_server_name = 'iis7';
50 }
51
52 if ($is_IIS) {
53 $this->_server_name = 'iis';
54 }
55
56 if ($is_nginx) {
57 $this->_server_name = 'nginx';
58 }
59 }
60
61 /**
62 * Sets web server's rewrite ability
63 */
64 private function set_rewrite_status() {
65 if ('apache' === $this->_server_name) {
66 $this->test_htaccess_capabilities();
67 } else {
68 $this->_rewrite_status = false;
69 }
70 }
71
72 /**
73 * Test Apache/LiteSpeed server's htaccess capabilities, and sets status and info
74 */
75 private function test_htaccess_capabilities() {
76 if (!class_exists('WPO_Htaccess_Capabilities')) {
77 include_once WPO_PLUGIN_MAIN_PATH . 'webp/class-wpo-htaccess-capabilities.php';
78 }
79 $htc = WPO_Htaccess_Capabilities::get_instance();
80 if ($htc->htaccess_enabled && $htc->mod_rewrite && $htc->mod_headers && $htc->mod_mime) {
81 $this->_rewrite_status = true;
82 } elseif ($htc->htaccess_enabled) {
83 $this->_rewrite_status = false;
84 }
85 }
86
87 /**
88 * Getter for web server name
89 *
90 * @return string
91 */
92 public function get_server_name() {
93 return $this->_server_name;
94 }
95
96 /**
97 * Getter for web server's rewrite capability
98 *
99 * @return bool
100 */
101 public function get_rewrite_status() {
102 return $this->_rewrite_status;
103 }
104 }
105