|
@@ -83,10 +83,10 @@ class Torrents
|
83
|
83
|
$NotFound = [];
|
84
|
84
|
$QueryID = G::$DB->get_query_id();
|
85
|
85
|
G::$DB->query("
|
86
|
|
- SELECT
|
87
|
|
- ID, Name, NameRJ, NameJP, Year, CatalogueNumber, Pages, Studio, Series, DLSiteID, TagList, WikiImage, CategoryID
|
88
|
|
- FROM torrents_group
|
89
|
|
- WHERE ID IN ($IDs)");
|
|
86
|
+ SELECT
|
|
87
|
+ ID, Name, NameRJ, NameJP, Year, CatalogueNumber, Pages, Studio, Series, DLSiteID, TagList, WikiImage, CategoryID
|
|
88
|
+ FROM torrents_group
|
|
89
|
+ WHERE ID IN ($IDs)");
|
90
|
90
|
|
91
|
91
|
while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
|
92
|
92
|
$NotFound[$Group['ID']] = $Group;
|
|
@@ -115,15 +115,15 @@ class Torrents
|
115
|
115
|
if ($Torrents) {
|
116
|
116
|
$QueryID = G::$DB->get_query_id();
|
117
|
117
|
G::$DB->query("
|
118
|
|
- SELECT
|
119
|
|
- ID, GroupID, Media, Container, Codec, Resolution, AudioFormat,
|
120
|
|
- Language, Subbing, Subber, Censored, Archive, FileCount, FreeTorrent,
|
121
|
|
- Size, Leechers, Seeders, Snatched, Time, f.ExpiryTime, ID AS HasFile,
|
122
|
|
- FreeLeechType, hex(info_hash) as info_hash
|
123
|
|
- FROM torrents
|
124
|
|
- LEFT JOIN shop_freeleeches AS f ON f.TorrentID=ID
|
125
|
|
- WHERE GroupID IN ($IDs)
|
126
|
|
- ORDER BY GroupID, Media, Container, Codec, ID");
|
|
118
|
+ SELECT
|
|
119
|
+ ID, GroupID, Media, Container, Codec, Resolution, AudioFormat,
|
|
120
|
+ Language, Subbing, Subber, Censored, Archive, FileCount, FreeTorrent,
|
|
121
|
+ Size, Leechers, Seeders, Snatched, Time, f.ExpiryTime, ID AS HasFile,
|
|
122
|
+ FreeLeechType, hex(info_hash) as info_hash
|
|
123
|
+ FROM torrents
|
|
124
|
+ LEFT JOIN shop_freeleeches AS f ON f.TorrentID=ID
|
|
125
|
+ WHERE GroupID IN ($IDs)
|
|
126
|
+ ORDER BY GroupID, Media, Container, Codec, ID");
|
127
|
127
|
while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
|
128
|
128
|
$NotFound[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
|
129
|
129
|
}
|
|
@@ -250,10 +250,10 @@ class Torrents
|
250
|
250
|
$QueryID = G::$DB->get_query_id();
|
251
|
251
|
G::$DB->query(
|
252
|
252
|
"
|
253
|
|
- INSERT INTO group_log
|
254
|
|
- (GroupID, TorrentID, UserID, Info, Time, Hidden)
|
255
|
|
- VALUES
|
256
|
|
- (?, ?, ?, ?, NOW(), ?)",
|
|
253
|
+ INSERT INTO group_log
|
|
254
|
+ (GroupID, TorrentID, UserID, Info, Time, Hidden)
|
|
255
|
+ VALUES
|
|
256
|
+ (?, ?, ?, ?, NOW(), ?)",
|
257
|
257
|
$GroupID,
|
258
|
258
|
$TorrentID,
|
259
|
259
|
$UserID,
|
|
@@ -275,16 +275,16 @@ class Torrents
|
275
|
275
|
$QueryID = G::$DB->get_query_id();
|
276
|
276
|
if (!$GroupID) {
|
277
|
277
|
G::$DB->query("
|
278
|
|
- SELECT GroupID, UserID
|
279
|
|
- FROM torrents
|
280
|
|
- WHERE ID = '$ID'");
|
|
278
|
+ SELECT GroupID, UserID
|
|
279
|
+ FROM torrents
|
|
280
|
+ WHERE ID = '$ID'");
|
281
|
281
|
list($GroupID, $UploaderID) = G::$DB->next_record();
|
282
|
282
|
}
|
283
|
283
|
if (empty($UserID)) {
|
284
|
284
|
G::$DB->query("
|
285
|
|
- SELECT UserID
|
286
|
|
- FROM torrents
|
287
|
|
- WHERE ID = '$ID'");
|
|
285
|
+ SELECT UserID
|
|
286
|
+ FROM torrents
|
|
287
|
+ WHERE ID = '$ID'");
|
288
|
288
|
list($UserID) = G::$DB->next_record();
|
289
|
289
|
}
|
290
|
290
|
|
|
@@ -298,21 +298,21 @@ class Torrents
|
298
|
298
|
}
|
299
|
299
|
|
300
|
300
|
G::$DB->query("
|
301
|
|
- SELECT info_hash
|
302
|
|
- FROM torrents
|
303
|
|
- WHERE ID = $ID");
|
|
301
|
+ SELECT info_hash
|
|
302
|
+ FROM torrents
|
|
303
|
+ WHERE ID = $ID");
|
304
|
304
|
list($InfoHash) = G::$DB->next_record(MYSQLI_BOTH, false);
|
305
|
305
|
G::$DB->query("
|
306
|
|
- DELETE FROM torrents
|
307
|
|
- WHERE ID = $ID");
|
|
306
|
+ DELETE FROM torrents
|
|
307
|
+ WHERE ID = $ID");
|
308
|
308
|
Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
|
309
|
309
|
|
310
|
310
|
G::$Cache->decrement('stats_torrent_count');
|
311
|
311
|
|
312
|
312
|
G::$DB->query("
|
313
|
|
- SELECT COUNT(ID)
|
314
|
|
- FROM torrents
|
315
|
|
- WHERE GroupID = '$GroupID'");
|
|
313
|
+ SELECT COUNT(ID)
|
|
314
|
+ FROM torrents
|
|
315
|
+ WHERE GroupID = '$GroupID'");
|
316
|
316
|
list($Count) = G::$DB->next_record();
|
317
|
317
|
|
318
|
318
|
if ($Count == 0) {
|
|
@@ -323,24 +323,24 @@ class Torrents
|
323
|
323
|
|
324
|
324
|
// Torrent notifications
|
325
|
325
|
G::$DB->query("
|
326
|
|
- SELECT UserID
|
327
|
|
- FROM users_notify_torrents
|
328
|
|
- WHERE TorrentID = '$ID'");
|
|
326
|
+ SELECT UserID
|
|
327
|
+ FROM users_notify_torrents
|
|
328
|
+ WHERE TorrentID = '$ID'");
|
329
|
329
|
while (list($UserID) = G::$DB->next_record()) {
|
330
|
330
|
G::$Cache->delete_value("notifications_new_$UserID");
|
331
|
331
|
}
|
332
|
332
|
G::$DB->query("
|
333
|
|
- DELETE FROM users_notify_torrents
|
334
|
|
- WHERE TorrentID = '$ID'");
|
|
333
|
+ DELETE FROM users_notify_torrents
|
|
334
|
+ WHERE TorrentID = '$ID'");
|
335
|
335
|
|
336
|
336
|
G::$DB->query("
|
337
|
|
- UPDATE reportsv2
|
338
|
|
- SET
|
339
|
|
- Status = 'Resolved',
|
340
|
|
- LastChangeTime = NOW(),
|
341
|
|
- ModComment = 'Report already dealt with (torrent deleted)'
|
342
|
|
- WHERE TorrentID = ?
|
343
|
|
- AND Status != 'Resolved'", $ID);
|
|
337
|
+ UPDATE reportsv2
|
|
338
|
+ SET
|
|
339
|
+ Status = 'Resolved',
|
|
340
|
+ LastChangeTime = NOW(),
|
|
341
|
+ ModComment = 'Report already dealt with (torrent deleted)'
|
|
342
|
+ WHERE TorrentID = ?
|
|
343
|
+ AND Status != 'Resolved'", $ID);
|
344
|
344
|
$Reports = G::$DB->affected_rows();
|
345
|
345
|
if ($Reports) {
|
346
|
346
|
G::$Cache->decrement('num_torrent_reportsv2', $Reports);
|
|
@@ -348,18 +348,18 @@ class Torrents
|
348
|
348
|
|
349
|
349
|
unlink(TORRENT_STORE.$ID.'.torrent');
|
350
|
350
|
G::$DB->query("
|
351
|
|
- DELETE FROM torrents_bad_tags
|
352
|
|
- WHERE TorrentID = ?", $ID);
|
|
351
|
+ DELETE FROM torrents_bad_tags
|
|
352
|
+ WHERE TorrentID = ?", $ID);
|
353
|
353
|
G::$DB->query("
|
354
|
|
- DELETE FROM torrents_bad_folders
|
355
|
|
- WHERE TorrentID = ?", $ID);
|
|
354
|
+ DELETE FROM torrents_bad_folders
|
|
355
|
+ WHERE TorrentID = ?", $ID);
|
356
|
356
|
G::$DB->query("
|
357
|
|
- DELETE FROM torrents_bad_files
|
358
|
|
- WHERE TorrentID = ?", $ID);
|
|
357
|
+ DELETE FROM torrents_bad_files
|
|
358
|
+ WHERE TorrentID = ?", $ID);
|
359
|
359
|
|
360
|
360
|
G::$DB->query("
|
361
|
|
- DELETE FROM shop_freeleeches
|
362
|
|
- WHERE TorrentID = ?", $ID);
|
|
361
|
+ DELETE FROM shop_freeleeches
|
|
362
|
+ WHERE TorrentID = ?", $ID);
|
363
|
363
|
$FLs = G::$DB->affected_rows();
|
364
|
364
|
if ($FLs) {
|
365
|
365
|
G::$Cache->delete_value('shop_freeleech_list');
|
|
@@ -367,8 +367,8 @@ class Torrents
|
367
|
367
|
|
368
|
368
|
// Tells Sphinx that the group is removed
|
369
|
369
|
G::$DB->query("
|
370
|
|
- REPLACE INTO sphinx_delta (ID, Time)
|
371
|
|
- VALUES (?, UNIX_TIMESTAMP())", $ID);
|
|
370
|
+ REPLACE INTO sphinx_delta (ID, Time)
|
|
371
|
+ VALUES (?, UNIX_TIMESTAMP())", $ID);
|
372
|
372
|
|
373
|
373
|
G::$Cache->delete_value("torrent_download_$ID");
|
374
|
374
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
|
@@ -389,9 +389,9 @@ class Torrents
|
389
|
389
|
Misc::write_log("Group $GroupID automatically deleted (No torrents have this group).");
|
390
|
390
|
|
391
|
391
|
G::$DB->query("
|
392
|
|
- SELECT CategoryID
|
393
|
|
- FROM torrents_group
|
394
|
|
- WHERE ID = ?", $GroupID);
|
|
392
|
+ SELECT CategoryID
|
|
393
|
+ FROM torrents_group
|
|
394
|
+ WHERE ID = ?", $GroupID);
|
395
|
395
|
list($Category) = G::$DB->next_record();
|
396
|
396
|
if ($Category == 1) {
|
397
|
397
|
G::$Cache->decrement('stats_album_count');
|
|
@@ -400,18 +400,18 @@ class Torrents
|
400
|
400
|
|
401
|
401
|
// Collages
|
402
|
402
|
G::$DB->query("
|
403
|
|
- SELECT CollageID
|
404
|
|
- FROM collages_torrents
|
405
|
|
- WHERE GroupID = ?", $GroupID);
|
|
403
|
+ SELECT CollageID
|
|
404
|
+ FROM collages_torrents
|
|
405
|
+ WHERE GroupID = ?", $GroupID);
|
406
|
406
|
if (G::$DB->has_results()) {
|
407
|
407
|
$CollageIDs = G::$DB->collect('CollageID');
|
408
|
408
|
G::$DB->query("
|
409
|
|
- UPDATE collages
|
410
|
|
- SET NumTorrents = NumTorrents - 1
|
411
|
|
- WHERE ID IN (".implode(', ', $CollageIDs).')');
|
|
409
|
+ UPDATE collages
|
|
410
|
+ SET NumTorrents = NumTorrents - 1
|
|
411
|
+ WHERE ID IN (".implode(', ', $CollageIDs).')');
|
412
|
412
|
G::$DB->query("
|
413
|
|
- DELETE FROM collages_torrents
|
414
|
|
- WHERE GroupID = ?", $GroupID);
|
|
413
|
+ DELETE FROM collages_torrents
|
|
414
|
+ WHERE GroupID = ?", $GroupID);
|
415
|
415
|
|
416
|
416
|
foreach ($CollageIDs as $CollageID) {
|
417
|
417
|
G::$Cache->delete_value("collage_$CollageID");
|
|
@@ -422,14 +422,14 @@ class Torrents
|
422
|
422
|
// Artists
|
423
|
423
|
// Collect the artist IDs and then wipe the torrents_artist entry
|
424
|
424
|
G::$DB->query("
|
425
|
|
- SELECT ArtistID
|
426
|
|
- FROM torrents_artists
|
427
|
|
- WHERE GroupID = ?", $GroupID);
|
|
425
|
+ SELECT ArtistID
|
|
426
|
+ FROM torrents_artists
|
|
427
|
+ WHERE GroupID = ?", $GroupID);
|
428
|
428
|
$Artists = G::$DB->collect('ArtistID');
|
429
|
429
|
|
430
|
430
|
G::$DB->query("
|
431
|
|
- DELETE FROM torrents_artists
|
432
|
|
- WHERE GroupID = ?", $GroupID);
|
|
431
|
+ DELETE FROM torrents_artists
|
|
432
|
+ WHERE GroupID = ?", $GroupID);
|
433
|
433
|
|
434
|
434
|
foreach ($Artists as $ArtistID) {
|
435
|
435
|
if (empty($ArtistID)) {
|
|
@@ -437,18 +437,18 @@ class Torrents
|
437
|
437
|
}
|
438
|
438
|
// Get a count of how many groups or requests use the artist ID
|
439
|
439
|
G::$DB->query("
|
440
|
|
- SELECT COUNT(ag.ArtistID)
|
441
|
|
- FROM artists_group AS ag
|
442
|
|
- LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
|
443
|
|
- WHERE ra.ArtistID IS NOT NULL
|
444
|
|
- AND ag.ArtistID = ?", $ArtistID);
|
|
440
|
+ SELECT COUNT(ag.ArtistID)
|
|
441
|
+ FROM artists_group AS ag
|
|
442
|
+ LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
|
|
443
|
+ WHERE ra.ArtistID IS NOT NULL
|
|
444
|
+ AND ag.ArtistID = ?", $ArtistID);
|
445
|
445
|
list($ReqCount) = G::$DB->next_record();
|
446
|
446
|
G::$DB->query("
|
447
|
|
- SELECT COUNT(ag.ArtistID)
|
448
|
|
- FROM artists_group AS ag
|
449
|
|
- LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
|
450
|
|
- WHERE ta.ArtistID IS NOT NULL
|
451
|
|
- AND ag.ArtistID = ?", $ArtistID);
|
|
447
|
+ SELECT COUNT(ag.ArtistID)
|
|
448
|
+ FROM artists_group AS ag
|
|
449
|
+ LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
|
|
450
|
+ WHERE ta.ArtistID IS NOT NULL
|
|
451
|
+ AND ag.ArtistID = ?", $ArtistID);
|
452
|
452
|
list($GroupCount) = G::$DB->next_record();
|
453
|
453
|
if (($ReqCount + $GroupCount) == 0) {
|
454
|
454
|
//The only group to use this artist
|
|
@@ -461,14 +461,14 @@ class Torrents
|
461
|
461
|
|
462
|
462
|
// Requests
|
463
|
463
|
G::$DB->query("
|
464
|
|
- SELECT ID
|
465
|
|
- FROM requests
|
466
|
|
- WHERE GroupID = ?", $GroupID);
|
|
464
|
+ SELECT ID
|
|
465
|
+ FROM requests
|
|
466
|
+ WHERE GroupID = ?", $GroupID);
|
467
|
467
|
$Requests = G::$DB->collect('ID');
|
468
|
468
|
G::$DB->query("
|
469
|
|
- UPDATE requests
|
470
|
|
- SET GroupID = NULL
|
471
|
|
- WHERE GroupID = ?", $GroupID);
|
|
469
|
+ UPDATE requests
|
|
470
|
+ SET GroupID = NULL
|
|
471
|
+ WHERE GroupID = ?", $GroupID);
|
472
|
472
|
foreach ($Requests as $RequestID) {
|
473
|
473
|
G::$Cache->delete_value("request_$RequestID");
|
474
|
474
|
}
|
|
@@ -477,17 +477,17 @@ class Torrents
|
477
|
477
|
Comments::delete_page('torrents', $GroupID);
|
478
|
478
|
|
479
|
479
|
G::$DB->query("
|
480
|
|
- DELETE FROM torrents_group
|
481
|
|
- WHERE ID = ?", $GroupID);
|
|
480
|
+ DELETE FROM torrents_group
|
|
481
|
+ WHERE ID = ?", $GroupID);
|
482
|
482
|
G::$DB->query("
|
483
|
|
- DELETE FROM torrents_tags
|
484
|
|
- WHERE GroupID = ?", $GroupID);
|
|
483
|
+ DELETE FROM torrents_tags
|
|
484
|
+ WHERE GroupID = ?", $GroupID);
|
485
|
485
|
G::$DB->query("
|
486
|
|
- DELETE FROM bookmarks_torrents
|
487
|
|
- WHERE GroupID = ?", $GroupID);
|
|
486
|
+ DELETE FROM bookmarks_torrents
|
|
487
|
+ WHERE GroupID = ?", $GroupID);
|
488
|
488
|
G::$DB->query("
|
489
|
|
- DELETE FROM wiki_torrents
|
490
|
|
- WHERE PageID = ?", $GroupID);
|
|
489
|
+ DELETE FROM wiki_torrents
|
|
490
|
+ WHERE PageID = ?", $GroupID);
|
491
|
491
|
|
492
|
492
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
493
|
493
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
|
@@ -505,23 +505,23 @@ class Torrents
|
505
|
505
|
$QueryID = G::$DB->get_query_id();
|
506
|
506
|
|
507
|
507
|
G::$DB->query("
|
508
|
|
- UPDATE torrents_group
|
509
|
|
- SET TagList = (
|
|
508
|
+ UPDATE torrents_group
|
|
509
|
+ SET TagList = (
|
510
|
510
|
SELECT REPLACE(GROUP_CONCAT(tags.Name SEPARATOR ' '), '.', '_')
|
511
|
511
|
FROM torrents_tags AS t
|
512
|
512
|
INNER JOIN tags ON tags.ID = t.TagID
|
513
|
513
|
WHERE t.GroupID = ?
|
514
|
514
|
GROUP BY t.GroupID
|
515
|
|
- )
|
516
|
|
- WHERE ID = ?", $GroupID, $GroupID);
|
|
515
|
+ )
|
|
516
|
+ WHERE ID = ?", $GroupID, $GroupID);
|
517
|
517
|
|
518
|
518
|
// Fetch album artists
|
519
|
519
|
G::$DB->query("
|
520
|
|
- SELECT GROUP_CONCAT(ag.Name separator ' ')
|
521
|
|
- FROM torrents_artists AS ta
|
522
|
|
- JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
|
523
|
|
- WHERE ta.GroupID = ?
|
524
|
|
- GROUP BY ta.GroupID", $GroupID);
|
|
520
|
+ SELECT GROUP_CONCAT(ag.Name separator ' ')
|
|
521
|
+ FROM torrents_artists AS ta
|
|
522
|
+ JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
|
|
523
|
+ WHERE ta.GroupID = ?
|
|
524
|
+ GROUP BY ta.GroupID", $GroupID);
|
525
|
525
|
if (G::$DB->has_results()) {
|
526
|
526
|
list($ArtistName) = G::$DB->next_record(MYSQLI_NUM, false);
|
527
|
527
|
} else {
|
|
@@ -529,19 +529,19 @@ class Torrents
|
529
|
529
|
}
|
530
|
530
|
|
531
|
531
|
G::$DB->query("
|
532
|
|
- REPLACE INTO sphinx_delta
|
533
|
|
- (ID, GroupID, GroupName, GroupNameRJ, GroupNameJP, TagList, Year, CatalogueNumber, CategoryID, Time,
|
534
|
|
- Size, Snatched, Seeders, Leechers, Censored, Studio, Series, DLsiteID,
|
535
|
|
- FreeTorrent, Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description,
|
536
|
|
- FileList, ArtistName)
|
537
|
|
- SELECT
|
538
|
|
- t.ID, g.ID, Name, NameRJ, NameJP, TagList, Year, CatalogueNumber, CategoryID, UNIX_TIMESTAMP(t.Time),
|
539
|
|
- Size, Snatched, Seeders, Leechers, Censored, Studio, Series, DLsiteID,
|
540
|
|
- CAST(FreeTorrent AS CHAR), Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description,
|
541
|
|
- REPLACE(REPLACE(FileList, '_', ' '), '/', ' ') AS FileList, ?
|
542
|
|
- FROM torrents AS t
|
543
|
|
- JOIN torrents_group AS g ON g.ID = t.GroupID
|
544
|
|
- WHERE g.ID = ?", $ArtistName, $GroupID);
|
|
532
|
+ REPLACE INTO sphinx_delta
|
|
533
|
+ (ID, GroupID, GroupName, GroupNameRJ, GroupNameJP, TagList, Year, CatalogueNumber, CategoryID, Time,
|
|
534
|
+ Size, Snatched, Seeders, Leechers, Censored, Studio, Series, DLsiteID,
|
|
535
|
+ FreeTorrent, Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description,
|
|
536
|
+ FileList, ArtistName)
|
|
537
|
+ SELECT
|
|
538
|
+ t.ID, g.ID, Name, NameRJ, NameJP, TagList, Year, CatalogueNumber, CategoryID, UNIX_TIMESTAMP(t.Time),
|
|
539
|
+ Size, Snatched, Seeders, Leechers, Censored, Studio, Series, DLsiteID,
|
|
540
|
+ CAST(FreeTorrent AS CHAR), Media, Container, Codec, Resolution, AudioFormat, Subbing, Language, Description,
|
|
541
|
+ REPLACE(REPLACE(FileList, '_', ' '), '/', ' ') AS FileList, ?
|
|
542
|
+ FROM torrents AS t
|
|
543
|
+ JOIN torrents_group AS g ON g.ID = t.GroupID
|
|
544
|
+ WHERE g.ID = ?", $ArtistName, $GroupID);
|
545
|
545
|
|
546
|
546
|
G::$Cache->delete_value("torrents_details_$GroupID");
|
547
|
547
|
G::$Cache->delete_value("torrent_group_$GroupID");
|
|
@@ -564,9 +564,9 @@ class Torrents
|
564
|
564
|
$QueryID = G::$DB->get_query_id();
|
565
|
565
|
|
566
|
566
|
G::$DB->query("
|
567
|
|
- SELECT GroupID
|
568
|
|
- FROM torrents
|
569
|
|
- WHERE ID = ?", $TorrentID);
|
|
567
|
+ SELECT GroupID
|
|
568
|
+ FROM torrents
|
|
569
|
+ WHERE ID = ?", $TorrentID);
|
570
|
570
|
if (G::$DB->has_results()) {
|
571
|
571
|
list($GroupID) = G::$DB->next_record(MYSQLI_NUM, false);
|
572
|
572
|
$Contents = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
|
|
@@ -586,7 +586,7 @@ class Torrents
|
586
|
586
|
"
|
587
|
587
|
UPDATE torrents
|
588
|
588
|
SET Size = ?, FilePath = ?, FileList = ?
|
589
|
|
- WHERE ID = ?",
|
|
589
|
+ WHERE ID = ?",
|
590
|
590
|
$TotalSize,
|
591
|
591
|
$FilePath,
|
592
|
592
|
$FileString,
|
|
@@ -668,38 +668,40 @@ class Torrents
|
668
|
668
|
*/
|
669
|
669
|
public static function torrent_info($Data, $ShowMedia = true, $ShowEdition = false, $HTMLy = true)
|
670
|
670
|
{
|
|
671
|
+ # Main torrent search results info!
|
671
|
672
|
$Info = [];
|
672
|
673
|
|
673
|
674
|
# Platform
|
674
|
675
|
if ($ShowMedia && !empty($Data['Media'])) {
|
675
|
|
- $Info[] = display_str($Data['Media']);
|
|
676
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&media='.display_str($Data['Media']).'">'.display_str($Data['Media']).'</a>';
|
676
|
677
|
}
|
677
|
678
|
|
678
|
679
|
# Format
|
679
|
680
|
if (!empty($Data['Container'])) {
|
680
|
|
- $Info[] = display_str($Data['Container']);
|
|
681
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&container='.display_str($Data['Container']).'">'.display_str($Data['Container']).'</a>';
|
681
|
682
|
}
|
682
|
683
|
|
683
|
684
|
# Archive
|
684
|
685
|
if (!empty($Data['Archive'])) {
|
|
686
|
+ # todo: Search on archives, lowest priority
|
685
|
687
|
$Info[] = display_str($Data['Archive']);
|
686
|
688
|
}
|
687
|
689
|
|
688
|
690
|
# Resolution
|
689
|
691
|
if (!empty($Data['Resolution'])) {
|
690
|
|
- $Info[] = display_str($Data['Resolution']);
|
|
692
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&resolution='.display_str($Data['Resolution']).'">'.display_str($Data['Resolution']).'</a>';
|
691
|
693
|
}
|
692
|
694
|
|
693
|
695
|
# License
|
694
|
696
|
if (!empty($Data['Codec'])) {
|
695
|
|
- $Info[] = display_str($Data['Codec']);
|
|
697
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&codec='.display_str($Data['Codec']).'">'.display_str($Data['Codec']).'</a>';
|
696
|
698
|
}
|
697
|
699
|
|
698
|
700
|
# Alignned/Annotated
|
699
|
701
|
if ($Data['Censored'] === 1) {
|
700
|
|
- $Info[] = 'Aligned';
|
|
702
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&censored=1">Aligned</a>';
|
701
|
703
|
} else {
|
702
|
|
- $Info[] = 'Unaligned';
|
|
704
|
+ $Info[] = '<a class="search_link" href="torrents.php?action=advanced&censored=0">Not Aligned</a>';
|
703
|
705
|
}
|
704
|
706
|
|
705
|
707
|
/*
|
|
@@ -749,12 +751,15 @@ class Torrents
|
749
|
751
|
$Info[] = $HTMLy ? Format::torrent_label('Freeleech!', 'important_text_alt') : 'Freeleech!';
|
750
|
752
|
}
|
751
|
753
|
}
|
|
754
|
+
|
752
|
755
|
if ($Data['FreeTorrent'] == '2') {
|
753
|
756
|
$Info[] = $HTMLy ? Format::torrent_label('Neutral Leech!', 'bold') : 'Neutral Leech!';
|
754
|
757
|
}
|
|
758
|
+
|
755
|
759
|
if ($Data['PersonalFL']) {
|
756
|
760
|
$Info[] = $HTMLy ? Format::torrent_label('Personal Freeleech!', 'important_text_alt') : 'Personal Freeleech!';
|
757
|
761
|
}
|
|
762
|
+
|
758
|
763
|
return implode(' / ', $Info);
|
759
|
764
|
}
|
760
|
765
|
|
|
@@ -773,15 +778,15 @@ class Torrents
|
773
|
778
|
|
774
|
779
|
$QueryID = G::$DB->get_query_id();
|
775
|
780
|
G::$DB->query("
|
776
|
|
- UPDATE torrents
|
777
|
|
- SET FreeTorrent = '$FreeNeutral', FreeLeechType = '$FreeLeechType'
|
778
|
|
- WHERE ID IN (".implode(', ', $TorrentIDs).')');
|
|
781
|
+ UPDATE torrents
|
|
782
|
+ SET FreeTorrent = '$FreeNeutral', FreeLeechType = '$FreeLeechType'
|
|
783
|
+ WHERE ID IN (".implode(', ', $TorrentIDs).')');
|
779
|
784
|
|
780
|
785
|
G::$DB->query('
|
781
|
|
- SELECT ID, GroupID, info_hash
|
782
|
|
- FROM torrents
|
783
|
|
- WHERE ID IN ('.implode(', ', $TorrentIDs).')
|
784
|
|
- ORDER BY GroupID ASC');
|
|
786
|
+ SELECT ID, GroupID, info_hash
|
|
787
|
+ FROM torrents
|
|
788
|
+ WHERE ID IN ('.implode(', ', $TorrentIDs).')
|
|
789
|
+ ORDER BY GroupID ASC');
|
785
|
790
|
$Torrents = G::$DB->to_array(false, MYSQLI_NUM, false);
|
786
|
791
|
$GroupIDs = G::$DB->collect('GroupID');
|
787
|
792
|
G::$DB->set_query_id($QueryID);
|
|
@@ -818,9 +823,9 @@ class Torrents
|
818
|
823
|
}
|
819
|
824
|
|
820
|
825
|
G::$DB->query('
|
821
|
|
- SELECT ID
|
822
|
|
- FROM torrents
|
823
|
|
- WHERE GroupID IN ('.implode(', ', $GroupIDs).')');
|
|
826
|
+ SELECT ID
|
|
827
|
+ FROM torrents
|
|
828
|
+ WHERE GroupID IN ('.implode(', ', $GroupIDs).')');
|
824
|
829
|
if (G::$DB->has_results()) {
|
825
|
830
|
$TorrentIDs = G::$DB->collect('ID');
|
826
|
831
|
Torrents::freeleech_torrents($TorrentIDs, $FreeNeutral, $FreeLeechType);
|
|
@@ -847,10 +852,10 @@ class Torrents
|
847
|
852
|
if ($TokenTorrents === false) {
|
848
|
853
|
$QueryID = G::$DB->get_query_id();
|
849
|
854
|
G::$DB->query("
|
850
|
|
- SELECT TorrentID
|
851
|
|
- FROM users_freeleeches
|
852
|
|
- WHERE UserID = ?
|
853
|
|
- AND Expired = 0", $UserID);
|
|
855
|
+ SELECT TorrentID
|
|
856
|
+ FROM users_freeleeches
|
|
857
|
+ WHERE UserID = ?
|
|
858
|
+ AND Expired = 0", $UserID);
|
854
|
859
|
$TokenTorrents = array_fill_keys(G::$DB->collect('TorrentID', false), true);
|
855
|
860
|
G::$DB->set_query_id($QueryID);
|
856
|
861
|
G::$Cache->cache_value("users_tokens_$UserID", $TokenTorrents);
|
|
@@ -922,9 +927,9 @@ class Torrents
|
922
|
927
|
}
|
923
|
928
|
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
|
924
|
929
|
G::$DB->query("
|
925
|
|
- SELECT fid
|
926
|
|
- FROM xbt_snatched
|
927
|
|
- WHERE uid = ?", $UserID);
|
|
930
|
+ SELECT fid
|
|
931
|
+ FROM xbt_snatched
|
|
932
|
+ WHERE uid = ?", $UserID);
|
928
|
933
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
929
|
934
|
$SnatchedTorrents[$ID & $LastBucket][(int)$ID] = true;
|
930
|
935
|
}
|
|
@@ -935,10 +940,10 @@ class Torrents
|
935
|
940
|
} else {
|
936
|
941
|
// Old cache, check if torrent has been snatched recently
|
937
|
942
|
G::$DB->query("
|
938
|
|
- SELECT fid
|
939
|
|
- FROM xbt_snatched
|
940
|
|
- WHERE uid = ?
|
941
|
|
- AND tstamp >= ?", $UserID, $UpdateTime['last']);
|
|
943
|
+ SELECT fid
|
|
944
|
+ FROM xbt_snatched
|
|
945
|
+ WHERE uid = ?
|
|
946
|
+ AND tstamp >= ?", $UserID, $UpdateTime['last']);
|
942
|
947
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
943
|
948
|
$CurBucketID = $ID & $LastBucket;
|
944
|
949
|
if ($SnatchedTorrents[$CurBucketID] === false) {
|
|
@@ -1004,11 +1009,11 @@ class Torrents
|
1004
|
1009
|
}
|
1005
|
1010
|
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
|
1006
|
1011
|
G::$DB->query("
|
1007
|
|
- SELECT fid
|
1008
|
|
- FROM xbt_files_users
|
1009
|
|
- WHERE uid = ?
|
1010
|
|
- AND active = 1
|
1011
|
|
- AND Remaining = 0", $UserID);
|
|
1012
|
+ SELECT fid
|
|
1013
|
+ FROM xbt_files_users
|
|
1014
|
+ WHERE uid = ?
|
|
1015
|
+ AND active = 1
|
|
1016
|
+ AND Remaining = 0", $UserID);
|
1012
|
1017
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
1013
|
1018
|
$SeedingTorrents[$ID & $LastBucket][(int)$ID] = true;
|
1014
|
1019
|
}
|
|
@@ -1019,12 +1024,12 @@ class Torrents
|
1019
|
1024
|
} else {
|
1020
|
1025
|
// Old cache, check if torrent has been seeding recently
|
1021
|
1026
|
G::$DB->query("
|
1022
|
|
- SELECT fid
|
1023
|
|
- FROM xbt_files_users
|
1024
|
|
- WHERE uid = ?
|
1025
|
|
- AND active = 1
|
1026
|
|
- AND Remaining = 0
|
1027
|
|
- AND mtime >= ?", $UserID, $UpdateTime['last']);
|
|
1027
|
+ SELECT fid
|
|
1028
|
+ FROM xbt_files_users
|
|
1029
|
+ WHERE uid = ?
|
|
1030
|
+ AND active = 1
|
|
1031
|
+ AND Remaining = 0
|
|
1032
|
+ AND mtime >= ?", $UserID, $UpdateTime['last']);
|
1028
|
1033
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
1029
|
1034
|
$CurBucketID = $ID & $LastBucket;
|
1030
|
1035
|
if ($SeedingTorrents[$CurBucketID] === false) {
|
|
@@ -1090,11 +1095,11 @@ class Torrents
|
1090
|
1095
|
}
|
1091
|
1096
|
// Not found in cache. Since we don't have a suitable index, it's faster to update everything
|
1092
|
1097
|
G::$DB->query("
|
1093
|
|
- SELECT fid
|
1094
|
|
- FROM xbt_files_users
|
1095
|
|
- WHERE uid = ?
|
1096
|
|
- AND active = 1
|
1097
|
|
- AND Remaining > 0", $UserID);
|
|
1098
|
+ SELECT fid
|
|
1099
|
+ FROM xbt_files_users
|
|
1100
|
+ WHERE uid = ?
|
|
1101
|
+ AND active = 1
|
|
1102
|
+ AND Remaining > 0", $UserID);
|
1098
|
1103
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
1099
|
1104
|
$LeechingTorrents[$ID & $LastBucket][(int)$ID] = true;
|
1100
|
1105
|
}
|
|
@@ -1105,12 +1110,12 @@ class Torrents
|
1105
|
1110
|
} else {
|
1106
|
1111
|
// Old cache, check if torrent has been leeching recently
|
1107
|
1112
|
G::$DB->query("
|
1108
|
|
- SELECT fid
|
1109
|
|
- FROM xbt_files_users
|
1110
|
|
- WHERE uid = ?
|
1111
|
|
- AND active = 1
|
1112
|
|
- AND Remaining > 0
|
1113
|
|
- AND mtime >= ?", $UserID, $UpdateTime['last']);
|
|
1113
|
+ SELECT fid
|
|
1114
|
+ FROM xbt_files_users
|
|
1115
|
+ WHERE uid = ?
|
|
1116
|
+ AND active = 1
|
|
1117
|
+ AND Remaining > 0
|
|
1118
|
+ AND mtime >= ?", $UserID, $UpdateTime['last']);
|
1114
|
1119
|
while (list($ID) = G::$DB->next_record(MYSQLI_NUM, false)) {
|
1115
|
1120
|
$CurBucketID = $ID & $LastBucket;
|
1116
|
1121
|
if ($LeechingTorrents[$CurBucketID] === false) {
|
|
@@ -1258,15 +1263,15 @@ class Torrents
|
1258
|
1263
|
if ($Reports === false) {
|
1259
|
1264
|
$QueryID = G::$DB->get_query_id();
|
1260
|
1265
|
G::$DB->query("
|
1261
|
|
- SELECT
|
1262
|
|
- ID,
|
1263
|
|
- ReporterID,
|
1264
|
|
- Type,
|
1265
|
|
- UserComment,
|
1266
|
|
- ReportedTime
|
1267
|
|
- FROM reportsv2
|
1268
|
|
- WHERE TorrentID = ?
|
1269
|
|
- AND Status != 'Resolved'", $TorrentID);
|
|
1266
|
+ SELECT
|
|
1267
|
+ ID,
|
|
1268
|
+ ReporterID,
|
|
1269
|
+ Type,
|
|
1270
|
+ UserComment,
|
|
1271
|
+ ReportedTime
|
|
1272
|
+ FROM reportsv2
|
|
1273
|
+ WHERE TorrentID = ?
|
|
1274
|
+ AND Status != 'Resolved'", $TorrentID);
|
1270
|
1275
|
$Reports = G::$DB->to_array(false, MYSQLI_ASSOC, false);
|
1271
|
1276
|
G::$DB->set_query_id($QueryID);
|
1272
|
1277
|
G::$Cache->cache_value("reports_torrent_$TorrentID", $Reports, 0);
|