Initial Github commit
This commit is contained in:
70
webdata/wallboard/30min24hr.php
Normal file
70
webdata/wallboard/30min24hr.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/* Include all the classes */
|
||||
include("../graph/pchart/class/pData.class.php");
|
||||
include("../graph/pchart/class/pDraw.class.php");
|
||||
include("../graph/pchart/class/pImage.class.php");
|
||||
include("../includes/db_config.php");
|
||||
if(isset($_GET['port'])){
|
||||
$varService = $_GET['port'];
|
||||
}else{
|
||||
$varService = 0;
|
||||
}
|
||||
|
||||
/* Create your dataset object */
|
||||
$myData = new pData();
|
||||
|
||||
$db = mysql_connect($servername, $username, $password); //location of server, db username, db pass
|
||||
mysql_select_db("$dbname", $db);
|
||||
|
||||
$Requete = "SELECT amount, time, type FROM stats WHERE service = '".$varService."' and type = '30min' AND time > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 24 HOUR) ORDER BY time"; //table name
|
||||
$Result = mysql_query($Requete, $db);
|
||||
|
||||
/*This fetches the data from the mysql database, and adds it to pchart as points*/
|
||||
while($row = mysql_fetch_array($Result))
|
||||
{
|
||||
//$Sample_Number = $row["Sample_Number"]; //Not using this data
|
||||
//$myData->addPoints($Sample_Number,"Sample_Number");
|
||||
|
||||
$Time = $row["time"];
|
||||
$myData->addPoints($Time,"time");
|
||||
|
||||
$Amt = $row["amount"];
|
||||
$myData->addPoints($Amt,"amount");
|
||||
|
||||
// $Type = $row["type"];
|
||||
// $myData->addPoints($Type,"type");
|
||||
}
|
||||
|
||||
$myData-> setSerieOnAxis("amount", 0); //assigns the data to the frist axis
|
||||
$myData-> setAxisName(0, "# of Connections"); //adds the label to the first axis
|
||||
|
||||
//$myData-> setSerieOnAxis("type", 1);
|
||||
//$myData-> setAxisName(1, "Service");
|
||||
|
||||
$myData-> setAxisPosition(1,AXIS_POSITION_LEFT); //moves the second axis to the far left
|
||||
|
||||
$myData->setAbscissa("time"); //sets the time data set as the x axis label
|
||||
|
||||
|
||||
$myPicture = new pImage(900,320,$myData); /* Create a pChart object and associate your dataset */
|
||||
$rectsettings = array("R"=>40, "G"=>40, "B"=>40, "Dash"=>1, "DashR"=>80, "DashG"=>80, "DashB"=>80);
|
||||
$myPicture->drawFilledRectangle(0,0,900,320,$rectsettings);
|
||||
$myPicture->setFontProperties(array("FontName"=>"../graph/pchart/fonts/verdana.ttf","FontSize"=>8, "R"=>248, "G"=>248, "B"=>248)); /* Choose a nice font */
|
||||
|
||||
$myPicture->setGraphArea(60,20,850,200); /* Define the boundaries of the graph area */
|
||||
|
||||
$Settings = array("R"=>40, "G"=>40, "B"=>40, "Dash"=>1, "DashR"=>255, "DashG"=>255, "DashB"=>255);
|
||||
|
||||
$myPicture->drawScale(array("LabelRotation"=>295)); /* Draw the scale, keep everything automatic */
|
||||
$myPicture->drawFilledRectangle(60,20,850,200,array("R"=>46,"G"=>46,"B"=>46,"Surrounding"=>-200,"Alpha"=>10));
|
||||
/*The combination makes a cool looking graph*/
|
||||
$myPicture->drawPlotChart();
|
||||
$myPicture->drawLineChart();
|
||||
|
||||
|
||||
//$myPicture->drawLegend(90,20); //adds the legend
|
||||
|
||||
$myPicture->autoOutput(); /* Build the PNG file and send it to the web browser */
|
||||
|
||||
?>
|
27
webdata/wallboard/graphs.php
Normal file
27
webdata/wallboard/graphs.php
Normal file
@ -0,0 +1,27 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../css/wallboardstyle.css">
|
||||
<link rel="shortcut icon" href="../favicon.ico" />
|
||||
<title>Wallboard Graphs</title>
|
||||
<meta http-equiv="refresh" content="300">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Service Connection Totals Every 30 minutes, for the Past 24 Hours.</h1>
|
||||
<!-- Display the graphs in 2 columns -->
|
||||
<div id="col1">
|
||||
<h2>HTTP</h2>
|
||||
<img src="30min24hr.php?port=80">
|
||||
<br>
|
||||
<h2>HTTPS</h2>
|
||||
<img src="30min24hr.php?port=443">
|
||||
</div>
|
||||
<div id="col2">
|
||||
<h2>SSH</h2>
|
||||
<img src="30min24hr.php?port=22">
|
||||
<br>
|
||||
<h2>SMTP</h2>
|
||||
<img src="30min24hr.php?port=25">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
151
webdata/wallboard/map.php
Normal file
151
webdata/wallboard/map.php
Normal file
@ -0,0 +1,151 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="../css/wallboardstyle.css">
|
||||
<link rel="shortcut icon" href="../favicon.ico" />
|
||||
<script type='text/javascript' src='../mapdata/jquery-1.6.2.min.js'></script>
|
||||
<script type='text/javascript' src='../mapdata/jquery-ui.min.js'></script>
|
||||
<script type='text/javascript' src='../mapdata/mcplus/src/markerclusterer_packed.js'></script>
|
||||
<title>Wallboard Map</title>
|
||||
<?php
|
||||
$varPort2 = $_GET['formPort'];
|
||||
if($varPort2 != ""){
|
||||
echo "<meta http-equiv=\"refresh\" content=\"60; map.php?formPort=" . $varPort2. "\">";
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false" /></script>
|
||||
<!-- Javascript to plot the locations of Source IPs on the map -->
|
||||
<script type='text/javascript'>
|
||||
//This javascript will load when the page loads.
|
||||
jQuery(document).ready( function($){
|
||||
|
||||
//Initialize the Google Maps
|
||||
var geocoder;
|
||||
var map;
|
||||
var markersArray = [];
|
||||
var infos = [];
|
||||
|
||||
geocoder = new google.maps.Geocoder();
|
||||
var myOptions = {
|
||||
zoom: 2,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||
center: new google.maps.LatLng(13.30410, -27.570313),
|
||||
}
|
||||
//Load the Map into the map_canvas div
|
||||
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||
//map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||
var mcOptions = {gridSize: 50, maxZoom: 14};
|
||||
//Initialize a variable that the auto-size the map to whatever you are plotting
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
//Initialize the encoded string
|
||||
var encodedString;
|
||||
//Initialize the array that will hold the contents of the split string
|
||||
var stringArray = [];
|
||||
//Get the value of the encoded string from the hidden input
|
||||
encodedString = document.getElementById("encodedString").value;
|
||||
//Split the encoded string into an array the separates each location
|
||||
stringArray = encodedString.split("****");
|
||||
|
||||
var x;
|
||||
for (x = 0; x < stringArray.length; x = x + 1)
|
||||
{
|
||||
var addressDetails = [];
|
||||
var marker;
|
||||
//Separate each field
|
||||
addressDetails = stringArray[x].split("&&&");
|
||||
//Load the lat, long data
|
||||
var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
|
||||
//Create a new marker and info window
|
||||
marker = new google.maps.Marker({
|
||||
map: map,
|
||||
position: lat,
|
||||
//Content is what will show up in the info window
|
||||
content: addressDetails[0]
|
||||
});
|
||||
//Pushing the markers into an array so that it's easier to manage them
|
||||
markersArray.push(marker);
|
||||
google.maps.event.addListener( marker, 'click', function () {
|
||||
closeInfos();
|
||||
var info = new google.maps.InfoWindow({content: this.content});
|
||||
//On click the map will load the info window
|
||||
info.open(map,this);
|
||||
infos[0]=info;
|
||||
});
|
||||
//Extends the boundaries of the map to include this new location
|
||||
bounds.extend(lat);
|
||||
}
|
||||
//Takes all the lat, longs in the bounds variable and autosizes the map
|
||||
//map.fitBounds(bounds);
|
||||
var mc = new MarkerClusterer(map, markersArray, mcOptions);
|
||||
//Manages the info windows
|
||||
function closeInfos(){
|
||||
if(infos.length > 0){
|
||||
infos[0].set("marker",null);
|
||||
infos[0].close();
|
||||
infos.length = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Perform the MySQL query to get the source IPs, and geolocate them using the Pear Net::GeoIP class -->
|
||||
<?php
|
||||
require_once "Net/GeoIP.php";
|
||||
$geoip = Net_GeoIP::getInstance("../mapdata/GeoLiteCity.dat");
|
||||
|
||||
//Get data from the form submit
|
||||
if(isset($_GET['formPort'])){
|
||||
$varPort = $_GET['formPort'];
|
||||
}else{
|
||||
$varPort = 0;
|
||||
}
|
||||
|
||||
//Connect to DB to pull IPs
|
||||
//Include DB connection Info
|
||||
include("../includes/db_config.php");
|
||||
|
||||
// Create connection
|
||||
$conn1 = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
//Create dropdown
|
||||
$query1 = "SELECT src_ip FROM rawdata WHERE `dst_port` = '".$varPort."' AND time > (UNIX_TIMESTAMP() - 900) GROUP BY src_ip";
|
||||
$iplist = mysqli_query($conn1, $query1);
|
||||
|
||||
echo "<h2>Locations of the Unique Source IP addresses for incoming traffic on Port $varPort from the last 15 minutes</h2>";
|
||||
|
||||
//Initialize your first couple variables
|
||||
$encodedString = ""; //This is the string that will hold all your location data
|
||||
$x = 0; //This is a trigger to keep the string tidy
|
||||
|
||||
|
||||
//Multiple rows are returned
|
||||
while ($row = mysqli_fetch_array($iplist))
|
||||
{
|
||||
$ip = $row['src_ip'];
|
||||
$location = $geoip->lookupLocation($ip);
|
||||
//This is to keep an empty first or last line from forming, when the string is split
|
||||
if ( $x == 0 )
|
||||
{
|
||||
$separator = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Each row in the database is separated in the string by four *'s
|
||||
$separator = "****";
|
||||
}
|
||||
//Saving to the String, each variable is separated by three &'s
|
||||
$encodedString = $encodedString.$separator.
|
||||
"<p class='content'><b>IP: </b>".$row['src_ip'].
|
||||
"<br><b>Lat:</b> ".$location->latitude.
|
||||
"<br><b>Long:</b> ".$location->longitude.
|
||||
"</p>&&&".$location->latitude."&&&".$location->longitude;
|
||||
$x = $x + 1;
|
||||
}
|
||||
$conn1->close();
|
||||
?>
|
||||
<input type="hidden" id="encodedString" name="encodedString" value="<?php echo $encodedString; ?>" />
|
||||
</div>
|
||||
<!-- Display the map -->
|
||||
<div id="map_canvas"></div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user