HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: //var/www/html/test01.amberconcept/wp-content/plugins/wp-security-audit-log/classes/Autoloader.php
<?php
/**
 * Classes Auto Loader.
 *
 * @package wsal
 */
class WSAL_Autoloader {

	/**
	 * Instance of WpSecurityAuditLog.
	 *
	 * @var object
	 */
	protected $plugin;

	/**
	 * Paths to load.
	 *
	 * @var array
	 */
	protected $paths = array();

	/**
	 * Method: Constructor.
	 *
	 * @param WpSecurityAuditLog $plugin - Instance of WpSecurityAuditLog.
	 */
	public function __construct( WpSecurityAuditLog $plugin ) {
		$this->plugin = $plugin;

		// Register autoloader.
		spl_autoload_register( array( $this, 'LoadClass' ) );
	}

	/**
	 * Method: Register class.
	 *
	 * @param string $prefix - Prefix of the class.
	 * @param string $path - Path of the file.
	 */
	public function Register( $prefix, $path ) {
		if ( ! isset( $this->paths[ $prefix ] ) ) {
			$this->paths[ $prefix ] = array();
		}
		$this->paths[ $prefix ][] = rtrim( str_replace( '\\', '/', $path ), '/' ) . '/';
	}

	/**
	 * This is the class autoloader. You should not call this directly.
	 *
	 * @param string $class - Class name.
	 * @return boolean - True if class is found and loaded, false otherwise.
	 */
	public function LoadClass( $class ) {
		foreach ( $this->paths as $prefix => $paths ) {
			foreach ( $paths as $path ) {
				if ( strstr( $class, $prefix ) !== false ) {
					$file = $path . str_replace( '_', DIRECTORY_SEPARATOR, substr( $class, strlen( $prefix ) ) ) . '.php';
					if ( file_exists( $file ) ) {
						require_once $file;
						return class_exists( $class, false ) || interface_exists( $class, false );
					}
				}
			}
		}
		return false;
	}

	/**
	 * Returns the class name of a particular file that contains the class.
	 *
	 * @param string $file File name.
	 * @return string|false Class name or false on error.
	 */
	public function GetClassFileClassName( $file ) {
		$file = str_replace( '\\', '/', $file ); // Win/DOS hotfix.

		foreach ( $this->paths as $prefix => $paths ) {
			foreach ( $paths as $path ) {
				if ( strstr( $file, $path ) !== false ) {
					return str_replace(
						array( $path, '/' ),
						array( $prefix, '_' ),
						substr( $file, 0, -4 ) // Remove '.php'.
					);
				}
			}
		}
		return false;
	}
}