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,6 +178,33 @@ class ENV
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 209
      * map
183 210
      *

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

@@ -37,6 +37,8 @@ class Security
37 37
      */
38 38
     public function setupPitfalls()
39 39
     {
40
+        $ENV = ENV::go();
41
+
40 42
         # short_open_tag
41 43
         if (!ini_get('short_open_tag')) {
42 44
             error('short_open_tag != On in php.ini');
@@ -47,6 +49,11 @@ class Security
47 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 57
         # Deal with dumbasses
51 58
         if (isset($_REQUEST['info_hash']) && isset($_REQUEST['peer_id'])) {
52 59
             error(

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

@@ -14,14 +14,6 @@ class TorrentForm
14 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 17
     # Formats
26 18
     # See classes/config.php
27 19
     public $SeqFormats = [];
@@ -34,10 +26,6 @@ class TorrentForm
34 26
     public $BinDocFormats = [];
35 27
     public $CpuGenFormats = [];
36 28
     public $PlainFormats = [];
37
-
38
-    # Misc
39
-    public $Codecs = [];
40
-    public $Archives = [];
41 29
     public $Resolutions = [];
42 30
 
43 31
     # Gazelle
@@ -51,7 +39,8 @@ class TorrentForm
51 39
     public function __construct($Torrent = false, $Error = false, $NewTorrent = true)
52 40
     {
53 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 44
         #global $UploadForm, $Categories, $Formats, $Bitrates, $Media, $MediaManga, $TorrentID, $Containers, $ContainersGames, $Codecs, $Resolutions, $Platform, $Archives, $ArchivesManga;
56 45
 
57 46
         # Gazelle
@@ -63,15 +52,8 @@ class TorrentForm
63 52
         $this->Categories = $Categories;
64 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 55
         # Formats
56
+        # See classes/config.php
75 57
         $this->SeqFormats = $SeqFormats;
76 58
         $this->ProtFormats = $ProtFormats;
77 59
         $this->GraphXmlFormats = $GraphXmlFormats;
@@ -82,10 +64,6 @@ class TorrentForm
82 64
         $this->BinDocFormats = $BinDocFormats;
83 65
         $this->CpuGenFormats = $CpuGenFormats;
84 66
         $this->PlainFormats = $PlainFormats;
85
-        
86
-        # Misc
87
-        $this->Codecs = $Codecs;
88
-        $this->Archives = $Archives;
89 67
         $this->Resolutions = $Resolutions;
90 68
 
91 69
         # Quick constructor test
@@ -579,7 +557,6 @@ HTML;
579 557
          */
580 558
         if ($this->NewTorrent) {
581 559
             $TorrentLocation = display_str($Torrent['Series']);
582
-
583 560
             echo $Twig->render(
584 561
                 'torrent_form/location.html',
585 562
                 [
@@ -601,21 +578,14 @@ HTML;
601 578
          * Year
602 579
          */
603 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,14 +610,14 @@ HTML;
640 610
               <option>---</option>
641 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 617
                 echo " selected";
648 618
             }
649 619
             
650
-            echo ">$Codec</option>\n";
620
+            echo ">$License</option>\n";
651 621
         }
652 622
 
653 623
         echo <<<HTML
@@ -729,7 +699,7 @@ HTML;
729 699
                 $trID = 'media_tr',
730 700
                 $Label = 'Platform',
731 701
                 $Torrent = $Torrent,
732
-                $Media = $this->SeqPlatforms
702
+                $Media = $ENV->META->Platforms->Sequences
733 703
             );
734 704
             
735 705
 
@@ -740,7 +710,10 @@ HTML;
740 710
                 $trID = 'media_graphs_tr',
741 711
                 $Label = 'Platform',
742 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,18 +724,21 @@ HTML;
751 724
                 $trID = 'media_scalars_vectors_tr',
752 725
                 $Label = 'Platform',
753 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 737
             mediaSelect(
762 738
                 $trID = 'media_images_tr',
763 739
                 $Label = 'Platform',
764 740
                 $Torrent = $Torrent,
765
-                $Media = $this->ImgPlatforms
741
+                $Media = $ENV->META->Platforms->Images
766 742
             );
767 743
 
768 744
 
@@ -773,7 +749,7 @@ HTML;
773 749
                 $trID = 'media_documents_tr',
774 750
                 $Label = 'Platform',
775 751
                 $Torrent = $Torrent,
776
-                $Media = $this->DocPlatforms
752
+                $Media = $ENV->META->Platforms->Documents
777 753
             );
778 754
 
779 755
 
@@ -784,7 +760,7 @@ HTML;
784 760
                 $trID = 'media_machine_data_tr',
785 761
                 $Label = 'Platform',
786 762
                 $Torrent = $Torrent,
787
-                $Media = $this->RawPlatforms
763
+                $Media = $ENV->META->Platforms->Raw
788 764
             );
789 765
         } # fi NewTorrent
790 766
         else {
@@ -850,7 +826,7 @@ HTML;
850 826
             $trID = 'container_tr',
851 827
             $Label = 'Format',
852 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,7 +848,7 @@ HTML;
872 848
             $trID = 'container_scalars_vectors_tr',
873 849
             $Label = 'Format',
874 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,7 +190,7 @@ class Validate
190 190
      * Extension Parser
191 191
      *
192 192
      * Takes an associative array of file types and extension, e.g.,
193
-     * $Archives = [
193
+     * $ENV->META->Archives = [
194 194
      *   '7z'     => ['7z'],
195 195
      *   'bzip2'  => ['bz2', 'bzip2'],
196 196
      *   'gzip'   => ['gz', 'gzip', 'tgz', 'tpz'],

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

@@ -1,5 +1,7 @@
1 1
 <?php
2
-/*
2
+declare(strict_types=1);
3
+
4
+/**
3 5
  * This page is used for viewing reports in every viewpoint except auto.
4 6
  * It doesn't AJAX grab a new report when you resolve each one, use auto
5 7
  * for that (reports.php). If you wanted to add a new view, you'd simply
@@ -10,185 +12,200 @@
10 12
  */
11 13
 
12 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 20
 define('REPORTS_PER_PAGE', '10');
19 21
 list($Page, $Limit) = Format::page_limit(REPORTS_PER_PAGE);
20 22
 
21 23
 
22 24
 if (isset($_GET['view'])) {
23
-  $View = $_GET['view'];
25
+    $View = $_GET['view'];
24 26
 } else {
25
-  error(404);
27
+    error(404);
26 28
 }
27 29
 
28 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 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 45
 if (!$ID) {
41
-  switch ($View) {
46
+    switch ($View) {
42 47
     case 'resolved':
43 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 51
       break;
52
+
47 53
     case 'unauto':
48 54
       $Title = 'New reports, not auto assigned!';
49
-      $Where = "WHERE r.Status = 'New'";
55
+      $Where = "WHERE r.`Status` = 'New'";
50 56
       break;
57
+
51 58
     default:
52 59
       error(404);
53 60
       break;
54 61
   }
55 62
 } else {
56
-  switch ($View) {
63
+    switch ($View) {
57 64
     case 'staff':
58 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 69
       list($Username) = $DB->next_record();
63 70
       if ($Username) {
64
-        $Title = "$Username's in-progress reports";
71
+          $Title = "$Username's in-progress reports";
65 72
       } else {
66
-        $Title = "$ID's in-progress reports";
73
+          $Title = "$ID's in-progress reports";
67 74
       }
68 75
       $Where = "
69
-        WHERE r.Status = 'InProgress'
70
-          AND r.ResolverID = $ID";
76
+        WHERE r.`Status` = 'InProgress'
77
+          AND r.`ResolverID` = $ID";
71 78
       break;
79
+
72 80
     case 'resolver':
73 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 85
       list($Username) = $DB->next_record();
78 86
       if ($Username) {
79
-        $Title = "$Username's resolved reports";
87
+          $Title = "$Username's resolved reports";
80 88
       } else {
81
-        $Title = "$ID's resolved reports";
89
+          $Title = "$ID's resolved reports";
82 90
       }
83 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 95
       break;
96
+
88 97
     case 'group':
89 98
       $Title = "Unresolved reports for the group $ID";
90 99
       $Where = "
91
-        WHERE r.Status != 'Resolved'
92
-          AND tg.ID = $ID";
100
+        WHERE r.`Status` != 'Resolved'
101
+          AND tg.`id` = $ID";
93 102
       break;
103
+
94 104
     case 'torrent':
95 105
       $Title = "All reports for the torrent $ID";
96
-      $Where = "WHERE r.TorrentID = $ID";
106
+      $Where = "WHERE r.`TorrentID` = $ID";
97 107
       break;
108
+
98 109
     case 'report':
99 110
       $Title = "Viewing resolution of report $ID";
100
-      $Where = "WHERE r.ID = $ID";
111
+      $Where = "WHERE r.`ID` = $ID";
101 112
       break;
113
+
102 114
     case 'reporter':
103 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 119
       list($Username) = $DB->next_record();
108 120
       if ($Username) {
109
-        $Title = "All torrents reported by $Username";
121
+          $Title = "All torrents reported by $Username";
110 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 127
       break;
128
+
116 129
     case 'uploader':
117 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 134
       list($Username) = $DB->next_record();
122 135
       if ($Username) {
123
-        $Title = "All reports for torrents uploaded by $Username";
136
+          $Title = "All reports for torrents uploaded by $Username";
124 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 140
       $Where = "
128
-        WHERE r.Status != 'Resolved'
129
-          AND t.UserID = $ID";
141
+        WHERE r.`Status` != 'Resolved'
142
+          AND t.`UserID` = $ID";
130 143
       break;
144
+
131 145
     case 'type':
132 146
       $Title = 'All new reports for the chosen type';
133 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 150
       break;
151
+      
138 152
     default:
139 153
       error(404);
140 154
       break;
141 155
   }
142 156
 }
143 157
 
158
+/**
159
+ * The large query
160
+ */
144 161
 $DB->query("
145 162
   SELECT
146 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 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 189
       WHEN 0 THEN ''
173 190
       ELSE 'Various Artists'
174 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 207
   $Where
191
-  GROUP BY r.ID
208
+  GROUP BY r.`ID`
192 209
   $Order
193 210
   LIMIT $Limit");
194 211
 
@@ -219,78 +236,75 @@ View::show_header('Reports V2!', 'reportsv2,bbcode');
219 236
 </div>
220 237
 <?php } ?>
221 238
 <div id="all_reports" style="width: 80%; margin-left: auto; margin-right: auto;">
222
-<?
239
+<?php
223 240
 if (count($Reports) === 0) {
224
-?>
241
+      ?>
225 242
   <div class="box pad center">
226 243
     <strong>No new reports</strong>
227 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 249
     $ResolverID, $ResolverName, $Status, $ReportedTime, $LastChangeTime, $ModComment,
234 250
     $Tracks, $Images, $ExtraIDs, $Links, $LogMessage, $GroupName, $GroupID, $ArtistID,
235 251
     $ArtistName, $Year, $CategoryID, $Time, $Media, $Size, $UploaderID,
236 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 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 264
   <div id="report<?=$ReportID?>" class="report box pad center" data-load-report="<?=$ReportID?>">
250 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 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 272
 //        if (array_key_exists($Type, $Types[$CategoryID])) {
258 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 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 305
   <div id="report<?=$ReportID?>" data-load-report="<?=$ReportID?>">
292 306
     <form class="manage_form" name="report" id="reportform_<?=$ReportID?>" action="reports.php" method="post">
293
-<?
307
+<?php
294 308
 /*
295 309
 * Some of these are for takeresolve, namely the ones that aren't inputs, some for the JavaScript.
296 310
 */
@@ -320,63 +334,62 @@ if (count($Reports) === 0) {
320 334
             uploaded by <a href="user.php?id=<?=$UploaderID?>"><?=$UploaderName?></a> <?=time_diff($Time)?>
321 335
             <br />
322 336
 <?php if ($ReporterName == '') {
323
-          $ReporterName = 'System';
324
-        } ?>
337
+    $ReporterName = 'System';
338
+} ?>
325 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 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 350
             <div style="text-align: right;">
338 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 352
             </div>
340 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 364
             <div style="text-align: right;">
352 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 366
             </div>
354 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 385
             <div style="text-align: right;">
373 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 387
             </div>
375
-<?php }
376
-          }
388
+<?php
377 389
         }
378
-      }
379
-?>
390
+    }
391
+}
392
+      } ?>
380 393
           </td>
381 394
         </tr>
382 395
 <?php if ($Tracks) { ?>
@@ -386,101 +399,99 @@ if (count($Reports) === 0) {
386 399
             <?=str_replace(' ', ', ', $Tracks)?>
387 400
           </td>
388 401
         </tr>
389
-<?
402
+<?php
390 403
       }
391 404
 
392
-      if ($Links) { ?>
405
+              if ($Links) { ?>
393 406
         <tr>
394 407
           <td class="label">Relevant links:</td>
395 408
           <td colspan="3">
396
-<?
409
+<?php
397 410
         $Links = explode(' ', $Links);
398 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 415
             <a href="<?=$Link?>"><?=$Link?></a>
405
-<?php } ?>
416
+<?php
417
+        } ?>
406 418
           </td>
407 419
         </tr>
408
-<?
420
+<?php
409 421
       }
410 422
 
411
-      if ($ExtraIDs) { ?>
423
+              if ($ExtraIDs) { ?>
412 424
         <tr>
413 425
           <td class="label">Relevant other torrents:</td>
414 426
           <td colspan="3">
415
-<?
427
+<?php
416 428
         $First = true;
417 429
         $Extras = explode(' ', $ExtraIDs);
418 430
         foreach ($Extras as $ExtraID) {
419
-          $DB->query("
431
+            $DB->query("
420 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 438
                 WHEN 0 THEN ''
427 439
                 ELSE 'Various Artists'
428 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 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 465
             <?=($First ? '' : '<br />')?>
456 466
             <?=$ExtraLinkName?>
457 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 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 470
             $First = false;
461
-          }
471
+            }
462 472
         }
463 473
 ?>
464 474
           </td>
465 475
         </tr>
466
-<?
476
+<?php
467 477
       }
468 478
 
469
-      if ($Images) {
470
-?>
479
+              if ($Images) {
480
+                  ?>
471 481
         <tr>
472 482
           <td class="label">Relevant images:</td>
473 483
           <td colspan="3">
474
-<?
484
+<?php
475 485
         $Images = explode(' ', $Images);
476
-        foreach ($Images as $Image) {
477
-?>
486
+                  foreach ($Images as $Image) {
487
+                      ?>
478 488
             <img style="max-width: 200px;" class="lightbox-init" src="<?=ImageTools::process($Image)?>" alt="Relevant image" />
479
-<?php } ?>
489
+<?php
490
+                  } ?>
480 491
           </td>
481 492
         </tr>
482
-<?
483
-      } ?>
493
+<?php
494
+              } ?>
484 495
         <tr>
485 496
           <td class="label">User comment:</td>
486 497
           <td colspan="3" class="wrap_overflow"><?=Text::full_format($UserComment)?></td>
@@ -494,7 +505,7 @@ if (count($Reports) === 0) {
494 505
           </td>
495 506
         </tr>
496 507
 <?php }
497
-      if ($Status != 'Resolved') { ?>
508
+              if ($Status != 'Resolved') { ?>
498 509
         <tr>
499 510
           <td class="label">Report comment:</td>
500 511
           <td colspan="3">
@@ -508,11 +519,11 @@ if (count($Reports) === 0) {
508 519
           </td>
509 520
           <td colspan="3">
510 521
             <select name="resolve_type" id="resolve_type<?=$ReportID?>" onchange="ChangeResolve(<?=$ReportID?>);">
511
-<?
522
+<?php
512 523
         $TypeList = $Types['master'] /* + $Types[$CategoryID] */ ;
513 524
         $Priorities = [];
514 525
         foreach ($TypeList as $Key => $Value) {
515
-          $Priorities[$Key] = $Value['priority'];
526
+            $Priorities[$Key] = $Value['priority'];
516 527
         }
517 528
         array_multisort($Priorities, SORT_ASC, $TypeList);
518 529
 
@@ -562,14 +573,14 @@ if (count($Reports) === 0) {
562 573
         <tr>
563 574
           <td class="label"><strong>Extra</strong> log message:</td>
564 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 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 586
           </td>
@@ -628,13 +639,13 @@ if (count($Reports) === 0) {
628 639
       </div>
629 640
     </form>
630 641
   </div>
631
-<?
632
-    }
642
+<?php
643
+          }
644
+      }
633 645
   }
634
-}
635 646
 ?>
636 647
 </div>
637
-<? if ($PageLinks) { ?>
648
+<?php if ($PageLinks) { ?>
638 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,6 +1,8 @@
1 1
 <?php
2 2
 #declare(strict_types = 1);
3 3
 
4
+$ENV = ENV::go();
5
+
4 6
 require_once SERVER_ROOT.'/sections/torrents/functions.php';
5 7
 
6 8
 // The "order by x" links on columns headers
@@ -276,7 +278,7 @@ View::show_header('Browse Torrents', 'browse');
276 278
 
277 279
               <select name="media" class="ft_media fti_advanced">
278 280
                 <option value="">Sequences</option>
279
-                <?php foreach ($SeqPlatforms as $Platform) { ?>
281
+                <?php foreach ($ENV->META->Platforms->Sequences as $Platform) { ?>
280 282
                 <option
281 283
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
282 284
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
@@ -286,7 +288,7 @@ View::show_header('Browse Torrents', 'browse');
286 288
 
287 289
               <select name="media" class="ft_media fti_advanced">
288 290
                 <option value="">Graphs</option>
289
-                <?php foreach ($GraphPlatforms as $Platform) { ?>
291
+                <?php foreach ($ENV->META->Platforms->Graphs as $Platform) { ?>
290 292
                 <option
291 293
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
292 294
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
@@ -296,7 +298,7 @@ View::show_header('Browse Torrents', 'browse');
296 298
 
297 299
               <select name="media" class="ft_media fti_advanced">
298 300
                 <option value="">Images</option>
299
-                <?php foreach ($ImgPlatforms as $Platform) { ?>
301
+                <?php foreach ($ENV->META->Platforms->Images as $Platform) { ?>
300 302
                 <option
301 303
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
302 304
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
@@ -306,7 +308,7 @@ View::show_header('Browse Torrents', 'browse');
306 308
 
307 309
               <select name="media" class="ft_media fti_advanced">
308 310
                 <option value="">Documents</option>
309
-                <?php foreach ($DocPlatforms as $Platform) { ?>
311
+                <?php foreach ($ENV->META->Platforms->Documents as $Platform) { ?>
310 312
                 <option
311 313
                   value="<?=display_str($Platform); # pcs-comment-start; keep quote?>"
312 314
                   <?Format::selected('media', $Platform)?>><?=display_str($Platform); ?>
@@ -417,9 +419,9 @@ View::show_header('Browse Torrents', 'browse');
417 419
               <!-- Codec/License -->
418 420
               <select name="codec" class="ft_codec fti_advanced">
419 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 425
                 </option>
424 426
                 <?php } ?>
425 427
               </select>

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

@@ -1,6 +1,8 @@
1 1
 <?php
2 2
 #declare(strict_types = 1);
3 3
 
4
+$ENV = ENV::go();
5
+
4 6
 $Orders = ['Time', 'Name', 'Seeders', 'Leechers', 'Snatched', 'Size'];
5 7
 $Ways = ['DESC' => 'Descending', 'ASC' => 'Ascending'];
6 8
 
@@ -54,7 +56,7 @@ if (!empty($_GET['format'])) {
54 56
 
55 57
 # Get release specifics
56 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 60
     $SearchWhere[] = "t.Container = '".db_string($_GET['container'])."'";
59 61
 }
60 62
 
@@ -64,21 +66,21 @@ if (isset($_GET['bitrate'])
64 66
 }
65 67
 
66 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 70
     $SearchWhere[] = "t.Media = '".db_string($_GET['media'])."'";
69 71
 }
70 72
 
71 73
 if (isset($_GET['codec'])
72
- && in_array($_GET['codec'], $Codecs)) {
74
+ && in_array($_GET['codec'], $ENV->META->Licenses)) {
73 75
     $SearchWhere[] = "t.Codec = '".db_string($_GET['codec'])."'";
74 76
 }
75 77
 
76
-if (isset($_GET['version']) {
78
+if (isset($_GET['version'])) {
77 79
     $SearchWhere[] = "t.Version = '".db_string($_GET['version'])."'";
78 80
 }
79 81
 
80 82
 if (isset($_GET['resolution'])
81
- && in_array($_GET['resolution'], $Resolutions)) {
83
+ && in_array($_GET['resolution'], $ENV->flatten($ENV->META->Scopes))) {
82 84
     $SearchWhere[] = "t.Resolution = '".db_string($_GET['resolution'])."'";
83 85
 }
84 86
 
@@ -360,8 +362,8 @@ $Pages = Format::get_pages($Page, $TorrentCount, TORRENTS_PER_PAGE);
360 362
 
361 363
             <select id="codec" name="codec" class="ft_codec">
362 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 367
               </option>
366 368
               <?php } ?>
367 369
             </select>

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

@@ -209,13 +209,7 @@ if (!$_POST['groupid']) {
209 209
         '1',
210 210
         'inarray',
211 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,10 +407,10 @@ if ($T['Archive'] === 'Autofill') {
413 407
         $Tor->file_list(),
414 408
 
415 409
         # $Category
416
-        array_keys($Archives),
410
+        array_keys($ENV->META->Formats->Archives),
417 411
 
418 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

@@ -0,0 +1,17 @@
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