Browse Source

Add ENV->flatten, fix reportsv2, start new development branch, and reconcile config template

biotorrents 4 years ago
parent
commit
87a09c6749

classes/config.template.php
File diff suppressed because it is too large
View File


+ 27
- 0
classes/env.class.php View File

178
     }
178
     }
179
 
179
 
180
 
180
 
181
+    /**
182
+     * flatten
183
+     *
184
+     * Takes an $ENV node (Recursive ArrayObject)
185
+     * and flattens out the multi-dimensionality.
186
+     * Returns a single, non-deduplicated array.
187
+     */
188
+    public function flatten($arr)
189
+    {
190
+        $new = array();
191
+
192
+        foreach ($arr as $k => $v) {
193
+            if (is_object($v)) {
194
+                $v = $this->toArray($v);
195
+            }
196
+    
197
+            if (is_array($v)) {
198
+                $new = array_merge($new, $this->flatten($v));
199
+            } else {
200
+                $new[$k] = $v;
201
+            }
202
+        }
203
+
204
+        return $new;
205
+    }
206
+
207
+
181
     /**
208
     /**
182
      * map
209
      * map
183
      *
210
      *

+ 7
- 0
classes/security.class.php View File

37
      */
37
      */
38
     public function setupPitfalls()
38
     public function setupPitfalls()
