Oppaitime'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.6KB

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