|
@@ -1,6 +1,7 @@
|
1
|
|
-<?
|
|
1
|
+<?php
|
2
|
2
|
//------------- Delete dead torrents ------------------------------------//
|
3
|
3
|
|
|
4
|
+/*
|
4
|
5
|
$DB->query("
|
5
|
6
|
SELECT
|
6
|
7
|
t.ID,
|
|
@@ -21,47 +22,47 @@ echo 'Found '.count($Torrents)." inactive torrents to be deleted.\n";
|
21
|
22
|
$LogEntries = $DeleteNotes = [];
|
22
|
23
|
|
23
|
24
|
// Exceptions for inactivity deletion
|
24
|
|
-$InactivityExceptionsMade = []; //UserID => expiry time of exception
|
|
25
|
+$InactivityExceptionsMade = []; // UserID => expiry time of exception
|
25
|
26
|
|
26
|
27
|
$i = 0;
|
27
|
28
|
foreach ($Torrents as $Torrent) {
|
28
|
|
- list($ID, $GroupID, $Name, $UserID, $Media, $InfoHash) = $Torrent;
|
29
|
|
- if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
|
30
|
|
- // don't delete the torrent!
|
31
|
|
- continue;
|
32
|
|
- }
|
33
|
|
- $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
|
34
|
|
- if ($ArtistName) {
|
35
|
|
- $Name = "$ArtistName - $Name";
|
36
|
|
- }
|
37
|
|
- Torrents::delete_torrent($ID, $GroupID);
|
38
|
|
- $LogEntries[] = db_string("Torrent $ID ($Name) (".strtoupper($InfoHash).") was deleted for inactivity (unseeded)");
|
|
29
|
+ list($ID, $GroupID, $Name, $UserID, $Media, $InfoHash) = $Torrent;
|
|
30
|
+ if (array_key_exists($UserID, $InactivityExceptionsMade) && (time() < $InactivityExceptionsMade[$UserID])) {
|
|
31
|
+ // Don't delete the torrent!
|
|
32
|
+ continue;
|
|
33
|
+ }
|
|
34
|
+ $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false);
|
|
35
|
+ if ($ArtistName) {
|
|
36
|
+ $Name = "$ArtistName - $Name";
|
|
37
|
+ }
|
|
38
|
+ Torrents::delete_torrent($ID, $GroupID);
|
|
39
|
+ $LogEntries[] = db_string("Torrent $ID ($Name) (".strtoupper($InfoHash).") was deleted for inactivity (unseeded)");
|
39
|
40
|
|
40
|
|
- if (!array_key_exists($UserID, $DeleteNotes)) {
|
41
|
|
- $DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => '');
|
42
|
|
- }
|
|
41
|
+ if (!array_key_exists($UserID, $DeleteNotes)) {
|
|
42
|
+ $DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => '');
|
|
43
|
+ }
|
43
|
44
|
|
44
|
|
- $DeleteNotes[$UserID]['Msg'] .= "\n$Name";
|
45
|
|
- $DeleteNotes[$UserID]['Count']++;
|
|
45
|
+ $DeleteNotes[$UserID]['Msg'] .= "\n$Name";
|
|
46
|
+ $DeleteNotes[$UserID]['Count']++;
|
46
|
47
|
|
47
|
|
- ++$i;
|
48
|
|
- if ($i % 500 == 0) {
|
49
|
|
- echo "$i inactive torrents removed.\n";
|
50
|
|
- }
|
|
48
|
+ ++$i;
|
|
49
|
+ if ($i % 500 === 0) {
|
|
50
|
+ echo "$i inactive torrents removed.\n";
|
|
51
|
+ }
|
51
|
52
|
}
|
52
|
53
|
echo "$i torrents deleted for inactivity.\n";
|
53
|
54
|
|
54
|
55
|
foreach ($DeleteNotes as $UserID => $MessageInfo) {
|
55
|
|
- $Singular = ($MessageInfo['Count'] == 1);
|
56
|
|
- Misc::send_pm($UserID, 0, $MessageInfo['Count'].' of your torrents '.($Singular ? 'has' : 'have').' been deleted for inactivity', ($Singular ? 'One' : 'Some').' of your uploads '.($Singular ? 'has' : 'have').' been deleted for being unseeded. Since '.($Singular ? 'it' : 'they').' didn\'t break any rules (we hope), please feel free to re-upload '.($Singular ? 'it' : 'them').".\n\nThe following torrent".($Singular ? ' was' : 's were').' deleted:'.$MessageInfo['Msg']);
|
|
56
|
+ $Singular = ($MessageInfo['Count'] === 1);
|
|
57
|
+ Misc::send_pm($UserID, 0, $MessageInfo['Count'].' of your torrents '.($Singular ? 'has' : 'have').' been deleted for inactivity', ($Singular ? 'One' : 'Some').' of your uploads '.($Singular ? 'has' : 'have').' been deleted for being unseeded. Since '.($Singular ? 'it' : 'they').' didn\'t break any rules (we hope), please feel free to re-upload '.($Singular ? 'it' : 'them').".\n\nThe following torrent".($Singular ? ' was' : 's were').' deleted:'.$MessageInfo['Msg']);
|
57
|
58
|
}
|
58
|
59
|
unset($DeleteNotes);
|
59
|
60
|
|
60
|
61
|
if (count($LogEntries) > 0) {
|
61
|
|
- $Values = "('".implode("', '$sqltime'), ('", $LogEntries) . "', '$sqltime')";
|
62
|
|
- $DB->query("
|
|
62
|
+ $Values = "('".implode("', '$sqltime'), ('", $LogEntries) . "', '$sqltime')";
|
|
63
|
+ $DB->query("
|
63
|
64
|
INSERT INTO log (Message, Time)
|
64
|
65
|
VALUES $Values");
|
65
|
|
- echo "\nDeleted $i torrents for inactivity\n";
|
|
66
|
+ echo "\nDeleted $i torrents for inactivity\n";
|
66
|
67
|
}
|
67
|
|
-?>
|
|
68
|
+*/
|