Gazelle/sections/torrents/index.php

272 lines
6.9 KiB
PHP
Raw Permalink Normal View History

2011-03-28 14:21:28 +00:00
<?
//Function used for pagination of peer/snatch/download lists on details.php
function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
2013-04-20 08:01:01 +00:00
$NumPages = ceil($NumResults / 100);
2011-03-28 14:21:28 +00:00
$PageLinks = array();
2013-04-20 08:01:01 +00:00
for ($i = 1; $i <= $NumPages; $i++) {
if ($i == $CurrentPage) {
$PageLinks[] = $i;
2011-03-28 14:21:28 +00:00
} else {
2013-07-04 08:00:56 +00:00
$PageLinks[] = "<a href=\"#\" onclick=\"$Action($TorrentID, $i)\">$i</a>";
2011-03-28 14:21:28 +00:00
}
}
2013-07-04 08:00:56 +00:00
return implode(' | ', $PageLinks);
2011-03-28 14:21:28 +00:00
}
2012-02-23 08:00:18 +00:00
// This gets used in a few places
$ArtistTypes = array(1 => 'Main', 2 => 'Guest', 3 => 'Remixer', 4 => 'Composer', 5 => 'Conductor', 6 => 'DJ/Compiler', 7 => 'Producer');
2013-04-20 08:01:01 +00:00
if (!empty($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
2011-03-28 14:21:28 +00:00
case 'edit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/edit.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'editgroup':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/editgroup.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'editgroupid':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/editgroupid.php');
break;
2013-02-22 08:00:24 +00:00
2013-03-02 08:00:34 +00:00
case 'changecategory':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takechangecategory.php');
break;
2013-12-16 08:00:48 +00:00
case 'grouplog':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/grouplog.php');
break;
2011-03-28 14:21:28 +00:00
case 'takeedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takeedit.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'newgroup':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takenewgroup.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'peerlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/peerlist.php');
break;
2013-04-20 08:01:01 +00:00
2011-03-28 14:21:28 +00:00
case 'snatchlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/snatchlist.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'downloadlist':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/downloadlist.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'redownload':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/redownload.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'revert':
case 'takegroupedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takegroupedit.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'nonwikiedit':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/nonwikiedit.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'rename':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/rename.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'merge':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/merge.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'add_alias':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/add_alias.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'delete_alias':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/delete_alias.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'history':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/history.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'delete':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/delete.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'takedelete':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takedelete.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'masspm':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/masspm.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'reseed':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/reseed.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'takemasspm':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/takemasspm.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'vote_tag':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/vote_tag.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'add_tag':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/add_tag.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'delete_tag':
enforce_login();
authorize();
include(SERVER_ROOT.'/sections/torrents/delete_tag.php');
break;
2013-02-22 08:00:24 +00:00
2011-03-28 14:21:28 +00:00
case 'notify':
enforce_login();
include(SERVER_ROOT.'/sections/torrents/notify.php');
break;
case 'manage_artists':
enforce_login();
2013-02-22 08:00:24 +00:00
require(SERVER_ROOT.'/sections/torrents/manage_artists.php');
2011-03-28 14:21:28 +00:00
break;
2012-10-27 08:00:09 +00:00
case 'notify_clear':
case 'notify_clear_item':
2013-02-15 08:00:35 +00:00
case 'notify_clear_items':
2012-10-27 08:00:09 +00:00
case 'notify_clearitem':
case 'notify_clear_filter':
2011-03-28 14:21:28 +00:00
case 'notify_cleargroup':
2012-10-27 08:00:09 +00:00
case 'notify_catchup':
case 'notify_catchup_filter':
2011-03-28 14:21:28 +00:00
authorize();
enforce_login();
2012-10-27 08:00:09 +00:00
require(SERVER_ROOT.'/sections/torrents/notify_actions.php');
2011-03-28 14:21:28 +00:00
break;
2012-10-27 08:00:09 +00:00
2011-03-28 14:21:28 +00:00
case 'download':
require(SERVER_ROOT.'/sections/torrents/download.php');
2011-03-28 14:21:28 +00:00
break;
2013-02-22 08:00:24 +00:00
2013-07-04 08:00:56 +00:00
case 'regen_filelist':
2013-04-20 08:01:01 +00:00
if (check_perms('users_mod') && !empty($_GET['torrentid']) && is_number($_GET['torrentid'])) {
2013-02-11 08:00:34 +00:00
Torrents::regenerate_filelist($_GET['torrentid']);
header('Location: torrents.php?torrentid='.$_GET['torrentid']);
2011-03-28 14:21:28 +00:00
die();
} else {
error(403);
}
break;
2013-07-04 08:00:56 +00:00
case 'fix_group':
2013-04-20 08:01:01 +00:00
if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
2013-07-04 08:00:56 +00:00
$DB->query('
SELECT COUNT(ID)
FROM torrents
WHERE GroupID = '.$_GET['groupid']);
2011-03-28 14:21:28 +00:00
list($Count) = $DB->next_record();
2013-04-20 08:01:01 +00:00
if ($Count == 0) {
2012-10-11 08:00:15 +00:00
Torrents::delete_group($_GET['groupid']);
2011-03-28 14:21:28 +00:00
} else {
}
2013-04-20 08:01:01 +00:00
if (!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
2011-03-28 14:21:28 +00:00
header('Location: artist.php?id='.$_GET['artistid']);
} else {
header('Location: torrents.php?id='.$_GET['groupid']);
}
} else {
error(403);
}
break;
2013-05-27 08:00:58 +00:00
case 'add_cover_art':
include(SERVER_ROOT.'/sections/torrents/add_cover_art.php');
break;
case 'remove_cover_art':
include(SERVER_ROOT.'/sections/torrents/remove_cover_art.php');
break;
2013-07-01 08:01:00 +00:00
case 'autocomplete_tags':
include(SERVER_ROOT.'/sections/torrents/autocomplete_tags.php');
break;
2011-03-28 14:21:28 +00:00
default:
enforce_login();
2013-02-22 08:00:24 +00:00
2013-04-20 08:01:01 +00:00
if (!empty($_GET['id'])) {
2011-03-28 14:21:28 +00:00
include(SERVER_ROOT.'/sections/torrents/details.php');
2013-04-20 08:01:01 +00:00
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
2013-07-04 08:00:56 +00:00
$DB->query('
SELECT GroupID
FROM torrents
WHERE ID = '.$_GET['torrentid']);
2011-03-28 14:21:28 +00:00
list($GroupID) = $DB->next_record();
2013-04-20 08:01:01 +00:00
if ($GroupID) {
2013-07-04 08:00:56 +00:00
header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
2011-03-28 14:21:28 +00:00
}
} else {
2013-11-11 08:00:59 +00:00
include(SERVER_ROOT.'/sections/torrents/browse.php');
2011-03-28 14:21:28 +00:00
}
break;
}
} else {
enforce_login();
2013-04-20 08:01:01 +00:00
if (!empty($_GET['id'])) {
2011-03-28 14:21:28 +00:00
include(SERVER_ROOT.'/sections/torrents/details.php');
2013-04-20 08:01:01 +00:00
} elseif (isset($_GET['torrentid']) && is_number($_GET['torrentid'])) {
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT GroupID
FROM torrents
WHERE ID = ".$_GET['torrentid']);
2011-03-28 14:21:28 +00:00
list($GroupID) = $DB->next_record();
2013-04-20 08:01:01 +00:00
if ($GroupID) {
2013-07-04 08:00:56 +00:00
header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid'].'#torrent'.$_GET['torrentid']);
2011-03-28 14:21:28 +00:00
} else {
2012-09-27 08:00:20 +00:00
header("Location: log.php?search=Torrent+$_GET[torrentid]");
2011-03-28 14:21:28 +00:00
}
2013-04-20 08:01:01 +00:00
} elseif (!empty($_GET['type'])) {
2011-03-28 14:21:28 +00:00
include(SERVER_ROOT.'/sections/torrents/user.php');
2013-04-20 08:01:01 +00:00
} elseif (!empty($_GET['groupname']) && !empty($_GET['forward'])) {
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT ID
FROM torrents_group
WHERE Name LIKE '".db_string($_GET['groupname'])."'");
2011-03-28 14:21:28 +00:00
list($GroupID) = $DB->next_record();
2013-04-20 08:01:01 +00:00
if ($GroupID) {
2013-07-04 08:00:56 +00:00
header("Location: torrents.php?id=$GroupID");
2011-03-28 14:21:28 +00:00
} else {
2013-11-11 08:00:59 +00:00
include(SERVER_ROOT.'/sections/torrents/browse.php');
2011-03-28 14:21:28 +00:00
}
} else {
2013-11-11 08:00:59 +00:00
include(SERVER_ROOT.'/sections/torrents/browse.php');
2011-03-28 14:21:28 +00:00
}
}
?>