- 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)) {
$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) {
$this->page = 1;
}
$offset = $rows_per_page * ($this->page-1);
$endset = $offset + $rows_per_page;
$recordSet->Move($offset);
if($this->page > $this->max_pages || $this->page <= 0) {
$this->page = 1;
}
$offset = $rows_per_page * ($this->page-1);
$endset = $offset + $rows_per_page;
$recordSet->Move($offset);
while (($recordSet->CurrentRow() < $endset) && ($recordSet->CurrentRow() < $total_rows) && ($recordSet)) {
$recordArray{sizeof($recordArray)} = $recordSet->fields;
$recordSet->MoveNext();
}
$recordSet->close();
return($recordArray);
while (($recordSet->CurrentRow() < $endset) && ($recordSet->CurrentRow() < $total_rows) && ($recordSet)) {
$recordArray{sizeof($recordArray)} = $recordSet->fields;
$recordSet->MoveNext();
}
$recordSet->close();
}
return($recordArray);
} else {
echo "<p style='font-size: 16px; font-weight: bold; color: red;'>Database Error (".$this->conn->ErrorNo().")</p>\n<p>".$this->conn->ErrorMsg()."</p>";
exit;
@ -351,7 +353,7 @@ class TSMMonitor {
}
foreach ($this->getTimestampsOfADay($_SESSION['timemachine']['date']) as $ts) {
$ret .= "<option value='".$ts['timestamp']."'";
if ($_SESSION['timemachine']['time'] == $ts['timestamp']) {
if ($_SESSION['timemachine']['time'] == $ts['timestamp']) {
$ret .= " SELECTED ";
}
$ret .= "> ".strftime('%H:%M:%S', $ts['timestamp'])."</option>";
@ -964,14 +966,23 @@ class TSMMonitor {
$arrval = "";
$arrop = "";
$operators = array ("<", "=", "<>", ">");
$searcharr = $_SESSION["search"][$this->GETVars['qq']];
if (isset($searcharr)) {
$arrfield = $searcharr["field"];
$arrval = $searcharr["val"];
$arrop = $searcharr["op"];
}
$operators = array ("<", "=", "<>", ">", "LIKE");
$searcharr = $_SESSION["search"][$this->GETVars['qq']];
if ($_POST["wcfield"] != "") {
$arrfield = $_POST["wcfield"];
} else if (isset($searcharr)){
$arrfield = $searcharr["field"];
}
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'];
$fieldnames = $this->adodb->fetchArrayDB($sql);
@ -987,7 +998,7 @@ class TSMMonitor {
$fieldbox.= "</select>";
// Build Operator Combobox
if ($arrop=="") $arrop="=";
if ($arrop == "") $arrop="=";
$opbox = "<select name='wcop' size=1 onChange='' class='button topnavbutton'>";
foreach ($operators as $op) {
$opbox.= '<option value="'.$op.'"';

View File

@ -153,11 +153,14 @@ include_once "includes/page_head.php";
} else {
$whereclause = array();
$whereclause["field"] = $_POST["wcfield"];
$whereclause["field"] = $_POST["wcfield"];
$whereclause["val"] = $_POST["wcval"];
$whereclause["op"] = $_POST["wcop"];
//}
if ($whereclause["field"]!="" && $whereclause["val"]!="") {
if ($whereclause["op"] == 'LIKE') {
$whereclause["val"] = ereg_replace("\*","%",$whereclause["val"]);
$_POST["wcval"] = $whereclause["val"];
}
if ($whereclause["field"] != "" && $whereclause["val"] != "") {
if ($_POST["Clear"] == "Clear") {
$_SESSION["search"][$tsmmonitor->GETVars['qq']] = "";
} else {