include.inc 1.6 KB

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