Back to index

php5  5.3.10
include.inc
Go to the documentation of this file.
00001 <?php
00002 
00003 function get_cgi_path() /* {{{ */
00004 {
00005        $php = getenv("TEST_PHP_EXECUTABLE");
00006 
00007        $cli = false;
00008        $cgi = false;
00009 
00010        if (file_exists($php) && is_executable($php)) {
00011               $version = `$php -n -v`;
00012               if (strstr($version, "(cli)")) {
00013                      /* that's cli */
00014                      $cli = true;
00015               } else if (strpos($version, "(cgi")) {
00016                      /* that's cgi */
00017                      return $php;
00018               }
00019        }
00020 
00021        if ($cli) {
00022               /* trying to guess ... */
00023               $php_path = $php;
00024               for ($i = 0; $i < 2; $i++) {
00025                      $slash_pos = strrpos($php_path, "/");
00026                      if ($slash_pos) {
00027                             $php_path = substr($php_path, 0, $slash_pos);
00028                      } else {
00029                             return FALSE;
00030                      }
00031               }
00032 
00033               if ($php_path && is_dir($php_path) && file_exists($php_path."/cgi/php-cgi") && is_executable($php_path."/cgi/php-cgi")) { 
00034                      /* gotcha */
00035                      return $php_path."/cgi/php-cgi";
00036               }
00037               return false;
00038        }
00039        /* uhm? what's that then? */
00040        return false;
00041 }
00042 /* }}} */
00043 
00044 function reset_env_vars() /* {{{ */
00045 {
00046        putenv("REDIRECT_STATUS");
00047        putenv("QUERY_STRING");
00048        putenv("PATH_TRANSLATED");
00049        putenv("SCRIPT_FILENAME");
00050        putenv("SERVER_SOFTWARE");
00051        putenv("SERVER_NAME");
00052        putenv("GATEWAY_INTERFACE");
00053        putenv("REQUEST_METHOD");
00054 }
00055 /* }}} */
00056 
00057 ?>