From 9b37179e5c5c8c274041faeb8bc7f15f47bb1ac2 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 25 Sep 2006 03:43:31 +0000 Subject: If an error occurs during download then scroll down to bottom of page and output error in a white div. --- packages/snort/snort.xml | 4 +++ packages/snort/snort_download_rules.php | 47 ++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'packages/snort') diff --git a/packages/snort/snort.xml b/packages/snort/snort.xml index e47b1199..ce891802 100644 --- a/packages/snort/snort.xml +++ b/packages/snort/snort.xml @@ -36,6 +36,10 @@ /pkg_edit.php?xml=snort.xml&id=0 + + Update Snort Rules + /snort_download_rules.php + diff --git a/packages/snort/snort_download_rules.php b/packages/snort/snort_download_rules.php index 7abfe448..1dea97f4 100644 --- a/packages/snort/snort_download_rules.php +++ b/packages/snort/snort_download_rules.php @@ -28,10 +28,10 @@ */ -$pgtitle = array(gettext("Services"),gettext("Snort"),gettext("Update Rules")); - +require_once("functions.inc"); require_once("guiconfig.inc"); -require_once("xmlrpc.inc"); + +$pgtitle = "Services: Snort: Update Rules"; include("head.inc"); @@ -39,6 +39,7 @@ include("head.inc"); +

@@ -108,12 +109,14 @@ exec("rm -rf {$tmpfname}; mkdir -p {$tmpfname}"); /* download snort rules */ $static_output = gettext("Downloading current snort rules... "); update_all_status($static_output); -download_file_with_progress_bar($dl, $tmpfname); +download_file_with_progress_bar($dl, $tmpfname . "/snortrules-snapshot-CURRENT.tar.gz"); +verify_downloaded_file($tmpfname . "/snortrules-snapshot-CURRENT.tar.gz"); /* download snort rules md5 file */ $static_output = gettext("Downloading current snort rules md5... "); update_all_status($static_output); -download_file_with_progress_bar($dl_md5, $tmpfname); +download_file_with_progress_bar($dl_md5, $tmpfname . "/snortrules-snapshot-CURRENT.tar.gz.md5"); +verify_downloaded_file($tmpfname . "/snortrules-snapshot-CURRENT.tar.gz.md5"); /* verify downloaded rules signature */ verify_snort_rules_md5($tmpfname); @@ -125,7 +128,7 @@ $static_output = gettext("Your snort rules are now up to date."); update_all_status($static_output); /* cleanup temporary directory */ -exec("rm -rf {$tmpfname};"); +//exec("rm -rf {$tmpfname};"); /* hide progress bar and lets end this party */ hide_progress_bar_status(); @@ -137,6 +140,38 @@ hide_progress_bar_status();
"; + echo " 

"; + echo "The following error occured while downloading the snort rules file from snort.org:

"; + echo $contents; + echo " 

"; + echo "

"; + scroll_down_to_bottom_of_page(); + exit; + } +} + +function scroll_down_to_bottom_of_page() { + echo "\n"; +} + +function verify_downloaded_file($filename) { + update_all_status("Checking {$filename}..."); + check_for_common_errors($filename); + update_all_status("Verifying {$filename}..."); + if(!file_exists($filename)) { + update_all_status("Could not fetch snort rules ({$filename}). Check oinkid key and dns and try again."); + hide_progress_bar_status(); + exit; + } + update_all_status("Verifyied {$filename}."); +} + function extract_snort_rules_md5($tmpfname) { $static_output = gettext("Extracting snort rules..."); update_all_status($static_output); -- cgit v1.2.3