From a6e79bbfe2f935448572ec8105dac77b8b3637aa Mon Sep 17 00:00:00 2001 From: Git Date: Thu, 9 Feb 2012 08:00:20 +0000 Subject: [PATCH] Empty commit --- sections/ajax/browse.php | 233 ++++++++++++++++++------------ sections/ajax/forum/index.php | 1 + sections/ajax/forum/thread.php | 7 +- sections/ajax/index.php | 3 - sections/better/files.php | 6 +- sections/better/folders.php | 1 + sections/better/single.php | 1 + sections/better/snatch.php | 1 + sections/better/tags.php | 1 + sections/better/transcode.php | 2 +- sections/better/upload.php | 1 + sections/forums/thread.php | 26 ++-- sections/torrents/notify.php | 12 +- sections/user/linkedfunctions.php | 2 +- static/functions/notifications.js | 32 +++- 15 files changed, 211 insertions(+), 118 deletions(-) diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php index 39b97971..944a21ce 100644 --- a/sections/ajax/browse.php +++ b/sections/ajax/browse.php @@ -5,23 +5,22 @@ include(SERVER_ROOT.'/sections/bookmarks/functions.php'); include(SERVER_ROOT.'/sections/torrents/functions.php'); -// Search by infohash -if(!empty($_GET['searchstr']) || !empty($_GET['groupname'])) { - if(!empty($_GET['searchstr'])) { - $InfoHash = $_GET['searchstr']; - } else { - $InfoHash = $_GET['groupname']; - } +// The "order by x" links on columns headers +function header_link($SortKey,$DefaultWay="desc") { + global $OrderBy,$OrderWay; + if($SortKey==$OrderBy) { + if($OrderWay=="desc") { $NewWay="asc"; } + else { $NewWay="desc"; } + } else { $NewWay=$DefaultWay; } - if($InfoHash = is_valid_torrenthash($InfoHash)) { - $InfoHash = db_string(pack("H*", $InfoHash)); - $DB->query("SELECT ID,GroupID FROM torrents WHERE info_hash='$InfoHash'"); - if($DB->record_count() > 0) { - list($ID, $GroupID) = $DB->next_record(); - header('Location: torrents.php?id='.$GroupID.'&torrentid='.$ID); - die(); - } - } + return "torrents.php?order_way=".$NewWay."&order_by=".$SortKey."&".get_url(array('order_way','order_by')); +} + +$TokenTorrents = $Cache->get_value('users_tokens_'.$UserID); +if (empty($TokenTorrents)) { + $DB->query("SELECT TorrentID FROM users_freeleeches WHERE UserID=$UserID AND Expired=FALSE"); + $TokenTorrents = $DB->collect('TorrentID'); + $Cache->cache_value('users_tokens_'.$UserID, $TokenTorrents); } // Setting default search options @@ -156,7 +155,7 @@ if(!empty($_GET[$Search])) { $_GET[$Search] = str_replace(array('%'), '', $_GET[$Search]); if($Search == 'filelist') { - $Queries[]='@filelist "'.$SS->EscapeString(strtr($_GET['filelist'], '.', " ")).'"~20'; + $Queries[]='@filelist "'.$SS->EscapeString($_GET['filelist']).'"~20'; } else { $Words = explode(' ', $_GET[$Search]); foreach($Words as $Key => &$Word) { @@ -255,14 +254,18 @@ $OrderWay = 'desc'; } -if(empty($_GET['order_by']) || !in_array($_GET['order_by'], array('year', 'time','size','seeders','leechers','snatched'))) { +if(empty($_GET['order_by']) || !in_array($_GET['order_by'], array('year','time','size','seeders','leechers','snatched','random'))) { $_GET['order_by'] = 'time'; $OrderBy = 'time'; // For header links +} elseif($_GET['order_by'] == 'random') { + $OrderBy = '@random'; + $Way = SPH_SORT_EXTENDED; + $SS->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); } else { $OrderBy = $_GET['order_by']; } -$SS->SetSortMode($Way, $_GET['order_by']); +$SS->SetSortMode($Way, $OrderBy); if(count($Queries)>0) { @@ -278,20 +281,6 @@ $Results = $SS->search($Query, '', 0, array(), '', ''); $TorrentCount = $SS->TotalResults; -/* -// If some were fetched from memcached, get their artists -if(!empty($Results['matches'])) { // Fetch the artists for groups - $GroupIDs = array_keys($Results['matches']); - $Artists = get_artists($GroupIDs); - - foreach($Artists as $GroupID=>$Data) { - if(!empty($Data[1])) { - $Results['matches'][$GroupID]['Artists']=$Data[1]; // Only use main artists - } - ksort($Results['matches'][$GroupID]); - } -} -*/ // These ones were not found in the cache, run SQL if(!empty($Results['notfound'])) { $SQLResults = get_groups($Results['notfound']); @@ -320,27 +309,25 @@ $Action = 'action=advanced'; } - // List of pages -$Pages=get_pages($Page,$TorrentCount,TORRENTS_PER_PAGE); if(count($Results)==0) { - $DB->query("SELECT - tags.Name, - ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score - FROM xbt_snatched AS s - INNER JOIN torrents AS t ON t.ID=s.fid - INNER JOIN torrents_group AS g ON t.GroupID=g.ID - INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID - INNER JOIN tags ON tags.ID=tt.TagID - WHERE s.uid='$LoggedUser[ID]' - AND tt.TagID<>'13679' - AND tt.TagID<>'4820' - AND tt.TagID<>'2838' - AND g.CategoryID='1' - AND tags.Uses > '10' - GROUP BY tt.TagID - ORDER BY Score DESC - LIMIT 8"); +$DB->query("SELECT + tags.Name, + ((COUNT(tags.Name)-2)*(SUM(tt.PositiveVotes)-SUM(tt.NegativeVotes)))/(tags.Uses*0.8) AS Score + FROM xbt_snatched AS s + INNER JOIN torrents AS t ON t.ID=s.fid + INNER JOIN torrents_group AS g ON t.GroupID=g.ID + INNER JOIN torrents_tags AS tt ON tt.GroupID=g.ID + INNER JOIN tags ON tags.ID=tt.TagID + WHERE s.uid='$LoggedUser[ID]' + AND tt.TagID<>'13679' + AND tt.TagID<>'4820' + AND tt.TagID<>'2838' + AND g.CategoryID='1' + AND tags.Uses > '10' + GROUP BY tt.TagID + ORDER BY Score DESC + LIMIT 8"); $JsonYouMightLike = array(); while(list($Tag)=$DB->next_record()) { @@ -364,14 +351,25 @@ $JsonGroups = array(); foreach($Results as $GroupID=>$Data) { - $JsonGroup = array(); - list($Artists, $GroupCatalogueNumber, $GroupID2, $GroupName, $GroupRecordLabel, $ReleaseType, $TagList, $Torrents, $GroupVanityHouse, $GroupYear, $CategoryID, $FreeTorrent, $HasCue, $HasLog, $TotalLeechers, $LogScore, $ReleaseType, $ReleaseType, $TotalSeeders, $MaxSize, $TotalSnatched, $GroupTime) = array_values($Data); + list($Artists, $GroupCatalogueNumber, $ExtendedArtists, $GroupID2, $GroupName, $GroupRecordLabel, $ReleaseType, $TagList, $Torrents, $GroupVanityHouse, $GroupYear, $CategoryID, $FreeTorrent, $HasCue, $HasLog, $TotalLeechers, $LogScore, $ReleaseType, $ReleaseType, $TotalSeeders, $MaxSize, $TotalSnatched, $GroupTime) = array_values($Data); + $TagList = explode(' ',str_replace('_','.',$TagList)); if(count($Torrents)>1 || $CategoryID==1) { // These torrents are in a group - $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); - $IsBookmarked = in_array($GroupID, $Bookmarks); + if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { + unset($ExtendedArtists[2]); + unset($ExtendedArtists[3]); + $DisplayName = display_artists($ExtendedArtists, false, false); + } elseif(!empty($Artists)) { + $DisplayName = display_artists(array(1=>$Artists), false, false); + } else { + $DisplayName=''; + } + $DisplayName.=''.$GroupName.''; + if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($GroupVanityHouse) { $DisplayName .= ' [VH]'; } + $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']'; $LastRemasterYear = '-'; $LastRemasterTitle = ''; @@ -384,8 +382,10 @@ $JsonTorrents = array(); foreach($Torrents as $TorrentID => $Data) { - $JsonTorrent = array(); - + // All of the individual torrents in the group + + // If they're using the advanced search and have chosen enabled grouping, we just skip the torrents that don't check out + $Filter = false; $Pass = false; @@ -477,18 +477,19 @@ if ($Data['Remastered'] && !$Data['RemasterYear']) { $FirstUnknown = !isset($FirstUnknown); } + + if (in_array($TorrentID, $TokenTorrents) && empty($Torrent['FreeTorrent'])) { + $Data['PersonalFL'] = 1; + } - if($CategoryID == 1 && ($Data['RemasterTitle'] != $LastRemasterTitle || - $Data['RemasterYear'] != $LastRemasterYear || - $Data['RemasterRecordLabel'] != $LastRemasterRecordLabel || - $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber) || - $FirstUnknown || $Data['Media'] != $LastMedia) { + if($CategoryID == 1 && ($Data['RemasterTitle'] != $LastRemasterTitle || $Data['RemasterYear'] != $LastRemasterYear || + $Data['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Data['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber) || $FirstUnknown || $Data['Media'] != $LastMedia) { $EditionID++; if($Data['Remastered'] && $Data['RemasterYear'] != 0) { $RemasterName = $Data['RemasterYear']; - $AddExtra = " - "; + $AddExtra = " - "; if($Data['RemasterRecordLabel']) { $RemasterName .= $AddExtra.display_str($Data['RemasterRecordLabel']); $AddExtra=' / '; } if($Data['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Data['RemasterCatalogueNumber']); $AddExtra=' / '; } if($Data['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Data['RemasterTitle']); $AddExtra=' / '; } @@ -505,29 +506,85 @@ $MasterName .= $AddExtra.display_str($Data['Media']); } } - $JsonTorrents[] = $Data; + $LastRemasterTitle = $Data['RemasterTitle']; + $LastRemasterYear = $Data['RemasterYear']; + $LastRemasterRecordLabel = $Data['RemasterRecordLabel']; + $LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber']; + $LastMedia = $Data['Media']; + + $JsonTorrents[] = array( + 'torrentId' => (int) $TorrentID, + 'editionId' => (int) $EditionID, + 'remastered' => $Data['Remastered'], + 'remasterYear' => (int) $Data['RemasterYear'], + 'remasterCatalogueNumber' => $Data['RemasterCatalogueNumber'], + 'remasterTitle' => $Data['RemasterTitle'], + 'media' => $Data['Media'], + 'encoding' => $Data['Encoding'], + 'format' => $Data['Format'], + 'hasLog' => $Data['HasLog'] == '1', + 'logScore' => (int) $Data['LogScore'], + 'hasCue' => $Data['HasCue'] == '1', + 'scene' => $Data['Scene'] == '1', + 'vanityHouse' => $Data['VanityHouse'] == '1', + 'fileCount' => (int) $Data['FileCount'], + 'time' => $Data['Time'], + 'size' => (int) $Data['Size'], + 'snatches' => (int) $Data['Snatched'], + 'seeders' => (int) $Data['Seeders'], + 'leechers' => (int) $Data['Leechers'], + 'isFreeleech' => $Data['FreeTorrent'] == '1', + 'isNeutralLeech' => $Data['FreeTorrent'] == '2', + 'isPersonalFreeleech' => in_array($TorrentID, $TokenTorrents), + 'canUseToken' => ($LoggedUser['FLTokens'] > 0) + && $Data['HasFile'] && ($Data['Size'] < 1073741824) + && !in_array($TorrentID, $TokenTorrents) + && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1') + ); } - $LastRemasterTitle = $Data['RemasterTitle']; - $LastRemasterYear = $Data['RemasterYear']; - $LastRemasterRecordLabel = $Data['RemasterRecordLabel']; - $LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber']; - $LastMedia = $Data['Media']; - $JsonGroup[] = $JsonTorrents; - } else { - list($TorrentID, $Data) = each($Torrents); - $JsonGroup = $Data; + + $JsonGroups[] = array( + 'groupId' => (int) $GroupID, + 'groupName' => $GroupName, + 'tags' => $TagList, + 'bookmarked' => in_array($GroupID, $Bookmarks), + 'vanityHouse' => $GroupVanityHouse, + 'groupYear' => (int) $GroupYear, + 'releaseType' => $ReleaseTypes[$ReleaseType], + 'groupTime' => $GroupTime, + 'maxSize' => (int) $MaxSize, + 'totalSnatched' => (int) $TotalSnatched, + 'totalSeeders' => (int) $TotalSeeders, + 'totalLeechers' => (int) $TotalLeechers, + 'torrents' => $JsonTorrents + ); + } + else { + // Viewing a type that does not require grouping + + list($TorrentID, $Data) = each($Torrents); + + $JsonGroups[] = array( + 'groupId' => (int) $GroupID, + 'groupName' => $GroupName, + 'torrentId' => (int) $TorrentID, + 'tags' => $TagList, + 'category' => $Categories[$CategoryID-1], + 'fileCount' => (int) $Data['FileCount'], + 'groupTime' => $GroupTime, + 'size' => (int) $Data['Size'], + 'snatches' => (int) $TotalSnatched, + 'seeders' => (int) $TotalSeeders, + 'leechers' => (int) $TotalLeechers, + 'isFreeleech' => $Data['FreeTorrent'] == '1', + 'isNeutralLeech' => $Data['FreeTorrent'] == '2', + 'isPersonalFreeleech' => in_array($TorrentID, $TokenTorrents), + 'canUseToken' => ($LoggedUser['FLTokens'] > 0) + && $Data['HasFile'] && ($Data['Size'] < 1073741824) + && !in_array($TorrentID, $TokenTorrents) + && empty($Data['FreeTorrent']) && ($LoggedUser['CanLeech'] == '1') + ); } - $JsonGroups[] = array( - 'groupId' => (int) $GroupID, - 'groupName' => $GroupName, - 'tags' => $TagList, - 'torrentId' => (int) $TorrentID, - 'categoryId' => (int) $Categories[$CategoryID-1], - 'totalSnatched' => (int) $TotalSnatched, - 'totalSeeders' => (int) $TotalSeeders, - 'totalLeechers' => (int) $TotalLeechers, - 'group' => $JsonGroup - ); } print @@ -536,10 +593,8 @@ 'status' => 'success', 'response' => array( 'currentPage' => intval($Page), - 'pages' => ceil($Pages/TORRENTS_PER_PAGE), + 'pages' => ceil($TorrentCount/TORRENTS_PER_PAGE), 'results' => $JsonGroups ) ) - ); - -?> + ); \ No newline at end of file diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index 9bea5044..515474a1 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -4,6 +4,7 @@ if (!empty($LoggedUser['DisableForums'])) { print json_encode(array('status' => 'failure')); + die(); } else { include(SERVER_ROOT.'/sections/forums/functions.php'); diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 24aad056..932970bb 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -30,9 +30,11 @@ die(); } else { print json_encode(array('status' => 'failure')); + die(); } } else { print json_encode(array('status' => 'failure')); + die(); } } else { $ThreadID = $_GET['threadid']; @@ -56,6 +58,7 @@ // Make sure they're allowed to look at the page if(!check_forumperm($ForumID)) { print json_encode(array('status' => 'failure')); + die(); } //Post links utilize the catalogue & key params to prevent issues with custom posts per page @@ -227,7 +230,7 @@ 'paranoia' => $Paranoia, 'artist' => $Artist == 1, 'donor' => $Donor == 1, - 'warned' => $Warned == 1, + 'warned' => ($Warned!='0000-00-00 00:00:00'), 'avatar' => $Avatar, 'enabled' => $Enabled == 2 ? false : true, 'userTitle' => $UserTitle @@ -254,4 +257,4 @@ 'posts' => $JsonPosts ) ) - ); \ No newline at end of file + ); diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 532f499b..a352d260 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -71,9 +71,6 @@ case 'index': require(SERVER_ROOT.'/sections/ajax/info.php'); break; - case 'usersearch': - require(SERVER_ROOT.'/sections/ajax/usersearch.php'); - break; case 'bookmarks': require(SERVER_ROOT.'/sections/ajax/bookmarks.php'); break; diff --git a/sections/better/files.php b/sections/better/files.php index 47b1bf27..7f2c77b3 100644 --- a/sections/better/files.php +++ b/sections/better/files.php @@ -51,9 +51,9 @@ $DisplayName = display_artists(array('1'=>$Artists)); } $DisplayName.=''.$GroupName.''; - if($GroupYear>0) { - $DisplayName.=" [".$GroupYear."]"; - } + if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } + $ExtraInfo = torrent_info($Torrents[$TorrentID]); if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; diff --git a/sections/better/folders.php b/sections/better/folders.php index 63e1bb11..d79dd8da 100644 --- a/sections/better/folders.php +++ b/sections/better/folders.php @@ -54,6 +54,7 @@ if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $ExtraInfo = torrent_info($Torrents[$TorrentID]); if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; diff --git a/sections/better/single.php b/sections/better/single.php index 7154cf63..8304321b 100644 --- a/sections/better/single.php +++ b/sections/better/single.php @@ -34,6 +34,7 @@ } $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $TagList=array(); if($TorrentTags!='') { diff --git a/sections/better/snatch.php b/sections/better/snatch.php index f079be19..f2a0b4e9 100644 --- a/sections/better/snatch.php +++ b/sections/better/snatch.php @@ -80,6 +80,7 @@ } $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1); diff --git a/sections/better/tags.php b/sections/better/tags.php index 225d7d27..cc996b71 100644 --- a/sections/better/tags.php +++ b/sections/better/tags.php @@ -53,6 +53,7 @@ if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $ExtraInfo = torrent_info($Torrents[$TorrentID]); if($ExtraInfo) { $DisplayName.=' - '.$ExtraInfo; diff --git a/sections/better/transcode.php b/sections/better/transcode.php index f240e692..a7e29c52 100644 --- a/sections/better/transcode.php +++ b/sections/better/transcode.php @@ -102,7 +102,7 @@ } $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } - + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1); $FlacID = 0; diff --git a/sections/better/upload.php b/sections/better/upload.php index 9692913b..b21b7ce7 100644 --- a/sections/better/upload.php +++ b/sections/better/upload.php @@ -67,6 +67,7 @@ } $DisplayName.=''.$GroupName.''; if($GroupYear>0) { $DisplayName.=" [".$GroupYear."]"; } + if($ReleaseType>0) { $DisplayName.=" [".$ReleaseTypes[$ReleaseType]."]"; } $MissingEncodings = array('V0 (VBR)'=>1, 'V2 (VBR)'=>1, '320'=>1); diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 118ede29..f9be9332 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -92,19 +92,21 @@ } $Thread = catalogue_select($Catalogue,$Page,$PerPage,THREAD_CATALOGUE); -$LastPost = end($Thread); -$LastPost = $LastPost['ID']; -reset($Thread); +if ($_GET['updatelastread'] != '0') { + $LastPost = end($Thread); + $LastPost = $LastPost['ID']; + reset($Thread); -//Handle last read -if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { - $DB->query("SELECT PostID From forums_last_read_topics WHERE UserID='$LoggedUser[ID]' AND TopicID='$ThreadID'"); - list($LastRead) = $DB->next_record(); - if($LastRead < $LastPost) { - $DB->query("INSERT INTO forums_last_read_topics - (UserID, TopicID, PostID) VALUES - ('$LoggedUser[ID]', '".$ThreadID ."', '".db_string($LastPost)."') - ON DUPLICATE KEY UPDATE PostID='$LastPost'"); + //Handle last read + if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { + $DB->query("SELECT PostID From forums_last_read_topics WHERE UserID='$LoggedUser[ID]' AND TopicID='$ThreadID'"); + list($LastRead) = $DB->next_record(); + if($LastRead < $LastPost) { + $DB->query("INSERT INTO forums_last_read_topics + (UserID, TopicID, PostID) VALUES + ('$LoggedUser[ID]', '".$ThreadID ."', '".db_string($LastPost)."') + ON DUPLICATE KEY UPDATE PostID='$LastPost'"); + } } } diff --git a/sections/torrents/notify.php b/sections/torrents/notify.php index 8a52a633..a634f0e5 100644 --- a/sections/torrents/notify.php +++ b/sections/torrents/notify.php @@ -62,20 +62,21 @@ ?> -

