diff -Naur phpPgAdmin-3.3.1-original/INSTALL phpPgAdmin-3.3.1-new/INSTALL
--- phpPgAdmin-3.3.1-original/INSTALL	2004-01-29 08:30:11.000000000 +0100
+++ phpPgAdmin-3.3.1-new/INSTALL	2004-05-27 18:01:05.000000000 +0200
@@ -63,3 +63,43 @@
    can then disable 'extra_login_security' so that you can log in as your
    database administrator using the administrator password.
 
+8. Security enhanced PostgreSQL installation
+
+   The most common installations of PostgreSQL comes with superuser named
+   "postgres" which should be able to locally connect without password.
+   This does not have to be like this. It is wise to make default user
+   "postgres" as regular user and use some other user as superuser.
+
+   Regular users are by default able to see existing databases on the
+   server. This is security as well as esthetic issue.
+
+   Regular user by default can see every database on the server by making
+   SELECT on the table pg_database like this:
+        SELECT * FROM pg_database;
+
+   Also, one could see every user on the system by making SELECT on the table
+   pg_user like this:
+        SELECT * FROM pg_user;
+
+   By using VIEW on table pg_database you can limit results from pg_database
+   so that user can see only databases that he own.
+   That view would be created like this:
+        CREATE VIEW pg_db AS SELECT oid, * FROM pg_database
+                    WHERE datname=(SELECT current_user);
+   After successful creation of our view (pg_db in this example), we have to
+   give users rights to access that view:
+        GRANT SELECT ON pg_db TO public;
+   Note that similar steps should be done for table pg_group.
+
+   We also have to remove rights to access to table pg_database:
+        REVOKE SELECT ON pg_database FROM public;
+
+   All this does not have much sense if you leave pg_user accessible.
+   You have to modify pg_user from this:
+        SELECT usename, usesysid, usecreatedb, usesuper, usecatupd,
+                '********'::text AS passwd, valuntil, useconfig
+                FROM pg_shadow WHERE usename=(select current_user);
+   to this:
+        SELECT usename, usesysid, usecreatedb, usesuper, usecatupd,
+                '********'::text AS passwd, valuntil, useconfig
+                FROM pg_shadow;
diff -Naur phpPgAdmin-3.3.1-original/classes/database/Postgres.php phpPgAdmin-3.3.1-new/classes/database/Postgres.php
--- phpPgAdmin-3.3.1-original/classes/database/Postgres.php	2004-03-07 07:39:05.000000000 +0100
+++ phpPgAdmin-3.3.1-new/classes/database/Postgres.php	2004-05-27 10:55:02.000000000 +0200
@@ -203,17 +203,30 @@
 		else $clause = '';
 
 		if (!$conf['show_system'])
-			$where = "AND pdb.datname NOT IN ('template1')";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "AND pdb.datname NOT IN ('template1')";
 		else
 			$where = '';
 
