Source for file harmoni.inc.php

Documentation is available at harmoni.inc.php

  1. <?PHP
  2.  
  3. /**
  4. * This file sets up global harmoni options, includes important files,
  5. * and defines a few crucial functions.
  6. *
  7. *
  8. * @package harmoni
  9. *
  10. * @copyright Copyright &copy; 2005, Middlebury College
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  12. *
  13. * @version $Id: harmoni.inc.php,v 1.46 2007/09/04 21:02:19 adamfranco Exp $
  14. */
  15.  
  16. /* :: start the output buffer, if it's not already :: */
  17. if (!ob_get_level()) ob_start();
  18. /**
  19. * Defines the global harmoni directory.
  20. * @const string HARMONI The harmoni core directory.
  21. ***/
  22.  
  23. define("HARMONI",dirname(__FILE__).DIRECTORY_SEPARATOR."core".DIRECTORY_SEPARATOR);
  24.  
  25. /**
  26. * Defines the global harmoni directory.
  27. * @const string HARMONI_BASE The base harmoni directory.
  28. ***/
  29.  
  30. define("HARMONI_BASE",dirname(__FILE__).DIRECTORY_SEPARATOR);
  31. define("HARMONIBASE",HARMONI_BASE);
  32.  
  33. define("SIMPLE_TEST",HARMONI.DIRECTORY_SEPARATOR."simple_test".DIRECTORY_SEPARATOR);
  34.  
  35. /**
  36. * Defines where OKI interfaces for PHP are located.
  37. * @const string OKI The OKI interfaces location.
  38. */
  39. define("OKI",dirname(__FILE__).DIRECTORY_SEPARATOR."oki".DIRECTORY_SEPARATOR);
  40. define("OKI2",dirname(__FILE__).DIRECTORY_SEPARATOR."oki2".DIRECTORY_SEPARATOR);
  41. //require_once(OKI."inc.php");
  42.  
  43. /*******************************************************
  44. * if magic quotes on then get rid of them as we assume that
  45. * they are off.
  46. *********************************************************/
  47.  
  48. if (get_magic_quotes_gpc()) {
  49. // but really throw an error
  50. print '
  51. <HTML>
  52. <HEAD>
  53. <TITLE>ERROR</TITLE>
  54. <STYLE TYPE="text/css">
  55. body {
  56. background-color: #eee;
  57. margin: 50px 150px 50px 150px;
  58. padding: 30px;
  59. color: #333;
  60. font-family: Verdana;
  61.  
  62. border: 1px dotted #555;
  63. }
  64.  
  65. body p {
  66. font-size: 12px;
  67. text-align: center;
  68. color: #955;
  69. }
  70.  
  71. body div {
  72. font-size: 18px;
  73. font-weight: normal;
  74. }
  75. </STYLE>
  76. </HEAD>
  77.  
  78. <BODY>
  79. <P>Harmoni could not be initialized for the following reason:</P>
  80. <DIV>
  81. PHP\'s config directive <b>magic_quotes_gpc</b> is set to <b>On</b> and should be <b>Off</b>.
  82. </DIV>
  83. <p>To have Harmoni run in compatability mode (stripping slashes from the GET, POST, COOKIE, and REQUEST arrays, comment out lines 49-86 of harmoni.inc.php (this file/message).
  84. </BODY>
  85. </HTML>';
  86. exit(1);
  87. function array_walk_stripslashes(&$val, $key) {
  88. if (is_array($val)) array_walk($val, 'array_walk_stripslashes');
  89. else $val = stripslashes($val);
  90. }
  91. array_walk($_GET, 'array_walk_stripslashes');
  92. array_walk($_POST, 'array_walk_stripslashes');
  93. array_walk($_REQUEST, 'array_walk_stripslashes');
  94. array_walk($_COOKIE, 'array_walk_stripslashes');
  95. }
  96.  
  97. /*******************************************************
  98. * Check that the PHP version is at least 5
  99. *********************************************************/
  100.  
  101. $minPhpVersion = "5.2.0";
  102. if (version_compare(phpversion(), $minPhpVersion, "<")) {
  103. // but really throw an error
  104. print '
  105. <HTML>
  106. <HEAD>
  107. <TITLE>ERROR</TITLE>
  108. <STYLE TYPE="text/css">
  109. body {
  110. background-color: #eee;
  111. margin: 50px 150px 50px 150px;
  112. padding: 30px;
  113. color: #333;
  114. font-family: Verdana;
  115.  
  116. border: 1px dotted #555;
  117. }
  118.  
  119. body p {
  120. font-size: 12px;
  121. text-align: center;
  122. color: #955;
  123. }
  124.  
  125. body div {
  126. font-size: 18px;
  127. font-weight: normal;
  128. }
  129. </STYLE>
  130. </HEAD>
  131.  
  132. <BODY>
  133. <P>Harmoni could not be initialized for the following reason:</P>
  134. <DIV>
  135. PHP version <b>'.$minPhpVersion.'</b> or greater required. This host is using <b>'.phpversion().'</b>.
  136. </DIV>
  137. </BODY>
  138. </HTML>';
  139. exit(1);
  140. }
  141.  
  142.  
  143. /*******************************************************
  144. * Create the Harmoni object - required
  145. *********************************************************/
  146.  
  147. /* :: load the Framework config file :: */
  148. require_once(HARMONIBASE."config/framework.cfg.php");
  149. $harmoni = Harmoni::instance();
  150.  
  151. /*******************************************************
  152. * Services
  153. *********************************************************/
  154.  
  155. /**
  156. * The name of the services variable.
  157. * @const SERVICES_OBJECT The name of the services variable.
  158. ***/
  159. define("SERVICES_OBJECT","__services__");
  160.  
  161. /* :: load the services :: */
  162. require_once(HARMONI."services/Services.class.php");
  163.  
  164. /**
  165. * The global Services object.
  166. * @var object Services $__services__ The global Services object.
  167. ***/
  168. $__services__ = new Services();
  169. $GLOBALS[SERVICES_OBJECT] =$__services__;
  170.  
  171. /* :: load the Services registration config file :: */
  172. require_once(HARMONIBASE."config/services.cfg.php");
  173.  
  174.  
  175. /*******************************************************
  176. * include other useful things
  177. *********************************************************/
  178.  
  179. require_once(HARMONI."utilities/TemplateFactory.class.php");
  180. require_once(HARMONI."utilities/MIMETypes.class.php");
  181. require_once(HARMONI."architecture/events/EventTrigger.abstract.php");
  182. require_once(HARMONI."architecture/events/EventListener.interface.php");
  183.  
  184.  
  185. ?>

Documentation generated on Wed, 19 Sep 2007 10:23:35 -0400 by phpDocumentor 1.3.0RC3