b2evolution PHP Cross Reference Blogging Systems

Source: /inc/_init_base.inc.php - 274 lines - 8061 bytes - Text - Print

Description: This file initializes everything BUT the blog! It is useful when you want to do very customized templates! It is also called by more complete initializers.

   1  <?php
   2  /**
   3   * This file initializes everything BUT the blog!
   4   *
   5   * It is useful when you want to do very customized templates!
   6   * It is also called by more complete initializers.
   7   *
   8   * This file is part of the evoCore framework - {@link http://evocore.net/}
   9   * See also {@link http://sourceforge.net/projects/evocms/}.
  10   *
  11   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
  12   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  13   * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}.
  14   *
  15   * {@internal License choice
  16   * - If you have received this file as part of a package, please find the license.txt file in
  17   *   the same folder or the closest folder above for complete license terms.
  18   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  19   *   then you must choose one of the following licenses before using the file:
  20   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  21   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  22   * }}
  23   *
  24   * {@internal Open Source relicensing agreement:
  25   * Daniel HAHLER grants Francois PLANQUE the right to license
  26   * Daniel HAHLER's contributions to this file and the b2evolution project
  27   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  28   *
  29   * Matt FOLLETT grants Francois PLANQUE the right to license
  30   * Matt FOLLETT's contributions to this file and the b2evolution project
  31   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  32   * }}
  33   *
  34   * @package evocore
  35   *
  36   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  37   * @author fplanque: Francois PLANQUE
  38   * @author blueyed: Daniel HAHLER
  39   * @author mfollett: Matt FOLLETT
  40   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  41   *
  42   * @version $Id: _init_base.inc.php 6136 2014-03-08 07:59:48Z manuel $
  43   */
  44  if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );
  45  
  46  /**
  47   * @global boolean Are we running on Command Line Interface instead of a web request?
  48   */
  49  $is_cli = empty($_SERVER['SERVER_SOFTWARE']) ? true : false;
  50  $is_web = ! $is_cli;
  51  // echo ($is_cli ? 'cli' : 'web' );
  52  
  53  
  54  if( $maintenance_mode )
  55  { // Maintenance mode with a conf switch
  56      header('HTTP/1.0 503 Service Unavailable');
  57      echo '<h1>503 Service Unavailable</h1>';
  58      die( 'The site is temporarily down for maintenance.' );
  59  }
  60  elseif( file_exists( $conf_path.'imaintenance.html' ) )
  61  { // Maintenance mode with a file - "imaintenance.html" with an "i" prevents access to the site but NOT to install
  62      header('HTTP/1.0 503 Service Unavailable');
  63      readfile( $conf_path.'imaintenance.html' );
  64      die();
  65  }
  66  
  67  
  68  /**
  69   * Absolute Unix timestamp for server
  70   * @global int $servertimenow
  71   */
  72  $servertimenow = time();
  73  
  74  
  75  /**
  76   * Security check for older PHP versions
  77   * Contributed by counterpoint / MAMBO team
  78   */
  79  {
  80      $protects = array( '_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION' );
  81      foreach( $protects as $protect )
  82      {
  83          if(  in_array( $protect, array_keys($_REQUEST) )
  84              || in_array( $protect, array_keys($_GET) )
  85              || in_array( $protect, array_keys($_POST) )
  86              || in_array( $protect, array_keys($_COOKIE) )
  87              || in_array( $protect, array_keys($_FILES) ) )
  88          {
  89              require_once $inc_path.'/_core/_misc.funcs.php';
  90              bad_request_die( 'Unacceptable params.' );
  91          }
  92      }
  93  }
  94  
  95  /**
  96   * Request/Transaction name, used for performance monitoring.
  97   */
  98  $request_transaction_name = '';
  99  
 100  
 101  if( !$config_is_done )
 102  { // base config is not done!
 103      $error_message = 'Base configuration is not done! (see /conf/_basic_config.php)';
 104  }
 105  elseif( !isset( $locales[$default_locale] ) )
 106  {
 107      $error_message = 'The default locale '.var_export( $default_locale, true ).' does not exist! (see /conf/_locales.php)';
 108  }
 109  if( isset( $error_message ) )
 110  { // error & exit
 111      require dirname(__FILE__).'/../skins_adm/conf_error.main.php';
 112  }
 113  
 114  
 115  /**
 116   * Class loader.
 117   */
 118  require_once $inc_path.'_core/_class'.floor(PHP_VERSION).'.funcs.php';
 119  
 120  
 121  /**
 122   * Locale related functions
 123   */
 124  require_once $inc_path.'locales/_locale.funcs.php';
 125  
 126  
 127  /**
 128   * Miscellaneous functions
 129   */
 130  require_once $inc_path.'_core/_misc.funcs.php';
 131  
 132  
 133  /**
 134   * Debug message log for debugging only (initialized here).
 135   *
 136   * @global Log|Log_noop $Debuglog
 137   */
 138  if( $debug )
 139  {
 140      load_class( '_core/model/_log.class.php', 'Log' );
 141      $Debuglog = new Log();
 142  }
 143  else
 144  {
 145      load_class( '_core/model/_log.class.php', 'Log_noop' );
 146      $Debuglog = new Log_noop();
 147  }
 148  
 149  
 150  /**
 151   * Info & error message log for end user (initialized here)
 152   * @global Log $Messages
 153   */
 154  load_class( '_core/model/_messages.class.php', 'Messages' );
 155  $Messages = new Messages();
 156  
 157  
 158  /*
 159   * Start timer:
 160   */
 161  load_class( '_core/model/_timer.class.php', 'Timer' );
 162  $Timer = new Timer('total');
 163  $Timer->resume( '_init_base' );
 164  $Timer->resume( '_MAIN.inc' );
 165  
 166  
 167  
 168  // the weekdays and the months..
 169  $weekday[0] = NT_('Sunday');
 170  $weekday[1] = NT_('Monday');
 171  $weekday[2] = NT_('Tuesday');
 172  $weekday[3] = NT_('Wednesday');
 173  $weekday[4] = NT_('Thursday');
 174  $weekday[5] = NT_('Friday');
 175  $weekday[6] = NT_('Saturday');
 176  
 177  // the weekdays short form (typically 3 letters)
 178  // TRANS: abbrev. for Sunday
 179  $weekday_abbrev[0] = NT_('Sun');
 180  // TRANS: abbrev. for Monday
 181  $weekday_abbrev[1] = NT_('Mon');
 182  // TRANS: abbrev. for Tuesday
 183  $weekday_abbrev[2] = NT_('Tue');
 184  // TRANS: abbrev. for Wednesday
 185  $weekday_abbrev[3] = NT_('Wed');
 186  // TRANS: abbrev. for Thursday
 187  $weekday_abbrev[4] = NT_('Thu');
 188  // TRANS: abbrev. for Friday
 189  $weekday_abbrev[5] = NT_('Fri');
 190  // TRANS: abbrev. for Saturday
 191  $weekday_abbrev[6] = NT_('Sat');
 192  
 193  // the weekdays even shorter form (typically 1 letter)
 194  // TRANS: abbrev. for Sunday
 195  $weekday_letter[0] = NT_(' S ');
 196  // TRANS: abbrev. for Monday
 197  $weekday_letter[1] = NT_(' M ');
 198  // TRANS: abbrev. for Tuesday
 199  $weekday_letter[2] = NT_(' T ');
 200  // TRANS: abbrev. for Wednesday
 201  $weekday_letter[3] = NT_(' W ');
 202  // TRANS: abbrev. for Thursday
 203  $weekday_letter[4] = NT_(' T  ');
 204  // TRANS: abbrev. for Friday
 205  $weekday_letter[5] = NT_(' F ');
 206  // TRANS: abbrev. for Saturday
 207  $weekday_letter[6] = NT_(' S  ');
 208  
 209  // the months
 210  $month['00'] = '\?\?';    // This can happen when importing junk dates from WordPress
 211  $month['01'] = NT_('January');
 212  $month['02'] = NT_('February');
 213  $month['03'] = NT_('March');
 214  $month['04'] = NT_('April');
 215  // TRANS: space at the end only to differentiate from short form. You don't need to keep it in the translation.
 216  $month['05'] = NT_('May ');
 217  $month['06'] = NT_('June');
 218  $month['07'] = NT_('July');
 219  $month['08'] = NT_('August');
 220  $month['09'] = NT_('September');
 221  $month['10'] = NT_('October');
 222  $month['11'] = NT_('November');
 223  $month['12'] = NT_('December');
 224  
 225  // the months short form (typically 3 letters)
 226  // TRANS: abbrev. for January
 227  $month_abbrev['01'] = NT_('Jan');
 228  // TRANS: abbrev. for February
 229  $month_abbrev['02'] = NT_('Feb');
 230  // TRANS: abbrev. for March
 231  $month_abbrev['03'] = NT_('Mar');
 232  // TRANS: abbrev. for April
 233  $month_abbrev['04'] = NT_('Apr');
 234  // TRANS: abbrev. for May
 235  $month_abbrev['05'] = NT_('May');
 236  // TRANS: abbrev. for June
 237  $month_abbrev['06'] = NT_('Jun');
 238  // TRANS: abbrev. for July
 239  $month_abbrev['07'] = NT_('Jul');
 240  // TRANS: abbrev. for August
 241  $month_abbrev['08'] = NT_('Aug');
 242  // TRANS: abbrev. for September
 243  $month_abbrev['09'] = NT_('Sep');
 244  // TRANS: abbrev. for October
 245  $month_abbrev['10'] = NT_('Oct');
 246  // TRANS: abbrev. for November
 247  $month_abbrev['11'] = NT_('Nov');
 248  // TRANS: abbrev. for December
 249  $month_abbrev['12'] = NT_('Dec');
 250  
 251  
 252  /**
 253   * IDs of items for which we should increment the view count on shutdown
 254   *
 255   * @var array
 256   * @todo fp> find a better place to init this
 257   */
 258  $shutdown_count_item_views = array();
 259  
 260  
 261  /**
 262   * Load modules.
 263   *
 264   * This initializes table name aliases and is required before trying to connect to the DB.
 265   */
 266  load_class( '_core/model/_module.class.php', 'Module' );
 267  foreach( $modules as $module )
 268  {
 269      require_once $inc_path.$module.'/_'.$module.'.init.php';
 270  }
 271  
 272  $Timer->pause( '_init_base' );
 273  
 274  ?>

title

Description

title

Description

title

Description

title

title

Body