|
@@ -3,29 +3,31 @@ declare(strict_types=1);
|
3
|
3
|
|
4
|
4
|
authorize();
|
5
|
5
|
|
6
|
|
-$GroupID = (int) $_GET['groupid'];
|
7
|
|
-Security::checkInt($GroupID);
|
|
6
|
+$group_id = (int) $_REQUEST['groupid'];
|
|
7
|
+Security::checkInt($group_id);
|
8
|
8
|
|
9
|
9
|
// Usual perm checks
|
10
|
10
|
if (!check_perms('torrents_edit')) {
|
11
|
|
- $DB->query("
|
|
11
|
+ $DB->prepare_query("
|
12
|
12
|
SELECT
|
13
|
13
|
`UserID`
|
14
|
14
|
FROM
|
15
|
15
|
`torrents`
|
16
|
16
|
WHERE
|
17
|
|
- `GroupID` = '$group_id'
|
|
17
|
+ `GroupID` = '$GroupID'
|
18
|
18
|
");
|
|
19
|
+ $DB->exec_prepared_query();
|
19
|
20
|
|
20
|
21
|
if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
|
21
|
22
|
error(403);
|
22
|
23
|
}
|
23
|
24
|
}
|
24
|
25
|
|
|
26
|
+# ?
|
25
|
27
|
if (check_perms('torrents_freeleech')
|
26
|
|
- && (isset($_POST['freeleech'])
|
27
|
|
- xor isset($_POST['neutralleech'])
|
28
|
|
- xor isset($_POST['unfreeleech']))) {
|
|
28
|
+ && (isset($_POST['freeleech'])
|
|
29
|
+ xor isset($_POST['neutralleech'])
|
|
30
|
+ xor isset($_POST['unfreeleech']))) {
|
29
|
31
|
if (isset($_POST['freeleech'])) {
|
30
|
32
|
$Free = 1;
|
31
|
33
|
} elseif (isset($_POST['neutralleech'])) {
|
|
@@ -48,36 +50,38 @@ $Artists = $_POST['idols'];
|
48
|
50
|
// Escape fields
|
49
|
51
|
$workgroup = db_string($_POST['studio']);
|
50
|
52
|
$location = db_string($_POST['series']);
|
51
|
|
-$published = db_string((int)$_POST['year']);
|
|
53
|
+$year = db_string((int)$_POST['year']);
|
52
|
54
|
$identifier = db_string($_POST['catalogue']);
|
53
|
55
|
|
54
|
56
|
// Get some info for the group log
|
55
|
|
-$DB->query("
|
|
57
|
+$DB->prepare_query("
|
56
|
58
|
SELECT
|
57
|
|
- `published`
|
|
59
|
+ `year`
|
58
|
60
|
FROM
|
59
|
61
|
`torrents_group`
|
60
|
62
|
WHERE
|
61
|
63
|
`id` = '$group_id'
|
62
|
64
|
");
|
|
65
|
+$DB->exec_prepared_query();
|
63
|
66
|
list($OldYear) = $DB->next_record();
|
64
|
67
|
|
65
|
|
-$DB->query("
|
|
68
|
+$DB->prepare_query("
|
66
|
69
|
UPDATE
|
67
|
70
|
`torrents_group`
|
68
|
71
|
SET
|
69
|
|
- `published` = '$published',
|
|
72
|
+ `year` = '$year',
|
70
|
73
|
`identifier` = '$identifier',
|
71
|
74
|
`workgroup` = '$workgroup',
|
72
|
75
|
`location` = '$location'
|
73
|
76
|
WHERE
|
74
|
77
|
`id` = '$group_id'
|
75
|
78
|
");
|
|
79
|
+$DB->exec_prepared_query();
|
76
|
80
|
|
77
|
|
-if ($OldYear !== $published) {
|
78
|
|
- $Message = db_string("Year changed from $OldYear to $published");
|
|
81
|
+if ($OldYear !== $year) {
|
|
82
|
+ $Message = db_string("Year changed from $OldYear to $year");
|
79
|
83
|
|
80
|
|
- $DB->query("
|
|
84
|
+ $DB->prepare_query("
|
81
|
85
|
INSERT INTO `group_log`(`GroupID`, `UserID`, `Time`, `Info`)
|
82
|
86
|
VALUES(
|
83
|
87
|
'$group_id',
|
|
@@ -85,9 +89,10 @@ if ($OldYear !== $published) {
|
85
|
89
|
NOW(),
|
86
|
90
|
'$Message')
|
87
|
91
|
");
|
|
92
|
+ $DB->exec_prepared_query();
|
88
|
93
|
}
|
89
|
94
|
|
90
|
|
-$DB->query("
|
|
95
|
+$DB->prepare_query("
|
91
|
96
|
SELECT
|
92
|
97
|
ag.`Name`
|
93
|
98
|
FROM
|
|
@@ -98,6 +103,7 @@ ON
|
98
|
103
|
WHERE
|
99
|
104
|
ta.`GroupID` = '$group_id'
|
100
|
105
|
");
|
|
106
|
+$DB->exec_prepared_query();
|
101
|
107
|
|
102
|
108
|
while ($r = $DB->next_record(MYSQLI_ASSOC, true)) {
|
103
|
109
|
$CurrArtists[] = $r['Name'];
|
|
@@ -106,7 +112,7 @@ while ($r = $DB->next_record(MYSQLI_ASSOC, true)) {
|
106
|
112
|
foreach ($Artists as $Artist) {
|
107
|
113
|
if (!in_array($Artist, $CurrArtists)) {
|
108
|
114
|
$Artist = db_string($Artist);
|
109
|
|
- $DB->query("
|
|
115
|
+ $DB->prepare_query("
|
110
|
116
|
SELECT
|
111
|
117
|
`ArtistID`
|
112
|
118
|
FROM
|
|
@@ -114,18 +120,20 @@ foreach ($Artists as $Artist) {
|
114
|
120
|
WHERE
|
115
|
121
|
`Name` = '$Artist'
|
116
|
122
|
");
|
|
123
|
+ $DB->exec_prepared_query();
|
117
|
124
|
|
118
|
125
|
if ($DB->has_results()) {
|
119
|
126
|
list($ArtistID) = $DB->next_record();
|
120
|
127
|
} else {
|
121
|
|
- $DB->query("
|
|
128
|
+ $DB->prepare_query("
|
122
|
129
|
INSERT INTO `artists_group`(`Name`)
|
123
|
130
|
VALUES('$Artist')
|
124
|
131
|
");
|
|
132
|
+ $DB->exec_prepared_query();
|
125
|
133
|
$ArtistID = $DB->inserted_id();
|
126
|
134
|
}
|
127
|
135
|
|
128
|
|
- $DB->query("
|
|
136
|
+ $DB->prepare_query("
|
129
|
137
|
INSERT INTO `torrents_artists`(`GroupID`, `ArtistID`, `UserID`)
|
130
|
138
|
VALUES(
|
131
|
139
|
'$group_id',
|
|
@@ -136,6 +144,7 @@ foreach ($Artists as $Artist) {
|
136
|
144
|
UPDATE
|
137
|
145
|
`UserID` = '$LoggedUser[ID]'
|
138
|
146
|
"); // Why does this even happen
|
|
147
|
+ $DB->exec_prepared_query();
|
139
|
148
|
$Cache->delete_value('artist_groups_'.$ArtistID);
|
140
|
149
|
}
|
141
|
150
|
}
|
|
@@ -144,7 +153,7 @@ foreach ($CurrArtists as $CurrArtist) {
|
144
|
153
|
if (!in_array($CurrArtist, $Artists)) {
|
145
|
154
|
$CurrArtist = db_string($CurrArtist);
|
146
|
155
|
|
147
|
|
- $DB->query("
|
|
156
|
+ $DB->prepare_query("
|
148
|
157
|
SELECT
|
149
|
158
|
`ArtistID`
|
150
|
159
|
FROM
|
|
@@ -152,11 +161,12 @@ foreach ($CurrArtists as $CurrArtist) {
|
152
|
161
|
WHERE
|
153
|
162
|
`Name` = '$CurrArtist'
|
154
|
163
|
");
|
|
164
|
+ $DB->exec_prepared_query();
|
155
|
165
|
|
156
|
166
|
if ($DB->has_results()) {
|
157
|
167
|
list($ArtistID) = $DB->next_record();
|
158
|
168
|
|
159
|
|
- $DB->query("
|
|
169
|
+ $DB->prepare_query("
|
160
|
170
|
DELETE
|
161
|
171
|
FROM
|
162
|
172
|
`torrents_artists`
|
|
@@ -164,8 +174,9 @@ foreach ($CurrArtists as $CurrArtist) {
|
164
|
174
|
`ArtistID` = '$ArtistID'
|
165
|
175
|
AND `GroupID` = '$group_id'
|
166
|
176
|
");
|
|
177
|
+ $DB->exec_prepared_query();
|
167
|
178
|
|
168
|
|
- $DB->query("
|
|
179
|
+ $DB->prepare_query("
|
169
|
180
|
SELECT
|
170
|
181
|
`GroupID`
|
171
|
182
|
FROM
|
|
@@ -173,11 +184,12 @@ foreach ($CurrArtists as $CurrArtist) {
|
173
|
184
|
WHERE
|
174
|
185
|
`ArtistID` = '$ArtistID'
|
175
|
186
|
");
|
|
187
|
+ $DB->exec_prepared_query();
|
176
|
188
|
|
177
|
189
|
$Cache->delete_value('artist_groups_'.$ArtistID);
|
178
|
190
|
|
179
|
191
|
if (!$DB->has_results()) {
|
180
|
|
- $DB->query("
|
|
192
|
+ $DB->prepare_query("
|
181
|
193
|
SELECT
|
182
|
194
|
`RequestID`
|
183
|
195
|
FROM
|
|
@@ -186,6 +198,7 @@ foreach ($CurrArtists as $CurrArtist) {
|
186
|
198
|
`ArtistID` = '$ArtistID'
|
187
|
199
|
AND `ArtistID` != 0
|
188
|
200
|
");
|
|
201
|
+ $DB->exec_prepared_query();
|
189
|
202
|
|
190
|
203
|
if (!$DB->has_results()) {
|
191
|
204
|
Artists::delete_artist($ArtistID);
|
|
@@ -195,7 +208,7 @@ foreach ($CurrArtists as $CurrArtist) {
|
195
|
208
|
}
|
196
|
209
|
}
|
197
|
210
|
|
198
|
|
-$DB->query("
|
|
211
|
+$DB->prepare_query("
|
199
|
212
|
SELECT
|
200
|
213
|
`ID`
|
201
|
214
|
FROM
|
|
@@ -203,6 +216,7 @@ FROM
|
203
|
216
|
WHERE
|
204
|
217
|
`GroupID` = '$group_id'
|
205
|
218
|
");
|
|
219
|
+$DB->exec_prepared_query();
|
206
|
220
|
|
207
|
221
|
while (list($TorrentID) = $DB->next_record()) {
|
208
|
222
|
$Cache->delete_value("torrent_download_$TorrentID");
|