- 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:
Frank Fegert 2009-05-24 19:22:45 +00:00
parent e310e91542
commit 65322d9858
2 changed files with 66 additions and 52 deletions

View File

@ -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>";
@ -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.'"';

View File

@ -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 {