From 19598c0fc7074cfbb42e32cd8f0354c74a7c6c22 Mon Sep 17 00:00:00 2001 From: robiscool Date: Wed, 1 Jun 2011 19:01:11 -0700 Subject: snort-dev, add update code, add update tab --- config/snort-dev/snort_json_get.php | 43 +++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'config/snort-dev/snort_json_get.php') diff --git a/config/snort-dev/snort_json_get.php b/config/snort-dev/snort_json_get.php index a8cdcd2d..1fdcc1e7 100644 --- a/config/snort-dev/snort_json_get.php +++ b/config/snort-dev/snort_json_get.php @@ -2,10 +2,49 @@ require_once("guiconfig.inc"); require_once("/usr/local/pkg/snort/snort_new.inc"); +require_once("/usr/local/pkg/snort/snort_download_rules.inc"); +session_start(); // alwaya at the very top of a php page or "Cannot send session cache limiter - headers already sent" - - +// upload created log tar to user +if ($_GET['snortGetUpdate'] == 1) +{ + + $tmpfname = "/usr/local/etc/snort/snort_download"; + $snort_filename = "snortrules-snapshot-2905.tar.gz"; + + + $snortSessionPath = $_SESSION['tmp']['snort']['snort_download_updates']; + + if (!file_exists("{$tmpfname}/{$snort_filename}")) + { + + if ($snortSessionPath['download']['working'] != '1') + { + unset($_SESSION['tmp']); + $snortSessionPath['download']['working'] = '1'; + sendUpdateSnortLogDownload(); + } + + } + + $time = time(); + while((time() - $time) < 30) { + // query memcache, database, etc. for new data + $data = $datasource->getLatest(); + + // if we have new data return it + if(!empty($data)) { + echo json_encode($data); + ob_flush(); + flush(); + break; + } + + usleep(25000); + } + +} // end main if -- cgit v1.2.3