includes/functions.php
changeset 1310 41ac3758ba79
parent 1301 bd9e124f5904
child 1322 8496dd47b87c
--- a/includes/functions.php	Thu Oct 28 03:32:57 2010 -0400
+++ b/includes/functions.php	Mon Nov 15 16:58:05 2010 -0500
@@ -5274,6 +5274,21 @@
 }
 
 /**
+ * Return the OS's PATH variable.
+ * @return string
+ */
+
+function get_system_path()
+{
+	$path = ( isset($_ENV['PATH']) ) ? $_ENV['PATH'] : ( isset($_SERVER['PATH']) ? $_SERVER['PATH'] : false );
+	if ( !$path )
+		// couldn't get OS's PATH
+		return false;
+		
+	return $path;
+}
+
+/**
  * Implementation of the "which" command in native PHP.
  * @param string command
  * @return string path to executable, or false on failure
@@ -5281,15 +5296,15 @@
 
 function which($executable)
 {
-	$path = ( isset($_ENV['PATH']) ) ? $_ENV['PATH'] : ( isset($_SERVER['PATH']) ? $_SERVER['PATH'] : false );
-	if ( !$path )
-		// couldn't get OS's PATH
+	$path = get_system_path();
+	if ( empty($paths) )
 		return false;
-		
+	
 	$win32 = ( PHP_OS == 'WINNT' || PHP_OS == 'WIN32' );
 	$extensions = $win32 ? array('.exe', '.com', '.bat') : array('');
 	$separator = $win32 ? ';' : ':';
 	$paths = explode($separator, $path);
+	
 	foreach ( $paths as $dir )
 	{
 		foreach ( $extensions as $ext )