HEX
Server: LiteSpeed
System: Linux cde2.duelhost.dk 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: dtptviut (1121)
PHP: 8.0.30
Disabled: exec,system,passthru,shell_exec,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/dtptviut/public_html/wp-content/plugins/nitropack/classes/Integration/Plugin/RC.php
<?php

namespace NitroPack\Integration\Plugin;

use \NitroPack\SDK\Filesystem;

class RC {
	public static $modules = [//Key should match the value from nitropack_get_conflicting_plugins() assigned to the $clashingPlugins array
		'WP-Rocket' => 'NitroPack\Integration\Plugin\WPRocket',
	];

	public static function clearCache() {
	}

	public static function dirHasContents( $dir_path, $recursive_scan ) {
		$exclude_list = [ '.', '..', '.htaccess', 'index.html' ];
		if ( is_dir( $dir_path ) ) {
			$dir_path = nitropack_trailingslashit( $dir_path );
			$dir_contents = scandir( $dir_path );
			foreach ( $dir_contents as $current_item ) {
				if ( ! in_array( $current_item, $exclude_list ) ) {
					$current_item_path = nitropack_trailingslashit( $dir_path . $current_item );
					if ( is_dir( $current_item_path ) ) {
						if ( $recursive_scan ) {
							if ( self::dirHasContents( $current_item_path, true ) )
								return true;
						} else {
							return true;
						}
					} else {
						return true;
					}
				}
			}
		}
		return false;
	}

	public static function clearResidualCache( $full_cache_path ) {
		try {
			if ( Filesystem::fileExists( $full_cache_path ) ) {
				if ( is_dir( $full_cache_path ) && is_writable( $full_cache_path ) ) {
					$diskStorage = new \NitroPack\SDK\StorageDriver\Disk();
					$diskStorage->deleteDir( $full_cache_path );
					return true;
				}
				return false;
			}
		} catch (\Exception $e) {
			//TODO: Log the exception in a NP log
			return false;
		}
	}

	public static function getCurrentDomain() {
		$url = new \NitroPack\Url\Url( get_site_url() );
		return $url ? $url->getHost() : NULL;
	}

	public static function getWPCacheDir() {
		$wpc_dir = nitropack_trailingslashit( defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ( defined( 'ABSPATH' ) ? ABSPATH . '/wp-content' : 'Undefined' ) ) . 'cache';
		if ( Filesystem::fileExists( $wpc_dir ) ) {
			return $wpc_dir;
		}
		return false;
	}

	public static function isConflictingPluginActive( $cp_name ) {
		$conflictingPlugins = \NitroPack\WordPress\ConflictingPlugins::getInstance();
		$conflictingPlugins = $conflictingPlugins->nitropack_get_conflicting_plugins();
		foreach ( $conflictingPlugins as $clashingPlugin ) {
			if ( $clashingPlugin['name'] === $cp_name ) {
				$cp_name = $clashingPlugin['plugin'];
				return true;
			}
		}
		return false;
	}

	public static function detectThirdPartyCaches() {
		$residual_cache = array();

		foreach ( self::$modules as $module_name => $module ) {
			if ( ! self::isConflictingPluginActive( $module_name ) && $module::hasResidualCache() ) {
				$residual_cache[] = $module_name;
			}
		}

		return $residual_cache;
	}
}