From 595b892e25bdc787bf3a47d64fe291ce3746fdbb Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 21 Aug 2004 14:14:58 +0000 Subject: [PATCH] Hey! Stop breaking my functions! --- includes/GlobalFunctions.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d969a05272..5cb78fb839 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -565,6 +565,8 @@ function wfPurgeSquidServers ($urlArr) { } # Windows-compatible version of escapeshellarg() +# Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() +# function puts single quotes in regardless of OS function wfEscapeShellArg( ) { $args = func_get_args(); @@ -576,11 +578,11 @@ function wfEscapeShellArg( ) } else { $first = false; } - - if ( function_exists( 'escapeshellarg' ) ) { - $retVal .= escapeshellarg( $arg ); - } else { + + if ( wfIsWindows() ) { $retVal .= '"' . str_replace( '"','\"', $arg ) . '"'; + } else { + $retVal .= escapeshellarg( $arg ); } } return $retVal; @@ -838,4 +840,12 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) { } } +function wfIsWindows() { + if (substr(php_uname(), 0, 7) == 'Windows') { + return true; + } else { + return false; + } +} + ?> -- 2.20.1