functions.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. $GLOBALS['rememberMeDays'] = '99';
  14. // Add in default and custom settings
  15. configLazy();
  16. // Define Logs and files after db location is set
  17. if (isset($GLOBALS['dbLocation'])) {
  18. $GLOBALS['organizrLog'] = $GLOBALS['dbLocation'] . 'organizrLog.json';
  19. $GLOBALS['organizrLoginLog'] = $GLOBALS['dbLocation'] . 'organizrLoginLog.json';
  20. $GLOBALS['paths'] = array(
  21. 'Root Folder' => dirname(__DIR__, 2) . DIRECTORY_SEPARATOR,
  22. 'API Folder' => dirname(__DIR__, 1) . DIRECTORY_SEPARATOR,
  23. 'DB Folder' => $GLOBALS['dbLocation']
  24. );
  25. if (($GLOBALS['uuid'] == '')) {
  26. $uuid = gen_uuid();
  27. $GLOBALS['uuid'] = $uuid;
  28. updateConfig(array('uuid' => $uuid));
  29. }
  30. if ($GLOBALS['docker']) {
  31. $getBranch = file_get_contents(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'Docker.txt');
  32. $getBranch = (empty($getBranch)) ? 'v2-master' : trim($getBranch);
  33. $GLOBALS['branch'] = $getBranch;
  34. if (!isset($GLOBALS['commit']) || $GLOBALS['commit'] == 'n/a') {
  35. $GLOBALS['commit'] = $GLOBALS['quickCommit'];
  36. }
  37. }
  38. //Upgrade Check
  39. upgradeCheck();
  40. }
  41. // Reset RememberMe if zero
  42. $GLOBALS['rememberMeDays'] = ($GLOBALS['rememberMeDays'] == '0') ? '99' : $GLOBALS['rememberMeDays'];
  43. // Cookie name
  44. $GLOBALS['cookieName'] = $GLOBALS['uuid'] !== '' ? 'organizr_token_' . $GLOBALS['uuid'] : 'organizr_token_temp';
  45. // Validate Token if set and set guest if not - sets GLOBALS
  46. getOrganizrUserToken();
  47. // Include all pages files
  48. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  49. require_once $filename;
  50. }
  51. // Include all plugin files
  52. foreach (glob(__DIR__ . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . "*.php") as $filename) {
  53. require_once $filename;
  54. }