[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/admin/check/ -> check_php_inc.php (source)

   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   * @package MantisBT
  19   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  20   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  21   * @link http://www.mantisbt.org
  22   *
  23   * @uses check_api.php
  24   * @uses config_api.php
  25   * @uses utility_api.php
  26   */
  27  
  28  if ( !defined( 'CHECK_PHP_INC_ALLOW' ) ) {
  29      return;
  30  }
  31  
  32  require_once ( 'check_api.php' );
  33  require_api( 'config_api.php' );
  34  require_api( 'utility_api.php' );
  35  
  36  check_print_section_header_row( 'PHP' );
  37  
  38  check_print_test_row(
  39      'Version of <a href="http://en.wikipedia.org/wiki/PHP">PHP</a> installed is at least ' . PHP_MIN_VERSION,
  40      version_compare( phpversion(), PHP_MIN_VERSION, '>=' ),
  41      'PHP version ' . phpversion() . ' is currently installed on this server.'
  42  );
  43  
  44  $t_extensions_required = array(
  45      'date',
  46      'hash',
  47      'pcre',
  48      'Reflection',
  49      'session'
  50  );
  51  
  52  foreach( $t_extensions_required as $t_extension ) {
  53      check_print_test_row(
  54          $t_extension . ' PHP extension is available',
  55          extension_loaded( $t_extension ),
  56          array( false => 'MantisBT requires the ' . $t_extension . ' extension to either be compiled into PHP or loaded as an extension.' )
  57      );
  58  }
  59  
  60  check_print_test_warn_row(
  61      '<a href="http://en.wikipedia.org/wiki/Xdebug">Xdebug</a> extension is not loaded',
  62      !extension_loaded( 'xdebug' ),
  63      array( false => 'For security reasons this extension should not be loaded on production and Internet facing servers.' )
  64  );
  65  
  66  $t_variables_order = ini_get( 'variables_order' );
  67  check_print_test_row(
  68      'variables_order php.ini directive contains GPCS',
  69      stripos( $t_variables_order, 'G' ) !== false &&
  70          stripos( $t_variables_order, 'P' ) !== false &&
  71          stripos( $t_variables_order, 'C' ) !== false &&
  72          stripos( $t_variables_order, 'S' ) !== false,
  73      array( false => 'The value of this directive is currently: ' . $t_variables_order )
  74  );
  75  
  76  check_print_test_row(
  77      'magic_quotes_gpc php.ini directive is disabled',
  78      !( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ),
  79      array( false => 'PHP\'s magic quotes feature is <a href="http://www.php.net/manual/en/security.magicquotes.whynot.php">deprecated in PHP 5.3.0</a> and should not be used.' )
  80  );
  81  
  82  check_print_test_row(
  83      'register_globals php.ini directive is disabled',
  84      !ini_get_bool( 'register_globals' ),
  85      array( false => 'PHP\'s register globals feature is <a href="http://php.net/manual/en/security.globals.php">deprecated in PHP 5.3.0</a> and should not be used.' )
  86  );
  87  
  88  check_print_test_warn_row(
  89      'register_argc_argv php.ini directive is disabled',
  90      !ini_get_bool( 'register_argc_argv' ),
  91      array( false => 'This directive should be disabled to increase performance (it only affects PHP in CLI mode).' )
  92  );
  93  
  94  check_print_test_warn_row(
  95      'register_long_arrays php.ini directive is disabled',
  96      !ini_get_bool( 'register_long_arrays' ),
  97      array( false => 'This directive is deprecated in PHP 5.3.0 and should be disabled for performance reasons.' )
  98  );
  99  
 100  check_print_test_warn_row(
 101      'auto_globals_jit php.ini directive is enabled',
 102      ini_get_bool( 'auto_globals_jit' ),
 103      array( false => 'This directive is currently disabled: enable it for a performance gain.' )
 104  );
 105  
 106  check_print_test_warn_row(
 107      'display_errors php.ini directive is disabled',
 108      !ini_get_bool( 'display_errors' ),
 109      array( false => 'For security reasons this directive should be disabled on all production and Internet facing servers.' )
 110  );
 111  
 112  check_print_test_warn_row(
 113      'display_startup_errors php.ini directive is disabled',
 114      !ini_get_bool( 'display_startup_errors' ),
 115      array( false => 'For security reasons this directive should be disabled on all production and Internet facing servers.' )
 116  );
 117  
 118  check_print_test_warn_row(
 119      'PHP errors are being logged or reported',
 120      !( ini_get_bool( 'display_errors' ) || ini_get_bool( 'log_errors' ) ),
 121      array( false => 'PHP is not currently set to log or report errors and thus you may be unaware of PHP errors that occur.' )
 122  );
 123  
 124  check_print_info_row(
 125      'php.ini directive: memory_limit',
 126      htmlentities( ini_get_number( 'memory_limit' ) ) . ' bytes'
 127  );
 128  
 129  check_print_info_row(
 130      'php.ini directive: post_max_size',
 131      htmlentities( ini_get_number( 'post_max_size' ) ) . ' bytes'
 132  );
 133  
 134  check_print_test_row(
 135      'memory_limit php.ini directive is at least equal to the post_max_size directive',
 136      ini_get_number( 'memory_limit' ) >= ini_get_number( 'post_max_size' ),
 137      array( false => 'The current value of the memory_limit directive is ' . htmlentities( ini_get_number( 'memory_limit' ) ) . ' bytes. This value needs to be at least equal to the post_max_size directive value of ' . htmlentities( ini_get_number( 'post_max_size' ) ) . ' bytes.' )
 138  );
 139  
 140  check_print_info_row(
 141      'File uploads are enabled (php.ini directive: file_uploads)',
 142      ini_get_bool( 'file_uploads' ) ? 'Yes' : 'No'
 143  );
 144  
 145  check_print_info_row(
 146      'php.ini directive: upload_max_filesize',
 147      htmlentities( ini_get_number( 'upload_max_filesize' ) ) . ' bytes'
 148  );
 149  
 150  check_print_test_row(
 151      'post_max_size php.ini directive is at least equal to the upload_max_size directive',
 152      ini_get_number( 'post_max_size' ) >= ini_get_number( 'upload_max_filesize' ),
 153      array( false => 'The current value of the post_max_size directive is ' . htmlentities( ini_get_number( 'post_max_size' ) ) . ' bytes. This value needs to be at least equal to the upload_max_size directive value of ' . htmlentities( ini_get_number( 'upload_max_filesize' ) ) . ' bytes.' )
 154  );
 155  
 156  $t_disabled_functions = explode( ',', ini_get( 'disable_functions' ) );
 157  foreach( $t_disabled_functions as $t_disabled_function ) {
 158      $t_disabled_function = trim( $t_disabled_function );
 159      if( $t_disabled_function ) {
 160          check_print_test_warn_row(
 161              '<em>' . $t_disabled_function . '</em> function is enabled',
 162              false,
 163              'This function has been disabled by the disable_functions php.ini directive. MantisBT may not operate correctly with this function disabled.'
 164          );
 165      }
 166  }
 167  
 168  $t_disabled_classes = explode( ',', ini_get( 'disable_classes' ) );
 169  foreach( $t_disabled_classes as $t_disabled_class ) {
 170      $t_disabled_class = trim( $t_disabled_class );
 171      if( $t_disabled_class ) {
 172          check_print_test_warn_row(
 173              '<em>' . $t_disabled_class . '</em> class is enabled',
 174              false,
 175              'This class has been disabled by the disable_classes php.ini directive. MantisBT may not operate correctly with this class disabled.'
 176  
 177          );
 178      }
 179  }
 180  
 181  # Print additional information from php.ini to assist debugging (see http://www.php.net/manual/en/ini.list.php)
 182  $t_vars = array(
 183      'open_basedir',
 184      'extension',
 185      'upload_tmp_dir',
 186      'max_file_uploads',
 187      'date.timezone'
 188  );
 189  
 190  while( list( $t_foo, $t_var ) = each( $t_vars ) ) {
 191      $t_value = ini_get( $t_var );
 192      if( $t_value != '' ) {
 193          check_print_info_row( 'php.ini directive: ' . $t_var, htmlentities( $t_value ) );
 194      }
 195  }


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7