From 50972b6d5964d42937beadd86e1bd7ef5078b343 Mon Sep 17 00:00:00 2001 From: jakani24 Date: Sat, 17 Feb 2024 15:47:54 +0100 Subject: [PATCH] Update compile_database.php --- .../api/php/database/compile_database.php | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/src/server/cyberhex-code/api/php/database/compile_database.php b/src/server/cyberhex-code/api/php/database/compile_database.php index f17e3d1..21f4a96 100644 --- a/src/server/cyberhex-code/api/php/database/compile_database.php +++ b/src/server/cyberhex-code/api/php/database/compile_database.php @@ -35,33 +35,18 @@ function sort_hashesh($inputFile) { fclose($handle); } function download_files(){ - -} -$url = 'http://example.com/file.txt'; - -// Initialize cURL session -$ch = curl_init($url); - -// Set options -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - -// Execute cURL session -$fileContents = curl_exec($ch); - -// Check if the request was successful -if ($fileContents === false) { - die('Failed to download file'); + $file_count=485; + for($i=0;$i<$file_count;$i++){ + $fileNumber = sprintf('%05d', $i); + $url="https://virusshare.com/hashfiles/VirusShare_$fileNumber.md5"; + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $fileContents = curl_exec($ch); + file_put_contents("/var/www/html/database_srv/$fileNumber.md5", $fileContents); + } } -// Close cURL session -curl_close($ch); - -// Save the downloaded file to disk -$localFilePath = 'downloaded_file.txt'; -file_put_contents($localFilePath, $fileContents); - -echo 'File downloaded successfully'; -// Usage example: Provide the path to the input file +download_files(); $inputFile = "input.txt"; //sortWordsIntoFiles($inputFile);