show settings and show processes support (needs to be fixed for < 7.3, however
authorchriskl <chriskl>
Sat, 13 Dec 2003 09:28:46 +0000 (09:28 +0000)
committerchriskl <chriskl>
Sat, 13 Dec 2003 09:28:46 +0000 (09:28 +0000)
BUGS
TODO
classes/Misc.php
classes/database/Postgres.php
database.php
lang/english.php
lang/recoded/english.php

diff --git a/BUGS b/BUGS
index 2791957624cccfe8c4a6059b08dd142d5f4cad9e..dcb416a56771162f258cb39d451e43a95cf3a5e7 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -17,8 +17,5 @@ fix dumping clustering info
 can't edit SELECT results by oid
 investigate phpPgInfo
 
-Fix
----
-
-* Does dropping a database work at all?
-
+Need to fix:
+* Variables and processes views for < 7.3
diff --git a/TODO b/TODO
index 2f61f76ed577a3ed111e795fc84010f5cecea924..c900ab008d555d814b4dfba16667a45da99950b4 100644 (file)
--- a/TODO
+++ b/TODO
@@ -30,7 +30,7 @@ Permissions
 Databases
 ---------
 
-* Fix failure to drop database even tho seemingly no-one is connected to it
+* -Fix failure to drop database even tho seemingly no-one is connected to it (chriskl, bryan)
 * Add alter database for 7.3+
 * Dump database using pg_dump streaming
 
@@ -43,7 +43,7 @@ Tables
 * -Cluster support
 * Vacuum & analyze (half done)
 * ORDER BY in Select function
-* Unify Select and Browse functions
+* -Unify Select and Browse functions (chriskl)
 
 Views
 -----
@@ -125,7 +125,7 @@ Casts (7.3)
 Settings
 --------
 
-* Postgres 7.3 returns SHOW ALL as a proper result set - makes it easy to do a phpMyAdmin style 'view settings'.
+* -Postgres 7.3 returns SHOW ALL as a proper result set - makes it easy to do a phpMyAdmin style 'view settings'.
 
 Miscellaneous
 -------------
index 683c5bbda6ba467b44f6f87271bae16e5bf0e023..a133926d7ec6ae26e1c4f34e217053a9aecdb09c 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.50 2003/12/10 16:03:30 chriskl Exp $
+        * $Id: Misc.php,v 1.51 2003/12/13 09:28:46 chriskl Exp $
         */
         
        class Misc {
                                // Send XHTML headers, or regular HTML headers
                                if (isset($conf['use_xhtml']) && $conf['use_xhtml']) {
                                        echo "<?xml version=\"1.0\" encoding=\"", htmlspecialchars($lang['appcharset']), "\"?>\n";
-                                       echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd\">\n";\r
+                                       echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd\">\n";
                                        echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
                                } else {
                                        echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
                        echo "<table class=\"navbar\" border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"3\"><tr>\n";
                        // Only show schemas if available
                        if ($data->hasSchemas()) {
-                               echo "<td width=\"20%\"><a href=\"database.php?{$vars}\">{$lang['strschemas']}</a></td>\n";
+                               echo "<td width=\"14%\"><a href=\"database.php?{$vars}\">{$lang['strschemas']}</a></td>\n";
                        }
                        // Only show database privs if available
                        if (isset($data->privlist['database'])) {
-                               echo "<td width=\"20%\"><a href=\"privileges.php?{$vars}&amp;type=database&amp;object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
+                               echo "<td width=\"14%\"><a href=\"privileges.php?{$vars}&amp;type=database&amp;object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
                        }
-                       echo "<td width=\"20%\"><a href=\"database.php?{$vars}&amp;action=sql\">{$lang['strsql']}</a></td>\n";
-                       echo "<td width=\"20%\"><a href=\"database.php?{$vars}&amp;action=find\">{$lang['strfind']}</a></td>\n";
-                       echo "<td width=\"20%\"><a href=\"database.php?{$vars}&amp;action=admin\">{$lang['stradmin']}</a></td>\n";
+                       echo "<td width=\"14%\"><a href=\"database.php?{$vars}&amp;action=sql\">{$lang['strsql']}</a></td>\n";
+                       echo "<td width=\"14%\"><a href=\"database.php?{$vars}&amp;action=find\">{$lang['strfind']}</a></td>\n";
+                       echo "<td width=\"14%\"><a href=\"database.php?{$vars}&amp;action=variables\">{$lang['strvariables']}</a></td>\n";
+                       echo "<td width=\"14%\"><a href=\"database.php?{$vars}&amp;action=processes\">{$lang['strprocesses']}</a></td>\n";
+                       echo "<td width=\"14%\"><a href=\"database.php?{$vars}&amp;action=admin\">{$lang['stradmin']}</a></td>\n";
                        echo "</tr></table>\n";
                }
 
index a947cc3cd6954d01c70853aee1e62a7393446601..62f479a67e7ff86678a9f10168a979bdf41b8e45 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.165 2003/12/10 16:03:30 chriskl Exp $
+ * $Id: Postgres.php,v 1.166 2003/12/13 09:28:46 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -229,6 +229,32 @@ class Postgres extends BaseDB {
                return $this->selectRow($sql);
        }
 
+       /**
+        * Returns all available variable information.
+        * @return A recordset
+        */
+       function &getVariables() {
+               $sql = "SHOW ALL";
+               
+               return $this->selectSet($sql);
+       }
+       
+       /**
+        * Returns all available process information.
+        * @param $database (optional) Find only connections to specified database
+        * @return A recordset
+        */
+       function &getProcesses($database = null) {
+               if ($database === null)
+                       $sql = "SELECT * FROM pg_stat_activity ORDER BY datname, usename, procpid";
+               else {
+                       $this->clean($database);
+                       $sql = "SELECT * FROM pg_stat_activity WHERE datname='{$database}' ORDER BY usename, procpid";
+               }
+               
+               return $this->selectSet($sql);
+       }
+       
        /**
         * Returns the current database encoding
         * @return The encoding.  eg. SQL_ASCII, UTF-8, etc.
index 9b3efac153615ed0829ad814bd77882b6fa5fefa..fd8f60749f874988882c7bd5a4693f240317ec1f 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.26 2003/12/10 16:03:29 chriskl Exp $
+        * $Id: database.php,v 1.27 2003/12/13 09:28:46 chriskl Exp $
         */
 
        // Include application functions
                }               
        }
        
