index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Copyright (c) 2016, 2024, 5 Mode
  4. *
  5. * This file is part of Puzzleu.
  6. *
  7. * Puzzleu 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. * Puzzleu 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 Puzzleu. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * index.php
  21. *
  22. * Puzzleu 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. // FUNCTION AND VARIABLE DECLARATIONS
  29. $scriptPath = APP_SCRIPT_PATH;
  30. // PARAMETERS VALIDATION
  31. $url = filter_input(INPUT_GET, "url")??"";
  32. $url = strip_tags($url);
  33. $url = strtolower(trim(substr($url, 0, 300), "/"));
  34. switch ($url) {
  35. case "action":
  36. $scriptPath = APP_AJAX_PATH;
  37. define("SCRIPT_NAME", "action");
  38. define("SCRIPT_FILENAME", "action.php");
  39. break;
  40. case "download":
  41. define("SCRIPT_NAME", "download");
  42. define("SCRIPT_FILENAME", "download.php");
  43. break;
  44. case "d":
  45. define("SCRIPT_NAME", "d");
  46. define("SCRIPT_FILENAME", "d.php");
  47. break;
  48. case "":
  49. case "home":
  50. define("SCRIPT_NAME", "home");
  51. define("SCRIPT_FILENAME", "home.php");
  52. break;
  53. case "img":
  54. $ID = filter_input(INPUT_GET, "av")??"";
  55. $JOB_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . $ID;
  56. $GALLERY_PATH = $JOB_PATH . DIRECTORY_SEPARATOR . "gallery";
  57. $pic = filter_input(INPUT_GET, "pic")??"";
  58. $originalFilename = pathinfo($pic, PATHINFO_FILENAME);
  59. $originalFileExt = pathinfo($pic, PATHINFO_EXTENSION);
  60. $fileExt = strtolower(pathinfo($pic, PATHINFO_EXTENSION));
  61. if (left($pic,4) === "logo") {
  62. $picPath = APP_DATA_PATH . DIRECTORY_SEPARATOR . $ID . DIRECTORY_SEPARATOR . $pic;
  63. } else {
  64. $picPath = $GALLERY_PATH . DIRECTORY_SEPARATOR . $pic;
  65. }
  66. if (filesize($picPath) <= APP_FILE_MAX_SIZE) {
  67. if ($fileExt = "jpg") {
  68. header("Content-Type: image/jpeg");
  69. } else {
  70. header("Content-Type: image/" . $fileExt);
  71. }
  72. echo(file_get_contents($picPath));
  73. exit(0);
  74. } else {
  75. die("picture size over app limits.");
  76. }
  77. break;
  78. default:
  79. $scriptPath = APP_ERROR_PATH;
  80. define("SCRIPT_NAME", "err-404");
  81. define("SCRIPT_FILENAME", "err-404.php");
  82. define("AVATAR_NAME", $url);
  83. break;
  84. }
  85. if (SCRIPT_NAME==="err-404") {
  86. header("HTTP/1.1 404 Not Found");
  87. }
  88. require $scriptPath . "/" . SCRIPT_FILENAME;