HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
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/html/wpwatermates/wp-content/plugins/wp-google-maps/includes/class.integrity-checker.php
<?php

class IntegrityChecker
{
	public function __construct()
	{
		
	}
	
	/**
	 * Recursive glob. This function is used to match files given the specified pattern, recursively.
	 * @todo Put this somewhere standardised, this is copied (WET) from the ScriptLoader
	 * @param string $pattern The pattern to match
	 * @param int $flags Flags to pass to glob
	 * @return string[] An array of matching files.
	 * @see http://php.net/manual/en/function.glob.php
	 */
	protected function rglob($pattern, $flags = 0)
	{
		$files = glob($pattern, $flags); 
		
		foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
			
			$files = array_merge($files, $this->rglob($dir.'/'.basename($pattern), $flags));
			
		}
		
		return $files;
	}
	
	public function record($dir, $pattern="*.php")
	{
		$dst		= "$dir/integrity.json";
		$files		= $this->rglob("$dir/$pattern");
		$json		= (object)array('files' => array());
		
		foreach($files as $filename)
		{
			$src	= file_get_contents($filename);
			$crc	= crc32($src);
			
			$json->records []= array(
				'file'		=> preg_replace('#.+includes#', '', $filename),
				'crc32'		=> $crc
			);
		}
		
		file_put_contents($dst, json_encode($json));
	}
	
	public function check($dir)
	{
		$src		= "$dir/integrity.json";
		
		if(!file_exists($src))
		{
			trigger_error("Integrity records missing", E_USER_WARNING);
			return false;
		}
		
		$json		= json_decode( file_get_contents($src) );
		
		foreach($json->records as $record)
		{
			$filename = "$dir/{$record->file}";
			
			if(!file_exists($filename))
			{
				trigger_error("File in integrity record missing ({$record->file})", E_USER_WARNING);
				return false;
			}
			
			$src	= file_get_contents($filename);
			$crc	= crc32($src);
			
			if($crc != $record->crc32)
			{
				trigger_error("File integrity check failed ({$record->file})", E_USER_WARNING);
				return false;
			}
		}
		
		return true;
	}
}