2007-06-06 09:41:51 +00:00
<? php
2007-11-21 14:26:24 +00:00
if ( $_SESSION [ 'userlevel' ] >= '5' ) {
2007-06-24 14:56:47 +00:00
$sql = "SELECT * FROM `temperature` AS T, `devices` AS D WHERE T.temp_host = D.device_id ORDER BY D.hostname, T.temp_descr" ;
} else {
$sql = "SELECT * FROM `temperature` AS T, `devices` AS D, devices_perms as P WHERE T.temp_host = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION [ 'user_id' ] . "' ORDER BY D.hostname, T.temp_descr" ;
}
2007-06-06 09:41:51 +00:00
$query = mysql_query ( $sql );
2010-01-25 21:07:57 +00:00
echo ( '<table cellspacing="0" cellpadding="2" width="100%">' );
2007-06-06 09:41:51 +00:00
2010-01-25 21:07:57 +00:00
echo ( '<tr class=tablehead>
<th width="280">Device</th>
<th width="280">Sensor</th>
2009-12-30 21:20:40 +00:00
<th></th>
2010-01-25 21:07:57 +00:00
<th></th>
<th width="100">Current</th>
<th width="100">Alert</th>
2007-06-06 09:41:51 +00:00
<th>Notes</th>
2010-01-25 21:07:57 +00:00
</tr>' );
2007-06-06 09:41:51 +00:00
$row = 1 ;
2010-01-25 21:07:57 +00:00
while ( $temp = mysql_fetch_array ( $query ))
{
2007-06-06 09:41:51 +00:00
if ( is_integer ( $row / 2 )) { $row_colour = $list_colour_a ; } else { $row_colour = $list_colour_b ; }
$speed = humanspeed ( $temp [ 'ifSpeed' ]);
$type = humanmedia ( $temp [ 'ifType' ]);
2010-01-25 21:07:57 +00:00
$weekly_temp = "graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $week &to= $now &width=500&height=150" ;
2009-12-30 21:14:33 +00:00
$temp_popup = "<a onmouseover= \" return overlib('<img src=\' $weekly_temp \'>', LEFT); \" onmouseout= \" return nd(); \" >
2009-12-30 21:12:32 +00:00
" . $temp [ 'temp_descr' ] . "</a>" ;
2007-06-06 09:41:51 +00:00
2007-06-24 14:56:47 +00:00
$temp_perc = $temp [ 'temp_current' ] / $temp [ 'temp_limit' ] * 100 ;
$temp_colour = percent_colour ( $temp_perc );
2010-01-25 21:07:57 +00:00
if ( $temp [ 'temp_current' ] >= $temp [ 'temp_limit' ]) { $alert = '<img src="images/16/flag_red.png" alt="alert" />' ; } else { $alert = "" ; }
$temp_day = "graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $day &to= $now &width=300&height=100" ;
$temp_week = "graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $week &to= $now &width=300&height=100" ;
$temp_month = "graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $month &to= $now &width=300&height=100" ;
$temp_year = "graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $year &to= $now &width=300&height=100" ;
2007-06-24 14:56:47 +00:00
2010-01-25 21:07:57 +00:00
$temp_minigraph = "<img src='graph.php?id=" . $temp [ 'temp_id' ] . "&type=temperature&from= $day &to= $now &width=100&height=20'" ;
2010-01-03 20:13:10 +00:00
$temp_minigraph .= " onmouseover= \" return overlib('<div class=list-large>" . $temp [ 'hostname' ] . " - " . $temp [ 'temp_descr' ];
$temp_minigraph .= "</div><div style=\'width: 750px\'><img src=\' $temp_day \'><img src=\' $temp_week \'><img src=\' $temp_month \'><img src=\' $temp_year \'></div>', RIGHT" . $config [ 'overlib_defaults' ] . "); \" onmouseout= \" return nd(); \" >" ;
2007-06-06 09:41:51 +00:00
echo ( "<tr bgcolor= $row_colour >
<td class=list-bold>" . generatedevicelink ( $temp ) . "</td>
<td> $temp_popup </td>
2009-12-30 21:20:40 +00:00
<td> $temp_minigraph </td>
2010-01-25 21:07:57 +00:00
<td width=100> $alert </td>
2010-01-03 20:13:10 +00:00
<td style='color: $temp_colour ; text-align: center; font-weight: bold;'>" . $temp [ 'temp_current' ] . " °C</td>
<td style='text-align: center'>" . $temp [ 'temp_limit' ] . " °C</td>
2007-06-06 09:41:51 +00:00
<td>" . $temp [ 'temp_notes' ] . "</td>
</tr> \n " );
$row ++ ;
}
echo ( "</table>" );
?>