From b428bddf545b930005148f01081344840fadf37a Mon Sep 17 00:00:00 2001 From: Frank Fegert Date: Fri, 5 Jun 2009 14:54:36 +0000 Subject: [PATCH] - Fixed numeric sort order for varchar() columns with numeric content. - Fixed sort order for "# Nodes" by urlencode()'ing the "sort=" parameter. This is only a quick fix, all URL parameters should be urlencode()'ed. --- includes/tsmmonitor.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/tsmmonitor.php b/includes/tsmmonitor.php index 1be388d..9aa9ae2 100644 --- a/includes/tsmmonitor.php +++ b/includes/tsmmonitor.php @@ -233,7 +233,7 @@ class TSMMonitor { $so = $_GET['so']; $sortcol = $_GET['sort']; - $getvars = 'q='.$_GET['q'].'&m='.$_GET['m'].'&s='.$this->GETVars['server'].'&sort='.$sortcol."&so=".$so; + $getvars = 'q='.$_GET['q'].'&m='.$_GET['m'].'&s='.$this->GETVars['server'].'&sort='.(urlencode($sortcol))."&so=".$so; $self = htmlspecialchars($_SERVER['PHP_SELF']); $navelement = 'GETVars['ob'] == $name && $this->GETVars['ob']!="") || ($this->GETVars['ob']=="" && $orderby!="" && $orderby == $name)) { - $link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".$name."&page=".$this->page."&so=".$sonew."&s=".$this->GETVars['server']."'"; + if (($this->GETVars['ob'] == $name && $this->GETVars['ob'] != "") || ($this->GETVars['ob'] == "" && $orderby != "" && $orderby == $name)) { + $link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".(urlencode($name))."&page=".$this->page."&so=".$sonew."&s=".$this->GETVars['server']."'"; if ($orderdir == "asc") { $arrow = "↑"; } else if ($orderdir == "desc") { @@ -551,7 +551,7 @@ class TSMMonitor { } } else { $arrow = ""; - $link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".$name."&page=".$this->page."&s=".$this->GETVars['server']."'"; + $link = "href='".$_SERVER['PHP_SELF']."?q=".$this->GETVars['qq']."&m=".$this->GETVars['menu']."&sort=".(urlencode($name))."&page=".$this->page."&s=".$this->GETVars['server']."'"; } $tableheader = $tableheader."".ucfirst($name)." ".$arrow.""; } @@ -562,7 +562,7 @@ class TSMMonitor { } else if ($orderdir == "desc") { $arrow = "⇓"; } - $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=".(urlencode($name))."&page=".$this->page."&so=".$sonew."'"; $label = $fieldnames[0]['Field']; $tableheader = $tableheader."".$label." ".$arrow.""; } @@ -794,14 +794,17 @@ class TSMMonitor { $server = $this->GETVars['server']; $outp = ''; $outp_cache = ''; - $stop=FALSE; + $stop = FALSE; $tablearray = array(); $bContinue = TRUE; + $num_cols = array('Version', 'OS Level', 'Total GB', 'Pct of total files', 'GB', 'TX/GB', 'ELAPTIME (D HHMMSS)', 'MB', 'MB/s', 'GB sent', 'GB rcvd', 'Capacity (MB)', 'Usage (Pct)', 'Pct util', 'Pct mig', 'Pct reclaim', 'Write Err', 'Read Err', 'GB transfered'); if ($this->GETVars['ob'] != '' ) { - $sqlappend = " order by `".$this->GETVars['ob']."` ".$this->GETVars['orderdir']; + if (in_array($this->GETVars['ob'], $num_cols)) $num_order = " + 0"; + $sqlappend = " order by (`".$this->GETVars['ob']."`".$num_order.") ".$this->GETVars['orderdir']; } elseif ($this->configarray["queryarray"][$this->GETVars['qq']]["orderby"] != '') { - $sqlappend = " order by `".$this->configarray["queryarray"][$this->GETVars['qq']]["orderby"]."` ".$this->GETVars['orderdir']; + if (in_array($this->configarray["queryarray"][$this->GETVars['qq']]["orderby"], $num_cols)) $num_order = " + 0"; + $sqlappend = " order by (`".$this->configarray["queryarray"][$this->GETVars['qq']]["orderby"]."`".$num_order.") ".$this->GETVars['orderdir']; } $qtable = $this->configarray["queryarray"][$this->GETVars['qq']]["name"]; @@ -846,6 +849,7 @@ class TSMMonitor { //execute the constructed query $sql = "SELECT ".$columnnames." from res_".$qtable."_".$server.$timestampquery.$wc.$sqlappend; +echo "TEST 1: $sql
\n"; $_SESSION["lastsql"] = $sql; if ($sqlres) $this->message = $sql;