-		$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding, 
-					(SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS description 
-					FROM pg_database pdb, pg_user pu
-					WHERE pdb.datdba = pu.usesysid
-					{$where}
-					{$clause}
-					ORDER BY pdb.datname";
+
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding, 
+						(SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS description 
+						FROM pg_database pdb, pg_shadow pu
+						WHERE pdb.datdba = pu.usesysid
+						{$where}
+						{$clause}
+						ORDER BY pdb.datname";
+		else
+			$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding, 
+						(SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS description 
+						FROM {$conf['servers'][$_SESSION['webdbServerID']]['pg_database_view']} pdb, pg_user pu
+						WHERE pdb.datdba = pu.usesysid
+						{$where}
+						{$clause}
+						ORDER BY pdb.datname";
 
 		return $this->selectSet($sql);
 	}
@@ -225,7 +238,10 @@
 	 */
 	function &getDatabase($database) {
 		$this->clean($database);
-		$sql = "SELECT * FROM pg_database WHERE datname='{$database}'";
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			$sql = "SELECT * FROM {$conf['servers'][$_SESSION['webdbServerID']]['pg_database_view']} WHERE datname='{$database}'";
+		else
+			$sql = "SELECT * FROM pg_database WHERE datname='{$database}'";
 		return $this->selectSet($sql);
 	}
 
@@ -965,8 +981,14 @@
 	 */
 	function &getTables($all = false) {
 		global $conf;
-		if (!$conf['show_system'] || $all) $where = "WHERE tablename NOT LIKE 'pg\\\\_%' ";
-		else $where = '';
+		if (!$conf['show_system'] || $all)
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "WHERE tablename NOT LIKE 'pg\\\\_%' ";
+		else
+			$where = '';
+
 		$sql = "SELECT NULL AS schemaname, tablename, tableowner FROM pg_tables {$where}ORDER BY tablename";
 		return $this->selectSet($sql);
 	}
@@ -1429,7 +1451,10 @@
 	 * @return A recordset
 	 */
 	function &getSequences() {
-		$sql = "SELECT c.relname, u.usename FROM pg_class c, pg_user u WHERE c.relowner=u.usesysid AND c.relkind = 'S' ORDER BY relname";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT c.relname, u.usename FROM pg_class c, pg_shadow u WHERE c.relowner=u.usesysid AND c.relkind = 'S' ORDER BY relname";
+		else
+			$sql = "SELECT c.relname, u.usename FROM pg_class c, pg_user u WHERE c.relowner=u.usesysid AND c.relkind = 'S' ORDER BY relname";
 		
 		return $this->selectSet( $sql );
 	}
@@ -1995,8 +2020,12 @@
 	function &getViews() {
 		global $conf;
 		if (!$conf['show_system'])
-			$where = "WHERE viewname NOT LIKE 'pg\\\\_%'";
-		else $where  = '';
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where  = '';
+			else
+				$where = "WHERE viewname NOT LIKE 'pg\\\\_%'";
+		else
+			$where  = '';
 		
 		$sql = "SELECT viewname, viewowner FROM pg_views {$where} ORDER BY viewname";
 
@@ -2102,7 +2131,9 @@
 			SELECT CASE WHEN relkind='r' THEN 'TABLE'::VARCHAR WHEN relkind='v' THEN 'VIEW'::VARCHAR WHEN relkind='S' THEN 'SEQUENCE'::VARCHAR END AS type, 
 				pc.oid, NULL::VARCHAR AS schemaname, NULL::VARCHAR AS relname, pc.relname AS name FROM pg_class pc
 				WHERE relkind IN ('r', 'v', 'S') AND relname ~* '.*{$term}.*'";
-		if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";
 
 		// Columns
 		$sql .= "				
@@ -2110,14 +2141,18 @@
 			SELECT 'COLUMN', NULL, NULL, pc.relname, pa.attname FROM pg_class pc,
 				pg_attribute pa WHERE pc.oid=pa.attrelid 
 				AND pa.attname ~* '.*{$term}.*' AND pa.attnum > 0 AND pc.relkind IN ('r', 'v')";
-		if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";
 
 		// Functions
 		$sql .= "
 			UNION ALL
 			SELECT 'FUNCTION', pp.oid, NULL, NULL, pp.proname FROM pg_proc pp
 				WHERE proname ~* '.*{$term}.*'";
-		if (!$conf['show_system']) $sql .= " AND pp.oid > '{$this->_lastSystemOID}'::oid";
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pp.oid > '{$this->_lastSystemOID}'::oid";
 			
 		// Indexes
 		$sql .= "
@@ -2126,7 +2161,9 @@
 				pg_index pi, pg_class pc2 WHERE pc.oid=pi.indrelid 
 				AND pi.indexrelid=pc2.oid
 				AND pc2.relname ~* '.*{$term}.*' AND NOT pi.indisprimary AND NOT pi.indisunique";
-		if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";
 
 		// Check Constraints
 		$sql .= "
@@ -2134,7 +2171,10 @@
 			SELECT 'CONSTRAINT', NULL, NULL, pc.relname, pr.rcname FROM pg_class pc,
 				pg_relcheck pr WHERE pc.oid=pr.rcrelid
 				AND pr.rcname ~* '.*{$term}.*'";
-		if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";
+
 		// Unique and Primary Key Constraints
 		$sql .= "
 			UNION ALL
@@ -2142,7 +2182,9 @@
 				pg_index pi, pg_class pc2 WHERE pc.oid=pi.indrelid 
 				AND pi.indexrelid=pc2.oid
 				AND pc2.relname ~* '.*{$term}.*' AND (pi.indisprimary OR pi.indisunique)";
-		if (!$conf['show_system']) $sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc2.relname NOT LIKE 'pg\\\\_%'";
 
 		// Triggers
 		$sql .= "
@@ -2150,14 +2192,18 @@
 			SELECT 'TRIGGER', NULL, NULL, pc.relname, pt.tgname FROM pg_class pc,
 				pg_trigger pt WHERE pc.oid=pt.tgrelid
 				AND pt.tgname ~* '.*{$term}.*'";
-		if (!$conf['show_system']) $sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND pc.relname NOT LIKE 'pg\\\\_%'";
 
 		// Rules
 		$sql .= "
 			UNION ALL
 			SELECT 'RULE', NULL, NULL, tablename, rulename FROM pg_rules
 				WHERE rulename ~* '.*{$term}.*'";
-		if (!$conf['show_system']) $sql .= " AND tablename NOT LIKE 'pg\\\\_%'";				
+		if (!$conf['show_system'])
+			if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+				$sql .= " AND tablename NOT LIKE 'pg\\\\_%'";
 
 		// Advanced Objects
 		if ($conf['show_advanced']) {
@@ -2166,39 +2212,49 @@
 				UNION ALL
 				SELECT 'TYPE', pt.oid, NULL, NULL, pt.typname FROM pg_type pt
 					WHERE typname ~* '.*{$term}.*' AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_class c WHERE c.oid = pt.typrelid))";
-			if (!$conf['show_system']) $sql .= " AND pt.oid > '{$this->_lastSystemOID}'::oid";
+			if (!$conf['show_system'])
+				if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+					$sql .= " AND pt.oid > '{$this->_lastSystemOID}'::oid";
 
 			// Operators
 			$sql .= "				
 				UNION ALL
 				SELECT 'OPERATOR', po.oid, NULL, NULL, po.oprname FROM pg_operator po
 					WHERE oprname ~* '.*{$term}.*'";
-			if (!$conf['show_system']) $sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
+			if (!$conf['show_system'])
+				if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+					$sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
 
 			// Languages
 			$sql .= "				
 				UNION ALL
 				SELECT 'LANGUAGE', pl.oid, NULL, NULL, pl.lanname FROM pg_language pl
 					WHERE lanname ~* '.*{$term}.*'";
-			if (!$conf['show_system']) $sql .= " AND pl.lanispl";
+			if (!$conf['show_system'])
+				if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+					$sql .= " AND pl.lanispl";
 
 			// Aggregates
 			$sql .= "				
 				UNION ALL
 				SELECT DISTINCT ON (a.aggname) 'AGGREGATE', a.oid, NULL, NULL, a.aggname FROM pg_aggregate a 
 					WHERE aggname ~* '.*{$term}.*'";
-			if (!$conf['show_system']) $sql .= " AND a.oid > '{$this->_lastSystemOID}'::oid";
+			if (!$conf['show_system'])
+				if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+					$sql .= " AND a.oid > '{$this->_lastSystemOID}'::oid";
 
 			// Op Classes
 			$sql .= "				
 				UNION ALL
 				SELECT DISTINCT ON (po.opcname) 'OPCLASS', po.oid, NULL, NULL, po.opcname FROM pg_opclass po
 					WHERE po.opcname ILIKE '%{$term}%'";
-			if (!$conf['show_system']) $sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
+			if (!$conf['show_system'])
+				if (!$this->isSuperUser($_SESSION['webdbUsername']) && !$conf['show_system_admin'])
+					$sql .= " AND po.oid > '{$this->_lastSystemOID}'::oid";
 		}
-				
+		
 		$sql .= " ORDER BY type, schemaname, relname, name";
-			
+		
 		return $this->selectSet($sql);
 	}
 
