mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Fix coding style part 2
This commit is contained in:
+95
-70
@@ -1,101 +1,126 @@
|
||||
<?php
|
||||
|
||||
$pagetitle[] = "Services";
|
||||
$pagetitle[] = 'Services';
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
echo("<span style='font-weight: bold;'>Services</span> » ");
|
||||
echo "<span style='font-weight: bold;'>Services</span> » ";
|
||||
|
||||
$menu_options = array('basic' => 'Basic',
|
||||
'details' => 'Details');
|
||||
$menu_options = array(
|
||||
'basic' => 'Basic',
|
||||
'details' => 'Details',
|
||||
);
|
||||
|
||||
$sql_param = array();
|
||||
if(isset($vars['state']))
|
||||
{
|
||||
if($vars['state'] == 'up')
|
||||
{
|
||||
$state = '1';
|
||||
}
|
||||
elseif($vars['state'] == 'down')
|
||||
{
|
||||
$state = '0';
|
||||
}
|
||||
if (isset($vars['state'])) {
|
||||
if ($vars['state'] == 'up') {
|
||||
$state = '1';
|
||||
}
|
||||
else if ($vars['state'] == 'down') {
|
||||
$state = '0';
|
||||
}
|
||||
}
|
||||
|
||||
if ($vars['state']) {
|
||||
$where .= " AND service_status= ?"; $sql_param[] = $state;
|
||||
$where .= " AND service_disabled='0' AND `service_ignore`='0'"; $sql_param[] = '';
|
||||
if ($vars['state']) {
|
||||
$where .= ' AND service_status= ?';
|
||||
$sql_param[] = $state;
|
||||
$where .= " AND service_disabled='0' AND `service_ignore`='0'";
|
||||
$sql_param[] = '';
|
||||
}
|
||||
if ($vars['disabled']) { $where .= " AND service_disabled= ?"; $sql_param[] = $vars['disabled']; }
|
||||
if ($vars['ignore']) { $where .= " AND `service_ignore`= ?"; $sql_param[] = $vars['ignore']; }
|
||||
if (!$vars['view']) { $vars['view'] = "basic"; }
|
||||
|
||||
$sep = "";
|
||||
foreach ($menu_options as $option => $text)
|
||||
{
|
||||
if (empty($vars['view'])) { $vars['view'] = $option; }
|
||||
echo($sep);
|
||||
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
|
||||
echo(generate_link($text, $vars, array('view'=>$option)));
|
||||
if ($vars['view'] == $option) { echo("</span>"); }
|
||||
$sep = " | ";
|
||||
if ($vars['disabled']) {
|
||||
$where .= ' AND service_disabled= ?';
|
||||
$sql_param[] = $vars['disabled'];
|
||||
}
|
||||
|
||||
if ($vars['ignore']) {
|
||||
$where .= ' AND `service_ignore`= ?';
|
||||
$sql_param[] = $vars['ignore'];
|
||||
}
|
||||
|
||||
if (!$vars['view']) {
|
||||
$vars['view'] = 'basic';
|
||||
}
|
||||
|
||||
$sep = '';
|
||||
foreach ($menu_options as $option => $text) {
|
||||
if (empty($vars['view'])) {
|
||||
$vars['view'] = $option;
|
||||
}
|
||||
|
||||
echo $sep;
|
||||
if ($vars['view'] == $option) {
|
||||
echo "<span class='pagemenu-selected'>";
|
||||
}
|
||||
|
||||
echo generate_link($text, $vars, array('view' => $option));
|
||||
if ($vars['view'] == $option) {
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
$sep = ' | ';
|
||||
}
|
||||
|
||||
unset($sep);
|
||||
|
||||
print_optionbar_end();
|
||||
|
||||
echo('<table class="table table-condensed">');
|
||||
//echo("<tr class=interface-desc bgcolor='#e5e5e5'><td>Device</td><td>Service</td><td>Status</td><td>Changed</td><td>Checked</td><td>Message</td></tr>");
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5')
|
||||
{
|
||||
$host_sql = "SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.device_id GROUP BY D.hostname ORDER BY D.hostname";
|
||||
$host_par = array();
|
||||
} else {
|
||||
$host_sql = "SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname";
|
||||
$host_par = array($_SESSION['user_id']);
|
||||
echo '<table class="table table-condensed">';
|
||||
// echo("<tr class=interface-desc bgcolor='#e5e5e5'><td>Device</td><td>Service</td><td>Status</td><td>Changed</td><td>Checked</td><td>Message</td></tr>");
|
||||
if ($_SESSION['userlevel'] >= '5') {
|
||||
$host_sql = 'SELECT * FROM devices AS D, services AS S WHERE D.device_id = S.device_id GROUP BY D.hostname ORDER BY D.hostname';
|
||||
$host_par = array();
|
||||
}
|
||||
$shift = 1;
|
||||
foreach (dbFetchRows($host_sql, $host_par) as $device)
|
||||
{
|
||||
$device_id = $device['device_id'];
|
||||
else {
|
||||
$host_sql = 'SELECT * FROM devices AS D, services AS S, devices_perms AS P WHERE D.device_id = S.device_id AND D.device_id = P.device_id AND P.user_id = ? GROUP BY D.hostname ORDER BY D.hostname';
|
||||
$host_par = array($_SESSION['user_id']);
|
||||
}
|
||||
|
||||
$shift = 1;
|
||||
foreach (dbFetchRows($host_sql, $host_par) as $device) {
|
||||
$device_id = $device['device_id'];
|
||||
$device_hostname = $device['hostname'];
|
||||
if ($shift == 1) {
|
||||
array_unshift($sql_param, $device_id);
|
||||
$shift = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$sql_param[0] = $device_id;
|
||||
}
|
||||
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service)
|
||||
{
|
||||
include("includes/print-service.inc.php");
|
||||
|
||||
# $samehost = 1;
|
||||
if ($vars['view'] == "details")
|
||||
{
|
||||
$graph_array['height'] = "100";
|
||||
$graph_array['width'] = "215";
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $service['service_id'];
|
||||
$graph_array['type'] = "service_availability";
|
||||
foreach (dbFetchRows("SELECT * FROM `services` WHERE `device_id` = ? $where", $sql_param) as $service) {
|
||||
include 'includes/print-service.inc.php';
|
||||
|
||||
$periods = array('day', 'week', 'month', 'year');
|
||||
// $samehost = 1;
|
||||
if ($vars['view'] == 'details') {
|
||||
$graph_array['height'] = '100';
|
||||
$graph_array['width'] = '215';
|
||||
$graph_array['to'] = $config['time']['now'];
|
||||
$graph_array['id'] = $service['service_id'];
|
||||
$graph_array['type'] = 'service_availability';
|
||||
|
||||
echo('<tr style="background-color: '.$bg.'; padding: 5px;"><td colspan=6>');
|
||||
$periods = array(
|
||||
'day',
|
||||
'week',
|
||||
'month',
|
||||
'year',
|
||||
);
|
||||
|
||||
foreach ($periods as $period)
|
||||
{
|
||||
$graph_array['from'] = $$period;
|
||||
$graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400";
|
||||
echo(overlib_link("", generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL));
|
||||
}
|
||||
echo("</td></tr>");
|
||||
}
|
||||
}
|
||||
unset ($samehost);
|
||||
}
|
||||
echo '<tr style="background-color: '.$bg.'; padding: 5px;"><td colspan=6>';
|
||||
|
||||
echo("</table>");
|
||||
foreach ($periods as $period) {
|
||||
$graph_array['from'] = $$period;
|
||||
$graph_array_zoom = $graph_array;
|
||||
$graph_array_zoom['height'] = '150';
|
||||
$graph_array_zoom['width'] = '400';
|
||||
echo overlib_link('', generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), null);
|
||||
}
|
||||
|
||||
?>
|
||||
echo '</td></tr>';
|
||||
}//end if
|
||||
}//end foreach
|
||||
|
||||
unset($samehost);
|
||||
}//end foreach
|
||||
|
||||
echo '</table>';
|
||||
|
||||
Reference in New Issue
Block a user