Latest notifications (clear all) (edit filters)

+

Latest notifications (clear all) (clear selected) (edit filters)

record_count()==0) { ?> -
+ No new notifications found! Edit notification filters
next_record()) { if(!$Result['FilterID']) { $Result['FilterID'] = 0; @@ -88,10 +89,13 @@ } unset($Result); foreach($FilterGroups as $ID => $FilterResults) { + $i++; ?> -

Matches for (Clear)

+

Matches for (Clear) (clear selected)

+
+ @@ -159,6 +163,7 @@ // print row ?> +
Name Files
@@ -184,6 +189,7 @@ } ?>
+
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(); $UserInfo = user_info($UserID); $TargetInfo = user_info($TargetID); if (!$UserInfo || !$TargetInfo) { return; } 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"); $GroupID = $UserGroupID; } else { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $TargetGroupID)"); $GroupID = $TargetGroupID; } } elseif ($UserGroupID) { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $UserGroupID)"); $GroupID = $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)"); } $AdminComment = sqltime()." - Linked accounts updated: [user]".$UserInfo['Username']."[/user] and [user]".$TargetInfo['Username']."[/user] linked by ".$LoggedUser['Username']; $DB->query("UPDATE users_info AS i JOIN users_dupes AS d ON d.UserID = i.UserID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d.GroupID = $GroupID"); } function unlink_user($UserID) { global $DB, $LoggedUser; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $UserInfo = user_info($UserID); if ($UserInfo === FALSE) { return; } $AdminComment = sqltime()." - Linked accounts updated: [user]".$UserInfo['Username']."[/user] unlinked by ".$LoggedUser['Username']; $DB->query("UPDATE users_info AS i JOIN users_dupes AS d1 ON d1.UserID = i.UserID JOIN users_dupes AS d2 ON d2.GroupID = d1.GroupID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d2.UserID = $UserID"); $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, $LoggedUser; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("SELECT SHA1(Comments) AS CommentHash FROM dupe_groups WHERE ID = $GroupID"); list($OldCommentHash) = $DB->next_record(); if ($OldCommentHash != sha1($Comments)) { $AdminComment = sqltime()." - Linked accounts updated: Comments updated by ".$LoggedUser['Username']; $DB->query("UPDATE dupe_groups SET Comments = '".db_string($Comments)."' WHERE ID = '$GroupID'"); $DB->query("UPDATE users_info AS i JOIN users_dupes AS d ON d.UserID = i.UserID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d.GroupID = $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 +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(); $UserInfo = user_info($UserID); $TargetInfo = user_info($TargetID); if (!$UserInfo || !$TargetInfo) { return; } 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"); $GroupID = $UserGroupID; } else { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($UserID, $TargetGroupID)"); $GroupID = $TargetGroupID; } } elseif ($UserGroupID) { $DB->query("INSERT INTO users_dupes (UserID, GroupID) VALUES ($TargetID, $UserGroupID)"); $GroupID = $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)"); } $AdminComment = sqltime()." - Linked accounts updated: [user]".$UserInfo['Username']."[/user] and [user]".$TargetInfo['Username']."[/user] linked by ".$LoggedUser['Username']; $DB->query("UPDATE users_info AS i JOIN users_dupes AS d ON d.UserID = i.UserID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d.GroupID = $GroupID"); } function unlink_user($UserID) { global $DB, $LoggedUser; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($UserID)) { error(403); } $UserInfo = user_info($UserID); if ($UserInfo === FALSE) { return; } $AdminComment = sqltime()." - Linked accounts updated: [user]".$UserInfo['Username']."[/user] unlinked by ".$LoggedUser['Username']; $DB->query("UPDATE users_info AS i JOIN users_dupes AS d1 ON d1.UserID = i.UserID JOIN users_dupes AS d2 ON d2.GroupID = d1.GroupID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d2.UserID = $UserID"); $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, $LoggedUser; authorize(); if (!check_perms('users_mod')) { error(403); } if (!is_number($GroupID)) { error(403); } $DB->query("SELECT SHA1(Comments) AS CommentHash FROM dupe_groups WHERE ID = $GroupID"); list($OldCommentHash) = $DB->next_record(); if ($OldCommentHash != sha1($Comments)) { $AdminComment = sqltime()." - Linked accounts updated: Comments updated by ".$LoggedUser['Username']; $DB->query("UPDATE dupe_groups SET Comments = '".db_string($Comments)."' WHERE ID = '$GroupID'"); $DB->query("UPDATE users_info AS i JOIN users_dupes AS d ON d.UserID = i.UserID SET i.AdminComment = CONCAT('".db_string($AdminComment)."\n\n', i.AdminComment) WHERE d.GroupID = $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 ASC"); $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/static/functions/notifications.js b/static/functions/notifications.js index df3e4b12..8a8668a1 100644 --- a/static/functions/notifications.js +++ b/static/functions/notifications.js @@ -1,5 +1,29 @@ -function Clear(torrentid) { - ajax.get("?action=notify_clearitem&torrentid=" + torrentid + "&auth=" + authkey, function() { - $("#torrent" + torrentid).remove(); - }); +function Clear(torrentid) { + ajax.get("?action=notify_clearitem&torrentid=" + torrentid + "&auth=" + authkey, function() { + $("#torrent" + torrentid).remove(); + }); +} + +function GroupClear(form) { + for (var i = 0; i < form.elements.length; i++ ) { + if (form.elements[i].type == 'checkbox' && form.elements[i].name != 'toggle') { + if (form.elements[i].checked == true) { + Clear(form.elements[i].value); + } + } + } +} + +function ToggleBoxes(form, newval) { + for (var i = 0; i < form.elements.length; i++ ) { + if (form.elements[i].type == 'checkbox' && form.elements[i].name != 'toggle') { + form.elements[i].checked = newval; + } + } +} + +function SuperGroupClear() { + for (var i = 0; i < document.forms.length; i++ ) { + GroupClear(document.forms[i]); + } } \ No newline at end of file