index.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. /**
  3. * Copyright (c) 2016, 2024, 5 Mode
  4. *
  5. * This file is part of Musicing.
  6. *
  7. * Musicing 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. * Musicing 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 Musicing. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * index.php
  21. *
  22. * Musicing 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 "audio":
  41. define("SCRIPT_NAME", "audio");
  42. define("SCRIPT_FILENAME", "audio.php");
  43. break;
  44. case "":
  45. case "home":
  46. if (defined("APP_HOME_PATH") && (APP_HOME_PATH !== PHP_STR) && is_readable(APP_HOME_PATH)) {
  47. define("SCRIPT_NAME", "homeproxy");
  48. define("SCRIPT_FILENAME", "homeproxy.php");
  49. } else {
  50. define("SCRIPT_NAME", "home");
  51. define("SCRIPT_FILENAME", "home.php");
  52. $pattern = APP_DATA_PATH . DIRECTORY_SEPARATOR . "*";
  53. $aAvatarPaths = glob($pattern, GLOB_ONLYDIR);
  54. if (empty($aAvatarPaths)) {
  55. die("<br>&nbsp;No avatar exists yet: type in the url with your avatar name like http://" . $_SERVER['HTTP_HOST']. "/&lt;your avatar&gt;.<br>&nbsp;Login with the password and drag-n-drop here all the resources you want to associate to it. <br><br>&nbsp;Links by text and first dropped picture will be your avatar image.");
  56. } else {
  57. define("AVATAR_NAME", basename($aAvatarPaths[0]));
  58. }
  59. }
  60. break;
  61. case "doc":
  62. $avatar = filter_input(INPUT_GET, "av")??"";
  63. $avatar = strip_tags($avatar);
  64. $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . $avatar;
  65. $repo = filter_input(INPUT_GET, "re")??"";
  66. $repo = strip_tags($repo);
  67. switch ($repo) {
  68. case "cv":
  69. $REPO_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "cv";
  70. break;
  71. default:
  72. die("unknown parma value:".$repo);
  73. }
  74. $doc = filter_input(INPUT_GET, "doc")??"";
  75. $doc = strip_tags($doc);
  76. $originalFilename = pathinfo($doc, PATHINFO_FILENAME);
  77. $destFilename = explode("|",$originalFilename)[1];
  78. $originalFileExt = pathinfo($doc, PATHINFO_EXTENSION);
  79. $fileExt = strtolower(pathinfo($doc, PATHINFO_EXTENSION));
  80. $docPath = $REPO_PATH . DIRECTORY_SEPARATOR . $doc;
  81. if (filesize($docPath) <= APP_FILE_MAX_SIZE) {
  82. switch ($fileExt) {
  83. case "doc":
  84. header("Content-Type: application/msword");
  85. header('Content-Disposition: attachment; filename=' . $destFilename . '.doc');
  86. break;
  87. case "pdf":
  88. header("Content-Type: application/pdf");
  89. header('Content-Disposition: attachment; filename=' . $destFilename . '.pdf');
  90. break;
  91. default:
  92. die("unknown file extension.");
  93. }
  94. echo(file_get_contents($docPath));
  95. exit(0);
  96. } else {
  97. die("doc size over app limits.");
  98. }
  99. break;
  100. case "img":
  101. $avatar = filter_input(INPUT_GET, "av")??"";
  102. $avatar = strip_tags($avatar);
  103. $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . $avatar;
  104. $GALLERY_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "gallery";
  105. $pic = filter_input(INPUT_GET, "pic")??"";
  106. $pic = strip_tags($pic);
  107. $originalFilename = pathinfo($pic, PATHINFO_FILENAME);
  108. $originalFileExt = pathinfo($pic, PATHINFO_EXTENSION);
  109. $fileExt = strtolower(pathinfo($pic, PATHINFO_EXTENSION));
  110. if ($pic === APP_DEF_PROFILE_PIC) {
  111. $picPath = APP_PATH . DIRECTORY_SEPARATOR . "static" . $pic;
  112. } else {
  113. $picPath = $GALLERY_PATH . DIRECTORY_SEPARATOR . $pic;
  114. }
  115. if (filesize($picPath) <= APP_FILE_MAX_SIZE) {
  116. if ($fileExt === "jpg") {
  117. header("Content-Type: image/jpeg");
  118. } else {
  119. header("Content-Type: image/" . $fileExt);
  120. }
  121. echo(file_get_contents($picPath));
  122. exit(0);
  123. } else {
  124. die("picture size over app limits.");
  125. }
  126. break;
  127. case "imgj":
  128. $avatar = filter_input(INPUT_GET, "av")??"";
  129. $avatar = strip_tags($avatar);
  130. $jar = (int)substr(strip_tags(filter_input(INPUT_GET, "jar")??""),0,1);
  131. if ($jar >= 1 && $jar <= 3) {
  132. } else {
  133. die("jar parameter error.");
  134. }
  135. $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . $avatar;
  136. $JAR_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar" . $jar;
  137. $fileName = filter_input(INPUT_GET, "fn")??"";
  138. $fileName = strip_tags($fileName);
  139. $originalFilename = pathinfo($fileName, PATHINFO_FILENAME);
  140. $orioriFilename = explode("|", $originalFilename)[1];
  141. $originalFileExt = pathinfo($fileName, PATHINFO_EXTENSION);
  142. $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
  143. $filePath = $JAR_PATH . DIRECTORY_SEPARATOR . $fileName;
  144. if (filesize($filePath) <= APP_FILE_MAX_SIZE) {
  145. if ($fileExt === "jpg") {
  146. header("Content-Type: image/jpeg");
  147. } else {
  148. header("Content-Type: image/" . $fileExt);
  149. }
  150. //header("Content-Disposition: attachment; filename=" . $orioriFilename . ".$fileExt");
  151. echo(file_get_contents($filePath));
  152. exit(0);
  153. } else {
  154. die("file size over app limits.");
  155. }
  156. break;
  157. case "file":
  158. $avatar = filter_input(INPUT_GET, "av")??"";
  159. $avatar = strip_tags($avatar);
  160. $jar = (int)substr(strip_tags(filter_input(INPUT_GET, "jar")??""),0,1);
  161. if ($jar >= 1 && $jar <= 3) {
  162. } else {
  163. die("jar parameter error.");
  164. }
  165. $AVATAR_PATH = APP_DATA_PATH . DIRECTORY_SEPARATOR . $avatar;
  166. $JAR_PATH = $AVATAR_PATH . DIRECTORY_SEPARATOR . "magicjar" . $jar;
  167. $fileName = filter_input(INPUT_GET, "fn")??"";
  168. $fileName = strip_tags($fileName);
  169. $originalFilename = pathinfo($fileName, PATHINFO_FILENAME);
  170. $orioriFilename = explode("|", $originalFilename)[1];
  171. $originalFileExt = pathinfo($fileName, PATHINFO_EXTENSION);
  172. $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
  173. $filePath = $JAR_PATH . DIRECTORY_SEPARATOR . $fileName;
  174. if (filesize($filePath) <= APP_FILE_MAX_SIZE) {
  175. header("Content-Type: avatarfree/bin");
  176. header("Content-Disposition: attachment; filename=" . $orioriFilename . ".$fileExt");
  177. echo(file_get_contents($filePath));
  178. exit(0);
  179. } else {
  180. die("file size over app limits.");
  181. }
  182. break;
  183. default:
  184. define("SCRIPT_NAME", "home");
  185. define("SCRIPT_FILENAME", "home.php");
  186. define("AVATAR_NAME", $url);
  187. break;
  188. }
  189. if (SCRIPT_NAME==="err-404") {
  190. header("HTTP/1.1 404 Not Found");
  191. }
  192. require $scriptPath . "/" . SCRIPT_FILENAME;