Empty commit

This commit is contained in:
Git 2013-11-11 08:00:59 +00:00
parent dcd7d38564
commit 99c3e1e954
11 changed files with 1037 additions and 2395 deletions

View File

@ -55,8 +55,8 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
unset($GroupIDs[$i], $Found[$GroupID], $NotFound[$GroupID]);
continue;
}
$Data = G::$Cache->get_value($Key.$GroupID, true);
if (!empty($Data) && $Data['ver'] == CACHE::GROUP_VERSION) {
$Data = G::$Cache->get_value($Key . $GroupID, true);
if (!empty($Data) && is_array($Data) && $Data['ver'] == CACHE::GROUP_VERSION) {
unset($NotFound[$GroupID]);
$Found[$GroupID] = $Data['d'];
}
@ -65,7 +65,6 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
if (count($GroupIDs) === 0) {
return array();
}
$IDs = implode(',', array_keys($NotFound));
/*
Changing any of these attributes returned will cause very large, very dramatic site-wide chaos.
@ -76,6 +75,8 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
*/
if (count($NotFound) > 0) {
$IDs = implode(',', array_keys($NotFound));
$NotFound = array();
$QueryID = G::$DB->get_query_id();
G::$DB->query("
SELECT
@ -84,20 +85,12 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
WHERE g.ID IN ($IDs)");
while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
unset($NotFound[$Group['ID']]);
$Found[$Group['ID']] = $Group;
$Found[$Group['ID']]['Torrents'] = array();
$Found[$Group['ID']]['Artists'] = array();
$NotFound[$Group['ID']] = $Group;
$NotFound[$Group['ID']]['Torrents'] = array();
$NotFound[$Group['ID']]['Artists'] = array();
}
G::$DB->set_query_id($QueryID);
// Orphan torrents. There shouldn't ever be any
if (count($NotFound) > 0) {
foreach (array_keys($NotFound) as $GroupID) {
unset($Found[$GroupID]);
}
}
if ($Torrents) {
$QueryID = G::$DB->get_query_id();
G::$DB->query("
@ -106,27 +99,25 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true,
RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore,
FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile
FROM torrents AS t
WHERE GroupID IN($IDs)
WHERE GroupID IN ($IDs)
ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle,
RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID");
while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
$Found[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
$NotFound[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
}
G::$DB->set_query_id($QueryID);
// Cache it all
foreach ($Found as $GroupID => $GroupInfo) {
G::$Cache->cache_value("torrent_group_$GroupID",
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
G::$Cache->cache_value("torrent_group_light_$GroupID",
array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
}
} else {
foreach ($Found as $Group) {
G::$Cache->cache_value('torrent_group_light_'.$Group['ID'], array('ver' => CACHE::GROUP_VERSION, 'd' => $Found[$Group['ID']]), 0);
}
}
foreach ($NotFound as $GroupID => $GroupInfo) {
G::$Cache->cache_value($Key . $GroupID, array('ver' => CACHE::GROUP_VERSION, 'd' => $GroupInfo), 0);
}
$Found = $NotFound + $Found;
}
// Filter out orphans (elements that are == false)
$Found = array_filter($Found);
if ($GetArtists) {
$Artists = Artists::get_artists($GroupIDs);
} else {

View File

@ -29,46 +29,49 @@
<div class="header">
<h2>Clear a cache key</h2>
</div>
<form class="manage_form" name="cache" method="get" action="">
<input type="hidden" name="action" value="clear_cache" />
<table class="layout" cellpadding="2" cellspacing="1" border="0" align="center">
<tr>
<td>Key</td>
<td>
<table class="layout" cellpadding="2" cellspacing="1" border="0" align="center">
<tr>
<td>Key</td>
<td>
<form class="manage_form" name="cache" method="get" action="">
<input type="hidden" name="action" value="clear_cache" />
<select name="type">
<option value="view">View</option>
<option value="clear">Clear</option>
</select>
<input type="text" name="key" id="key" class="inputtext" value="<?=(isset($_GET['key']) && $_GET['submit'] != 'Multi' ? display_str($_GET['key']) : '')?>" />
<input type="submit" name="submit" value="Single" class="submit" />
</td>
</tr>
<tr>
<td>Multi-key</td>
<td>
</form>
</td>
</tr>
<tr>
<td>Multi-key</td>
<td>
<form class="manage_form" name="cache" method="get" action="">
<input type="hidden" name="action" value="clear_cache" />
<select name="type">
<option value="view">View</option>
<option value="clear">Clear</option>
</select>
<textarea type="text" name="key" id="key" class="inputtext"><?=(isset($_GET['key']) && $_GET['submit'] == 'Multi' ? display_str($_GET['key']) : '')?></textarea>
<input type="submit" name="submit" value="Multi" class="submit" />
</td>
</tr>
</form>
</td>
</tr>
<?
if (isset($Keys) && $_GET['type'] == 'view') {
foreach ($Keys as $Key) {
?>
<tr>
<td><?=display_str($Key)?></td>
<td>
<pre><? var_dump($Cache->get_value($Key)); ?></pre>
</td>
</tr>
<tr>
<td><?=display_str($Key)?></td>
<td>
<pre><? var_dump($Cache->get_value($Key)); ?></pre>
</td>
</tr>
<?
}
}
?>
</table>
</form>
</table>
<?
View::show_footer();

View File

@ -10,6 +10,15 @@
error(0);
}
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
if (!$DB->has_results()) {
error(404);
}
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
$Changed = false;
for ($i = 0; $i < count($AliasNames); $i++) {
@ -45,12 +54,6 @@
$AliasID = $DB->inserted_id();
}
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
$DB->query("
SELECT Name
FROM artists_group
@ -66,16 +69,6 @@
if ($DB->affected_rows()) {
$Changed = true;
$DB->query("
INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
WHERE ta.GroupID = '$GroupID'
AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
NumArtists = VALUES (NumArtists);");
Misc::write_log("Artist $ArtistID ($ArtistName) was added to the group $GroupID ($GroupName) as ".$ArtistTypes[$Importance].' by user '.$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "added artist $ArtistName as ".$ArtistTypes[$Importance], 0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,9 @@
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
if (!$DB->has_results()) {
error(404);
}
list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
// Get a count of how many groups or requests use this artist ID
@ -47,16 +50,6 @@
Artists::delete_artist($ArtistID);
}
$DB->query("
INSERT INTO torrents_group (ID, NumArtists)
SELECT ta.GroupID, COUNT(ta.ArtistID)
FROM torrents_artists AS ta
WHERE ta.GroupID = '$GroupID'
AND ta.Importance = '1'
GROUP BY ta.GroupID
ON DUPLICATE KEY UPDATE
NumArtists = VALUES (NumArtists);");
$Cache->delete_value("torrents_details_$GroupID"); // Delete torrent group cache
$Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
Misc::write_log('Artist ('.$ArtistTypes[$Importance].") $ArtistID ($ArtistName) was removed from the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');

View File

@ -228,7 +228,7 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
header("Location: torrents.php?id=$GroupID&torrentid=".$_GET['torrentid']);
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
include(SERVER_ROOT.'/sections/torrents/browse.php');
}
break;
}
@ -259,10 +259,10 @@ function js_pages($Action, $TorrentID, $NumResults, $CurrentPage) {
if ($GroupID) {
header("Location: torrents.php?id=$GroupID");
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
include(SERVER_ROOT.'/sections/torrents/browse.php');
}
} else {
include(SERVER_ROOT.'/sections/torrents/browse2.php');
include(SERVER_ROOT.'/sections/torrents/browse.php');
}
}
?>

View File

@ -25,7 +25,6 @@
if (empty($Year) || empty($ArtistName) || !is_number($Year) || empty($ReleaseType) || !is_number($ReleaseType)) {
error(0);
}
$SearchText = "$ArtistName $Title $Year";
$DB->query("
SELECT ArtistID, AliasID, Redirect, Name
FROM artists_alias
@ -49,9 +48,9 @@
$DB->query("
INSERT INTO torrents_group
(ArtistID, NumArtists, CategoryID, Name, Year, ReleaseType, Time, WikiBody, WikiImage, SearchText)
(ArtistID, CategoryID, Name, Year, ReleaseType, Time, WikiBody, WikiImage)
VALUES
($ArtistID, '1', '1', '$Title', '$Year', '$ReleaseType', '".sqltime()."', '', '', '$SearchText')");
($ArtistID, '1', '$Title', '$Year', '$ReleaseType', '".sqltime()."', '', '')");
$GroupID = $DB->inserted_id();
$DB->query("
@ -66,24 +65,22 @@
if (empty($Year) || !is_number($Year)) {
error(0);
}
$SearchText = "$Title $Year";
$DB->query("
INSERT INTO torrents_group
(CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
(CategoryID, Name, Year, Time, WikiBody, WikiImage)
VALUES
($NewCategoryID, '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
($NewCategoryID, '$Title', '$Year', '".sqltime()."', '', '')");
$GroupID = $DB->inserted_id();
break;
case 'Applications':
case 'Comics':
case 'E-Books':
case 'E-Learning Videos':
$SearchText = $Title;
$DB->query("
INSERT INTO torrents_group
(CategoryID, Name, Time, WikiBody, WikiImage, SearchText)
(CategoryID, Name, Time, WikiBody, WikiImage)
VALUES
($NewCategoryID, '$Title', '".sqltime()."', '', '', '$SearchText')");
($NewCategoryID, '$Title', '".sqltime()."', '', '')");
$GroupID = $DB->inserted_id();
break;
}

View File

@ -15,7 +15,6 @@
$ArtistName = db_string(trim($_POST['artist']));
$Title = db_string(trim($_POST['title']));
$Year = trim($_POST['year']);
$SearchText = db_string(trim($_POST['artist']) . ' ' . trim($_POST['title']) . ' ' . trim($_POST['year']));
if (!is_number($OldGroupID) || !is_number($TorrentID) || !is_number($Year) || !$OldGroupID || !$TorrentID || !$Year || empty($Title) || empty($ArtistName)) {
error(0);
@ -71,9 +70,9 @@
$DB->query("
INSERT INTO torrents_group
(ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText)
(ArtistID, CategoryID, Name, Year, Time, WikiBody, WikiImage)
VALUES
($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')");
($ArtistID, '1', '$Title', '$Year', '".sqltime()."', '', '')");
$GroupID = $DB->inserted_id();
$DB->query("

View File

@ -348,8 +348,6 @@
}
}
$SearchText = db_string(trim($Properties['Artist']).' '.trim($Properties['Title']).' '.trim($Properties['Year']));
//******************************************************************************//
//--------------- Generate torrent file ----------------------------------------//
@ -575,9 +573,9 @@
// Create torrent group
$DB->query("
INSERT INTO torrents_group
(ArtistID, CategoryID, Name, Year, RecordLabel, CatalogueNumber, Time, WikiBody, WikiImage, SearchText, ReleaseType, VanityHouse)
(ArtistID, CategoryID, Name, Year, RecordLabel, CatalogueNumber, Time, WikiBody, WikiImage, ReleaseType, VanityHouse)
VALUES
(0, $TypeID, ".$T['Title'].", $T[Year], $T[RecordLabel], $T[CatalogueNumber], '".sqltime()."', '".db_string($Body)."', $T[Image], '$SearchText', $T[ReleaseType], $T[VanityHouse])");
(0, $TypeID, ".$T['Title'].", $T[Year], $T[RecordLabel], $T[CatalogueNumber], '".sqltime()."', '".db_string($Body)."', $T[Image], $T[ReleaseType], $T[VanityHouse])");
$GroupID = $DB->inserted_id();
if ($Type == 'Music') {
foreach ($ArtistForm as $Importance => $Artists) {

View File

@ -216,16 +216,6 @@ function toggleTorrentSearch(mode) {
return false;
}
// For /sections/torrents/browse.php (not browse2.php)
function Bitrate() {
$('#other_bitrate').raw().value = '';
if ($('#bitrate').raw().options[$('#bitrate').raw().selectedIndex].value == 'Other') {
$('#other_bitrate_span').gshow();
} else {
$('#other_bitrate_span').ghide();
}
}
var ArtistFieldCount = 1;
function AddArtistField() {