2022-08-05 18:41:35 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Check for NCC
|
|
|
|
if(!file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php'))
|
|
|
|
{
|
|
|
|
print('Could not find \'autoload.php\', this script is intended to be executed during the redistribution process');
|
|
|
|
exit(1);
|
|
|
|
}
|
2023-08-18 00:37:08 -04:00
|
|
|
|
2022-08-05 18:41:35 -04:00
|
|
|
require(__DIR__ . DIRECTORY_SEPARATOR . 'autoload.php');
|
|
|
|
|
|
|
|
// Start script
|
|
|
|
function scanContents($dir, &$results = array())
|
|
|
|
{
|
|
|
|
$files = scandir($dir);
|
|
|
|
|
|
|
|
foreach ($files as $key => $value)
|
|
|
|
{
|
|
|
|
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
|
|
|
if (!is_dir($path))
|
|
|
|
{
|
|
|
|
$results[] = str_ireplace(__DIR__ . DIRECTORY_SEPARATOR, (string)null, $path);
|
|
|
|
}
|
2023-08-18 00:37:08 -04:00
|
|
|
else if ($value !== '.' && $value !== '..')
|
2022-08-05 18:41:35 -04:00
|
|
|
{
|
|
|
|
scanContents($path, $results);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $results;
|
|
|
|
}
|
|
|
|
|
|
|
|
ncc\Utilities\Console::out('Creating checksum.bin ...');
|
|
|
|
|
|
|
|
$excluded_files = [
|
|
|
|
'hash_check.php',
|
2022-08-11 14:04:33 -04:00
|
|
|
'generate_build_files.php',
|
|
|
|
'checksum.bin',
|
|
|
|
'build_files'
|
2022-08-05 18:41:35 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
$hash_values = [];
|
|
|
|
foreach(scanContents(__DIR__) as $file)
|
|
|
|
{
|
|
|
|
|
2023-08-18 00:37:08 -04:00
|
|
|
if(!in_array($file, $excluded_files, true))
|
2022-08-05 18:41:35 -04:00
|
|
|
{
|
|
|
|
$hash_values[$file] = hash_file('sha256', __DIR__ . DIRECTORY_SEPARATOR . $file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . 'checksum.bin', \ncc\ZiProto\ZiProto::encode($hash_values));
|
|
|
|
ncc\Utilities\Console::out('Created checksum.bin');
|
|
|
|
exit(0);
|