PageRenderTime 26ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/index.php

https://gitlab.com/Illprotectyew/xlt
PHP | 301 lines | 127 code | 38 blank | 136 comment | 20 complexity | 1ca556b0114822e1d8ea0da304a67176 MD5 | raw file
  1. <?php
  2. /**
  3. * Code All The Things!
  4. *
  5. * A project kickstarter based on the Sprint & CodeIgnitor frameworks.
  6. *
  7. * @package DigitalPoetry\CATT
  8. * @author Jesse LaReaux <jlareaux@gmail.com>
  9. * @copyright Copyright (c) 2016, DigitalPoetry (http://digitalpoetry.studio/).
  10. * @license http://opensource.org/licenses/MIT MIT License
  11. * @link http://codeallthethings.xyz
  12. * @version 0.1.0 Shiny Things
  13. * @filesource
  14. */
  15. /**
  16. * Autoload the vendors
  17. */
  18. include "vendor/autoload.php";
  19. /**
  20. * Set the domain
  21. */
  22. $domain = ! empty($_SERVER['HTTP_HOST']) ? strtolower($_SERVER['HTTP_HOST']) : 'cli';
  23. /*
  24. * Application Environment
  25. *
  26. * * A simple method to automatically determine the environment that
  27. * the script is running on. Modify to support your needs.
  28. *
  29. * You can load different configurations depending on your
  30. * current environment. Setting the environment also influences
  31. * things like logging and error reporting.
  32. *
  33. * This can be set to anything, but default usage is:
  34. *
  35. * development
  36. * testing
  37. * production
  38. *
  39. * Note: If you change these, also change the error_reporting() code below
  40. *
  41. * To handle Travis-ci testing, we check for an environment
  42. * variable called TRAVIS which is set in the .travis.yml file.
  43. * This allows a database-specific setup for Travis testing.
  44. */
  45. if (isset($_ENV['TRAVIS']))
  46. {
  47. define('ENVIRONMENT', 'travis');
  48. }
  49. else if (isset($_ENV['TESTING']))
  50. {
  51. define('ENVIRONMENT', 'testing');
  52. }
  53. else if (strpos($domain, '.dev') !== false || $domain == 'cli')
  54. {
  55. define('ENVIRONMENT', 'development');
  56. }
  57. else {
  58. define('ENVIRONMENT', 'production');
  59. }
  60. /*
  61. * Error Reporting.
  62. *
  63. * Different environments will require different levels of error reporting.
  64. * By default development will show errors but testing and live will hide them.
  65. */
  66. switch (ENVIRONMENT)
  67. {
  68. case 'development':
  69. case 'travis':
  70. case 'testing':
  71. error_reporting(-1);
  72. ini_set('display_errors', 1);
  73. break;
  74. case 'production':
  75. ini_set('display_errors', 0);
  76. if (version_compare(PHP_VERSION, '5.3', '>='))
  77. {
  78. error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
  79. }
  80. else
  81. {
  82. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
  83. }
  84. break;
  85. default:
  86. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  87. echo 'The application environment is not set correctly.';
  88. exit(1); // EXIT_ERROR
  89. }
  90. /**
  91. * System Folder Name.
  92. *
  93. * This variable must contain the name of your "system" folder.
  94. * Include the path if the folder is not in the same directory
  95. * as this file.
  96. */
  97. $system_path = 'system';
  98. /**
  99. * Application Folder Name.
  100. *
  101. * If you want this front controller to use a different "application"
  102. * folder than the default one you can set its name here. The folder
  103. * can also be renamed or relocated anywhere on your server. If
  104. * you do, use a full server path. For more info please see the user guide:
  105. * http://codeigniter.com/user_guide/general/managing_apps.html
  106. *
  107. * Note: No trailing slash!
  108. */
  109. $application_folder = 'application';
  110. /**
  111. * Myth Folder Name.
  112. *
  113. * This variable must contain the name of your "myth" folder.
  114. * Include the path if the folder is not in the same directory
  115. * as this file.
  116. */
  117. $myth_folder = 'myth';
  118. /**
  119. * View Folder Name.
  120. *
  121. * If you want to move the view folder out of the application
  122. * folder set the path to the folder here. The folder can be renamed
  123. * and relocated anywhere on your server. If blank, it will default
  124. * to the standard location inside your application folder. If you
  125. * do move this, use the full server path to this folder.
  126. *
  127. * Note: No trailing slash!
  128. */
  129. $view_folder = '';
  130. /*
  131. * Default Controller
  132. *
  133. * Normally you will set your default controller in the routes.php file.
  134. * You can, however, force a custom routing by hard-coding a
  135. * specific controller class/function here. For most applications, you
  136. * WILL NOT set your routing here, but it's an option for those
  137. * special instances where you might want to override the standard
  138. * routing in a specific front controller that shares a common CI installation.
  139. *
  140. * IMPORTANT: If you set the routing here, NO OTHER controller will be
  141. * callable. In essence, this preference limits your application to ONE
  142. * specific controller. Leave the function name blank if you need
  143. * to call functions dynamically via the URI.
  144. *
  145. * Un-comment the $routing array below to use this feature
  146. */
  147. // The directory name, relative to the "controllers" folder. Leave blank
  148. // if your controller is not in a sub-folder within the "controllers" folder
  149. #$routing['directory'] = '';
  150. // The controller class file name. Example: mycontroller
  151. #$routing['controller'] = '';
  152. // The controller function you wish to be called.
  153. #$routing['function'] = '';
  154. /**
  155. * Custom Config Values
  156. *
  157. * The $assign_to_config array below will be passed dynamically to the
  158. * config class when initialized. This allows you to set custom config
  159. * items or override any default config values found in the config.php file.
  160. * This can be handy as it permits you to share one application between
  161. * multiple front controller files, with each file containing different
  162. * config values.
  163. *
  164. * Un-comment the $assign_to_config array below to use this feature
  165. */
  166. #$assign_to_config['name_of_config_item'] = 'value of config item';
  167. /*
  168. * End of user configurable settings. Do not edit below this line.
  169. */
  170. /*
  171. * Resolve the system path for increased reliability.
  172. */
  173. // Set the current directory correctly for CLI requests
  174. if (defined('STDIN'))
  175. {
  176. chdir(dirname(__FILE__));
  177. }
  178. if (($_temp = realpath($system_path)) !== FALSE)
  179. {
  180. $system_path = $_temp.'/';
  181. }
  182. else
  183. {
  184. // Ensure there's a trailing slash
  185. $system_path = rtrim($system_path, '/').'/';
  186. }
  187. // Is the system path correct?
  188. if ( ! is_dir($system_path))
  189. {
  190. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  191. echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
  192. exit(3); // EXIT_CONFIG
  193. }
  194. /*
  195. * Now that we know the path, set the main path constants.
  196. */
  197. // The name of THIS file
  198. define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
  199. // Path to the system folder
  200. define('BASEPATH', str_replace('\\', '/', $system_path));
  201. // Path to the front controller (this file)
  202. define('FCPATH', dirname(__FILE__).'/');
  203. // Name of the "system folder"
  204. define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
  205. // Path to the myth folder
  206. define('MYTHPATH', rtrim( str_replace('\\', '/', $myth_folder), '/ ') .'/' );
  207. // The path to the "application" folder
  208. if (is_dir($application_folder))
  209. {
  210. if (($_temp = realpath($application_folder)) !== FALSE)
  211. {
  212. $application_folder = $_temp;
  213. }
  214. define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
  215. }
  216. else
  217. {
  218. if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
  219. {
  220. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  221. echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  222. exit(3); // EXIT_CONFIG
  223. }
  224. define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR);
  225. }
  226. // The path to the "views" folder
  227. if ( ! is_dir($view_folder))
  228. {
  229. if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
  230. {
  231. $view_folder = APPPATH.$view_folder;
  232. }
  233. elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
  234. {
  235. header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
  236. echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
  237. exit(3); // EXIT_CONFIG
  238. }
  239. else
  240. {
  241. $view_folder = APPPATH.'views';
  242. }
  243. }
  244. if (($_temp = realpath($view_folder)) !== FALSE)
  245. {
  246. $view_folder = $_temp.DIRECTORY_SEPARATOR;
  247. }
  248. else
  249. {
  250. $view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
  251. }
  252. define('VIEWPATH', $view_folder);
  253. /**
  254. * Load the bootstrap file.
  255. *
  256. * And away we go...
  257. */
  258. require_once BASEPATH.'core/CodeIgniter.php';