@@ -2211,8 +2267,12 @@
 	function &getOperators() {
 		global $conf;
 		if (!$conf['show_system'])
-			$where = "WHERE po.oid > '{$this->_lastSystemOID}'::oid";
-		else $where  = '';
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where  = '';
+			else
+				$where = "WHERE po.oid > '{$this->_lastSystemOID}'::oid";
+		else
+			$where  = '';
 		
 		$sql = "
 			SELECT
@@ -2311,8 +2371,12 @@
 	 */
 	function &getUsers() {
 		$sql = "SELECT usename, usesuper, usecreatedb, valuntil";
-		if ($this->hasUserSessionDefaults()) $sql .= ", useconfig";
-		$sql .= " FROM pg_user ORDER BY usename";
+		if ($this->hasUserSessionDefaults())
+			 $sql .= ", useconfig";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql .= " FROM pg_shadow ORDER BY usename";
+		else
+			$sql .= " FROM pg_user ORDER BY usename";
 		
 		return $this->selectSet($sql);
 	}
@@ -2326,8 +2390,12 @@
 		$this->clean($username);
 		
 		$sql = "SELECT usename, usesuper, usecreatedb, valuntil";
-		if ($this->hasUserSessionDefaults()) $sql .= ", useconfig";
-		$sql .= " FROM pg_user WHERE usename='{$username}'";
+		if ($this->hasUserSessionDefaults())
+			 $sql .= ", useconfig";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql .= " FROM pg_shadow WHERE usename='{$username}'";
+		else
+			$sql .= " FROM pg_user WHERE usename='{$username}'";
 		
 		return $this->selectSet($sql);
 	}
@@ -2418,8 +2486,16 @@
 	 * @return All groups
 	 */
 	function &getGroups() {
-		$sql = "SELECT groname FROM pg_group ORDER BY groname";
-		
+		global $conf;
+
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT groname FROM pg_group ORDER BY groname";
+			else
+				$sql = "SELECT groname FROM {$conf['servers'][$_SESSION['webdbServerID']]['pg_grp_view']} ORDER BY groname";
+		else
+			$sql = "SELECT groname FROM pg_group ORDER BY groname";
+
 		return $this->selectSet($sql);
 	}
 
@@ -2429,9 +2505,16 @@
 	 * @return All users in the group
 	 */
 	function &getGroup($groname) {
+		global $conf;
 		$this->clean($groname);
 
-		$sql = "SELECT grolist FROM pg_group WHERE groname = '{$groname}'";
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT grolist FROM pg_group WHERE groname = '{$groname}'";
+			else
+				$sql = "SELECT grolist FROM {$conf['servers'][$_SESSION['webdbServerID']]['pg_grp_view']} WHERE groname = '{$groname}'";
+		else
+			$sql = "SELECT grolist FROM pg_group WHERE groname = '{$groname}'";
       
 		$grodata = $this->selectSet($sql);
 		if ($grodata->f['grolist'] !== null && $grodata->f['grolist'] != '{}') {
@@ -2439,9 +2522,16 @@
 			$members = ereg_replace("\{|\}","",$members);
 			$this->clean($members);
 
-			$sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT usename FROM pg_shadow WHERE usesysid IN ({$members}) ORDER BY usename";
+			else
+				$sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
 		}
-		else $sql = "SELECT usename FROM pg_user WHERE false";
+		else
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT usename FROM pg_shadow WHERE false";
+			else
+				$sql = "SELECT usename FROM pg_user WHERE false";
 
 		return $this->selectSet($sql);
 	}
@@ -2518,11 +2608,14 @@
 	function &getTypes($all = false, $tabletypes = false) {
 		global $conf;
 		
-		if ($all || $conf['show_system']) {
+		if ($all || $conf['show_system'])
 			$where = '';
-		} else {
-			$where = "AND pt.oid > '{$this->_lastSystemOID}'::oid";
-		}
+		else
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "AND pt.oid > '{$this->_lastSystemOID}'::oid";
+
 		// Never show system table types
 		$where2 = "AND c.oid > '{$this->_lastSystemOID}'::oid";
 
@@ -2531,20 +2624,36 @@
 		else
 			$tqry = "'c'";
 
-		$sql = "SELECT
-				pt.typname AS basename,
-				pt.typname,
-				pu.usename AS typowner
-			FROM
-				pg_type pt,
-				pg_user pu
-			WHERE
-				pt.typowner = pu.usesysid
-				AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
-				AND typname !~ '^_'
-				{$where}
-			ORDER BY typname
-		";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT
+					pt.typname AS basename,
+					pt.typname,
+					pu.usename AS typowner
+				FROM
+					pg_type pt,
+					pg_shadow pu
+				WHERE
+					pt.typowner = pu.usesysid
+					AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
+					AND typname !~ '^_'
+					{$where}
+				ORDER BY typname
+			";
+		else
+			$sql = "SELECT
+					pt.typname AS basename,
+					pt.typname,
+					pu.usename AS typowner
+				FROM
+					pg_type pt,
+					pg_user pu
+				WHERE
+					pt.typowner = pu.usesysid
+					AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
+					AND typname !~ '^_'
+					{$where}
+				ORDER BY typname
+			";
 
 		return $this->selectSet($sql);
 	}
@@ -3155,36 +3264,70 @@
 		if ($all || $conf['show_system'])
 			$where = '';
 		else
