Simplified dataexport.php to include dbexport.php rather than redirecting to it.
Now makes use of the common 'subject' req var to determine pg_dump/dumpall rather than the export specific 'mode' var.
Fixed setting of 'search_path' when exporting a query.
/**
* Manage databases within a server
*
- * $Id: all_db.php,v 1.35.4.4 2005/03/22 09:29:43 jollytoad Exp $
+ * $Id: all_db.php,v 1.35.4.5 2005/03/29 09:33:46 jollytoad Exp $
*/
// Include application functions
echo "<br/><input type=\"radio\" name=\"output\" value=\"download\" />{$lang['strdownload']}</p>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
- echo "<p><input type=\"hidden\" name=\"mode\" value=\"cluster\" />\n";
+ echo "<p><input type=\"hidden\" name=\"subject\" value=\"server\" />\n";
echo $misc->form;
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
echo "</form>\n";
/**
* Manage schemas within a database
*
- * $Id: database.php,v 1.65.2.5 2005/03/22 09:29:43 jollytoad Exp $
+ * $Id: database.php,v 1.65.2.6 2005/03/29 09:33:47 jollytoad Exp $
*/
// Include application functions
}
echo "</p>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
- echo "<p><input type=\"hidden\" name=\"mode\" value=\"database\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"database\" />\n";
echo $misc->form;
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
echo "</form>\n";
* 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.18 2005/02/09 11:26:24 chriskl Exp $
+ * $Id: dataexport.php,v 1.18.2.1 2005/03/29 09:33:47 jollytoad Exp $
*/
$extensions = array(
'html' => 'html',
'xml' => 'xml'
);
-
+
// Prevent timeouts on large exports
set_time_limit(0);
// What must we do in this case? Maybe redirect to the homepage?
// If format is set, then perform the export
- if (isset($_REQUEST['what'])) {
-
+ if (isset($_REQUEST['what'])) {
+
// Include application functions
$_no_output = true;
include_once('./libraries/lib.inc.php');
-
+
switch ($_REQUEST['what']) {
case 'dataonly':
// Check to see if they have pg_dump set up and if they do, use that
// instead of custom dump code
if ($misc->isDumpEnabled()
&& ($_REQUEST['d_format'] == 'copy' || $_REQUEST['d_format'] == 'sql')) {
- $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
- $url .= '&what=' . urlencode($_REQUEST['what']);
- $url .= '&table=' . urlencode($_REQUEST['table']);
- if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
- $url .= '&d_format=' . urlencode($_REQUEST['d_format']);
- $url .= '&output=' . urlencode($_REQUEST['output']);
- if (isset($_REQUEST['d_oids'])) $url .= '&d_oids=' . urlencode($_REQUEST['d_oids']);
- $url .= "&" . SID;
-
- header("Location: {$url}");
+ include('./dbexport.php');
exit;
}
else {
// Check to see if they have pg_dump set up and if they do, use that
// instead of custom dump code
if ($misc->isDumpEnabled()) {
- $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
- $url .= '&what=' . urlencode($_REQUEST['what']);
- $url .= '&table=' . urlencode($_REQUEST['table']);
- if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
- $url .= '&output=' . urlencode($_REQUEST['output']);
- if (isset($_REQUEST['s_clean'])) $url .= '&s_clean=' . urlencode($_REQUEST['s_clean']);
- $url .= "&" . SID;
-
- header("Location: {$url}");
+ include('./dbexport.php');
exit;
}
else $clean = isset($_REQUEST['s_clean']);
// Check to see if they have pg_dump set up and if they do, use that
// instead of custom dump code
if ($misc->isDumpEnabled()) {
- $url = 'dbexport.php?mode=database&database=' . urlencode($_REQUEST['database']);
- $url .= '&what=' . urlencode($_REQUEST['what']);
- $url .= '&table=' . urlencode($_REQUEST['table']);
- if ($data->hasSchemas()) $url .= '&schema=' . urlencode($_REQUEST['schema']);
- $url .= '&sd_format=' . urlencode($_REQUEST['sd_format']);
- $url .= '&output=' . urlencode($_REQUEST['output']);
- if (isset($_REQUEST['sd_clean'])) $url .= '&sd_clean=' . urlencode($_REQUEST['sd_clean']);
- if (isset($_REQUEST['sd_oids'])) $url .= '&sd_oids=' . urlencode($_REQUEST['sd_oids']);
- $url .= "&" . SID;
-
- header("Location: {$url}");
+ include('./dbexport.php');
exit;
}
else {
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS'])) {
header('Content-Type: text/plain');
}
- else {\r
+ else {
header('Content-Type: application/download');
if (isset($extensions[$format]))
if (isset($_REQUEST['query'])) $_REQUEST['query'] = trim(unserialize($_REQUEST['query']));
+ // Set the schema search path
+ if ($data->hasSchemas() && isset($_REQUEST['search_path'])) {
+ $data->setSearchPath(array_map('trim',explode(',',$_REQUEST['search_path'])));
+ }
+
// Set up the dump transaction
$status = $data->beginDump();
$status = $data->endDump();
}
else {
- if (!isset($msg)) $msg = null;
-
// Include application functions
include_once('./libraries/lib.inc.php');
- $misc->printHeader($lang['strexport']);
- echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strexport']}</h2>\n";
- $misc->printMsg($msg);
+ $misc->printHeader($lang['strexport']);
+ $misc->printBody();
+ $misc->printTrail(isset($_REQUEST['subject']) ? $_REQUEST['subject'] : 'database');
+ $misc->printTitle($lang['strexport']);
+ if (isset($msg)) $misc->printMsg($msg);
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">\n";
echo "<table>\n";
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
}
echo "<input type=\"hidden\" name=\"query\" value=\"", htmlspecialchars(serialize($_REQUEST['query'])), "\" />\n";
+ if (isset($_REQUEST['search_path'])) {
+ echo "<input type=\"hidden\" name=\"search_path\" value=\"", htmlspecialchars($_REQUEST['search_path']), "\" />\n";
+ }
echo $misc->form;
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
echo "</form>\n";
* Does an export of a database or a table (via pg_dump)
* to the screen or as a download.
*
- * $Id: dbexport.php,v 1.17.2.1 2005/03/01 10:52:23 jollytoad Exp $
+ * $Id: dbexport.php,v 1.17.2.2 2005/03/29 09:33:47 jollytoad Exp $
*/
// Prevent timeouts on large exports
$server_info = $misc->getServerInfo();
// Set environmental variable for user and password that pg_dump uses
- putenv('PGPASSWORD=' . $server_info['password'];
- putenv('PGUSER=' . $server_info['username'];
+ putenv('PGPASSWORD=' . $server_info['password']);
+ putenv('PGUSER=' . $server_info['username']);
// Prepare command line arguments
$hostname = $server_info['host'];
$port = $server_info['port'];
- // Check if we're doing a cluster-wide dump or just a per-database dump
- if ($_REQUEST['mode'] == 'database') {
- // Get path of the pg_dump executable.
- $exe = $misc->escapeShellCmd($server_info['pg_dump_path']);
- }
- else {
- // Get path of the pg_dumpall executable.
- $exe = $misc->escapeShellCmd($server_info['pg_dumpall_path']);
- }
+ // Are we doing a cluster-wide dump or just a per-database dump
+ $dumpall = ($_REQUEST['subject'] == 'server');
+
+ // Get the path og the pg_dump/pg_dumpall executable
+ $exe = $misc->escapeShellCmd($server_info[$dumpall ? 'pg_dumpall_path' : 'pg_dump_path']);
// Build command for executing pg_dump. '-i' means ignore version differences.
$cmd = $exe . " -i";
$cmd .= " -p " . $misc->escapeShellArg($port);
}
- // Check for a table specified
- if (isset($_REQUEST['table']) && $_REQUEST['mode'] == 'database') {
-
+ // Check for a specified table/view
+ switch ($_REQUEST['subject']) {
+ case 'table':
+ case 'view':
// Obtain the pg_dump version number
$version = array();
preg_match("/(\d+(?:\.\d+)?)(?:\.\d+)?.*$/", exec($exe . " --version"), $version);
// set dump schema as well. Also, mixed case dumping has been fixed
// then..
if (((float) $version[1]) >= 7.4) {
- $cmd .= " -t " . $misc->escapeShellArg($_REQUEST['table']);
+ $cmd .= " -t " . $misc->escapeShellArg($_REQUEST[$_REQUEST['subject']]);
// Even though they're using a schema-enabled pg_dump, the backend database
// may not support schemas.
if ($data->hasSchemas()) {
else {
// This is an annoying hack needed to work around a bug in dumping
// mixed case tables in pg_dump prior to 7.4
- $cmd .= " -t " . $misc->escapeShellArg('"' . $_REQUEST['table'] . '"');
+ $cmd .= " -t " . $misc->escapeShellArg('"' . $_REQUEST[$_REQUEST['subject']] . '"');
}
}
// Check for GZIP compression specified
- if ($_REQUEST['output'] == 'gzipped' && $_REQUEST['mode'] == 'database') {
+ if ($_REQUEST['output'] == 'gzipped' && !$dumpall) {
$cmd .= " -Z 9";
}
break;
}
- if ($_REQUEST['mode'] == 'database') {
+ if (!$dumpall) {
$cmd .= " " . $misc->escapeShellArg($_REQUEST['database']);
}
* @param $return_desc The return link name
* @param $page The current page
*
- * $Id: display.php,v 1.47 2005/02/09 11:26:24 chriskl Exp $
+ * $Id: display.php,v 1.47.2.1 2005/03/29 09:33:48 jollytoad Exp $
*/
// Prevent timeouts on large result sets
// Report views don't set a schema, so we need to disable create view in that case
if (isset($_REQUEST['schema'])) echo " | <a class=\"navlink\" href=\"views.php?action=create&formDefinition=",
urlencode($_REQUEST['query']), "&{$misc->href}\">{$lang['strcreateview']}</a>\n";
- echo " | <a class=\"navlink\" href=\"dataexport.php?query=",
- urlencode($_REQUEST['query']), "&{$misc->href}\">{$lang['strdownload']}</a>\n";
+ echo " | <a class=\"navlink\" href=\"dataexport.php?query=", urlencode($_REQUEST['query']),
+ "&search_path=", urlencode($_REQUEST['search_path']),
+ "&{$misc->href}\">{$lang['strdownload']}</a>\n";
}
// Insert
/**
* List tables in a database
*
- * $Id: tblproperties.php,v 1.62.4.1 2005/03/01 10:47:04 jollytoad Exp $
+ * $Id: tblproperties.php,v 1.62.4.2 2005/03/29 09:33:49 jollytoad Exp $
*/
// Include application functions
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
echo $misc->form;
+ echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n";
echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
echo "</form>\n";
/**
* List views in a database
*
- * $Id: viewproperties.php,v 1.13.4.1 2005/03/01 10:47:04 jollytoad Exp $
+ * $Id: viewproperties.php,v 1.13.4.2 2005/03/29 09:33:49 jollytoad Exp $
*/
// Include application functions
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
echo $misc->form;
- echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['view']), "\" />\n";
+ echo "<input type=\"hidden\" name=\"subject\" value=\"view\" />\n";
+ echo "<input type=\"hidden\" name=\"view\" value=\"", htmlspecialchars($_REQUEST['view']), "\" />\n";
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
echo "</form>\n";
}