diff --git a/html/pages/health/current.inc.php b/html/pages/health/current.inc.php index a660ed6f2..074afecfe 100644 --- a/html/pages/health/current.inc.php +++ b/html/pages/health/current.inc.php @@ -1,93 +1,9 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='current' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `current` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='current' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr"; -} - -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".$sensor['sensor_descr']; - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { ## If graphs - echo(""); - - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentWarningLimitNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . "A" . $sensor['sensor_limit_warn'] . $unit . "" . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); +include("pages/health/sensors.inc.php"); ?> diff --git a/html/pages/health/fanspeed.inc.php b/html/pages/health/fanspeed.inc.php index 97182d80b..f8aae0665 100644 --- a/html/pages/health/fanspeed.inc.php +++ b/html/pages/health/fanspeed.inc.php @@ -1,92 +1,9 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='fanspeed' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr"; -} - -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - if ($sensor['sensor_current'] <= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".$sensor['sensor_descr']; - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - - echo(""); - - } # endif graphs - - $row++; -} - -echo("
DeviceFanCurrentAlertNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=219&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=219&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=219&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=219&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); +include("pages/health/sensors.inc.php"); ?> diff --git a/html/pages/health/frequency.inc.php b/html/pages/health/frequency.inc.php index dcabecba0..4e52297a0 100644 --- a/html/pages/health/frequency.inc.php +++ b/html/pages/health/frequency.inc.php @@ -1,92 +1,9 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='frequency' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='frequency' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr"; -} +include("pages/health/sensors.inc.php"); -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".$sensor['sensor_descr']; - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - - echo(""); - - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentRange limitNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit_low'] . $unit . " - " . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); - -?> \ No newline at end of file +?> diff --git a/html/pages/health/humidity.inc.php b/html/pages/health/humidity.inc.php index f1222bb10..68fcbec3b 100644 --- a/html/pages/health/humidity.inc.php +++ b/html/pages/health/humidity.inc.php @@ -2,95 +2,8 @@ $graph_type = "sensor_humidity"; $unit = "%"; +$class = "humidity"; -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='humidity' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_index, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='humidity' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_index, S.sensor_descr"; -} +include("pages/health/sensors.inc.php"); -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - $sensor['sensor_current'] = round($sensor['sensor_current'],1); - - $sensor_perc = $sensor['sensor_current'] / $sensor['sensor_limit'] * 100; - $sensor_colour = percent_colour($sensor_perc); - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".$sensor['sensor_descr']; - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - echo(""); - - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentAlertNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); - -?> \ No newline at end of file +?> diff --git a/html/pages/health/mempool.inc.php b/html/pages/health/mempool.inc.php index 505463308..3973b64de 100644 --- a/html/pages/health/mempool.inc.php +++ b/html/pages/health/mempool.inc.php @@ -14,8 +14,7 @@ echo(" "); $i = '1'; -$mempools = mysql_query("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname"); -while ($mempool = mysql_fetch_assoc($mempools)) +foreach (dbFetchRows("SELECT * FROM `mempools` AS M, `devices` as D WHERE D.device_id = M.device_id ORDER BY D.hostname") as $mempool) { if (device_permitted($mempool['device_id'])) { diff --git a/html/pages/health/power.inc.php b/html/pages/health/power.inc.php index bb0390f70..6256158b4 100644 --- a/html/pages/health/power.inc.php +++ b/html/pages/health/power.inc.php @@ -2,89 +2,8 @@ $graph_type = "sensor_power"; $unit = "W"; +$class = "power"; -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='power' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='power' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr"; -} - -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".mres($sensor['sensor_descr']); - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - echo(""); - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentRange limitNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit_low'] . $unit . " - " . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); +include("pages/health/sensors.inc.php"); ?> diff --git a/html/pages/health/processor.inc.php b/html/pages/health/processor.inc.php index 134cddf03..cfe59516e 100644 --- a/html/pages/health/processor.inc.php +++ b/html/pages/health/processor.inc.php @@ -13,8 +13,7 @@ echo(" "); $i = '1'; -$procs = mysql_query("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname"); -while ($proc = mysql_fetch_assoc($procs)) +foreach (dbFetchRows("SELECT * FROM `processors` AS P, `devices` AS D WHERE D.device_id = P.device_id ORDER BY D.hostname") as $proc) { if (device_permitted($proc['device_id'])) { diff --git a/html/pages/health/storage.inc.php b/html/pages/health/storage.inc.php index 7fabefe66..3b7a5c7f4 100644 --- a/html/pages/health/storage.inc.php +++ b/html/pages/health/storage.inc.php @@ -2,10 +2,6 @@ $graph_type = "storage_usage"; -$sql = "SELECT * FROM `storage` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.storage_descr"; - -$query = mysql_query($sql); - echo("
"); @@ -19,7 +15,7 @@ echo(" $row = 1; -while ($drive = mysql_fetch_assoc($query)) +foreach (dbFetchRows("SELECT * FROM `storage` AS S, `devices` AS D WHERE S.device_id = D.device_id ORDER BY D.hostname, S.storage_descr") as $drive) { if (device_permitted($drive['device_id'])) { diff --git a/html/pages/health/temperature.inc.php b/html/pages/health/temperature.inc.php index 08e095154..f6cd40cfd 100644 --- a/html/pages/health/temperature.inc.php +++ b/html/pages/health/temperature.inc.php @@ -2,94 +2,8 @@ $graph_type = "sensor_temperature"; $unit = "°C"; +$class = "temperature"; -if ($_SESSION['userlevel'] >= '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='temperature' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_index, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='temperature' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_index, S.sensor_descr"; -} - -$query = mysql_query($sql); - -echo('
'); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - $sensor['sensor_current'] = round($sensor['sensor_current'],1); - - $sensor_perc = $sensor['sensor_current'] / $sensor['sensor_limit'] * 100; - $sensor_colour = percent_colour($sensor_perc); - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".$sensor['sensor_descr']; - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - echo(""); - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentAlertNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); +include("pages/health/sensors.inc.php"); ?> diff --git a/html/pages/health/voltage.inc.php b/html/pages/health/voltage.inc.php index d16978106..57d8a6886 100644 --- a/html/pages/health/voltage.inc.php +++ b/html/pages/health/voltage.inc.php @@ -1,90 +1,9 @@ = '5') -{ - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='voltage' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; -} else { - $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='voltage' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr"; -} +include("pages/health/sensors.inc.php"); -$query = mysql_query($sql); - -echo(''); - -echo(' - - - - - - - - '); - -$row = 1; - -while ($sensor = mysql_fetch_assoc($query)) -{ - if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } - - $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; - $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> - " . $sensor['sensor_descr'] . ""; - - if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } - - $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; - $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; - $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; - $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; - - $sensor_minigraph = "".$sensor['hostname']." - ".mres($sensor['sensor_descr']); - $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; - - echo(" - - - - - - - - \n"); - - if ($_GET['optb'] == "graphs") - { - echo(""); - } # endif graphs - - $row++; -} - -echo("
DeviceSensorCurrentRange limitNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit_low'] . $unit . " - " . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); - - $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; - $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; - - $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; - $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; - - $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; - $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; - - $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; - $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; - - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("', LEFT);\" onmouseout=\"return nd();\"> - "); - echo("
"); - -?> \ No newline at end of file +?>