functions.php 2.6 KB

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