attempt to fix dumping with new 8.0 beta native on windows. this may cause problems...
authorchriskl <chriskl>
Mon, 6 Dec 2004 03:03:00 +0000 (03:03 +0000)
committerchriskl <chriskl>
Mon, 6 Dec 2004 03:03:00 +0000 (03:03 +0000)
classes/Misc.php
dbexport.php

index 8815844e6e76d5291fd2c7f26c0f585766f2cb53..3703671e537fbb8a55f70e1eb91589eae17ed5ba 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * 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);
+               }
        }
 ?>
index f8fa5315c05b434e9cf3b436813efaf8c53b1c35..31793ec9f5e4df462d852f6ac50626572fccd66c 100644 (file)
@@ -3,7 +3,7 @@
         * 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