-			$where = "AND pc.oid > '{$this->_lastSystemOID}'::oid";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "AND pc.oid > '{$this->_lastSystemOID}'::oid";
+
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = 	"SELECT
+					pc.oid,
+					proname,
+					proretset,
+					pt.typname AS return_type,
+					oidvectortypes(pc.proargtypes) AS arguments
+				FROM
+					pg_proc pc, pg_shadow pu, pg_type pt
+				WHERE
+					pc.proowner = pu.usesysid
+					AND pc.prorettype = pt.oid
+					{$where}
+				UNION
+				SELECT 
+					pc.oid,
+					proname,
+					proretset,
+					'OPAQUE' AS result,
+					oidvectortypes(pc.proargtypes) AS arguments
+				FROM
+					pg_proc pc, pg_shadow pu, pg_type pt
+				WHERE	
+					pc.proowner = pu.usesysid
+					AND pc.prorettype = 0
+					{$where}
+				ORDER BY
+					proname, return_type
+				";
+		else
+			$sql = 	"SELECT
+					pc.oid,
+					proname,
+					proretset,
+					pt.typname AS return_type,
+					oidvectortypes(pc.proargtypes) AS arguments
+				FROM
+					pg_proc pc, pg_user pu, pg_type pt
+				WHERE
+					pc.proowner = pu.usesysid
+					AND pc.prorettype = pt.oid
+					{$where}
+				UNION
+				SELECT 
+					pc.oid,
+					proname,
+					proretset,
+					'OPAQUE' AS result,
+					oidvectortypes(pc.proargtypes) AS arguments
+				FROM
+					pg_proc pc, pg_user pu, pg_type pt
+				WHERE	
+					pc.proowner = pu.usesysid
+					AND pc.prorettype = 0
+					{$where}
+				ORDER BY
+					proname, return_type
+				";
 
-		$sql = 	"SELECT
-				pc.oid,
-				proname,
-				proretset,
-				pt.typname AS return_type,
-				oidvectortypes(pc.proargtypes) AS arguments
-			FROM
-				pg_proc pc, pg_user pu, pg_type pt
-			WHERE
-				pc.proowner = pu.usesysid
-				AND pc.prorettype = pt.oid
-				{$where}
-			UNION
-			SELECT 
-				pc.oid,
-				proname,
-				proretset,
-				'OPAQUE' AS result,
-				oidvectortypes(pc.proargtypes) AS arguments
-			FROM
-				pg_proc pc, pg_user pu, pg_type pt
-			WHERE	
-				pc.proowner = pu.usesysid
-				AND pc.prorettype = 0
-				{$where}
-			ORDER BY
-				proname, return_type
-			";
 
 		return $this->selectSet($sql);
 	}
@@ -3385,7 +3528,10 @@
 		if ($conf['show_system'] || $all)
 			$where = '';
 		else
-			$where = 'WHERE lanispl';
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = 'WHERE lanispl';
 
 		$sql = "
 			SELECT
@@ -3414,7 +3560,10 @@
 		if ($conf['show_system'])
 			$where = '';
 		else
-			$where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
 
 		$sql = "
 			SELECT
@@ -3445,7 +3594,10 @@
 		if ($conf['show_system'])
 			$where = '';
 		else
-			$where = "AND po.oid > '{$this->_lastSystemOID}'::oid";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "AND po.oid > '{$this->_lastSystemOID}'::oid";
 
 		$sql = "
 			SELECT DISTINCT
diff -Naur phpPgAdmin-3.3.1-original/classes/database/Postgres71.php phpPgAdmin-3.3.1-new/classes/database/Postgres71.php
--- phpPgAdmin-3.3.1-original/classes/database/Postgres71.php	2004-01-18 11:39:45.000000000 +0100
+++ phpPgAdmin-3.3.1-new/classes/database/Postgres71.php	2004-05-27 10:55:02.000000000 +0200
@@ -85,19 +85,40 @@
 			$clause = " AND pu.usename='{$username}'";
 		}
 		else $clause = '';
-		
+
 		if (!$conf['show_system'])
-			$where = 'AND NOT pdb.datistemplate';
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = 'AND pdb.datallowconn';
+			else
+				$where = 'AND NOT pdb.datistemplate';
 		else
 			$where = 'AND pdb.datallowconn';
 
-		$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding, pde.description FROM
-					pg_database pdb LEFT JOIN pg_description pde ON pdb.oid=pde.objoid,
-					pg_user pu
-					WHERE pdb.datdba = pu.usesysid
-					{$where}
-					{$clause}
-					ORDER BY pdb.datname";
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding,
+							(SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS description 
+							FROM pg_database pdb, pg_shadow pu
+							WHERE pdb.datdba = pu.usesysid
+							{$where}
+							{$clause}
+							ORDER BY pdb.datname";
+			else
+				$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding,
+							(SELECT description FROM pg_description pd WHERE pdb.oid=pd.objoid) AS description 
+							FROM {$conf['servers'][$_SESSION['webdbServerID']]['pg_database_view']} pdb, pg_user pu
+							WHERE pdb.datdba = pu.usesysid
+							{$where}
+							{$clause}
+							ORDER BY pdb.datname";
+		else
+			$sql = "SELECT pdb.datname, pu.usename AS owner, pg_encoding_to_char(encoding) AS encoding, pde.description FROM
+						pg_database pdb LEFT JOIN pg_description pde ON pdb.oid=pde.objoid,
+						pg_user pu
+						WHERE pdb.datdba = pu.usesysid
+						{$where}
+						{$clause}
+						ORDER BY pdb.datname";
 
 		return $this->selectSet($sql);
 	}
@@ -344,7 +365,10 @@
 		if ($conf['show_system'])
 			$where = '';
 		else
-			$where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "WHERE a.oid > '{$this->_lastSystemOID}'::oid";
 
 		$sql = "
 			SELECT
