BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <?php
  2. #declare(strict_types=1);
  3. //Function used for pagination of peer/snatch/download lists on details.php
  4. function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
  5. $NumPages = ceil($NumResults / 100);
  6. $PageLinks = [];
  7. for ($i = 1; $i <= $NumPages; $i++) {
  8. if ($i == $CurrentPage) {
  9. $PageLinks[] = $i;
  10. } else {
  11. $PageLinks[] = "<a href=\"#\" onclick=\"$Action($TorrentID, $i)\">$i</a>";
  12. }
  13. }
  14. return implode(' | ', $PageLinks);
  15. }
  16. // This gets used in a few places
  17. $ArtistTypes = array(1 => 'Main', 2 => 'Guest', 3 => 'Remixer', 4 => 'Composer', 5 => 'Conductor', 6 => 'DJ/Compiler', 7 => 'Producer');
  18. if (!empty($_REQUEST['action'])) {
  19. switch ($_REQUEST['action']) {
  20. case 'edit':
  21. enforce_login();
  22. include(SERVER_ROOT.'/sections/torrents/edit.php');
  23. break;
  24. case 'editgroup':
  25. enforce_login();
  26. include(SERVER_ROOT.'/sections/torrents/editgroup.php');
  27. break;
  28. case 'editgroupid':
  29. enforce_login();
  30. include(SERVER_ROOT.'/sections/torrents/editgroupid.php');
  31. break;
  32. case 'changecategory':
  33. enforce_login();
  34. include(SERVER_ROOT.'/sections/torrents/takechangecategory.php');
  35. break;
  36. case 'grouplog':
  37. enforce_login();
  38. include(SERVER_ROOT.'/sections/torrents/grouplog.php');
  39. break;
  40. case 'takeedit':
  41. enforce_login();
  42. include(SERVER_ROOT.'/sections/torrents/takeedit.php');
  43. break;
  44. case 'newgroup':
  45. enforce_login();
  46. include(SERVER_ROOT.'/sections/torrents/takenewgroup.php');
  47. break;
  48. case 'peerlist':
  49. enforce_login();
  50. include(SERVER_ROOT.'/sections/torrents/peerlist.php');
  51. break;
  52. case 'snatchlist':
  53. enforce_login();
  54. include(SERVER_ROOT.'/sections/torrents/snatchlist.php');
  55. break;
  56. case 'downloadlist':
  57. enforce_login();
  58. include(SERVER_ROOT.'/sections/torrents/downloadlist.php');
  59. break;
  60. case 'redownload':
  61. enforce_login();
  62. include(SERVER_ROOT.'/sections/torrents/redownload.php');
  63. break;
  64. case 'revert':
  65. case 'takegroupedit':
  66. enforce_login();
  67. include(SERVER_ROOT.'/sections/torrents/takegroupedit.php');
  68. break;
  69. case 'screenshotedit':
  70. enforce_login();
  71. include(SERVER_ROOT.'/sections/torrents/screenshotedit.php');
  72. break;
  73. case 'nonwikiedit':
  74. enforce_login();
  75. include(SERVER_ROOT.'/sections/torrents/nonwikiedit.php');
  76. break;
  77. case 'rename':
  78. enforce_login();
  79. include(SERVER_ROOT.'/sections/torrents/rename.php');
  80. break;
  81. case 'merge':
  82. enforce_login();
  83. include(SERVER_ROOT.'/sections/torrents/merge.php');
  84. break;
  85. case 'add_alias':
  86. enforce_login();
  87. include(SERVER_ROOT.'/sections/torrents/add_alias.php');
  88. break;
  89. case 'delete_alias':
  90. enforce_login();
  91. authorize();
  92. include(SERVER_ROOT.'/sections/torrents/delete_alias.php');
  93. break;
  94. case 'history':
  95. enforce_login();
  96. include(SERVER_ROOT.'/sections/torrents/history.php');
  97. break;
  98. case 'delete':
  99. enforce_login();
  100. include(SERVER_ROOT.'/sections/torrents/delete.php');
  101. break;
  102. case 'takedelete':
  103. enforce_login();
  104. include(SERVER_ROOT.'/sections/torrents/takedelete.php');
  105. break;
  106. case 'masspm':
  107. enforce_login();
  108. include(SERVER_ROOT.'/sections/torrents/masspm.php');
  109. break;
  110. case 'reseed':
  111. enforce_login();
  112. include(SERVER_ROOT.'/sections/torrents/reseed.php');
  113. break;
  114. case 'takemasspm':
  115. enforce_login();
  116. include(SERVER_ROOT.'/sections/torrents/takemasspm.php');
  117. break;
  118. case 'add_tag':
  119. enforce_login();
  120. include(SERVER_ROOT.'/sections/torrents/add_tag.php');
  121. break;
  122. case 'delete_tag':
  123. enforce_login();
  124. authorize();
  125. include(SERVER_ROOT.'/sections/torrents/delete_tag.php');
  126. break;
  127. case 'notify':
  128. enforce_login();
  129. include(SERVER_ROOT.'/sections/torrents/notify.php');
  130. break;
  131. case 'manage_artists':
  132. enforce_login();
  133. require(SERVER_ROOT.'/sections/torrents/manage_artists.php');
  134. break;
  135. case 'notify_clear':
  136. case 'notify_clear_item':
  137. case 'notify_clear_items':
  138. case 'notify_clearitem':
  139. case 'notify_clear_filter':
  140. case 'notify_cleargroup':
  141. case 'notify_catchup':
  142. case 'notify_catchup_filter':
  143. authorize();
  144. enforce_login();
  145. require(SERVER_ROOT.'/sections/torrents/notify_actions.php');
  146. break;
  147. case 'download':
  148. require(SERVER_ROOT.'/sections/torrents/download.php');
  149. break;
  150. case 'regen_filelist':
  151. if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  152. Torrents::regenerate_filelist($_GET['torrentid']);
  153. header('Location: torrents.php?torrentid='.$_GET['torrentid']);
  154. error();
  155. } else {
  156. error(403);
  157. }
  158. break;
  159. case 'fix_group':
  160. if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  161. $DB->query('
  162. SELECT COUNT(ID)
  163. FROM torrents
  164. WHERE GroupID = '.$_GET['groupid']);
  165. list($Count) = $DB->next_record();
  166. if ($Count == 0) {
  167. Torrents::delete_group($_GET['groupid']);
  168. }
  169. if (!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  170. header('Location: artist.php?id='.$_GET['artistid']);
  171. } else {
  172. header('Location: torrents.php?id='.$_GET['groupid']);
  173. }
  174. } else {
  175. error(403);
  176. }
  177. break;
  178. case 'add_cover_art':
  179. include(SERVER_ROOT.'/sections/torrents/add_cover_art.php');
  180. break;
  181. case 'remove_cover_art':
  182. include(SERVER_ROOT.'/sections/torrents/remove_cover_art.php');
  183. break;
  184. case 'autocomplete_tags':
  185. include(SERVER_ROOT.'/sections/torrents/autocomplete_tags.php');
  186. break;
  187. default:
  188. enforce_login();
  189. if (!empty($_GET['id'])) {
  190. include(SERVER_ROOT.'/sections/torrents/details.php');
  191. } elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  192. $DB->query('
  193. SELECT GroupID
  194. FROM torrents
  195. WHERE ID = '.$_GET['torrentid']);
  196. list($GroupID) = $DB->next_record();
  197. if ($GroupID) {
  198. header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
  199. }
  200. } else {
  201. include(SERVER_ROOT.'/sections/torrents/browse.php');
  202. }
  203. break;
  204. }
  205. } else {
  206. enforce_login();
  207. if (!empty($_GET['id'])) {
  208. include(SERVER_ROOT.'/sections/torrents/details.php');
  209. } elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  210. $DB->query("
  211. SELECT GroupID
  212. FROM torrents
  213. WHERE ID = ".$_GET['torrentid']);
  214. list($GroupID) = $DB->next_record();
  215. if ($GroupID) {
  216. header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid'].'#torrent'.$_GET['torrentid']);
  217. } else {
  218. header("Location: log.php?search=Torrent+$_GET[torrentid]");
  219. }
  220. } elseif (!empty($_GET['type'])) {
  221. include(SERVER_ROOT.'/sections/torrents/user.php');
  222. } elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
  223. $DB->query("
  224. SELECT ID
  225. FROM torrents_group
  226. WHERE Name LIKE '".db_string($_GET['groupname'])."'");
  227. list($GroupID) = $DB->next_record();
  228. if ($GroupID) {
  229. header("Location: torrents.php?id=$GroupID");
  230. } else {
  231. include(SERVER_ROOT.'/sections/torrents/browse.php');
  232. }
  233. } else {
  234. include(SERVER_ROOT.'/sections/torrents/browse.php');
  235. }
  236. }
  237. ?>