index.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Copyright (c) 2016, 2024, 5 Mode
  4. * All rights reserved.
  5. *
  6. * This file is part of PHPBSDRelay.
  7. *
  8. * PHPBSDRelay is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * PHPBSDRelay is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with PHPBSDRelay. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. * index.php
  22. *
  23. * The index file.
  24. *
  25. * @author Daniele Bonini <my25mb@aol.com>
  26. * @copyrights (c) 2016, 2024, 5 Mode
  27. * @license https://opensource.org/licenses/BSD-3-Clause
  28. */
  29. require "../Private/core/init.inc";
  30. //use fivemode\fivemode\Class;
  31. // FUNCTION AND VARIABLE DECLARATIONS
  32. $scriptPath = APP_SCRIPT_PATH;
  33. // PARAMETERS VALIDATION
  34. $url = filter_input(INPUT_GET, "url")??"";
  35. $url = strip_tags($url);
  36. $url = strtolower(trim(substr($url, 0, 300), "/"));
  37. switch ($url) {
  38. case "action":
  39. $scriptPath = APP_AJAX_PATH;
  40. define("SCRIPT_NAME", "action");
  41. define("SCRIPT_FILENAME", "action.php");
  42. break;
  43. case "script":
  44. define("SCRIPT_NAME", "script");
  45. define("SCRIPT_FILENAME", "scriptContent.php");
  46. break;
  47. case "":
  48. $bsdha = filter_input(INPUT_GET, "bsdha")??"";
  49. $bsdha = strip_tags($bsdha);
  50. $bsdha = strtolower(substr($bsdha, 0, 64));
  51. // SALT LOGIC
  52. $SALT = "";
  53. // Authentication
  54. $myhash = hash("sha256", APP_PASSWORD . $SALT, false);
  55. if ($myhash === $bsdha) {
  56. $auth = true;
  57. } else {
  58. $auth = false;
  59. }
  60. $bsdto = filter_input(INPUT_GET, "bsdto")??"";
  61. $bsdto = strip_tags($bsdto);
  62. $bsdto = trim(substr($bsdto, 0, 100), " ");
  63. $bsdsu = filter_input(INPUT_GET, "bsdsu")??"";
  64. $bsdsu = strip_tags($bsdsu);
  65. $bsdsu = trim(substr($bsdsu, 0, 300), " ");
  66. $bsdbo = filter_input(INPUT_GET, "bsdbo")??"";
  67. $bsdbo = strip_tags($bsdbo);
  68. $bsdbo = trim(substr($bsdbo, 0, 5000), " ");
  69. if (!$auth || ($bsdto===PHP_STR) || ($bsdsu===PHP_STR) || ($bsdbo===PHP_STR)) {
  70. echo("Param error.");
  71. exit(-1);
  72. } else {
  73. define("SCRIPT_NAME", "m");
  74. define("SCRIPT_FILENAME", "m.php");
  75. }
  76. break;
  77. default:
  78. $scriptPath = APP_ERROR_PATH;
  79. define("SCRIPT_NAME", "err-404");
  80. define("SCRIPT_FILENAME", "err-404.php");
  81. }
  82. if (SCRIPT_NAME==="err-404") {
  83. header("HTTP/1.1 404 Not Found");
  84. }
  85. require $scriptPath . "/" . SCRIPT_FILENAME;