|
|
@@ -1,4 +1,4 @@
|
|
1
|
|
-<?
|
|
|
1
|
+<?php
|
|
2
|
2
|
|
|
3
|
3
|
//******************************************************************************//
|
|
4
|
4
|
//----------------- Take request -----------------------------------------------//
|
|
|
@@ -6,171 +6,172 @@ authorize();
|
|
6
|
6
|
|
|
7
|
7
|
|
|
8
|
8
|
if ($_POST['action'] !== 'takenew' && $_POST['action'] !== 'takeedit') {
|
|
9
|
|
- error(0);
|
|
|
9
|
+ error(0);
|
|
10
|
10
|
}
|
|
11
|
11
|
|
|
12
|
12
|
$NewRequest = ($_POST['action'] === 'takenew');
|
|
13
|
13
|
|
|
14
|
14
|
if (!$NewRequest) {
|
|
15
|
|
- $ReturnEdit = true;
|
|
|
15
|
+ $ReturnEdit = true;
|
|
16
|
16
|
}
|
|
17
|
17
|
|
|
18
|
18
|
if ($NewRequest) {
|
|
19
|
|
- if (!check_perms('site_submit_requests') || $LoggedUser['BytesUploaded'] < 250 * 1024 * 1024) {
|
|
20
|
|
- error(403);
|
|
21
|
|
- }
|
|
|
19
|
+ if (!check_perms('site_submit_requests') || $LoggedUser['BytesUploaded'] < 250 * 1024 * 1024) {
|
|
|
20
|
+ error(403);
|
|
|
21
|
+ }
|
|
22
|
22
|
} else {
|
|
23
|
|
- $RequestID = $_POST['requestid'];
|
|
24
|
|
- if (!is_number($RequestID)) {
|
|
25
|
|
- error(0);
|
|
26
|
|
- }
|
|
|
23
|
+ $RequestID = $_POST['requestid'];
|
|
|
24
|
+ if (!is_number($RequestID)) {
|
|
|
25
|
+ error(0);
|
|
|
26
|
+ }
|
|
27
|
27
|
|
|
28
|
|
- $Request = Requests::get_request($RequestID);
|
|
29
|
|
- if ($Request === false) {
|
|
30
|
|
- error(404);
|
|
31
|
|
- }
|
|
32
|
|
- $VoteArray = Requests::get_votes_array($RequestID);
|
|
33
|
|
- $VoteCount = count($VoteArray['Voters']);
|
|
34
|
|
- $IsFilled = !empty($Request['TorrentID']);
|
|
35
|
|
- $CategoryName = $Categories[$Request['CategoryID'] - 1];
|
|
36
|
|
- $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Year === '0')));
|
|
37
|
|
- $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
|
38
|
|
-
|
|
39
|
|
- if (!$CanEdit) {
|
|
40
|
|
- error(403);
|
|
41
|
|
- }
|
|
|
28
|
+ $Request = Requests::get_request($RequestID);
|
|
|
29
|
+ if ($Request === false) {
|
|
|
30
|
+ error(404);
|
|
|
31
|
+ }
|
|
|
32
|
+ $VoteArray = Requests::get_votes_array($RequestID);
|
|
|
33
|
+ $VoteCount = count($VoteArray['Voters']);
|
|
|
34
|
+ $IsFilled = !empty($Request['TorrentID']);
|
|
|
35
|
+ $CategoryName = $Categories[$Request['CategoryID'] - 1];
|
|
|
36
|
+ $ProjectCanEdit = (check_perms('project_team') && !$IsFilled && ($Request['CategoryID'] === '0' || ($CategoryName === 'Music' && $Year === '0')));
|
|
|
37
|
+ $CanEdit = ((!$IsFilled && $LoggedUser['ID'] === $Request['UserID'] && $VoteCount < 2) || $ProjectCanEdit || check_perms('site_moderate_requests'));
|
|
|
38
|
+
|
|
|
39
|
+ if (!$CanEdit) {
|
|
|
40
|
+ error(403);
|
|
|
41
|
+ }
|
|
42
|
42
|
}
|
|
43
|
43
|
|
|
44
|
44
|
// Validate
|
|
45
|
45
|
if (empty($_POST['type'])) {
|
|
46
|
|
- error(0);
|
|
|
46
|
+ error(0);
|
|
47
|
47
|
}
|
|
48
|
48
|
|
|
49
|
49
|
$CategoryName = $_POST['type'];
|
|
50
|
50
|
$CategoryID = (array_search($CategoryName, $Categories) + 1);
|
|
51
|
51
|
|
|
52
|
52
|
if (empty($CategoryID)) {
|
|
53
|
|
- error(0);
|
|
|
53
|
+ error(0);
|
|
54
|
54
|
}
|
|
55
|
55
|
|
|
56
|
56
|
if (empty($_POST['title']) && empty($_POST['title_rj']) && empty($_POST['title_jp'])) {
|
|
57
|
|
- $Err = 'You must enter at least one title!';
|
|
|
57
|
+ $Err = 'You must enter at least one title!';
|
|
58
|
58
|
}
|
|
59
|
59
|
|
|
60
|
60
|
if (!empty($_POST['title'])) {
|
|
61
|
|
- $Title = trim($_POST['title']);
|
|
|
61
|
+ $Title = trim($_POST['title']);
|
|
62
|
62
|
}
|
|
63
|
63
|
|
|
64
|
64
|
if (!empty($_POST['title_rj'])) {
|
|
65
|
|
- $TitleRJ = trim($_POST['title_rj']);
|
|
|
65
|
+ $TitleRJ = trim($_POST['title_rj']);
|
|
66
|
66
|
}
|
|
67
|
67
|
|
|
68
|
68
|
if (!empty($_POST['title_jp'])) {
|
|
69
|
|
- $TitleJP = trim($_POST['title_jp']);
|
|
|
69
|
+ $TitleJP = trim($_POST['title_jp']);
|
|
70
|
70
|
}
|
|
71
|
71
|
|
|
72
|
72
|
if (empty($_POST['tags'])) {
|
|
73
|
|
- $Err = 'You forgot to enter any tags!';
|
|
|
73
|
+ $Err = 'You forgot to enter any tags!';
|
|
74
|
74
|
} else {
|
|
75
|
|
- $Tags = trim($_POST['tags']);
|
|
|
75
|
+ $Tags = trim($_POST['tags']);
|
|
76
|
76
|
}
|
|
77
|
77
|
|
|
78
|
78
|
if ($NewRequest) {
|
|
79
|
|
- if (empty($_POST['amount'])) {
|
|
80
|
|
- $Err = 'You forgot to enter any bounty!';
|
|
81
|
|
- } else {
|
|
82
|
|
- $Bounty = trim($_POST['amount']);
|
|
83
|
|
- if (!is_number($Bounty)) {
|
|
84
|
|
- $Err = 'Your entered bounty is not a number';
|
|
85
|
|
- } elseif ($Bounty < 100 * 1024 * 1024) {
|
|
86
|
|
- $Err = 'Minimum bounty is 100 MB.';
|
|
|
79
|
+ if (empty($_POST['amount'])) {
|
|
|
80
|
+ $Err = 'You forgot to enter any bounty!';
|
|
|
81
|
+ } else {
|
|
|
82
|
+ $Bounty = trim($_POST['amount']);
|
|
|
83
|
+ if (!is_number($Bounty)) {
|
|
|
84
|
+ $Err = 'Your entered bounty is not a number';
|
|
|
85
|
+ } elseif ($Bounty < 100 * 1024 * 1024) {
|
|
|
86
|
+ $Err = 'Minimum bounty is 100 MB.';
|
|
|
87
|
+ }
|
|
|
88
|
+ $Bytes = $Bounty; // From MB to B
|
|
87
|
89
|
}
|
|
88
|
|
- $Bytes = $Bounty; //From MB to B
|
|
89
|
|
- }
|
|
90
|
90
|
}
|
|
91
|
91
|
|
|
92
|
92
|
if (empty($_POST['image'])) {
|
|
93
|
|
- $Image = '';
|
|
|
93
|
+ $Image = '';
|
|
94
|
94
|
} else {
|
|
95
|
|
- ImageTools::blacklisted($_POST['image']);
|
|
96
|
|
- if (preg_match('/'.IMAGE_REGEX.'/', trim($_POST['image'])) > 0) {
|
|
97
|
|
- $Image = trim($_POST['image']);
|
|
98
|
|
- } else {
|
|
99
|
|
- $Err = display_str($_POST['image']).' does not appear to be a valid link to an image.';
|
|
100
|
|
- }
|
|
|
95
|
+ ImageTools::blacklisted($_POST['image']);
|
|
|
96
|
+ if (preg_match('/'.IMAGE_REGEX.'/', trim($_POST['image'])) > 0) {
|
|
|
97
|
+ $Image = trim($_POST['image']);
|
|
|
98
|
+ } else {
|
|
|
99
|
+ $Err = display_str($_POST['image']).' does not appear to be a valid link to an image.';
|
|
|
100
|
+ }
|
|
101
|
101
|
}
|
|
102
|
102
|
|
|
103
|
103
|
if (empty($_POST['description'])) {
|
|
104
|
|
- $Err = 'You forgot to enter a description.';
|
|
|
104
|
+ $Err = 'You forgot to enter a description.';
|
|
105
|
105
|
} else {
|
|
106
|
|
- $Description = trim($_POST['description']);
|
|
|
106
|
+ $Description = trim($_POST['description']);
|
|
107
|
107
|
}
|
|
108
|
108
|
|
|
109
|
|
-if (empty($_POST['artists']) && $CategoryName != 'Other') {
|
|
110
|
|
- $Err = 'You did not enter any artists.';
|
|
|
109
|
+if (empty($_POST['artists']) && $CategoryName !== 'Other') {
|
|
|
110
|
+ $Err = 'You did not enter any artists.';
|
|
111
|
111
|
} else {
|
|
112
|
|
- $Artists = $_POST['artists'];
|
|
|
112
|
+ $Artists = $_POST['artists'];
|
|
113
|
113
|
}
|
|
114
|
114
|
|
|
115
|
|
-//Not required
|
|
116
|
|
-if (!empty($_POST['cataloguenumber']) && $CategoryName == 'Movies') {
|
|
117
|
|
- $CatalogueNumber = trim($_POST['cataloguenumber']);
|
|
|
115
|
+// Not required
|
|
|
116
|
+if (!empty($_POST['cataloguenumber']) && $CategoryName === 'Movies') {
|
|
|
117
|
+ $CatalogueNumber = trim($_POST['cataloguenumber']);
|
|
118
|
118
|
} else {
|
|
119
|
|
- $CatalogueNumber = '';
|
|
|
119
|
+ $CatalogueNumber = '';
|
|
120
|
120
|
}
|
|
121
|
|
-if (!empty($_POST['dlsiteid']) && $CategoryName == 'Games') {
|
|
122
|
|
- $DLSiteID = trim($_POST['dlsiteid']);
|
|
|
121
|
+if (!empty($_POST['dlsiteid']) && $CategoryName === 'Games') {
|
|
|
122
|
+ $DLSiteID = trim($_POST['dlsiteid']);
|
|
123
|
123
|
} else {
|
|
124
|
|
- $DLSiteID = '';
|
|
|
124
|
+ $DLSiteID = '';
|
|
125
|
125
|
}
|
|
126
|
126
|
|
|
127
|
127
|
// GroupID
|
|
128
|
128
|
if (!empty($_POST['groupid'])) {
|
|
129
|
|
- $GroupID = $_POST['groupid'];
|
|
130
|
|
- if (is_number($GroupID)) {
|
|
131
|
|
- $DB->query("
|
|
|
129
|
+ $GroupID = $_POST['groupid'];
|
|
|
130
|
+ if (is_number($GroupID)) {
|
|
|
131
|
+ $DB->query("
|
|
132
|
132
|
SELECT CategoryID
|
|
133
|
133
|
FROM torrents_group
|
|
134
|
134
|
WHERE ID = '$GroupID'");
|
|
135
|
|
- if (!$DB->has_results()) {
|
|
136
|
|
- $Err = 'The torrent group, if entered, must correspond to a torrent group on the site.';
|
|
|
135
|
+ if (!$DB->has_results()) {
|
|
|
136
|
+ $Err = 'The torrent group, if entered, must correspond to a torrent group on the site.';
|
|
|
137
|
+ } else {
|
|
|
138
|
+ if ($CategoryID !== $DB->to_array()[0]['CategoryID']) {
|
|
|
139
|
+ $Err = 'The category of the specified torrent group does not match the category of your request.';
|
|
|
140
|
+ }
|
|
|
141
|
+ }
|
|
137
|
142
|
} else {
|
|
138
|
|
- if ($CategoryID != $DB->to_array()[0]['CategoryID']) {
|
|
139
|
|
- $Err = 'The category of the specified torrent group does not match the category of your request.';
|
|
140
|
|
- }
|
|
|
143
|
+ $Err = 'The torrent group, if entered, must correspond to a torrent group on the site.';
|
|
141
|
144
|
}
|
|
142
|
|
- } else {
|
|
143
|
|
- $Err = 'The torrent group, if entered, must correspond to a torrent group on the site.';
|
|
144
|
|
- }
|
|
145
|
145
|
} elseif (isset($_POST['groupid']) && $_POST['groupid'] === '0') {
|
|
146
|
|
- $GroupID = 0;
|
|
|
146
|
+ $GroupID = 0;
|
|
147
|
147
|
}
|
|
148
|
148
|
|
|
149
|
|
-//For refilling on error
|
|
|
149
|
+// For refilling on error
|
|
150
|
150
|
$ArtistNames = [];
|
|
151
|
151
|
$ArtistForm = [];
|
|
152
|
152
|
for ($i = 0; $i < count($Artists); $i++) {
|
|
153
|
|
- if (trim($Artists[$i]) !== '') {
|
|
154
|
|
- if (!in_array($Artists[$i], $ArtistNames)) {
|
|
155
|
|
- $ArtistForm[] = array('name' => trim($Artists[$i]));
|
|
156
|
|
- $ArtistNames[] = trim($Artists[$i]);
|
|
|
153
|
+ if (trim($Artists[$i]) !== '') {
|
|
|
154
|
+ if (!in_array($Artists[$i], $ArtistNames)) {
|
|
|
155
|
+ $ArtistForm[] = array('name' => trim($Artists[$i]));
|
|
|
156
|
+ $ArtistNames[] = trim($Artists[$i]);
|
|
|
157
|
+ }
|
|
157
|
158
|
}
|
|
158
|
|
- }
|
|
159
|
159
|
}
|
|
160
|
160
|
if (!isset($ArtistNames[0])) {
|
|
161
|
|
- unset($ArtistForm);
|
|
|
161
|
+ unset($ArtistForm);
|
|
162
|
162
|
}
|
|
163
|
163
|
|
|
164
|
164
|
if (!empty($Err)) {
|
|
165
|
|
- error($Err);
|
|
166
|
|
- $Div = $_POST['unit'] === 'mb' ? 1024 * 1024 : 1024 * 1024 * 1024;
|
|
167
|
|
- $Bounty /= $Div;
|
|
168
|
|
- include(SERVER_ROOT.'/sections/requests/new_edit.php');
|
|
169
|
|
- die();
|
|
|
165
|
+ error($Err);
|
|
|
166
|
+ $Div = $_POST['unit'] === 'mb' ? 1024 * 1024 : 1024 * 1024 * 1024;
|
|
|
167
|
+ $Bounty /= $Div;
|
|
|
168
|
+ include(SERVER_ROOT.'/sections/requests/new_edit.php');
|
|
|
169
|
+ die();
|
|
170
|
170
|
}
|
|
171
|
171
|
|
|
172
|
|
-//Databasify the input
|
|
173
|
|
-/*if ($CategoryName === 'Music') {
|
|
|
172
|
+// Databasify the input
|
|
|
173
|
+/*
|
|
|
174
|
+if ($CategoryName === 'Music') {
|
|
174
|
175
|
if (empty($AllBitrates)) {
|
|
175
|
176
|
foreach ($BitrateArray as $Index => $MasterIndex) {
|
|
176
|
177
|
if (array_key_exists($Index, $Bitrates)) {
|
|
|
@@ -231,13 +232,16 @@ if (!empty($Err)) {
|
|
231
|
232
|
$LogCue = 'Cue';
|
|
232
|
233
|
}
|
|
233
|
234
|
}
|
|
234
|
|
-}*/
|
|
|
235
|
+}
|
|
|
236
|
+*/
|
|
235
|
237
|
|
|
236
|
|
-if (!isset($GroupID)) $GroupID = '';
|
|
|
238
|
+if (!isset($GroupID)) {
|
|
|
239
|
+ $GroupID = '';
|
|
|
240
|
+}
|
|
237
|
241
|
|
|
238
|
|
-//Query time!
|
|
|
242
|
+// Query time!
|
|
239
|
243
|
if ($NewRequest) {
|
|
240
|
|
- $DB->query('
|
|
|
244
|
+ $DB->query('
|
|
241
|
245
|
INSERT INTO requests (
|
|
242
|
246
|
UserID, TimeAdded, LastVote, CategoryID, Title, TitleRJ, TitleJP, Image, Description,
|
|
243
|
247
|
CatalogueNumber, DLSiteID, Visible, GroupID)
|
|
|
@@ -245,10 +249,9 @@ if ($NewRequest) {
|
|
245
|
249
|
('.$LoggedUser['ID'].", NOW(), NOW(), $CategoryID, '".db_string($Title)."', '".db_string($TitleRJ)."', '".db_string($TitleJP)."', '".db_string($Image)."', '".db_string($Description)."',
|
|
246
|
250
|
'".db_string($CatalogueNumber)."', '".db_string($DLSiteID)."', '1', '$GroupID')");
|
|
247
|
251
|
|
|
248
|
|
- $RequestID = $DB->inserted_id();
|
|
249
|
|
-
|
|
|
252
|
+ $RequestID = $DB->inserted_id();
|
|
250
|
253
|
} else {
|
|
251
|
|
- $DB->query("
|
|
|
254
|
+ $DB->query("
|
|
252
|
255
|
UPDATE requests
|
|
253
|
256
|
SET CategoryID = $CategoryID,
|
|
254
|
257
|
Title = '".db_string($Title)."',
|
|
|
@@ -260,125 +263,123 @@ if ($NewRequest) {
|
|
260
|
263
|
DLSiteID = '".db_string($DLSiteID)."'
|
|
261
|
264
|
WHERE ID = $RequestID");
|
|
262
|
265
|
|
|
263
|
|
- // We need to be able to delete artists / tags
|
|
264
|
|
- $DB->query("
|
|
|
266
|
+ // We need to be able to delete artists/tags
|
|
|
267
|
+ $DB->query("
|
|
265
|
268
|
SELECT ArtistID
|
|
266
|
269
|
FROM requests_artists
|
|
267
|
270
|
WHERE RequestID = $RequestID");
|
|
268
|
|
- $RequestArtists = $DB->to_array();
|
|
269
|
|
- foreach ($RequestArtists as $RequestArtist) {
|
|
270
|
|
- $Cache->delete_value("artists_requests_".$RequestArtist['ArtistID']);
|
|
271
|
|
- }
|
|
272
|
|
- $DB->query("
|
|
|
271
|
+ $RequestArtists = $DB->to_array();
|
|
|
272
|
+ foreach ($RequestArtists as $RequestArtist) {
|
|
|
273
|
+ $Cache->delete_value("artists_requests_".$RequestArtist['ArtistID']);
|
|
|
274
|
+ }
|
|
|
275
|
+ $DB->query("
|
|
273
|
276
|
DELETE FROM requests_artists
|
|
274
|
277
|
WHERE RequestID = $RequestID");
|
|
275
|
|
- $Cache->delete_value("request_artists_$RequestID");
|
|
|
278
|
+ $Cache->delete_value("request_artists_$RequestID");
|
|
276
|
279
|
}
|
|
277
|
280
|
|
|
278
|
281
|
if ($GroupID) {
|
|
279
|
|
- $Cache->delete_value("requests_group_$GroupID");
|
|
|
282
|
+ $Cache->delete_value("requests_group_$GroupID");
|
|
280
|
283
|
}
|
|
281
|
284
|
|
|
282
|
285
|
/*
|
|
283
|
286
|
* Multiple Artists!
|
|
284
|
287
|
* For the multiple artists system, we have 3 steps:
|
|
285
|
|
- * 1. See if each artist given already exists and if it does, grab the ID.
|
|
286
|
|
- * 2. For each artist that didn't exist, create an artist.
|
|
287
|
|
- * 3. Create a row in the requests_artists table for each artist, based on the ID.
|
|
|
288
|
+ * 1. See if each artist given already exists and if it does, grab the ID.
|
|
|
289
|
+ * 2. For each artist that didn't exist, create an artist.
|
|
|
290
|
+ * 3. Create a row in the requests_artists table for each artist, based on the ID.
|
|
288
|
291
|
*/
|
|
289
|
292
|
if (isset($ArtistForm)) {
|
|
290
|
|
- foreach ($ArtistForm as $Num => $Artist) {
|
|
291
|
|
- //1. See if each artist given already exists and if it does, grab the ID.
|
|
292
|
|
- $DB->query("
|
|
|
293
|
+ foreach ($ArtistForm as $Num => $Artist) {
|
|
|
294
|
+ // 1. See if each artist given already exists and if it does, grab the ID.
|
|
|
295
|
+ $DB->query("
|
|
293
|
296
|
SELECT
|
|
294
|
297
|
ArtistID,
|
|
295
|
298
|
Name
|
|
296
|
299
|
FROM artists_group
|
|
297
|
300
|
WHERE Name = '".db_string($Artist['name'])."'");
|
|
298
|
301
|
|
|
299
|
|
- list($ArtistID, $ArtistName) = $DB->next_record(MYSQLI_NUM, false);
|
|
300
|
|
- $ArtistForm[$Num] = array('name' => $ArtistName, 'id' => $ArtistID);
|
|
|
302
|
+ list($ArtistID, $ArtistName) = $DB->next_record(MYSQLI_NUM, false);
|
|
|
303
|
+ $ArtistForm[$Num] = array('name' => $ArtistName, 'id' => $ArtistID);
|
|
301
|
304
|
|
|
302
|
|
- if (!$ArtistID) {
|
|
303
|
|
- //2. For each artist that didn't exist, create an artist.
|
|
304
|
|
- $DB->query("
|
|
|
305
|
+ if (!$ArtistID) {
|
|
|
306
|
+ // 2. For each artist that didn't exist, create an artist.
|
|
|
307
|
+ $DB->query("
|
|
305
|
308
|
INSERT INTO artists_group (Name)
|
|
306
|
309
|
VALUES ('".db_string($Artist['name'])."')");
|
|
307
|
|
- $ArtistID = $DB->inserted_id();
|
|
|
310
|
+ $ArtistID = $DB->inserted_id();
|
|
308
|
311
|
|
|
309
|
|
- $Cache->increment('stats_artist_count');
|
|
|
312
|
+ $Cache->increment('stats_artist_count');
|
|
310
|
313
|
|
|
311
|
|
- $ArtistForm[$Num] = array('id' => $ArtistID, 'name' => $Artist['name']);
|
|
|
314
|
+ $ArtistForm[$Num] = array('id' => $ArtistID, 'name' => $Artist['name']);
|
|
|
315
|
+ }
|
|
312
|
316
|
}
|
|
313
|
|
- }
|
|
314
|
317
|
|
|
315
|
|
-
|
|
316
|
|
- //3. Create a row in the requests_artists table for each artist, based on the ID.
|
|
317
|
|
- foreach ($ArtistForm as $Num => $Artist) {
|
|
318
|
|
- $DB->query("
|
|
|
318
|
+ // 3. Create a row in the requests_artists table for each artist, based on the ID.
|
|
|
319
|
+ foreach ($ArtistForm as $Num => $Artist) {
|
|
|
320
|
+ $DB->query("
|
|
319
|
321
|
INSERT IGNORE INTO requests_artists
|
|
320
|
322
|
(RequestID, ArtistID)
|
|
321
|
323
|
VALUES
|
|
322
|
324
|
($RequestID, ".$Artist['id'].")");
|
|
323
|
|
- $Cache->delete_value('artists_requests_'.$Artist['id']);
|
|
324
|
|
- }
|
|
325
|
|
- //End Music only
|
|
326
|
|
-
|
|
|
325
|
+ $Cache->delete_value('artists_requests_'.$Artist['id']);
|
|
|
326
|
+ }
|
|
|
327
|
+ // End Music only
|
|
327
|
328
|
} else {
|
|
328
|
|
- //Not a music request anymore, delete music only fields.
|
|
329
|
|
- if (!$NewRequest) {
|
|
330
|
|
- $DB->query("
|
|
|
329
|
+ // Not a music request anymore, delete music only fields.
|
|
|
330
|
+ if (!$NewRequest) {
|
|
|
331
|
+ $DB->query("
|
|
331
|
332
|
SELECT ArtistID
|
|
332
|
333
|
FROM requests_artists
|
|
333
|
334
|
WHERE RequestID = $RequestID");
|
|
334
|
|
- $OldArtists = $DB->collect('ArtistID');
|
|
335
|
|
- foreach ($OldArtists as $ArtistID) {
|
|
336
|
|
- if (empty($ArtistID)) {
|
|
337
|
|
- continue;
|
|
338
|
|
- }
|
|
339
|
|
- //Get a count of how many groups or requests use the artist ID
|
|
340
|
|
- $DB->query("
|
|
|
335
|
+ $OldArtists = $DB->collect('ArtistID');
|
|
|
336
|
+ foreach ($OldArtists as $ArtistID) {
|
|
|
337
|
+ if (empty($ArtistID)) {
|
|
|
338
|
+ continue;
|
|
|
339
|
+ }
|
|
|
340
|
+ // Get a count of how many groups or requests use the artist ID
|
|
|
341
|
+ $DB->query("
|
|
341
|
342
|
SELECT COUNT(ag.ArtistID)
|
|
342
|
343
|
FROM artists_group AS ag
|
|
343
|
344
|
LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
|
|
344
|
345
|
WHERE ra.ArtistID IS NOT NULL
|
|
345
|
346
|
AND ag.ArtistID = '$ArtistID'");
|
|
346
|
|
- list($ReqCount) = $DB->next_record();
|
|
347
|
|
- $DB->query("
|
|
|
347
|
+ list($ReqCount) = $DB->next_record();
|
|
|
348
|
+ $DB->query("
|
|
348
|
349
|
SELECT COUNT(ag.ArtistID)
|
|
349
|
350
|
FROM artists_group AS ag
|
|
350
|
351
|
LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
|
|
351
|
352
|
WHERE ta.ArtistID IS NOT NULL
|
|
352
|
353
|
AND ag.ArtistID = '$ArtistID'");
|
|
353
|
|
- list($GroupCount) = $DB->next_record();
|
|
354
|
|
- if (($ReqCount + $GroupCount) == 0) {
|
|
355
|
|
- //The only group to use this artist
|
|
356
|
|
- Artists::delete_artist($ArtistID);
|
|
357
|
|
- } else {
|
|
358
|
|
- //Not the only group, still need to clear cache
|
|
359
|
|
- $Cache->delete_value("artists_requests_$ArtistID");
|
|
360
|
|
- }
|
|
361
|
|
- }
|
|
362
|
|
- $DB->query("
|
|
|
354
|
+ list($GroupCount) = $DB->next_record();
|
|
|
355
|
+ if (($ReqCount + $GroupCount) === 0) {
|
|
|
356
|
+ // The only group to use this artist
|
|
|
357
|
+ Artists::delete_artist($ArtistID);
|
|
|
358
|
+ } else {
|
|
|
359
|
+ // Not the only group, still need to clear cache
|
|
|
360
|
+ $Cache->delete_value("artists_requests_$ArtistID");
|
|
|
361
|
+ }
|
|
|
362
|
+ }
|
|
|
363
|
+ $DB->query("
|
|
363
|
364
|
DELETE FROM requests_artists
|
|
364
|
365
|
WHERE RequestID = $RequestID");
|
|
365
|
|
- $Cache->delete_value("request_artists_$RequestID");
|
|
366
|
|
- }
|
|
|
366
|
+ $Cache->delete_value("request_artists_$RequestID");
|
|
|
367
|
+ }
|
|
367
|
368
|
}
|
|
368
|
369
|
|
|
369
|
370
|
//Tags
|
|
370
|
371
|
if (!$NewRequest) {
|
|
371
|
|
- $DB->query("
|
|
|
372
|
+ $DB->query("
|
|
372
|
373
|
DELETE FROM requests_tags
|
|
373
|
374
|
WHERE RequestID = $RequestID");
|
|
374
|
375
|
}
|
|
375
|
376
|
|
|
376
|
377
|
$Tags = array_unique(explode(',', $Tags));
|
|
377
|
378
|
foreach ($Tags as $Index => $Tag) {
|
|
378
|
|
- $Tag = Misc::sanitize_tag($Tag);
|
|
379
|
|
- $Tag = Misc::get_alias_tag($Tag);
|
|
380
|
|
- $Tags[$Index] = $Tag; //For announce
|
|
381
|
|
- $DB->query("
|
|
|
379
|
+ $Tag = Misc::sanitize_tag($Tag);
|
|
|
380
|
+ $Tag = Misc::get_alias_tag($Tag);
|
|
|
381
|
+ $Tags[$Index] = $Tag; // For announce
|
|
|
382
|
+ $DB->query("
|
|
382
|
383
|
INSERT INTO tags
|
|
383
|
384
|
(Name, UserID)
|
|
384
|
385
|
VALUES
|
|
|
@@ -386,9 +387,9 @@ foreach ($Tags as $Index => $Tag) {
|
|
386
|
387
|
ON DUPLICATE KEY UPDATE
|
|
387
|
388
|
Uses = Uses + 1");
|
|
388
|
389
|
|
|
389
|
|
- $TagID = $DB->inserted_id();
|
|
|
390
|
+ $TagID = $DB->inserted_id();
|
|
390
|
391
|
|
|
391
|
|
- $DB->query("
|
|
|
392
|
+ $DB->query("
|
|
392
|
393
|
INSERT IGNORE INTO requests_tags
|
|
393
|
394
|
(TagID, RequestID)
|
|
394
|
395
|
VALUES
|
|
|
@@ -396,30 +397,28 @@ foreach ($Tags as $Index => $Tag) {
|
|
396
|
397
|
}
|
|
397
|
398
|
|
|
398
|
399
|
if ($NewRequest) {
|
|
399
|
|
- //Remove the bounty and create the vote
|
|
400
|
|
- $DB->query("
|
|
|
400
|
+ // Remove the bounty and create the vote
|
|
|
401
|
+ $DB->query("
|
|
401
|
402
|
INSERT INTO requests_votes
|
|
402
|
403
|
(RequestID, UserID, Bounty)
|
|
403
|
404
|
VALUES
|
|
404
|
405
|
($RequestID, ".$LoggedUser['ID'].', '.($Bytes * (1 - $RequestTax)).')');
|
|
405
|
406
|
|
|
406
|
|
- $DB->query("
|
|
|
407
|
+ $DB->query("
|
|
407
|
408
|
UPDATE users_main
|
|
408
|
409
|
SET Uploaded = (Uploaded - $Bytes)
|
|
409
|
410
|
WHERE ID = ".$LoggedUser['ID']);
|
|
410
|
|
- $Cache->delete_value('user_stats_'.$LoggedUser['ID']);
|
|
411
|
|
-
|
|
412
|
|
- $AnnounceTitle = empty($Title) ? (empty($TitleRJ) ? $TitleJP : $TitleRJ) : $Title;
|
|
|
411
|
+ $Cache->delete_value('user_stats_'.$LoggedUser['ID']);
|
|
413
|
412
|
|
|
414
|
|
- $Announce = "\"$AnnounceTitle\"".(isset($ArtistForm)?(' - '.Artists::display_artists($ArtistForm, false, false)):'').' '.site_url()."requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
|
|
415
|
|
- send_irc('PRIVMSG '.BOT_REQUEST_CHAN.' '.$Announce);
|
|
|
413
|
+ $AnnounceTitle = empty($Title) ? (empty($TitleRJ) ? $TitleJP : $TitleRJ) : $Title;
|
|
416
|
414
|
|
|
|
415
|
+ $Announce = "\"$AnnounceTitle\"".(isset($ArtistForm)?(' - '.Artists::display_artists($ArtistForm, false, false)):'').' '.site_url()."requests.php?action=view&id=$RequestID - ".implode(' ', $Tags);
|
|
|
416
|
+ send_irc('PRIVMSG '.BOT_REQUEST_CHAN.' '.$Announce);
|
|
417
|
417
|
} else {
|
|
418
|
|
- $Cache->delete_value("request_$RequestID");
|
|
419
|
|
- $Cache->delete_value("request_artists_$RequestID");
|
|
|
418
|
+ $Cache->delete_value("request_$RequestID");
|
|
|
419
|
+ $Cache->delete_value("request_artists_$RequestID");
|
|
420
|
420
|
}
|
|
421
|
421
|
|
|
422
|
422
|
Requests::update_sphinx_requests($RequestID);
|
|
423
|
423
|
|
|
424
|
424
|
header("Location: requests.php?action=view&id=$RequestID");
|
|
425
|
|
-?>
|