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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 'add_tag':
  118. enforce_login();
  119. include(SERVER_ROOT.'/sections/torrents/add_tag.php');
  120. break;
  121. case 'delete_tag':
  122. enforce_login();
  123. authorize();
  124. include(SERVER_ROOT.'/sections/torrents/delete_tag.php');
  125. break;
  126. case 'notify':
  127. enforce_login();
  128. include(SERVER_ROOT.'/sections/torrents/notify.php');
  129. break;
  130. case 'manage_artists':
  131. enforce_login();
  132. require(SERVER_ROOT.'/sections/torrents/manage_artists.php');
  133. break;
  134. case 'notify_clear':
  135. case 'notify_clear_item':
  136. case 'notify_clear_items':
  137. case 'notify_clearitem':
  138. case 'notify_clear_filter':
  139. case 'notify_cleargroup':
  140. case 'notify_catchup':
  141. case 'notify_catchup_filter':
  142. authorize();
  143. enforce_login();
  144. require(SERVER_ROOT.'/sections/torrents/notify_actions.php');
  145. break;
  146. case 'download':
  147. require(SERVER_ROOT.'/sections/torrents/download.php');
  148. break;
  149. case 'regen_filelist':
  150. if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  151. Torrents::regenerate_filelist($_GET['torrentid']);
  152. header('Location: torrents.php?torrentid='.$_GET['torrentid']);
  153. die();
  154. } else {
  155. error(403);
  156. }
  157. break;
  158. case 'fix_group':
  159. if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
  160. $DB->query('
  161. SELECT COUNT(ID)
  162. FROM torrents
  163. WHERE GroupID = '.$_GET['groupid']);
  164. list($Count) = $DB->next_record();
  165. if ($Count == 0) {
  166. Torrents::delete_group($_GET['groupid']);
  167. }
  168. if (!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
  169. header('Location: artist.php?id='.$_GET['artistid']);
  170. } else {
  171. header('Location: torrents.php?id='.$_GET['groupid']);
  172. }
  173. } else {
  174. error(403);
  175. }
  176. break;
  177. case 'add_cover_art':
  178. include(SERVER_ROOT.'/sections/torrents/add_cover_art.php');
  179. break;
  180. case 'remove_cover_art':
  181. include(SERVER_ROOT.'/sections/torrents/remove_cover_art.php');
  182. break;
  183. case 'autocomplete_tags':
  184. include(SERVER_ROOT.'/sections/torrents/autocomplete_tags.php');
  185. break;
  186. default:
  187. enforce_login();
  188. if (!empty($_GET['id'])) {
  189. include(SERVER_ROOT.'/sections/torrents/details.php');
  190. } elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  191. $DB->query('
  192. SELECT GroupID
  193. FROM torrents
  194. WHERE ID = '.$_GET['torrentid']);
  195. list($GroupID) = $DB->next_record();
  196. if ($GroupID) {
  197. header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
  198. }
  199. } else {
  200. include(SERVER_ROOT.'/sections/torrents/browse.php');
  201. }
  202. break;
  203. }
  204. } else {
  205. enforce_login();
  206. if (!empty($_GET['id'])) {
  207. include(SERVER_ROOT.'/sections/torrents/details.php');
  208. } elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
  209. $DB->query("
  210. SELECT GroupID
  211. FROM torrents
  212. WHERE ID = ".$_GET['torrentid']);
  213. list($GroupID) = $DB->next_record();
  214. if ($GroupID) {
  215. header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid'].'#torrent'.$_GET['torrentid']);
  216. } else {
  217. header("Location: log.php?search=Torrent+$_GET[torrentid]");
  218. }
  219. } elseif (!empty($_GET['type'])) {
  220. include(SERVER_ROOT.'/sections/torrents/user.php');
  221. } elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
  222. $DB->query("
  223. SELECT ID
  224. FROM torrents_group
  225. WHERE Name LIKE '".db_string($_GET['groupname'])."'");
  226. list($GroupID) = $DB->next_record();
  227. if ($GroupID) {
  228. header("Location: torrents.php?id=$GroupID");
  229. } else {
  230. include(SERVER_ROOT.'/sections/torrents/browse.php');
  231. }
  232. } else {
  233. include(SERVER_ROOT.'/sections/torrents/browse.php');
  234. }
  235. }
  236. ?>