pretty login screen, show indexes on 7.2+ tables, remove indexes from browser, improv...
authorchriskl <chriskl>
Mon, 18 Nov 2002 04:57:33 +0000 (04:57 +0000)
committerchriskl <chriskl>
Mon, 18 Nov 2002 04:57:33 +0000 (04:57 +0000)
classes/database/Postgres.php
classes/database/Postgres72.php
classes/database/Postgres73.php
libraries/lib.inc.php
public_html/browser.php
public_html/login.php
public_html/tblproperties.php

index fc9670b561127753dc69a8ec1c974caa06bf4a90..af9996ea18a26cea10614a2267f99be300792185 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres\r
  * Note: This class uses ADODB and returns RecordSets.\r
  *\r
- * $Id: Postgres.php,v 1.22 2002/11/14 01:04:38 chriskl Exp $\r
+ * $Id: Postgres.php,v 1.23 2002/11/18 04:57:33 chriskl Exp $\r
  */\r
 \r
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???\r
@@ -18,7 +18,7 @@ class Postgres extends BaseDB {
        var $vwFields = array('vwname' => 'viewname', 'vwowner' => 'viewowner', 'vwdef' => 'definition');\r
        var $uFields = array('uname' => 'usename', 'usuper' => 'usesuper', 'ucreatedb' => 'usecreatedb', 'uexpires' => 'valuntil');\r
        var $sqFields = array('seqname' => 'relname', 'seqowner' => 'usename', 'lastvalue' => 'last_value', 'incrementby' => 'increment_by', 'maxvalue' => 'max_value', 'minvalue'=> 'min_value', 'cachevalue' => 'cache_value', 'logcount' => 'log_cnt', 'iscycled' => 'is_cycled', 'iscalled' => 'is_called' );\r
-       var $ixFields = array('idxname' => 'relname', 'tabname' => 'tab_name', 'columnname' => 'column_name', 'uniquekey' => 'unique_key', 'primarykey' => 'primary_key');\r
+       var $ixFields = array('idxname' => 'relname', 'idxdef' => 'pg_get_indexdef', 'uniquekey' => 'indisunique', 'primarykey' => 'indisprimary');\r
 \r
        // Last oid assigned to a system object\r
        var $_lastSystemOID = 18539;\r
@@ -759,10 +759,21 @@ class Postgres extends BaseDB {
        }\r
 \r
        /**\r
-        * grabs a list of indicies in the database\r
+        * Grabs a list of indicies in the database or table\r
+        * @param $table (optional) The name of a table to get the indicies for\r
         */\r
-       function &getIndicies() {\r
-               if (!$this->_showSystem)\r
+       function &getIndicies($table = '') {\r
+               $this->clean($table);\r
+\r
+               $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid)\r
+                       FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\r
+                       WHERE c.oid = '16977' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\r
+                       ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname";\r
+\r
+               \r
+               if ($table != '')\r
+                       $where = "WHERE relname='{$table}' AND ";\r
+               elseif (!$this->_showSystem)\r
                        $where = "WHERE relname NOT LIKE 'pg_%' AND ";\r
                else $where  = '';\r
                \r
index ae3e39c47ed46eb0ba7d9bcf2431c2e0c1ab2cc3..cc5d03a7d2046cba5ad7ffd1f50bca69055174f5 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres72.php,v 1.15 2002/11/14 01:04:38 chriskl Exp $
+ * $Id: Postgres72.php,v 1.16 2002/11/18 04:57:33 chriskl Exp $
  */
 
 
@@ -276,6 +276,20 @@ class Postgres72 extends Postgres71 {
                return $this->selectSet($sql);
        }
 
+       /**
+        * Grabs a list of indexes for a table
+        * @param $table The name of a table whose indexes to retrieve
+        * @return A recordset
+        */
+       function &getIndexes($table = '') {
+               $this->clean($table);
+               $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_get_indexdef(i.indexrelid)
+                       FROM pg_class c, pg_class c2, pg_index i
+                       WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid
+                       ORDER BY c2.relname";
+
+               return $this->selectSet($sql);
+       }
 
 }
 
index e6b771f84f5dcb3773072268aa78538e9eafac06..d80f0d0a2a3ca02b9abee15c112035d8c26e045d 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres\r
  * Note: This class uses ADODB and returns RecordSets.\r
  *\r
- * $Id: Postgres73.php,v 1.5 2002/09/15 07:29:08 chriskl Exp $\r
+ * $Id: Postgres73.php,v 1.6 2002/11/18 04:57:33 chriskl Exp $\r
  */\r
 \r
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???\r
@@ -319,6 +319,22 @@ class Postgres73 extends Postgres71 {
                return $this->selectSet($sql);\r
 \r
        }\r
+\r
+       /**\r
+        * Grabs a list of indexes for a table\r
+        * @param $table The name of a table whose indexes to retrieve\r
+        * @return A recordset\r
+        */\r
+       function &getIndexes($table = '') {\r
+               $this->clean($table);\r
+\r
+               $sql = "SELECT c2.relname, i.indisprimary, i.indisunique, pg_catalog.pg_get_indexdef(i.indexrelid) as indexdef\r
+                       FROM pg_catalog.pg_class c, pg_catalog.pg_class c2, pg_catalog.pg_index i\r
+                       WHERE c.relname = '{$table}' AND c.oid = i.indrelid AND i.indexrelid = c2.oid\r
+                       ORDER BY i.indisprimary DESC, i.indisunique DESC, c2.relname";\r
+\r
+               return $this->selectSet($sql);\r
+       }\r
         \r
        // Capabilities\r
        function hasSchemas() { return true; }\r
index 7158bc5825189774b6ff466fd97e5aae3897a0f2..06ee19fe98bbb283ed9f1710830cfe965f38c025 100644 (file)
@@ -3,7 +3,7 @@
        /**\r
         * Function library read in upon startup\r
         *\r
-        * $Id: lib.inc.php,v 1.3 2002/10/23 21:59:14 xzilla Exp $\r
+        * $Id: lib.inc.php,v 1.4 2002/11/18 04:57:34 chriskl Exp $\r
         */\r
 \r
        // Create Misc class references\r
                        ||      !isset($confServers[$_SESSION['webdbServerID']])\r
        ){\r
                include($appBase . '/login.php');\r
+               // Theme\r
+               echo "<style type=\"text/css\">\n<!--\n";\r
+               include("../themes/{$guiTheme}/global.css");\r
+               echo "\n-->\n</style>\n";\r
                exit;\r
        }\r
        \r
