Ejemplo n.º 1
0
function handle_havp_ajax($havp_alerts_logfile, $nentries = 5, $tail = 50)
{
    if ($_GET['lastsawtime'] or $_POST['lastsawtime']) {
        if ($_GET['lastsawtime']) {
            $lastsawtime = $_GET['lastsawtime'];
        }
        if ($_POST['lastsawtime']) {
            $lastsawtime = $_POST['lastsawtime'];
        }
        /*  compare lastsawrule's time stamp to alert logs.
         *  afterwards return the newer records so that client
         *  can update AJAX interface screen.
         */
        $new_rules = "";
        $time_regex = "";
        $havp_alerts = get_havp_alerts($havp_alerts_logfile, $nentries);
        foreach ($havp_alerts as $log_row) {
            preg_match("/^([0-9][0-9])\\/([0-9][0-9])\\/([0-9][0-9][0-9][0-9])\$/U", $log_row['date'], $time_regex);
            #			$time_regex = "";"/^([0-9][0-9])\/([0-9][0-9])\/([0-9][0-9][0-9][0-9])\s+([0-9][0-9]:[0-9][0-9]:[0-9][0-9])$/U"
            //		preg_match("/.*([0-9][0-9]:[0-9][0-9]:[0-9][0-9]).*/", $log_row['date'] . " " .  $log_row['time'], $time_regex);
            $row_time = strtotime($time_regex[2] . "/" . $time_regex[1] . "/" . $time_regex[3] . " " . $log_row['time']);
            // $myfile = "/testfile.txt";
            // $fh = fopen($myfile,'a') or die("can't open file");
            // $stringdata = $lastsawtime . "-" . $row_time . "\n";
            //  fwrite($fh, $stringdata);
            //  fclose($fh);
            if ($row_time > $lastsawtime and $lastsawtime > 0) {
                $new_rules .= "{$log_row['url']}||{$log_row['virusname']}||" . time() . "||{$log_row['date']}||{$log_row['time']}||" . "\n";
            }
        }
        echo $new_rules;
        exit;
    }
}
function handle_havp_ajax($havp_alerts_logfile, $nentries = 5, $tail = 50)
{
    if ($_GET['lastsawtime'] or $_POST['lastsawtime']) {
        if ($_GET['lastsawtime']) {
            $lastsawtime = $_GET['lastsawtime'];
        }
        if ($_POST['lastsawtime']) {
            $lastsawtime = $_POST['lastsawtime'];
        }
        // Compare last seen rule's time stamp with alert logs.
        // Afterwards, return the newer records so that client can update AJAX interface screen.
        $new_rules = "";
        $time_regex = "";
        $havp_alerts = get_havp_alerts($havp_alerts_logfile, $nentries);
        foreach ($havp_alerts as $log_row) {
            preg_match("/^([0-9][0-9])\\/([0-9][0-9])\\/([0-9][0-9][0-9][0-9])\$/U", $log_row['date'], $time_regex);
            $row_time = strtotime($time_regex[2] . "/" . $time_regex[1] . "/" . $time_regex[3] . " " . $log_row['time']);
            if ($row_time > $lastsawtime and $lastsawtime > 0) {
                $new_rules .= "{$log_row['url']}||{$log_row['virusname']}||" . time() . "||{$log_row['date']}||{$log_row['time']}||" . "\n";
            }
        }
        echo $new_rules;
        exit;
    }
}