1<?php 2 3function get_cgi_path() /* {{{ */ 4{ 5 $php = getenv("TEST_PHP_EXECUTABLE"); 6 $php_escaped = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); 7 8 $cli = false; 9 $cgi = false; 10 11 if (file_exists($php) && is_executable($php)) { 12 $version = `$php_escaped -n -v`; 13 if (strstr($version, "(cli)")) { 14 /* that's cli */ 15 $cli = true; 16 } else if (strpos($version, "(cgi")) { 17 /* that's cgi */ 18 return $php; 19 } 20 } 21 22 if ($cli) { 23 /* trying to guess ... */ 24 $php_path = $php; 25 if (defined("PHP_WINDOWS_VERSION_MAJOR")) { 26 /* On Windows it should be in the same dir as php.exe in most of the cases. */ 27 $cgi_path = dirname($php) . "/php-cgi.exe"; 28 if (is_executable($cgi_path)) { 29 return $cgi_path; 30 } 31 } else { 32 /* Try in the same path as php, for the case where php is installed. */ 33 $cgi_path = dirname($php) . "/php-cgi"; 34 if (is_executable($cgi_path)) { 35 return $cgi_path; 36 } 37 38 /* Try sapi/cgi/php-cgi, for the case where php is not installed. */ 39 $cgi_path = dirname($php, 3) . "/sapi/cgi/php-cgi"; 40 if (is_executable($cgi_path)) { 41 return $cgi_path; 42 } 43 } 44 return false; 45 } 46 /* uhm? what's that then? */ 47 return false; 48} 49/* }}} */ 50 51function reset_env_vars() /* {{{ */ 52{ 53 putenv("REDIRECT_STATUS"); 54 putenv("QUERY_STRING"); 55 putenv("PATH_TRANSLATED"); 56 putenv("SCRIPT_FILENAME"); 57 putenv("SERVER_SOFTWARE"); 58 putenv("SERVER_NAME"); 59 putenv("GATEWAY_INTERFACE"); 60 putenv("REQUEST_METHOD"); 61} 62/* }}} */ 63 64?> 65