index 778bb6ec8e84b56591da42aa86f278966035006e..156d5f4985a5a685ae4d2f822aeec2dea6c03067 100644 (file)
@@ -5,7 +5,7 @@
         * if you click on a database it shows a list of database objects in that
         * database.
         *
-        * $Id: browser.php,v 1.12 2002/11/14 01:04:38 chriskl Exp $
+        * $Id: browser.php,v 1.13 2002/11/18 04:57:34 chriskl Exp $
         */
 
        // Include application functions
                                while (!$schemas->EOF) {
                                        $schemanode = $tree->add_folder($node, htmlspecialchars($schemas->f[$data->nspFields['nspname']]), 
                                                'schema.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]) . '&schema=' . 
-                                               urlencode($schemas->f[$data->nspFields['nspname']]), '_self');                  
+                                               urlencode($schemas->f[$data->nspFields['nspname']]), 'detail');                 
                                        if ($data->hasTables()) {
-                                               $tree->add_document($schemanode, $strTables, 'tables.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/tables.gif");
+                                               $tables = &$localData->getTables();
+                                               $table_node = $tree->add_folder($schemanode, $strTables, 
+                                                       'tables.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
+                                               while (!$tables->EOF) {
+                                                       $tree->add_document($table_node, htmlspecialchars($tables->f[$data->tbFields['tbname']]), 
+                                                               'tblproperties.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]) . '&table=' .
+                                                               urlencode($tables->f[$data->tbFields['tbname']]), 'detail', "../images/themes/{$guiTheme}/tables.gif");
+                                                       $tables->moveNext();
+                                               }
                                        }
                                        if ($data->hasViews())
                                                $tree->add_document($schemanode, $strViews, 'views.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/views.gif");
-                       /*              if ($data->hasTriggers())
-                                               $tree->add_document($node, $strTriggers, 'triggers.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]));
-                                       if ($data->hasRules())
-                                               $tree->add_document($node, $strRules, 'rules.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]));*/
                                        if ($data->hasSequences())
                                                $tree->add_document($schemanode, $strSequences, 'sequences.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail', "../images/themes/{$guiTheme}/sequences.gif");
                                        if ($data->hasFunctions())
@@ -87,8 +91,6 @@
                                        $tree->add_document($node, $strTypes, 'types.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
                                if ($data->hasAggregates())
                                        $tree->add_document($node, $strAggregates, 'aggregates.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
-                               if ($data->hasIndicies())
-                                       $tree->add_document($node, $strIndicies, 'indicies.php?database=' . urlencode($databases->f[$data->dbFields['dbname']]), 'detail');
                        }
                } else {
                        $node = $tree->add_document($root, htmlspecialchars($databases->f[$data->dbFields['dbname']]), 
index 68242797b7e957ea434c42840c621f98a628f5f1..2d8fb02456a44e69d1d9518aed20b8ca4eb02866 100755 (executable)
@@ -3,7 +3,7 @@
        /**\r
         * Login screen\r
         *\r
-        * $Id: login.php,v 1.3 2002/05/15 09:57:55 chriskl Exp $\r
+        * $Id: login.php,v 1.4 2002/11/18 04:57:34 chriskl Exp $\r
         */\r
 \r
        // Include application functions\r
        </head>\r
        \r
        <body>\r
-               <h1><?= $appName ?> <?= $appVersion ?></h1>\r
-               <table border="0" cellpadding="0" cellspacing="0" width="350">\r
+               <table class="navbar" border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">\r
                        <tr height="115">\r
                                <td height="115" align="center" valign="middle">\r
-                                       <table border="0" cellpadding="2" cellspacing="0">\r
-                                               <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="login_form">\r
+                                       <center>\r
+                                       <h1><?= $appName ?> <?= $strLogin ?></h1>\r
+                                       <table class="navbar" border="0" cellpadding="5" cellspacing="3">\r
+                                               <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" name="login_form">                                             \r
                                                <tr>\r
-                                                       <td class="form">Username:</td>\r
+                                                       <td>Username:</td>\r
                                                        <td><input type="text" name="formUsername" value="<?php isset($webdbUsername) ? htmlspecialchars($webdbUsername) : '' ?>" size="24"></td>\r
                                                </tr>\r
                                                <tr>\r
-                                                       <td class="form">Password:</td>\r
+                                                       <td>Password:</td>\r
                                                        <td><input type="password" name="formPassword" size="24"></td>\r
                                                </tr>\r
                                                <tr>\r
-                                                       <td class="form">Server:</td>\r
+                                                       <td>Server:</td>\r
                                                        <td><select name="formServer">\r
                                                        <?php\r
                                                                for ($i = 0; $i < sizeof($confServers); $i++) {\r
@@ -49,6 +50,7 @@
                                                </tr>\r
                                                </form>\r
                                        </table>\r
+                                       </center>\r
                                        <script language=javascript>\r
                                                var uname = document.login_form.formUsername;\r
                                                var pword = document.login_form.formPassword;\r
index c86740c290b478ecf61d0d910089ce3823cd0e95..0cd6017e6c06fb8010002679470ab5d903a153fb 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.6 2002/11/14 01:04:38 chriskl Exp $
+        * $Id: tblproperties.php,v 1.7 2002/11/18 04:57:34 chriskl Exp $
         */
 
        // Include application functions
        $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
        $PHP_SELF = $_SERVER['PHP_SELF'];
 
+       function doIndicies($msg = '') {
+               global $data, $localData, $misc; 
+               global $PHP_SELF;
+               global $strNoIndicies, $strIndicies, $strOwner, $strActions, $strName;
+               
+               doNav();
+               echo "<h2>", htmlspecialchars($_REQUEST['database']), ": ", htmlspecialchars($_REQUEST['table']), ": {$strIndicies}</h2>\n";
+               
+               $indexes = &$localData->getIndexes($_REQUEST['table']);
+               
+               if ($indexes->recordCount() > 0) {
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$strName}</th><th class=\"data\">Definition</th><th colspan=\"2\" class=\"data\">{$strActions}</th>\n";
+                       $i = 0;
+                       
+                       while (!$indexes->EOF) {
+                               $id = ( ($i % 2 ) == 0 ? '1' : '2' );
+                               echo "<tr><td class=\"data{$id}\">", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "</td>";
+                               echo "<td class=\"data{$id}\">", htmlspecialchars( $indexes->f[$data->ixFields['idxdef']]), "</td>";
+                               echo "<td class=\"data{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=confirm_drop&database=", htmlspecialchars($_REQUEST['database']), "&index=", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "\">Drop</td>\n"; 
+                               echo "<td class=\"data{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=priviledges&database=", htmlspecialchars($_REQUEST['database']), "&index=", htmlspecialchars( $indexes->f[$data->ixFields['idxname']]), "\">Privileges</td></tr>\n"; 
+                               
+                               $indexes->movenext();
+                               $i++;
+                       }
+                       
+                       echo "</table>\n";
+                       }
+               else
+                       echo "<p>{$strNoIndicies}</p>\n";
+               
+               echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=createindex&database=", 
+                       urlencode( $_REQUEST['database'] ), "&table=", htmlspecialchars($_REQUEST['table']), "\">Create Index</a></p>\n";               
+       }       
+
        function doExport($msg = '') {
                global $data, $localData, $misc;
                global $PHP_SELF, $strExport;
@@ -268,7 +305,7 @@ EOF;
                
                echo "<table class=\"navbar\" border=\"0\" width=\"100%\" cellpadding=\"5\" cellspacing=\"3\">\n";
                echo "<tr><td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}\">Columns</a></td>";
-               echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=indexes\">Indexes</a></td>";
+               echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=indicies\">Indexes</a></td>";
                echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=constraints\">Constraints</a></td>";
                echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=triggers\">Triggers</a></td>";
                echo "<td width=\"17%\"><a href=\"{$PHP_SELF}?{$vars}&action=rules\">Rules</a></td>";
@@ -280,6 +317,9 @@ EOF;
        echo "<body>\n";
        
        switch ($action) {
+               case 'indicies':
+                       doIndicies();
+                       break;
                case 'export':
                        doExport();
                        break;