+       /**
+        * Show the current status of all database variables
+        */
+       function doVariables() {
+               global $PHP_SELF, $data, $misc;
+               global $lang;
+
+               // Fetch the variables from the database
+               $variables = &$data->getVariables();
+               
+               $misc->printDatabaseNav();
+               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strvariables']}</h2>\n";
+
+               if ($variables->recordCount() > 0) {
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strsetting']}</th></tr>\n";
+                       $i = 0;
+                       while (!$variables->EOF) {
+                               $id = (($i % 2) == 0 ? '1' : '2');
+                               echo "<tr>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($variables->f['name']), "</td>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($variables->f['setting']), "</td>";
+                               echo "</tr>\n";
+                               $variables->moveNext();
+                               $i++;
+                       }
+                       echo "</table>\n";
+               }
+               else {
+                       echo "<p>{$lang['strnodata']}</p>\n";
+               }
+       }
+
+       /**
+        * Show all current database connections and any queries they
+        * are running.
+        */
+       function doProcesses() {
+               global $PHP_SELF, $data, $misc;
+               global $lang;
+
+               // Fetch the processes from the database
+               $processes = &$data->getProcesses($_REQUEST['database']);
+               
+               $misc->printDatabaseNav();
+               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strprocesses']}</h2>\n";
+
+               if ($processes->recordCount() > 0) {
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strprocess']}</th>";
+                       echo "<th class=\"data\">{$lang['strsql']}</th></tr>\n";
+                       $i = 0;
+                       while (!$processes->EOF) {
+                               $id = (($i % 2) == 0 ? '1' : '2');
+                               echo "<tr>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($processes->f['usename']), "</td>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($processes->f['procpid'], false, 'int4'), "</td>";
+                               echo "<td class=\"data{$id}\">", $misc->printVal($processes->f['current_query']), "</td>";
+                               echo "</tr>\n";
+                               $processes->moveNext();
+                               $i++;
+                       }
+                       echo "</table>\n";
+               }
+               else {
+                       echo "<p>{$lang['strnodata']}</p>\n";
+               }
+       }
+
        /**
         * Allow database administration and tuning tasks
         */
                case 'confirm_drop':
                        doDrop(true);
                        break;
+               case 'variables':
+                       doVariables();
+                       break;
+               case 'processes':
+                       doProcesses();
+                       break;
                default:
                        doDefault();
                        break;
index da3e2063c6de30f82a29b26e26d48118a0c5c6c7..40f70899144fc1b8a8b60b9498d09aa032397fe3 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.120 2003/10/28 04:02:15 chriskl Exp $
+        * $Id: english.php,v 1.121 2003/12/13 09:28:46 chriskl Exp $
         */
 
        // Language and character set
        $lang['strinfo'] = 'Info';
        $lang['stroids'] = 'OIDs';
        $lang['stradvanced'] = 'Advanced';
+       $lang['strvariables'] = 'Variables';
+       $lang['strprocess'] = 'Process';
+       $lang['strprocesses'] = 'Processes';
+       $lang['strsetting'] = 'Setting';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
index 444425bde77ea88410de248309c8483b4a88a11a..8afc1b27436617eab9527b043c8a98000c811c4f 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.72 2003/10/28 04:02:16 chriskl Exp $
+        * $Id: english.php,v 1.73 2003/12/13 09:28:46 chriskl Exp $
         */
 
        // Language and character set
        $lang['strinfo'] = 'Info';
        $lang['stroids'] = 'OIDs';
        $lang['stradvanced'] = 'Advanced';
+       $lang['strvariables'] = 'Variables';
+       $lang['strprocess'] = 'Process';
+       $lang['strprocesses'] = 'Processes';
+       $lang['strsetting'] = 'Setting';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';