1<?php 2# MantisBT - A PHP based bugtracking system 3 4# MantisBT is free software: you can redistribute it and/or modify 5# it under the terms of the GNU General Public License as published by 6# the Free Software Foundation, either version 2 of the License, or 7# (at your option) any later version. 8# 9# MantisBT is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17/** 18 * PHP Compatibility API 19 * 20 * Provides functions to assist with backwards compatibility between PHP 21 * versions. 22 * 23 * @package CoreAPI 24 * @subpackage PHPCompatibilityAPI 25 * @copyright Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 26 * @copyright Copyright 2002 MantisBT Team - mantisbt-dev@lists.sourceforge.net 27 * @link http://www.mantisbt.org 28 */ 29 30/** 31 * Determine if PHP is running in CLI or CGI mode and return the mode. 32 * @return int PHP mode 33 */ 34function php_mode() { 35 static $s_mode = null; 36 37 if( is_null( $s_mode ) ) { 38 # Check to see if this is CLI mode or CGI mode 39 if( isset( $_SERVER['SERVER_ADDR'] ) 40 || isset( $_SERVER['LOCAL_ADDR'] ) 41 || isset( $_SERVER['REMOTE_ADDR'] ) ) { 42 $s_mode = PHP_CGI; 43 } else { 44 $s_mode = PHP_CLI; 45 } 46 } 47 48 return $s_mode; 49} 50