| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/projects/ivca/ |
Upload File : |
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="20" />
<title>Untitled Document</title>
</head>
<body style = "text-align: ceneter; background-color: beige;"></body>
<body>
<?php
// Parametri baze podataka
$servername = "localhost";
$username = "rasin";
$password = "ErGtvlwYloAv5bFh";
$dbname = "senzordata";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
// if ($conn -> connect_error) {
// die("Connection failed: " . $conn -> connect_error);
// }
if(!$conn){
die("Connection failed: " . mysqli_connect_error());
}
// echo "Connected successfully";
// $dbh = mysqli_connect($servername, $username, $password, $dbname) or die ('I cannot connect to the database because: ' . mysqli_error($dbh));
$dbh = mysqli_connect($servername, $username, $password, $dbname);
// mysqli_select_db($dbname);
// Parametri grafika
$tpar_sr = "Temperatura vazduha";
$tpar_en = "Temperature";
$hpar_sr = "Vlažnost vazduha";
$hpar_en = "Humidity";
// Ispisivanje zaglavlja
include "ivth_header.php";
// Ispisivanje naziva parametara
include "ivth_par.php";
// Draw coordinate system
include "ivth_ord.php";
// Rad sa bazom podataka
//include "ivth_dbheader.php"
// Multiplicative parameters
$t0 = 0;
$dy = 0;
$h = 4;
//
$dty=-5;
$dtx=400;
$dt0=400;
// Draw line for 0C
echo"<g stroke='black'>";
echo "<line x1='225' y1='".$dt0."' x2='1025' y2='".$dt0."' />";
echo"</g>";
echo"<g stroke = 'gray'>";
echo "<line x1='225' y1='200' x2='1025' y2='200' />";
echo"</g>";
echo"<g stroke='gray' stroke-width='1'>";
echo "<line x1='225' y1='160' x2='1025' y2='160' />"; // 80 oC
echo "<line x1='225' y1='120' x2='1025' y2='120' />"; // 70 oC
echo "<line x1='225' y1='80' x2='1025' y2='80' />"; // 60 oC
echo "<line x1='225' y1='40' x2='1025' y2='40' />"; // 50 0C
echo "<line x1='225' y1='240' x2='1025' y2='240' />"; // 40 oC
echo "<line x1='225' y1='280' x2='1025' y2='280' />"; // 30 oC
echo "<line x1='225' y1='320' x2='1025' y2='320' />"; // 20 oC
echo "<line x1='225' y1='360' x2='1025' y2='360' />"; // 10 oC
echo "<line x1='225' y1='400' x2='1025' y2='400' />"; // 0 oC
echo "</g>";
// Draw legend for Temperature
echo "<text x='160' y='20' font-size='24' font-weight='bold' fill='blue'>T[ºC]</text>";
echo "<text x='198' y='206' font-size='20' font-weight='bold' fill='blue'>50</text>";
echo "<text x='198' y='166' font-size='20' font-weight='bold' fill='blue'>60</text>";
echo "<text x='198' y='126' font-size='20' font-weight='bold' fill='blue'>70</text>";
echo "<text x='198' y='86' font-size='20' font-weight='bold' fill='blue'>80</text>";
echo "<text x='198' y='46' font-size='20' font-weight='bold' fill='blue'>90</text>";
echo "<text x='198' y='246' font-size='20' font-weight='bold' fill='blue'>40</text>";
echo "<text x='198' y='286' font-size='20' font-weight='bold' fill='blue'>30</text>";
echo "<text x='198' y='324' font-size='20' font-weight='bold' fill='blue'>20</text>";
echo "<text x='198' y='364' font-size='20' font-weight='bold' fill='blue'>10</text>";
echo "<text x='206' y='404' font-size='20' font-weight='bold' fill='blue'>0</text>";
// Draw legend for Humidity
echo "<text x='1030' y='20' font-size='24' font-weight='bold' fill='green'>H[%]</text>";
echo "<text x='1030' y='206' font-size='20' font-weight='bold' fill='green'>50</text>";
echo "<text x='1030' y='166' font-size='20' font-weight='bold' fill='green'>60</text>";
echo "<text x='1030' y='126' font-size='20' font-weight='bold' fill='green'>70</text>";
echo "<text x='1030' y='86' font-size='20' font-weight='bold' fill='green'>80</text>";
echo "<text x='1030' y='46' font-size='20' font-weight='bold' fill='green'>90</text>";
echo "<text x='1030' y='246' font-size='20' font-weight='bold' fill='green'>40</text>";
echo "<text x='1030' y='286' font-size='20' font-weight='bold' fill='green'>30</text>";
echo "<text x='1030' y='324' font-size='20' font-weight='bold' fill='green'>20</text>";
echo "<text x='1030' y='364' font-size='20' font-weight='bold' fill='green'>10</text>";
echo "<text x='1038' y='404' font-size='20' font-weight='bold' fill='green'>0</text>";
echo "<text x='1030' y='390' font-size='24' font-weight='bold' fill='black'>t</text>";
//DRAW GRAPHICS
$sql = "SELECT * FROM ivmeteo ORDER BY time ASC";
$result = mysqli_query($dbh, $sql) or die (mysqli_error($dbh));
$ts=$row['time'];
$numofrows = mysqli_num_rows($result);
$xst=32;
if ($numofrows>16) $xst=16;
if ($numofrows>32) $xst=8;
if ($numofrows>64) $xst=4;
if ($numofrows>128) $xst=2;
if ($numofrows>256) $xst=1;
if ($numofrows>512) $xst=0.5;
// Draw graph - Temperature
echo "<g stroke-width = '2' stroke='blue'>";
$k=0;
$row = mysqli_fetch_array($result);
$y1=400-($row['temperature']-$dy)*$h;
for ($x = 225; $x < 1025; $x=$x+$xst) {
$k++;
$row = mysqli_fetch_array($result);
$x1=$x;
$x2=$x+$xst;
$y2=400-($row['temperature']-$dy)*$h;
if ($k<$numofrows){
echo "<line x1=".$x1." y1=".$y1." x2=".$x2." y2=".$y2." />";
}
$y1=$y2;
}
echo "</g>";
// Draw graph - Humidity
$sql = "SELECT * FROM ivmeteo ORDER BY time ASC";
$result = mysqli_query($dbh, $sql) or die (mysqli_error($dbh));
$ts=$row['time'];
$numofrows = mysqli_num_rows($result);
$xst=32;
if ($numofrows>16) $xst=16;
if ($numofrows>32) $xst=8;
if ($numofrows>64) $xst=4;
if ($numofrows>128) $xst=2;
if ($numofrows>256) $xst=1;
if ($numofrows>512) $xst=0.5;
echo "<g stroke-width = '2' stroke='green'>";
$k=0;
$row = mysqli_fetch_array($result);
$y1=400-($row['humidity']-$dy)*$h;
for ($x = 225; $x < 1025; $x=$x+$xst) {
$k++;
$row = mysqli_fetch_array($result);
$x1=$x;
$x2=$x+$xst;
$y2=400-($row['humidity']-$dy)*$h;
if ($k<$numofrows){
echo "<line x1=".$x1." y1=".$y1." x2=".$x2." y2=".$y2." />";
}
$y1=$y2;
}
echo "</g>";
//echo "<text x='5' y='439'>AMS ".$ams[$st]." Time ".$ts." # ".$te."</text>";
echo "</svg>";
echo "</table>";
echo "<br>";
// FOOTHER
include "graph-foother-sr.php";
//MIN - MAX
$par_db="temperature";
$parameter = "Temperature";
//include "plastgth_minmax_1.php";
mysqli_close($dbh);
?>
<table>
<tr>
<td style = "width: 100px; text-align: center"><a href = "appmenu.php"><img src = "img/r_ret.png" width = "" height = "48"></a></td>
<td style = "width: 200px; font-size: 12px; text-align: justify; color: blue"><i>Povratak na početnu stranicu</i></td>
<td style = "width: 400px"></td>
</tr>
</table>
<?php include 'foother.php'; ?>
</body>
</html>