static-globals.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. // ===================================
  3. // Organizr Version
  4. $GLOBALS['installedVersion'] = '2.0.0-beta.200';
  5. // ===================================
  6. // Quick php Version check
  7. $GLOBALS['minimumPHP'] = '7.0.0';
  8. if (!(version_compare(PHP_VERSION, $GLOBALS['minimumPHP']) >= 0)) {
  9. die('Organizr needs PHP Version: ' . $GLOBALS['minimumPHP'] . '<br/> You have PHP Version: ' . PHP_VERSION);
  10. }
  11. // Set GLOBALS from config file
  12. $GLOBALS['userConfigPath'] = dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
  13. $GLOBALS['defaultConfigPath'] = dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'default.php';
  14. $GLOBALS['currentTime'] = gmdate("Y-m-d\TH:i:s\Z");
  15. // Quick function for plugins
  16. function pluginFiles($type)
  17. {
  18. $files = '';
  19. switch ($type) {
  20. case 'js':
  21. foreach (glob(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . "*.js") as $filename) {
  22. $files .= '<script src="api/plugins/js/' . basename($filename) . '?v=' . $GLOBALS['installedVersion'] . '" defer="true"></script>';
  23. }
  24. break;
  25. case 'css':
  26. foreach (glob(dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . "*.js") as $filename) {
  27. $files .= '<link href="api/plugins/css/' . basename($filename) . $GLOBALS['installedVersion'] . '" rel="stylesheet">';
  28. }
  29. break;
  30. default:
  31. break;
  32. }
  33. return $files;
  34. }
  35. function loadConfigOnce($path = null)
  36. {
  37. $path = ($path) ? $path : $GLOBALS['userConfigPath'];
  38. if (!is_file($path)) {
  39. return null;
  40. } else {
  41. return (array)call_user_func(function () use ($path) {
  42. return include($path);
  43. });
  44. }
  45. }
  46. function favIcons()
  47. {
  48. $favicon = '
  49. <link rel="apple-touch-icon" sizes="180x180" href="plugins/images/favicon/apple-touch-icon.png">
  50. <link rel="icon" type="image/png" sizes="32x32" href="plugins/images/favicon/favicon-32x32.png">
  51. <link rel="icon" type="image/png" sizes="16x16" href="plugins/images/favicon/favicon-16x16.png">
  52. <link rel="manifest" href="plugins/images/favicon/site.webmanifest">
  53. <link rel="mask-icon" href="plugins/images/favicon/safari-pinned-tab.svg" color="#5bbad5">
  54. <link rel="shortcut icon" href="plugins/images/favicon/favicon.ico">
  55. <meta name="msapplication-TileColor" content="#da532c">
  56. <meta name="msapplication-TileImage" content="plugins/images/favicon/mstile-144x144.png">
  57. <meta name="msapplication-config" content="plugins/images/favicon/browserconfig.xml">
  58. <meta name="theme-color" content="#ffffff">
  59. ';
  60. if (file_exists($GLOBALS['userConfigPath'])) {
  61. $config = loadConfigOnce($GLOBALS['userConfigPath']);
  62. if (isset($config['favIcon'])) {
  63. if ($config['favIcon'] !== '') {
  64. $favicon = $config['favIcon'];
  65. }
  66. }
  67. }
  68. return $favicon;
  69. }