Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

bootstrap.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * For the brave souls who get this far: You are the chosen ones,
  4. * the valiant knights of programming who toil away, without rest,
  5. * fixing our most awful code. To you, true saviors, kings of men,
  6. * I say this: never gonna give you up, never gonna let you down,
  7. * never gonna run around and desert you. Never gonna make you cry,
  8. * never gonna say goodbye. Never gonna tell a lie and hurt you.
  9. *
  10. * - by stackoverflow.com
  11. */
  12. //http://www.chartjs.org/docs/latest/
  13. //https://github.com/ThingEngineer/PHP-MySQLi-Database-Class
  14. //TODO: filesystem cache: https://github.com/cosenary/Simple-PHP-Cache
  15. //TODO: log parser: https://github.com/kassner/log-parser
  16. //https://www.w3schools.com/howto/howto_css_overlay.asp
  17. //http://www.chartjs.org/docs/latest/
  18. $isCLI = defined('STDIN') ? true : false;
  19. define ('BASE_ROOT', dirname(dirname(__FILE__)).'/');
  20. define ('APP_DIR', BASE_ROOT.'App/');
  21. define ('ROUTERS_DIR', APP_DIR.'Routers/');
  22. define ('CLASSES_DIR', APP_DIR.'Classes/'); //Framework core
  23. define ('APP_VENDOR_DIR', APP_DIR.'Vendor/'); //Additional classes
  24. define ('CONTROLLER_DIR', APP_DIR.'Controllers/');
  25. define ('VIEWS_DIR', APP_DIR.'Views/');
  26. define ('LAYOUTS_DIR', APP_DIR.'Layouts/');
  27. define ('FUNCTIONS_DIR', APP_DIR.'Functions/');
  28. define ('CACHE_DIR', APP_DIR.'Cache/');
  29. //define ('CONFIGS_DIR', APP_DIR.'Configs/');
  30. define ('CONFIGS_DIR', dirname(APP_DIR).'/AppConfigs/');
  31. define ('LOCALE_DIR', APP_DIR.'Locale');
  32. define ('VENDOR_DIR', BASE_ROOT.'vendor/'); //For composer, etc...
  33. define ('RESOURCE_DIR', BASE_ROOT.'resource/');
  34. define ('PUBLIC_HTML', dirname(dirname(__FILE__)).'/public_html/');
  35. define ('PUBLIC_FILES', PUBLIC_HTML.'public_files/');
  36. define ('AVATAR_IMG_DIR', PUBLIC_FILES.'avatars/');
  37. define ('MEDIA_DIR', dirname(PUBLIC_HTML).'/media/');
  38. define ('MEDIA_TMP_DIR', dirname(PUBLIC_HTML).'/media/tmp/');
  39. define ('DATA_DIR', dirname(PUBLIC_HTML).'/data/');
  40. define ('DATA_TMP_DIR', dirname(PUBLIC_HTML).'/data/tmp/');
  41. define ('ATTACH_DIR', dirname(PUBLIC_HTML).'/data/files/');
  42. use PHPMailer\PHPMailer\PHPMailer;
  43. use PHPMailer\PHPMailer\Exception;
  44. require VENDOR_DIR.'autoload.php';
  45. require CONFIGS_DIR.'autoload.php';
  46. require CONFIGS_DIR.'config.php';
  47. //Ensure the server time is Europe/Rome
  48. date_default_timezone_set($config['settings']['default-timezone']);
  49. require FUNCTIONS_DIR.'functions.php';
  50. if (!is_writable(CACHE_DIR)) {
  51. echo '"Cache" directory (and its subdirectories) must be writable.';
  52. exit();
  53. }
  54. if (!is_writable(PUBLIC_FILES)) {
  55. echo '"public_files" directory (and its subdirectories) must be writable.';
  56. exit();
  57. }
  58. $GLOBALS['db'] = new \MysqliDb($config['db']['host'], $config['db']['user'], $config['db']['pass'], $config['db']['dbname']);
  59. $GLOBALS['mailer'] = new PHPMailer(true);
  60. define('SUPERADMIN_ROLE_ID', 1);
  61. define('ADMIN_ROLE_ID', 2);
  62. define('MODERATOR_ROLE_ID', 3);
  63. define('REFERRER_ROLE_ID', 4);
  64. define('APPLICANT_ROLE_ID', 5);
  65. define('GUEST_ROLE_ID', 6);
  66. define('GLOBAL_MANAGER_ID', 8);
  67. define('MANAGER_ID', 9);
  68. define('STATUS_TECH_ID', 2);
  69. if (!$isCLI) {
  70. //Do not change this order!!
  71. $app = new \Slim\App($config);
  72. require CONFIGS_DIR.'sessions.php';
  73. $GLOBALS['session'] = new Session();
  74. $GLOBALS['memoryCache'] = new MemoryCache();
  75. $GLOBALS['security'] = new Security();
  76. $GLOBALS['cookie'] = new Cookie();
  77. $GLOBALS['user'] = new User();
  78. $GLOBALS['locale'] = new l18n();
  79. $GLOBALS['layout'] = new Layout();
  80. $GLOBALS['logger'] = new Logger();
  81. /// ROUTERS ///
  82. include ROUTERS_DIR.'router.php';
  83. }