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

/exponent.php

https://github.com/exponentcms/exponent-cms-1
PHP | 184 lines | 86 code | 23 blank | 75 comment | 31 complexity | e1b88b4b7ae3680b441328e565ccab6f MD5 | raw file
  1. <?php
  2. ##################################################
  3. #
  4. # Copyright (c) 2004-2006 OIC Group, Inc.
  5. # Written and Designed by James Hunt
  6. #
  7. # This file is part of Exponent
  8. #
  9. # Exponent is free software; you can redistribute
  10. # it and/or modify it under the terms of the GNU
  11. # General Public License as published by the Free
  12. # Software Foundation; either version 2 of the
  13. # License, or (at your option) any later version.
  14. #
  15. # GPL: http://www.gnu.org/licenses/gpl.txt
  16. #
  17. ##################################################
  18. function __realpath($path) {
  19. $path = str_replace('\\','/',realpath($path));
  20. if ($path{1} == ':') {
  21. // We can't just check for C:/, because windows users may have the IIS webroot on X: or F:, etc.
  22. $path = substr($path,2);
  23. }
  24. return $path;
  25. }
  26. // Bootstrap, which will clean the _POST, _GET and _REQUEST arrays, and include
  27. // necessary setup files (exponent_setup.php, exponent_variables.php) as well as initialize
  28. // the compatibility layer.
  29. // This was moved into its own file from this file so that 'lighter' scripts could bootstrap.
  30. include_once(dirname(__realpath(__FILE__)).'/exponent_bootstrap.php');
  31. // After config config setup:
  32. // Put session stuff first.
  33. $user = null;
  34. // Initialize the AutoLoader Subsystem
  35. require_once(BASE.'subsystems/autoloader.php');
  36. // Initialize the Sessions Subsystem
  37. require_once(BASE.'subsystems/sessions.php');
  38. // Initializes the session. This will populate the $user variable
  39. exponent_sessions_initialize();
  40. /*
  41. if (isset($_REQUEST['section'])) {
  42. exponent_sessions_set('last_section', intval($_REQUEST['section']));
  43. } else {
  44. if (!isset($_REQUEST['action']) && !isset($_REQUEST['module'])) exponent_sessions_set('last_section', SITE_DEFAULT_SECTION);
  45. }
  46. */
  47. if (!defined('DISPLAY_THEME')) {
  48. /* exdoc
  49. * The directory and class name of the current active theme. This may be different
  50. * than the configure theme (DISPLAY_THEME_REAL) due to previewing.
  51. */
  52. define('DISPLAY_THEME',DISPLAY_THEME_REAL);
  53. }
  54. if (!defined('THEME_ABSOLUTE')) {
  55. /* exdoc
  56. * The absolute path to the current active theme's files. This is similar to the BASE constant
  57. */
  58. define('THEME_ABSOLUTE',BASE.'themes/'.DISPLAY_THEME.'/'); // This is the recommended way
  59. }
  60. if (!defined('THEME_RELATIVE')) {
  61. /* exdoc
  62. * The relative web path to the current active theme. This is similar to the PATH_RELATIVE consant.
  63. */
  64. define('THEME_RELATIVE',PATH_RELATIVE.'themes/'.DISPLAY_THEME.'/');
  65. }
  66. // iconset base
  67. if (!defined('ICON_RELATIVE')) {
  68. //DEPRECATED: old directory, inconsitent naming
  69. if (is_readable(THEME_ABSOLUTE . 'icons/')) {
  70. /* exdoc
  71. * The relative web path to the current icon set. If an icons/ directory exists directly
  72. * underneath the theme's directory, that is used. Otherwise, the system falls back to
  73. * the iconset directory in the root of the Exponent directory.
  74. */
  75. define('ICON_RELATIVE', THEME_RELATIVE . 'icons/');
  76. } else if(is_readable(THEME_ABSOLUTE . "images/icons/")){
  77. define('ICON_RELATIVE',THEME_RELATIVE . 'images/icons/');
  78. } else {
  79. define('ICON_RELATIVE', PATH_RELATIVE . 'themes/common/images/icons/');
  80. }
  81. }
  82. if (!defined('MIMEICON_RELATIVE')) {
  83. //DEPRECATED: old directory, inconsitent naming
  84. if (is_readable(THEME_ABSOLUTE . 'mimetypes/')) {
  85. /* exdoc
  86. * The relative web path to the current MIME icon set. If a mimetypes/ directory
  87. * exists directly underneath the theme's directory, then that is used. Otherwise, the
  88. * system falls back to the iconset/mimetypes/ directory in the root of the Exponent directory.
  89. */
  90. define('MIMEICON_RELATIVE', THEME_RELATIVE . 'mimetypes/');
  91. } else if(is_readable(THEME_ABSOLUTE . "images/icons/mimetypes" )){
  92. define('MIMEICON_RELATIVE', THEME_RELATIVE . "images/icons/mimetypes/");
  93. } else {
  94. define('MIMEICON_RELATIVE', PATH_RELATIVE . 'themes/common/images/icons/mimetypes/');
  95. }
  96. }
  97. // Initialize the language subsystem
  98. require_once(BASE.'subsystems/lang.php');
  99. exponent_lang_initialize();
  100. // Initialize the Core Subsystem
  101. require_once(BASE.'subsystems/core.php');
  102. // Initialize the Database Subsystem
  103. require_once(BASE.'subsystems/database.php');
  104. $db = exponent_database_connect(DB_USER,DB_PASS,DB_HOST.':'.DB_PORT,DB_NAME);
  105. // Initialize the Modules Subsystem.
  106. require_once(BASE.'subsystems/modules.php');
  107. exponent_modules_initialize();
  108. // Initialize the Template Subsystem.
  109. require_once(BASE.'subsystems/template.php');
  110. // Initialize the Permissions Subsystem.
  111. require_once(BASE.'subsystems/permissions.php');
  112. // Initialize the Flow Subsystem.
  113. if (!defined('SYS_FLOW')) require_once(BASE.'subsystems/flow.php');
  114. // Initialize the User Subsystem.
  115. require_once(BASE.'subsystems/users.php');
  116. // Initialize the javascript subsystem
  117. if (!defined('SYS_JAVASCRIPT')) require_once(BASE.'subsystems/javascript.php');
  118. //check to see if we need to suppress errors
  119. require_once(BASE.'framework/expFramework.php');
  120. if (exponent_javascript_inAjaxAction()) set_error_handler('handleErrors');
  121. // Validate session
  122. exponent_sessions_validate();
  123. // Initialize permissions variables
  124. exponent_permissions_initialize();
  125. // initialize the router
  126. $router = new router();
  127. //Initialize the navigation heirarchy
  128. $sections = exponent_core_initializeNavigation();
  129. // if the user has turned on sef_urls then we need to route the request, otherwise we can just
  130. // skip it and default back to the old way of doing things.
  131. //$router->routeRequest();
  132. //$section = $router->getSection();
  133. //$sectionObj = $router->getSectionObj($section);
  134. // This causes about a half dozen bugs if its here and not in index.php.
  135. function eDebug($var, $halt=false){
  136. if (DEVELOPMENT) {
  137. echo "<xmp>";
  138. print_r($var);
  139. echo "</xmp>";
  140. if ($halt) die();
  141. }
  142. }
  143. function eLog($var, $type='', $path='', $minlevel='0') {
  144. if($type == '') { $type = "INFO"; }
  145. if($path == '') { $path = BASE . 'tmp/exponent.log'; }
  146. if (DEVELOPMENT >= $minlevel) {
  147. if (is_writable ($path) || !file_exists($path)) {
  148. if (!$log = fopen ($path, "ab")) {
  149. eDebug("Error opening log file for writing.");
  150. } else {
  151. if (fwrite ($log, $type . ": " . $var . "\r\n") === FALSE) {
  152. eDebug("Error writing to log file ($log).");
  153. }
  154. fclose ($log);
  155. }
  156. } else {
  157. eDebug ("Log file ($log) not writable.");
  158. }
  159. }
  160. }
  161. ?>