include.inc 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. for ($i = 0; $i < 2; $i++) {
  21. $slash_pos = strrpos($php_path, "/");
  22. if ($slash_pos) {
  23. $php_path = substr($php_path, 0, $slash_pos);
  24. } else {
  25. return FALSE;
  26. }
  27. }
  28. if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) {
  29. /* gotcha */
  30. return $php_path."/cgi/php-cgi";
  31. }
  32. return false;
  33. }
  34. /* uhm? what's that then? */
  35. return false;
  36. }
  37. /* }}} */
  38. function reset_env_vars() /* {{{ */
  39. {
  40. putenv("REDIRECT_STATUS");
  41. putenv("QUERY_STRING");
  42. putenv("PATH_TRANSLATED");
  43. putenv("SCRIPT_FILENAME");
  44. putenv("SERVER_SOFTWARE");
  45. putenv("SERVER_NAME");
  46. putenv("GATEWAY_INTERFACE");
  47. putenv("REQUEST_METHOD");
  48. }
  49. /* }}} */
  50. ?>