/** * Return a combined dataset (mostly for maps) * * request array array with all the filters, options, ... * returns JSON encoded string * */ public function buildCombinedDataset($request = 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; } $groupbyip = "ip_saddr"; $filters = convertRequestToParams($request); $time = $this->convertTimeframeParam($timeframe); $where = ""; if (is_array($filters) and count($filters) > 0) { foreach ($filters as $filter) { $where .= " ( 1=1 " . $this->filterToWhere($filter) . " ) OR "; } $where = rtrim($where, " OR "); } $con = mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE); if (strlen($where) > 0) { $where = " AND " . $where; } // First grab total number of markers $sql = "SELECT COUNT(*) AS markercount FROM " . DB_TABLE . " WHERE " . " oob_time_sec > " . $time . " " . $where; $dbresult = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($dbresult); $markercount = (int) $row["markercount"]; $sql = "SELECT COUNT(*) AS qt, hex(" . $groupbyip . ") AS ip FROM " . DB_TABLE . " WHERE " . " oob_time_sec > " . $time . " " . $where . " GROUP BY " . $groupbyip; $dbresult = mysqli_query($con, $sql); $result = array(); $markercountdb = 0; $markerrecount = 1; if ($markercount > DEFAULT_MAP_MAXMARKERS and DEFAULT_MAP_MAXMARKERS > 0) { $markerrecount = (int) $markercount / DEFAULT_MAP_MAXMARKERS; } while ($row = mysqli_fetch_assoc($dbresult)) { $ip = googlemap_IpToLocation(db2ip($row["ip"])); $qt = (int) round($row["qt"] / $markerrecount); if ($qt > 0) { $markercountdb = $markercountdb + $qt; array_push($result, array("qt" => $qt, "ip" => db2ip($row["ip"]), "latitude" => $ip["latitude"], "longitude" => $ip["longitude"])); } } array_push($result, array("counters" => array("markerrecount" => $markerrecount, "count" => $markercount, "countdb" => $markercountdb))); if (is_array($request) and array_key_exists("return", $request) and $request["return"] == "data") { return $result; } else { echo json_encode($result); } } else { return false; } }
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); } ?> <div class="row"> <div class="col-lg-12"> <h3>Tools</h3> </div> </div>