<?php
$id = $_GET['id']; $temp = array(); $all = false;
// CONGIG
// name to oczywiscie wyswietlana nazwa, all to czy pokazywac na wspolnym wykresie
//$temp[0] = array("name" => "Sypialnia", "all" => true);
//$temp[1] = array("name" => "Kuchnia", "all" => true);
//$temp[0] = array("name" => "Sypialnia", "all" => true);
$temp[1] = array("name" => "Pokój", "all" => true);
$temp[2] = array("name" => "Zewnatrz", "all" => true);
// Koniec Configu
// obecna temp
foreach(unserialize(file_get_contents("last.txt")) as $i => $t) {
if(isset($temp[($i)]))
$temp[($i)]["temp"] = $t; // Obecna Temp
}
if(!isset($temp[($id)])) // Gdy brak id to pokazuj wszystkie czujniki z parametrem all = true
$all = true;
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Temperatura</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function() {
Highcharts.setOptions({
lang: {
months: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Śierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
weekdays: ['Nie', 'Pon', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob'] },
global: {
useUTC: false
}
}),
window.chart = new Highcharts.StockChart({
chart: {
renderTo: 'container'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
second: '%d-%m-%y<br/>%H:%M:%S',
minute: '%d-%m<br/>%H:%M',
hour: '%d-%m<br/>%H:%M',
day: '%Y<br/>%d-%m',
week: '%Y<br/>%d-%m',
month: '%m-%Y',
year: '%Y'
}
},
rangeSelector: {
buttons: [{
type: 'day',
count: 1,
text: '1d'
}, {
type: 'day',
count: 7,
text: '7d'
}, {
type: 'month',
count: 1,
text: '1m'
}, {
type: 'year',
count: 1,
text: '1rok'
}, {
type: 'all',
text: 'All'
}],
selected: 0
},
title: {
text: '<?php echo ($all ? "Temperatura" : "Temperatura - ".$temp[($id)]['name']); ?>'
},
yAxis: {
title: {
text: 'Temperatura ( °C )'
},
},
<?php
if(!$all) {
echo "series: [{
name: 'Temperatura',
data: [".file_get_contents($id.'.txt')."],
type: 'spline',
shadow: true,
tooltip: {
valueDecimals: 2,
valueSuffix: '°C'
}
}] ";
} else {
echo "series: [";
$f = false;
foreach($temp as $k => $v) {
if(!$v['all']) continue;
if($f) echo ",";
echo "{
name: '".$v['name']."',
data: [".file_get_contents($k.'.txt')."],
type: 'spline',
shadow: true,
tooltip: {
valueDecimals: '2',
valueSuffix: ' °C'
}
}";
$f = true;
}
echo "] ";
}
?>
});
});
</script>
</head>
<body>
<script src="js/highstock.js"></script>
<script src="js/modules/exporting.js"></script>
<script type="text/javascript" src="js/themes/gray.js"></script>
<b>Temperatura (<a href="?">wszystkie termometry</a>)</b>
<table rules="all" border=1 width="100%"><tr width="100%">
<?php
$cd = "";
foreach($temp as $k => $v) {
echo '<td align="center"><a href="?id='.$k.'">'.$v["name"].'</a></td>';
$cd .= '<td align="center">'.$v["temp"].'</td>';
}
echo "</tr><tr>".$cd."</tr>"
?>
</table><br>
<div id="container" style="height: 500px"></div><br>
//<br>
//<a href="usb-io-pcb.png">Jesteś ciekaw jak wygląda stacja?</a>
//<br>
<!-- Nie usuwać! :) -->
<center>Created by <a href="http://bbarwik.com">BBarwik</a> (<a href="http://eko.one.pl/forum/profile.php?id=4187">forum</a>).</center>
</body>
</html>
A czy dużo roboty jest z przerobieniem powyższego kodu na to by korzystał z Mysql a nie z plików txt?
Bo głównie na tym by mi zależało. Mógłbym prosić kogoś o pomoc?
Dodałem wstawkę łączącą się z MySql - łączę się z bazą ale nadal żadnych pomiarów nie widać :(