functions.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. if ($GLOBALS['docker']) {
  30. $getBranch = file_get_contents(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'Docker.txt');
  31. $getBranch = (empty($getBranch)) ? 'v2-master' : trim($getBranch);
  32. $GLOBALS['branch'] = $getBranch;
  33. if (!isset($GLOBALS['commit']) || $GLOBALS['commit'] == 'n/a') {
  34. $GLOBALS['commit'] = $GLOBALS['quickCommit'];
  35. }
  36. }
  37. //Upgrade Check
  38. upgradeCheck();
  39. }
  40. // Cookie name
  41. $GLOBALS['cookieName'] = $GLOBALS['uuid'] !== '' ? 'organizr_token_' . $GLOBALS['uuid'] : 'organizr_token_temp';
  42. // Validate Token if set and set guest if not - sets GLOBALS
  43. getOrganizrUserToken();
  44. // Include all pages files
  45. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  46. require_once $filename;
  47. }
  48. // Include all plugin files
  49. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  50. require_once $filename;
  51. }