---------------
Features
+* Database dump feature, which uses pg_dump
* Large speed improvements by reducing number of database
connections and using external style sheet.
the 'sql' subdirectory and view the SQL script for your database. It
will contain instructions on how to set up the reports database.
-4. Browse to the phpPgAdmin installation using a web browser. You might
+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.
+
+ Also, you will need to ensure that your 'pg_dump' and 'pg_dumpall' utilities
+ are executable by the PHP process.
+
+5. Browse to the phpPgAdmin installation using a web browser. You might
need cookies enabled for phpPgAdmin to work.
-5. IMPORTANT - SECURITY
+6. IMPORTANT - SECURITY
PostgreSQL by default does not require you to use a password to log in.
- This means that if you set up phpPgAdmin where the world can see it,
- someone could just come along and type username 'postgres' or 'pgsql'
- with no password and easily log in as a super user.
-
We STRONGLY recomment that you enable md5 passwords for local connections
in your pg_hba.conf, and set a password for the default superuser account.
+ Due to the large number of phpPgAdmin installations that have not set
+ passwords on local connections, there is now a configuration file
+ option called 'extra_login_security', which is TRUE by default. While
+ this option is enabled, you will be unable to log in to phpPgAdmin as
+ the 'root', 'administrator', 'pgsql' or 'postgres' users and empty passwords
+ will not work.
+
+ Once you are certain you have properly secured your database server, you
+ can then disable 'extra_login_security' so that you can log in as your
+ database administrator using the administrator password.
* -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
+* -Dump database using pg_dump streaming (chriskl)
Tables
------
-* Not using proper attFields array for attribute info (i was being lazy)
+* -Not using proper attFields array for attribute info (i was being lazy) (wontfix)
* -Rename table
* -Change table owner
* -Cluster support
* Vacuum & analyze (half done)
-* ORDER BY in Select function
+* -ORDER BY in Select function (can do so after the fact now - chriskl)
* -Unify Select and Browse functions (chriskl)
Views
* Allow setting/dropping comments for all objects
* Show owner for all objects
* Allow changing owner for objects that have this feature (7.4+ generally)
-* pg_dump integration
* -Config option to disallow pgsql and postgres logins
* Do David Smith's redireect idea to prevent refresh login resending password
* Translated FAQ
* Put functions in the highest class possible. For instance, simple selects
should be in BaseDB, whereas something that works for 7.1+ should be in the
7.1 class. This will minimise bugs and duplicated code.
-* We primarily support Postgres, and only secondarily support MySQL, etc.
* Adhere to current coding standards
* Avoid using global variables if possible
/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.51 2003/12/13 09:28:46 chriskl Exp $
+ * $Id: Misc.php,v 1.52 2003/12/13 11:04:04 chriskl Exp $
*/
class Misc {
* Display the navigation header for tables
*/
function printDatabaseNav() {
- global $lang, $data;
+ global $lang, $conf, $data;
$vars = 'database=' . urlencode($_REQUEST['database']);
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=\"14%\"><a href=\"database.php?{$vars}\">{$lang['strschemas']}</a></td>\n";
+ echo "<td width=\"12%\"><a href=\"database.php?{$vars}\">{$lang['strschemas']}</a></td>\n";
}
// Only show database privs if available
if (isset($data->privlist['database'])) {
- echo "<td width=\"14%\"><a href=\"privileges.php?{$vars}&type=database&object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
+ echo "<td width=\"13%\"><a href=\"privileges.php?{$vars}&type=database&object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
+ }
+ echo "<td width=\"12%\"><a href=\"database.php?{$vars}&action=sql\">{$lang['strsql']}</a></td>\n";
+ echo "<td width=\"13%\"><a href=\"database.php?{$vars}&action=find\">{$lang['strfind']}</a></td>\n";
+ echo "<td width=\"12%\"><a href=\"database.php?{$vars}&action=variables\">{$lang['strvariables']}</a></td>\n";
+ echo "<td width=\"13%\"><a href=\"database.php?{$vars}&action=processes\">{$lang['strprocesses']}</a></td>\n";
+ echo "<td width=\"12%\"><a href=\"database.php?{$vars}&action=admin\">{$lang['stradmin']}</a></td>\n";
+ // Check that database dumps are enabled. The is_executable function
+ // check is required as it only appeared in Win32 PHP in version 5.0.0
+ if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != ''
+ && function_exists('is_executable') && is_executable($conf['pg_dump_path'])) {
+ echo "<td width=\"13%\"><a href=\"database.php?{$vars}&action=export\">{$lang['strexport']}</a></td>\n";
}
- echo "<td width=\"14%\"><a href=\"database.php?{$vars}&action=sql\">{$lang['strsql']}</a></td>\n";
- echo "<td width=\"14%\"><a href=\"database.php?{$vars}&action=find\">{$lang['strfind']}</a></td>\n";
- echo "<td width=\"14%\"><a href=\"database.php?{$vars}&action=variables\">{$lang['strvariables']}</a></td>\n";
- echo "<td width=\"14%\"><a href=\"database.php?{$vars}&action=processes\">{$lang['strprocesses']}</a></td>\n";
- echo "<td width=\"14%\"><a href=\"database.php?{$vars}&action=admin\">{$lang['stradmin']}</a></td>\n";
echo "</tr></table>\n";
}
* Central phpPgAdmin configuration. As a user you may modify the
* settings here for your particular configuration.
*
- * $Id: config.inc.php-dist,v 1.29 2003/11/14 09:22:10 chriskl Exp $
+ * $Id: config.inc.php-dist,v 1.30 2003/12/13 11:04:04 chriskl Exp $
*/
// An example server. Create as many of these as you wish,
// 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.
+ $conf['pg_dump_path'] = '/usr/local/bin/pg_dump';
+ $conf['pg_dumpall_path'] = '/usr/local/bin/pg_dumpall';
+
// Minimum length users can set their password to.
$conf['min_password_length'] = 1;
* Don't modify anything below this line *
*****************************************/
- $conf['version'] = 11;
+ $conf['version'] = 12;
?>
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.27 2003/12/13 09:28:46 chriskl Exp $
+ * $Id: database.php,v 1.28 2003/12/13 11:04:04 chriskl Exp $
*/
// Include application functions
else echo "<p>{$lang['strnoobjects']}</p>\n";
}
}
+
+ /**
+ * Displays options for database download
+ */
+ function doExport($msg = '') {
+ global $data, $misc;
+ global $PHP_SELF, $lang;
+
+ $misc->printDatabaseNav();
+ echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strexport']}</h2>\n";
+ $misc->printMsg($msg);
+
+ echo "<form action=\"dbexport.php\" method=\"post\">\n";
+ echo "<table>\n";
+ echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
+ // Data only
+ echo "<tr><th class=\"data left\" rowspan=\"2\">";
+ echo "<input type=\"radio\" name=\"what\" value=\"dataonly\" checked=\"checked\" />{$lang['strdataonly']}</th>\n";
+ echo "<td>{$lang['strformat']}</td>\n";
+ echo "<td><select name=\"d_format\">\n";
+ echo "<option value=\"copy\">COPY</option>\n";
+ echo "<option value=\"sql\">SQL</option>\n";
+ echo "</select>\n</td>\n</tr>\n";
+ echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"d_oids\" /></td>\n</tr>\n";
+ // Structure only
+ echo "<tr><th class=\"data left\"><input type=\"radio\" name=\"what\" value=\"structureonly\" />{$lang['strstructureonly']}</th>\n";
+ echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"s_clean\" /></td>\n</tr>\n";
+ // Structure and data
+ echo "<tr><th class=\"data left\" rowspan=\"3\">";
+ echo "<input type=\"radio\" name=\"what\" value=\"structureanddata\" />{$lang['strstructureanddata']}</th>\n";
+ echo "<td>{$lang['strformat']}</td>\n";
+ echo "<td><select name=\"sd_format\">\n";
+ echo "<option value=\"copy\">COPY</option>\n";
+ echo "<option value=\"sql\">SQL</option>\n";
+ echo "</select>\n</td>\n</tr>\n";
+ echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"sd_clean\" /></td>\n</tr>\n";
+ echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"sd_oids\" /></td>\n</tr>\n";
+ echo "</table>\n";
+
+ echo "<h3>{$lang['stroptions']}</h3>\n";
+ echo "<table>\n";
+ echo "<tr>\n<th class=\"data left\">{$lang['strdownload']}</th>\n";
+ echo "<td><input type=\"checkbox\" name=\"download\" /></td>\n</tr>\n";
+ echo "</table>\n";
+
+ echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
+ echo $misc->form;
+ echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
+ echo "</form>\n";
+ }
/**
* Show the current status of all database variables
case 'processes':
doProcesses();
break;
+ case 'export':
+ doExport();
+ break;
default:
doDefault();
break;
--- /dev/null
+<?php
+ /**
+ * Does an export of a database to the screen or as a download
+ *
+ * $Id: dbexport.php,v 1.1 2003/12/13 11:04:04 chriskl Exp $
+ */
+
+ // Include application functions
+ $_no_output = true;
+ include_once('libraries/lib.inc.php');
+
+ // Check that database dumps are enabled. The is_executable function
+ // check is required as it only appeared in Win32 PHP in version 5.0.0
+ if ($conf['pg_dump_path'] !== null && $conf['pg_dump_path'] != ''
+ && function_exists('is_executable') && is_executable($conf['pg_dump_path'])) {
+
+ // Make it do a download, if necessary
+ if (isset($_REQUEST['download'])) {
+ header('Content-Type: application/download');
+ header('Content-Disposition: attachment; filename=dbdump.sql');
+ }
+ else {
+ header('Content-Type: text/plain');
+ }
+
+ // Set environmental variable for password that pg_dump uses
+ putenv('PGPASSWORD=' . $_SESSION['webdbPassword']);
+
+ // Prepare command line arguments
+ $hostname = $conf['servers'][$_SESSION['webdbServerID']]['host'];
+ $port = $conf['servers'][$_SESSION['webdbServerID']]['port'];
+ $username = escapeshellarg($_SESSION['webdbUsername']);
+ $database = escapeshellarg($_REQUEST['database']);
+
+ // Build command for executing pg_dump
+ $cmd = escapeshellcmd($conf['pg_dump_path']) . " -i -U {$username}";
+ if ($hostname !== null && $hostname != '') {
+ $cmd .= " -h " . escapeshellarg($hostname);
+ }
+ if ($port !== null && $port != '') {
+ $cmd .= " -p " . escapeshellarg($port);
+ }
+
+ switch ($_REQUEST['what']) {
+ case 'dataonly':
+ $cmd .= ' -a';
+ if ($_REQUEST['d_format'] == 'sql') $cmd .= ' -d';
+ elseif (isset($_REQUEST['d_oids'])) $cmd .= ' -o';
+ break;
+ case 'structureonly':
+ $cmd .= ' -s';
+ if (isset($_REQUEST['s_clean'])) $cmd .= ' -c';
+ break;
+ case 'structureanddata':
+ if ($_REQUEST['sd_format'] == 'sql') $cmd .= ' -d';
+ elseif (isset($_REQUEST['sd_oids'])) $cmd .= ' -o';
+ if (isset($_REQUEST['sd_clean'])) $cmd .= ' -c';
+ break;
+ }
+
+ $cmd .= " -U {$username} {$database}";
+
+ // Execute command and return the output to the screen
+ passthru($cmd);
+ }
+
+?>
/**
* Function library read in upon startup
*
- * $Id: lib.inc.php,v 1.69 2003/12/10 16:03:30 chriskl Exp $
+ * $Id: lib.inc.php,v 1.70 2003/12/13 11:04:04 chriskl Exp $
*/
// Set error reporting level to max
// Configuration file version. If this is greater than that in config.inc.php, then
// the app will refuse to run. This and $conf['version'] should be incremented whenever
// backwards incompatible changes are made to config.inc.php-dist.
- $conf['base_version'] = 11;
+ $conf['base_version'] = 12;
// List of available language files
$appLangFiles = array(