use per-server pg_dump and pg_dumpall. improve docs quite a bit
authorchriskl <chriskl>
Thu, 29 Jan 2004 07:30:11 +0000 (07:30 +0000)
committerchriskl <chriskl>
Thu, 29 Jan 2004 07:30:11 +0000 (07:30 +0000)
BUGS
INSTALL
TODO
classes/Misc.php
classes/database/Postgres.php
conf/config.inc.php-dist
dataexport.php
dbexport.php

diff --git a/BUGS b/BUGS
index 9f0cdb177097addd599c258b2f7754ec87bda687..d5fa5a36fa2b6f95dfdfd84a78528a83ea2abf8c 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -21,4 +21,6 @@ Need to fix:
 * Aggregate and opclass support for < 7.3
 * The getType function needs to be ported to 7.2 and 7.3 classes to add
   pretty type name and schema support
+* Add query start time to processes view for 7.4+
+* Report login errors
 
diff --git a/INSTALL b/INSTALL
index cb43d96d54fca2a031fecf33b1bd179c7f043f2f..049404da26ad424b34711acabff4363acb8c0320 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -20,10 +20,18 @@ phpPgAdmin Installation Guide
 
 4. If you run your PHP installation in safe mode, in order that the database
    dump feature can work correctly, you need to set the 'safe_mode_allowed_env_vars'
-   php.ini variable to include the PGPASSWORD environmental variable.
+   php.ini variable to include the PGPASSWORD environmental variable and the
+   safe_mode_exec_dir to include /usr/local/bin.
+   
+       eg. safe_mode_allowed_env_vars = PHP_,PGPASSWORD
+           safe_mode_exec_dir = /usr/bin
+   
+   Given that you usually don't want to allow everything in /usr/bin to
+   be executed, you might want to copy the pg_dump and pg_dumpall utilities
+   to a directory by themselves.
    
    Also, you will need to ensure that your 'pg_dump' and 'pg_dumpall' utilities
-   are executable by the PHP process.
+   are executable by the PHP process, if you want dump support in phpPgAdmin.
 
 5. Enable the statistics collector in PostgreSQL.  phpPgAdmin will display
    table and index performance and usage statistics if you have enabled the
@@ -31,9 +39,9 @@ phpPgAdmin Installation Guide
    following lines in your postgresql.conf and enable them:
 
        stats_start_collector = true
-       stats_command_string = true
-       stats_block_level = true
-       stats_row_level = true
+               stats_command_string = true
+               stats_block_level = true
+               stats_row_level = true
 
 6. Browse to the phpPgAdmin installation using a web browser.  You might
    need cookies enabled for phpPgAdmin to work.
diff --git a/TODO b/TODO
index 4e74d125c6cf4c0ca2e13b13e3257171c025131f..3343457dd110ea39e5d5a0a8b57a4d731ca1801b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -44,6 +44,7 @@ Tables
 * Vacuum & analyze (half done)
 * -ORDER BY in Select function (can do so after the fact now - chriskl)
 * -Unify Select and Browse functions (chriskl)
+* Add option for showing table size counts
 
 Views
 -----
