index.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 = strtolower(trim(substr(filter_input(INPUT_GET, "url", FILTER_SANITIZE_STRING), 0, 300), "/"));
  35. switch ($url) {
  36. case "action":
  37. $scriptPath = APP_AJAX_PATH;
  38. define("SCRIPT_NAME", "action");
  39. define("SCRIPT_FILENAME", "action.php");
  40. break;
  41. case "script":
  42. define("SCRIPT_NAME", "script");
  43. define("SCRIPT_FILENAME", "scriptContent.php");
  44. break;
  45. case "":
  46. $bsdha = strtolower(substr(filter_input(INPUT_GET, "bsdha", FILTER_SANITIZE_STRING), 0, 64));
  47. // SALT LOGIC
  48. $SALT = "";
  49. // Authentication
  50. $myhash = hash("sha256", APP_PASSWORD . $SALT, false);
  51. if ($myhash === $bsdha) {
  52. $auth = true;
  53. } else {
  54. $auth = false;
  55. }
  56. $bsdto = trim(substr(filter_input(INPUT_GET, "bsdto", FILTER_SANITIZE_STRING), 0, 100), " ");
  57. $bsdsu = trim(substr(filter_input(INPUT_GET, "bsdsu", FILTER_SANITIZE_STRING), 0, 300), " ");
  58. $bsdbo = trim(substr(filter_input(INPUT_GET, "bsdbo", FILTER_SANITIZE_STRING), 0, 5000), " ");
  59. if (!$auth || ($bsdto===PHP_STR) || ($bsdsu===PHP_STR) || ($bsdbo===PHP_STR)) {
  60. echo("Param error.");
  61. exit(-1);
  62. } else {
  63. define("SCRIPT_NAME", "m");
  64. define("SCRIPT_FILENAME", "m.php");
  65. }
  66. break;
  67. default:
  68. $scriptPath = APP_ERROR_PATH;
  69. define("SCRIPT_NAME", "err-404");
  70. define("SCRIPT_FILENAME", "err-404.php");
  71. }
  72. if (SCRIPT_NAME==="err-404") {
  73. header("HTTP/1.1 404 Not Found");
  74. }
  75. require $scriptPath . "/" . SCRIPT_FILENAME;