default.inc.php 954 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Register automatic loading for dependency injection
  4. */
  5. spl_autoload_register(function($class){
  6. if(file_exists('include/php/models/'.$class.'.php')){
  7. include 'include/php/models/'.$class.'.php';
  8. }
  9. elseif(file_exists('include/php/classes/'.$class.'.php')){
  10. include 'include/php/classes/'.$class.'.php';
  11. }
  12. });
  13. /**
  14. * Load some global accessible functions
  15. */
  16. require_once 'include/php/global.inc.php';
  17. /**
  18. * Require config
  19. */
  20. if(file_exists('config/config.inc.php')){
  21. require_once 'config/config.inc.php';
  22. }
  23. else{
  24. require_once 'config/config.inc.php.example';
  25. }
  26. /**
  27. * Establish database connection
  28. */
  29. $db = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
  30. if($db->connect_errno > 0){
  31. die('Unable to connect to database [' . $db->connect_error . ']');
  32. }
  33. /**
  34. * Initialize Authentication (Login User if in session)
  35. */
  36. Auth::init();
  37. /**
  38. * Setup routes
  39. */
  40. require_once 'include/php/routes.inc.php';