Browse Source

Start to implement Seqhash and fix lots of stuff (the site is still broken)

biotorrents 4 years ago
parent
commit
390486c99e

+ 0
- 10
classes/script_start.php View File

@@ -547,16 +547,6 @@ if (isset(G::$LoggedUser['LockedAccount']) && !in_array($Document, $AllowedPages
547 547
 
548 548
 $Debug->set_flag('completed module execution');
549 549
 
550
-/* Required in the absence of session_start() for providing that pages will change
551
-upon hit rather than being browser cached for changing content.
552
-
553
-Old versions of Internet Explorer choke when downloading binary files over HTTPS with disabled cache.
554
-Define the following constant in files that handle file downloads */
555
-if (!defined('SKIP_NO_CACHE_HEADERS')) {
556
-    header('Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0');
557
-    header('Pragma: no-cache');
558
-}
559
-
560 550
 // Flush to user
561 551
 ob_end_flush();
562 552
 

+ 14
- 10
classes/security.class.php View File

@@ -6,6 +6,7 @@ declare(strict_types = 1);
6 6
  *
7 7
  * Designed to hold common authentication functions from various sources:
8 8
  *  - classes/script_start.php
9
+ *  - "Quick SQL injection check"
9 10
  */
10 11
 
11 12
 class Security
@@ -16,16 +17,17 @@ class Security
16 17
      * Makes sure a number ID is valid,
17 18
      * e.g., a page ID requested by GET.
18 19
      */
19
-    public function checkInt($IDs)
20
+    public function checkInt(mixed $ID)
21
+    #public function checkInt(int|array $ID) # Union types need PHP 8 - unbelievable!
20 22
     {
21
-        # Temporary failsafe
22
-        # (int) 'dingus' = 0
23
-        # (int) 3.14 = 3
24
-        $IDs = (is_array($IDs) ?: [(int) $IDs]);
25
-        foreach ($IDs as $ID) {
26
-            $ID = (int) $ID;
27
-
28
-            if (!is_int($ID) || $ID < 1) {
23
+        # Cast single ID to array
24
+        if (!is_array($ID)) {
25
+            $ID = [$ID];
26
+        }
27
+
28
+        # Check each ID supplied
29
+        foreach ($ID as $ID) {
30
+            if (!ID || !is_int($ID) || $ID < 1) {
29 31
                 error(400);
30 32
             }
31 33
         }
@@ -33,13 +35,14 @@ class Security
33 35
         return;
34 36
     }
35 37
 
38
+
36 39
     /**
37 40
      * Setup pitfalls
38 41
      *
39 42
      * A series of quick sanity checks during app init.
40 43
      * Previously in classes/script_start.php.
41 44
      */
42
-    public function SetupPitfalls()
45
+    public function setupPitfalls()
43 46
     {
44 47
         # short_open_tag
45 48
         if (!ini_get('short_open_tag')) {
@@ -63,6 +66,7 @@ class Security
63 66
         return;
64 67
     }
65 68
 
69
+
66 70
     /**
67 71
      * UserID checks
68 72
      *

+ 360
- 0
classes/seqhash.class.php View File

@@ -0,0 +1,360 @@
1
+<?php
2
+#declare(strict_types = 1);
3
+# PHP Notice:  Trying to access array offset on value of type bool in /var/www/html/dev.biotorrents.de/classes/seqhash.class.php on line 233
4
+
5
+/**
6
+ * Seqhash
7
+ *
8
+ * Implements Keoni's Seqhash algorithm for DNA/RNA/protein sequences,
9
+ * e.g., v1_DCD_4b0616d1b3fc632e42d78521deb38b44fba95cca9fde159e01cd567fa996ceb9
10
+ *
11
+ * > The first element is the version tag (v1 for version 1).
12
+ * > If there is ever a Seqhash version 2, this tag will differentiate seqhashes.
13
+ *
14
+ * > The second element is the metadata tag, which has 3 letters.
15
+ * > The first letter codes for the sequenceType (D for DNA, R for RNA, and P for Protein).
16
+ * > The second letter codes for whether or not the sequence is circular (C for Circular, L for Linear).
17
+ * > The final letter codes for whether or not the sequence is double stranded (D for Double stranded, S for Single stranded).
18
+ *
19
+ * > The final element is the blake3 hash of the sequence (once rotated and complemented).
20
+ *
21
+ * Requires the php-blake3 extension from:
22
+ * https://github.com/cypherbits/php-blake3
23
+ *
24
+ * @see https://blog.libredna.org/post/seqhash/
25
+ * @see https://github.com/TimothyStiles/poly/blob/prime/hash.go
26
+ * @see https://github.com/TimothyStiles/poly/blob/prime/hash_test.go
27
+ */
28
+
29
+class Seqhash
30
+{
31
+    /**
32
+     * boothLeastRotation
33
+     *
34
+     * Gets the least rotation of a circular string.
35
+     * @see https://en.wikipedia.org/wiki/Lexicographically_minimal_string_rotation
36
+     */
37
+    public function boothLeastRotation(string $Sequence)
38
+    {
39
+        # First concatenate the sequence to itself to avoid modular arithmatic
40
+        # todo: Use buffers just for speed? May get annoying with larger sequences
41
+        $Sequence = $Sequence . $Sequence;
42
+        $LeastRotationIndex = 0;
43
+
44
+        # Initializing failure slice
45
+        $FailureSlice = array_fill(0, strlen($Sequence), -1);
46
+
47
+        /*
48
+        for ($i = 0; $i <= strlen($Sequence); $i++) {
49
+            $FailureSlice[$i] = -1;
50
+        }
51
+        */
52
+
53
+        # Iterate through each character in the doubled-over sequence
54
+        for ($CharacterIndex = 1; $CharacterIndex < strlen($Sequence); $CharacterIndex++) {
55
+
56
+            # Get character
57
+            $Character = $Sequence[$CharacterIndex];
58
+
59
+            # Get failure
60
+            $Failure = $FailureSlice[$CharacterIndex - $LeastRotationIndex - 1];
61
+
62
+            # While failure !== -1 and character !== the character found at the least rotation + failure + 1
63
+            while ($Failure !== -1 && $Character !== $Sequence[$LeastRotationIndex + $Failure + 1]) {
64
+
65
+                # If character is lexically less than whatever is at $LeastRotationIndex, update $LeastRotationIndex
66
+                if ($Character < $Sequence[$LeastRotationIndex + $Failure + 1]) {
67
+                    $LeastRotationIndex = $CharacterIndex - $Failure - 1;
68
+                }
69
+
70
+                # Update failure using previous failure as index?
71
+                $Failure = $FailureSlice[$Failure];
72
+            } # while
73
+
74
+            # If character does not equal whatever character is at leastRotationIndex plus failure
75
+            if ($Character !== $Sequence[$LeastRotationIndex + $Failure + 1]) {
76
+
77
+                # If character is lexically less then what is rotated, $LeastRotatationIndex gets value of $CharacterIndex
78
+                if ($Character < $Sequence[$LeastRotationIndex]) {
79
+                    $LeastRotationIndex = $CharacterIndex;
80
+                }
81
+
82
+                # Assign -1 to whatever is at the index of difference between character and rotation indices
83
+                $FailureSlice[$CharacterIndex - $LeastRotationIndex] = -1;
84
+    
85
+            # If character does equal whatever character is at $LeastRotationIndex + $Failure
86
+            } else {
87
+                # Assign $Failure + 1 at the index of difference between character and rotation indices
88
+                $FailureSlice[$CharacterIndex - $LeastRotationIndex] = $Failure + 1;
89
+            }
90
+        } # for
91
+
92
+        return $LeastRotationIndex;
93
+    }
94
+
95
+
96
+    /**
97
+     * rotateSequence
98
+     *
99
+     * Rotates circular sequences to a deterministic point.
100
+     */
101
+    public function rotateSequence(string $Sequence)
102
+    {
103
+        $RotationIndex = $this->boothLeastRotation($Sequence);
104
+
105
+        # Writing the same sequence twice
106
+        # PHP has no strings.Builder.WriteString
107
+        $ConcatenatedSequence = $Sequence . $Sequence;
108
+
109
+        # https://stackoverflow.com/a/2423867
110
+        $Length = $RotationIndex % strlen($Sequence);
111
+        return substr($Sequence, $Length) . substr($Sequence, 0, $Length);
112
+    }
113
+
114
+
115
+    /**
116
+     * reverseComplement
117
+     *
118
+     * Takes the reverse complement of a sequence.
119
+     * Doesn't validate the sequence alphabet first.
120
+     */
121
+    public function reverseComplement(string $Sequence)
122
+    {
123
+        # Normalize the sequence
124
+        $Sequence = strtoupper($Sequence);
125
+
126
+        /**
127
+         * Provides 1:1 mapping between bases and their complements.
128
+         * Kind of ghetto, but lowercase replaces help stop extra flips.
129
+         * @see https://github.com/TimothyStiles/poly/blob/prime/sequence.go
130
+         */
131
+        $RuneMap = [
132
+            'A' => 't',
133
+            'B' => 'v',
134
+            'C' => 'g',
135
+            'D' => 'h',
136
+            'G' => 'c',
137
+            'H' => 'd',
138
+            'K' => 'm',
139
+            'M' => 'k',
140
+            'N' => 'n',
141
+            'R' => 'y',
142
+            'S' => 's',
143
+            'T' => 'a',
144
+            'U' => 'a',
145
+            'V' => 'b',
146
+            'W' => 'w',
147
+            'Y' => 'r',
148
+        ];
149
+
150
+        return $ComplementString = strtoupper(
151
+            str_replace(
152
+                array_keys($RuneMap),
153
+                array_values($RuneMap),
154
+                $Sequence
155
+            )
156
+        );
157
+    }
158
+
159
+
160
+    /**
161
+     * hash
162
+     *
163
+     * Create a Seqhash from a string.
164
+     */
165
+    public function hash(
166
+        string $Sequence,
167
+        string $SequenceType,
168
+        bool   $Circular = false,
169
+        bool   $DoubleStranded = true
170
+    ) {
171
+        # Check for Blake3 support
172
+        if (!extension_loaded('blake3')) {
173
+            throw new Exception('Please install and enable the php-blake3 extension.');
174
+        }
175
+
176
+        # By definition, Seqhashes are of uppercase sequences
177
+        $Sequence = strtoupper($Sequence);
178
+
179
+        # If RNA, convert to a DNA sequence
180
+        # The hash itself between a DNA and RNA sequence will not be different,
181
+        # but their Seqhash will have a different metadata string (R vs. D)
182
+        if ($SequenceType === 'RNA') {
183
+            $Sequence = str_replace('T', 'U', $Sequence);
184
+        }
185
+
186
+        # Run checks on the input
187
+        if (!in_array($SequenceType, ['DNA', 'RNA', 'PROTEIN'])) {
188
+            throw new Exception("SequenceType must be one of [DNA, RNA, PROTEIN]. Got $SequenceType.");
189
+        }
190
+
191
+        # Check the alphabet used
192
+        $SequenceRegex = '/[ATUGCYRSWKMBDHVNZ]/';
193
+        $ProteinRegex = '/[ACDEFGHIKLMNPQRSTVWYUO*BXZ]/';
194
+
195
+        # todo: Refactor this to detect $SequenceType from alphabet
196
+        if ($SequenceType === 'DNA' || $SequenceType === 'RNA') {
197
+            foreach (str_split($Sequence) as $Letter) {
198
+                if (!preg_match($SequenceRegex, $Letter)) {
199
+                    throw new Exception("Only letters ATUGCYRSWKMBDHVNZ are allowed for DNA/RNA. Got $Letter.");
200
+                }
201
+            }
202
+        }
203
+
204
+        /**
205
+         * Selenocysteine (Sec; U) and pyrrolysine (Pyl; O) are added
206
+         * in accordance with https://www.uniprot.org/help/sequences
207
+         *
208
+         * The release notes https://web.expasy.org/docs/relnotes/relstat.html
209
+         * also state there are Asx (B), Glx (Z), and Xaa (X) amino acids,
210
+         * so these are added in as well.
211
+         */
212
+        else {
213
+            foreach (str_split($Sequence) as $Letter) {
214
+                if (!preg_match($ProteinRegex, $Letter)) {
215
+                    throw new Exception("Only letters ACDEFGHIKLMNPQRSTVWYUO*BXZ are allowed for proteins. Got $Letter.");
216
+                }
217
+            }
218
+        }
219
+    
220
+        # There is no check for circular proteins since proteins can be circular
221
+        if ($SequenceType === 'PROTEIN' && $DoubleStranded) {
222
+            throw new Exception("Proteins can't be double stranded.");
223
+        }
224
+
225
+        # Gets deterministic sequence based off of metadata + sequence
226
+        #switch ($Circular && $DoubleStranded) {
227
+        switch ([$Circular, $DoubleStranded]) {
228
+            #case (true && true):
229
+            case [true, true]:
230
+                $PotentialSequences = [
231
+                    $this->rotateSequence($Sequence),
232
+                    $this->rotateSequence($this->reverseComplement($Sequence)),
233
+                ];
234
+                $DeterministicSequence = sort($PotentialSequences)[0];
235
+                break;
236
+
237
+            #case (true && false):
238
+            case [true, false]:
239
+                $DeterministicSequence = $this->rotateSequence($Sequence);
240
+                break;
241
+
242
+            #case (false && true):
243
+            case [false, true]:
244
+                $PotentialSequences = [
245
+                    $Sequence,
246
+                    $this->reverseComplement($Sequence),
247
+                ];
248
+                $DeterministicSequence = sort($PotentialSequences)[0];
249
+                break;
250
+
251
+            #case (false && false):
252
+            case [false, false]:
253
+                $DeterministicSequence = $Sequence;
254
+                break;
255
+
256
+            default:
257
+                break;
258
+        }
259
+
260
+        /**
261
+         * Build 3 letter metadata
262
+         */
263
+
264
+        # Get first letter: D for DNA, R for RNA, and P for Protein
265
+        switch ($SequenceType) {
266
+            case 'DNA':
267
+                $SequenceTypeLetter = 'D';
268
+                break;
269
+            
270
+            case 'RNA':
271
+                $SequenceTypeLetter = 'R';
272
+                break;
273
+            
274
+            case 'PROTEIN':
275
+                $SequenceTypeLetter = 'P';
276
+                break;
277
+                
278
+            default:
279
+                break;
280
+            }
281
+
282
+        # Get 2nd letter: C for circular, L for Linear
283
+        if ($Circular) {
284
+            $CircularLetter = 'C';
285
+        } else {
286
+            $CircularLetter = 'L';
287
+        }
288
+
289
+        # Get 3rd letter: D for Double stranded, S for Single stranded
290
+        if ($DoubleStranded) {
291
+            $DoubleStrandedLetter = 'D';
292
+        } else {
293
+            $DoubleStrandedLetter = 'S';
294
+        }
295
+
296
+        # php-blake3 returns hex by default,
297
+        # binary if $rawOutput = true
298
+        return
299
+            'v1'
300
+          . '_'
301
+          . $SequenceTypeLetter
302
+          . $CircularLetter
303
+          . $DoubleStrandedLetter
304
+          . '_'
305
+          . blake3($DeterministicSequence);
306
+    }
307
+
308
+
309
+    /**
310
+     * validate
311
+     *
312
+     * Validates a Seqhash's metadata.
313
+     * Doesn't check the Blake3 hash itself,
314
+     * because php-blake3 has no such feature.
315
+     */
316
+    public function validate(string $Seqhash)
317
+    {
318
+        $Parts = explode('_', $Seqhash);
319
+
320
+        # Check version info
321
+        if ($Parts[0] !== 'v1') {
322
+            throw new Exception("Invalid version info. Got $Parts[0].");
323
+        }
324
+
325
+        # Check 3 letter metadata
326
+        $Meta = str_split($Parts[1]);
327
+        if (!in_array($Meta[0], ['D', 'R', 'P'])
328
+         || !in_array($Meta[1], ['C', 'L'])
329
+         || !in_array($Meta[2], ['D', 'S'])) {
330
+            throw new Exception("Invalid metadata. Got $Parts[1].");
331
+        }
332
+
333
+        # Check Blake3 hex and hash length
334
+        if (!ctype_xdigit($Parts[2]) || strlen($Parts[2] !== 64)) {
335
+            throw new Exception("Invalid Blake3 hash. Expected a 64-character hex string.");
336
+        }
337
+
338
+        return true;
339
+    }
340
+
341
+
342
+    /**
343
+     * gcContent
344
+     *
345
+     * Bonus feature!
346
+     * Calculate GC content of a DNA sequence.
347
+     * Shamelessly ripped from kennypavan/BioPHP.
348
+     *
349
+     * @see https://github.com/kennypavan/BioPHP/blob/master/BioPHP.php
350
+     */
351
+    public function gcContent(string $Sequence, int $Precision = 2)
352
+    {
353
+        $Sequence = strtoupper($Sequence);
354
+        
355
+        $G = substr_count($Sequence, 'G');
356
+        $C = substr_count($Sequence, 'C');
357
+
358
+        return number_format((($G + $C) / strlen($Sequence)) * 100, $Precision);
359
+    }
360
+}

+ 0
- 1
gazelle.sql View File

@@ -1597,7 +1597,6 @@ CREATE TABLE `users_notify_filters` (
1597 1597
   `Media` varchar(500) NOT NULL DEFAULT '',
1598 1598
   `FromYear` int NOT NULL DEFAULT '0',
1599 1599
   `ToYear` int NOT NULL DEFAULT '0',
1600
-  `ExcludeVA` enum('1','0') NOT NULL DEFAULT '0',
1601 1600
   `NewGroupsOnly` enum('1','0') NOT NULL DEFAULT '0',
1602 1601
   `ReleaseTypes` varchar(500) NOT NULL DEFAULT '',
1603 1602
   PRIMARY KEY (`ID`),

+ 0
- 1
image.php View File

@@ -112,5 +112,4 @@ function image_height($Type, $Data)
112 112
   }
113 113
 }
114 114
 
115
-define('SKIP_NO_CACHE_HEADERS', 1);
116 115
 require_once 'classes/script_start.php'; // script_start.php contains all we need and includes sections/image/index.php

+ 1
- 1
rules.php View File

@@ -1,4 +1,4 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
-require 'classes/script_start.php';
4
+require_once 'classes/script_start.php';

+ 1
- 1
sections/ajax/torrent.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 #declare(strict_types=1);
3 3
 
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
4
+require_once SERVER_ROOT.'/sections/torrents/functions.php';
5 5
 
6 6
 $TorrentID = (int) $_GET['id'];
7 7
 $TorrentHash = (string) $_GET['hash'];

+ 1
- 1
sections/ajax/torrentgroup.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 #declare(strict_types=1);
3 3
 
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
4
+require_once SERVER_ROOT.'/sections/torrents/functions.php';
5 5
 
6 6
 $GroupID = (int) $_GET['id'];
7 7
 $TorrentHash = (string) $_GET['hash'];

+ 1
- 1
sections/ajax/torrentgroupalbumart.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
4
+require_once SERVER_ROOT.'/sections/torrents/functions.php';
5 5
 
6 6
 $GroupID = (int) $_GET['id'];
7 7
 if ($GroupID === 0) {

+ 1
- 1
sections/api/torrents/torrentgroupalbumart.php View File

@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 declare(strict_types=1);
3 3
 
4
-require SERVER_ROOT.'/sections/torrents/functions.php';
4
+require_once SERVER_ROOT.'/sections/torrents/functions.php';
5 5
 
6 6
 $GroupID = (int) $_GET['id'];
7 7
 if ($GroupID === 0) {

+ 31
- 92
sections/artist/download.php View File

@@ -1,4 +1,6 @@
1
-<?
1
+<?php
2
+#declare(strict_types = 1);
3
+
2 4
 // todo: Freeleech in ratio hit calculations, in addition to a warning of whats freeleech in the Summary.txt
3 5
 /*
4 6
 This page is something of a hack so those
@@ -23,28 +25,6 @@ fashion.
23 25
 Thats all you get for a disclaimer, just
24 26
 remember, this page isn't for the faint of
25 27
 heart. -A9
26
-
27
-SQL template:
28
-SELECT
29
-  CASE
30
-    WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
31
-      THEN 1
32
-    WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
33
-      THEN 2
34
-    ELSE 100
35
-  END AS Rank,
36
-  t.GroupID,
37
-  t.Media,
38
-  t.Format,
39
-  t.Encoding,
40
-  IF(t.Year = 0, tg.Year, t.Year),
41
-  tg.Name,
42
-  a.Name,
43
-  t.Size
44
-FROM torrents AS t
45
-  INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
46
-  INNER JOIN artists_group AS a ON a.ArtistID = tg.ArtistID AND a.ArtistID = '59721'
47
-ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
48 28
 */
49 29
 
50 30
 if (
@@ -55,11 +35,11 @@ if (
55 35
   || $_REQUEST['preference'] > 2
56 36
   || count($_REQUEST['list']) === 0
57 37
 ) {
58
-  error(0);
38
+    error(0);
59 39
 }
60 40
 
61 41
 if (!check_perms('zip_downloader')) {
62
-  error(403);
42
+    error(403);
63 43
 }
64 44
 
65 45
 $Preferences = array('RemasterTitle DESC', 'Seeders ASC', 'Size ASC');
@@ -78,52 +58,13 @@ $DB->query("
78 58
   FROM torrents_artists
79 59
   WHERE ArtistID = '$ArtistID'");
80 60
 if (!$DB->has_results()) {
81
-  error(404);
61
+    error(404);
82 62
 }
83 63
 $Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false);
84 64
 $GroupIDs = array_keys($Releases);
85 65
 
86
-$SQL = 'SELECT CASE ';
87
-
88
-foreach ($_REQUEST['list'] as $Priority => $Selection) {
89
-  if (!is_number($Priority)) {
90
-    continue;
91
-  }
92
-  $SQL .= 'WHEN ';
93
-  switch ($Selection) {
94
-    case '00': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V0 (VBR)'"; break;
95
-    case '01': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'APX (VBR)'"; break;
96
-    case '02': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '256 (VBR)'"; break;
97
-    case '03': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V1 (VBR)'"; break;
98
-    case '10': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '224 (VBR)'"; break;
99
-    case '11': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V2 (VBR)'"; break;
100
-    case '12': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'APS (VBR)'"; break;
101
-    case '13': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '192 (VBR)'"; break;
102
-    case '20': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '320'"; break;
103
-    case '21': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '256'"; break;
104
-    case '22': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '224'"; break;
105
-    case '23': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '192'"; break;
106
-    case '30': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'Vinyl'"; break;
107
-    case '31': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'DVD'"; break;
108
-    case '32': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'SACD'"; break;
109
-    case '33': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'WEB'"; break;
110
-    case '34': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100' AND HasCue = '1'"; break;
111
-    case '35': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100'"; break;
112
-    case '36': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1'"; break;
113
-    case '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
114
-    case '40': $SQL .= "t.Format = 'DTS'"; break;
115
-    case '42': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '320'"; break;
116
-    case '43': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '256'"; break;
117
-    case '44': $SQL .= "t.Format = 'AAC'  AND t.Encoding = 'q5.5'"; break;
118
-    case '45': $SQL .= "t.Format = 'AAC'  AND t.Encoding = 'q5'"; break;
119
-    case '46': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '192'"; break;
120
-    default: error(0);
121
-  }
122
-  $SQL .= " THEN $Priority ";
123
-}
124
-$SQL .= "
125
-    ELSE 100
126
-  END AS Rank,
66
+$SQL = "
67
+SELECT
127 68
   t.GroupID,
128 69
   t.ID AS TorrentID,
129 70
   t.Media,
@@ -135,38 +76,36 @@ $SQL .= "
135 76
   t.Size
136 77
 FROM torrents AS t
137 78
   JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1' AND tg.ID IN (".implode(',', $GroupIDs).")
138
-ORDER BY t.GroupID ASC, Rank DESC, t.$Preference";
79
+ORDER BY t.GroupID ASC, Rank DESC, t.$Preference
80
+";
139 81
 
140 82
 $DownloadsQ = $DB->query($SQL);
141 83
 $Collector = new TorrentsDL($DownloadsQ, $ArtistName);
142 84
 while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
143
-  $Artists = Artists::get_artists($GroupIDs);
144
-  $TorrentIDs = array_keys($GroupIDs);
145
-  foreach ($TorrentIDs as $TorrentID) {
146
-    $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
147
-    $GroupID = $GroupIDs[$TorrentID];
148
-    $Download =& $Downloads[$GroupID];
149
-    $Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
150
-    if ($Download['Rank'] == 100) {
151
-      $Collector->skip_file($Download);
152
-      continue;
153
-    }
154
-    if ($Releases[$GroupID]['Importance'] == 1) {
155
-      $ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']];
156
-    } elseif ($Releases[$GroupID]['Importance'] == 2) {
157
-      $ReleaseTypeName = 'Guest Appearance';
158
-    } elseif ($Releases[$GroupID]['Importance'] == 3) {
159
-      $ReleaseTypeName = 'Remixed By';
85
+    $Artists = Artists::get_artists($GroupIDs);
86
+    $TorrentIDs = array_keys($GroupIDs);
87
+    foreach ($TorrentIDs as $TorrentID) {
88
+        $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
89
+        $GroupID = $GroupIDs[$TorrentID];
90
+        $Download =& $Downloads[$GroupID];
91
+        $Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
92
+        if ($Download['Rank'] == 100) {
93
+            $Collector->skip_file($Download);
94
+            continue;
95
+        }
96
+        if ($Releases[$GroupID]['Importance'] == 1) {
97
+            $ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']];
98
+        } elseif ($Releases[$GroupID]['Importance'] == 2) {
99
+            $ReleaseTypeName = 'Guest Appearance';
100
+        } elseif ($Releases[$GroupID]['Importance'] == 3) {
101
+            $ReleaseTypeName = 'Remixed By';
102
+        }
103
+        $Collector->add_file($TorrentFile, $Download, $ReleaseTypeName);
104
+        unset($Download);
160 105
     }
161
-    $Collector->add_file($TorrentFile, $Download, $ReleaseTypeName);
162
-    unset($Download);
163
-  }
164 106
 }
165 107
 $Collector->finalize();
166 108
 $Settings = array(implode(':', $_REQUEST['list']), $_REQUEST['preference']);
167 109
 if (!isset($LoggedUser['Collector']) || $LoggedUser['Collector'] != $Settings) {
168
-  Users::update_site_options($LoggedUser['ID'], array('Collector' => $Settings));
110
+    Users::update_site_options($LoggedUser['ID'], array('Collector' => $Settings));
169 111
 }
170
-
171
-define('SKIP_NO_CACHE_HEADERS', 1);
172
-?>

+ 31
- 21
sections/better/covers.php View File

@@ -5,36 +5,46 @@ if (!empty($_GET['filter']) && $_GET['filter'] === 'all') {
5 5
     $Join = '';
6 6
     $All = true;
7 7
 } else {
8
-    $Join = 'JOIN torrents AS t ON t.GroupID=tg.ID
9
-           JOIN xbt_snatched AS x ON x.fid = t.ID AND x.uid = '.$LoggedUser['ID'];
8
+    $Join = "
9
+    JOIN `torrents` AS t
10
+    ON
11
+      t.`GroupID` = tg.`id`
12
+    JOIN `xbt_snatched` AS x
13
+    ON
14
+      x.`fid` = t.`ID` AND x.`uid` = $LoggedUser[ID]
15
+    ";
10 16
     $All = false;
11 17
 }
12 18
 
13
-View::show_header('Torrent groups with no covers');
14 19
 $DB->query("
15
-  SELECT
16
-    SQL_CALC_FOUND_ROWS
17
-    tg.ID
18
-  FROM torrents_group AS tg
19
-    $Join
20
-  WHERE tg.WikiImage=''
21
-  ORDER BY RAND()
22
-  LIMIT 20");
20
+SELECT SQL_CALC_FOUND_ROWS
21
+  tg.`id`
22
+FROM
23
+  `torrents_group` AS tg
24
+$Join
25
+WHERE
26
+  tg.`picture` = ''
27
+ORDER BY
28
+  RAND()
29
+LIMIT 20
30
+");
23 31
 
24
-$Groups = $DB->to_array('ID', MYSQLI_ASSOC);
32
+$Groups = $DB->to_array('id', MYSQLI_ASSOC);
25 33
 $DB->query('SELECT FOUND_ROWS()');
26 34
 list($NumResults) = $DB->next_record();
27 35
 $Results = Torrents::get_groups(array_keys($Groups));
36
+
37
+View::show_header('Torrent groups with no picture');
28 38
 ?>
29 39
 
30 40
 <div class="header">
31 41
   <?php if ($All) { ?>
32 42
   <h2>
33
-    All torrent groups with no cover
43
+    All torrent groups with no picture
34 44
   </h2>
35 45
   <?php } else { ?>
36 46
   <h2>
37
-    Torrent groups with no cover that you have snatched
47
+    Torrent groups with no picture that you have snatched
38 48
   </h2>
39 49
   <?php } ?>
40 50
 
@@ -57,21 +67,21 @@ $Results = Torrents::get_groups(array_keys($Groups));
57 67
     <?php
58 68
 foreach ($Results as $Result) {
59 69
     extract($Result);
60
-    $TorrentTags = new Tags($TagList);
70
+    $TorrentTags = new Tags($tag_list);
61 71
 
62
-    $DisplayName = "<a href='torrents.php?id=$ID' ";
72
+    $DisplayName = "<a href='torrents.php?id=$id' ";
63 73
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
64
-        $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
74
+        $DisplayName .= 'data-cover="'.ImageTools::process($picture, 'thumb').'" ';
65 75
     }
66 76
 
67
-    $DisplayName .= ">$Name</a>";
68
-    if ($Year > 0) {
69
-        $DisplayName .= " [$Year]";
77
+    $DisplayName .= ">$title</a>";
78
+    if ($published) {
79
+        $DisplayName .= " [$published]";
70 80
     } ?>
71 81
 
72 82
     <tr class="torrent">
73 83
       <td>
74
-        <div class="<?=Format::css_category($CategoryID)?>"></div>
84
+        <div class="<?=Format::css_category($category_id)?>"></div>
75 85
       </td>
76 86
 
77 87
       <td>

+ 44
- 96
sections/collages/download.php View File

@@ -1,4 +1,4 @@
1
-<?
1
+<?php
2 2
 /*
3 3
 This page is something of a hack so those
4 4
 easily scared off by funky solutions, don't
@@ -22,29 +22,6 @@ fashion.
22 22
 Thats all you get for a disclaimer, just
23 23
 remember, this page isn't for the faint of
24 24
 heart. -A9
25
-
26
-SQL template:
27
-SELECT
28
-  CASE
29
-    WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'
30
-      THEN 1
31
-    WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'
32
-      THEN 2
33
-    ELSE 100
34
-  END AS Rank,
35
-  t.GroupID,
36
-  t.Media,
37
-  t.Format,
38
-  t.Encoding,
39
-  IF(t.Year = 0, tg.Year, t.Year),
40
-  tg.Name,
41
-  a.Name,
42
-  t.Size
43
-FROM torrents AS t
44
-  INNER JOIN collages_torrents AS c ON t.GroupID = c.GroupID AND c.CollageID = '8'
45
-  INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
46
-  LEFT JOIN artists_group AS a ON a.ArtistID = tg.ArtistID
47
-ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC
48 25
 */
49 26
 
50 27
 if (
@@ -55,11 +32,11 @@ if (
55 32
   || $_REQUEST['preference'] > 2
56 33
   || count($_REQUEST['list']) === 0
57 34
 ) {
58
-  error(0);
35
+    error(0);
59 36
 }
60 37
 
61 38
 if (!check_perms('zip_downloader')) {
62
-  error(403);
39
+    error(403);
63 40
 }
64 41
 
65 42
 $Preferences = array('RemasterTitle DESC', 'Seeders ASC', 'Size ASC');
@@ -73,84 +50,55 @@ $DB->query("
73 50
   WHERE ID = '$CollageID'");
74 51
 list($CollageName) = $DB->next_record(MYSQLI_NUM, false);
75 52
 
76
-$SQL = 'SELECT CASE ';
77
-
78
-foreach ($_REQUEST['list'] as $Priority => $Selection) {
79
-  if (!is_number($Priority)) {
80
-    continue;
81
-  }
82
-  $SQL .= 'WHEN ';
83
-  switch ($Selection) {
84
-    case '00': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V0 (VBR)'"; break;
85
-    case '01': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'APX (VBR)'"; break;
86
-    case '02': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '256 (VBR)'"; break;
87
-    case '03': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V1 (VBR)'"; break;
88
-    case '10': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '224 (VBR)'"; break;
89
-    case '11': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'V2 (VBR)'"; break;
90
-    case '12': $SQL .= "t.Format = 'MP3'  AND t.Encoding = 'APS (VBR)'"; break;
91
-    case '13': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '192 (VBR)'"; break;
92
-    case '20': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '320'"; break;
93
-    case '21': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '256'"; break;
94
-    case '22': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '224'"; break;
95
-    case '23': $SQL .= "t.Format = 'MP3'  AND t.Encoding = '192'"; break;
96
-    case '30': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'Vinyl'"; break;
97
-    case '31': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'DVD'"; break;
98
-    case '32': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'SACD'"; break;
99
-    case '33': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'WEB'"; break;
100
-    case '34': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100' AND HasCue = '1'"; break;
101
-    case '35': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100'"; break;
102
-    case '36': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1'"; break;
103
-    case '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break;
104
-    case '40': $SQL .= "t.Format = 'DTS'"; break;
105
-    case '42': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '320'"; break;
106
-    case '43': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '256'"; break;
107
-    case '44': $SQL .= "t.Format = 'AAC'  AND t.Encoding = 'q5.5'"; break;
108
-    case '45': $SQL .= "t.Format = 'AAC'  AND t.Encoding = 'q5'"; break;
109
-    case '46': $SQL .= "t.Format = 'AAC'  AND t.Encoding = '192'"; break;
110
-    default: error(0);
111
-  }
112
-  $SQL .= " THEN $Priority ";
113
-}
114
-$SQL .= "
115
-    ELSE 100
116
-  END AS Rank,
117
-  t.GroupID,
118
-  t.ID AS TorrentID,
119
-  t.Media,
120
-  t.Format,
121
-  t.Encoding,
122
-  IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year,
123
-  tg.Name,
124
-  t.Size
125
-FROM torrents AS t
126
-  INNER JOIN collages_torrents AS c ON t.GroupID = c.GroupID AND c.CollageID = '$CollageID'
127
-  INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1'
128
-ORDER BY t.GroupID ASC, Rank DESC, t.$Preference";
53
+$SQL = "
54
+SELECT
55
+  t.`GroupID`,
56
+  t.`ID` AS `TorrentID`,
57
+  t.`Media`,
58
+  t.`Format`,
59
+  t.`Encoding`,
60
+  IF(
61
+    t.`RemasterYear` = 0,
62
+    tg.`published`,
63
+    t.`RemasterYear`
64
+  ) AS `Year`,
65
+  tg.`title`,
66
+  t.`Size`
67
+FROM
68
+  `torrents` AS t
69
+INNER JOIN `collages_torrents` AS c
70
+ON
71
+  t.`GroupID` = c.`GroupID` AND c.`CollageID` = '$CollageID'
72
+INNER JOIN `torrents_group` AS tg
73
+ON
74
+  tg.`id` = t.`GroupID` AND tg.`category_id` = '1'
75
+ORDER BY
76
+  t.`GroupID` ASC,
77
+  `Rank` DESC,
78
+  t.$Preference
79
+";
129 80
 
130 81
 $DownloadsQ = $DB->query($SQL);
131 82
 $Collector = new TorrentsDL($DownloadsQ, $CollageName);
132 83
 
133 84
 while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) {
134
-  $Artists = Artists::get_artists($GroupIDs);
135
-  $TorrentIDs = array_keys($GroupIDs);
136
-  foreach ($TorrentIDs as $TorrentID) {
137
-    file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
138
-    $GroupID = $GroupIDs[$TorrentID];
139
-    $Download =& $Downloads[$GroupID];
140
-    $Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
141
-    if ($Download['Rank'] == 100) {
142
-      $Collector->skip_file($Download);
143
-      continue;
85
+    $Artists = Artists::get_artists($GroupIDs);
86
+    $TorrentIDs = array_keys($GroupIDs);
87
+    foreach ($TorrentIDs as $TorrentID) {
88
+        file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
89
+        $GroupID = $GroupIDs[$TorrentID];
90
+        $Download =& $Downloads[$GroupID];
91
+        $Download['Artist'] = Artists::display_artists($Artists[$Download['GroupID']], false, true, false);
92
+        if ($Download['Rank'] == 100) {
93
+            $Collector->skip_file($Download);
94
+            continue;
95
+        }
96
+        $Collector->add_file($TorrentFile, $Download);
97
+        unset($Download);
144 98
     }
145
-    $Collector->add_file($TorrentFile, $Download);
146
-    unset($Download);
147
-  }
148 99
 }
149 100
 $Collector->finalize();
150 101
 $Settings = array(implode(':', $_REQUEST['list']), $_REQUEST['preference']);
151 102
 if (!isset($LoggedUser['Collector']) || $LoggedUser['Collector'] != $Settings) {
152
-  Users::update_site_options($LoggedUser['ID'], array('Collector' => $Settings));
103
+    Users::update_site_options($LoggedUser['ID'], array('Collector' => $Settings));
153 104
 }
154
-
155
-define('SKIP_NO_CACHE_HEADERS', 1);
156
-?>

+ 17
- 13
sections/schedule/daily/delete_dead_torrents.php View File

@@ -5,19 +5,23 @@
5 5
 //   (t.last_action < (NOW() - INTERVAL 28 DAY) AND t.last_action IS NOT NULL)
6 6
 
7 7
 $DB->query("
8
-  SELECT
9
-    t.ID,
10
-    t.GroupID,
11
-    tg.Name,
12
-    t.UserID,
13
-    t.Media,
14
-    HEX(t.info_hash) AS InfoHash
15
-  FROM torrents AS t
16
-    JOIN torrents_group AS tg ON tg.ID = t.GroupID
17
-  WHERE
18
-    (t.last_action < (NOW() - INTERVAL 365 DAY) AND t.last_action IS NOT NULL)
19
-    OR
20
-    (t.Time < (NOW() - INTERVAL 2 DAY) AND t.last_action IS NULL)");
8
+SELECT
9
+  t.`ID`,
10
+  t.`GroupID`,
11
+  tg.`title`,
12
+  t.`UserID`,
13
+  t.`Media`,
14
+  HEX(t.`info_hash`) AS InfoHash
15
+FROM
16
+  `torrents` AS t
17
+JOIN `torrents_group` AS tg
18
+ON
19
+  tg.`id` = t.`GroupID`
20
+WHERE
21
+  (t.`last_action` <(NOW() - INTERVAL 365 DAY) AND t.`last_action` IS NOT NULL)
22
+OR
23
+  (t.`Time` <(NOW() - INTERVAL 3 DAY) AND t.`last_action` IS NULL)
24
+");
21 25
 
22 26
 $Torrents = $DB->to_array(false, MYSQLI_NUM, false);
23 27
 echo 'Found '.count($Torrents)." inactive torrents to be deleted.\n";

+ 1
- 1
sections/tools/data/database_specifics.php View File

@@ -26,7 +26,7 @@ if (!$Tables = $Cache->get_value('database_table_stats')) {
26 26
 }
27 27
 
28 28
 # todo: Remove Google Charts dependency
29
-require SERVER_ROOT.'/classes/charts.class.php';
29
+require_once SERVER_ROOT.'/classes/charts.class.php';
30 30
 $Pie = new PIE_CHART(750, 400, array('Other'=>1,'Percentage'=>1,'Sort'=>1));
31 31
 
32 32
 // Begin sorting

+ 0
- 1
sections/torrents/download.php View File

@@ -211,4 +211,3 @@ $UserAnnounceList = (sizeof(ANNOUNCE_URLS[0]) === 1 && sizeof(ANNOUNCE_URLS[0][0
211 211
 #$UserAnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map("add_passkey", ANNOUNCE_URLS);
212 212
 
213 213
 echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList);
214
-define('SKIP_NO_CACHE_HEADERS', 1);

+ 4
- 4
sections/torrents/editgroup.php View File

@@ -8,7 +8,7 @@ declare(strict_types = 1);
8 8
  * and clears the cache for the torrent group page.
9 9
  */
10 10
 
11
-$GroupID = $_GET['groupid'];
11
+$GroupID = (int) $_GET['groupid'];
12 12
 Security::checkInt($GroupID);
13 13
 
14 14
 // Get the torrent group name and the body of the last revision
@@ -21,8 +21,8 @@ SELECT
21 21
   wt.`Body`,
22 22
   tg.`picture`,
23 23
   tg.`description`,
24
-  tg.`year`,
25
-  tg.`labratory`,
24
+  tg.`published`,
25
+  tg.`workgroup`,
26 26
   tg.`location`,
27 27
   tg.`identifier`,
28 28
   tg.`category_id`
@@ -39,7 +39,7 @@ $DB->exec_prepared_query();
39 39
 if (!$DB->has_results()) {
40 40
     error(404);
41 41
 }
42
-list($Name, $Title2, $NameJP, $Image, $Body, $WikiImage, $WikiBody, $Year, $Studio, $Series, $CatalogueNumber, $CategoryID) = $DB->next_record();
42
+list($title, $subject, $object, $Image, $Body, $picture, $description, $published, $workgroup, $location, $identifier, $category_id) = $DB->next_record();
43 43
 
44 44
 $DB->prepare_query("
45 45
 SELECT

+ 0
- 2
sections/torrents/redownload.php View File

@@ -84,5 +84,3 @@ while (list($Downloads, $GroupIDs) = $Collector->get_downloads('TorrentID')) {
84 84
     }
85 85
 }
86 86
 $Collector->finalize(false);
87
-
88
-define('SKIP_NO_CACHE_HEADERS', 1);

+ 14
- 14
sections/torrents/takedelete.php View File

@@ -1,15 +1,15 @@
1
-<?
1
+<?php
2 2
 #declare(strict_types = 1);
3 3
 
4 4
 authorize();
5 5
 
6 6
 $TorrentID = $_POST['torrentid'];
7 7
 if (!$TorrentID || !is_number($TorrentID)) {
8
-  error(404);
8
+    error(404);
9 9
 }
10 10
 
11 11
 if ($Cache->get_value("torrent_{$TorrentID}_lock")) {
12
-  error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
12
+    error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
13 13
 }
14 14
 
15 15
 $DB->query("
@@ -31,28 +31,28 @@ $DB->query("
31 31
 list($UploaderID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
32 32
 
33 33
 if ($LoggedUser['ID'] != $UploaderID && !check_perms('torrents_delete')) {
34
-  error(403);
34
+    error(403);
35 35
 }
36 36
 
37 37
 if (time_ago($Time) > 3600 * 24 * 7 && !check_perms('torrents_delete')) {
38
-  error('Torrent cannot be deleted because it is over one week old. If you think there is a problem, contact staff.');
38
+    error('Torrent cannot be deleted because it is over one week old. If you think there is a problem, contact staff.');
39 39
 }
40 40
 
41 41
 if ($Snatches > 4 && !check_perms('torrents_delete')) {
42
-  error('Torrent cannot be deleted because it has been snatched by more than 4 people. If you think there is a problem, contact staff.');
42
+    error('Torrent cannot be deleted because it has been snatched by more than 4 people. If you think there is a problem, contact staff.');
43 43
 }
44 44
 
45 45
 if ($ArtistName) {
46
-  $Name = "$ArtistName - $Name";
46
+    $Name = "$ArtistName - $Name";
47 47
 }
48 48
 
49 49
 if (isset($_SESSION['logged_user']['multi_delete'])) {
50
-  if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
51
-    error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
52
-  }
53
-  $_SESSION['logged_user']['multi_delete']++;
50
+    if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
51
+        error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
52
+    }
53
+    $_SESSION['logged_user']['multi_delete']++;
54 54
 } else {
55
-  $_SESSION['logged_user']['multi_delete'] = 1;
55
+    $_SESSION['logged_user']['multi_delete'] = 1;
56 56
 }
57 57
 
58 58
 $InfoHash = unpack('H*', $InfoHash);
@@ -65,5 +65,5 @@ View::show_header('Torrent deleted');
65 65
 <div>
66 66
   <h3>Torrent was successfully deleted.</h3>
67 67
 </div>
68
-<?
69
-View::show_footer();
68
+
69
+<?php View::show_footer();

+ 26
- 21
sections/torrents/takegroupedit.php View File

@@ -1,30 +1,32 @@
1 1
 <?php
2 2
 #declare(strict_types = 1);
3 3
 
4
-authorize();
4
+/**
5
+ * Input validation
6
+ */
5 7
 
6
-// Quick SQL injection check
7
-if (!$_REQUEST['groupid'] || !is_number($_REQUEST['groupid'])) {
8
-    error(404);
9
-}
8
+# User permissions
9
+authorize();
10 10
 
11 11
 if (!check_perms('site_edit_wiki')) {
12 12
     error(403);
13 13
 }
14 14
 
15
-// Variables for database input
16
-$UserID = $LoggedUser['ID'];
17
-$GroupID = $_REQUEST['groupid'];
15
+# Variables for database input
16
+$UserID = (int) $LoggedUser['ID'];
17
+$GroupID = (int) $_REQUEST['groupid'];
18 18
 
19
-if (!empty($_GET['action']) && $_GET['action'] === 'revert') { // if we're reverting to a previous revision
20
-    $RevisionID = $_GET['revisionid'];
21
-    if (!is_number($RevisionID)) {
22
-        error(400);
23
-    }
19
+Security::checkInt([$UserID, $GroupID]);
20
+
21
+# If we're reverting to a previous revision
22
+if (!empty($_GET['action']) && $_GET['action'] === 'revert') {
23
+    $RevisionID = (int) $_GET['revisionid'];
24
+    Security::checkInt($RevisionID);
24 25
 
25
-    // To cite from merge: "Everything is legit, let's just confim they're not retarded"
26
+    # To cite from merge: "Everything is legit, let's just confim they're not retarded"
26 27
     if (empty($_GET['confirm'])) {
27
-        View::show_header(); ?>
28
+        View::show_header();
29
+    } ?>
28 30
 
29 31
 <!-- Start HTML -->
30 32
 <div class="center">
@@ -104,12 +106,15 @@ $Image = db_string($Image);
104 106
 
105 107
 // Update torrents table (technically, we don't need the RevisionID column, but we can use it for a join which is nice and fast)
106 108
 $DB->query("
107
-  UPDATE torrents_group
108
-  SET
109
-    RevisionID = '$RevisionID',
110
-    WikiBody = '$Body',
111
-    WikiImage = '$Image'
112
-  WHERE ID='$GroupID'");
109
+UPDATE
110
+  `torrents_group`
111
+SET
112
+  `revision_id` = '$RevisionID',
113
+  `description` = '$Body',
114
+  `picture` = '$Image'
115
+WHERE
116
+  `id` = '$GroupID'
117
+");
113 118
 
114 119
 // There we go, all done!
115 120
 

+ 6
- 33
sections/torrents/user.php View File

@@ -49,10 +49,6 @@ $SearchWhere = [];
49 49
 if (!empty($_GET['format'])) {
50 50
     if (in_array($_GET['format'], $Formats)) {
51 51
         $SearchWhere[] = "t.Format = '".db_string($_GET['format'])."'";
52
-        /*
53
-        } elseif ($_GET['format'] === 'perfectflac') {
54
-            $_GET['filter'] = 'perfectflac';
55
-        */
56 52
     }
57 53
 }
58 54
 
@@ -227,32 +223,6 @@ switch ($_GET['type']) {
227 223
     error(404);
228 224
 }
229 225
 
230
-/*
231
-if (!empty($_GET['filter'])) {
232
-    if ($_GET['filter'] === 'perfectflac') {
233
-        if (!check_paranoia('perfectflacs', $User['Paranoia'], $UserClass, $UserID)) {
234
-            error(403);
235
-        }
236
-        $ExtraWhere .= " AND t.Format = 'FLAC'";
237
-        if (empty($_GET['media'])) {
238
-            $ExtraWhere .= "
239
-        AND (
240
-          t.LogScore = 100 OR
241
-          t.Media IN ('Vinyl', 'WEB', 'DVD', 'Soundboard', 'Cassette', 'SACD', 'Blu-ray', 'DAT')
242
-          )";
243
-        } elseif (strtoupper($_GET['media']) === 'CD' && empty($_GET['log'])) {
244
-            $ExtraWhere .= "
245
-        AND t.LogScore = 100";
246
-        }
247
-    } elseif ($_GET['filter'] === 'uniquegroup') {
248
-        if (!check_paranoia('uniquegroups', $User['Paranoia'], $UserClass, $UserID)) {
249
-            error(403);
250
-        }
251
-        $GroupBy = 'tg.ID';
252
-    }
253
-}
254
-*/
255
-
256 226
 if (empty($GroupBy)) {
257 227
     $GroupBy = 't.ID';
258 228
 }
@@ -534,15 +504,18 @@ foreach ($Categories as $CatKey => $CatName) {
534 504
         </td>
535 505
 
536 506
         <td class="sign snatches">
537
-          <a href="<?= header_link('Snatched') ?>">↻</a>
507
+          <a
508
+            href="<?= header_link('Snatched') ?>">↻</a>
538 509
         </td>
539 510
 
540 511
         <td class="sign seeders">
541
-          <a href="<?= header_link('Seeders') ?>">&uarr;</a>
512
+          <a
513
+            href="<?= header_link('Seeders') ?>">&uarr;</a>
542 514
         </td>
543 515
 
544 516
         <td class="sign leechers">
545
-          <a href="<?= header_link('Leechers') ?>">&darr;</a>
517
+          <a
518
+            href="<?= header_link('Leechers') ?>">&darr;</a>
546 519
         </td>
547 520
       </tr>
548 521
 

+ 196
- 243
sections/upload/upload_handle.php View File

@@ -1,31 +1,34 @@
1 1
 <?php
2 2
 #declare(strict_types=1);
3 3
 
4
-//****************************************************************************//
5
-//--------------- Take upload ------------------------------------------------//
6
-// This pages handles the backend of the torrent upload function. It checks   //
7
-// the data, and if it all validates, it builds the torrent file, then writes //
8
-// the data to the database and the torrent to the disk.                      //
9
-//****************************************************************************//
4
+/**
5
+ * Take upload
6
+ *
7
+ * This pages handles the backend of the torrent upload function.
8
+ * It checks the data, and if it all validates, it builds the torrent file,
9
+ * then writes the data to the database and the torrent to the disk.
10
+ */
11
+
12
+$ENV = ENV::go();
13
+$Feed = new Feed;
14
+$Validate = new Validate;
10 15
 
11
-include SERVER_ROOT.'/classes/validate.class.php';
12
-include SERVER_ROOT.'/classes/feed.class.php';
13
-include SERVER_ROOT.'/sections/torrents/functions.php';
16
+require_once "$ENV->SERVER_ROOT/classes/feed.class.php";
17
+require_once "$ENV->SERVER_ROOT/classes/validate.class.php";
18
+require_once "$ENV->SERVER_ROOT/sections/torrents/functions.php";
14 19
 
15 20
 enforce_login();
16 21
 authorize();
17 22
 
18
-$ENV = ENV::go();
19
-$Validate = new Validate;
20
-$Feed = new Feed;
21
-
22 23
 
23
-//*****************************************************************************//
24
-//--------------- Set $Properties array ---------------------------------------//
25
-// This is used if the form doesn't validate, and when the time comes to enter //
26
-// it into the database.
27
-// todo: Do something about this mess
28
-//****************************************************************************//
24
+/**
25
+ * Set $Properties array
26
+ *
27
+ * This is used if the form doesn't validate,
28
+ * and when the time comes to enter it into the database.
29
+ *
30
+ * todo: Do something about this mess
31
+ */
29 32
 
30 33
 $Properties = [];
31 34
 $Type = $Categories[(int) $_POST['type']];
@@ -102,8 +105,10 @@ if (!empty($_POST['requestid'])) {
102 105
     $Properties['RequestID'] = $RequestID;
103 106
 }
104 107
 
105
-//******************************************************************************//
106
-//--------------- Validate data in upload form ---------------------------------//
108
+
109
+/**
110
+ * Validate data in upload form
111
+ */
107 112
 
108 113
 # Submit button
109 114
 $Validate->SetFields(
@@ -114,7 +119,7 @@ $Validate->SetFields(
114 119
     array('inarray' => array_keys($Categories))
115 120
 );
116 121
 
117
-# torrents_group.CategoryID
122
+# torrents_group.category_id
118 123
 $Validate->SetFields(
119 124
     'type',
120 125
     '1',
@@ -123,182 +128,154 @@ $Validate->SetFields(
123 128
     array('inarray' => array_keys($Categories))
124 129
 );
125 130
 
126
-# todo: Remove the switch statement
127
-switch ($Type) {
128
-    /*
129
-  case 'Imaging':
130
-    if (!isset($_POST['groupid']) || !$_POST['groupid']) {
131
-        # torrents.Media
132
-        $Validate->SetFields(
133
-            'media',
134
-            '1',
135
-            'inarray',
136
-            'Please select a valid platform.',
137
-            array('inarray' => array_merge($Media, $MediaManga, $Platform))
138
-        );
139
-
140
-        # torrents.Container
141
-        $Validate->SetFields(
142
-            'container',
143
-            '1',
144
-            'inarray',
145
-            'Please select a valid format.',
146
-            array('inarray' => array_merge($Containers, $ContainersGames))
147
-        );
148
-    }
149
-break;
150
-*/
131
+if (!$_POST['groupid']) {
132
+    # torrents_group.CatalogueNumber
133
+    $Validate->SetFields(
134
+        'catalogue',
135
+        '0',
136
+        'string',
137
+        'Accession Number must be between 0 and 50 characters.',
138
+        array('maxlength' => 50, 'minlength' => 0)
139
+    );
151 140
 
152
-default:
153
-    if (!isset($_POST['groupid']) || !$_POST['groupid']) {
154
-        # torrents_group.CatalogueNumber
155
-        $Validate->SetFields(
156
-            'catalogue',
157
-            '0',
158
-            'string',
159
-            'Accession Number must be between 0 and 50 characters.',
160
-            array('maxlength' => 50, 'minlength' => 0)
161
-        );
162
-
163
-        # torrents.Version
164
-        $Validate->SetFields(
165
-            'version',
166
-            '0',
167
-            'string',
168
-            'Version must be between 0 and 10 characters.',
169
-            array('maxlength' => 10, 'minlength' => 0)
170
-        );
171
-        
172
-        # torrents_group.Name
173
-        $Validate->SetFields(
174
-            'title',
175
-            '1',
176
-            'string',
177
-            'Torrent Title must be between 10 and 255 characters.',
178
-            array('maxlength' => 255, 'minlength' => 10)
179
-        );
180
-
181
-        # torrents_group.Title2
182
-        $Validate->SetFields(
183
-            'title_rj',
184
-            '0',
185
-            'string',
186
-            'Organism must be between 0 and 255 characters.',
187
-            array('maxlength' => 255, 'minlength' => 0)
188
-        );
189
-
190
-        # torrents_group.NameJP
191
-        $Validate->SetFields(
192
-            'title_jp',
193
-            '0',
194
-            'string',
195
-            'Strain/Variety must be between 0 and 255 characters.',
196
-            array('maxlength' => 255, 'minlength' => 0)
197
-        );
198
-
199
-        # torrents_group.Studio
200
-        $Validate->SetFields(
201
-            'studio',
202
-            '1',
203
-            'string',
204
-            'Department/Lab must be between 0 and 100 characters.',
205
-            array('maxlength' => 100, 'minlength' => 0)
206
-        );
207
-
208
-        # torrents_group.Series
209
-        $Validate->SetFields(
210
-            'series',
211
-            '0',
212
-            'string',
213
-            'Location must be between 0 and 100 characters.',
214
-            array('maxlength' => 100, 'minlength' => 0)
215
-        );
216
-
217
-        /* todo: Fix the year validation
218
-        # torrents_group.Year
219
-        $Validate->SetFields(
220
-            'year',
221
-            '1',
222
-            'number',
223
-            'The year of the original release must be entered.',
224
-            array('maxlength' => 4, 'minlength' => 4)
225
-        );
226
-        */
227
-
228
-        # torrents.Media
229
-        $Validate->SetFields(
230
-            'media',
231
-            '1',
232
-            'inarray',
233
-            'Please select a valid platform.',
234
-            array('inarray' => array_merge(
235
-                $SeqPlatforms,
236
-                $GraphPlatforms,
237
-                $ImgPlatforms,
238
-                $DocPlatforms,
239
-                $RawPlatforms
240
-            ))
241
-        );
242
-
243
-        /*
244
-        # torrents.Container
245
-        $Validate->SetFields(
246
-            'container',
247
-            '1',
248
-            'inarray',
249
-            'Please select a valid format.',
250
-            array('inarray' => array_merge($Containers, $ContainersGames))
251
-        );
252
-        */
253
-
254
-        # torrents.Resolution
255
-        $Validate->SetFields(
256
-            'resolution',
257
-            '1',
258
-            'string',
259
-            'Scope must be between 4 and 20 characters.',
260
-            array('maxlength' => 20, 'minlength' => 4)
261
-        );
141
+    # torrents.Version
142
+    $Validate->SetFields(
143
+        'version',
144
+        '0',
145
+        'string',
146
+        'Version must be between 0 and 10 characters.',
147
+        array('maxlength' => 10, 'minlength' => 0)
148
+    );
262 149
         
263
-        # torrents_group.TagList
264
-        $Validate->SetFields(
265
-            'tags',
266
-            '1',
267
-            'string',
268
-            'You must enter at least five tags. Maximum length is 500 characters.',
269
-            array('maxlength' => 500, 'minlength' => 10)
270
-        );
271
-
272
-        # torrents_group.WikiImage
273
-        $Validate->SetFields(
274
-            'image',
275
-            '0',
276
-            'link',
277
-            'The image URL you entered was invalid.',
278
-            array('maxlength' => 255, 'minlength' => 10) # x.yz/a.bc
279
-        );
280
-    }
150
+    # torrents_group.title
151
+    $Validate->SetFields(
152
+        'title',
153
+        '1',
154
+        'string',
155
+        'Torrent Title must be between 10 and 255 characters.',
156
+        array('maxlength' => 255, 'minlength' => 10)
157
+    );
158
+
159
+    # torrents_group.subject
160
+    $Validate->SetFields(
161
+        'title_rj',
162
+        '0',
163
+        'string',
164
+        'Organism must be between 0 and 255 characters.',
165
+        array('maxlength' => 255, 'minlength' => 0)
166
+    );
167
+
168
+    # torrents_group.object
169
+    $Validate->SetFields(
170
+        'title_jp',
171
+        '0',
172
+        'string',
173
+        'Strain/Variety must be between 0 and 255 characters.',
174
+        array('maxlength' => 255, 'minlength' => 0)
175
+    );
281 176
 
282
-    # torrents_group.WikiBody
177
+    # torrents_group.workgroup
283 178
     $Validate->SetFields(
284
-        'album_desc',
179
+        'studio',
285 180
         '1',
286 181
         'string',
287
-        'The description must be between 100 and 65535 characters.',
288
-        array('maxlength' => 65535, 'minlength' => 100)
182
+        'Department/Lab must be between 0 and 100 characters.',
183
+        array('maxlength' => 100, 'minlength' => 0)
289 184
     );
290 185
 
291
-    /* todo: Fix the Group ID validation
292
-    # torrents_group.ID
186
+    # torrents_group.location
293 187
     $Validate->SetFields(
294
-        'groupid',
188
+        'series',
295 189
         '0',
190
+        'string',
191
+        'Location must be between 0 and 100 characters.',
192
+        array('maxlength' => 100, 'minlength' => 0)
193
+    );
194
+
195
+    /* todo: Fix the year validation
196
+    # torrents_group.published
197
+    $Validate->SetFields(
198
+        'year',
199
+        '1',
296 200
         'number',
297
-        'Group ID was not numeric.'
201
+        'The year of the original release must be entered.',
202
+        array('maxlength' => 4, 'minlength' => 4)
203
+    );
204
+    */
205
+
206
+    # torrents.Media
207
+    $Validate->SetFields(
208
+        'media',
209
+        '1',
210
+        'inarray',
211
+        'Please select a valid platform.',
212
+        array('inarray' => array_merge(
213
+            $SeqPlatforms,
214
+            $GraphPlatforms,
215
+            $ImgPlatforms,
216
+            $DocPlatforms,
217
+            $RawPlatforms
218
+        ))
219
+    );
220
+
221
+    /*
222
+    # torrents.Container
223
+    $Validate->SetFields(
224
+        'container',
225
+        '1',
226
+        'inarray',
227
+        'Please select a valid format.',
228
+        array('inarray' => array_merge($Containers, $ContainersGames))
298 229
     );
299 230
     */
231
+
232
+    # torrents.Resolution
233
+    $Validate->SetFields(
234
+        'resolution',
235
+        '1',
236
+        'string',
237
+        'Scope must be between 4 and 20 characters.',
238
+        array('maxlength' => 20, 'minlength' => 4)
239
+    );
240
+        
241
+    # torrents_group.tag_list
242
+    $Validate->SetFields(
243
+        'tags',
244
+        '1',
245
+        'string',
246
+        'You must enter at least five tags. Maximum length is 500 characters.',
247
+        array('maxlength' => 500, 'minlength' => 10)
248
+    );
249
+
250
+    # torrents_group.picture
251
+    $Validate->SetFields(
252
+        'image',
253
+        '0',
254
+        'link',
255
+        'The image URL you entered was invalid.',
256
+        array('maxlength' => 255, 'minlength' => 10) # x.yz/a.bc
257
+    );
300 258
 }
301 259
 
260
+# torrents_group.description
261
+$Validate->SetFields(
262
+    'album_desc',
263
+    '1',
264
+    'string',
265
+    'The description must be between 100 and 65535 characters.',
266
+    array('maxlength' => 65535, 'minlength' => 100)
267
+);
268
+
269
+/* todo: Fix the Group ID validation
270
+# torrents_group.id
271
+$Validate->SetFields(
272
+    'groupid',
273
+    '0',
274
+    'number',
275
+    'Group ID was not numeric.'
276
+);
277
+*/
278
+
302 279
 $Err = $Validate->ValidateForm($_POST); // Validate the form
303 280
 
304 281
 # todo: Move all this validation code to the Validate class
@@ -351,20 +328,25 @@ if (empty($Properties['GroupID']) && empty($ArtistForm)) {
351 328
 
352 329
 if ($Err) { // Show the upload form, with the data the user entered
353 330
     $UploadForm = $Type;
354
-    include SERVER_ROOT.'/sections/upload/upload.php' ;
331
+    require_once SERVER_ROOT.'/sections/upload/upload.php' ;
355 332
     error(400, $NoHTML = true);
356 333
 }
357 334
 
358 335
 ImageTools::blacklisted($Properties['Image']);
359 336
 
360
-//******************************************************************************//
361
-//--------------- Make variables ready for database input ----------------------//
362 337
 
363
-// Prepared SQL statements do this for us, so there is nothing to do here anymore
338
+/**
339
+ * Make variables ready for database input
340
+ *
341
+ * Prepared SQL statements do this for us,
342
+ * so there is nothing to do here anymore.
343
+ */
364 344
 $T = $Properties;
365 345
 
366
-//******************************************************************************//
367
-//--------------- Generate torrent file ----------------------------------------//
346
+
347
+/**
348
+ * Generate torrent file
349
+ */
368 350
 
369 351
 $Tor = new BencodeTorrent($TorrentName, true);
370 352
 $PublicTorrent = $Tor->make_private(); // The torrent is now private
@@ -451,16 +433,19 @@ if (!preg_match('/^'.IMAGE_REGEX.'$/i', $T['Image'])) {
451 433
 // Does it belong in a group?
452 434
 if ($T['GroupID']) {
453 435
     $DB->query("
454
-      SELECT
455
-        ID,
456
-        WikiImage,
457
-        WikiBody,
458
-        RevisionID,
459
-        Name,
460
-        Year,
461
-        TagList
462
-      FROM torrents_group
463
-        WHERE id = ?", $T['GroupID']);
436
+    SELECT
437
+      `id`,
438
+      `picture`,
439
+      `description`,
440
+      `revision_id`,
441
+      `title`,
442
+      `published`,
443
+      `tag_list`
444
+    FROM
445
+      `torrents_group`
446
+    WHERE
447
+      `id` = $T[GroupID]
448
+    ");
464 449
 
465 450
     if ($DB->has_results()) {
466 451
         // Don't escape tg.Name. It's written directly to the log table
@@ -835,11 +820,12 @@ if (trim($T['Image']) !== '') {
835 820
     }
836 821
 }
837 822
 
838
-//******************************************************************************//
839
-//------------------------------- Post-processing ------------------------------//
840
-/* Because tracker updates and notifications can be slow, we're
841
- * redirecting the user to the destination page and flushing the buffers
842
- * to make it seem like the PHP process is working in the background.
823
+
824
+/**
825
+ * Post-processing
826
+ *
827
+ * Because tracker updates and notifications can be slow, we're redirecting the user to the destination page
828
+ * and flushing the buffers to make it seem like the PHP process is working in the background.
843 829
  */
844 830
 
845 831
 if ($PublicTorrent) {
@@ -879,8 +865,10 @@ if (function_exists('fastcgi_finish_request')) {
879 865
     ob_start(); // So we don't keep sending data to the client
880 866
 }
881 867
 
882
-//******************************************************************************//
883
-//--------------------------- IRC announce and feeds ---------------------------//
868
+
869
+/**
870
+ * IRC announce and feeds
871
+ */
884 872
 
885 873
 $Announce = '';
886 874
 
@@ -978,31 +966,13 @@ if (!empty($ArtistsUnescaped)) {
978 966
         $ArtistNameList[] = "Artists LIKE '%|".db_string(str_replace('\\', '\\\\', $Artist['name']), true)."|%'";
979 967
     }
980 968
 
981
-    // Don't add notification if >2 main artists or if tracked artist isn't a main artist
982
-    /*
983
-    if (count($ArtistNameList) > 2 || $Artist['name'] === 'Various Artists') {
984
-        $SQL .= " AND (ExcludeVA = '0' AND (";
985
-        $SQL .= implode(' OR ', array_merge($ArtistNameList, $GuestArtistNameList));
986
-        $SQL .= " OR Artists = '')) AND (";
987
-    } else {
988
-    */
989
-
990 969
     $SQL .= " AND (";
991 970
 
992
-    /*
993
-    if (!empty($GuestArtistNameList)) {
994
-        $SQL .= "(ExcludeVA = '0' AND (";
995
-        $SQL .= implode(' OR ', $GuestArtistNameList);
996
-        $SQL .= ')) OR ';
997
-    }
998
-    */
999
-
1000 971
     if (count($ArtistNameList) > 0) {
1001 972
         $SQL .= implode(' OR ', $ArtistNameList);
1002 973
         $SQL .= " OR ";
1003 974
     }
1004 975
     $SQL .= "Artists = '') AND (";
1005
-#}
1006 976
 } else {
1007 977
     $SQL .= "AND (Artists = '') AND (";
1008 978
 }
@@ -1022,13 +992,6 @@ $SQL .= implode(' OR ', $TagSQL);
1022 992
 $SQL .= ") AND !(".implode(' OR ', $NotTagSQL).')';
1023 993
 $SQL .= " AND (Categories LIKE '%|".db_string(trim($Type))."|%' OR Categories = '') ";
1024 994
 
1025
-/*
1026
-if ($T['ReleaseType']) {
1027
-    $SQL .= " AND (ReleaseTypes LIKE '%|".db_string(trim($ReleaseTypes[$T['ReleaseType']]))."|%' OR ReleaseTypes = '') ";
1028
-} else {
1029
-    $SQL .= " AND (ReleaseTypes = '') ";
1030
-}
1031
-*/
1032 995
 
1033 996
 /*
1034 997
   Notify based on the following:
@@ -1036,25 +999,17 @@ if ($T['ReleaseType']) {
1036 999
     2. If they set NewGroupsOnly to 1, it must also be the first torrent in the group to match the formatbitrate filter on the notification
1037 1000
 */
1038 1001
 
1039
-/*
1040 1002
 if ($T['Format']) {
1041 1003
     $SQL .= " AND (Formats LIKE '%|".db_string(trim($T['Format']))."|%' OR Formats = '') ";
1042 1004
 } else {
1043 1005
     $SQL .= " AND (Formats = '') ";
1044 1006
 }
1045 1007
 
1046
-if ($_POST['bitrate']) {
1047
-    $SQL .= " AND (Encodings LIKE '%|".db_string(trim($_POST['bitrate']))."|%' OR Encodings = '') ";
1048
-} else {
1049
-    $SQL .= " AND (Encodings = '') ";
1050
-}
1051
-
1052 1008
 if ($T['Media']) {
1053 1009
     $SQL .= " AND (Media LIKE '%|".db_string(trim($T['Media']))."|%' OR Media = '') ";
1054 1010
 } else {
1055 1011
     $SQL .= " AND (Media = '') ";
1056 1012
 }
1057
-*/
1058 1013
 
1059 1014
 // Either they aren't using NewGroupsOnly
1060 1015
 $SQL .= "AND ((NewGroupsOnly = '0' ";
@@ -1062,14 +1017,12 @@ $SQL .= "AND ((NewGroupsOnly = '0' ";
1062 1017
 $SQL .= ") OR ( NewGroupsOnly = '1' ";
1063 1018
 $SQL .= '))';
1064 1019
 
1065
-/*
1066 1020
 if ($T['Year']) {
1067 1021
     $SQL .= " AND (('".db_string(trim($T['Year']))."' BETWEEN FromYear AND ToYear)
1068 1022
       OR (FromYear = 0 AND ToYear = 0)) ";
1069 1023
 } else {
1070 1024
     $SQL .= " AND (FromYear = 0 AND ToYear = 0) ";
1071 1025
 }
1072
-*/
1073 1026
 
1074 1027
 $SQL .= " AND UserID != '".$LoggedUser['ID']."' ";
1075 1028
 
@@ -1145,9 +1098,9 @@ $Feed->populate('torrents_all', $Item);
1145 1098
 $Feed->populate('torrents_'.strtolower($Type), $Item);
1146 1099
 $Debug->set_flag('upload: notifications handled');
1147 1100
 
1148
-// Clear cache
1101
+# Clear cache
1149 1102
 $Cache->delete_value("torrents_details_$GroupID");
1150 1103
 $Cache->delete_value("contest_scores");
1151 1104
 
1152
-// Allow deletion of this torrent now
1105
+# Allow deletion of this torrent now
1153 1106
 $Cache->delete_value("torrent_{$TorrentID}_lock");

+ 0
- 11
sections/user/notify_edit.php View File

@@ -24,7 +24,6 @@ $DB->query("
24 24
     ID,
25 25
     Label,
26 26
     Artists,
27
-    ExcludeVA,
28 27
     NewGroupsOnly,
29 28
     Tags,
30 29
     NotTags,
@@ -46,7 +45,6 @@ $Notifications[] = array(
46 45
   'ID' => false,
47 46
   'Label' => '',
48 47
   'Artists' => '',
49
-  'ExcludeVA' => false,
50 48
   'NewGroupsOnly' => true,
51 49
   'Tags' => '',
52 50
   'NotTags' => '',
@@ -148,15 +146,6 @@ foreach ($Notifications as $N) { // $N stands for Notifications
148 146
           <textarea name="artists<?=$i?>" style="width: 100%;"
149 147
             rows="5"><?=display_str($N['Artists'])?></textarea>
150 148
           Comma-separated list, e.g., Yumeno Aika, Pink Pineapple
151
-          <!--
152
-          <input type="checkbox" name="excludeva<?=$i?>"
153
-          id="excludeva_<?=$N['ID']?>" <?php if ($N['ExcludeVA'] === '1') {
154
-        echo ' checked="checked"';
155
-    } ?>>
156
-          <label
157
-            for="excludeva_<?=$N['ID']?>">Exclude
158
-            Various Artists releases</label>
159
-          -->
160 149
         </td>
161 150
       </tr>
162 151
 

+ 2
- 10
sections/user/notify_handle.php View File

@@ -33,13 +33,6 @@ if ($_POST['artists'.$FormID]) {
33 33
     }
34 34
 }
35 35
 
36
-if ($_POST['excludeva'.$FormID]) {
37
-    $ExcludeVA = '1';
38
-    $HasFilter = true;
39
-} else {
40
-    $ExcludeVA = '0';
41
-}
42
-
43 36
 if ($_POST['newgroupsonly'.$FormID]) {
44 37
     $NewGroupsOnly = '1';
45 38
     $HasFilter = true;
@@ -124,7 +117,6 @@ if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
124 117
     UPDATE users_notify_filters
125 118
     SET
126 119
       Artists='$ArtistList',
127
-      ExcludeVA='$ExcludeVA',
128 120
       NewGroupsOnly='$NewGroupsOnly',
129 121
       Tags='$TagList',
130 122
       NotTags='$NotTagList',
@@ -136,9 +128,9 @@ if ($_POST['id'.$FormID] && is_number($_POST['id'.$FormID])) {
136 128
 } else {
137 129
     $DB->query("
138 130
     INSERT INTO users_notify_filters
139
-      (UserID, Label, Artists, ExcludeVA, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
131
+      (UserID, Label, Artists, NewGroupsOnly, Tags, NotTags, Categories, Media, Users)
140 132
     VALUES
141
-      ('$LoggedUser[ID]','".db_string($_POST['label'.$FormID])."','$ArtistList','$ExcludeVA','$NewGroupsOnly','$TagList','$NotTagList','$CategoryList','$MediaList','$Users')");
133
+      ('$LoggedUser[ID]','".db_string($_POST['label'.$FormID])."','$ArtistList','$NewGroupsOnly','$TagList','$NotTagList','$CategoryList','$MediaList','$Users')");
142 134
 }
143 135
 
144 136
 $Cache->delete_value('notify_filters_'.$LoggedUser['ID']);

+ 0
- 1
static/styles/beluga/beluga.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/beluga";

+ 0
- 1
static/styles/bookish/bookish.scss View File

@@ -1,4 +1,3 @@
1
-@import "../assets/go";
2 1
 @import "scss/bookish";
3 2
 
4 3
 @import "scss/colors";

+ 1
- 0
static/styles/bookish/scss/layout.scss View File

@@ -71,6 +71,7 @@ ol {
71 71
     /* border: 2px solid rgba(0, 0, 0, 0.01); */
72 72
     margin: auto;
73 73
     margin-bottom: 1rem;
74
+    width: 100%;
74 75
 }
75 76
 
76 77
 /* Main column and sidebar */

+ 0
- 1
static/styles/development/development.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/development";

+ 0
- 1
static/styles/genaviv/genaviv.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/genaviv";

+ 0
- 1
static/styles/matcha/matcha.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/matcha";

+ 0
- 1
static/styles/oppai/oppai.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/oppai";

+ 0
- 1
static/styles/postmod/postmod.scss View File

@@ -1,4 +1,3 @@
1
-@import "../assets/go";
2 1
 @import "scss/postmod";
3 2
 
4 3
 @import "scss/colors";

+ 0
- 1
static/styles/public/public.scss View File

@@ -1,2 +1 @@
1
-@import "../assets/go";
2 1
 @import "scss/public";

Loading…
Cancel
Save