PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.1.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.1.2
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Inc/Classes/ServerInfo.php +38 -51 4.2.124.0.1.2 View file →
@@ -1,14 +1,16 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Classes;
3 +namespace WPAdminify\Inc\Classes;
4 4
5 +use WPAdminify\Inc\Utils;
6 +
5 7 // no direct access allowed
6 8 if (!defined('ABSPATH')) {
7 9 exit;
8 10 }
9 11 /**
10 - * PXLBSAdminify
12 + * WPAdminify
11 13 * Admin Menu: Server Info
12 14 *
13 15 * @author Jewel Theme <support@jeweltheme.com>
14 16 */
@@ -37,14 +39,14 @@
37 39 $checks = [];
38 40 foreach ([0, 1] as $i) {
39 41 $cmd = '/proc/stat';
40 42 $lines = [];
41 - $fh = fopen($cmd, 'r'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- reading the /proc special path not supported by WP_Filesystem.
43 + $fh = fopen($cmd, 'r');
42 44 if ($fh) {
43 45 while ($line = fgets($fh)) {
44 46 $lines[] = $line;
45 47 }
46 - fclose($fh); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- closing the /proc special path not supported by WP_Filesystem.
48 + fclose($fh);
47 49 }
48 50 foreach ($lines as $line) {
49 51 $ma = [];
50 52 if (!preg_match('/^cpu (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+) (\d+)$/', $line, $ma)) {
@@ -111,14 +113,13 @@
111 113 public function get_wp_memory_limit()
112 114 {
113 115 $memory_limit = (int) @ini_get('memory_limit') . ' MB' . ' (' . (int) WP_MEMORY_LIMIT . ' MB)';
114 116 if (@ini_get('memory_limit') == '-1') {
115 - $memory_limit = '-1 / ' . esc_html__('Unlimited', 'adminify') . ' (' . (int) WP_MEMORY_LIMIT . ' MB)';
117 + $memory_limit = '-1 / ' . esc_html__('Unlimited', 'adminify-serverinfo') . ' (' . (int) WP_MEMORY_LIMIT . ' MB)';
116 118 }
117 119
118 120 if ((int) WP_MEMORY_LIMIT < (int) @ini_get('memory_limit') && WP_MEMORY_LIMIT != '-1' || (int) WP_MEMORY_LIMIT < (int) @ini_get('memory_limit') && @ini_get('memory_limit') != '-1') {
119 - /* translators: %s: Server PHP memory limit, e.g. "256 MB" */
120 - $memory_limit .= ' <span class="warning"><span class="dashicons dashicons-warning"></span> ' . sprintf(__('The WP PHP Memory Limit is less than the %s Server PHP Memory Limit', 'adminify'), (int) @ini_get('memory_limit') . ' MB') . '!</span>';
121 + $memory_limit .= ' <span class="warning"><span class="dashicons dashicons-warning"></span> ' . sprintf(__('The WP PHP Memory Limit is less than the %s Server PHP Memory Limit', 'adminify-serverinfo'), (int) @ini_get('memory_limit') . ' MB') . '!</span>';
121 122 }
122 123
123 124 return $memory_limit;
124 125 }
@@ -138,10 +139,9 @@
138 139 $php_version = PHP_VERSION;
139 140 }
140 141
141 142 if ($php_version != 'N/A' && version_compare($php_version, '7.3', '<')) {
142 - /* translators: 1: Current PHP version, 2: Link to WordPress requirements page */
143 - $php_version = '<span class="warning"><span class="dashicons dashicons-warning"></span> ' . sprintf(__('%1$s - Recommend PHP version of 7.3. See: %2$s', 'adminify'), esc_html($php_version), '<a href="https://wordpress.org/about/requirements/" target="_blank" rel="noopener">' . __('WordPress Requirements', 'adminify') . '</a>') . '</span>';
143 + $php_version = '<span class="warning"><span class="dashicons dashicons-warning"></span> ' . sprintf(__('%1$s - Recommend PHP version of 7.3. See: %2$s', 'adminify-serverinfo'), esc_html($php_version), '<a href="https://wordpress.org/about/requirements/" target="_blank" rel="noopener">' . __('WordPress Requirements', 'adminify-serverinfo') . '</a>') . '</span>';
144 144 }
145 145
146 146 return $php_version;
147 147 }
@@ -192,13 +192,13 @@
192 192
193 193 // Short Version
194 194 // $db_version = $wpdb->db_server_info();
195 195
196 - $db_version_dump = $wpdb->get_var('SELECT VERSION() AS version from DUAL'); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- direct query required for reading the live MySQL server version; not cached intentionally.
196 + $db_version_dump = $wpdb->get_var('SELECT VERSION() AS version from DUAL');
197 197 if (preg_match('/\d+(?:\.\d+)+/', $db_version_dump, $matches)) {
198 198 $db_version = $matches[0]; // returning the first match
199 199 } else {
200 - $db_version = __('N/A', 'adminify');
200 + $db_version = __('N/A', 'adminify-serverinfo');
201 201 }
202 202 return $db_version;
203 203 }
204 204
@@ -210,15 +210,15 @@
210 210 */
211 211 public function get_db_software()
212 212 {
213 213 global $wpdb;
214 - $db_software_query = $wpdb->get_row("SHOW VARIABLES LIKE 'version_comment'"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- direct query required for reading the live MySQL server variable; not cached intentionally.
214 + $db_software_query = $wpdb->get_row("SHOW VARIABLES LIKE 'version_comment'");
215 215 $db_software_dump = $db_software_query->Value;
216 216 if (!empty($db_software_dump)) {
217 217 $db_soft_array = explode(' ', trim($db_software_dump));
218 218 $db_software = $db_soft_array[0];
219 219 } else {
220 - $db_software = __('N/A', 'adminify');
220 + $db_software = __('N/A', 'adminify-serverinfo');
221 221 }
222 222
223 223 return $db_software;
224 224 }
@@ -285,9 +285,9 @@
285 285 $result = 0;
286 286
287 287 // Linux server
288 288 if ($os == 'Linux') {
289 - $fh = fopen('/proc/meminfo', 'r'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- reading the /proc special path not supported by WP_Filesystem.
289 + $fh = fopen('/proc/meminfo', 'r');
290 290 if ($fh) {
291 291 while ($line = fgets($fh)) {
292 292 $pieces = [];
293 293 if (preg_match('/^MemTotal:\s+(\d+)\skB$/', $line, $pieces)) {
@@ -296,9 +296,9 @@
296 296 $result = round($result / 1024 / 1024, 2);
297 297 break;
298 298 }
299 299 }
300 - fclose($fh); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- closing the /proc special path not supported by WP_Filesystem.
300 + fclose($fh);
301 301 return $result;
302 302 }
303 303 }
304 304
@@ -319,9 +319,9 @@
319 319 $result = 0;
320 320
321 321 // Linux server
322 322 if ($os == 'Linux') {
323 - $fh = fopen('/proc/meminfo', 'r'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- reading the /proc special path not supported by WP_Filesystem.
323 + $fh = fopen('/proc/meminfo', 'r');
324 324 if ($fh) {
325 325 while ($line = fgets($fh)) {
326 326 $pieces = [];
327 327 if (preg_match('/^MemFree:\s+(\d+)\skB$/', $line, $pieces)) {
@@ -329,9 +329,9 @@
329 329 $result = round($pieces[1] / 1024 / 1024, 2);
330 330 break;
331 331 }
332 332 }
333 - fclose($fh); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fclose -- closing the /proc special path not supported by WP_Filesystem.
333 + fclose($fh);
334 334
335 335 return $result;
336 336 }
337 337 }
@@ -354,9 +354,9 @@
354 354 if ($os == 'Linux') {
355 355
356 356 $ram_data = '';
357 357 // Check if it readable
358 - $fh = fopen('/proc/meminfo', 'r'); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen -- reading the /proc special path not supported by WP_Filesystem.
358 + $fh = fopen('/proc/meminfo', 'r');
359 359 if ($fh) {
360 360 foreach (file('/proc/meminfo') as $ri) {
361 361 $m[strtok($ri, ':')] = strtok('');
362 362 }
@@ -405,24 +405,14 @@
405 405 * WP Memory Usage
406 406 */
407 407 public function get_wp_memory_usage()
408 408 {
409 - // Get PHP memory limit
410 - $php_memory_limit = ini_get('memory_limit');
411 -
412 - // Get WordPress memory limit if defined
413 - $wordpress_memory_limit = defined('WP_MEMORY_LIMIT') ? WP_MEMORY_LIMIT : null;
414 -
415 - // Determine the effective memory limit with PHP memory limit taking priority
416 - $get_memory_limit = $php_memory_limit ? $php_memory_limit : $wordpress_memory_limit;
417 -
418 -
419 409 // Get WP Memory Limit
420 - // $get_memory_limit = WP_MEMORY_LIMIT;
421 - // if ((int) WP_MEMORY_LIMIT > (int) @ini_get('memory_limit')) {
422 - // // WP Limit can't be greater than Server Limiit
423 - // $get_memory_limit = @ini_get('memory_limit');
424 - // }
410 + $get_memory_limit = WP_MEMORY_LIMIT;
411 + if ((int) WP_MEMORY_LIMIT > (int) @ini_get('memory_limit')) {
412 + // WP Limit can't be greater than Server Limiit
413 + $get_memory_limit = @ini_get('memory_limit');
414 + }
425 415
426 416 $memory_limit_convert = $this->convert_memory_size($get_memory_limit);
427 417 $memory_limit_format = size_format($memory_limit_convert);
428 418 $memory_limit = $memory_limit_convert;
@@ -501,9 +491,9 @@
501 491 return 'N/A';
502 492 }
503 493
504 494
505 - public static function memory_usage_percentage()
495 + public static function wp_memory_usage_percentage()
506 496 {
507 497 $memory_usage = (new ServerInfo())->get_wp_memory_usage();
508 498 $memory_usage_percentage = $memory_usage['MemUsageCalc'];
509 499 return $memory_usage_percentage;
@@ -530,12 +520,9 @@
530 520 $result['free'] = 0;
531 521 $result['used'] = 0;
532 522
533 523 $lines = null;
534 - // $path defaults to '/'. Escape it before composing the shell
535 - // command so any future caller-supplied path can't break out
536 - // into additional commands.
537 - exec( sprintf( 'df /P %s', escapeshellarg( $path ) ), $lines );
524 + exec(sprintf('df /P %s', $path), $lines);
538 525
539 526 foreach ($lines as $index => $line) {
540 527 if ($index != 1) {
541 528 continue;
@@ -624,21 +611,21 @@
624 611
625 612 public function format_filesize($bytes)
626 613 {
627 614 if (($bytes / pow(1024, 5)) > 1) {
628 - return number_format_i18n(($bytes / pow(1024, 5)), 0) . ' ' . __('PB', 'adminify');
615 + return number_format_i18n(($bytes / pow(1024, 5)), 0) . ' ' . __('PB', 'adminify-serverinfo');
629 616 } elseif (($bytes / pow(1024, 4)) > 1) {
630 - return number_format_i18n(($bytes / pow(1024, 4)), 0) . ' ' . __('TB', 'adminify');
617 + return number_format_i18n(($bytes / pow(1024, 4)), 0) . ' ' . __('TB', 'adminify-serverinfo');
631 618 } elseif (($bytes / pow(1024, 3)) > 1) {
632 - return number_format_i18n(($bytes / pow(1024, 3)), 0) . ' ' . __('GB', 'adminify');
619 + return number_format_i18n(($bytes / pow(1024, 3)), 0) . ' ' . __('GB', 'adminify-serverinfo');
633 620 } elseif (($bytes / pow(1024, 2)) > 1) {
634 - return number_format_i18n(($bytes / pow(1024, 2)), 0) . ' ' . __('MB', 'adminify');
621 + return number_format_i18n(($bytes / pow(1024, 2)), 0) . ' ' . __('MB', 'adminify-serverinfo');
635 622 } elseif ($bytes / 1024 > 1) {
636 - return number_format_i18n($bytes / 1024, 0) . ' ' . __('KB', 'adminify');
623 + return number_format_i18n($bytes / 1024, 0) . ' ' . __('KB', 'adminify-serverinfo');
637 624 } elseif ($bytes >= 0) {
638 - return number_format_i18n($bytes, 0) . ' ' . __('bytes', 'adminify');
625 + return number_format_i18n($bytes, 0) . ' ' . __('bytes', 'adminify-serverinfo');
639 626 } else {
640 - return __('Unknown', 'adminify');
627 + return __('Unknown', 'adminify-serverinfo');
641 628 }
642 629 }
643 630
644 631 public function format_filesize_kB($kiloBytes)
@@ -643,19 +630,19 @@
643 630
644 631 public function format_filesize_kB($kiloBytes)
645 632 {
646 633 if (($kiloBytes / pow(1024, 4)) > 1) {
647 - return number_format_i18n(($kiloBytes / pow(1024, 4)), 0) . ' ' . __('PB', 'adminify');
634 + return number_format_i18n(($kiloBytes / pow(1024, 4)), 0) . ' ' . __('PB', 'adminify-serverinfo');
648 635 } elseif (($kiloBytes / pow(1024, 3)) > 1) {
649 - return number_format_i18n(($kiloBytes / pow(1024, 3)), 0) . ' ' . __('TB', 'adminify');
636 + return number_format_i18n(($kiloBytes / pow(1024, 3)), 0) . ' ' . __('TB', 'adminify-serverinfo');
650 637 } elseif (($kiloBytes / pow(1024, 2)) > 1) {
651 - return number_format_i18n(($kiloBytes / pow(1024, 2)), 0) . ' ' . __('GB', 'adminify');
638 + return number_format_i18n(($kiloBytes / pow(1024, 2)), 0) . ' ' . __('GB', 'adminify-serverinfo');
652 639 } elseif (($kiloBytes / 1024) > 1) {
653 - return number_format_i18n($kiloBytes / 1024, 0) . ' ' . __('MB', 'adminify');
640 + return number_format_i18n($kiloBytes / 1024, 0) . ' ' . __('MB', 'adminify-serverinfo');
654 641 } elseif ($kiloBytes >= 0) {
655 - return number_format_i18n($kiloBytes / 1, 0) . ' ' . __('KB', 'adminify');
642 + return number_format_i18n($kiloBytes / 1, 0) . ' ' . __('KB', 'adminify-serverinfo');
656 643 } else {
657 - return __('Unknown', 'adminify');
644 + return __('Unknown', 'adminify-serverinfo');
658 645 }
659 646 }
660 647
661 648 public function format_php_size($size)