PluginProbe ʕ •ᴥ•ʔ
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN / 3.14.1
Smush – Image Optimization, Compression, Lazy Load, WebP & CDN v3.14.1
4.1.0 4.0.3 4.0.2 2.8.1 2.9.1 3.0.0 3.0.1 3.0.2 3.1.1 3.10.1 3.10.2 3.10.3 3.11.1 3.12.3 3.12.4 3.12.5 3.12.6 3.13.0 3.13.1 3.13.2 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.15.2 3.15.3 3.15.4 3.15.5 3.16.2 3.16.4 3.16.5 3.16.6 3.17.0 3.17.1 3.18.0 3.18.1 3.2.0.1 3.2.1 3.2.2.1 3.2.4 3.20.0 3.21.1 3.22.1 3.22.3 3.23.0 3.23.1 3.23.2 3.23.3 3.23.4 3.24.0 3.24.0-beta.2 3.3.0 3.3.1 3.3.2 3.4.1 3.4.2 3.6.1 3.6.3 3.7.0 3.7.1 3.7.2 3.7.3 3.8.2 3.8.3 3.8.4 3.8.5 3.8.7 3.8.8 3.9.0 3.9.1 3.9.11 3.9.2 3.9.4 3.9.5 3.9.8 3.9.9 trunk 1.0.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.10 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.5.3 1.6.5.4 1.7 1.7.1 1.7.1.1 2.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.6.2 2.0.6.3 2.0.6.5 2.0.7 2.0.7.1 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.2 2.3 2.3.1 2.4 2.4.2 2.4.3 2.4.4 2.4.5 2.5.2 2.5.3 2.6.1 2.6.2 2.6.3 2.7 2.7.1 2.7.4 2.7.4.1 2.7.5 2.7.6 2.7.8 2.7.8.1 2.7.9.1 2.8.0 2.8.0.1
wp-smushit / core / class-server-utils.php
wp-smushit / core Last commit date
api 2 years ago backups 2 years ago external 2 years ago integrations 2 years ago media 2 years ago media-library 2 years ago modules 2 years ago photon 2 years ago png2jpg 2 years ago resize 2 years ago s3 2 years ago smush 2 years ago stats 2 years ago webp 2 years ago class-animated-status-controller.php 2 years ago class-array-utils.php 2 years ago class-attachment-id-list.php 2 years ago class-backup-size.php 2 years ago class-cli.php 2 years ago class-configs.php 2 years ago class-controller.php 2 years ago class-core.php 2 years ago class-deprecated-hooks.php 2 years ago class-error-handler.php 2 years ago class-file-system.php 2 years ago class-helper.php 2 years ago class-installer.php 2 years ago class-modules.php 2 years ago class-optimization-controller.php 2 years ago class-plugin-settings-watcher.php 2 years ago class-rest.php 2 years ago class-server-utils.php 2 years ago class-settings.php 2 years ago class-smush-file.php 2 years ago class-stats.php 2 years ago class-upload-dir.php 2 years ago
class-server-utils.php
81 lines
1 <?php
2
3 namespace Smush\Core;
4
5 class Server_Utils {
6 /**
7 * @var string
8 */
9 private $mysql_version;
10
11 public function get_server_type() {
12 if ( empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
13 return '';
14 }
15
16 $server_software = wp_unslash( $_SERVER['SERVER_SOFTWARE'] );
17 if ( ! is_array( $server_software ) ) {
18 $server_software = array( $server_software );
19 }
20
21 $server_software = array_map( 'strtolower', $server_software );
22 $is_nginx = $this->array_has_needle( $server_software, 'nginx' );
23 if ( $is_nginx ) {
24 return 'nginx';
25 }
26
27 $is_apache = $this->array_has_needle( $server_software, 'apache' );
28 if ( $is_apache ) {
29 return 'apache';
30 }
31
32 return '';
33 }
34
35 public function get_memory_limit() {
36 if ( function_exists( 'ini_get' ) ) {
37 $memory_limit = ini_get( 'memory_limit' );
38 } else {
39 // Sensible default.
40 $memory_limit = '128M';
41 }
42
43 if ( ! $memory_limit || - 1 === $memory_limit ) {
44 // Unlimited, set to 32GB.
45 $memory_limit = '32000M';
46 }
47
48 return intval( $memory_limit ) * 1024 * 1024;
49 }
50
51 public function get_memory_usage() {
52 return memory_get_usage( true );
53 }
54
55 private function array_has_needle( $array, $needle ) {
56 foreach ( $array as $item ) {
57 if ( strpos( $item, $needle ) !== false ) {
58 return true;
59 }
60 }
61
62 return false;
63 }
64
65 public function get_mysql_version() {
66 if ( ! $this->mysql_version ) {
67 global $wpdb;
68 $this->mysql_version = $wpdb->db_version();
69 }
70 return $this->mysql_version;
71 }
72
73 public function get_max_execution_time() {
74 return (int) ini_get( 'max_execution_time' );
75 }
76
77 public function get_user_agent() {
78 return ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) : '';
79 }
80 }
81