1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| <?php
//global $site;
if (!isset($_SESSION)) { session_start(); }
include 'db.php'; //paramètres bdd
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
// If there is an error with the connection, stop the script and display the error.
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
$b=$_SESSION['email'];
$sql = "SELECT * FROM `site` WHERE `email`='$b'";
$fire = mysqli_query($con,$sql);
$row_cnt = $fire->num_rows;
if ($row_cnt==0){
echo "Vous n'avez pas encore de site enregistré";
}
else{
while ($row = mysqli_fetch_array($fire)) {
//echo $row['nom']."\n";
$site=$row['nom'];
//include 'rapport.php';
$sql2 = "SELECT * FROM datar where nom='".$site."'";
//echo $sql2;
$datar = mysqli_query($con,$sql2);
while ($row = mysqli_fetch_array($datar)) {
$timeon=$row['timeon'];
$timetot=$row['timetot'];
}
if ($timetot==0){
echo "Vous n'avez pas encore de données pour ".$site."</br>";
}
else{
$time=($timeon/$timetot)*100;
echo "Pourcentage d'activité ".$site." sur ces dernières 24h : ".$time."% </br>";
}
$sq2 = "SELECT * FROM datag where nom='".$site."'";
//echo $sql2;
$datag = mysqli_query($con,$sq2);
?>
ok
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['time', 'Rep'],
<?php
while ($result = mysqli_fetch_assoc($datag)) {
if($result['rep']=='None'){
$result['rep']=0;
echo"['".$result['time']."',".$result['rep']."],";
}
else{
echo"['".$result['time']."',".$result['rep']."],";
}
}
?>
]);
var options = {
title: 'Response Time',
curveType: 'function',
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['time', 'Status'],
<?php
while ($result = mysqli_fetch_assoc($datag)) {
echo"['".$result['time']."',".$result['status']."],";
}
?>
]);
var options = {
title: 'Uptime',
isStacked: true,
legend:{position:'none'}
};
var chart = new google.visualization.SteppedAreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: auto; height: auto"></div>
<div id="chart_div" style="width: auto; height: 500px;"></div>
</body>
</html>
<?php
}
}
$con->close();
?> |
Partager