index.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of SnipSwap.
  6. *
  7. * SnipSwap 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. * SnipSwap 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 SnipSwap. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * index.php
  21. *
  22. * The index file.
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2016, 2024, 5 Mode
  26. */
  27. require "../Private/core/init.inc";
  28. use fivemode\fivemode\CatUtil;
  29. // FUNCTION AND VARIABLE DECLARATIONS
  30. $scriptPath = APP_SCRIPT_PATH;
  31. // PARAMETERS VALIDATION
  32. $url = filter_input(INPUT_GET, "url")??"";
  33. $url = strip_tags($url);
  34. $url = strtolower(trim(substr($url, 0, 300), "/"));
  35. switch ($url) {
  36. case "footercontent":
  37. define("SCRIPT_NAME", "footerContent");
  38. define("SCRIPT_FILENAME", "footerContent.php");
  39. break;
  40. case "getxml":
  41. define("SCRIPT_NAME", "getxml");
  42. define("SCRIPT_FILENAME", "getxml.php");
  43. break;
  44. case "putxml":
  45. $scriptPath = APP_AJAX_PATH;
  46. define("SCRIPT_NAME", "putxml");
  47. define("SCRIPT_FILENAME", "putxml.php");
  48. break;
  49. case "headercontent":
  50. define("SCRIPT_NAME", "headerContent");
  51. define("SCRIPT_FILENAME", "headerContent.php");
  52. break;
  53. default:
  54. $platform = filter_input(INPUT_GET, "platform")??"";
  55. $platform = strip_tags($platform);
  56. $platform = strtolower(substr($platform, 0, 1));
  57. $catPath = filter_input(INPUT_GET, "cat")??"";
  58. $catPath = strip_tags($catPath);
  59. $catPath = rtrim(substr($catPath, 0, 300), "/");
  60. $catMaskedPath = str_replace(PHP_SLASH, PHP_TILDE, $catPath);
  61. if (CatUtil::catExist($catMaskedPath)) {
  62. define("SCRIPT_NAME", "home");
  63. define("SCRIPT_FILENAME", "home.php");
  64. } else {
  65. // In any other case, the category has no match..
  66. /*
  67. * $scriptPath = APP_ERROR_PATH;
  68. define("SCRIPT_NAME", "err-404");
  69. define("SCRIPT_FILENAME", "err-404.php");
  70. *
  71. */
  72. $catMaskedPath = PHP_STR;
  73. define("SCRIPT_NAME", "home");
  74. define("SCRIPT_FILENAME", "home.php");
  75. }
  76. }
  77. if (SCRIPT_NAME==="err-404") {
  78. header("HTTP/1.1 404 Not Found");
  79. }
  80. require $scriptPath . "/" . SCRIPT_FILENAME;