diff -Naur phpPgAdmin-3.3.1-original/classes/database/Postgres72.php phpPgAdmin-3.3.1-new/classes/database/Postgres72.php
--- phpPgAdmin-3.3.1-original/classes/database/Postgres72.php	2004-03-07 07:39:05.000000000 +0100
+++ phpPgAdmin-3.3.1-new/classes/database/Postgres72.php	2004-05-27 15:57:45.000000000 +0200
@@ -44,7 +44,7 @@
 	 * @return A recordset
 	 */
 	function &getProcesses($database = null) {
-		if ($database === null)
+		if ($database == null)
 			$sql = "SELECT * FROM pg_stat_activity ORDER BY datname, usename, procpid";
 		else {
 			$this->clean($database);
@@ -264,11 +264,14 @@
 	function &getTypes($all = false, $tabletypes = false) {
 		global $conf;
 		
-		if ($all || $conf['show_system']) {
+		if ($all || $conf['show_system'])
 			$where = '';
-		} else {
-			$where = "AND pt.oid > '{$this->_lastSystemOID}'::oid";
-		}
+		else
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = "AND pt.oid > '{$this->_lastSystemOID}'::oid";
+
 		// Never show system table types
 		$where2 = "AND c.oid > '{$this->_lastSystemOID}'::oid";
 		
@@ -277,20 +280,36 @@
 		else
 			$tqry = "'c'";
 		
-		$sql = "SELECT
-				pt.typname AS basename,
-				format_type(pt.oid, NULL) AS typname,
-				pu.usename AS typowner
-			FROM
-				pg_type pt,
-				pg_user pu
-			WHERE
-				pt.typowner = pu.usesysid
-				AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
-				AND typname !~ '^_'
-				{$where}
-			ORDER BY typname
-		";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT
+					pt.typname AS basename,
+					format_type(pt.oid, NULL) AS typname,
+					pu.usename AS typowner
+				FROM
+					pg_type pt,
+					pg_shadow pu
+				WHERE
+					pt.typowner = pu.usesysid
+					AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
+					AND typname !~ '^_'
+					{$where}
+				ORDER BY typname
+			";
+		else
+			$sql = "SELECT
+					pt.typname AS basename,
+					format_type(pt.oid, NULL) AS typname,
+					pu.usename AS typowner
+				FROM
+					pg_type pt,
+					pg_user pu
+				WHERE
+					pt.typowner = pu.usesysid
+					AND (pt.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_class c WHERE c.oid = pt.typrelid {$where2}))
+					AND typname !~ '^_'
+					{$where}
+				ORDER BY typname
+			";
 
 		return $this->selectSet($sql);
 	}
diff -Naur phpPgAdmin-3.3.1-original/classes/database/Postgres73.php phpPgAdmin-3.3.1-new/classes/database/Postgres73.php
--- phpPgAdmin-3.3.1-original/classes/database/Postgres73.php	2004-02-14 05:21:03.000000000 +0100
+++ phpPgAdmin-3.3.1-new/classes/database/Postgres73.php	2004-05-27 15:57:51.000000000 +0200
@@ -97,12 +97,65 @@
 	 */
 	function &getSchemas() {
 		global $conf;
-
-		if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg\\\\_%'";
-		else $and = '';
-		$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
-			WHERE pn.nspowner = pu.usesysid
-			{$and}ORDER BY nspname";
+/*
+		if (!$conf['show_system'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				if ($conf['show_system_admin'])
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						AND nspname NOT LIKE 'pg\\\\_%'
+						ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					AND nspname NOT LIKE 'pg\\\\_%'
+					ORDER BY nspname";
+		else
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+					WHERE pn.nspowner = pu.usesysid
+					ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					ORDER BY nspname";
+*/
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if (!$conf['show_system'])
+				if ($this->isSuperUser($_SESSION['webdbUsername']))
+					if ($conf['show_system_admin'])
+						$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+							WHERE pn.nspowner = pu.usesysid
+							ORDER BY nspname";
+					else
+						$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+							WHERE pn.nspowner = pu.usesysid
+							AND nspname NOT LIKE 'pg\\\\_%'
+							ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+						WHERE nspname NOT LIKE 'pg\\\\_%'
+						ORDER BY nspname";
+			else
+				if ($this->isSuperUser($_SESSION['webdbUsername']))
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+						ORDER BY nspname";
+		else
+			if (!$conf['show_system'])
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					WHERE pn.nspowner = pu.usesysid
+					AND nspname NOT LIKE 'pg\\\\_%'
+					ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					WHERE pn.nspowner = pu.usesysid
+					ORDER BY nspname";
 
 		return $this->selectSet($sql);
 	}
@@ -166,7 +219,7 @@
 	 * @return A recordset
 	 */
 	function &getProcesses($database = null) {
-		if ($database === null)
+		if ($database == null)
 			$sql = "SELECT * FROM pg_catalog.pg_stat_activity ORDER BY datname, usename, procpid";
 		else {
 			$this->clean($database);
@@ -288,17 +341,30 @@
 	function &getTable($table) {
 		$this->clean($table);
 		
-		$sql = "		
-			SELECT
-			  c.relname AS tablename,
-			  u.usename AS tableowner,
-			  pg_catalog.obj_description(c.oid, 'pg_class') AS tablecomment
-			FROM pg_catalog.pg_class c
-			     LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
-			     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
-			WHERE c.relkind = 'r'
-			      AND n.nspname = '{$this->_schema}'
-			      AND c.relname = '{$table}'";		
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "		
+				SELECT
+				  c.relname AS tablename,
+				  u.usename AS tableowner,
+				  pg_catalog.obj_description(c.oid, 'pg_class') AS tablecomment
+				FROM pg_catalog.pg_class c
+				     LEFT JOIN pg_catalog.pg_shadow u ON u.usesysid = c.relowner
+				     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
+				WHERE c.relkind = 'r'
+				      AND n.nspname = '{$this->_schema}'
+				      AND c.relname = '{$table}'";
+		else
+			$sql = "		
+				SELECT
+				  c.relname AS tablename,
+				  u.usename AS tableowner,
+				  pg_catalog.obj_description(c.oid, 'pg_class') AS tablecomment
+				FROM pg_catalog.pg_class c
+				     LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
+				     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
+				WHERE c.relkind = 'r'
+				      AND n.nspname = '{$this->_schema}'
+				      AND c.relname = '{$table}'";
 			
 		return $this->selectSet($sql);
 	}
@@ -505,9 +571,14 @@
 	 * @return A recordset
 	 */
 	function &getSequences() {
-		$sql = "SELECT c.relname, u.usename FROM pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n
-			WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid
-			AND c.relkind = 'S' AND n.nspname='{$this->_schema}' ORDER BY relname";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT c.relname, u.usename FROM pg_catalog.pg_class c, pg_catalog.pg_shadow u, pg_catalog.pg_namespace n
+				WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid
+				AND c.relkind = 'S' AND n.nspname='{$this->_schema}' ORDER BY relname";
+		else
+			$sql = "SELECT c.relname, u.usename FROM pg_catalog.pg_class c, pg_catalog.pg_user u, pg_catalog.pg_namespace n
+				WHERE c.relowner=u.usesysid AND c.relnamespace=n.oid
+				AND c.relkind = 'S' AND n.nspname='{$this->_schema}' ORDER BY relname";
 			
 		return $this->selectSet( $sql );
 	}
@@ -814,19 +885,34 @@
 		else
 			$tqry = "'c'";
 			
-		$sql = "SELECT
-				t.typname AS basename,
-				pg_catalog.format_type(t.oid, NULL) AS typname,
-				pu.usename AS typowner
-			FROM (pg_catalog.pg_type t
-				LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace)
-				LEFT JOIN pg_catalog.pg_user pu ON t.typowner = pu.usesysid
-			WHERE (t.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid {$where2}))	 
-			AND t.typname !~ '^_'
-			AND {$where}
-			AND t.typtype != 'd'
-			ORDER BY typname
-		";
+		if ($this->isSuperUser($_SESSION['webdbUsername']))
+			$sql = "SELECT
+					t.typname AS basename,
+					pg_catalog.format_type(t.oid, NULL) AS typname,
+					pu.usename AS typowner
+				FROM (pg_catalog.pg_type t
+					LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace)
+					LEFT JOIN pg_catalog.pg_shadow pu ON t.typowner = pu.usesysid
+				WHERE (t.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid {$where2}))	 
+				AND t.typname !~ '^_'
+				AND {$where}
+				AND t.typtype != 'd'
+				ORDER BY typname
+			";
+		else
+			$sql = "SELECT
+					t.typname AS basename,
+					pg_catalog.format_type(t.oid, NULL) AS typname,
+					pu.usename AS typowner
+				FROM (pg_catalog.pg_type t
+					LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace)
+					LEFT JOIN pg_catalog.pg_user pu ON t.typowner = pu.usesysid
+				WHERE (t.typrelid = 0 OR (SELECT c.relkind IN ({$tqry}) FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid {$where2}))	 
+				AND t.typname !~ '^_'
+				AND {$where}
+				AND t.typtype != 'd'
+				ORDER BY typname
+			";
 
 		return $this->selectSet($sql);
 	}
