- Fixed memory exhaustion bug if DB query returned empty result set.
- Fixed POST/SESSION variable inconsistency with search form. - Cosmetics (removed whitespace at end of line).
This commit is contained in:
parent
e310e91542
commit
65322d9858
|
@ -23,9 +23,9 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* tsmmonitor.php, TSM Monitor
|
* tsmmonitor.php, TSM Monitor
|
||||||
*
|
*
|
||||||
* TSM Monitor main class
|
* TSM Monitor main class
|
||||||
*
|
*
|
||||||
* @author Michael Clemens
|
* @author Michael Clemens
|
||||||
* @package tsmmonitor
|
* @package tsmmonitor
|
||||||
*/
|
*/
|
||||||
|
@ -57,9 +57,9 @@ class TSMMonitor {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TSMMonitor
|
* TSMMonitor
|
||||||
*
|
*
|
||||||
* @param mixed $adodb
|
* @param mixed $adodb
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -131,8 +131,8 @@ class TSMMonitor {
|
||||||
|
|
||||||
//Cleanup
|
//Cleanup
|
||||||
if ($_SESSION["from"] != $_GET['q']) {
|
if ($_SESSION["from"] != $_GET['q']) {
|
||||||
$_SESSION['timemachine'] = "";
|
$_SESSION['timemachine'] = "";
|
||||||
$_SESSION['tabletype'] = "";
|
$_SESSION['tabletype'] = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// BEGIN Timemachine
|
// BEGIN Timemachine
|
||||||
|
@ -194,21 +194,23 @@ class TSMMonitor {
|
||||||
|
|
||||||
if (($recordSet) || ($this->adodb->conn->ErrorNo() == 0)) {
|
if (($recordSet) || ($this->adodb->conn->ErrorNo() == 0)) {
|
||||||
$total_rows = $recordSet->RecordCount($recordSet);
|
$total_rows = $recordSet->RecordCount($recordSet);
|
||||||
$this->max_pages = ceil($total_rows/$rows_per_page);
|
if ($total_rows > 0 ) {
|
||||||
|
$this->max_pages = ceil($total_rows/$rows_per_page);
|
||||||
|
|
||||||
if($this->page > $this->max_pages || $this->page <= 0) {
|
if($this->page > $this->max_pages || $this->page <= 0) {
|
||||||
$this->page = 1;
|
$this->page = 1;
|
||||||
}
|
}
|
||||||
$offset = $rows_per_page * ($this->page-1);
|
$offset = $rows_per_page * ($this->page-1);
|
||||||
$endset = $offset + $rows_per_page;
|
$endset = $offset + $rows_per_page;
|
||||||
$recordSet->Move($offset);
|
$recordSet->Move($offset);
|
||||||
|
|
||||||
while (($recordSet->CurrentRow() < $endset) && ($recordSet->CurrentRow() < $total_rows) && ($recordSet)) {
|
while (($recordSet->CurrentRow() < $endset) && ($recordSet->CurrentRow() < $total_rows) && ($recordSet)) {
|
||||||
$recordArray{sizeof($recordArray)} = $recordSet->fields;
|
$recordArray{sizeof($recordArray)} = $recordSet->fields;
|
||||||
$recordSet->MoveNext();
|
$recordSet->MoveNext();
|
||||||
}
|
}
|
||||||
$recordSet->close();
|
$recordSet->close();
|
||||||
return($recordArray);
|
}
|
||||||
|
return($recordArray);
|
||||||
} else {
|
} else {
|
||||||
echo "<p style='font-size: 16px; font-weight: bold; color: red;'>Database Error (".$this->conn->ErrorNo().")</p>\n<p>".$this->conn->ErrorMsg()."</p>";
|
echo "<p style='font-size: 16px; font-weight: bold; color: red;'>Database Error (".$this->conn->ErrorNo().")</p>\n<p>".$this->conn->ErrorMsg()."</p>";
|
||||||
exit;
|
exit;
|
||||||
|
@ -351,7 +353,7 @@ class TSMMonitor {
|
||||||
}
|
}
|
||||||
foreach ($this->getTimestampsOfADay($_SESSION['timemachine']['date']) as $ts) {
|
foreach ($this->getTimestampsOfADay($_SESSION['timemachine']['date']) as $ts) {
|
||||||
$ret .= "<option value='".$ts['timestamp']."'";
|
$ret .= "<option value='".$ts['timestamp']."'";
|
||||||
if ($_SESSION['timemachine']['time'] == $ts['timestamp']) {
|
if ($_SESSION['timemachine']['time'] == $ts['timestamp']) {
|
||||||
$ret .= " SELECTED ";
|
$ret .= " SELECTED ";
|
||||||
}
|
}
|
||||||
$ret .= "> ".strftime('%H:%M:%S', $ts['timestamp'])."</option>";
|
$ret .= "> ".strftime('%H:%M:%S', $ts['timestamp'])."</option>";
|
||||||
|
@ -416,7 +418,7 @@ class TSMMonitor {
|
||||||
$key = "admin.php";
|
$key = "admin.php";
|
||||||
}else if ($val['label'] == "TSM Monitor") {
|
}else if ($val['label'] == "TSM Monitor") {
|
||||||
$key = "index.php";
|
$key = "index.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($val['label'] == "trennlinie") {
|
if ($val['label'] == "trennlinie") {
|
||||||
$links .= "<br>\n";
|
$links .= "<br>\n";
|
||||||
|
@ -562,7 +564,7 @@ class TSMMonitor {
|
||||||
}
|
}
|
||||||
$link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".$name."&page=".$this->page."&so=".$sonew."'";
|
$link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".$name."&page=".$this->page."&so=".$sonew."'";
|
||||||
$label = $fieldnames[0]['Field'];
|
$label = $fieldnames[0]['Field'];
|
||||||
$tableheader = $tableheader."<th><a class='navhead' ".$link.">".$label." ".$arrow."</a></th>";
|
$tableheader = $tableheader."<th><a class='navhead' ".$link.">".$label." ".$arrow."</a></th>";
|
||||||
}
|
}
|
||||||
if ($isAdmin) {
|
if ($isAdmin) {
|
||||||
$tableheader = $tableheader."<th colspan=2><a class='navhead'></a></th>";
|
$tableheader = $tableheader."<th colspan=2><a class='navhead'></a></th>";
|
||||||
|
@ -573,7 +575,7 @@ class TSMMonitor {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkLogin - processes login procedure and sets loggedin property in SESSION
|
* checkLogin - processes login procedure and sets loggedin property in SESSION
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function checkLogin() {
|
function checkLogin() {
|
||||||
|
@ -590,7 +592,7 @@ class TSMMonitor {
|
||||||
|
|
||||||
if ($ret[0] != "" && $ret[0]['password'] == md5($pass)) {
|
if ($ret[0] != "" && $ret[0]['password'] == md5($pass)) {
|
||||||
$_SESSION["logindata"]["role"] = $ret[0]['role'];
|
$_SESSION["logindata"]["role"] = $ret[0]['role'];
|
||||||
if (!$isAdmin || ($isAdmin && $ret[0]['role'] == "admin")) {
|
if (!$isAdmin || ($isAdmin && $ret[0]['role'] == "admin")) {
|
||||||
$_SESSION["logindata"]["loggedin"] = TRUE;
|
$_SESSION["logindata"]["loggedin"] = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -609,7 +611,7 @@ class TSMMonitor {
|
||||||
*
|
*
|
||||||
* @param string $comperator
|
* @param string $comperator
|
||||||
* @param string $alertval the value which will trigger an alert
|
* @param string $alertval the value which will trigger an alert
|
||||||
* @param string $val the value that will be checked
|
* @param string $val the value that will be checked
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function checkAlert($comperator = '', $alertval = '', $val = '') {
|
function checkAlert($comperator = '', $alertval = '', $val = '') {
|
||||||
|
@ -692,9 +694,9 @@ class TSMMonitor {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTableFields
|
* getTableFields
|
||||||
*
|
*
|
||||||
* @param string $tablename
|
* @param string $tablename
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -798,7 +800,7 @@ class TSMMonitor {
|
||||||
$outp = '';
|
$outp = '';
|
||||||
$outp_cache = '';
|
$outp_cache = '';
|
||||||
$stop=FALSE;
|
$stop=FALSE;
|
||||||
$tablearray = array();
|
$tablearray = array();
|
||||||
$bContinue = TRUE;
|
$bContinue = TRUE;
|
||||||
|
|
||||||
if ($this->GETVars['ob'] != '' ) {
|
if ($this->GETVars['ob'] != '' ) {
|
||||||
|
@ -858,7 +860,7 @@ class TSMMonitor {
|
||||||
} else {
|
} else {
|
||||||
$lpp = 20;
|
$lpp = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bContinue) {
|
if ($bContinue) {
|
||||||
if ($type == "table") {
|
if ($type == "table") {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -902,11 +904,11 @@ class TSMMonitor {
|
||||||
|
|
||||||
return $outp;
|
return $outp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renderZebraTableRow - returns HTML code for one zebra tabel row
|
* renderZebraTableRow - returns HTML code for one zebra tabel row
|
||||||
*
|
*
|
||||||
* @param mixed $row array of fields
|
* @param mixed $row array of fields
|
||||||
* @param mixed $shade 1 or 0
|
* @param mixed $shade 1 or 0
|
||||||
* @param mixed $alarmcol column which should be colored in alarm color
|
* @param mixed $alarmcol column which should be colored in alarm color
|
||||||
|
@ -964,14 +966,23 @@ class TSMMonitor {
|
||||||
$arrval = "";
|
$arrval = "";
|
||||||
$arrop = "";
|
$arrop = "";
|
||||||
|
|
||||||
$operators = array ("<", "=", "<>", ">");
|
$operators = array ("<", "=", "<>", ">", "LIKE");
|
||||||
|
$searcharr = $_SESSION["search"][$this->GETVars['qq']];
|
||||||
$searcharr = $_SESSION["search"][$this->GETVars['qq']];
|
if ($_POST["wcfield"] != "") {
|
||||||
if (isset($searcharr)) {
|
$arrfield = $_POST["wcfield"];
|
||||||
$arrfield = $searcharr["field"];
|
} else if (isset($searcharr)){
|
||||||
$arrval = $searcharr["val"];
|
$arrfield = $searcharr["field"];
|
||||||
$arrop = $searcharr["op"];
|
}
|
||||||
}
|
if ($_POST["wcval"] != "") {
|
||||||
|
$arrval = $_POST["wcval"];
|
||||||
|
} else if (isset($searcharr)){
|
||||||
|
$arrval = $searcharr["val"];
|
||||||
|
}
|
||||||
|
if ($_POST["wcop"] != "") {
|
||||||
|
$arrop = $_POST["wcop"];
|
||||||
|
} else if (isset($searcharr)){
|
||||||
|
$arrop = $searcharr["op"];
|
||||||
|
}
|
||||||
$sql = "SHOW COLUMNS FROM res_".$this->configarray["queryarray"][$this->GETVars['qq']]["name"]."_".$this->GETVars['server'];
|
$sql = "SHOW COLUMNS FROM res_".$this->configarray["queryarray"][$this->GETVars['qq']]["name"]."_".$this->GETVars['server'];
|
||||||
$fieldnames = $this->adodb->fetchArrayDB($sql);
|
$fieldnames = $this->adodb->fetchArrayDB($sql);
|
||||||
|
|
||||||
|
@ -987,7 +998,7 @@ class TSMMonitor {
|
||||||
$fieldbox.= "</select>";
|
$fieldbox.= "</select>";
|
||||||
|
|
||||||
// Build Operator Combobox
|
// Build Operator Combobox
|
||||||
if ($arrop=="") $arrop="=";
|
if ($arrop == "") $arrop="=";
|
||||||
$opbox = "<select name='wcop' size=1 onChange='' class='button topnavbutton'>";
|
$opbox = "<select name='wcop' size=1 onChange='' class='button topnavbutton'>";
|
||||||
foreach ($operators as $op) {
|
foreach ($operators as $op) {
|
||||||
$opbox.= '<option value="'.$op.'"';
|
$opbox.= '<option value="'.$op.'"';
|
||||||
|
@ -1142,7 +1153,7 @@ class TSMMonitor {
|
||||||
} else {
|
} else {
|
||||||
$errorcolor = "ok";
|
$errorcolor = "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
$cellprop = array();
|
$cellprop = array();
|
||||||
$cellprop["name"] = "width='50%'";
|
$cellprop["name"] = "width='50%'";
|
||||||
$cellprop["result"] = "align='center'";
|
$cellprop["result"] = "align='center'";
|
||||||
|
@ -1273,7 +1284,7 @@ class TSMMonitor {
|
||||||
$end = ($valrow[2]-$startpunkt)/$faktor;
|
$end = ($valrow[2]-$startpunkt)/$faktor;
|
||||||
$duration = $end - $start;
|
$duration = $end - $start;
|
||||||
// fake a longer time for better visibility
|
// fake a longer time for better visibility
|
||||||
if ($duration < 2) {$duration=2;}
|
if ($duration < 2) {$duration=2;}
|
||||||
// cut the bar at the right side to fit into table
|
// cut the bar at the right side to fit into table
|
||||||
if (($start+$duration)>$lastpoint) {
|
if (($start+$duration)>$lastpoint) {
|
||||||
$duration = $lastpoint-$start;
|
$duration = $lastpoint-$start;
|
||||||
|
|
19
index.php
19
index.php
|
@ -24,9 +24,9 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* index.php, TSM Monitor
|
* index.php, TSM Monitor
|
||||||
*
|
*
|
||||||
* main php file
|
* main php file
|
||||||
*
|
*
|
||||||
* @author Michael Clemens
|
* @author Michael Clemens
|
||||||
* @package tsmmonitor
|
* @package tsmmonitor
|
||||||
*/
|
*/
|
||||||
|
@ -44,9 +44,9 @@ include_once "includes/page_head.php";
|
||||||
<td id="tnright">
|
<td id="tnright">
|
||||||
<div id="tnbox1">
|
<div id="tnbox1">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ( $_SESSION["logindata"]["loggedin"] && !in_array($tsmmonitor->GETVars['qq'], array("admin", "serverlist", "custom", "polldstat", "index", "overview", "")) && !strstr($tsmmonitor->GETVars['qq'], 'table') ) {
|
if ( $_SESSION["logindata"]["loggedin"] && !in_array($tsmmonitor->GETVars['qq'], array("admin", "serverlist", "custom", "polldstat", "index", "overview", "")) && !strstr($tsmmonitor->GETVars['qq'], 'table') ) {
|
||||||
echo $tsmmonitor->getSearchfield();
|
echo $tsmmonitor->getSearchfield();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -153,11 +153,14 @@ include_once "includes/page_head.php";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$whereclause = array();
|
$whereclause = array();
|
||||||
$whereclause["field"] = $_POST["wcfield"];
|
$whereclause["field"] = $_POST["wcfield"];
|
||||||
$whereclause["val"] = $_POST["wcval"];
|
$whereclause["val"] = $_POST["wcval"];
|
||||||
$whereclause["op"] = $_POST["wcop"];
|
$whereclause["op"] = $_POST["wcop"];
|
||||||
//}
|
if ($whereclause["op"] == 'LIKE') {
|
||||||
if ($whereclause["field"]!="" && $whereclause["val"]!="") {
|
$whereclause["val"] = ereg_replace("\*","%",$whereclause["val"]);
|
||||||
|
$_POST["wcval"] = $whereclause["val"];
|
||||||
|
}
|
||||||
|
if ($whereclause["field"] != "" && $whereclause["val"] != "") {
|
||||||
if ($_POST["Clear"] == "Clear") {
|
if ($_POST["Clear"] == "Clear") {
|
||||||
$_SESSION["search"][$tsmmonitor->GETVars['qq']] = "";
|
$_SESSION["search"][$tsmmonitor->GETVars['qq']] = "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,7 +210,7 @@ include_once "includes/page_head.php";
|
||||||
|
|
||||||
}
|
}
|
||||||
$_SESSION['from'] = $tsmmonitor->GETVars['qq'];
|
$_SESSION['from'] = $tsmmonitor->GETVars['qq'];
|
||||||
session_write_close(void);
|
session_write_close(void);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue