/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.95 2004/11/02 11:46:53 soranzo Exp $
+ * $Id: Misc.php,v 1.96 2004/12/06 03:03:00 chriskl Exp $
*/
class Misc {
return false;
}
}
+
+ /**
+ * Function to escape command line parameters
+ * @param $str The string to escape
+ * @return The escaped string
+ */
+ function escapeShellArg($str) {
+ global $data;
+
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ $data->fieldClean($str);
+ return '"' . $str . '"';
+ }
+ else
+ return escapeshellarg($str);
+ }
+
+ /**
+ * Function to escape command line programs
+ * @param $str The string to escape
+ * @return The escaped string
+ */
+ function escapeShellCmd($str) {
+ global $data;
+
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ $data->fieldClean($str);
+ return '"' . $str . '"';
+ }
+ else
+ return escapeshellcmd($str);
+ }
}
?>
* Does an export of a database or a table (via pg_dump)
* to the screen or as a download.
*
- * $Id: dbexport.php,v 1.14 2004/11/04 02:56:51 chriskl Exp $
+ * $Id: dbexport.php,v 1.15 2004/12/06 03:03:00 chriskl Exp $
*/
// Include application functions
// 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 = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path']);
+ $exe = $misc->escapeShellCmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dump_path']);
}
else {
// Get path of the pg_dumpall executable.
- $exe = escapeshellcmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dumpall_path']);
+ $exe = $misc->escapeShellCmd($conf['servers'][$_SESSION['webdbServerID']]['pg_dumpall_path']);
}
// Build command for executing pg_dump. '-i' means ignore version differences.
$cmd = $exe . " -i";
if ($hostname !== null && $hostname != '') {
- $cmd .= " -h " . escapeshellarg($hostname);
+ $cmd .= " -h " . $misc->escapeShellArg($hostname);
}
if ($port !== null && $port != '') {
- $cmd .= " -p " . escapeshellarg($port);
+ $cmd .= " -p " . $misc->escapeShellArg($port);
}
// Check for a table specified
// set dump schema as well. Also, mixed case dumping has been fixed
// then..
if (((float) $version[1]) >= 7.4) {
- $cmd .= " -t " . escapeshellarg($_REQUEST['table']);
- $cmd .= " -n " . escapeshellarg($_REQUEST['schema']);
+ $cmd .= " -t " . $misc->escapeShellArg($_REQUEST['table']);
+ $cmd .= " -n " . $misc->escapeShellArg($_REQUEST['schema']);
}
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 " . escapeshellarg('"' . $_REQUEST['table'] . '"');
+ $cmd .= " -t " . $misc->escapeShellArg('"' . $_REQUEST['table'] . '"');
}
}
}
if ($_REQUEST['mode'] == 'database') {
- $cmd .= " " . escapeshellarg($_REQUEST['database']);
+ $cmd .= " " . $misc->escapeShellArg($_REQUEST['database']);
}
// Execute command and return the output to the screen