<?php
	if (isset($_GET['hash'])) {
		require_once('configdb.php');
		$filePath = $imageBasePath.$_GET['hash'];
		$hashArray = array();
		// Verify file path exists and is a directory
		if (!file_exists($filePath)) {
			print $filePath;
			$data   = json_encode($hashArray);
			die($data);
		}
		// Prevent access to parent folders
		if (strpos($filePath, '<') !== false || strpos($filePath, '>') !== false || strpos($filePath, '..') !== false || strpos($filePath, '/var/www/vuplus-support.org/htdocs/wbb4/vtisoftware/') === false ) {
			$data   = json_encode($hashArray);
			die($data);
		}
		$hashArray['md5']  = hash_file('md5', $filePath);
		$hashArray['sha256'] = hash_file('sha256', $filePath);
		$data   = json_encode($hashArray);
		die($data);
	}
?>
