index.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * Bibliotheca
  4. *
  5. * Copyright 2018-2024 Johannes Keßler
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  19. */
  20. require_once './config/config.php';
  21. const BIB_VERSION = '1.x - Dark Arena';
  22. mb_http_output('UTF-8');
  23. mb_internal_encoding('UTF-8');
  24. error_reporting(-1); // E_ALL & E_STRICT
  25. # check request
  26. $_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
  27. if(!empty($_urlToParse)) {
  28. if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) {
  29. die('Malformed request. Make sure you know what you are doing.');
  30. }
  31. }
  32. # set the error reporting
  33. ini_set('log_errors',true);
  34. if(DEBUG === true) {
  35. ini_set('display_errors',true);
  36. }
  37. else {
  38. ini_set('display_errors',false);
  39. }
  40. # time settings
  41. date_default_timezone_set(TIMEZONE);
  42. # i18n
  43. require_once 'lib/i18n.class.php';
  44. $I18n = new I18n();
  45. # static helper class
  46. require_once 'lib/summoner.class.php';
  47. # general includes
  48. require_once 'lib/doomguy.class.php';
  49. require_once 'lib/gorenest.class.php';
  50. ## main vars
  51. # the template data as an array
  52. # and some defaults
  53. $TemplateData = array();
  54. $TemplateData['pagination'] = array();
  55. $TemplateData['navSearchAction'] = array();
  56. $TemplateData['pageTitle'] = 'Dashboard';
  57. # the view
  58. $View = Summoner::themefile('dashboard/dashboard.html', UI_THEME);
  59. # the script
  60. $ViewScript = Summoner::themefile('dashboard/dashboard.php', UI_THEME);
  61. # the messages
  62. $ViewMessage = Summoner::themefile('system/message.php',UI_THEME);
  63. # the menu
  64. $ViewMenu = Summoner::themefile('system/menu.php',UI_THEME);
  65. ## DB connection
  66. $DB = new mysqli(DB_HOST, DB_USERNAME,DB_PASSWORD, DB_NAME);
  67. $driver = new mysqli_driver();
  68. $driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT;
  69. if ($DB->connect_errno) exit('Can not connect to MySQL Server');
  70. $DB->set_charset("utf8mb4");
  71. $DB->query("SET collation_connection = 'utf8mb4_unicode_ci'");
  72. # user Object
  73. $Doomguy = new Doomguy($DB);
  74. # menu Object
  75. $Gorenest = new GoreNest($DB,$Doomguy);
  76. $_requestMode = "dashboard";
  77. if(isset($_GET['p']) && !empty($_GET['p'])) {
  78. $_requestMode = trim($_GET['p']);
  79. $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "dashboard";
  80. $_validPages = $Gorenest->allowedPageRequests();
  81. $_validPages["dashboard"] = "dashboard";
  82. if(!isset($_validPages[$_requestMode])) $_requestMode = "dashboard";
  83. $ViewScript = Summoner::themefile($_requestMode.'/'.$_requestMode.'.php', UI_THEME);
  84. $View = Summoner::themefile($_requestMode.'/'.$_requestMode.'.html', UI_THEME);
  85. }
  86. # now include the script
  87. # this sets information into $Data and can overwrite $View
  88. if(!empty($ViewScript)) {
  89. require_once $ViewScript;
  90. }
  91. if(!empty($TemplateData['refresh'])) {
  92. header("Location: ".$TemplateData['refresh']);
  93. }
  94. # header information
  95. header('Content-type: text/html; charset=UTF-8');
  96. ## now inlcude the main view
  97. require_once Summoner::themefile('main.php', UI_THEME);
  98. $DB->close();