index de41c3a7df7d26f59fc3e56e9f05a320b20d94a2..761956100f18c1fa4f9aac6e1fbb97da99e811e6 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.56 2003/12/30 03:09:29 chriskl Exp $
+        * $Id: Misc.php,v 1.57 2004/01/29 07:30:12 chriskl Exp $
         */
         
        class Misc {
                function Misc() {
                }
 
+               /** 
+                * Checks if dumps are properly set up
+                * @param $all (optional) True to check pg_dumpall, false to just check pg_dump
+                * @return True, dumps are set up, false otherwise
+                */
+               function isDumpEnabled($all = false) {
+                       global $conf;
+                       
+                       if ($all)
+                               return ($conf['servers'][$_SESSION['webdbServerID']]['pg_dumpall_path'] !== null 
+                                                               && $conf['servers'][$_SESSION['webdbServerID']]['pg_dumpall_path'] != '');
+                       else 
+                               return ($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path'] !== null 
+                                                               && $conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path'] != '');
+               }
+
                /**
                 * Checks whether a login is allowed
                 * @return True if login is allowed to be used
                                echo "<td width=\"13%\"><a href=\"privileges.php?{$vars}&amp;type=database&amp;object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
                        }
                        // Check that database dumps are enabled.
-                       if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != '') {
+                       if ($this->isDumpEnabled()) {
                                echo "<td width=\"13%\"><a href=\"database.php?{$vars}&amp;action=export\">{$lang['strexport']}</a></td>\n";
                        }
                        echo "</tr></table>\n";
index 2baa44e1fae5e549bc7d746c75c0665e571590ef..c0dfe633fec5f43bc3501aed281659fca8bdf5ac 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.177 2004/01/18 11:09:12 chriskl Exp $
+ * $Id: Postgres.php,v 1.178 2004/01/29 07:30:12 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -965,17 +965,6 @@ class Postgres extends BaseDB {
                return $this->execute($sql);
        }
        
-       /**
-        * Dumps a database
-        */
-       function dbDump($database) {
-               global $appDumper;
-
-               $database = escapeshellarg($database);
-
-               passthru("/usr/local/bin/pg_dump {$database}");
-       }
-
        // Table functions
 
        /**
index f9dec8819bc0488f9d3a75d0bd0b57fd72b71a98..3eca790f2fbb5badb1db4400a8a2209313b7a93a 100644 (file)
@@ -4,65 +4,70 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.31 2003/12/13 16:15:48 chriskl Exp $
+        * $Id: config.inc.php-dist,v 1.32 2004/01/29 07:30:12 chriskl Exp $
         */
 
        // An example server.  Create as many of these as you wish,
        // indexed from zero upwards.
-       $conf['servers'][0]['desc'] = 'PostgreSQL'; // Display name for server
-       $conf['servers'][0]['host'] = '';  // Hostname or IP address for server.
-                                      // Null or '' indicates UNIX domain
-                                      // socket.
-       $conf['servers'][0]['port'] = 5432;         // Database port on server
-       $conf['servers'][0]['defaultdb'] = 'template1';  // Default database to connect to.
-                                                    // Only change this if your administrator
-                                                    // has disabled connections to template1.
+
+       // Display name for the server on the login screen
+       $conf['servers'][0]['desc'] = 'PostgreSQL';
+
+       // Hostname or IP address for server.  Use '' for UNIX domain socket.
+       $conf['servers'][0]['host'] = '';
+
+       // Database port on server (5432 is the PostgreSQL default)
+       $conf['servers'][0]['port'] = 5432;
+
+       // Change the default database only if you cannot connect to template1
+       $conf['servers'][0]['defaultdb'] = 'template1';
+
+       // Specify the path to the database dump utilities for this server.
+       // You can set these to '' if no dumper is available.
+       $conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
+       $conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
 
        // Example for a second server
-       //$conf['servers'][1]['desc'] = 'Dev Server';
+       //$conf['servers'][1]['desc'] = 'Test Server';
        //$conf['servers'][1]['host'] = '192.168.0.1';
        //$conf['servers'][1]['port'] = 5432;
        //$conf['servers'][1]['defaultdb'] = 'template1';
+       //$conf['servers'][1]['pg_dump_path'] = 'c:/cygwin/bin/pg_dump.exe';
+       //$conf['servers'][1]['pg_dumpall_path'] = '';
 
        // Default language setting.  eg 'english', 'polish', etc.
        $conf['default_lang'] = 'english';
        
-       // If extra login security is true, then logins via phpPgAdmin with no password
-       // or certain usernames (pgsql, postgres, root, administrator) will be denied.
-       // Only turn this off once you have read the FAQ and understand how to change
-       // PostgreSQL's pg_hba.conf to enable passworded local connections.
+       // If extra login security is true, then logins via phpPgAdmin with no
+       // password or certain usernames (pgsql, postgres, root, administrator)
+       // will be denied. Only turn this off once you have read the FAQ and
+       // understand how to change PostgreSQL's pg_hba.conf to enable
+       // passworded local connections.
        $conf['extra_login_security'] = true;
 
        // Only show owned databases?
-       // 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.)
+       // 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.)
        $conf['owned_only'] = false;
 
-       // Display "advanced" objects?  Setting this to true will show types, operators
-       // conversions, languages and casts in phpPgAdmin.  These objects are rarely
-       // administered and can clutter the interface.
+       // Display "advanced" objects?  Setting this to true will show types,
+       // operators conversions, languages and casts in phpPgAdmin.  These
+       // objects are rarely administered and can clutter the interface.
        $conf['show_advanced'] = false;
 
        // Display "system" objects?
        $conf['show_system'] = false;
 
-       // Display reports feature?
+       // Display reports feature?  For this feature to work, you must
+       // install the reports database as explained in the INSTALL file.
        $conf['show_reports'] = true;
 
        // Only show owned reports?
-       // Note: This does not prevent people from accessing other reports by other
-       // means.
+       // Note: This does not prevent people from accessing other reports by
+       // other means.
        $conf['owned_reports_only'] = false;
 
-       // Allow database and cluster dumps?
-       // Note: Set this to the fully qualified path name for your pg_dump 
-       // and pg_dumpall utilities.  If you set them to '' or null, then the 
-       // feature will be disabled.  Read the INSTALL file for more
-       // information.  Usual Win32 Cygwin dir is 'c:/cygwin/bin/pg_dump.exe'
-       $conf['pg_dump_path'] = '/usr/bin/pg_dump';
-       $conf['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
-       
        // Minimum length users can set their password to.
        $conf['min_password_length'] = 1;
 
index f53231ded6de47ab79d2b3739f39d72159ca042a..2db816cf15dbc217c30ea4d8acb28f5546afd4e4 100644 (file)
@@ -4,7 +4,7 @@
         * Does an export to the screen or as a download.  This checks to
         * see if they have pg_dump set up, and will use it if possible.
         *
-        * $Id: dataexport.php,v 1.10 2003/12/31 15:44:27 soranzo Exp $
+        * $Id: dataexport.php,v 1.11 2004/01/29 07:30:11 chriskl Exp $
         */
 
        $extensions = array(
@@ -30,7 +30,7 @@
                        case 'dataonly':
                                // Check to see if they have pg_dump set up and if they do, use that
                                // instead of custom dump code
-                               if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != ''
+                               if ($misc->isDumpEnabled()
                                                && ($_REQUEST['d_format'] == 'copy' || $_REQUEST['d_format'] == 'sql')) {
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
@@ -51,7 +51,7 @@
                        case 'structureonly':
                                // Check to see if they have pg_dump set up and if they do, use that
                                // instead of custom dump code
-                               if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != '') {
+                               if ($misc->isDumpEnabled()) {
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
@@ -67,7 +67,7 @@
                        case 'structureanddata':
                                // Check to see if they have pg_dump set up and if they do, use that
                                // instead of custom dump code
-                               if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != '') {
+                               if ($misc->isDumpEnabled()) {
                                        $url = 'dbexport.php?database=' . urlencode($_REQUEST['database']);
                                        $url .= '&what=' . urlencode($_REQUEST['what']);
                                        $url .= '&table=' . urlencode($_REQUEST['table']);
index 98cfac49e6aecf720315f1686703b14d4676593f..0cde9bc2a0c970add25f587312714c97f4b9bca4 100644 (file)
@@ -3,7 +3,7 @@
         * Does an export of a database to the screen or as a download.
         * Can also dump a specific table of a database.
         *
-        * $Id: dbexport.php,v 1.6 2003/12/31 15:44:27 soranzo Exp $
+        * $Id: dbexport.php,v 1.7 2004/01/29 07:30:11 chriskl Exp $
         */
 
        // Include application functions
@@ -11,7 +11,7 @@
        include_once('./libraries/lib.inc.php');
        
        // Check that database dumps are enabled.
-       if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != '') {
+       if ($misc->isDumpEnabled()) {
 
                // Make it do a download, if necessary
                switch($_REQUEST['output']){
@@ -38,7 +38,7 @@
                $database = escapeshellarg($_REQUEST['database']);              
 
                // Build command for executing pg_dump
-               $cmd = escapeshellcmd($conf['pg_dump_path']) . " -i -U {$username}";
+               $cmd = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path']) . " -i -U {$username}";
                if ($hostname !== null && $hostname != '') {
                        $cmd .= " -h " . escapeshellarg($hostname);
                }