diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index 32dff7e2..e4bd8c23 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -278,7 +278,11 @@ function compare($X, $Y){ ?>
  • - + <?=$DisplayName?>
    diff --git a/sections/collages/add_torrent.php b/sections/collages/add_torrent.php index 23ac3c9d..f1b631eb 100644 --- a/sections/collages/add_torrent.php +++ b/sections/collages/add_torrent.php @@ -4,9 +4,35 @@ include(SERVER_ROOT.'/classes/class_validate.php'); $Val = new VALIDATE; +function AddTorrent($CollageID, $GroupID) { + global $Cache, $LoggedUser, $DB; + + $DB->query("SELECT MAX(Sort) FROM collages_torrents WHERE CollageID='$CollageID'"); + list($Sort) = $DB->next_record(); + $Sort+=10; + + $DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); + if($DB->record_count() == 0) { + $DB->query("INSERT IGNORE INTO collages_torrents + (CollageID, GroupID, UserID, Sort, AddedOn) + VALUES + ('$CollageID', '$GroupID', '$LoggedUser[ID]', '$Sort', NOW())"); + + $DB->query("UPDATE collages SET NumTorrents=NumTorrents+1 WHERE ID='$CollageID'"); + + $Cache->delete_value('collage_'.$CollageID); + $Cache->delete_value('torrents_details_'.$GroupID); + $Cache->delete_value('torrent_collages_'.$GroupID); + + $DB->query("SELECT UserID FROM users_collage_subs WHERE CollageID=$CollageID"); + while (list($CacheUserID) = $DB->next_record()) { + $Cache->delete_value('collage_subs_user_new_'.$CacheUserID); + } + } +} + $CollageID = $_POST['collageid']; if(!is_number($CollageID)) { error(404); } - $DB->query("SELECT UserID, CategoryID, Locked, NumTorrents, MaxGroups, MaxGroupsPerUser FROM collages WHERE ID='$CollageID'"); list($UserID, $CategoryID, $Locked, $NumTorrents, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record(); if($CategoryID == 0 && $UserID!=$LoggedUser['ID'] && !check_perms('site_collages_delete')) { error(403); } @@ -19,54 +45,68 @@ } } +if ($_REQUEST['action'] == 'add_torrent') { + $URLRegex = '/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; + $Val->SetFields('url', '1','regex','The URL must be a link to a torrent on the site.',array('regex'=>$URLRegex)); + $Err = $Val->ValidateForm($_POST); -$URLRegex = '/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; -$Val->SetFields('url', '1','regex','The URL must be a link to a torrent on the site.',array('regex'=>$URLRegex)); -$Err = $Val->ValidateForm($_POST); - -if($Err) { - error($Err); - header('Location: collages.php?id='.$CollageID); - die(); -} - -$URL = $_POST['url']; - -// Get torrent ID -$URLRegex = '/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; -preg_match($URLRegex, $URL, $Matches); -$TorrentID=$Matches[2]; -if(!$TorrentID || (int)$TorrentID == 0) { error(404); } - -$DB->query("SELECT ID FROM torrents_group WHERE ID='$TorrentID'"); -list($GroupID) = $DB->next_record(); -if(!$GroupID) { - error('The torrent was not found in the database.'); -} - -$DB->query("SELECT MAX(Sort) FROM collages_torrents WHERE CollageID='$CollageID'"); -list($Sort) = $DB->next_record(); -$Sort+=10; - -$DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID' AND GroupID='$GroupID'"); -if($DB->record_count() == 0) { - $DB->query("INSERT IGNORE INTO collages_torrents - (CollageID, GroupID, UserID, Sort, AddedOn) - VALUES - ('$CollageID', '$GroupID', '$LoggedUser[ID]', '$Sort', NOW())"); - - $DB->query("UPDATE collages SET NumTorrents=NumTorrents+1 WHERE ID='$CollageID'"); - - $Cache->delete_value('collage_'.$CollageID); - $Cache->delete_value('torrents_details_'.$GroupID); - $Cache->delete_value('torrent_collages_'.$GroupID); - - $DB->query("SELECT UserID FROM users_collage_subs WHERE CollageID=$CollageID"); - while (list($CacheUserID) = $DB->next_record()) { - $Cache->delete_value('collage_subs_user_new_'.$CacheUserID); + if($Err) { + error($Err); + header('Location: collages.php?id='.$CollageID); + die(); } + + $URL = $_POST['url']; + + // Get torrent ID + $URLRegex = '/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; + preg_match($URLRegex, $URL, $Matches); + $TorrentID=$Matches[2]; + if(!$TorrentID || (int)$TorrentID == 0) { error(404); } + + $DB->query("SELECT ID FROM torrents_group WHERE ID='$TorrentID'"); + list($GroupID) = $DB->next_record(); + if(!$GroupID) { + error('The torrent was not found in the database.'); + } + + AddTorrent($CollageID, $GroupID); } else { - error('Torrent already in collage!'); + $URLRegex = '/^https?:\/\/(www\.|ssl\.)?'.NONSSL_SITE_URL.'\/torrents\.php\?(page=[0-9]+&)?id=([0-9]+)/i'; + + $URLs = explode("\n",$_REQUEST['urls']); + $GroupIDs = array(); + $Err = ''; + + foreach ($URLs as $URL) { + $URL = trim($URL); + if ($URL == '') { continue; } + + $Matches = array(); + if (preg_match($URLRegex, $URL, $Matches)) { + $GroupIDs[] = $Matches[3]; + $GroupID = $Matches[3]; + } else { + $Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site."; + break; + } + + $DB->query("SELECT ID FROM torrents_group WHERE ID='$GroupID'"); + if(!$DB->record_count()) { + $Err = "One of the entered URLs ($URL) does not correspond to a torrent on the site."; + break; + } + } + + if($Err) { + error($Err); + header('Location: collages.php?id='.$CollageID); + die(); + } + + foreach ($GroupIDs as $GroupID) { + AddTorrent($CollageID, $GroupID); + } } header('Location: collages.php?id='.$CollageID); diff --git a/sections/collages/collage.php b/sections/collages/collage.php index 680436f4..efc1a1e0 100644 --- a/sections/collages/collage.php +++ b/sections/collages/collage.php @@ -317,7 +317,11 @@ function compare($X, $Y){ ?>
  • - + <?=$DisplayName?>
    @@ -521,8 +525,8 @@ function compare($X, $Y){
    -
    Add torrent
    -
    + +
    @@ -533,6 +537,17 @@ function compare($X, $Y){ Enter the URL of a torrent on the site.
    +

    Comments

    diff --git a/sections/collages/index.php b/sections/collages/index.php index cbf9e2fe..48f4979f 100644 --- a/sections/collages/index.php +++ b/sections/collages/index.php @@ -13,6 +13,7 @@ require(SERVER_ROOT.'/sections/collages/new_handle.php'); break; case 'add_torrent': + case 'add_torrent_batch': if(!check_perms('site_collages_manage')) { error(403); } require(SERVER_ROOT.'/sections/collages/add_torrent.php'); break; diff --git a/sections/requests/new_edit.php b/sections/requests/new_edit.php index a313b16e..37c3bb3e 100644 --- a/sections/requests/new_edit.php +++ b/sections/requests/new_edit.php @@ -106,12 +106,13 @@ tg.Year, tg.ReleaseType, tg.WikiImage, - GROUP_CONCAT(t.Name SEPARATOR ', ') + GROUP_CONCAT(t.Name SEPARATOR ', '), + tg.CategoryID FROM torrents_group AS tg JOIN torrents_tags AS tt ON tt.GroupID=tg.ID JOIN tags AS t ON t.ID=tt.TagID WHERE tg.ID = ".$_GET['groupid']); - if(list($Title, $Year, $ReleaseType, $Image, $Tags) = $DB->next_record()) { + if(list($Title, $Year, $ReleaseType, $Image, $Tags, $CategoryID) = $DB->next_record()) { $GroupID = trim($_REQUEST['groupid']); } } @@ -324,7 +325,7 @@ If this request matches a torrent group already existing on the site, please indicate that here. - Torrent Group diff --git a/sections/requests/takenew_edit.php b/sections/requests/takenew_edit.php index aec629c2..885bfefa 100644 --- a/sections/requests/takenew_edit.php +++ b/sections/requests/takenew_edit.php @@ -182,12 +182,12 @@ $GroupID = $Matches[3]; } if (is_number($GroupID)) { - $DB->query("SELECT 1 FROM torrents_group WHERE ID = '$GroupID'"); + $DB->query("SELECT 1 FROM torrents_group WHERE ID = '$GroupID' AND CategoryID = 1"); if ($DB->record_count() == 0) { - $Err = "Torrent Group, if entered, must correspond to a group on the site."; + $Err = "Torrent Group, if entered, must correspond to a music group on the site."; } } else { - $Err = "Torrent Group, if entered, must correspond to a group on the site."; + $Err = "Torrent Group, if entered, must correspond to a music group on the site."; } } diff --git a/sections/staffpm/staff_inbox.php b/sections/staffpm/staff_inbox.php index ee37815a..a90c9479 100644 --- a/sections/staffpm/staff_inbox.php +++ b/sections/staffpm/staff_inbox.php @@ -6,6 +6,7 @@ $UserLevel = $LoggedUser['Class']; // Setup for current view mode +$SortStr = "IF(AssignedToUser = ".$LoggedUser['ID'].",0,1) ASC, "; switch ($View) { case 'unanswered': $ViewString = "Unanswered"; @@ -14,10 +15,12 @@ case 'open': $ViewString = "All open"; $WhereCondition = "WHERE (Level <= $UserLevel OR AssignedToUser='".$LoggedUser['ID']."') AND Status IN ('Open', 'Unanswered')"; + $SortStr = ''; break; case 'resolved': $ViewString = "Resolved"; $WhereCondition = "WHERE (Level <= $UserLevel OR AssignedToUser='".$LoggedUser['ID']."') AND Status='Resolved'"; + $SortStr = ''; break; case 'my': $ViewString = "My unanswered"; @@ -51,7 +54,7 @@ ResolverID FROM staff_pm_conversations $WhereCondition - ORDER BY IF(AssignedToUser = ".$LoggedUser['ID'].",0,1) ASC, Level DESC, Date DESC + ORDER BY $SortStr Level DESC, Date DESC LIMIT $Limit "); diff --git a/sections/top10/torrents.php b/sections/top10/torrents.php index 73c09118..25b64cf5 100644 --- a/sections/top10/torrents.php +++ b/sections/top10/torrents.php @@ -138,7 +138,8 @@ t.Snatched, t.Seeders, t.Leechers, - ((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data + ((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data, + g.ReleaseType FROM torrents AS t LEFT JOIN torrents_group AS g ON g.ID = t.GroupID "; @@ -225,7 +226,8 @@ } if(($Details=='all' || $Details=='seeded') && !$Filtered) { - if (!$TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum)) { + $TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum); + if ($TopTorrentsSeeded === FALSE) { $Query = $BaseQuery; if (!empty($Where)) { $Query .= ' WHERE '.$Where; } $Query .= " @@ -245,7 +247,7 @@ // generate a table based on data from most recent query to $DB function generate_torrent_table($Caption, $Tag, $Details, $Limit) { - global $LoggedUser,$Categories,$Debug; + global $LoggedUser,$Categories,$Debug,$ReleaseTypes; ?>

    Top @@ -288,7 +290,7 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) { foreach ($Details as $Detail) { list($TorrentID,$GroupID,$GroupName,$GroupCategoryID,$TorrentTags, $Format,$Encoding,$Media,$Scene,$HasLog,$HasCue,$LogScore,$Year,$GroupYear, - $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data) = $Detail; + $RemasterTitle,$Snatched,$Seeders,$Leechers,$Data,$ReleaseType) = $Detail; // highlight every other row $Rank++; @@ -307,6 +309,9 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) { if($GroupCategoryID==1 && $GroupYear>0) { $DisplayName.= " [$GroupYear]"; } + if($GroupCategoryID==1 && $ReleaseType > 0) { + $DisplayName.= ' ['.$ReleaseTypes[$ReleaseType].']'; + } // append extra info to torrent title $ExtraInfo=''; diff --git a/sections/torrents/browse2.php b/sections/torrents/browse2.php index c8829cf8..d037e670 100644 --- a/sections/torrents/browse2.php +++ b/sections/torrents/browse2.php @@ -712,6 +712,7 @@ function header_link($SortKey,$DefaultWay="desc") { $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } if($GroupVanityHouse) { $DisplayName .= ' [VH]'; } + $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']'; ?> Cover

    <?=$AltName?>

    query("SELECT 1 FROM users_main WHERE ID IN ($UserID, $TargetID)"); if ($DB->record_count() != 2) { error(403); } $DB->query("SELECT GroupID FROM users_dupes WHERE UserID = $TargetID"); list($TargetGroupID) = $DB->next_record(); $DB->query("SELECT u.GroupID, d.Comments FROM users_dupes AS u JOIN dupe_groups AS d ON d.ID = u.GroupID WHERE UserID = $UserID"); list($UserGroupID, $Comments) = $DB->next_record(); if ($TargetGroupID) { if ($TargetGroupID == $UserGroupID) { return; } if ($UserGroupID) { $DB->query("UPDATE users_dupes SET GroupID = $TargetGroupID WHERE GroupID = $UserGroupID"); $DB->query("UPDATE dupe_groups SET Comments = CONCAT('".db_string($Comments)."\n\n',Comments) WHERE ID = $TargetGroupID"); $DB->query("DELETE FROM dupe_groups WHERE ID = $UserGroupID"); } else { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $TargetGroupID)"); } } elseif ($UserGroupID) { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $UserGroupID)"); } else { $DB->query("INSERT INTO dupe_groups () VALUES ()"); $GroupID = $DB->inserted_id(); $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $GroupID)"); $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $GroupID)"); } } function unlink_user($UserID) { global $DB; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $DB->query("DELETE FROM users_dupes WHERE UserID='$UserID'"); $DB->query("DELETE g.* FROM dupe_groups AS g LEFT JOIN users_dupes AS u ON u.GroupID = g.ID WHERE u.GroupID IS NULL"); } function delete_dupegroup($GroupID) { global $DB; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("DELETE FROM dupe_groups WHERE ID = '$GroupID'"); } function dupe_comments($GroupID, $Comments) { global $DB, $Text; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("UPDATE dupe_groups SET Comments = '".db_string($Comments)."' WHERE ID = '$GroupID'"); } function user_dupes_table($UserID) { global $DB, $LoggedUser; $Text = new TEXT; if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $DB->query("SELECT d.ID, d.Comments FROM dupe_groups AS d JOIN users_dupes AS u ON u.GroupID = d.ID WHERE u.UserID = $UserID"); if (list($GroupID, $Comments) = $DB->next_record()) { $DB->query("SELECT m.ID FROM users_main AS m JOIN users_dupes AS d ON m.ID = d.UserID WHERE d.GroupID = $GroupID ORDER BY m.ID = $UserID DESC"); $DupeCount = $DB->record_count(); $Dupes = $DB->to_array(); } else { $DupeCount = 0; $Dupes = array(); } ?>
    Linked Account (View)
    0) { ?> "; } } for ($j = $i; $j < 5; $j++) { echo ''; } ?>
    \ No newline at end of file +query("SELECT 1 FROM users_main WHERE ID IN ($UserID, $TargetID)"); if ($DB->record_count() != 2) { error(403); } $DB->query("SELECT GroupID FROM users_dupes WHERE UserID = $TargetID"); list($TargetGroupID) = $DB->next_record(); $DB->query("SELECT u.GroupID, d.Comments FROM users_dupes AS u JOIN dupe_groups AS d ON d.ID = u.GroupID WHERE UserID = $UserID"); list($UserGroupID, $Comments) = $DB->next_record(); if ($TargetGroupID) { if ($TargetGroupID == $UserGroupID) { return; } if ($UserGroupID) { $DB->query("UPDATE users_dupes SET GroupID = $TargetGroupID WHERE GroupID = $UserGroupID"); $DB->query("UPDATE dupe_groups SET Comments = CONCAT('".db_string($Comments)."\n\n',Comments) WHERE ID = $TargetGroupID"); $DB->query("DELETE FROM dupe_groups WHERE ID = $UserGroupID"); } else { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $TargetGroupID)"); } } elseif ($UserGroupID) { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $UserGroupID)"); } else { $DB->query("INSERT INTO dupe_groups () VALUES ()"); $GroupID = $DB->inserted_id(); $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $GroupID)"); $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $GroupID)"); } } function unlink_user($UserID) { global $DB; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $DB->query("DELETE FROM users_dupes WHERE UserID='$UserID'"); $DB->query("DELETE g.* FROM dupe_groups AS g LEFT JOIN users_dupes AS u ON u.GroupID = g.ID WHERE u.GroupID IS NULL"); } function delete_dupegroup($GroupID) { global $DB; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("DELETE FROM dupe_groups WHERE ID = '$GroupID'"); } function dupe_comments($GroupID, $Comments) { global $DB, $Text; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("UPDATE dupe_groups SET Comments = '".db_string($Comments)."' WHERE ID = '$GroupID'"); } function user_dupes_table($UserID) { global $DB, $LoggedUser; $Text = new TEXT; if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $DB->query("SELECT d.ID, d.Comments FROM dupe_groups AS d JOIN users_dupes AS u ON u.GroupID = d.ID WHERE u.UserID = $UserID"); if (list($GroupID, $Comments) = $DB->next_record()) { $DB->query("SELECT m.ID FROM users_main AS m JOIN users_dupes AS d ON m.ID = d.UserID WHERE d.GroupID = $GroupID ORDER BY m.ID = $UserID DESC"); $DupeCount = $DB->record_count(); $Dupes = $DB->to_array(); } else { $DupeCount = 0; $Dupes = array(); } ?>
    Linked Account (View)
    ':''?> "; } } if ($DupeCount) { for ($j = $i; $j < 5; $j++) { echo ''; } ?>
    \ No newline at end of file diff --git a/sections/user/manage_linked.php b/sections/user/manage_linked.php index e1e26820..2c61f3ff 100644 --- a/sections/user/manage_linked.php +++ b/sections/user/manage_linked.php @@ -1 +1 @@ -query("SELECT ID FROM users_main WHERE Username LIKE '".db_string($Target)."'"); if (list($TargetID) = $DB->next_record()) { link_users($UserID, $TargetID); } else { error("User '$Target' not found."); } break; case 'comments': dupe_comments($_REQUEST['groupid'], $_REQUEST['dupecomments']); break; default: error(403); } echo '\o/'; header("Location: user.php?id=$UserID"); ?> \ No newline at end of file +query("SELECT ID FROM users_main WHERE Username LIKE '".db_string($Target)."'"); if (list($TargetID) = $DB->next_record()) { link_users($UserID, $TargetID); } else { error("User '$Target' not found."); } } $DB->query("SELECT GroupID FROM users_dupes WHERE UserID = '$UserID'"); list($GroupID) = $DB->next_record(); if ($_REQUEST['dupecomments'] && $GroupID) { dupe_comments($GroupID, $_REQUEST['dupecomments']); } break; default: error(403); } echo '\o/'; header("Location: user.php?id=$UserID"); ?> \ No newline at end of file diff --git a/sections/userhistory/subscribed_collages.php b/sections/userhistory/subscribed_collages.php index b99509a3..bda46cb3 100644 --- a/sections/userhistory/subscribed_collages.php +++ b/sections/userhistory/subscribed_collages.php @@ -146,7 +146,11 @@ - + <?=$AltName?> <?=$Categories[$GroupCategoryID-1]?>