diff --git a/includes/tsmmonitor.php b/includes/tsmmonitor.php index b128bcf..aaec342 100644 --- a/includes/tsmmonitor.php +++ b/includes/tsmmonitor.php @@ -719,26 +719,25 @@ class TSMMonitor { foreach ($rs as $row) { if ($type=="list") { - if ($i % 2 == 0) { - $outp .= ""; - }else{ - $outp .= ""; - } - $i++; - + $modrow = array(); + $widths = array(); while(list($keycell, $valcell) = each($row)) { if ($keycell == "id") { $id = $valcell; } else { - $outp .= "".$valcell.""; + $modrow[$keycell] = $valcell; } + $widths[$keycell] = ""; } $baseurl = $_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']; - $outp .= ""; - $outp .= ""; + $modrow["edit"] = ""; + $widths["edit"] = " width='20px' "; + $modrow["del"] = ""; + $widths["del"] = " width='20px' "; - $outp .= "\n"; + $outp .= $this->renderZebraTableRow($modrow, $i%2, "", "", $widths); + $i++; } else { $outp = $this->adodb->fetchArrayDB($sql); var_dump($outp); @@ -825,7 +824,7 @@ class TSMMonitor { if ($bContinue) { if ($type == "table") { - $i = 1; + $i = 0; $rs = $this->fetchSplitArrayDB($sql,20); foreach ($rs as $row) { @@ -838,30 +837,9 @@ class TSMMonitor { } else { $color = "ok"; } - $colorzebra = $colorsarray[$color][$i]; - } - if ($i % 2 == 0) { - $outp = $outp.""; - }else{ - $outp = $outp.""; } + $outp .= $this->renderZebraTableRow($row, $i%2, $col, $color, ""); $i++; - - while(list($keycell, $valcell) = each($row)) { - if($color!="" && $col==$keycell) { - - if ($i % 2 == 0) { - $cellcol = $colorsarray[$color."_light"]; - } else { - $cellcol = $colorsarray[$color."_dark"]; - } - $outp = $outp."".$valcell.""; - } else { - $outp = $outp."".$valcell.""; - } - - } - $outp = $outp."\n"; } } else if ($type == "verticaltable") { @@ -887,6 +865,46 @@ class TSMMonitor { return $outp; } + + + /** + * renderZebraTableRow - returns HTML code for one zebra tabel row + * + * @param mixed $row array of fields + * @param mixed $shade 1 or 0 + * @param mixed $alarmcol column which should be colored in alarm color + * @param mixed $color alarm color + * @param mixed $cellproperties array of cell properties (optional) + * @access public + * @return void + */ + function renderZebraTableRow ($row, $shade , $alarmcol, $color, $cellproperties) { + + $colorsarray = $this->configarray["colorsarray"]; + + $outp = $outp.""; + while(list($keycell, $valcell) = each($row)) { + if (isset($cellproperties) && $cellproperties[$keycell] != "") { + $cellproperty = " ".$cellproperties[$keycell]." "; + } else { + $cellproperty = ""; + } + if($color!="" && $alarmcol==$keycell) { + + if ($shade == 0) { + $cellcol = $colorsarray[$color."_light"]; + } else { + $cellcol = $colorsarray[$color."_dark"]; + } + $outp = $outp."".$valcell.""; + } else { + $outp = $outp."".$valcell.""; + } + } + $outp = $outp."\n"; + + return $outp; + } @@ -966,19 +984,14 @@ class TSMMonitor { $listip = $serveritems["ip"]; $listdescription = $serveritems["description"]; $listport = $serveritems["port"]; - if ($i == 0) { - $ret .= ""; - $i = 1; - } else { - $ret .= ""; - $i = 0; - } $listlink = $_SERVER['PHP_SELF']."?q=".$_SESSION["from"]."&m=".$this->GETVars['menu']."&s=".$servername; - $ret .= "".$servername."".$listdescription."".$listip."".$listport.""; + $row = array("".$servername."", $listdescription, $listip, $listport); + $ret .= $this->renderZebraTableRow($row, $i%2, "", "", ""); + $i++; } - return $ret.""; + } @@ -1022,21 +1035,17 @@ class TSMMonitor { $_SESSION["lastsql"] = $sql; $rs = $this->fetchSplitArrayDB($sql,20); foreach ($rs as $row) { - if ($i % 2 == 0) { - $outp = $outp.""; - } else { - $outp = $outp.""; - } - $i++; - + $modrow = array(); while(list($keycell, $valcell) = each($row)) { if ($keycell == "timestamp") { $valcell = strftime("%Y/%m/%d %T", $valcell); } - $outp = $outp."".$valcell.""; + $modrow[$keycell] = $valcell; } - $outp = $outp."\n"; + $outp .= $this->renderZebraTableRow($modrow, $i%2, "", "", ""); + $i++; } + $nav = $this->showPageNavigation("20"); if ($nav!="") { $outp = $outp."".$nav.""; @@ -1059,50 +1068,41 @@ class TSMMonitor { while(list($key, $val) = each($subindexqueryarray)) { - $bgcol=""; $comperator = ""; $alertval = ""; $alertcol = ""; - $cellcolors = $this->configarray["colorsarray"]; - $cache = $subindexqueryarray[$key]["cache"]; if ($this->configarray["serverlist"][$this->GETVars['server']]["libraryclient"] == 1 && $subindexqueryarray[$key]["notforlibclient"] == 1) { - $res = "-§§§-"; + $sqlres = array(); + $sqlres[0]["name"] = "-"; + $sqlres[0]["result"] = "-"; + $error = FALSE; } else { - $res = ''; $sql = "SELECT name, result from res_overview_".$this->GETVars['server']." where name='".$subindexqueryarray[$key]["name"]."'"; $sqlres = $this->adodb->fetchArrayDB($sql); - foreach ($sqlres as $row) { - $res .= $row['name']."§§§".$row['result']; - } + $comperator = $subindexqueryarray[$key]["alert_comp"]; + $alertval = $subindexqueryarray[$key]["alert_val"]; + $alertcol = $subindexqueryarray[$key]["alert_col"]; + $unit = $subindexqueryarray[$key]["unit"]; + $error = $this->checkAlert($comperator, $alertval, $sqlres[0]["result"]); } - if ($i == 1) { - $out = $out.""; - $i=0; + if ($error) { + $errorcolor = $alertcol; } else { - $out = $out.""; - $i=1; + $errorcolor = "ok"; } - $res = split("§§§", $res); - //$out .= $subindexqueryarray[$key]["header"]; - $out .= $res[0]; - $comperator = $subindexqueryarray[$key]["alert_comp"]; - $alertval = $subindexqueryarray[$key]["alert_val"]; - $alertcol = $subindexqueryarray[$key]["alert_col"]; - $unit = $subindexqueryarray[$key]["unit"]; - $error = $this->checkAlert($comperator, $alertval, $res[1]); - if ($i==1) { - $shade="light"; - } else { - $shade="dark"; - } - if ($error && $res != "" && $res[1] != "-") { - $bgcol="bgcolor='".$cellcolors[$alertcol."_".$shade]."'"; - } else { - $bgcol="bgcolor='".$cellcolors["ok_".$shade]."'"; - } - $out .= "".$res[1]." ".$unit."\n"; + + $cellprop = array(); + $cellprop["name"] = "width='50%'"; + $cellprop["result"] = "align='center'"; + + $res = array(); + $res["name"] = $sqlres[0]["name"]; + $res["result"] = $sqlres[0]["result"]." ".$unit; + + $out .= $this->renderZebraTableRow($res, $i%2, "result", $errorcolor, $cellprop, "" ); + $i++; } return $out; diff --git a/index.php b/index.php index 0c9d8cc..a4b5647 100644 --- a/index.php +++ b/index.php @@ -177,16 +177,16 @@ include_once "includes/page_head.php"; } } } else { - if (isset($_SESSION["logindata"])){ - $errormsg = "Login failed!"; - }else{ - $errormsg = "Login"; - } + if (isset($_SESSION["logindata"])){ + $errormsg = "Login failed!"; + }else{ + $errormsg = "Login"; + } - session_unset(); - $_SESSION=array(); + session_unset(); + $_SESSION=array(); - include_once "includes/login.php"; + include_once "includes/login.php"; } $_SESSION['from'] = $tsmmonitor->GETVars['qq'];