|
@@ -16,15 +16,14 @@ $DB->query("
|
16
|
16
|
r.FillerID,
|
17
|
17
|
r.Title,
|
18
|
18
|
u.Uploaded,
|
|
19
|
+ u.BonusPoints,
|
19
|
20
|
r.GroupID,
|
20
|
21
|
t.UserID,
|
21
|
|
- u2.Uploaded
|
22
|
22
|
FROM requests AS r
|
23
|
23
|
LEFT JOIN torrents AS t ON t.ID = TorrentID
|
24
|
24
|
LEFT JOIN users_main AS u ON u.ID = FillerID
|
25
|
|
- LEFT JOIN users_main AS u2 ON u2.ID = t.UserID
|
26
|
25
|
WHERE r.ID = $RequestID");
|
27
|
|
-list($CategoryID, $UserID, $FillerID, $Title, $Uploaded, $GroupID, $UploaderID, $UploaderUploaded) = $DB->next_record();
|
|
26
|
+list($CategoryID, $UserID, $FillerID, $Title, $Uploaded, $BonusPoints, $GroupID, $UploaderID) = $DB->next_record();
|
28
|
27
|
|
29
|
28
|
if (!$UploaderID) {
|
30
|
29
|
// If the torrent was deleted and we don't know who the uploader was, just assume it was the filler
|
|
@@ -58,32 +57,65 @@ $RequestVotes = Requests::get_votes_array($RequestID);
|
58
|
57
|
|
59
|
58
|
//Remove Filler portion of bounty
|
60
|
59
|
if (intval($RequestVotes['TotalBounty']*(1/4)) > $Uploaded) {
|
61
|
|
- // If we can't take it all out of upload, zero that out and add whatever is left as download.
|
|
60
|
+ // If we can't take it all out of upload, attempt to take the rest out of bonus points
|
62
|
61
|
$DB->query("
|
63
|
62
|
UPDATE users_main
|
64
|
63
|
SET Uploaded = 0
|
65
|
64
|
WHERE ID = $FillerID");
|
66
|
|
- $DB->query('
|
67
|
|
- UPDATE users_main
|
68
|
|
- SET Downloaded = Downloaded + '.intval($RequestVotes['TotalBounty']*(1/4) - $Uploaded)."
|
69
|
|
- WHERE ID = $FillerID");
|
|
65
|
+ if (intval($RequestVotes['TotalBounty']*(1/4)-$Uploaded) > $BonusPoints) {
|
|
66
|
+ // If we can't take the rest as bonus points, turn the remaining bit to download
|
|
67
|
+ $DB->query("
|
|
68
|
+ UPDATE users_main
|
|
69
|
+ SET BonusPoints = 0
|
|
70
|
+ WHERE ID = $FillerID");
|
|
71
|
+ $DB->query('
|
|
72
|
+ UPDATE users_main
|
|
73
|
+ SET Downloaded = Downloaded + '.intval($RequestVotes['TotalBounty']*(1/4) - $Uploaded - $BonusPoints*1000)."
|
|
74
|
+ WHERE ID = $FillerID");
|
|
75
|
+ } else {
|
|
76
|
+ $DB->query('
|
|
77
|
+ UPDATE users_main
|
|
78
|
+ SET BonusPoints = BonusPoints - '.intval(($RequestVotes['TotalBounty']*(1/4) - $Uploaded)/1000)."
|
|
79
|
+ WHERE ID = $FillerID");
|
|
80
|
+ }
|
70
|
81
|
} else {
|
71
|
82
|
$DB->query('
|
72
|
83
|
UPDATE users_main
|
73
|
84
|
SET Uploaded = Uploaded - '.intval($RequestVotes['TotalBounty']*(1/4))."
|
74
|
85
|
WHERE ID = $FillerID");
|
75
|
86
|
}
|
|
87
|
+
|
|
88
|
+$DB->query("
|
|
89
|
+ SELECT
|
|
90
|
+ Uploaded,
|
|
91
|
+ BonusPoints
|
|
92
|
+ FROM users_main
|
|
93
|
+ WHERE ID = $UploaderID");
|
|
94
|
+list($UploaderUploaded, $UploaderBonusPoints) = $DB->next_record();
|
|
95
|
+
|
76
|
96
|
//Remove Uploader portion of bounty
|
77
|
97
|
if (intval($RequestVotes['TotalBounty']*(3/4)) > $UploaderUploaded) {
|
78
|
|
- // If we can't take it all out of upload, zero that out and add whatever is left as download.
|
|
98
|
+ // If we can't take it all out of upload, attempt to take the rest out of bonus points
|
79
|
99
|
$DB->query("
|
80
|
100
|
UPDATE users_main
|
81
|
101
|
SET Uploaded = 0
|
82
|
102
|
WHERE ID = $UploaderID");
|
83
|
|
- $DB->query('
|
84
|
|
- UPDATE users_main
|
85
|
|
- SET Downloaded = Downloaded + '.intval($RequestVotes['TotalBounty']*(3/4) - $UploaderUploaded)."
|
86
|
|
- WHERE ID = $UploaderID");
|
|
103
|
+ if (intval($RequestVotes['TotalBounty']*(3/4) - $UploaderUploaded) > $UploaderBonusPoints) {
|
|
104
|
+ // If we can't take the rest as bonus points, turn the remaining bit to download
|
|
105
|
+ $DB->query("
|
|
106
|
+ UPDATE users_main
|
|
107
|
+ SET BonusPoints = 0
|
|
108
|
+ WHERE ID = $UploaderID");
|
|
109
|
+ $DB->query('
|
|
110
|
+ UPDATE users_main
|
|
111
|
+ SET Downloaded = Downloaded + '.intval($RequestVotes['TotalBounty']*(3/4) - $UploaderUploaded - $UploaderBonusPoints*1000)."
|
|
112
|
+ WHERE ID = $UploaderID");
|
|
113
|
+ } else {
|
|
114
|
+ $DB->query('
|
|
115
|
+ UPDATE users_main
|
|
116
|
+ SET BonusPoints = BonusPoints - '.intval(($RequestVotes['TotalBounty']*(3/4) - $UploaderUploaded)/1000)."
|
|
117
|
+ WHERE ID = $UploaderID");
|
|
118
|
+ }
|
87
|
119
|
} else {
|
88
|
120
|
$DB->query('
|
89
|
121
|
UPDATE users_main
|