HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/delta/wp-content/plugins/wp-smushit/core/class-file-system.php
<?php

namespace Smush\Core;

class File_System {
	public function file_get_contents( $path, $use_include_path = false, $context = null, $offset = 0, $length = null ) {
		if ( ! $this->is_valid_path( $path ) ) {
			return false;
		}

		if ( str_starts_with( $path, ABSPATH ) && ! file_exists( $path ) ) {
			return false;
		}

		$args = array( $path, $use_include_path, $context, $offset );
		if ( ! is_null( $length ) ) {
			// Even though the default value of $length is 'null', an empty string is returned when 'null' is passed as $length. So, we only include it when a non-null value is provided.
			$args[] = $length;
		}

		return call_user_func_array( 'file_get_contents', $args );
	}

	public function file_exists( $path ) {
		return $this->validate_and_call( 'file_exists', $path );
	}

	public function unlink( $path ) {
		return $this->validate_and_call( 'unlink', $path );
	}

	public function copy( $source, $destination ) {
		return $this->validate_and_call( 'copy', $source, $destination );
	}

	public function is_file( $file ) {
		return $this->validate_and_call( 'is_file', $file );
	}

	public function is_dir( $path ) {
		return $this->validate_and_call( 'is_dir', $path );
	}

	public function filesize( $file ) {
		return $this->validate_and_call( 'filesize', $file );
	}

	public function getimagesize( $path ) {
		return $this->validate_and_call( 'getimagesize', $path );
	}

	private function validate_and_call( $callback, ...$args ) {
		foreach ( $args as $arg ) {
			if ( ! $this->is_valid_path( $arg ) ) {
				return false;
			}
		}

		return call_user_func_array( $callback, $args );
	}

	private function is_valid_path( $path ) {
		return false === stripos( $path, 'phar://' );
	}

	public function get_wp_filesystem() {
		global $wp_filesystem;
		if ( is_null( $wp_filesystem ) ) {
			// These aren't included when applying a config from the Hub.
			if ( ! function_exists( 'WP_Filesystem' ) ) {
				require_once ABSPATH . 'wp-admin/includes/file.php';
			}
			WP_Filesystem();
		}

		return $wp_filesystem;
	}
}