@@ -1049,6 +1135,7 @@
 	 * @return -3 unknown privilege type
 	 */
 	function getPrivileges($object, $type) {
+		global $conf;
 		$this->clean($object);
 
 		switch ($type) {
@@ -1059,7 +1146,13 @@
 						AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')";
 				break;
 			case 'database':
-				$sql = "SELECT datacl AS acl FROM pg_catalog.pg_database WHERE datname='{$object}'";
+					if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+						if ($this->isSuperUser($_SESSION['webdbUsername']))
+							$sql = "SELECT datacl AS acl FROM pg_catalog.pg_database WHERE datname='{$object}'";
+						else
+							$sql = "SELECT datacl AS acl FROM public.{$conf['servers'][$_SESSION['webdbServerID']]['pg_database_view']} WHERE datname='{$object}'";
+					else
+						$sql = "SELECT datacl AS acl FROM pg_catalog.pg_database WHERE datname='{$object}'";
 				break;
 			case 'function':
 				// Since we fetch functions by oid, they are already constrained to
@@ -1185,18 +1278,27 @@
 		$this->clean($term);
 
 		// Exclude system relations if necessary
-		if (!$conf['show_system']) {
-			// XXX: The mention of information_schema here is in the wrong place, but
-			// it's the quickest fix to exclude the info schema from 7.4
-			$where = " AND pn.nspname NOT LIKE 'pg\\\\_%' AND pn.nspname != 'information_schema'";
-			$lan_where = "AND pl.lanispl";
-			$rule_where = " AND schemaname NOT LIKE 'pg\\\\_%' AND schemaname != 'information_schema'";
-		}
-		else {
+		if (!$conf['show_system'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				{
+				$where = '';
+				$lan_where = '';
+				$rule_where = '';
+				}
+			else
+				{
+				// XXX: The mention of information_schema here is in the wrong place, but
+				// it's the quickest fix to exclude the info schema from 7.4
+				$where = " AND pn.nspname NOT LIKE 'pg\\\\_%' AND pn.nspname != 'information_schema'";
+				$lan_where = "AND pl.lanispl";
+				$rule_where = " AND schemaname NOT LIKE 'pg\\\\_%' AND schemaname != 'information_schema'";
+				}
+		else
+			{
 			$where = '';
 			$lan_where = '';
 			$rule_where = '';
-		}
+			}
 		
 		$sql = "
 			SELECT 'SCHEMA' AS type, oid, NULL AS schemaname, NULL AS relname, nspname AS name 
@@ -1361,11 +1463,14 @@
 		if ($conf['show_system'])
 			$where = '';
 		else
-			$where = "
-				AND n1.nspname NOT LIKE 'pg\\\\_%'
-				AND n2.nspname NOT LIKE 'pg\\\\_%'
-				AND n3.nspname NOT LIKE 'pg\\\\_%'
-			";
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+					$where = '';
+				else
+					$where = "
+						AND n1.nspname NOT LIKE 'pg\\\\_%'
+						AND n2.nspname NOT LIKE 'pg\\\\_%'
+						AND n3.nspname NOT LIKE 'pg\\\\_%'
+					";
 
 		$sql = "
 			SELECT
@@ -1427,7 +1532,10 @@
 		if ($conf['show_system'] || $all)
 			$where = '';
 		else
-			$where = 'WHERE lanispl';
+			if ($this->isSuperUser($_SESSION['webdbUsername']) && $conf['show_system_admin'])
+				$where = '';
+			else
+				$where = 'WHERE lanispl';
 
 		$sql = "
 			SELECT
diff -Naur phpPgAdmin-3.3.1-original/classes/database/Postgres74.php phpPgAdmin-3.3.1-new/classes/database/Postgres74.php
--- phpPgAdmin-3.3.1-original/classes/database/Postgres74.php	2004-02-19 05:20:00.000000000 +0100
+++ phpPgAdmin-3.3.1-new/classes/database/Postgres74.php	2004-05-27 13:28:32.000000000 +0200
@@ -99,11 +99,22 @@
 	 * @return All users in the group
 	 */
 	function &getGroup($groname) {
+		global $conf;
 		$this->clean($groname);
 
-		$sql = "SELECT s.usename FROM pg_catalog.pg_user s, pg_catalog.pg_group g 
-					WHERE g.groname='{$groname}' AND s.usesysid = ANY (g.grolist)
-					ORDER BY s.usename";
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT s.usename FROM pg_catalog.pg_shadow s, pg_catalog.pg_group g 
+							WHERE g.groname='{$groname}' AND s.usesysid = ANY (g.grolist)
+							ORDER BY s.usename";
+			else
+				$sql = "SELECT s.usename FROM pg_catalog.pg_user s, public.{$conf['servers'][$_SESSION['webdbServerID']]['pg_grp_view']} g 
+							WHERE g.groname='{$groname}' AND s.usesysid = ANY (g.grolist)
+							ORDER BY s.usename";
+		else
+			$sql = "SELECT s.usename FROM pg_catalog.pg_user s, pg_catalog.pg_group g 
+						WHERE g.groname='{$groname}' AND s.usesysid = ANY (g.grolist)
+						ORDER BY s.usename";
 
 		return $this->selectSet($sql);
 	}
@@ -117,12 +128,65 @@
 	 */
 	function &getSchemas() {
 		global $conf;
-		
-		if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'";
-		else $and = '';
-		$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
-			WHERE pn.nspowner = pu.usesysid
-			{$and}ORDER BY nspname";
+/*
+		if (!$conf['show_system'])
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				if ($conf['show_system_admin'])
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'
+						ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					WHERE nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'
+					ORDER BY nspname";
+		else
+			if ($this->isSuperUser($_SESSION['webdbUsername']))
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+					WHERE pn.nspowner = pu.usesysid
+					ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					ORDER BY nspname";
+*/
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			if (!$conf['show_system'])
+				if ($this->isSuperUser($_SESSION['webdbUsername']))
+					if ($conf['show_system_admin'])
+						$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+							WHERE pn.nspowner = pu.usesysid
+							ORDER BY nspname";
+					else
+						$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+							WHERE pn.nspowner = pu.usesysid
+							AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'
+							ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+						WHERE nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'
+						ORDER BY nspname";
+			else
+				if ($this->isSuperUser($_SESSION['webdbUsername']))
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_shadow pu
+						WHERE pn.nspowner = pu.usesysid
+						ORDER BY nspname";
+				else
+					$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+						ORDER BY nspname";
+		else
+			if (!$conf['show_system'])
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					WHERE pn.nspowner = pu.usesysid
+					AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'
+					ORDER BY nspname";
+			else
+				$sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+					WHERE pn.nspowner = pu.usesysid
+					ORDER BY nspname";
 
 		return $this->selectSet($sql);
 	}	
@@ -163,8 +227,9 @@
 	function &getView($view) {
 		$this->clean($view);
 		
-		$sql = "SELECT relname AS viewname, pg_catalog.pg_get_userbyid(relowner) AS viewowner, pg_catalog.pg_get_viewdef(oid, true) AS definition
-            FROM pg_class WHERE relkind='v' AND relname='{$view}'";
+		$sql = "SELECT relname AS viewname, pg_catalog.pg_get_userbyid(relowner)
+			AS viewowner, pg_catalog.pg_get_viewdef(oid, true) AS definition
+			FROM pg_class WHERE relkind='v' AND relname='{$view}'";
 
 		return $this->selectSet($sql);
 	}	
diff -Naur phpPgAdmin-3.3.1-original/conf/config.inc.php phpPgAdmin-3.3.1-new/conf/config.inc.php
--- phpPgAdmin-3.3.1-original/conf/config.inc.php	2004-03-12 05:02:54.000000000 +0100
+++ phpPgAdmin-3.3.1-new/conf/config.inc.php	2004-05-27 18:02:45.000000000 +0200
@@ -27,6 +27,30 @@
 	$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
 	$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
 
+	// Enable this option if you are using enhanced security with your
+	// PostgreSQL installation.
+	// This implies that you have set up you PostgreSQL installation
+	// according to section "8. Security enhanced PostgreSQL installation"
+	// from the INSTALL file that comes with distribution of phpPgAdmin.
+	// In short, you will have to revoke some rights from users and
+	// create views pg_db and pg_grp to pg_database and pg_group,
+	// respectively.
+	$conf['servers'][0]['enhanced_security'] = false;
+
+	// If "enhanced_security" is enabled, regular users will be able to
+	// access to pg_database only trough view on that table.
+	// Here you can define the name of your view (e.g. pg_db):
+	$conf['servers'][0]['pg_database_view'] = 'pg_db';
+
+	// If "enhanced_security" is enabled, regular users will be able to
+	// access to pg_group only trough view on that table.
+	// Here you can define the name of your view (e.g. pg_grp):
+	$conf['servers'][0]['pg_group_view'] = 'pg_grp';
+
+	// If "enhanced_security" is enabled, it is assumed that regular user
+	// is able to retrieve only his own username record by SELECT * from
+	// pg_user table.
+
 	// Example for a second server
 	//$conf['servers'][1]['desc'] = 'Test Server';
 	//$conf['servers'][1]['host'] = '192.168.0.1';
@@ -34,6 +58,9 @@
 	//$conf['servers'][1]['defaultdb'] = 'template1';
 	//$conf['servers'][1]['pg_dump_path'] = 'c:/cygwin/bin/pg_dump.exe';
 	//$conf['servers'][1]['pg_dumpall_path'] = '';
+	//$conf['servers'][1]['enhanced_security'] = false;
+	//$conf['servers'][1]['pg_database_view'] = 'pg_db';
+	//$conf['servers'][1]['pg_group_view'] = 'pg_grp';
 
 	// Default language setting.  eg 'english', 'polish', etc.
 	$conf['default_lang'] = 'english';
@@ -49,6 +76,8 @@
 	// Note: This will simply hide other databases in the list - this does
 	// not in any way prevent your users from seeing other database by
 	// other means. (eg. Run 'SELECT * FROM pg_database' in the SQL area.)
+	// If "enhanced_security" is enabled, this option will not permit
+	// regular users to see databases that they do not own.
 	$conf['owned_only'] = false;
 
 	// Display "advanced" objects?  Setting this to true will show types,
@@ -59,6 +88,10 @@
 	// Display "system" objects?
 	$conf['show_system'] = false;
 
+	// Display "system" objects to admins, even if "show_system" is set
+	// to false?
+	$conf['show_system_admin'] = true;
+
 	// Display reports feature?  For this feature to work, you must
 	// install the reports database as explained in the INSTALL file.
 	$conf['show_reports'] = true;
diff -Naur phpPgAdmin-3.3.1-original/conf/config.inc.php-dist phpPgAdmin-3.3.1-new/conf/config.inc.php-dist
--- phpPgAdmin-3.3.1-original/conf/config.inc.php-dist	2004-01-29 08:30:12.000000000 +0100
+++ phpPgAdmin-3.3.1-new/conf/config.inc.php-dist	2004-05-27 18:02:50.000000000 +0200
@@ -27,6 +27,30 @@
 	$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
 	$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
 
+	// Enable this option if you are using enhanced security with your
+	// PostgreSQL installation.
+	// This implies that you have set up you PostgreSQL installation
+	// according to section "8. Security enhanced PostgreSQL installation"
+	// from the INSTALL file that comes with distribution of phpPgAdmin.
+	// In short, you will have to revoke some rights from users and
+	// create views pg_db and pg_grp to pg_database and pg_group,
+	// respectively.
+	$conf['servers'][0]['enhanced_security'] = false;
+
+	// If "enhanced_security" is enabled, regular users will be able to
+	// access to pg_database only trough view on that table.
+	// Here you can define the name of your view (e.g. pg_db):
+	$conf['servers'][0]['pg_database_view'] = 'pg_db';
+
+	// If "enhanced_security" is enabled, regular users will be able to
+	// access to pg_group only trough view on that table.
+	// Here you can define the name of your view (e.g. pg_grp):
+	$conf['servers'][0]['pg_group_view'] = 'pg_grp';
+
+	// If "enhanced_security" is enabled, it is assumed that regular user
+	// is able to retrieve only his own username record by SELECT * from
+	// pg_user table.
+
 	// Example for a second server
 	//$conf['servers'][1]['desc'] = 'Test Server';
 	//$conf['servers'][1]['host'] = '192.168.0.1';
@@ -34,6 +58,9 @@
 	//$conf['servers'][1]['defaultdb'] = 'template1';
 	//$conf['servers'][1]['pg_dump_path'] = 'c:/cygwin/bin/pg_dump.exe';
 	//$conf['servers'][1]['pg_dumpall_path'] = '';
+	//$conf['servers'][1]['enhanced_security'] = false;
+	//$conf['servers'][1]['pg_database_view'] = 'pg_db';
+	//$conf['servers'][1]['pg_group_view'] = 'pg_grp';
 
 	// Default language setting.  eg 'english', 'polish', etc.
 	$conf['default_lang'] = 'english';
@@ -49,6 +76,8 @@
 	// Note: This will simply hide other databases in the list - this does
 	// not in any way prevent your users from seeing other database by
 	// other means. (eg. Run 'SELECT * FROM pg_database' in the SQL area.)
+	// If "enhanced_security" is enabled, this option will not permit
+	// regular users to see databases that they do not own.
 	$conf['owned_only'] = false;
 
 	// Display "advanced" objects?  Setting this to true will show types,
@@ -59,6 +88,10 @@
 	// Display "system" objects?
 	$conf['show_system'] = false;
 
+	// Display "system" objects to admins, even if "show_system" is set
+	// to false?
+	$conf['show_system_admin'] = true;
+
 	// Display reports feature?  For this feature to work, you must
 	// install the reports database as explained in the INSTALL file.
 	$conf['show_reports'] = true;
diff -Naur phpPgAdmin-3.3.1-original/libraries/adodb/drivers/adodb-postgres64.inc.php phpPgAdmin-3.3.1-new/libraries/adodb/drivers/adodb-postgres64.inc.php
--- phpPgAdmin-3.3.1-original/libraries/adodb/drivers/adodb-postgres64.inc.php	2003-04-19 11:49:01.000000000 +0200
+++ phpPgAdmin-3.3.1-new/libraries/adodb/drivers/adodb-postgres64.inc.php	2004-05-27 10:55:04.000000000 +0200
@@ -369,7 +369,11 @@
 	 function &MetaDatabases()
 	 {
 	 	$arr = array();
-	  	$sql="select datname from pg_database";
+		if ($conf['servers'][$_SESSION['webdbServerID']]['enhanced_security'])
+			$sql="select datname from {$conf['servers'][$_SESSION['webdbServerID']]['pg_database_view']}";
+		else
+			$sql="select datname from pg_database";
+
 		$rs = $this->Execute($sql);
 		if (!$rs) return false;
 		while (!$rs->EOF) {
