PageRenderTime 57ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/blogs/inc/_init_base.inc.php

https://github.com/blueyed/b2evolution
PHP | 265 lines | 117 code | 33 blank | 115 comment | 10 complexity | b07946db3036d9f4f10996de865298bd MD5 | raw file
  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 6135 2014-03-08 07:54:05Z manuel $
  43. */
  44. if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );
  45. /**
  46. * @global boolean Are we running on Command Line Interface instead of a web request?
  47. */
  48. $is_cli = empty($_SERVER['SERVER_SOFTWARE']) ? true : false;
  49. $is_web = ! $is_cli;
  50. // echo ($is_cli ? 'cli' : 'web' );
  51. if( $maintenance_mode )
  52. { // Maintenance mode with a conf switch
  53. header('HTTP/1.0 503 Service Unavailable');
  54. echo '<h1>503 Service Unavailable</h1>';
  55. die( 'The site is temporarily down for maintenance.' );
  56. }
  57. elseif( file_exists( $conf_path.'imaintenance.html' ) )
  58. { // Maintenance mode with a file - "imaintenance.html" with an "i" prevents access to the site but NOT to install
  59. header('HTTP/1.0 503 Service Unavailable');
  60. readfile( $conf_path.'imaintenance.html' );
  61. die();
  62. }
  63. /**
  64. * Absolute Unix timestamp for server
  65. * @global int $servertimenow
  66. */
  67. $servertimenow = time();
  68. /**
  69. * Security check for older PHP versions
  70. * Contributed by counterpoint / MAMBO team
  71. */
  72. {
  73. $protects = array( '_REQUEST', '_GET', '_POST', '_COOKIE', '_FILES', '_SERVER', '_ENV', 'GLOBALS', '_SESSION' );
  74. foreach( $protects as $protect )
  75. {
  76. if( in_array( $protect, array_keys($_REQUEST) )
  77. || in_array( $protect, array_keys($_GET) )
  78. || in_array( $protect, array_keys($_POST) )
  79. || in_array( $protect, array_keys($_COOKIE) )
  80. || in_array( $protect, array_keys($_FILES) ) )
  81. {
  82. require_once $inc_path.'/_core/_misc.funcs.php';
  83. bad_request_die( 'Unacceptable params.' );
  84. }
  85. }
  86. }
  87. /**
  88. * Request/Transaction name, used for performance monitoring.
  89. */
  90. $request_transaction_name = '';
  91. if( !$config_is_done )
  92. { // base config is not done!
  93. $error_message = 'Base configuration is not done! (see /conf/_basic_config.php)';
  94. }
  95. elseif( !isset( $locales[$default_locale] ) )
  96. {
  97. $error_message = 'The default locale '.var_export( $default_locale, true ).' does not exist! (see /conf/_locales.php)';
  98. }
  99. if( isset( $error_message ) )
  100. { // error & exit
  101. require dirname(__FILE__).'/../skins_adm/conf_error.main.php';
  102. }
  103. /**
  104. * Class loader.
  105. */
  106. require_once $inc_path.'_core/_class'.floor(PHP_VERSION).'.funcs.php';
  107. /**
  108. * Locale related functions
  109. */
  110. require_once $inc_path.'locales/_locale.funcs.php';
  111. /**
  112. * Miscellaneous functions
  113. */
  114. require_once $inc_path.'_core/_misc.funcs.php';
  115. /**
  116. * Debug message log for debugging only (initialized here).
  117. *
  118. * @global Log|Log_noop $Debuglog
  119. */
  120. if( $debug )
  121. {
  122. load_class( '_core/model/_log.class.php', 'Log' );
  123. $Debuglog = new Log();
  124. }
  125. else
  126. {
  127. load_class( '_core/model/_log.class.php', 'Log_noop' );
  128. $Debuglog = new Log_noop();
  129. }
  130. /**
  131. * Info & error message log for end user (initialized here)
  132. * @global Log $Messages
  133. */
  134. load_class( '_core/model/_messages.class.php', 'Messages' );
  135. $Messages = new Messages();
  136. /*
  137. * Start timer:
  138. */
  139. load_class( '_core/model/_timer.class.php', 'Timer' );
  140. $Timer = new Timer('total');
  141. $Timer->resume( '_init_base' );
  142. $Timer->resume( '_MAIN.inc' );
  143. // the weekdays and the months..
  144. $weekday[0] = NT_('Sunday');
  145. $weekday[1] = NT_('Monday');
  146. $weekday[2] = NT_('Tuesday');
  147. $weekday[3] = NT_('Wednesday');
  148. $weekday[4] = NT_('Thursday');
  149. $weekday[5] = NT_('Friday');
  150. $weekday[6] = NT_('Saturday');
  151. // the weekdays short form (typically 3 letters)
  152. // TRANS: abbrev. for Sunday
  153. $weekday_abbrev[0] = NT_('Sun');
  154. // TRANS: abbrev. for Monday
  155. $weekday_abbrev[1] = NT_('Mon');
  156. // TRANS: abbrev. for Tuesday
  157. $weekday_abbrev[2] = NT_('Tue');
  158. // TRANS: abbrev. for Wednesday
  159. $weekday_abbrev[3] = NT_('Wed');
  160. // TRANS: abbrev. for Thursday
  161. $weekday_abbrev[4] = NT_('Thu');
  162. // TRANS: abbrev. for Friday
  163. $weekday_abbrev[5] = NT_('Fri');
  164. // TRANS: abbrev. for Saturday
  165. $weekday_abbrev[6] = NT_('Sat');
  166. // the weekdays even shorter form (typically 1 letter)
  167. // TRANS: abbrev. for Sunday
  168. $weekday_letter[0] = NT_(' S ');
  169. // TRANS: abbrev. for Monday
  170. $weekday_letter[1] = NT_(' M ');
  171. // TRANS: abbrev. for Tuesday
  172. $weekday_letter[2] = NT_(' T ');
  173. // TRANS: abbrev. for Wednesday
  174. $weekday_letter[3] = NT_(' W ');
  175. // TRANS: abbrev. for Thursday
  176. $weekday_letter[4] = NT_(' T ');
  177. // TRANS: abbrev. for Friday
  178. $weekday_letter[5] = NT_(' F ');
  179. // TRANS: abbrev. for Saturday
  180. $weekday_letter[6] = NT_(' S ');
  181. // the months
  182. $month['00'] = '\?\?'; // This can happen when importing junk dates from WordPress
  183. $month['01'] = NT_('January');
  184. $month['02'] = NT_('February');
  185. $month['03'] = NT_('March');
  186. $month['04'] = NT_('April');
  187. // TRANS: space at the end only to differentiate from short form. You don't need to keep it in the translation.
  188. $month['05'] = NT_('May ');
  189. $month['06'] = NT_('June');
  190. $month['07'] = NT_('July');
  191. $month['08'] = NT_('August');
  192. $month['09'] = NT_('September');
  193. $month['10'] = NT_('October');
  194. $month['11'] = NT_('November');
  195. $month['12'] = NT_('December');
  196. // the months short form (typically 3 letters)
  197. // TRANS: abbrev. for January
  198. $month_abbrev['01'] = NT_('Jan');
  199. // TRANS: abbrev. for February
  200. $month_abbrev['02'] = NT_('Feb');
  201. // TRANS: abbrev. for March
  202. $month_abbrev['03'] = NT_('Mar');
  203. // TRANS: abbrev. for April
  204. $month_abbrev['04'] = NT_('Apr');
  205. // TRANS: abbrev. for May
  206. $month_abbrev['05'] = NT_('May');
  207. // TRANS: abbrev. for June
  208. $month_abbrev['06'] = NT_('Jun');
  209. // TRANS: abbrev. for July
  210. $month_abbrev['07'] = NT_('Jul');
  211. // TRANS: abbrev. for August
  212. $month_abbrev['08'] = NT_('Aug');
  213. // TRANS: abbrev. for September
  214. $month_abbrev['09'] = NT_('Sep');
  215. // TRANS: abbrev. for October
  216. $month_abbrev['10'] = NT_('Oct');
  217. // TRANS: abbrev. for November
  218. $month_abbrev['11'] = NT_('Nov');
  219. // TRANS: abbrev. for December
  220. $month_abbrev['12'] = NT_('Dec');
  221. /**
  222. * Load modules.
  223. *
  224. * This initializes table name aliases and is required before trying to connect to the DB.
  225. */
  226. load_class( '_core/model/_module.class.php', 'Module' );
  227. foreach( $modules as $module )
  228. {
  229. require_once $inc_path.$module.'/_'.$module.'.init.php';
  230. }
  231. $Timer->pause( '_init_base' );
  232. ?>