aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort-dev/snort_json_get.php
diff options
context:
space:
mode:
Diffstat (limited to 'config/snort-dev/snort_json_get.php')
-rw-r--r--config/snort-dev/snort_json_get.php43
1 files changed, 41 insertions, 2 deletions
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