index.php 6.85 KB
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="2">
<title>Détection automatique de DoS</title>
<script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script type="text/javascript">
    window.onload = function() {
        var dataPoints = [];

        function getDataPointsFromCSV(csv) {
            var dataPoints = csvLines = points = [];
            csvLines = csv.split(/[\r?\n|\r|\n]+/);

            for (var i = 0; i < csvLines.length; i++)
                if (csvLines[i].length > 0) {
                    points = csvLines[i].split(",");
                    dataPoints.push({
                        x: parseFloat(points[0]),
                        y: parseFloat(points[1])
                    });
                }
            return dataPoints;
        }

        function getDataTraficFromCSV(csv) {
            var dataPoints = csvLines = points = [];
            csvLines = csv.split(/[\r?\n|\r|\n]+/);
            for (var i = 0; i < csvLines.length; i++)
                if (csvLines[i].length > 0) {
                    return csvLines[i]
                }
        }

      	$.get("temperature.csv", function(data) {
      	    var chart = new CanvasJS.Chart("chartTemp", {
              axisY: {
                title: "Température (Celsius)"
            	},
            	axisX: {
            		title: "Temps",
            		titleFontColor: "#4F81BC",
            		suffix: "s"
            	},
      		    data: [{
      		         type: "area",
                   color: "red",
      		         dataPoints: getDataPointsFromCSV(data)
      		      }]
      	     });
      	      chart.render();
      	});

        $.get("ping.csv", function(data) {
            var chart = new CanvasJS.Chart("chartPing", {
              axisY: {
                title: "Ping (ms)"
              },
              axisX: {
                title: "Temps",
                titleFontColor: "#4F81BC",
                suffix: "s"
              },
              data: [{
                   type: "area",
                   color: "blue",
                   dataPoints: getDataPointsFromCSV(data)
                }]
             });
              chart.render();
        });

        $.get("puissance.csv", function(data) {
            var chart = new CanvasJS.Chart("chartPuissance", {
              axisY: {
                title: "RSSI (dBm)"
              },
              axisX: {
                title: "Temps",
                titleFontColor: "#4F81BC",
                suffix: "s"
              },
              data: [{
                   type: "area",
                   color: "green",
                   dataPoints: getDataPointsFromCSV(data)
                }]
             });
              chart.render();
        });

        $.get("traficPing.csv", function(data) {
            x = getDataTraficFromCSV(data);
            if(x == 0){
              var chart = new CanvasJS.Chart("chartTraficPing", {
                theme: "light2", // "light1", "light2", "dark1", "dark2"
              	exportEnabled: true,
              	animationEnabled: true,
              	title: {
              		text: "PING"
              	},
              	data: [{
              		type: "pie",
              		startAngle: 25,
              		toolTipContent: "<b>{label}</b>: {y}%",
              		showInLegend: "true",
              		legendText: "{label}",
              		indexLabelFontSize: 16,
              		indexLabel: "{label} - {y}%",
              		dataPoints: [
              			{y: 100, label: "Normal", color: "green"},
                    {y: 0, label: "Attaque", color: "red"}
              		]
              	}]
              });
            }
            else if(x == 1) {
              var chart = new CanvasJS.Chart("chartTraficPing", {
                theme: "light2", // "light1", "light2", "dark1", "dark2"
              	exportEnabled: true,
              	animationEnabled: true,
              	title: {
              		text: "PING"
              	},
              	data: [{
              		type: "pie",
              		startAngle: 25,
              		toolTipContent: "<b>{label}</b>: {y}%",
              		showInLegend: "true",
              		legendText: "{label}",
              		indexLabelFontSize: 16,
              		indexLabel: "{label} - {y}%",
              		dataPoints: [
              			{y: 0, label: "Normal", color: "green"},
                    {y: 100, label: "Attaque", color: "red"}
              		]
              	}]
              });
            }
            chart.render();
        });

        $.get("traficRssi.csv", function(data) {
            x = getDataTraficFromCSV(data);
            if(x == 0){
              var chart = new CanvasJS.Chart("chartTraficRssi", {
                theme: "light2", // "light1", "light2", "dark1", "dark2"
              	exportEnabled: true,
              	animationEnabled: true,
              	title: {
              		text: "RSSI"
              	},
              	data: [{
              		type: "pie",
              		startAngle: 25,
              		toolTipContent: "<b>{label}</b>: {y}%",
              		showInLegend: "true",
              		legendText: "{label}",
              		indexLabelFontSize: 16,
              		indexLabel: "{label} - {y}%",
              		dataPoints: [
              			{y: 100, label: "Normal", color: "green"},
                    {y: 0, label: "Attaque", color: "red"}
              		]
              	}]
              });
            }
            else if (x == 1) {
              var chart = new CanvasJS.Chart("chartTraficRssi", {
                theme: "light2", // "light1", "light2", "dark1", "dark2"
              	exportEnabled: true,
              	animationEnabled: true,
              	title: {
              		text: "RSSI"
              	},
              	data: [{
              		type: "pie",
              		startAngle: 25,
              		toolTipContent: "<b>{label}</b>: {y}%",
              		showInLegend: "true",
              		legendText: "{label}",
              		indexLabelFontSize: 16,
              		indexLabel: "{label} - {y}%",
              		dataPoints: [
              			{y: 0, label: "Normal", color: "green"},
                    {y: 100, label: "Attaque", color: "red"}
              		]
              	}]
              });
            }
            chart.render();
        });
  }
</script>
</head>
<body>
  <div style="float:left; width:70%;">
  	<div id="chartTemp" style="width:100%; height:200px;"></div>
    <div id="chartPing" style="width:100%; height:200px;"></div>
    <div id="chartPuissance" style="width:100%; height:200px;"></div>
  </div>
  <br>
  <br>
  <br>
  <br>
  <div style="float:left; width:30%;">
    <div id="chartTraficPing" style="width:100%; height:200px;"></div>
    <div id="chartTraficRssi" style="width:100%; height:200px;"></div>
  </div>
</body>
</html>