functions.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. // Set UTC timeone
  3. date_default_timezone_set("UTC");
  4. // Autoload frameworks
  5. require_once(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
  6. // Include all function files
  7. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'functions' . DIRECTORY_SEPARATOR . '*.php') as $filename) {
  8. require_once $filename;
  9. }
  10. // Set Root Directory
  11. $GLOBALS['root'] = dirname(__DIR__, 1);
  12. $GLOBALS['uuid'] = '';
  13. // Add in default and custom settings
  14. configLazy();
  15. // Define Logs and files after db location is set
  16. if (isset($GLOBALS['dbLocation'])) {
  17. $GLOBALS['organizrLog'] = $GLOBALS['dbLocation'] . 'organizrLog.json';
  18. $GLOBALS['organizrLoginLog'] = $GLOBALS['dbLocation'] . 'organizrLoginLog.json';
  19. $GLOBALS['paths'] = array(
  20. 'Root Folder' => dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
  21. 'API Folder' => dirname(__DIR__, 1) . DIRECTORY_SEPARATOR,
  22. 'DB Folder' => $GLOBALS['dbLocation']
  23. );
  24. if (($GLOBALS['uuid'] == '')) {
  25. $uuid = gen_uuid();
  26. $GLOBALS['uuid'] = $uuid;
  27. updateConfig(array('uuid' => $uuid));
  28. }
  29. //Upgrade Check
  30. upgradeCheck();
  31. }
  32. // Cookie name
  33. $GLOBALS['cookieName'] = $GLOBALS['uuid'] !== '' ? 'organizr_token_' . $GLOBALS['uuid'] : 'organizr_token_temp';
  34. // Validate Token if set and set guest if not - sets GLOBALS
  35. getOrganizrUserToken();
  36. // Include all pages files
  37. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  38. require_once $filename;
  39. }
  40. // Include all plugin files
  41. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  42. require_once $filename;
  43. }