/html/index.php

https://github.com/xmmedia/xm_template · PHP · 136 lines · 46 code · 21 blank · 69 comment · 13 complexity · a95d2a1187878e1421a32ff9d64b0160 MD5 · raw file

  1. <?php
  2. // include the config file
  3. // for each server, replace this file with the correct config
  4. require_once('../application/init.php');
  5. // set the upload paths based on the ABS root
  6. // these can be set here because it's unlikely the relative path will change per site
  7. define('UPLOAD_ROOT_PUBLIC', ABS_ROOT . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'uploads');
  8. define('UPLOAD_ROOT_PRIVATE', ABS_ROOT . DIRECTORY_SEPARATOR . 'uploads');
  9. define('UPLOAD_ROOT', UPLOAD_ROOT_PRIVATE);
  10. /**
  11. * Set the PHP error reporting level. If you set this in php.ini, you remove this.
  12. * @see http://php.net/error_reporting
  13. *
  14. * When developing your application, it is highly recommended to enable notices
  15. * and strict warnings. Enable them by using: E_ALL | E_STRICT
  16. *
  17. * In a production environment, it is safe to ignore notices and strict warnings.
  18. * Disable them by using: E_ALL ^ E_NOTICE
  19. *
  20. * When using a legacy application with PHP >= 5.3, it is recommended to disable
  21. * deprecated notices. Disable with: E_ALL & ~E_DEPRECATED
  22. */
  23. if (DEBUG_FLAG) {
  24. // debug mode
  25. error_reporting(-1);
  26. ini_set('display_errors', 'On');
  27. } else {
  28. // production site
  29. error_reporting(E_ALL | E_STRICT);
  30. } // if
  31. /**
  32. * The default extension of resource files. If you change this, all resources
  33. * must be renamed to use the new extension.
  34. *
  35. * @see http://kohanaframework.org/guide/about.install#ext
  36. */
  37. define('EXT', '.php');
  38. /**
  39. * Define some line endings
  40. */
  41. define('EOL', "\n");
  42. define('HEOL', "<br>\n");
  43. /**
  44. * The directory in which your application specific resources are located.
  45. * The application directory must contain the bootstrap.php file.
  46. *
  47. * @see http://kohanaframework.org/guide/about.install#application
  48. */
  49. $application = '../application/';
  50. /**
  51. * The directory in which your modules are located.
  52. *
  53. * @see http://kohanaframework.org/guide/about.install#modules
  54. */
  55. $modules = '../modules/';
  56. /**
  57. * The directory in which the Kohana resources are located. The system
  58. * directory must contain the classes/kohana.php file.
  59. *
  60. * @see http://kohanaframework.org/guide/about.install#system
  61. */
  62. $system = '../system/';
  63. /**
  64. * End of standard configuration! Changing any of the code below should only be
  65. * attempted by those with a working knowledge of Kohana internals.
  66. *
  67. * @see http://kohanaframework.org/guide/using.configuration
  68. */
  69. // Set the full path to the docroot
  70. define('DOCROOT', realpath(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
  71. // Make the application relative to the docroot
  72. if ( ! is_dir($application) && is_dir(DOCROOT . $application))
  73. $application = DOCROOT . $application;
  74. // Make the modules relative to the docroot
  75. if ( ! is_dir($modules) && is_dir(DOCROOT . $modules))
  76. $modules = DOCROOT . $modules;
  77. // Make the system relative to the docroot
  78. if ( ! is_dir($system) && is_dir(DOCROOT . $system))
  79. $system = DOCROOT . $system;
  80. // Define the absolute paths for configured directories
  81. define('APPPATH', realpath($application) . DIRECTORY_SEPARATOR);
  82. define('MODPATH', realpath($modules) . DIRECTORY_SEPARATOR);
  83. define('SYSPATH', realpath($system) . DIRECTORY_SEPARATOR);
  84. // set a path for xm which will be used on our extension of Kohana so we can use the xm exception handler
  85. define('XM_PATH', realpath(MODPATH . 'xm') . DIRECTORY_SEPARATOR);
  86. // Clean up the configuration vars
  87. unset($application, $modules, $system);
  88. /**
  89. * Define the start time of the application, used for profiling.
  90. */
  91. if ( ! defined('KOHANA_START_TIME')) {
  92. define('KOHANA_START_TIME', microtime(TRUE));
  93. }
  94. /**
  95. * Define the memory usage at the start of the application, used for profiling.
  96. */
  97. if ( ! defined('KOHANA_START_MEMORY')) {
  98. define('KOHANA_START_MEMORY', memory_get_usage());
  99. }
  100. // Bootstrap the application
  101. require APPPATH . 'bootstrap' . EXT;
  102. if (PHP_SAPI == 'cli') {
  103. class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.');
  104. set_exception_handler(array('Minion_Exception', 'handler'));
  105. Minion_Task::factory(Minion_CLI::options())->execute();
  106. } else {
  107. /**
  108. * Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
  109. * If no source is specified, the URI will be automatically detected.
  110. */
  111. echo Request::factory(TRUE, array(), FALSE)
  112. ->execute()
  113. ->send_headers(TRUE)
  114. ->body();
  115. }