39
     {
39
     {
40
+        $ENV = ENV::go();
41
+
40
         # short_open_tag
42
         # short_open_tag
41
         if (!ini_get('short_open_tag')) {
43
         if (!ini_get('short_open_tag')) {
42
             error('short_open_tag != On in php.ini');
44
             error('short_open_tag != On in php.ini');
47
             error('APCu extension not loaded');
49
             error('APCu extension not loaded');
48
         }
50
         }
49
 
51
 
52
+        # Bad PHP version
53
+        if (version_compare($ENV->PHP_MIN, '7.4.0', '<')) {
54
+            error("Gazelle requires PHP > $ENV->PHP_MIN.");
55
+        }
56
+
50
         # Deal with dumbasses
57
         # Deal with dumbasses
51
         if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) {
58
         if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) {
52
             error(
59
             error(

+ 30
- 54
classes/torrent_form.class.php View File

14
      * recursively copying parts to arrays in place as needed.
14
      * recursively copying parts to arrays in place as needed.
15
      */
15
      */
16
     
16
     
17
-    # Platforms
18
-    # See classes/config.php
19
-    public $SeqPlatforms = [];
20
-    public $GraphPlatforms = [];
21
-    public $ImgPlatforms = [];
22
-    public $DocPlatforms = [];
23
-    public $RawPlatforms = [];
24
-
25
     # Formats
17
     # Formats
26
     # See classes/config.php
18
     # See classes/config.php
27
     public $SeqFormats = [];
19
     public $SeqFormats = [];
34
     public $BinDocFormats = [];
26
     public $BinDocFormats = [];
35
     public $CpuGenFormats = [];
27
     public $CpuGenFormats = [];
36
     public $PlainFormats = [];
28
     public $PlainFormats = [];
37
-
38
-    # Misc
39
-    public $Codecs = [];
40
-    public $Archives = [];
41
     public $Resolutions = [];
29
     public $Resolutions = [];
42
 
30
 
43
     # Gazelle
31
     # Gazelle
51
     public function __construct($Torrent = false, $Error = false, $NewTorrent = true)
39
     public function __construct($Torrent = false, $Error = false, $NewTorrent = true)
52
     {
40
     {
53
         # See classes/config.php
41
         # See classes/config.php
54
-        global $UploadForm, $Categories, $TorrentID, $SeqPlatforms, $GraphPlatforms, $ImgPlatforms, $DocPlatforms, $RawPlatforms, $SeqFormats, $ProtFormats, $GraphXmlFormats, $GraphTxtFormats, $ImgFormats, $MapVectorFormats, $MapRasterFormats, $BinDocFormats, $CpuGenFormats, $PlainFormats, $Codecs, $Archives, $Resolutions;
42
+        global $UploadForm, $Categories, $TorrentID, $SeqFormats, $ProtFormats, $GraphXmlFormats, $GraphTxtFormats, $ImgFormats, $MapVectorFormats, $MapRasterFormats, $BinDocFormats, $CpuGenFormats, $PlainFormats, $Resolutions;
43
+        #global $UploadForm, $Categories, $TorrentID, $SeqPlatforms, $GraphPlatforms, $ImgPlatforms, $DocPlatforms, $RawPlatforms, $SeqFormats, $ProtFormats, $GraphXmlFormats, $GraphTxtFormats, $ImgFormats, $MapVectorFormats, $MapRasterFormats, $BinDocFormats, $CpuGenFormats, $PlainFormats, $Codecs, $Archives, $Resolutions;
55
         #global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $MediaManga, $TorrentID, $Containers, $ContainersGames, $Codecs, $Resolutions, $Platform, $Archives, $ArchivesManga;
44
         #global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $MediaManga, $TorrentID, $Containers, $ContainersGames, $Codecs, $Resolutions, $Platform, $Archives, $ArchivesManga;
56
 
45
 
57
         # Gazelle
46
         # Gazelle
63
         $this->Categories = $Categories;
52
         $this->Categories = $Categories;
64
         $this->TorrentID = $TorrentID;
53
         $this->TorrentID = $TorrentID;
65
 
54
 
66
-        # Platforms
67
-        # See classes/config.php
68
-        $this->SeqPlatforms = $SeqPlatforms;
69
-        $this->GraphPlatforms = $GraphPlatforms;
70
-        $this->ImgPlatforms = $ImgPlatforms;
71
-        $this->DocPlatforms = $DocPlatforms;
72
-        $this->RawPlatforms = $RawPlatforms;
73
-       
74
         # Formats
55
         # Formats
56
+        # See classes/config.php
75
         $this->SeqFormats = $SeqFormats;
57
         $this->SeqFormats = $SeqFormats;
76
         $this->ProtFormats = $ProtFormats;
58
         $this->ProtFormats = $ProtFormats;
77
         $this->GraphXmlFormats = $GraphXmlFormats;
59
         $this->GraphXmlFormats = $GraphXmlFormats;
82
         $this->BinDocFormats = $BinDocFormats;
64
         $this->BinDocFormats = $BinDocFormats;
83
         $this->CpuGenFormats = $CpuGenFormats;
65
         $this->CpuGenFormats = $CpuGenFormats;
84
         $this->PlainFormats = $PlainFormats;
66
         $this->PlainFormats = $PlainFormats;
85
-        
86
-        # Misc
87
-        $this->Codecs = $Codecs;
88
-        $this->Archives = $Archives;
89
         $this->Resolutions = $Resolutions;
67
         $this->Resolutions = $Resolutions;
90
 
68
 
91
         # Quick constructor test
69
         # Quick constructor test
579
          */
557
          */
580
         if ($this->NewTorrent) {
558
         if ($this->NewTorrent) {
581
             $TorrentLocation = display_str($Torrent['Series']);
559
             $TorrentLocation = display_str($Torrent['Series']);
582
-
583
             echo $Twig->render(
560
             echo $Twig->render(
584
                 'torrent_form/location.html',
561
                 'torrent_form/location.html',
585
                 [
562
                 [
601
          * Year
578
          * Year
602
          */
579
          */
603
         $TorrentYear = display_str($Torrent['Year']);
580
         $TorrentYear = display_str($Torrent['Year']);
604
-        echo <<<HTML
605
-        <tr id="year_tr">
606
-          <td>
607
-            <label for="year" class="required">
608
-              Year
609
-            </label>
610
-          </td>
611
-          
612
-          <td>
613
-            <input type="text" id="year" name="year"
614
-              maxlength="4" size="15" placeholder="Publication year"
615
-              value="$TorrentYear" />
616
-          </td>
617
-        </tr>
618
-HTML;
581
+
582
+        echo $Twig->render(
583
+            'torrent_form/year.html',
584
+            [
585
+            'db' => $ENV->DB->year,
586
+            'location' => $TorrentYear,
587
+          ]
588
+        );
619
 
589
 
620
 
590
 
621
         /**
591
         /**
640
               <option>---</option>
610
               <option>---</option>
641
 HTML;
611
 HTML;
642
 
612
 
643
-        foreach ($this->Codecs as $Codec) {
644
-            echo "<option value='$Codec'";
613
+        foreach ($ENV->META->Licenses as $License) {
614
+            echo "<option value='$License'";
645
 
615
 
646
-            if ($Codec === ($Torrent['Codec'] ?? false)) {
616
+            if ($License === ($Torrent['Codec'] ?? false)) {
647
                 echo " selected";
617
                 echo " selected";
648
             }
618
             }
649
             
619
             
650
-            echo ">$Codec</option>\n";
620
+            echo ">$License</option>\n";
651
         }
621
         }
652
 
622
 
653
         echo <<<HTML
623
         echo <<<HTML
729
                 $trID = 'media_tr',
699
                 $trID = 'media_tr',
730
                 $Label = 'Platform',
700
                 $Label = 'Platform',
731
                 $Torrent = $Torrent,
701
                 $Torrent = $Torrent,
732
-                $Media = $this->SeqPlatforms
702
+                $Media = $ENV->META->Platforms->Sequences
733
             );
703
             );
734
             
704
             
735
 
705
 
740
                 $trID = 'media_graphs_tr',
710
                 $trID = 'media_graphs_tr',
741
                 $Label = 'Platform',
711
                 $Label = 'Platform',
742
                 $Torrent = $Torrent,
712
                 $Torrent = $Torrent,
743
-                $Media = array_merge($this->GraphPlatforms, $this->SeqPlatforms)
713
+                $Media = $ENV->flatten([
714
+                    $ENV->META->Platforms->Graphs,
715
+                    $ENV->META->Platforms->Sequences
716
+                ])
744
             );
717
             );
745
             
718
             
746
 
719
 
751
                 $trID = 'media_scalars_vectors_tr',
724
                 $trID = 'media_scalars_vectors_tr',
752
                 $Label = 'Platform',
725
                 $Label = 'Platform',
753
                 $Torrent = $Torrent,
726
                 $Torrent = $Torrent,
754
-                $Media = array_merge($this->GraphPlatforms, $this->ImgPlatforms)
727
+                $Media = $ENV->flatten([
728
+                    $ENV->META->Platforms->Graphs,
729
+                    $ENV->META->Platforms->Images
730
+                ])
755
             );
731
             );
756
 
732
 
757
 
733
 
758
             /**
734
             /**
759
-             * Platform: Scalars/Vectors
735
+             * Platform: Images
760
              */
736
              */
761
             mediaSelect(
737
             mediaSelect(
762
                 $trID = 'media_images_tr',
738
                 $trID = 'media_images_tr',
763
                 $Label = 'Platform',
739
                 $Label = 'Platform',
764
                 $Torrent = $Torrent,
740
                 $Torrent = $Torrent,
765
-                $Media = $this->ImgPlatforms
741
+                $Media = $ENV->META->Platforms->Images
766
             );
742
             );
767
 
743
 
768
 
744
 
773
                 $trID = 'media_documents_tr',
749
                 $trID = 'media_documents_tr',
774
                 $Label = 'Platform',
750
                 $Label = 'Platform',
775
                 $Torrent = $Torrent,
751
                 $Torrent = $Torrent,
776
-                $Media = $this->DocPlatforms
752
+                $Media = $ENV->META->Platforms->Documents
777
             );
753
             );
778
 
754
 
779
 
755
 
784
                 $trID = 'media_machine_data_tr',
760
                 $trID = 'media_machine_data_tr',
785
                 $Label = 'Platform',
761
                 $Label = 'Platform',
786
                 $Torrent = $Torrent,
762
                 $Torrent = $Torrent,
787
-                $Media = $this->RawPlatforms
763
+                $Media = $ENV->META->Platforms->Raw
788
             );
764
             );
789
         } # fi NewTorrent
765
         } # fi NewTorrent
790
         else {
766
         else {
850
             $trID = 'container_tr',
826
             $trID = 'container_tr',
851
             $Label = 'Format',
827
             $Label = 'Format',
852
             $Torrent = $Torrent,
828
             $Torrent = $Torrent,
853
-            $FileTypes = array_merge($this->SeqFormats, $this->ProtFormats, $this->PlainFormats)
829
+            $FileTypes = array_merge(($ENV->CATS->{1}->Formats))
854
         );
830
         );
855
         
831
         
856
 
832
 
872
             $trID = 'container_scalars_vectors_tr',
848
             $trID = 'container_scalars_vectors_tr',
873
             $Label = 'Format',
849
             $Label = 'Format',
874
             $Torrent = $Torrent,
850
             $Torrent = $Torrent,
875
-            $FileTypes = array_merge($this->ImgFormats, $this->SeqFormats, $this->ProtFormats, $this->PlainFormats)
851
+            $FileTypes = $ENV->flatten($ENV->CATS->{5}->Formats)
876
         );
852
         );
877
 
853
 
878
 
854
 

+ 1
- 1
classes/validate.class.php View File

190
      * Extension Parser
190
      * Extension Parser
191
      *
191
      *
192
      * Takes an associative array of file types and extension, e.g.,
192
      * Takes an associative array of file types and extension, e.g.,
193
-     * $Archives = [
193
+     * $ENV->META->Archives = [
194
      *   '7z'     => ['7z'],
194
      *   '7z'     => ['7z'],
195
      *   'bzip2'  => ['bz2', 'bzip2'],
195
      *   'bzip2'  => ['bz2', 'bzip2'],
196
      *   'gzip'   => ['gz', 'gzip', 'tgz', 'tpz'],
196
      *   'gzip'   => ['gz', 'gzip', 'tgz', 'tpz'],

+ 261
- 250
sections/reportsv2/static.php View File

1
 <?php
1
 <?php
2
-/*
2
+declare(strict_types=1);
3
+
4
+/**
3
  * This page is used for viewing reports in every viewpoint except auto.
5
  * This page is used for viewing reports in every viewpoint except auto.
4
  * It doesn't AJAX grab a new report when you resolve each one, use auto
6
  * It doesn't AJAX grab a new report when you resolve each one, use auto
5
  * for that (reports.php). If you wanted to add a new view, you'd simply
7
  * for that (reports.php). If you wanted to add a new view, you'd simply
10
  */
12
  */
11
 
13
 
12
 if (!check_perms('admin_reports')) {
14
 if (!check_perms('admin_reports')) {
13
-  error(403);
15
+    error(403);
14
 }
16
 }
15
 
17
 
16
-include(SERVER_ROOT.'/classes/reports.class.php');
18
+require_once SERVER_ROOT.'/classes/reports.class.php';
17
 
19
 
18
 define('REPORTS_PER_PAGE', '10');
20
 define('REPORTS_PER_PAGE', '10');
19
 list($Page, $Limit) = Format::page_limit(REPORTS_PER_PAGE);
21
 list($Page, $Limit) = Format::page_limit(REPORTS_PER_PAGE);
20
 
22
 
21
 
23
 
22
 if (isset($_GET['view'])) {
24
 if (isset($_GET['view'])) {
23
-  $View = $_GET['view'];
25
+    $View = $_GET['view'];
24
 } else {
26
 } else {
25
-  error(404);
27
+    error(404);
26
 }
28
 }
27
 
29
 
28
 if (isset($_GET['id'])) {
30
 if (isset($_GET['id'])) {
29
-  if (!is_number($_GET['id']) && $View !== 'type') {
30
-    error(404);
31
-  } else {
32
-    $ID = db_string($_GET['id']);
33
-  }
31
+    if (!is_number($_GET['id']) && $View !== 'type') {
32
+        error(404);
33
+    } else {
34
+        $ID = db_string($_GET['id']);
35
+    }
34
 } else {
36
 } else {
35
-  $ID = '';
37
+    $ID = '';
36
 }
38
 }
37
 
39
 
38
-$Order = 'ORDER BY r.ReportedTime ASC';
40
+/**
41
+ * Large query builder
42
+ */
43
+$Order = 'ORDER BY r.`ReportedTime` ASC';
39
 
44
 
40
 if (!$ID) {
45
 if (!$ID) {
41
-  switch ($View) {
46
+    switch ($View) {
42
     case 'resolved':
47
     case 'resolved':
43
       $Title = 'All the old smelly reports';
48
       $Title = 'All the old smelly reports';
44
-      $Where = "WHERE r.Status = 'Resolved'";
45
-      $Order = 'ORDER BY r.LastChangeTime DESC';
49
+      $Where = "WHERE r.`Status` = 'Resolved'";
50
+      $Order = 'ORDER BY r.`LastChangeTime` DESC';
46
       break;
51
       break;
52
+
47
     case 'unauto':
53
     case 'unauto':
48
       $Title = 'New reports, not auto assigned!';
54
       $Title = 'New reports, not auto assigned!';
49
-      $Where = "WHERE r.Status = 'New'";
55
+      $Where = "WHERE r.`Status` = 'New'";
50
       break;
56
       break;
57
+
51
     default:
58
     default:
52
       error(404);
59
       error(404);
53
       break;
60
       break;
54
   }
61
   }
55
 } else {
62
 } else {
56
-  switch ($View) {
63
+    switch ($View) {
57
     case 'staff':
64
     case 'staff':
58
       $DB->query("
65
       $DB->query("
59
-        SELECT Username
60
-        FROM users_main
61
-        WHERE ID = $ID");
66
+        SELECT `Username`
67
+        FROM `users_main`
68
+        WHERE `ID` = $ID");
62
       list($Username) = $DB->next_record();
69
       list($Username) = $DB->next_record();
63
       if ($Username) {
70
       if ($Username) {
64
-        $Title = "$Username's in-progress reports";
71
+          $Title = "$Username's in-progress reports";
65
       } else {
72
       } else {
66
-        $Title = "$ID's in-progress reports";
73
+          $Title = "$ID's in-progress reports";
67
       }
74
       }
68
       $Where = "
75
       $Where = "
69
-        WHERE r.Status = 'InProgress'
70
-          AND r.ResolverID = $ID";
76
+        WHERE r.`Status` = 'InProgress'
77
+          AND r.`ResolverID` = $ID";
71
       break;
78
       break;
79
+
72
     case 'resolver':
80
     case 'resolver':
73
       $DB->query("
81
       $DB->query("
74
-        SELECT Username
75
-        FROM users_main
76
-        WHERE ID = $ID");
82
+        SELECT `Username`
83
+        FROM `users_main`
84
+        WHERE `ID` = $ID");
77
       list($Username) = $DB->next_record();
85
       list($Username) = $DB->next_record();
78
       if ($Username) {
86
       if ($Username) {
79
-        $Title = "$Username's resolved reports";
87
+          $Title = "$Username's resolved reports";
80
       } else {
88
       } else {
81
-        $Title = "$ID's resolved reports";
89
+          $Title = "$ID's resolved reports";
82
       }
90
       }
83
       $Where = "
91
       $Where = "
84
-        WHERE r.Status = 'Resolved'
85
-          AND r.ResolverID = $ID";
86
-      $Order = 'ORDER BY r.LastChangeTime DESC';
92
+        WHERE r.`Status` = 'Resolved'
93
+          AND r.`ResolverID` = $ID";
94
+      $Order = 'ORDER BY r.`LastChangeTime` DESC';
87
       break;
95
       break;
96
+
88
     case 'group':
97
     case 'group':
89
       $Title = "Unresolved reports for the group $ID";
98
       $Title = "Unresolved reports for the group $ID";
90
       $Where = "
99
       $Where = "
91
-        WHERE r.Status != 'Resolved'
92
-          AND tg.ID = $ID";
100
+        WHERE r.`Status` != 'Resolved'
101
+          AND tg.`id` = $ID";
93
       break;
102
       break;
103
+
94
     case 'torrent':
104
     case 'torrent':
95
       $Title = "All reports for the torrent $ID";
105
       $Title = "All reports for the torrent $ID";
96
-      $Where = "WHERE r.TorrentID = $ID";
106
+      $Where = "WHERE r.`TorrentID` = $ID";
97
       break;
107
       break;
108
+
98
     case 'report':
109
     case 'report':
99
       $Title = "Viewing resolution of report $ID";
110
       $Title = "Viewing resolution of report $ID";
100
-      $Where = "WHERE r.ID = $ID";
111
+      $Where = "WHERE r.`ID` = $ID";
101
       break;
112
       break;
113
+
102
     case 'reporter':
114
     case 'reporter':
103
       $DB->query("
115
       $DB->query("
104
-        SELECT Username
105
-        FROM users_main
106
-        WHERE ID = $ID");
116
+        SELECT `Username`
117
+        FROM `users_main`
118
+        WHERE `ID` = $ID");
107
       list($Username) = $DB->next_record();
119
       list($Username) = $DB->next_record();
108
       if ($Username) {
120
       if ($Username) {
109
-        $Title = "All torrents reported by $Username";
121
+          $Title = "All torrents reported by $Username";
110
       } else {
122
       } else {
111
-        $Title = "All torrents reported by user $ID";
123
+          $Title = "All torrents reported by user $ID";
112
       }
124
       }
113
-      $Where = "WHERE r.ReporterID = $ID";
114
-      $Order = 'ORDER BY r.ReportedTime DESC';
125
+      $Where = "WHERE r.`ReporterID` = $ID";
126
+      $Order = 'ORDER BY r.`ReportedTime` DESC';
115
       break;
127
       break;
128
+
116
     case 'uploader':
129
     case 'uploader':
117
       $DB->query("
130
       $DB->query("
118
-        SELECT Username
119
-        FROM users_main
120
-        WHERE ID = $ID");
131
+        SELECT `Username`
132
+        FROM `users_main`
133
+        WHERE `ID` = $ID");
121
       list($Username) = $DB->next_record();
134
       list($Username) = $DB->next_record();
122
       if ($Username) {
135
       if ($Username) {
123
-        $Title = "All reports for torrents uploaded by $Username";
136
+          $Title = "All reports for torrents uploaded by $Username";
124
       } else {
137
       } else {
125
-        $Title = "All reports for torrents uploaded by user $ID";
138
+          $Title = "All reports for torrents uploaded by user $ID";
126
       }
139
       }
127
       $Where = "
140
       $Where = "
128
-        WHERE r.Status != 'Resolved'
129
-          AND t.UserID = $ID";
141
+        WHERE r.`Status` != 'Resolved'
142
+          AND t.`UserID` = $ID";
130
       break;
143
       break;
144
+
131
     case 'type':
145
     case 'type':
132
       $Title = 'All new reports for the chosen type';
146
       $Title = 'All new reports for the chosen type';
133
       $Where = "
147
       $Where = "
134
-        WHERE r.Status = 'New'
135
-          AND r.Type = '$ID'";
136
-      break;
148
+        WHERE r.`Status` = 'New'
149
+          AND r.`Type` = '$ID'";
137
       break;
150
       break;
151
+      
138
     default:
152
     default:
139
       error(404);
153
       error(404);
140
       break;
154
       break;
141
   }
155
   }
142
 }
156
 }
143
 
157
 
158
+/**
159
+ * The large query
160
+ */
144
 $DB->query("
161
 $DB->query("
145
   SELECT
162
   SELECT
146
     SQL_CALC_FOUND_ROWS
163
     SQL_CALC_FOUND_ROWS
147
-    r.ID,
148
-    r.ReporterID,
149
-    reporter.Username,
150
-    r.TorrentID,
151
-    r.Type,
152
-    r.UserComment,
153
-    r.ResolverID,
154
-    resolver.Username,
155
-    r.Status,
156
-    r.ReportedTime,
157
-    r.LastChangeTime,
158
-    r.ModComment,
159
-    r.Track,
160
-    r.Image,
161
-    r.ExtraID,
162
-    r.Link,
163
-    r.LogMessage,
164
-    COALESCE(NULLIF(tg.Name, ''), NULLIF(tg.Title2, ''), tg.NameJP) AS Name,
165
-    tg.ID,
166
-    CASE COUNT(ta.GroupID)
167
-      WHEN 1 THEN ag.ArtistID
164
+    r.`ID`,
165
+    r.`ReporterID`,
166
+    reporter.`Username`,
167
+    r.`TorrentID`,
168
+    r.`Type`,
169
+    r.`UserComment`,
170
+    r.`ResolverID`,
171
+    resolver.`Username`,
172
+    r.`Status`,
173
+    r.`ReportedTime`,
174
+    r.`LastChangeTime`,
175
+    r.`ModComment`,
176
+    r.`Track`,
177
+    r.`Image`,
178
+    r.`ExtraID`,
179
+    r.`Link`,
180
+    r.`LogMessage`,
181
+    COALESCE(NULLIF(tg.`title`, ''), NULLIF(tg.`subject`, ''), tg.`object`) AS Name,
182
+    tg.`id`,
183
+    CASE COUNT(ta.`GroupID`)
184
+      WHEN 1 THEN ag.`ArtistID`
168
       ELSE '0'
185
       ELSE '0'
169
-    END AS ArtistID,
170
-    CASE COUNT(ta.GroupID)
171
-      WHEN 1 THEN ag.Name
186
+    END AS `ArtistID`,
187
+    CASE COUNT(ta.`GroupID`)
188
+      WHEN 1 THEN ag.`Name`
172
       WHEN 0 THEN ''
189
       WHEN 0 THEN ''
173
       ELSE 'Various Artists'
190
       ELSE 'Various Artists'
174
     END AS ArtistName,
191
     END AS ArtistName,
175
-    tg.Year,
176
-    tg.CategoryID,
177
-    t.Time,
178
-    t.Media,
179
-    t.Size,
180
-    t.UserID AS UploaderID,
181
-    uploader.Username
182
-  FROM reportsv2 AS r
183
-    LEFT JOIN torrents AS t ON t.ID = r.TorrentID
184
-    LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
185
-    LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
186
-    LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
187
-    LEFT JOIN users_main AS resolver ON resolver.ID = r.ResolverID
188
-    LEFT JOIN users_main AS reporter ON reporter.ID = r.ReporterID
189
-    LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
192
+    tg.`year`,
193
+    tg.`category_id`,
194
+    t.`Time`,
195
+    t.`Media`,
196
+    t.`Size`,
197
+    t.`UserID` AS UploaderID,
198
+    uploader.`Username`
199
+  FROM `reportsv2` AS r
200
+    LEFT JOIN `torrents` AS t ON t.`ID` = r.`TorrentID`
201
+    LEFT JOIN `torrents_group` AS tg ON tg.`id` = t.`GroupID`
202
+    LEFT JOIN `torrents_artists` AS ta ON ta.`GroupID` = tg.`id`
203
+    LEFT JOIN `artists_group` AS ag ON ag.`ArtistID` = ta.`ArtistID`
204
+    LEFT JOIN `users_main` AS resolver ON resolver.`ID` = r.`ResolverID`
205
+    LEFT JOIN `users_main` AS reporter ON reporter.`ID` = r.`ReporterID`
206
+    LEFT JOIN `users_main` AS uploader ON uploader.`ID` = t.`UserID`
190
   $Where
207
   $Where
191
-  GROUP BY r.ID
208
+  GROUP BY r.`ID`
192
   $Order
209
   $Order
193
   LIMIT $Limit");
210
   LIMIT $Limit");
194
 
211
 
219
 </div>
236
 </div>
220
 <?php } ?>
237
 <?php } ?>
221
 <div id="all_reports" style="width: 80%; margin-left: auto; margin-right: auto;">
238
 <div id="all_reports" style="width: 80%; margin-left: auto; margin-right: auto;">
222
-<?
239
+<?php
223
 if (count($Reports) === 0) {
240
 if (count($Reports) === 0) {
224
-?>
241
+      ?>
225
   <div class="box pad center">
242
   <div class="box pad center">
226
     <strong>No new reports</strong>
243
     <strong>No new reports</strong>
227
   </div>
244
   </div>
228
-<?
229
-} else {
230
-  foreach ($Reports as $Report) {
231
-
232
-    list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment,
245
+<?php
246
+  } else {
247
+      foreach ($Reports as $Report) {
248
+          list($ReportID, $ReporterID, $ReporterName, $TorrentID, $Type, $UserComment,
233
     $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime, $ModComment,
249
     $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime, $ModComment,
234
     $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID,
250
     $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID,
235
     $ArtistName, $Year, $CategoryID, $Time, $Media, $Size, $UploaderID,
251
     $ArtistName, $Year, $CategoryID, $Time, $Media, $Size, $UploaderID,
236
     $UploaderName) = Misc::display_array($Report, array('ModComment'));
252
     $UploaderName) = Misc::display_array($Report, array('ModComment'));
237
 
253
 
238
-    if (!$GroupID && $Status != 'Resolved') {
239
-      //Torrent already deleted
240
-      $DB->query("
241
-        UPDATE reportsv2
254
+          if (!$GroupID && $Status != 'Resolved') {
255
+              //Torrent already deleted
256
+              $DB->query("
257
+        UPDATE `reportsv2`
242
         SET
258
         SET
243
-          Status = 'Resolved',
244
-          LastChangeTime = NOW(),
245
-          ModComment = 'Report already dealt with (torrent deleted)'
246
-        WHERE ID = $ReportID");
247
-      $Cache->decrement('num_torrent_reportsv2');
248
-?>
259
+          `Status` = 'Resolved',
260
+          `LastChangeTime` = NOW(),
261
+          `ModComment` = 'Report already dealt with (torrent deleted)'
262
+        WHERE `ID` = $ReportID");
263
+              $Cache->decrement('num_torrent_reportsv2'); ?>
249
   <div id="report<?=$ReportID?>" class="report box pad center" data-load-report="<?=$ReportID?>">
264
   <div id="report<?=$ReportID?>" class="report box pad center" data-load-report="<?=$ReportID?>">
250
     <a href="reportsv2.php?view=report&amp;id=<?=$ReportID?>">Report <?=$ReportID?></a> for torrent <?=$TorrentID?> (deleted) has been automatically resolved. <input type="button" value="Hide" onclick="ClearReport(<?=$ReportID?>);" />
265
     <a href="reportsv2.php?view=report&amp;id=<?=$ReportID?>">Report <?=$ReportID?></a> for torrent <?=$TorrentID?> (deleted) has been automatically resolved. <input type="button" value="Hide" onclick="ClearReport(<?=$ReportID?>);" />
251
   </div>
266
   </div>
252
-<?
253
-    } else {
254
-      if (!$CategoryID && false) {
255
-        //Torrent was deleted
256
-      } else {
267
+<?php
268
+          } else {
269
+              if (!$CategoryID && false) {
270
+                  //Torrent was deleted
271
+              } else {
257
 //        if (array_key_exists($Type, $Types[$CategoryID])) {
272
 //        if (array_key_exists($Type, $Types[$CategoryID])) {
258
 //          $ReportType = $Types[$CategoryID][$Type];
273
 //          $ReportType = $Types[$CategoryID][$Type];
259
-/*        } else*/if (array_key_exists($Type, $Types['master'])) {
260
-          $ReportType = $Types['master'][$Type];
261
-        } else {
262
-          //There was a type but it wasn't an option!
263
-          $Type = 'other';
264
-          $ReportType = $Types['master']['other'];
265
-        }
266
-      }
274
+                  /*        } else*/if (array_key_exists($Type, $Types['master'])) {
275
+                      $ReportType = $Types['master'][$Type];
276
+                  } else {
277
+                      //There was a type but it wasn't an option!
278
+                      $Type = 'other';
279
+                      $ReportType = $Types['master']['other'];
280
+                  }
281
+              }
267
 //      $RemasterDisplayString = Reports::format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear);
282
 //      $RemasterDisplayString = Reports::format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear);
268
 
283
 
269
-/*
270
-      if ($ArtistID == 0 && empty($ArtistName)) {
271
-        $RawName = $GroupName.($Year ? " ($Year)" : '').($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . $RemasterDisplayString . ($HasCue ? ' (Cue)' : '').($HasLog ? " (Log: {$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
284
+              /*
285
+                    if ($ArtistID == 0 && empty($ArtistName)) {
286
+                      $RawName = $GroupName.($Year ? " ($Year)" : '').($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . $RemasterDisplayString . ($HasCue ? ' (Cue)' : '').($HasLog ? " (Log: {$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
272
 
287
 
273
-        $LinkName = "<a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\">".($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . $RemasterDisplayString . '</a> '.($HasCue ? ' (Cue)' : '').($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2)." MB)";
288
+                      $LinkName = "<a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\">".($Format || $Encoding || $Media ? " [$Format/$Encoding/$Media]" : '') . $RemasterDisplayString . '</a> '.($HasCue ? ' (Cue)' : '').($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2)." MB)";
274
 
289
 
275
-        $BBName = "[url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] ".($HasCue ? ' (Cue)' : '').($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
276
-      } elseif ($ArtistID == 0 && $ArtistName == 'Various Artists') {
277
-        $RawName = "Various Artists - $GroupName".($Year ? " ($Year)" : '')." [$Format/$Encoding/$Media]{$RemasterDisplayString}" . ($HasCue ? ' (Cue)' : '').($HasLog ? " (Log: {$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
290
+                      $BBName = "[url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] ".($HasCue ? ' (Cue)' : '').($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
291
+                    } elseif ($ArtistID == 0 && $ArtistName == 'Various Artists') {
292
+                      $RawName = "Various Artists - $GroupName".($Year ? " ($Year)" : '')." [$Format/$Encoding/$Media]{$RemasterDisplayString}" . ($HasCue ? ' (Cue)' : '').($HasLog ? " (Log: {$LogScore}%)" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
278
 
293
 
279
-        $LinkName = "Various Artists - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Format/$Encoding/$Media]$RemasterDisplayString</a> ".($HasCue ? ' (Cue)' : '').($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
294
+                      $LinkName = "Various Artists - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Format/$Encoding/$Media]$RemasterDisplayString</a> ".($HasCue ? ' (Cue)' : '').($HasLog ? " <a href=\"torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID\">(Log: {$LogScore}%)</a>" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
280
 
295
 
281
-        $BBName = "Various Artists - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] ".($HasCue ? ' (Cue)' : '').($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
282
-      } else {
283
-*/
284
-        $RawName = "$ArtistName - $GroupName".($Year ? " ($Year)" : '')." [$Media] (".number_format($Size / (1024 * 1024), 2).' MB)';
296
+                      $BBName = "Various Artists - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Format/$Encoding/$Media]{$RemasterDisplayString}[/url] ".($HasCue ? ' (Cue)' : '').($HasLog ? " [url=torrents.php?action=viewlog&amp;torrentid=$TorrentID&amp;groupid=$GroupID](Log: {$LogScore}%)[/url]" : '').' ('.number_format($Size / (1024 * 1024), 2).' MB)';
297
+                    } else {
298
+              */
299
+              $RawName = "$ArtistName - $GroupName".($Year ? " ($Year)" : '')." [$Media] (".number_format($Size / (1024 * 1024), 2).' MB)';
285
 
300
 
286
-        $LinkName = "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Media]</a> (".number_format($Size / (1024 * 1024), 2).' MB)';
301
+              $LinkName = "<a href=\"artist.php?id=$ArtistID\">$ArtistName</a> - <a href=\"torrents.php?id=$GroupID\">$GroupName".($Year ? " ($Year)" : '')."</a> <a href=\"torrents.php?torrentid=$TorrentID\"> [$Media]</a> (".number_format($Size / (1024 * 1024), 2).' MB)';
287
 
302
 
288
-        $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Media][/url] ".' ('.number_format($Size / (1024 * 1024), 2).' MB)';
289
-//      }
290
-?>
303
+              $BBName = "[url=artist.php?id=$ArtistID]".$ArtistName."[/url] - [url=torrents.php?id=$GroupID]$GroupName".($Year ? " ($Year)" : '')."[/url] [url=torrents.php?torrentid=$TorrentID][$Media][/url] ".' ('.number_format($Size / (1024 * 1024), 2).' MB)';
304
+//      }?>
291
   <div id="report<?=$ReportID?>" data-load-report="<?=$ReportID?>">
305
   <div id="report<?=$ReportID?>" data-load-report="<?=$ReportID?>">
292
     <form class="manage_form" name="report" id="reportform_<?=$ReportID?>" action="reports.php" method="post">
306
     <form class="manage_form" name="report" id="reportform_<?=$ReportID?>" action="reports.php" method="post">
293
-<?
307
+<?php
294
 /*
308
 /*
295
 * Some of these are for takeresolve, namely the ones that aren't inputs, some for the JavaScript.
309
 * Some of these are for takeresolve, namely the ones that aren't inputs, some for the JavaScript.
296
 */
310
 */
320
             uploaded by <a href="user.php?id=<?=$UploaderID?>"><?=$UploaderName?></a> <?=time_diff($Time)?>
334
             uploaded by <a href="user.php?id=<?=$UploaderID?>"><?=$UploaderName?></a> <?=time_diff($Time)?>
321
             <br />
335
             <br />
322
 <?php if ($ReporterName == '') {
336
 <?php if ($ReporterName == '') {
323
-          $ReporterName = 'System';
324
-        } ?>
337
+    $ReporterName = 'System';
338
+} ?>
325
             <div style="text-align: right;">was reported by <a href="user.php?id=<?=$ReporterID?>"><?=$ReporterName?></a> <?=time_diff($ReportedTime)?> for the reason: <strong><?=$ReportType['title']?></strong></div>
339
             <div style="text-align: right;">was reported by <a href="user.php?id=<?=$ReporterID?>"><?=$ReporterName?></a> <?=time_diff($ReportedTime)?> for the reason: <strong><?=$ReportType['title']?></strong></div>
326
 <?php if ($Status != 'Resolved') {
340
 <?php if ($Status != 'Resolved') {
327
-
328
-          $DB->query("
329
-            SELECT r.ID
330
-            FROM reportsv2 AS r
331
-              LEFT JOIN torrents AS t ON t.ID = r.TorrentID
332
-            WHERE r.Status != 'Resolved'
333
-              AND t.GroupID = $GroupID");
334
-          $GroupOthers = ($DB->record_count() - 1);
335
-
336
-          if ($GroupOthers > 0) { ?>
341
+    $DB->query("
342
+            SELECT r.`ID`
343
+            FROM `reportsv2` AS r
344
+              LEFT JOIN `torrents` AS t ON t.`ID` = r.`TorrentID`
345
+            WHERE r.`Status` != 'Resolved'
346
+              AND t.`GroupID` = $GroupID");
347
+    $GroupOthers = ($DB->record_count() - 1);
348
+
349
+    if ($GroupOthers > 0) { ?>
337
             <div style="text-align: right;">
350
             <div style="text-align: right;">
338
               <a href="reportsv2.php?view=group&amp;id=<?=$GroupID?>">There <?=(($GroupOthers > 1) ? "are $GroupOthers other reports" : "is 1 other report")?> for torrent(s) in this group</a>
351
               <a href="reportsv2.php?view=group&amp;id=<?=$GroupID?>">There <?=(($GroupOthers > 1) ? "are $GroupOthers other reports" : "is 1 other report")?> for torrent(s) in this group</a>
339
             </div>
352
             </div>
340
 <?php }
353
 <?php }
341
 
354
 
342
-          $DB->query("
343
-            SELECT t.UserID
344
-            FROM reportsv2 AS r
345
-              JOIN torrents AS t ON t.ID = r.TorrentID
346
-            WHERE r.Status != 'Resolved'
347
-              AND t.UserID = $UploaderID");
348
-          $UploaderOthers = ($DB->record_count() - 1);
355
+    $DB->query("
356
+            SELECT t.`UserID`
357
+            FROM `reportsv2` AS r
358
+              JOIN `torrents` AS t ON t.`ID` = r.`TorrentID`
359
+            WHERE r.`Status` != 'Resolved'
360
+              AND t.`UserID` = $UploaderID");
361
+    $UploaderOthers = ($DB->record_count() - 1);
349
 
362
 
350
-          if ($UploaderOthers > 0) { ?>
363
+    if ($UploaderOthers > 0) { ?>
351
             <div style="text-align: right;">
364
             <div style="text-align: right;">
352
               <a href="reportsv2.php?view=uploader&amp;id=<?=$UploaderID?>">There <?=(($UploaderOthers > 1) ? "are $UploaderOthers other reports" : "is 1 other report")?> for torrent(s) uploaded by this user</a>
365
               <a href="reportsv2.php?view=uploader&amp;id=<?=$UploaderID?>">There <?=(($UploaderOthers > 1) ? "are $UploaderOthers other reports" : "is 1 other report")?> for torrent(s) uploaded by this user</a>
353
             </div>
366
             </div>
354
 <?php }
367
 <?php }
355
 
368
 
356
-          $DB->query("
357
-            SELECT DISTINCT req.ID,
358
-              req.FillerID,
359
-              um.Username,
360
-              req.TimeFilled
361
-            FROM requests AS req
362
-              LEFT JOIN torrents AS t ON t.ID = req.TorrentID
363
-              LEFT JOIN reportsv2 AS rep ON rep.TorrentID = t.ID
364
-              JOIN users_main AS um ON um.ID = req.FillerID
365
-            WHERE rep.Status != 'Resolved'
366
-              AND req.TimeFilled > '2010-03-04 02:31:49'
367
-              AND req.TorrentID = $TorrentID");
368
-          $Requests = ($DB->has_results());
369
-          if ($Requests > 0) {
370
-            while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
371
-?>
369
+    $DB->query("
370
+            SELECT DISTINCT req.`ID`,
371
+              req.`FillerID`,
372
+              um.`Username`,
373
+              req.`TimeFilled`
374
+            FROM `requests` AS req
375
+              LEFT JOIN `torrents` AS t ON t.`ID` = req.`TorrentID`
376
+              LEFT JOIN `reportsv2` AS rep ON rep.`TorrentID` = t.`ID`
377
+              JOIN `users_main` AS um ON um.`ID` = req.`FillerID`
378
+            WHERE rep.`Status` != 'Resolved'
379
+              AND req.`TimeFilled` > '2010-03-04 02:31:49'
380
+              AND req.`TorrentID` = $TorrentID");
381
+    $Requests = ($DB->has_results());
382
+    if ($Requests > 0) {
383
+        while (list($RequestID, $FillerID, $FillerName, $FilledTime) = $DB->next_record()) {
384
+            ?>
372
             <div style="text-align: right;">
385
             <div style="text-align: right;">
373
               <strong class="important_text"><a href="user.php?id=<?=$FillerID?>"><?=$FillerName?></a> used this torrent to fill <a href="requests.php?action=view&amp;id=<?=$RequestID?>">this request</a> <?=time_diff($FilledTime)?></strong>
386
               <strong class="important_text"><a href="user.php?id=<?=$FillerID?>"><?=$FillerName?></a> used this torrent to fill <a href="requests.php?action=view&amp;id=<?=$RequestID?>">this request</a> <?=time_diff($FilledTime)?></strong>
374
             </div>
387
             </div>
375
-<?php }
376
-          }
388
+<?php
377
         }
389
         }
378
-      }
379
-?>
390
+    }
391
+}
392
+      } ?>
380
           </td>
393
           </td>
381
         </tr>
394
         </tr>
382
 <?php if ($Tracks) { ?>
395
 <?php if ($Tracks) { ?>
386
             <?=str_replace(' ', ', ', $Tracks)?>
399
             <?=str_replace(' ', ', ', $Tracks)?>
387
           </td>
400
           </td>
388
         </tr>
401
         </tr>
389
-<?
402
+<?php
390
       }
403
       }
391
 
404
 
392
-      if ($Links) { ?>
405
+              if ($Links) { ?>
393
         <tr>
406
         <tr>
394
           <td class="label">Relevant links:</td>
407
           <td class="label">Relevant links:</td>
395
           <td colspan="3">
408
           <td colspan="3">
396
-<?
409
+<?php
397
         $Links = explode(' ', $Links);
410
         $Links = explode(' ', $Links);
398
         foreach ($Links as $Link) {
411
         foreach ($Links as $Link) {
399
-
400
-          if ($local_url = Text::local_url($Link)) {
401
-            $Link = $local_url;
402
-          }
403
-?>
412
+            if ($local_url = Text::local_url($Link)) {
413
+                $Link = $local_url;
414
+            } ?>
404
             <a href="<?=$Link?>"><?=$Link?></a>
415
             <a href="<?=$Link?>"><?=$Link?></a>
405
-<?php } ?>
416
+<?php
417
+        } ?>
406
           </td>
418
           </td>
407
         </tr>
419
         </tr>
408
-<?
420
+<?php
409
       }
421
       }
410
 
422
 
411
-      if ($ExtraIDs) { ?>
423
+              if ($ExtraIDs) { ?>
412
         <tr>
424
         <tr>
413
           <td class="label">Relevant other torrents:</td>
425
           <td class="label">Relevant other torrents:</td>
414
           <td colspan="3">
426
           <td colspan="3">
415
-<?
427
+<?php
416
         $First = true;
428
         $First = true;
417
         $Extras = explode(' ', $ExtraIDs);
429
         $Extras = explode(' ', $ExtraIDs);
418
         foreach ($Extras as $ExtraID) {
430
         foreach ($Extras as $ExtraID) {
419
-          $DB->query("
431
+            $DB->query("
420
             SELECT
432
             SELECT
421
-              COALESCE(NULLIF(tg.Name, ''), NULLIF(tg.Title2, ''), tg.NameJP) AS Name,
422
-              tg.ID,
423
-              ta.ArtistID,
424
-              CASE COUNT(ta.GroupID)
425
-                WHEN 1 THEN ag.Name
433
+              COALESCE(NULLIF(tg.`title`, ''), NULLIF(tg.`subject`, ''), tg.`object`) AS Name,
434
+              tg.`id`,
435
+              ta.`ArtistID`,
436
+              CASE COUNT(ta.`GroupID`)
437
+                WHEN 1 THEN ag.`Name`
426
                 WHEN 0 THEN ''
438
                 WHEN 0 THEN ''
427
                 ELSE 'Various Artists'
439
                 ELSE 'Various Artists'
428
               END AS ArtistName,
440
               END AS ArtistName,
429
-              tg.Year,
430
-              t.Time,
431
-              t.Media,
432
-              t.Size,
433
-              t.UserID AS UploaderID,
434
-              uploader.Username
435
-            FROM torrents AS t
436
-              LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
437
-              LEFT JOIN torrents_artists AS ta ON ta.GroupID = tg.ID
438
-              LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
439
-              LEFT JOIN users_main AS uploader ON uploader.ID = t.UserID
440
-            WHERE t.ID = ?
441
-            GROUP BY tg.ID", $ExtraID);
442
-
443
-          list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime,
441
+              tg.`year`,
442
+              t.`Time`,
443
+              t.`Media`,
444
+              t.`Size`,
445
+              t.`UserID` AS UploaderID,
446
+              uploader.`Username`
447
+            FROM `torrents` AS t
448
+              LEFT JOIN `torrents_group` AS tg ON tg.`id` = t.`GroupID`
449
+              LEFT JOIN `torrents_artists` AS ta ON ta.`GroupID` = tg.`id`
450
+              LEFT JOIN `artists_group` AS ag ON ag.`ArtistID` = ta.`ArtistID`
451
+              LEFT JOIN `users_main` AS uploader ON uploader.`ID` = t.`UserID`
452
+            WHERE t.`ID` = ?
453
+            GROUP BY tg.`id`", $ExtraID);
454
+
455
+            list($ExtraGroupName, $ExtraGroupID, $ExtraArtistID, $ExtraArtistName, $ExtraYear, $ExtraTime,
444
             $ExtraMedia, $ExtraSize, $ExtraUploaderID, $ExtraUploaderName) = Misc::display_array($DB->next_record());
456
             $ExtraMedia, $ExtraSize, $ExtraUploaderID, $ExtraUploaderName) = Misc::display_array($DB->next_record());
445
-          if ($ExtraGroupName) {
446
-
447
-            if ($ArtistID == 0 && empty($ArtistName)) {
448
-              $ExtraLinkName = "<a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [$ExtraFormat/$ExtraEncoding/$ExtraMedia]</a> ".' ('.number_format($ExtraSize / (1024 * 1024), 2).' MB)';
449
-            } elseif ($ArtistID == 0 && $ArtistName == 'Various Artists') {
450
-              $ExtraLinkName = "Various Artists - <a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [$ExtraFormat/$ExtraEncoding/$ExtraMedia]</a> (".number_format($ExtraSize / (1024 * 1024), 2).' MB)';
451
-            } else {
452
-              $ExtraLinkName = "<a href=\"artist.php?id=$ExtraArtistID\">$ExtraArtistName</a> - <a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [//$ExtraMedia]</a>  (".number_format($ExtraSize / (1024 * 1024), 2).' MB)';
453
-            }
454
-?>
457
+            if ($ExtraGroupName) {
458
+                if ($ArtistID == 0 && empty($ArtistName)) {
459
+                    $ExtraLinkName = "<a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [$ExtraFormat/$ExtraEncoding/$ExtraMedia]</a> ".' ('.number_format($ExtraSize / (1024 * 1024), 2).' MB)';
460
+                } elseif ($ArtistID == 0 && $ArtistName == 'Various Artists') {
461
+                    $ExtraLinkName = "Various Artists - <a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [$ExtraFormat/$ExtraEncoding/$ExtraMedia]</a> (".number_format($ExtraSize / (1024 * 1024), 2).' MB)';
462
+                } else {
463
+                    $ExtraLinkName = "<a href=\"artist.php?id=$ExtraArtistID\">$ExtraArtistName</a> - <a href=\"torrents.php?id=$ExtraGroupID\">$ExtraGroupName".($ExtraYear ? " ($ExtraYear)" : '')."</a> <a href=\"torrents.php?torrentid=$ExtraID\"> [//$ExtraMedia]</a>  (".number_format($ExtraSize / (1024 * 1024), 2).' MB)';
464
+                } ?>
455
             <?=($First ? '' : '<br />')?>
465
             <?=($First ? '' : '<br />')?>
456
             <?=$ExtraLinkName?>
466
             <?=$ExtraLinkName?>
457
             <a href="torrents.php?action=download&amp;id=<?=$ExtraID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a>
467
             <a href="torrents.php?action=download&amp;id=<?=$ExtraID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a>
458
             uploaded by <a href="user.php?id=<?=$ExtraUploaderID?>"><?=$ExtraUploaderName?></a> <?=time_diff($ExtraTime)?> <a href="#" onclick="Switch(<?=$ReportID?>, <?=$TorrentID?>, <?=$ExtraID?>); return false;" class="brackets">Switch</a>
468
             uploaded by <a href="user.php?id=<?=$ExtraUploaderID?>"><?=$ExtraUploaderName?></a> <?=time_diff($ExtraTime)?> <a href="#" onclick="Switch(<?=$ReportID?>, <?=$TorrentID?>, <?=$ExtraID?>); return false;" class="brackets">Switch</a>
459
-<?
469
+<?php
460
             $First = false;
470
             $First = false;
461
-          }
471
+            }
462
         }
472
         }
463
 ?>
473
 ?>
464
           </td>
474
           </td>
465
         </tr>
475
         </tr>
466
-<?
476
+<?php
467
       }
477
       }
468
 
478
 
469
-      if ($Images) {
470
-?>
479
+              if ($Images) {
480
+                  ?>
471
         <tr>
481
         <tr>
472
           <td class="label">Relevant images:</td>
482
           <td class="label">Relevant images:</td>
473
           <td colspan="3">
483
           <td colspan="3">
474
-<?
484
+<?php
475
         $Images = explode(' ', $Images);
485
         $Images = explode(' ', $Images);
476
-        foreach ($Images as $Image) {
477
-?>
486
+                  foreach ($Images as $Image) {
487
+                      ?>
478
             <img style="max-width: 200px;" class="lightbox-init" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
488
             <img style="max-width: 200px;" class="lightbox-init" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
479
-<?php } ?>
489
+<?php
490
+                  } ?>
480
           </td>
491
           </td>
481
         </tr>
492
         </tr>
482
-<?
483
-      } ?>
493
+<?php
494
+              } ?>
484
         <tr>
495
         <tr>
485
           <td class="label">User comment:</td>
496
           <td class="label">User comment:</td>
486
           <td colspan="3" class="wrap_overflow"><?=Text::full_format($UserComment)?></td>
497
           <td colspan="3" class="wrap_overflow"><?=Text::full_format($UserComment)?></td>
494
           </td>
505
           </td>
495
         </tr>
506
         </tr>
496
 <?php }
507
 <?php }
497
-      if ($Status != 'Resolved') { ?>
508
+              if ($Status != 'Resolved') { ?>
498
         <tr>
509
         <tr>
499
           <td class="label">Report comment:</td>
510
           <td class="label">Report comment:</td>
500
           <td colspan="3">
511
           <td colspan="3">
508
           </td>
519
           </td>
509
           <td colspan="3">
520
           <td colspan="3">
510
             <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>);">
521
             <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>);">
511
-<?
522
+<?php
512
         $TypeList = $Types['master'] /* + $Types[$CategoryID] */ ;
523
         $TypeList = $Types['master'] /* + $Types[$CategoryID] */ ;
513
         $Priorities = [];
524
         $Priorities = [];
514
         foreach ($TypeList as $Key => $Value) {
525
         foreach ($TypeList as $Key => $Value) {
515
-          $Priorities[$Key] = $Value['priority'];
526
+            $Priorities[$Key] = $Value['priority'];
516
         }
527
         }
517
         array_multisort($Priorities, SORT_ASC, $TypeList);
528
         array_multisort($Priorities, SORT_ASC, $TypeList);
518
 
529
 
562
         <tr>
573
         <tr>
563
           <td class="label"><strong>Extra</strong> log message:</td>
574
           <td class="label"><strong>Extra</strong> log message:</td>
564
           <td>
575
           <td>
565
-            <input type="text" name="log_message" id="log_message<?=$ReportID?>" size="40"<?
576
+            <input type="text" name="log_message" id="log_message<?=$ReportID?>" size="40"<?php
566
           if ($ExtraIDs) {
577
           if ($ExtraIDs) {
567
-            $Extras = explode(' ', $ExtraIDs);
568
-            $Value = '';
569
-            foreach ($Extras as $ExtraID) {
570
-              $Value .= site_url()."torrents.php?torrentid=$ExtraID ";
571
-            }
572
-            echo ' value="'.trim($Value).'"';
578
+              $Extras = explode(' ', $ExtraIDs);
579
+              $Value = '';
580
+              foreach ($Extras as $ExtraID) {
581
+                  $Value .= site_url()."torrents.php?torrentid=$ExtraID ";
582
+              }
583
+              echo ' value="'.trim($Value).'"';
573
           } ?>
584
           } ?>
574
             />
585
             />
575
           </td>
586
           </td>
628
       </div>
639
       </div>
629
     </form>
640
     </form>
630
   </div>
641
   </div>
631
-<?
632
-    }
642
+<?php
643
+          }
644
+      }
633
   }
645
   }
634
-}
635
 ?>
646
 ?>
636
 </div>
647
 </div>
637
-<? if ($PageLinks) { ?>
648
+<?php if ($PageLinks) { ?>
638
 <div class="linkbox pager"><?=$PageLinks?></div>
649
 <div class="linkbox pager"><?=$PageLinks?></div>
639
-<? } ?>
640
-<? View::show_footer(); ?>
650
+<?php } ?>
651
+<?php View::show_footer(); ?>

+ 9
- 7
sections/torrents/browse.php View File

1
 <?php
1
 <?php
2
 #declare(strict_types = 1);
2
 #declare(strict_types = 1);
3
 
3
 
4
+$ENV = ENV::go();
5
+
4
 require_once SERVER_ROOT.'/sections/torrents/functions.php';
6
 require_once SERVER_ROOT.'/sections/torrents/functions.php';
5
 
7
 
6
 // The "order by x" links on columns headers
8
 // The "order by x" links on columns headers
276
 
278
 
277
               <select name="media" class="ft_media fti_advanced">
279
               <select name="media" class="ft_media fti_advanced">
278
                 <option value="">Sequences</option>
280
                 <option value="">Sequences</option>
279
-                <?php foreach ($SeqPlatforms as $Platform) { ?>
281
+                <?php foreach ($ENV->META->Platforms->Sequences as $Platform) { ?>
280
                 <option
282
                 <option
281
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
283
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
282
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
284
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
286
 
288
 
287
               <select name="media" class="ft_media fti_advanced">
289
               <select name="media" class="ft_media fti_advanced">
288
                 <option value="">Graphs</option>
290
                 <option value="">Graphs</option>
289
-                <?php foreach ($GraphPlatforms as $Platform) { ?>
291
+                <?php foreach ($ENV->META->Platforms->Graphs as $Platform) { ?>
290
                 <option
292
                 <option
291
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
293
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
292
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
294
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
296
 
298
 
297
               <select name="media" class="ft_media fti_advanced">
299
               <select name="media" class="ft_media fti_advanced">
298
                 <option value="">Images</option>
300
                 <option value="">Images</option>
299
-                <?php foreach ($ImgPlatforms as $Platform) { ?>
301
+                <?php foreach ($ENV->META->Platforms->Images as $Platform) { ?>
300
                 <option
302
                 <option
301
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
303
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
302
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
304
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
306
 
308
 
307
               <select name="media" class="ft_media fti_advanced">
309
               <select name="media" class="ft_media fti_advanced">
308
                 <option value="">Documents</option>
310
                 <option value="">Documents</option>
309
-                <?php foreach ($DocPlatforms as $Platform) { ?>
311
+                <?php foreach ($ENV->META->Platforms->Documents as $Platform) { ?>
310
                 <option
312
                 <option
311
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
313
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
312
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
314
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
417
               <!-- Codec/License -->
419
               <!-- Codec/License -->
418
               <select name="codec" class="ft_codec fti_advanced">
420
               <select name="codec" class="ft_codec fti_advanced">
419
                 <option value="">License</option>
421
                 <option value="">License</option>
420
-                <?php foreach ($Codecs as $Codec) { ?>
421
-                <option value="<?=display_str($Codec); ?>"
422
-                  <?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?>
422
+                <?php foreach ($ENV->META->Licenses as $License) { ?>
423
+                <option value="<?=display_str($License); ?>"
424
+                  <?Format::selected('codec', $License)?>><?=display_str($License); ?>
423
                 </option>
425
                 </option>
424
                 <?php } ?>
426
                 <?php } ?>
425
               </select>
427
               </select>

+ 9
- 7
sections/torrents/user.php View File

1
 <?php
1
 <?php
2
 #declare(strict_types = 1);
2
 #declare(strict_types = 1);
3
 
3
 
4
+$ENV = ENV::go();
5
+
4
 $Orders = ['Time', 'Name', 'Seeders', 'Leechers', 'Snatched', 'Size'];
6
 $Orders = ['Time', 'Name', 'Seeders', 'Leechers', 'Snatched', 'Size'];
5
 $Ways = ['DESC' => 'Descending', 'ASC' => 'Ascending'];
7
 $Ways = ['DESC' => 'Descending', 'ASC' => 'Ascending'];
6
 
8
 
54
 
56
 
55
 # Get release specifics
57
 # Get release specifics
56
 if (isset($_GET['container'])
58
 if (isset($_GET['container'])
57
- && in_array($_GET['container'], array_unique(array_merge($SeqFormats, $ProtFormats, $GraphXmlFormats, $GraphTxtFormats, $ImgFormats, $MapVectorFormats, $MapRasterFormats, $BinDocFormats, $CpuGenFormats, $PlainFormats)))) {
59
+ && in_array($_GET['container'], $ENV-flatten($ENV->META->Formats))) {
58
     $SearchWhere[] = "t.Container = '".db_string($_GET['container'])."'";
60
     $SearchWhere[] = "t.Container = '".db_string($_GET['container'])."'";
59
 }
61
 }
60
 
62
 
64
 }
66
 }
65
 
67
 
66
 if (isset($_GET['media'])
68
 if (isset($_GET['media'])
67
- && in_array($_GET['media'], array_unique(array_merge($SeqPlatforms, $GraphPlatforms, $ImgPlatforms, $DocPlatforms, $RawPlatforms)))) {
69
+ && in_array($_GET['media'], $ENV-flatten($ENV->META->Platforms))) {
68
     $SearchWhere[] = "t.Media = '".db_string($_GET['media'])."'";
70
     $SearchWhere[] = "t.Media = '".db_string($_GET['media'])."'";
69
 }
71
 }
70
 
72
 
71
 if (isset($_GET['codec'])
73
 if (isset($_GET['codec'])
72
- && in_array($_GET['codec'], $Codecs)) {
74
+ && in_array($_GET['codec'], $ENV->META->Licenses)) {
73
     $SearchWhere[] = "t.Codec = '".db_string($_GET['codec'])."'";
75
     $SearchWhere[] = "t.Codec = '".db_string($_GET['codec'])."'";
74
 }
76
 }
75
 
77
 
76
-if (isset($_GET['version']) {
78
+if (isset($_GET['version'])) {
77
     $SearchWhere[] = "t.Version = '".db_string($_GET['version'])."'";
79
     $SearchWhere[] = "t.Version = '".db_string($_GET['version'])."'";
78
 }
80
 }
79
 
81
 
80
 if (isset($_GET['resolution'])
82
 if (isset($_GET['resolution'])
81
- && in_array($_GET['resolution'], $Resolutions)) {
83
+ && in_array($_GET['resolution'], $ENV->flatten($ENV->META->Scopes))) {
82
     $SearchWhere[] = "t.Resolution = '".db_string($_GET['resolution'])."'";
84
     $SearchWhere[] = "t.Resolution = '".db_string($_GET['resolution'])."'";
83
 }
85
 }
84
 
86
 
360
 
362
 
361
             <select id="codec" name="codec" class="ft_codec">
363
             <select id="codec" name="codec" class="ft_codec">
362
               <option value="">License</option>
364
               <option value="">License</option>
363
-              <?php foreach ($Codecs as $CodecName) { ?>
364
-              <option value="<?= display_str($CodecName); ?>" <?php Format::selected('codec', $CodecName) ?>><?= display_str($CodecName); ?>
365
+              <?php foreach ($ENV->META->Licenses as $License) { ?>
366
+              <option value="<?= display_str($License); ?>" <?php Format::selected('codec', $License) ?>><?= display_str($License); ?>
365
               </option>
367
               </option>
366
               <?php } ?>
368
               <?php } ?>
367
             </select>
369
             </select>

+ 3
- 9
sections/upload/upload_handle.php View File

209
         '1',
209
         '1',
210
         'inarray',
210
         'inarray',
211
         'Please select a valid platform.',
211
         'Please select a valid platform.',
212
-        array('inarray' => array_merge(
213
-            $SeqPlatforms,
214
-            $GraphPlatforms,
215
-            $ImgPlatforms,
216
-            $DocPlatforms,
217
-            $RawPlatforms
218
-        ))
212
+        array('inarray' => $ENV->flatten($ENV->META->Platforms))
219
     );
213
     );
220
 
214
 
221
     /*
215
     /*
413
         $Tor->file_list(),
407
         $Tor->file_list(),
414
 
408
 
415
         # $Category
409
         # $Category
416
-        array_keys($Archives),
410
+        array_keys($ENV->META->Formats->Archives),
417
 
411
 
418
         # $FileTypes
412
         # $FileTypes
419
-        array_merge($Archives),
413
+        array_merge($ENV->META->Formats->Archives),
420
     );
414
     );
421
 }
415
 }
422
 
416
 

+ 17
- 0
templates/torrent_form/year.html View File

1
+<tr id="year_tr">
2
+  <td>
3
+    <label for="year" class="required">{{ db.name }}</label>
4
+  </td>
5
+
6
+  <td>
7
+    <input
8
+      type="text"
9
+      id="year"
10
+      name="year"
11
+      maxlength="4"
12
+      size="15"
13
+      placeholder="{{ db.desc }}"
14
+      value="{{ year }}"
15
+    />
16
+  </td>
17
+</tr>

Loading…
Cancel
Save