@@ -6,79 +6,79 @@ discard block |
||
6 | 6 | class EEM_System_Status |
7 | 7 | { |
8 | 8 | |
9 | - // private instance of the EEM_System_Status object |
|
10 | - protected static $_instance = null; |
|
9 | + // private instance of the EEM_System_Status object |
|
10 | + protected static $_instance = null; |
|
11 | 11 | |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * This function is a singleton method used to instantiate the EEM_Attendee object |
|
16 | - * |
|
17 | - * @access public |
|
18 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
19 | - * @return EEM_System_Status |
|
20 | - */ |
|
21 | - public static function instance() |
|
22 | - { |
|
14 | + /** |
|
15 | + * This function is a singleton method used to instantiate the EEM_Attendee object |
|
16 | + * |
|
17 | + * @access public |
|
18 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
|
19 | + * @return EEM_System_Status |
|
20 | + */ |
|
21 | + public static function instance() |
|
22 | + { |
|
23 | 23 | |
24 | - // check if instance of EEM_System_Status already exists |
|
25 | - if (self::$_instance === null) { |
|
26 | - // instantiate EEM_System_Status |
|
27 | - self::$_instance = new self(); |
|
28 | - } |
|
29 | - return self::$_instance; |
|
30 | - } |
|
31 | - private function __construct() |
|
32 | - { |
|
33 | - } |
|
34 | - /** |
|
35 | - * |
|
36 | - * @return array where each key is a function name on this class, and each value is SOMETHING-- |
|
37 | - * it might be a value, an array, or an object |
|
38 | - */ |
|
39 | - public function get_system_stati() |
|
40 | - { |
|
41 | - return apply_filters( |
|
42 | - 'FHEE__EEM_System_Status__get_system_stati', |
|
43 | - array( |
|
44 | - 'ee_version'=>$this->get_ee_version(), |
|
45 | - 'ee_activation_history'=>$this->get_ee_activation_history(), |
|
46 | - 'ee_config'=>$this->get_ee_config(), |
|
47 | - 'ee_migration_history'=>$this->get_ee_migration_history(), |
|
48 | - 'active_plugins'=>$this->get_active_plugins(), |
|
49 | - 'wp_settings'=>$this->get_wp_settings(), |
|
50 | - 'wp_maintenance_mode' => $this->get_wp_maintenance_mode(), |
|
51 | - 'https_enabled'=>$this->get_https_enabled(), |
|
52 | - 'logging_enabled' => $this->get_logging_enabled(), |
|
53 | - 'remote_posting' => $this->get_remote_posting(), |
|
54 | - 'php_version'=>$this->php_version(), |
|
55 | - 'php.ini_settings'=>$this->get_php_ini_all(), |
|
56 | - 'php_info'=>$this->get_php_info(), |
|
57 | - ), |
|
58 | - $this |
|
59 | - ); |
|
60 | - } |
|
61 | - /** |
|
62 | - * |
|
63 | - * @return string |
|
64 | - */ |
|
65 | - public function get_ee_version() |
|
66 | - { |
|
67 | - return espresso_version(); |
|
68 | - } |
|
69 | - /** |
|
70 | - * |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function php_version() |
|
74 | - { |
|
75 | - return phpversion(); |
|
76 | - } |
|
77 | - /** |
|
78 | - * |
|
79 | - * @return array, where each key is a plugin name (lower-cased), values are sub-arrays. |
|
80 | - * Sub-arrays like described in wp function get_plugin_data. Ie, * |
|
81 | - * 'Name' => 'Plugin Name', |
|
24 | + // check if instance of EEM_System_Status already exists |
|
25 | + if (self::$_instance === null) { |
|
26 | + // instantiate EEM_System_Status |
|
27 | + self::$_instance = new self(); |
|
28 | + } |
|
29 | + return self::$_instance; |
|
30 | + } |
|
31 | + private function __construct() |
|
32 | + { |
|
33 | + } |
|
34 | + /** |
|
35 | + * |
|
36 | + * @return array where each key is a function name on this class, and each value is SOMETHING-- |
|
37 | + * it might be a value, an array, or an object |
|
38 | + */ |
|
39 | + public function get_system_stati() |
|
40 | + { |
|
41 | + return apply_filters( |
|
42 | + 'FHEE__EEM_System_Status__get_system_stati', |
|
43 | + array( |
|
44 | + 'ee_version'=>$this->get_ee_version(), |
|
45 | + 'ee_activation_history'=>$this->get_ee_activation_history(), |
|
46 | + 'ee_config'=>$this->get_ee_config(), |
|
47 | + 'ee_migration_history'=>$this->get_ee_migration_history(), |
|
48 | + 'active_plugins'=>$this->get_active_plugins(), |
|
49 | + 'wp_settings'=>$this->get_wp_settings(), |
|
50 | + 'wp_maintenance_mode' => $this->get_wp_maintenance_mode(), |
|
51 | + 'https_enabled'=>$this->get_https_enabled(), |
|
52 | + 'logging_enabled' => $this->get_logging_enabled(), |
|
53 | + 'remote_posting' => $this->get_remote_posting(), |
|
54 | + 'php_version'=>$this->php_version(), |
|
55 | + 'php.ini_settings'=>$this->get_php_ini_all(), |
|
56 | + 'php_info'=>$this->get_php_info(), |
|
57 | + ), |
|
58 | + $this |
|
59 | + ); |
|
60 | + } |
|
61 | + /** |
|
62 | + * |
|
63 | + * @return string |
|
64 | + */ |
|
65 | + public function get_ee_version() |
|
66 | + { |
|
67 | + return espresso_version(); |
|
68 | + } |
|
69 | + /** |
|
70 | + * |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function php_version() |
|
74 | + { |
|
75 | + return phpversion(); |
|
76 | + } |
|
77 | + /** |
|
78 | + * |
|
79 | + * @return array, where each key is a plugin name (lower-cased), values are sub-arrays. |
|
80 | + * Sub-arrays like described in wp function get_plugin_data. Ie, * |
|
81 | + * 'Name' => 'Plugin Name', |
|
82 | 82 | 'PluginURI' => 'Plugin URI', |
83 | 83 | 'Version' => 'Version', |
84 | 84 | 'Description' => 'Description', |
@@ -87,221 +87,221 @@ discard block |
||
87 | 87 | 'TextDomain' => 'Text Domain', |
88 | 88 | 'DomainPath' => 'Domain Path', |
89 | 89 | 'Network' => 'Network', |
90 | - */ |
|
91 | - public function get_active_plugins() |
|
92 | - { |
|
93 | - $active_plugins = (array) get_option('active_plugins', array()); |
|
94 | - if (is_multisite()) { |
|
95 | - $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
96 | - } |
|
97 | - $active_plugins = array_map('strtolower', $active_plugins); |
|
98 | - $plugin_info = array(); |
|
99 | - foreach ($active_plugins as $plugin) { |
|
100 | - $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
90 | + */ |
|
91 | + public function get_active_plugins() |
|
92 | + { |
|
93 | + $active_plugins = (array) get_option('active_plugins', array()); |
|
94 | + if (is_multisite()) { |
|
95 | + $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array())); |
|
96 | + } |
|
97 | + $active_plugins = array_map('strtolower', $active_plugins); |
|
98 | + $plugin_info = array(); |
|
99 | + foreach ($active_plugins as $plugin) { |
|
100 | + $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin); |
|
101 | 101 | |
102 | - $plugin_info[ $plugin ] = $plugin_data; |
|
103 | - } |
|
104 | - return $plugin_info; |
|
105 | - } |
|
102 | + $plugin_info[ $plugin ] = $plugin_data; |
|
103 | + } |
|
104 | + return $plugin_info; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * |
|
109 | - * @return array with keys 'home_url' and 'site_url' |
|
110 | - */ |
|
111 | - public function get_wp_settings() |
|
112 | - { |
|
113 | - $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
|
114 | - if ($wp_memory_int < 67108864) { |
|
115 | - $wp_memory_to_display = '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"') . '</mark>'; |
|
116 | - } else { |
|
117 | - $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>'; |
|
118 | - } |
|
119 | - return array( |
|
120 | - 'name'=>get_bloginfo('name', 'display'), |
|
121 | - 'is_multisite'=>is_multisite(), |
|
122 | - 'version'=> get_bloginfo('version', 'display'), |
|
123 | - 'home_url'=>home_url(), |
|
124 | - 'site_url'=>site_url(), |
|
125 | - 'WP_DEBUG'=>WP_DEBUG, |
|
126 | - 'permalink_structure'=>get_option('permalink_structure'), |
|
127 | - 'theme'=>wp_get_theme(), |
|
128 | - 'gmt_offset'=>get_option('gmt_offset'), |
|
129 | - 'timezone_string'=>get_option('timezone_string'), |
|
130 | - 'admin_email'=> get_bloginfo('admin_email', 'display'), |
|
131 | - 'language'=>get_bloginfo('language', 'display'), |
|
132 | - 'wp_max_upload_size' => size_format(wp_max_upload_size()), |
|
133 | - 'wp_memory' => $wp_memory_to_display |
|
134 | - ); |
|
135 | - } |
|
107 | + /** |
|
108 | + * |
|
109 | + * @return array with keys 'home_url' and 'site_url' |
|
110 | + */ |
|
111 | + public function get_wp_settings() |
|
112 | + { |
|
113 | + $wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT); |
|
114 | + if ($wp_memory_int < 67108864) { |
|
115 | + $wp_memory_to_display = '<mark class="error">' . sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"') . '</mark>'; |
|
116 | + } else { |
|
117 | + $wp_memory_to_display = '<mark class="yes">' . size_format($wp_memory_int) . '</mark>'; |
|
118 | + } |
|
119 | + return array( |
|
120 | + 'name'=>get_bloginfo('name', 'display'), |
|
121 | + 'is_multisite'=>is_multisite(), |
|
122 | + 'version'=> get_bloginfo('version', 'display'), |
|
123 | + 'home_url'=>home_url(), |
|
124 | + 'site_url'=>site_url(), |
|
125 | + 'WP_DEBUG'=>WP_DEBUG, |
|
126 | + 'permalink_structure'=>get_option('permalink_structure'), |
|
127 | + 'theme'=>wp_get_theme(), |
|
128 | + 'gmt_offset'=>get_option('gmt_offset'), |
|
129 | + 'timezone_string'=>get_option('timezone_string'), |
|
130 | + 'admin_email'=> get_bloginfo('admin_email', 'display'), |
|
131 | + 'language'=>get_bloginfo('language', 'display'), |
|
132 | + 'wp_max_upload_size' => size_format(wp_max_upload_size()), |
|
133 | + 'wp_memory' => $wp_memory_to_display |
|
134 | + ); |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Gets an array of information about the history of ee versions installed |
|
139 | - * @return array |
|
140 | - */ |
|
141 | - public function get_ee_activation_history() |
|
142 | - { |
|
143 | - return get_option('espresso_db_update'); |
|
144 | - } |
|
137 | + /** |
|
138 | + * Gets an array of information about the history of ee versions installed |
|
139 | + * @return array |
|
140 | + */ |
|
141 | + public function get_ee_activation_history() |
|
142 | + { |
|
143 | + return get_option('espresso_db_update'); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed |
|
149 | - * @return EE_Data_Migration_Script_Base[] |
|
150 | - */ |
|
151 | - public function get_ee_migration_history() |
|
152 | - { |
|
153 | - $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
|
154 | - $presentable_migration_scripts = array(); |
|
155 | - foreach ($options as $option_array) { |
|
156 | - $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']); |
|
157 | - } |
|
158 | - return $presentable_migration_scripts; |
|
147 | + /** |
|
148 | + * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed |
|
149 | + * @return EE_Data_Migration_Script_Base[] |
|
150 | + */ |
|
151 | + public function get_ee_migration_history() |
|
152 | + { |
|
153 | + $options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options(); |
|
154 | + $presentable_migration_scripts = array(); |
|
155 | + foreach ($options as $option_array) { |
|
156 | + $presentable_migration_scripts[ str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name']) ] = maybe_unserialize($option_array['option_value']); |
|
157 | + } |
|
158 | + return $presentable_migration_scripts; |
|
159 | 159 | // return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran(); |
160 | - } |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * |
|
164 | - * @return array like EE_Config class |
|
165 | - */ |
|
166 | - public function get_ee_config() |
|
167 | - { |
|
168 | - return EE_Config::instance(); |
|
169 | - } |
|
162 | + /** |
|
163 | + * |
|
164 | + * @return array like EE_Config class |
|
165 | + */ |
|
166 | + public function get_ee_config() |
|
167 | + { |
|
168 | + return EE_Config::instance(); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463 |
|
173 | - * @return array like the output of phpinfo(), but in an array |
|
174 | - */ |
|
175 | - public function get_php_info() |
|
176 | - { |
|
177 | - ob_start(); |
|
178 | - phpinfo(-1); |
|
171 | + /** |
|
172 | + * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463 |
|
173 | + * @return array like the output of phpinfo(), but in an array |
|
174 | + */ |
|
175 | + public function get_php_info() |
|
176 | + { |
|
177 | + ob_start(); |
|
178 | + phpinfo(-1); |
|
179 | 179 | |
180 | - $pi = preg_replace( |
|
181 | - array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
|
182 | - '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
183 | - "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
|
184 | - '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
|
185 | - .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
|
186 | - '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
|
187 | - '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
|
188 | - "# +#", '#<tr>#', '#</tr>#'), |
|
189 | - array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
190 | - '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
|
191 | - "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
|
192 | - '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
|
193 | - '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
194 | - '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
|
195 | - ob_get_clean() |
|
196 | - ); |
|
180 | + $pi = preg_replace( |
|
181 | + array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms', |
|
182 | + '#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#', |
|
183 | + "#[ \t]+#", '# #', '# +#', '# class=".*?"#', '%'%', |
|
184 | + '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>' |
|
185 | + .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#', |
|
186 | + '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#', |
|
187 | + '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#', |
|
188 | + "# +#", '#<tr>#', '#</tr>#'), |
|
189 | + array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ', |
|
190 | + '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'. |
|
191 | + "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>', |
|
192 | + '<tr><td>PHP Credits Egg</td><td>$1</td></tr>', |
|
193 | + '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" . |
|
194 | + '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'), |
|
195 | + ob_get_clean() |
|
196 | + ); |
|
197 | 197 | |
198 | - $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>')); |
|
199 | - unset($sections[0]); |
|
198 | + $sections = explode('<h2>', strip_tags($pi, '<h2><th><td>')); |
|
199 | + unset($sections[0]); |
|
200 | 200 | |
201 | - $pi = array(); |
|
202 | - foreach ($sections as $section) { |
|
203 | - $n = substr($section, 0, strpos($section, '</h2>')); |
|
204 | - preg_match_all( |
|
205 | - '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
|
206 | - $section, |
|
207 | - $askapache, |
|
208 | - PREG_SET_ORDER |
|
209 | - ); |
|
210 | - foreach ($askapache as $m) { |
|
211 | - $m2 = isset($m[2]) ? $m[2] : null; |
|
212 | - } |
|
213 | - $pi[ $n ][ $m[1] ]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m, 2); |
|
214 | - } |
|
201 | + $pi = array(); |
|
202 | + foreach ($sections as $section) { |
|
203 | + $n = substr($section, 0, strpos($section, '</h2>')); |
|
204 | + preg_match_all( |
|
205 | + '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#', |
|
206 | + $section, |
|
207 | + $askapache, |
|
208 | + PREG_SET_ORDER |
|
209 | + ); |
|
210 | + foreach ($askapache as $m) { |
|
211 | + $m2 = isset($m[2]) ? $m[2] : null; |
|
212 | + } |
|
213 | + $pi[ $n ][ $m[1] ]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m, 2); |
|
214 | + } |
|
215 | 215 | |
216 | - return $pi; |
|
217 | - } |
|
216 | + return $pi; |
|
217 | + } |
|
218 | 218 | |
219 | - /** |
|
220 | - * Checks if site responds ot HTTPS |
|
221 | - * @return boolean |
|
222 | - */ |
|
223 | - public function get_https_enabled() |
|
224 | - { |
|
225 | - $home = str_replace("http://", "https://", home_url()); |
|
226 | - $response = wp_remote_get($home); |
|
227 | - if ($response instanceof WP_Error) { |
|
228 | - $error_string = ''; |
|
229 | - foreach ($response->errors as $short_name => $description_array) { |
|
230 | - $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array); |
|
231 | - } |
|
232 | - return $error_string; |
|
233 | - } |
|
234 | - return "ok!"; |
|
235 | - } |
|
236 | - /** |
|
237 | - * Whether or not a .maintenance file is detected |
|
238 | - * @return string descripting wp_maintenance_mode status |
|
239 | - */ |
|
240 | - public function get_wp_maintenance_mode() |
|
241 | - { |
|
242 | - $opened = file_exists(ABSPATH . '.maintenance'); |
|
243 | - return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso') ; |
|
244 | - } |
|
245 | - /** |
|
246 | - * Whether or not logging is enabled |
|
247 | - * @return string descripting logging's status |
|
248 | - */ |
|
249 | - public function get_logging_enabled() |
|
250 | - { |
|
251 | - $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a'); |
|
252 | - return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ; |
|
253 | - } |
|
254 | - /** |
|
255 | - * Whether curl ro fsock works |
|
256 | - * @return string describing posting's status |
|
257 | - */ |
|
258 | - public function get_remote_posting() |
|
259 | - { |
|
260 | - $fsock_works = function_exists('fsockopen'); |
|
261 | - $curl_works = function_exists('curl_init'); |
|
262 | - if ($fsock_works && $curl_works) { |
|
263 | - $status = __('Your server has fsockopen and cURL enabled.', 'event_espresso'); |
|
264 | - } elseif ($fsock_works) { |
|
265 | - $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
|
266 | - } elseif ($curl_works) { |
|
267 | - $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
|
268 | - } else { |
|
269 | - $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
270 | - } |
|
271 | - return $status; |
|
272 | - } |
|
273 | - /** |
|
274 | - * Gets all the php.ini settings |
|
275 | - * @return array |
|
276 | - */ |
|
277 | - public function get_php_ini_all() |
|
278 | - { |
|
279 | - return ini_get_all(); |
|
280 | - } |
|
281 | - /** |
|
282 | - * Transforms the php.ini notation for numbers (like '2M') to an integer. |
|
283 | - * |
|
284 | - * @param type $size |
|
285 | - * @return int |
|
286 | - */ |
|
287 | - public function let_to_num($size) |
|
288 | - { |
|
289 | - $l = substr($size, -1); |
|
290 | - $ret = substr($size, 0, -1); |
|
291 | - // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
292 | - switch (strtoupper($l)) { |
|
293 | - case 'P': |
|
294 | - $ret *= 1024; |
|
295 | - case 'T': |
|
296 | - $ret *= 1024; |
|
297 | - case 'G': |
|
298 | - $ret *= 1024; |
|
299 | - case 'M': |
|
300 | - $ret *= 1024; |
|
301 | - case 'K': |
|
302 | - $ret *= 1024; |
|
303 | - } |
|
304 | - // phpcs:enable |
|
305 | - return $ret; |
|
306 | - } |
|
219 | + /** |
|
220 | + * Checks if site responds ot HTTPS |
|
221 | + * @return boolean |
|
222 | + */ |
|
223 | + public function get_https_enabled() |
|
224 | + { |
|
225 | + $home = str_replace("http://", "https://", home_url()); |
|
226 | + $response = wp_remote_get($home); |
|
227 | + if ($response instanceof WP_Error) { |
|
228 | + $error_string = ''; |
|
229 | + foreach ($response->errors as $short_name => $description_array) { |
|
230 | + $error_string .= "<b>$short_name</b>: ".implode(", ", $description_array); |
|
231 | + } |
|
232 | + return $error_string; |
|
233 | + } |
|
234 | + return "ok!"; |
|
235 | + } |
|
236 | + /** |
|
237 | + * Whether or not a .maintenance file is detected |
|
238 | + * @return string descripting wp_maintenance_mode status |
|
239 | + */ |
|
240 | + public function get_wp_maintenance_mode() |
|
241 | + { |
|
242 | + $opened = file_exists(ABSPATH . '.maintenance'); |
|
243 | + return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso') ; |
|
244 | + } |
|
245 | + /** |
|
246 | + * Whether or not logging is enabled |
|
247 | + * @return string descripting logging's status |
|
248 | + */ |
|
249 | + public function get_logging_enabled() |
|
250 | + { |
|
251 | + $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a'); |
|
252 | + return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>') ; |
|
253 | + } |
|
254 | + /** |
|
255 | + * Whether curl ro fsock works |
|
256 | + * @return string describing posting's status |
|
257 | + */ |
|
258 | + public function get_remote_posting() |
|
259 | + { |
|
260 | + $fsock_works = function_exists('fsockopen'); |
|
261 | + $curl_works = function_exists('curl_init'); |
|
262 | + if ($fsock_works && $curl_works) { |
|
263 | + $status = __('Your server has fsockopen and cURL enabled.', 'event_espresso'); |
|
264 | + } elseif ($fsock_works) { |
|
265 | + $status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso'); |
|
266 | + } elseif ($curl_works) { |
|
267 | + $status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso'); |
|
268 | + } else { |
|
269 | + $status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>'; |
|
270 | + } |
|
271 | + return $status; |
|
272 | + } |
|
273 | + /** |
|
274 | + * Gets all the php.ini settings |
|
275 | + * @return array |
|
276 | + */ |
|
277 | + public function get_php_ini_all() |
|
278 | + { |
|
279 | + return ini_get_all(); |
|
280 | + } |
|
281 | + /** |
|
282 | + * Transforms the php.ini notation for numbers (like '2M') to an integer. |
|
283 | + * |
|
284 | + * @param type $size |
|
285 | + * @return int |
|
286 | + */ |
|
287 | + public function let_to_num($size) |
|
288 | + { |
|
289 | + $l = substr($size, -1); |
|
290 | + $ret = substr($size, 0, -1); |
|
291 | + // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment |
|
292 | + switch (strtoupper($l)) { |
|
293 | + case 'P': |
|
294 | + $ret *= 1024; |
|
295 | + case 'T': |
|
296 | + $ret *= 1024; |
|
297 | + case 'G': |
|
298 | + $ret *= 1024; |
|
299 | + case 'M': |
|
300 | + $ret *= 1024; |
|
301 | + case 'K': |
|
302 | + $ret *= 1024; |
|
303 | + } |
|
304 | + // phpcs:enable |
|
305 | + return $ret; |
|
306 | + } |
|
307 | 307 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.008'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.68.rc.008'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |