functions.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. if (($GLOBALS['uuid'] == '')) {
  20. $uuid = gen_uuid();
  21. $GLOBALS['uuid'] = $uuid;
  22. updateConfig(array('uuid' => $uuid));
  23. }
  24. //Upgrade Check
  25. upgradeCheck();
  26. }
  27. // Cookie name
  28. $GLOBALS['cookieName'] = $GLOBALS['uuid'] !== '' ? 'organizr_token_' . $GLOBALS['uuid'] : 'organizr_token_temp';
  29. // Validate Token if set and set guest if not - sets GLOBALS
  30. getOrganizrUserToken();
  31. // Include all pages files
  32. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  33. require_once $filename;
  34. }
  35. // Include all plugin files
  36. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  37. require_once $filename;
  38. }