PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.5.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.5.4
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 +33 -36 4.2.184.0.5.4 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 }
@@ -501,9 +501,9 @@
501 501 return 'N/A';
502 502 }
503 503
504 504
505 - public static function memory_usage_percentage()
505 + public static function wp_memory_usage_percentage()
506 506 {
507 507 $memory_usage = (new ServerInfo())->get_wp_memory_usage();
508 508 $memory_usage_percentage = $memory_usage['MemUsageCalc'];
509 509 return $memory_usage_percentage;
@@ -530,12 +530,9 @@
530 530 $result['free'] = 0;
531 531 $result['used'] = 0;
532 532
533 533 $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 );
534 + exec(sprintf('df /P %s', $path), $lines);
538 535
539 536 foreach ($lines as $index => $line) {
540 537 if ($index != 1) {
541 538 continue;
@@ -624,21 +621,21 @@
624 621
625 622 public function format_filesize($bytes)
626 623 {
627 624 if (($bytes / pow(1024, 5)) > 1) {
628 - return number_format_i18n(($bytes / pow(1024, 5)), 0) . ' ' . __('PB', 'adminify');
625 + return number_format_i18n(($bytes / pow(1024, 5)), 0) . ' ' . __('PB', 'adminify-serverinfo');
629 626 } elseif (($bytes / pow(1024, 4)) > 1) {
630 - return number_format_i18n(($bytes / pow(1024, 4)), 0) . ' ' . __('TB', 'adminify');
627 + return number_format_i18n(($bytes / pow(1024, 4)), 0) . ' ' . __('TB', 'adminify-serverinfo');
631 628 } elseif (($bytes / pow(1024, 3)) > 1) {
632 - return number_format_i18n(($bytes / pow(1024, 3)), 0) . ' ' . __('GB', 'adminify');
629 + return number_format_i18n(($bytes / pow(1024, 3)), 0) . ' ' . __('GB', 'adminify-serverinfo');
633 630 } elseif (($bytes / pow(1024, 2)) > 1) {
634 - return number_format_i18n(($bytes / pow(1024, 2)), 0) . ' ' . __('MB', 'adminify');
631 + return number_format_i18n(($bytes / pow(1024, 2)), 0) . ' ' . __('MB', 'adminify-serverinfo');
635 632 } elseif ($bytes / 1024 > 1) {
636 - return number_format_i18n($bytes / 1024, 0) . ' ' . __('KB', 'adminify');
633 + return number_format_i18n($bytes / 1024, 0) . ' ' . __('KB', 'adminify-serverinfo');
637 634 } elseif ($bytes >= 0) {
638 - return number_format_i18n($bytes, 0) . ' ' . __('bytes', 'adminify');
635 + return number_format_i18n($bytes, 0) . ' ' . __('bytes', 'adminify-serverinfo');
639 636 } else {
640 - return __('Unknown', 'adminify');
637 + return __('Unknown', 'adminify-serverinfo');
641 638 }
642 639 }
643 640
644 641 public function format_filesize_kB($kiloBytes)
@@ -643,19 +640,19 @@
643 640
644 641 public function format_filesize_kB($kiloBytes)
645 642 {
646 643 if (($kiloBytes / pow(1024, 4)) > 1) {
647 - return number_format_i18n(($kiloBytes / pow(1024, 4)), 0) . ' ' . __('PB', 'adminify');
644 + return number_format_i18n(($kiloBytes / pow(1024, 4)), 0) . ' ' . __('PB', 'adminify-serverinfo');
648 645 } elseif (($kiloBytes / pow(1024, 3)) > 1) {
649 - return number_format_i18n(($kiloBytes / pow(1024, 3)), 0) . ' ' . __('TB', 'adminify');
646 + return number_format_i18n(($kiloBytes / pow(1024, 3)), 0) . ' ' . __('TB', 'adminify-serverinfo');
650 647 } elseif (($kiloBytes / pow(1024, 2)) > 1) {
651 - return number_format_i18n(($kiloBytes / pow(1024, 2)), 0) . ' ' . __('GB', 'adminify');
648 + return number_format_i18n(($kiloBytes / pow(1024, 2)), 0) . ' ' . __('GB', 'adminify-serverinfo');
652 649 } elseif (($kiloBytes / 1024) > 1) {
653 - return number_format_i18n($kiloBytes / 1024, 0) . ' ' . __('MB', 'adminify');
650 + return number_format_i18n($kiloBytes / 1024, 0) . ' ' . __('MB', 'adminify-serverinfo');
654 651 } elseif ($kiloBytes >= 0) {
655 - return number_format_i18n($kiloBytes / 1, 0) . ' ' . __('KB', 'adminify');
652 + return number_format_i18n($kiloBytes / 1, 0) . ' ' . __('KB', 'adminify-serverinfo');
656 653 } else {
657 - return __('Unknown', 'adminify');
654 + return __('Unknown', 'adminify-serverinfo');
658 655 }
659 656 }
660 657
661 658 public function format_php_size($size)