Example #1
0
 /**
  * Build a JSON string from the ulogd data
  *
  * request       array         array with all the filters, options, ...
  * returns       JSON encoded string
  *
  */
 public function buildDataset($request = array())
 {
     $json = array();
     $filters = array();
     if (is_array($request)) {
         // Did we get a timeframe?
         if (is_array($request) and !array_key_exists("timeframe", $request)) {
             $request["timeframe"] = DEFAULT_TIMEFRAME;
         }
         $timeframe = strtolower($request["timeframe"]);
         if (!strlen($timeframe) > 0) {
             $timeframe = DEFAULT_TIMEFRAME;
         }
         $extrawhere = "";
         $filters_ip = convertRequestToParams($request, "dataset", "ip");
         $filters_port = convertRequestToParams($request, "dataset", "port");
         if (is_array($request) and array_key_exists("isolate_ip", $request) and $request["isolate_ip"] == "true") {
             // IP based
             // Results are based on IPs ; do we need to add an extra port filter to the queries?
             if (is_array($filters_port) and count($filters_port) > 0) {
                 foreach ($filters_port as $filter) {
                     //if (isset($filter["host"])) {
                     $extrawhere .= $this->filterToWhere($filter);
                     //}
                 }
             }
             // Multi source graph or not
             if (count($filters_ip) > 0) {
                 $container = array();
                 foreach ($filters_ip as $filter) {
                     $key = "";
                     $filter["extrawhere"] = $extrawhere;
                     if (isset($filter["host"])) {
                         $key = custom_filter_input($filter["host"]);
                     }
                     if (strlen($key) > 0) {
                         $container[$key] = $this->getData($timeframe, $filter);
                     }
                 }
                 $json = buildDataset_convertcolumns($container);
             } else {
                 $container = $this->getData($timeframe, array("extrawhere" => $extrawhere));
                 $json = buildDataset_convertcolumns($container);
             }
         } else {
             // PORT based
             // Results are based on ports ; do we need to add an extra IP filter to the queries?
             if (is_array($filters_ip) and count($filters_ip) > 0) {
                 foreach ($filters_ip as $filter) {
                     if (isset($filter["host"])) {
                         $extrawhere .= $this->filterToWhere($filter);
                     }
                 }
             }
             // Multi source graph or not
             $container = array();
             if (count($filters_port) <= 0) {
                 $container["base"] = $this->getData($timeframe, array());
             }
             foreach ($filters_port as $filter) {
                 $key = "";
                 $filter["extrawhere"] = $extrawhere;
                 if (isset($filter["port"]) and $filter["port"] != -1) {
                     $key = $filter["protocol"] . " / " . $filter["port"];
                 } elseif (isset($filter["protocol"])) {
                     $key = $filter["protocol"];
                 }
                 if (strlen($key) > 0) {
                     $container[$key] = $this->getData($timeframe, $filter);
                 }
             }
             $json = buildDataset_convertcolumns($container);
             /*}
               else {
                 $json['cols'][] = array('type' => 'string');
                 $container = $this->getData($timeframe, array( "extrawhere" => $extrawhere));
                 $json['cols'][] = array('type' => 'number', 'label' => 'hits');
                 foreach($container as $key => $value) {
                   $json['rows'][]['c'] = array(
                       array('v' => $key),
                       array('v' => $value)
                   );        
                 }
               }*/
         }
         if (is_array($request) and array_key_exists("return", $request) and $request["return"] == "data") {
             return $json;
         } else {
             echo json_encode($json);
         }
     } else {
         return false;
     }
 }
Example #2
0
$get = $_GET;
if (array_key_exists("timeframe", $get)) {
    $timeframe = custom_filter_input(strtolower($get["timeframe"]));
} else {
    $timeframe = DEFAULT_TIMEFRAME;
}
$params_filter = convertRequestToParams($get, "ajax");
if (array_key_exists("isolateresult", $get)) {
    if ($get["isolateresult"] == "isolate_ip") {
        $params_filter .= ", isolate_ip: true ";
    }
}
$params = " timeframe: '" . $timeframe . "' ";
$shortcut_name = $timeframe . convertRequestToParams($get, "shortcut_name");
$csv_url = "get.php?chart=csv&" . custom_filter_input($_SERVER["QUERY_STRING"]);
$table_url = "table.php?" . custom_filter_input($_SERVER["QUERY_STRING"]);
if (strlen($params_filter) > 0) {
    $params .= " , " . $params_filter;
    $legend = true;
    $chartArea = "largelegend";
} else {
    $legend = false;
    $chartArea = "large";
}
?>

<script type="text/javascript">
    google.load('visualization', '1', {'packages':['corechart']});
    google.load('visualization', '1', {'packages':['table']});

    // Set a callback to run when the Google Visualization API is loaded.
Example #3
0
<?php

/**
 *  ulogd visualizer
 *
 *    Main page
 *
 *  @author Koen Van Impe <*****@*****.**>
 *  @package  ulogdviz
 * 
 */
set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/../library'), get_include_path())));
require_once "../config/ulogd.php";
ulogd_printhtmlHead(custom_filter_input($_SERVER["PHP_SELF"]));
ulogd_printhtmlBodyStart(custom_filter_input($_SERVER["PHP_SELF"]));
?>

<script type="text/javascript">
    google.load('visualization', '1', {'packages':['corechart']});
    google.load('visualization', '1', {'packages':['table']});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart); 

    function drawChart() {
      <?php 
echo googlechart_getOptions(array("name" => "options_day", "chartArea" => "default", "legend" => false));
echo googlechart_getJson(array("name" => "json_day"));
echo googlechart_getJson(array("name" => "json_week", "data" => "timeframe: 'lastweek' "));
echo googlechart_getJson(array("name" => "json_month", "data" => "timeframe: 'lastmonth' "));
?>
Example #4
0
 *
 *  @author Koen Van Impe <*****@*****.**>
 *  @package  ulogdviz
 * 
 */
set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__) . '/../library'), get_include_path())));
require_once "../config/ulogd.php";
ulogd_printhtmlHead(custom_filter_input($_SERVER["PHP_SELF"]));
ulogd_printhtmlBodyStart(custom_filter_input($_SERVER["PHP_SELF"]));
$ip2db = custom_filter_input($_GET["ip2db"], FILTER_VALIDATE_IP);
$orig_ip2db = $ip2db;
$db2ip = custom_filter_input($_GET["db2ip"], FILTER_VALIDATE_STRING);
$orig_db2ip = $db2ip;
$time2date = custom_filter_input($_GET["time2date"], FILTER_VALIDATE_FLOAT);
$orig_time2date = $time2date;
$date2time = custom_filter_input($_GET["date2time"], FILTER_VALIDATE_STRING);
$orig_date2time = $date2time;
if (isset($ip2db)) {
    $ip2db = ip2db($ip2db);
}
if (isset($db2ip)) {
    $db2ip = db2ip($db2ip);
}
if (isset($time2date)) {
    $time2date = time2date($time2date);
}
if (isset($date2time)) {
    $date2time = date2time($date2time);
}
?>