Update compile_database.php

This commit is contained in:
jakani24
2024-03-10 11:18:42 +01:00
parent d2fc9548a7
commit a06f05f40a

View File

@@ -7,6 +7,9 @@ function sort_hashes($inputFile, $excluded) {
die("Unable to open input file."); die("Unable to open input file.");
} }
// Initialize an array to hold batched hashes
$batchedHashes = array();
// Read each line from the input file // Read each line from the input file
while (($line = fgets($handle)) !== false) { while (($line = fgets($handle)) !== false) {
// Remove leading/trailing whitespace and split the line into words // Remove leading/trailing whitespace and split the line into words
@@ -23,23 +26,20 @@ function sort_hashes($inputFile, $excluded) {
// Create the filename for the corresponding file // Create the filename for the corresponding file
$filename = "/var/www/html/database_srv/".$prefix . ".jdbf"; $filename = "/var/www/html/database_srv/".$prefix . ".jdbf";
// Open or create the file for writing // Add the hash to the batched array
$fileHandle = fopen($filename, "a"); $batchedHashes[$filename][] = $line . PHP_EOL;
if ($fileHandle === false) {
die("Unable to open/create file: $filename");
}
// Write the word to the file
fwrite($fileHandle, $line . PHP_EOL);
// Close the file handle
fclose($fileHandle);
} }
// Close the input file handle // Close the input file handle
fclose($handle); fclose($handle);
}
// Write batched hashes to files
foreach ($batchedHashes as $filename => $hashes) {
// Open or create the file for writing
$fileContents = implode('', $hashes);
file_put_contents($filename, $fileContents, FILE_APPEND);
}
}
function download_files($excluded){ function download_files($excluded){
//download from virusshare //download from virusshare
$file_count=485; $file_count=485;