Пример #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;
     }
 }
Пример #2
0
?>

      var chart_data = new google.visualization.LineChart(document.getElementById('chart_data'));
      var table_data = new google.visualization.Table(document.getElementById('chart_table'));      
      chart_data.draw(data_json_overview, options_overview);
      table_data.draw(data_json_overview, options_overview_table);      
    }
</script>

<div class="row">
    <div class="col-lg-12">
        <h3>Hits for <?php 
echo timeframeToHtml($timeframe);
?>
&nbsp;&nbsp;<small><?php 
echo convertRequestToParams($get, "label");
?>
</small></h3>
    </div>
</div>

<div class="row">
    <div class="col-lg-12" style="height: 320px;">
        <div id="chart_data"></div>
    </div>
</div>

<div class="modal fade" id="shortcutModal" tabindex="-1" role="dialog" aria-labelledby="shortcutModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">