Update compile_database.php
This commit is contained in:
@@ -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
|
||||||
@@ -16,30 +19,27 @@ function sort_hashes($inputFile, $excluded) {
|
|||||||
if (in_array($hash, $excluded)) {
|
if (in_array($hash, $excluded)) {
|
||||||
continue; // Skip this hash
|
continue; // Skip this hash
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the first two characters of the word
|
// Get the first two characters of the word
|
||||||
$prefix = substr($hash, 0, 2);
|
$prefix = substr($hash, 0, 2);
|
||||||
|
|
||||||
// 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;
|
||||||
|
|||||||
Reference in New Issue
Block a user