pjc 5 years ago
parent
commit
47a1daa8e3

+ 121
- 103
classes/calendarview.class.php View File

@@ -1,119 +1,137 @@
1
-<?
1
+<?php
2 2
 
3
-class CalendarView {
4
-  private static $Days = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
5
-  private static $Headings = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
6
-  private static $Events;
3
+# todo: Check strict eqality all this page
4
+# The staff calendar may actually be broken
7 5
 
8
-  public static function render_title($Month, $Year) {
9
-    if (!is_numeric($Month) || !is_numeric($Year)) {
10
-      error(404);
11
-    }
12
-    $NextMonth = $Month % 12 == 0 ? 1 : $Month + 1;
13
-    $PreviousMonth = $Month == 1 ? 12 : $Month - 1;
14
-    $NextYear = $Year;
15
-    if ($NextMonth == 1) {
16
-      $NextYear++;
17
-    }
18
-    $PreviousYear = $Year;
19
-    if ($PreviousMonth == 12) {
20
-      $PreviousYear--;
6
+class CalendarView
7
+{
8
+    private static $Days = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
9
+    private static $Headings = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
10
+    private static $Events;
11
+
12
+    public static function render_title($Month, $Year)
13
+    {
14
+        if (!is_numeric($Month) || !is_numeric($Year)) {
15
+            error(404);
16
+        }
17
+
18
+        $NextMonth = $Month % 12 == 0 ? 1 : $Month + 1;
19
+        $PreviousMonth = $Month == 1 ? 12 : $Month - 1;
20
+        $NextYear = $Year;
21
+
22
+        if ($NextMonth == 1) {
23
+            $NextYear++;
24
+        }
25
+
26
+        $PreviousYear = $Year;
27
+        if ($PreviousMonth == 12) {
28
+            $PreviousYear--;
29
+        } ?>
30
+
31
+<h1 class="center">
32
+  <a
33
+    href="tools.php?action=calendar&amp;month=<?=$PreviousMonth?>&amp;year=<?=$PreviousYear?>">«</a>
34
+  <?=date("F", mktime(0, 0, 0, $Month, 10)) . " $Year"?>
35
+  <a
36
+    href="tools.php?action=calendar&amp;month=<?=$NextMonth?>&amp;year=<?=$NextYear?>">»</a>
37
+</h1>
38
+
39
+<input type="hidden" id="month" value="<?=$Month?>" />
40
+<input type="hidden" id="year" value="<?=$Year?>" />
41
+
42
+<?php
21 43
     }
22
-?>
23
-    <h1 class="center">
24
-      <a href="tools.php?action=calendar&amp;month=<?=$PreviousMonth?>&amp;year=<?=$PreviousYear?>">&lt;</a>
25
-      <?=date("F", mktime(0, 0, 0, $Month, 10)) . " $Year"?>
26
-      <a href="tools.php?action=calendar&amp;month=<?=$NextMonth?>&amp;year=<?=$NextYear?>">&gt;</a>
27
-    </h1>
28
-    <input type="hidden" id="month" value="<?=$Month?>" />
29
-    <input type="hidden" id="year" value="<?=$Year?>" />
30
-<?
31
-  }
32
-
33
-  private static function get_events_on($Day, $Events) {
34
-    // Linear search, Lol.
35
-    $Results = [];
36
-    foreach ($Events as $Event) {
37
-      if ($Event['StartDay'] == $Day || ($Event['StartDay'] <= $Day && $Event['EndDay'] >= $Day)) {
38
-        $Results[] = $Event;
39
-      }
44
+
45
+    private static function get_events_on($Day, $Events)
46
+    {
47
+        // Linear search, lol
48
+        $Results = [];
49
+        foreach ($Events as $Event) {
50
+            if ($Event['StartDay'] == $Day || ($Event['StartDay'] <= $Day && $Event['EndDay'] >= $Day)) {
51
+                $Results[] = $Event;
52
+            }
53
+        }
54
+        return $Results;
40 55
     }
41
-    return $Results;
42
-  }
43
-
44
-
45
-  private static function render_events_day($Day, $Events) {
46
-    $Events = self::get_events_on($Day, $Events);
47
-    foreach ($Events as $Event) {
48
-      $Color = Calendar::$Colors[Calendar::$Importances[$Event['Importance']]];
49
-      $Category = Calendar::$Categories[$Event['Category']];
50
-      $Tooltip = $Event['Title'] . " - " . Calendar::$Categories[$Event['Category']] . " - " . Calendar::$Importances[$Event['Importance']];
51
-?>
52
-      <p><a href="#" class="event_day tooltip" title="<?=$Tooltip?>" data-gazelle-id="<?=$Event['ID']?>" style="color: <?=$Color?>;"><?=Format::cut_string($Event['Title'], 8, true)?></a></p>
53
-<?
56
+
57
+    private static function render_events_day($Day, $Events)
58
+    {
59
+        $Events = self::get_events_on($Day, $Events);
60
+        foreach ($Events as $Event) {
61
+            $Color = Calendar::$Colors[Calendar::$Importances[$Event['Importance']]];
62
+            $Category = Calendar::$Categories[$Event['Category']];
63
+            $Tooltip = $Event['Title'] . " - " . Calendar::$Categories[$Event['Category']] . " - " . Calendar::$Importances[$Event['Importance']]; ?>
64
+
65
+<p>
66
+  <a href="#" class="event_day tooltip" title="<?=$Tooltip?>"
67
+    data-gazelle-id="<?=$Event['ID']?>"
68
+    style="color: <?=$Color?>;"><?=Format::cut_string($Event['Title'], 8, true)?></a>
69
+</p>
70
+
71
+<?php
72
+        }
54 73
     }
55
-  }
56
-
57
-  public static function render_calendar($Month, $Year, $Events) {
58
-    $RunningDay = date('w', mktime(0, 0, 0, $Month, 1, $Year));
59
-    $DaysInMonth = date('t', mktime(0 ,0 ,0, $Month, 1, $Year));
60
-    $DaysThisWeek = 1;
61
-    $DayCounter = 0;
62
-    $DatesArray = [];
63
-?>
64
-
65
-    <table class="calendar">
66
-      <tr>
67
-<?    foreach (self::$Headings as $Heading) { ?>
68
-        <td class="calendar-row calendar-heading">
69
-          <strong><?=$Heading?></strong>
70
-        </td>
71
-<?    } ?>
72
-      </tr>
73
-      <tr class="calendar-row">
74
-
75
-<?    for ($x = 0; $x < $RunningDay; $x++) { ?>
76
-        <td class="calendar-day-np"></td>
77
-<?
74
+
75
+    public static function render_calendar($Month, $Year, $Events)
76
+    {
77
+        $RunningDay = date('w', mktime(0, 0, 0, $Month, 1, $Year));
78
+        $DaysInMonth = date('t', mktime(0, 0, 0, $Month, 1, $Year));
79
+        $DaysThisWeek = 1;
80
+        $DayCounter = 0;
81
+        $DatesArray = []; ?>
82
+
83
+<table class="calendar">
84
+  <tr>
85
+    <?php foreach (self::$Headings as $Heading) { ?>
86
+    <td class="calendar-row calendar-heading">
87
+      <strong><?=$Heading?></strong>
88
+    </td>
89
+    <?php } ?>
90
+  </tr>
91
+
92
+  <tr class="calendar-row">
93
+    <?php for ($x = 0; $x < $RunningDay; $x++) { ?>
94
+    <td class="calendar-day-np"></td>
95
+    <?php
78 96
       $DaysThisWeek++;
79 97
     }
80 98
 
81
-    for ($i = 1; $i <= $DaysInMonth; $i++) {
82
-?>
83
-        <td class="calendar-day">
84
-          <div class="day-events">
85
-<?            self::render_events_day($i, $Events); ?>
86
-          </div>
87
-          <div class="day-number">
88
-            <?=$i?>
89
-          </div>
90
-        </td>
91
-<?      if ($RunningDay == 6) { ?>
92
-      </tr>
93
-<?        if (($DayCounter + 1) != $DaysInMonth) { ?>
94
-      <tr class="calendar-row">
95
-<?
99
+        for ($i = 1; $i <= $DaysInMonth; $i++) {
100
+            ?>
101
+    <td class="calendar-day">
102
+      <div class="day-events">
103
+        <?php self::render_events_day($i, $Events); ?>
104
+      </div>
105
+      <div class="day-number">
106
+        <?=$i?>
107
+      </div>
108
+    </td>
109
+    <?php if ($RunningDay == 6) { ?>
110
+  </tr>
111
+
112
+  <?php if (($DayCounter + 1) != $DaysInMonth) { ?>
113
+  <tr class="calendar-row">
114
+    <?php
96 115
         }
97 116
         $RunningDay = -1;
98 117
         $DaysThisWeek = 0;
99 118
       }
100
-      $DaysThisWeek++;
101
-      $RunningDay++;
102
-      $DayCounter++;
103
-    }
119
+            $DaysThisWeek++;
120
+            $RunningDay++;
121
+            $DayCounter++;
122
+        }
104 123
 
105
-    if ($DaysThisWeek < 8) {
106
-      for ($x = 1; $x <= (8 - $DaysThisWeek); $x++) {
107
-?>
108
-        <td class="calendar-day-np"></td>
109
-<?
110
-      }
111
-    }
112
-?>
113
-      </tr>
124
+        if ($DaysThisWeek < 8) {
125
+            for ($x = 1; $x <= (8 - $DaysThisWeek); $x++) {
126
+                ?>
127
+    <td class="calendar-day-np"></td>
128
+    <?php
129
+            }
130
+        } ?>
131
+  </tr>
114 132
 
115
-    </table>
116
-<?
133
+</table>
134
+<?php
117 135
     echo $Calendar;
118
-  }
136
+    }
119 137
 }

+ 4
- 4
classes/format.class.php View File

@@ -295,8 +295,8 @@ class Format
295 295
             $Pages = '';
296 296
 
297 297
             if ($StartPage > 1) {
298
-                $Pages .= "<a href=\"$Location?page=1$QueryString$Anchor\"><strong>&lt;&lt; First</strong></a> ";
299
-                $Pages .= "<a href=\"$Location?page=".($StartPage - 1).$QueryString.$Anchor.'" class="pager_prev"><strong>&lt; Prev</strong></a> | ';
298
+                $Pages .= "<a href=\"$Location?page=1$QueryString$Anchor\"><strong>« First</strong></a> ";
299
+                $Pages .= "<a href=\"$Location?page=".($StartPage - 1).$QueryString.$Anchor.'" class="pager_prev"><strong> Prev</strong></a> | ';
300 300
             }
301 301
             // End change
302 302
 
@@ -325,8 +325,8 @@ class Format
325 325
             }
326 326
 
327 327
             if ($StartPage && $StartPage < $TotalPages) {
328
-                $Pages .= " | <a href=\"$Location?page=".($StartPage + 1).$QueryString.$Anchor.'" class="pager_next"><strong>Next &gt;</strong></a> ';
329
-                $Pages .= "<a href=\"$Location?page=$TotalPages$QueryString$Anchor\"><strong> Last &gt;&gt;</strong></a>";
328
+                $Pages .= " | <a href=\"$Location?page=".($StartPage + 1).$QueryString.$Anchor.'" class="pager_next"><strong>Next </strong></a> ';
329
+                $Pages .= "<a href=\"$Location?page=$TotalPages$QueryString$Anchor\"><strong> Last »</strong></a>";
330 330
             }
331 331
         }
332 332
         if ($TotalPages > 1) {

+ 251
- 121
classes/mediainfo.class.php View File

@@ -1,13 +1,17 @@
1 1
 <?php
2
-class MediaInfo {
3
-    public static function parse($string, $raw=false) {
2
+
3
+class MediaInfo
4
+{
5
+    public static function parse($string, $raw=false)
6
+    {
4 7
         $t = new ParseManager($string);
5 8
         $t->parse();
6 9
         return $raw ? $t->output_raw() : $t->output();
7 10
     }
8 11
 }
9 12
 
10
-class ParseManager {
13
+class ParseManager
14
+{
11 15
     protected $lines;
12 16
     protected $parsed_lines;
13 17
     protected $index;
@@ -22,7 +26,8 @@ class ParseManager {
22 26
 
23 27
     const GENERIC_PARSER = 'generic_parser';
24 28
     const MEDIAINFO_START = 'general';
25
-    public function __construct($string='') {
29
+    public function __construct($string='')
30
+    {
26 31
         $this->index = 0;
27 32
         $this->output = '';
28 33
         $this->parsed_lines = [];
@@ -31,44 +36,51 @@ class ParseManager {
31 36
         $this->add_parser($p);
32 37
     }
33 38
 
34
-    protected function set_string($string) {
39
+    protected function set_string($string)
40
+    {
35 41
         $string = trim($string);
36 42
         $string = static::strip_escaped_tags($string);
37 43
         $lines = preg_split("/\r\n|\n|\r/", $string);
38
-        array_walk($lines,function(&$l) {
44
+        array_walk($lines, function (&$l) {
39 45
             $l=trim($l);
40 46
         });
41 47
         $this->lines = $lines;
42 48
     }
43 49
 
44
-    protected function add_parser($p,$name='') {
45
-        $p->set_lines($this->lines,$this->index);
46
-        if (!$name) $name = static::GENERIC_PARSER;
50
+    protected function add_parser($p, $name='')
51
+    {
52
+        $p->set_lines($this->lines, $this->index);
53
+        if (!$name) {
54
+            $name = static::GENERIC_PARSER;
55
+        }
47 56
         $this->parsers[$name][] = $p;
48 57
     }
49 58
 
50
-    public function parse() {
51
-        // get the next section
59
+    public function parse()
60
+    {
61
+        // Get the next section
52 62
         while ($this->index < count($this->lines) &&
53 63
           !($line = $this->parsers[static::GENERIC_PARSER][0]->parse_line()));
54 64
         $section = SectionParser::section_name($line);
55 65
         $this->index--; // go back to line we just read
56 66
 
57
-        // we can have multiple mediainfo files inside the block, so handle that case here
67
+        // We can have multiple mediainfo files inside the block, so handle that case here
58 68
         if ($section == self::MEDIAINFO_START && isset($this->parsers[$section])) {
59 69
             $this->new_mediainfo();
60 70
         }
61
-        if (isset($this->available_parsers[$section])){
71
+
72
+        if (isset($this->available_parsers[$section])) {
62 73
             $parser = new $this->available_parsers[$section];
63
-            $this->add_parser($parser,$section);
64
-            // parse section using the parser
65
-            while ($line = $parser->parse_line()) $this->parsed_lines[] = $line;
74
+            $this->add_parser($parser, $section);
75
+            // Parse section using the parser
76
+            while ($line = $parser->parse_line()) {
77
+                $this->parsed_lines[] = $line;
78
+            }
66 79
 
67 80
             $this->parsed_lines[] = '';
68
-        }
69
-        else {
70
-            // skip until the next blank line or until the next general section
71
-            while ($line = $this->parsers[static::GENERIC_PARSER][0]->parse_line()){
81
+        } else {
82
+            // Skip until the next blank line or until the next general section
83
+            while ($line = $this->parsers[static::GENERIC_PARSER][0]->parse_line()) {
72 84
                 $section = SectionParser::section_name($line);
73 85
                 if ($section == self::MEDIAINFO_START) {
74 86
                     $this->index--; // go back to line we just read
@@ -77,15 +89,18 @@ class ParseManager {
77 89
             }
78 90
         }
79 91
 
80
-        // keep iterating until the last line
92
+        // Keep iterating until the last line
81 93
         if ($this->index < count($this->lines)) {
82 94
             $this->parse();
83 95
         }
84 96
     }
85 97
 
86
-    public function output($cummulative=true) {
87
-        $string = implode("<br />\n",$this->parsed_lines);
88
-        if (!isset($this->parsers['general'])) return $string;
98
+    public function output($cummulative=true)
99
+    {
100
+        $string = implode("<br />\n", $this->parsed_lines);
101
+        if (!isset($this->parsers['general'])) {
102
+            return $string;
103
+        }
89 104
 
90 105
         $midiv_start = '<div class="spoilerContainer hideContainer">
91 106
             <input type="button" class="spoilerButton" value="Show '.
@@ -95,43 +110,49 @@ class ParseManager {
95 110
 
96 111
         $output = '<table class="mediainfo"><tbody><tr><td>';
97 112
         $output .= $this->parsers['general'][0]->output();
98
-        if (isset($this->parsers['video'])){
113
+
114
+        if (isset($this->parsers['video'])) {
99 115
             $output .= '</td><td>';
100 116
             $output .= $this->parsers['video'][0]->output();
101 117
         }
102
-        if (isset($this->parsers['audio'])){
118
+
119
+        if (isset($this->parsers['audio'])) {
103 120
             $output .= '</td><td>';
104 121
             $output .= '<table><caption>Audio</caption><tbody>';
105
-            foreach($this->parsers['audio'] as $index => $ap) {
106
-                $output .= sprintf('<tr><td>#%d: &nbsp;</td><td>%s</td></tr>',intval($index+1),$ap->output());
122
+            foreach ($this->parsers['audio'] as $index => $ap) {
123
+                $output .= sprintf('<tr><td>#%d: &nbsp;</td><td>%s</td></tr>', intval($index+1), $ap->output());
107 124
             }
108 125
             $output .= '</tbody></table>';
109 126
         }
110
-        if (isset($this->parsers['text'])){
111
-            // subtitles table will be printed below the previous table
127
+
128
+        if (isset($this->parsers['text'])) {
129
+            // Subtitles table will be printed below the previous table
112 130
             $output .= '<br />';
113 131
             $output .= '<table><caption>Subtitles</caption><tbody>';
114
-            foreach($this->parsers['text'] as $index => $tp) {
115
-                $output .= sprintf('<tr><td>#%d: &nbsp;</td><td>%s</td></tr>',intval($index+1),$tp->output());
132
+            foreach ($this->parsers['text'] as $index => $tp) {
133
+                $output .= sprintf('<tr><td>#%d: &nbsp;</td><td>%s</td></tr>', intval($index+1), $tp->output());
116 134
             }
117 135
             $output .= '</tbody></table>';
118 136
         }
137
+
119 138
         $output .= '</td></tr></tbody></table><br />';
120 139
         $output = $midiv_start . $string . $midiv_end . $output;
140
+
121 141
         if ($cummulative) {
122 142
             $output = $this->output . $output;
123 143
         }
124 144
         return  $output;
125 145
     }
126 146
 
127
-    public function output_raw() {
147
+    public function output_raw()
148
+    {
128 149
         $output = [];
129 150
         $sections = ['general', 'video', 'audio', 'text'];
130 151
 
131
-        foreach($sections as $section) {
152
+        foreach ($sections as $section) {
132 153
             if (isset($this->parsers[$section])) {
133 154
                 $output[$section] = [];
134
-                foreach($this->parsers[$section] as $index => $parser) {
155
+                foreach ($this->parsers[$section] as $index => $parser) {
135 156
                     $output[$section][$index] = $parser->output_raw();
136 157
                 }
137 158
             }
@@ -139,100 +160,131 @@ class ParseManager {
139 160
         return $output;
140 161
     }
141 162
 
142
-    // strip escaped html tags
143
-    // this is not done for security, just to beautify things (html should already be escaped)
144
-    public static function strip_escaped_tags($string) {
163
+    // Strip escaped html tags
164
+    // This is not done for security, just to beautify things (html should already be escaped)
165
+    public static function strip_escaped_tags($string)
166
+    {
145 167
         // use the php function first
146 168
         $string = strip_tags($string);
147 169
 
148 170
         $gt = '&gt;|&#62;|>';
149 171
         $lt = '&lt;|&#60;|<';
150 172
 
151
-        // there is no opening tag, so don't go through the rest of the regexes
152
-        if (!preg_match("($lt)",$string))
173
+        // There is no opening tag, so don't go through the rest of the regexes
174
+        if (!preg_match("($lt)", $string)) {
153 175
             return $string;
176
+        }
154 177
 
155 178
         $tag_match = "/(?:$lt)(?P<tag>(?:(?!$gt).)*)(?:$gt)/ims";
156 179
 
157
-        // this should match and remove tags
158
-        $string = preg_replace($tag_match,'',$string);
180
+        // This should match and remove tags
181
+        $string = preg_replace($tag_match, '', $string);
159 182
 
160 183
         return $string;
161 184
     }
162 185
 
163
-    protected function new_mediainfo() {
186
+    protected function new_mediainfo()
187
+    {
164 188
         $this->output .= $this->output(false);
165 189
         $this->parsed_lines = [];
166
-        foreach(array_keys($this->parsers) as $key) {
167
-            if ($key != static::GENERIC_PARSER)
190
+
191
+        foreach (array_keys($this->parsers) as $key) {
192
+            if ($key != static::GENERIC_PARSER) {
168 193
                 unset($this->parsers[$key]);
194
+            }
169 195
         }
170 196
     }
171
-
172 197
 }
173 198
 
174
-class SectionParser {
199
+class SectionParser
200
+{
175 201
     protected $lines;
176 202
     protected $index;
177 203
 
178
-
179
-    public function __construct(&$lines=[],&$i=0) {
180
-        $this->set_lines($lines,$i);
204
+    public function __construct(&$lines=[], &$i=0)
205
+    {
206
+        $this->set_lines($lines, $i);
181 207
     }
182
-    public function set_lines(&$lines=[],&$i=0){
208
+
209
+    public function set_lines(&$lines=[], &$i=0)
210
+    {
183 211
         $this->lines = &$lines;
184 212
         $this->index = &$i;
185 213
     }
186
-    // should always return the read line
187
-    public function parse_line(){
214
+
215
+    // Should always return the read line
216
+    public function parse_line()
217
+    {
188 218
         if (!isset($this->lines[$this->index])) {
189 219
             return null;
190 220
         }
221
+
191 222
         $line = $this->lines[$this->index++];
192 223
         $pair = static::property_value_pair($line);
193
-        $this->handle_cases($pair['property'],$pair['value']);
224
+        $this->handle_cases($pair['property'], $pair['value']);
194 225
         return $line;
195 226
     }
196
-    public function output() {
197 227
 
228
+    public function output()
229
+    {
198 230
     }
199
-    protected function handle_cases($property, $value) {
200 231
 
232
+    protected function handle_cases($property, $value)
233
+    {
201 234
     }
202
-    public static function section_name($string) {
203
-        if (!$string) return false;
235
+
236
+    public static function section_name($string)
237
+    {
238
+        if (!$string) {
239
+            return false;
240
+        }
204 241
         $mistart="/^(?:general$|unique id|complete name)/i";
205
-        if (preg_match($mistart, $string)) return ParseManager::MEDIAINFO_START;
206
-        $words = explode(' ',$string);
242
+        if (preg_match($mistart, $string)) {
243
+            return ParseManager::MEDIAINFO_START;
244
+        }
245
+        $words = explode(' ', $string);
207 246
         return strtolower($words[0]);
208 247
     }
209
-    public static function property_value_pair($string) {
248
+
249
+    public static function property_value_pair($string)
250
+    {
210 251
         $pair = explode(":", $string, 2);
211 252
         return array('property'=>strtolower(trim($pair[0])),'value'=>trim($pair[1]??''));
212 253
     }
213
-    public static function strip_path($string) { // remove filepath
254
+
255
+    public static function strip_path($string)
256
+    { // remove filepath
214 257
         $string = str_replace("\\", "/", $string);
215 258
         $path_parts = pathinfo($string);
216 259
         return $path_parts['basename'];
217 260
     }
218
-    public static function parse_size($string) {
261
+
262
+    public static function parse_size($string)
263
+    {
219 264
         return str_replace(array('pixels', ' '), null, $string);
220 265
     }
221
-    protected static function table_head($caption) {
266
+
267
+    protected static function table_head($caption)
268
+    {
222 269
         return "<table class='nobr'><caption>$caption</caption><tbody>";
223 270
     }
224
-    protected static function table_row($property,$value) {
225
-        if ($value)
271
+
272
+    protected static function table_row($property, $value)
273
+    {
274
+        if ($value) {
226 275
             return "<tr><td>$property:&nbsp;&nbsp;</td><td>$value</td></tr>";
276
+        }
227 277
         return '';
228 278
     }
229
-    protected static function table_tail(){
279
+
280
+    protected static function table_tail()
281
+    {
230 282
         return '</tbody></table>';
231 283
     }
232
-
233 284
 }
234 285
 
235
-class AudioSectionParser extends SectionParser {
286
+class AudioSectionParser extends SectionParser
287
+{
236 288
     protected $audioformat;
237 289
     protected $audiobitrate;
238 290
     protected $audiochannels;
@@ -243,7 +295,8 @@ class AudioSectionParser extends SectionParser {
243 295
     protected $form_audioformat;
244 296
     protected $form_audiochannels;
245 297
 
246
-    protected function handle_cases($property,$value) {
298
+    protected function handle_cases($property, $value)
299
+    {
247 300
         switch ($property) {
248 301
             case "format":
249 302
                 $this->audioformat = $value;
@@ -268,14 +321,18 @@ class AudioSectionParser extends SectionParser {
268 321
                 break;
269 322
         }
270 323
     }
271
-    public function output() {
324
+
325
+    public function output()
326
+    {
272 327
         $this->process_vars();
273 328
         $output = $this->audiolang . ' ' . $this->channels() . ' ' . $this->format();
274 329
         $output .= ($this->audiobitrate) ? " @ $this->audiobitrate" : '';
275 330
         $output .= ($this->audiotitle) ? " ($this->audiotitle)" : '';
276 331
         return $output;
277 332
     }
278
-    public function output_raw() {
333
+
334
+    public function output_raw()
335
+    {
279 336
         $this->process_vars();
280 337
         $output = [];
281 338
         $properties = [
@@ -283,16 +340,23 @@ class AudioSectionParser extends SectionParser {
283 340
             'audiochannelpositions', 'audiotitle', 'audiolang', 'audioprofile',
284 341
             'form_audioformat', 'form_audiochannels'
285 342
         ];
286
-        foreach($properties as $property) {
287
-            if ($this->$property) $output[$property] = $this->$property;
343
+
344
+        foreach ($properties as $property) {
345
+            if ($this->$property) {
346
+                $output[$property] = $this->$property;
347
+            }
288 348
         }
289 349
         return $output;
290 350
     }
291
-    protected function process_vars() {
351
+
352
+    protected function process_vars()
353
+    {
292 354
         $this->form_audioformat = $this->form_format();
293 355
         $this->form_audiochannels = $this->form_channels();
294 356
     }
295
-    protected function format() {
357
+
358
+    protected function format()
359
+    {
296 360
         if (strtolower($this->audioformat) === 'mpeg audio') {
297 361
             switch (strtolower($this->audioprofile)) {
298 362
                 case 'layer 3':
@@ -305,7 +369,9 @@ class AudioSectionParser extends SectionParser {
305 369
         }
306 370
         return $this->audioformat;
307 371
     }
308
-    protected function form_format() {
372
+
373
+    protected function form_format()
374
+    {
309 375
         // Not implemented: Real Audio, DTS-HD
310 376
         switch (strtolower($this->format())) {
311 377
             case 'mp2':
@@ -329,6 +395,7 @@ class AudioSectionParser extends SectionParser {
329 395
                     default:
330 396
                         return 'DTS';
331 397
                 }
398
+                // no break
332 399
             case 'flac':
333 400
                 return 'FLAC';
334 401
             case 'pcm':
@@ -337,12 +404,16 @@ class AudioSectionParser extends SectionParser {
337 404
                 return 'WMA';
338 405
         }
339 406
     }
340
-    protected function channels() {
407
+
408
+    protected function channels()
409
+    {
341 410
         if (isset($this->audiochannels)) {
342 411
             $chans = preg_replace('/^(\d).*$/', '$1', $this->audiochannels);
343 412
 
344
-            if (isset($this->audiochannelpositions) && preg_match('/LFE/',
345
-                    $this->audiochannelpositions)) {
413
+            if (isset($this->audiochannelpositions) && preg_match(
414
+                '/LFE/',
415
+                $this->audiochannelpositions
416
+            )) {
346 417
                 $chans -= .9;
347 418
             } else {
348 419
                 $chans = $chans . '.0';
@@ -351,12 +422,15 @@ class AudioSectionParser extends SectionParser {
351 422
             return $chans . 'ch';
352 423
         }
353 424
     }
354
-    protected function form_channels() {
425
+
426
+    protected function form_channels()
427
+    {
355 428
         return preg_replace('/ch/', '', $this->channels());
356 429
     }
357 430
 }
358 431
 
359
-class GeneralSectionParser extends SectionParser {
432
+class GeneralSectionParser extends SectionParser
433
+{
360 434
     public $filename;
361 435
     protected $generalformat;
362 436
     protected $duration;
@@ -364,7 +438,8 @@ class GeneralSectionParser extends SectionParser {
364 438
     protected $form_codec;
365 439
     protected $form_releasegroup;
366 440
 
367
-    protected function handle_cases($property,$value) {
441
+    protected function handle_cases($property, $value)
442
+    {
368 443
         switch ($property) {
369 444
             case "complete name":
370 445
                 // Remove autodetected urls
@@ -384,7 +459,9 @@ class GeneralSectionParser extends SectionParser {
384 459
                 break;
385 460
         }
386 461
     }
387
-    public function output() {
462
+
463
+    public function output()
464
+    {
388 465
         $this->process_vars();
389 466
         $output = static::table_head('General');
390 467
         $properties = [
@@ -392,25 +469,35 @@ class GeneralSectionParser extends SectionParser {
392 469
             'Runtime' => 'duration',
393 470
             'Size' => 'filesize'
394 471
         ];
395
-        foreach($properties as $property => $value) {
396
-            $output .= static::table_row($property,$this->$value);
472
+
473
+        foreach ($properties as $property => $value) {
474
+            $output .= static::table_row($property, $this->$value);
397 475
         }
476
+
398 477
         $output .= static::table_tail();
399 478
         return  $output;
400 479
     }
401
-    public function output_raw() {
480
+
481
+    public function output_raw()
482
+    {
402 483
         $this->process_vars();
403 484
         $output = [];
404 485
         $properties = [
405 486
             'filename', 'generalformat', 'duration', 'filesize', 'form_codec',
406 487
             'form_releasegroup'
407 488
         ];
408
-        foreach($properties as $property) {
409
-            if ($this->$property) $output[$property] = $this->$property;
489
+
490
+        foreach ($properties as $property) {
491
+            if ($this->$property) {
492
+                $output[$property] = $this->$property;
493
+            }
410 494
         }
495
+
411 496
         return $output;
412 497
     }
413
-    protected function process_vars() {
498
+
499
+    protected function process_vars()
500
+    {
414 501
         switch (strtolower($this->generalformat)) {
415 502
             case 'mpeg-ts':
416 503
                 $this->form_codec = 'MPEG-TS';
@@ -420,14 +507,19 @@ class GeneralSectionParser extends SectionParser {
420 507
                 $this->form_codec = '---';
421 508
                 break;
422 509
         }
510
+
423 511
         $matches = [];
424
-        preg_match('/(?:^|.*\\|\/)\[(.*?)\].*$/',
425
-            $this->filename, $matches);
512
+        preg_match(
513
+            '/(?:^|.*\\|\/)\[(.*?)\].*$/',
514
+            $this->filename,
515
+            $matches
516
+        );
426 517
         $this->form_releasegroup = $matches ? $matches[1] : '';
427 518
     }
428 519
 }
429 520
 
430
-class TextSectionParser extends SectionParser {
521
+class TextSectionParser extends SectionParser
522
+{
431 523
     protected $title;
432 524
     protected $language;
433 525
     protected $format;
@@ -435,7 +527,8 @@ class TextSectionParser extends SectionParser {
435 527
     protected $processed_language;
436 528
     protected $form_format;
437 529
 
438
-    protected function handle_cases($property,$value) {
530
+    protected function handle_cases($property, $value)
531
+    {
439 532
         switch ($property) {
440 533
             case 'title':
441 534
                 $this->title = $value;
@@ -451,34 +544,47 @@ class TextSectionParser extends SectionParser {
451 544
                 break;
452 545
         }
453 546
     }
454
-    public function output() {
547
+
548
+    public function output()
549
+    {
455 550
         $this->process_vars();
456 551
         $language = $this->processed_language;
457 552
         $output = "$language ($this->format)";
458
-        if ($this->title) $output .= " ($this->title)";
459
-        if ($this->default) $output .= ' (default)';
553
+        if ($this->title) {
554
+            $output .= " ($this->title)";
555
+        }
556
+        if ($this->default) {
557
+            $output .= ' (default)';
558
+        }
460 559
         return $output;
461 560
     }
462
-    public function output_raw() {
561
+
562
+    public function output_raw()
563
+    {
463 564
         $this->process_vars();
464 565
         $output = [];
465 566
         $properties = [
466 567
             'title', 'language', 'format', 'default', 'processed_language',
467 568
             'form_format'
468 569
         ];
469
-        foreach($properties as $property) {
470
-            if ($this->$property) $output[$property] = $this->$property;
570
+        foreach ($properties as $property) {
571
+            if ($this->$property) {
572
+                $output[$property] = $this->$property;
573
+            }
471 574
         }
472 575
         return $output;
473 576
     }
474
-    protected function process_vars() {
577
+
578
+    protected function process_vars()
579
+    {
475 580
         $this->processed_language = ($this->language) ?
476 581
             $this->language : 'Unknown';
477 582
         $this->form_format = 'Softsubbed';
478 583
     }
479 584
 }
480 585
 
481
-class VideoSectionParser extends SectionParser {
586
+class VideoSectionParser extends SectionParser
587
+{
482 588
     protected $videoformat;
483 589
     protected $videoformatversion;
484 590
     protected $codec;
@@ -499,7 +605,8 @@ class VideoSectionParser extends SectionParser {
499 605
     protected $form_codec;
500 606
     protected $form_resolution;
501 607
 
502
-    protected function handle_cases($property,$value) {
608
+    protected function handle_cases($property, $value)
609
+    {
503 610
         switch ($property) {
504 611
             case "format":
505 612
                 $this->videoformat = $value;
@@ -546,7 +653,9 @@ class VideoSectionParser extends SectionParser {
546 653
                 break;
547 654
         }
548 655
     }
549
-    public function output() {
656
+
657
+    public function output()
658
+    {
550 659
         $this->process_vars();
551 660
         $output = static::table_head('Video');
552 661
         $properties = [
@@ -558,13 +667,17 @@ class VideoSectionParser extends SectionParser {
558 667
             'Bit rate' => 'bitrate',
559 668
             'BPP' => 'bpp'
560 669
         ];
561
-        foreach($properties as $property => $value) {
562
-            $output .= static::table_row($property,$this->$value);
670
+
671
+        foreach ($properties as $property => $value) {
672
+            $output .= static::table_row($property, $this->$value);
563 673
         }
674
+
564 675
         $output .= static::table_tail();
565 676
         return  $output;
566 677
     }
567
-    public function output_raw() {
678
+
679
+    public function output_raw()
680
+    {
568 681
         $this->process_vars();
569 682
         $output = [];
570 683
         $properties = [
@@ -574,12 +687,18 @@ class VideoSectionParser extends SectionParser {
574 687
             'processed_codec', 'processed_resolution', 'processed_framerate',
575 688
             'form_codec', 'form_resolution'
576 689
         ];
577
-        foreach($properties as $property) {
578
-            if ($this->$property) $output[$property] = $this->$property;
690
+
691
+        foreach ($properties as $property) {
692
+            if ($this->$property) {
693
+                $output[$property] = $this->$property;
694
+            }
579 695
         }
696
+
580 697
         return $output;
581 698
     }
582
-    protected function process_vars() {
699
+
700
+    protected function process_vars()
701
+    {
583 702
         $this->processed_codec = $this->compute_codec();
584 703
         $this->processed_resolution = ($this->width) ?
585 704
             $this->width . 'x' . $this->height : '';
@@ -589,7 +708,9 @@ class VideoSectionParser extends SectionParser {
589 708
         $this->form_codec = $this->compute_form_codec();
590 709
         $this->form_resolution = $this->compute_form_resolution();
591 710
     }
592
-    protected function compute_codec() {
711
+
712
+    protected function compute_codec()
713
+    {
593 714
         switch (strtolower($this->videoformat)) {
594 715
             case "mpeg video":
595 716
                 switch (strtolower($this->videoformatversion)) {
@@ -615,24 +736,28 @@ class VideoSectionParser extends SectionParser {
615 736
 
616 737
         $chk = strtolower($this->codec);
617 738
         $wl = strtolower($this->writinglibrary);
618
-        if (($chk === "v_mpeg4/iso/avc" || $chk === "avc1") && strpos($wl, "x264 core") === FALSE) {
739
+
740
+        if (($chk === "v_mpeg4/iso/avc" || $chk === "avc1") && strpos($wl, "x264 core") === false) {
619 741
             return "H264";
620
-        } else if (($chk === "v_mpeg4/iso/avc" || $chk === "avc1") && strpos($wl, "x264 core") > -1)  {
742
+        } elseif (($chk === "v_mpeg4/iso/avc" || $chk === "avc1") && strpos($wl, "x264 core") > -1) {
621 743
             return "x264";
622
-        } else if (strtolower($this->videoformat) === "avc" && strpos($wl, "x264 core") === FALSE) {
744
+        } elseif (strtolower($this->videoformat) === "avc" && strpos($wl, "x264 core") === false) {
623 745
             return "H264";
624 746
         }
625 747
 
626
-        if (($chk === 'v_mpegh/iso/hevc') || ($wl === 'hevc'))
748
+        if (($chk === 'v_mpegh/iso/hevc') || ($wl === 'hevc')) {
627 749
             return 'H265';
750
+        }
628 751
     }
629
-    protected function compute_form_codec() {
752
+
753
+    protected function compute_form_codec()
754
+    {
630 755
         // Not implemented: DVD5, DVD9, WMV, Real Video
631 756
         // MPEG-TS set as GeneralSectionParser::$form_codec if found
632 757
         // MPEG-PS sets GeneralSectionParser::$form_codec to blank form value
633 758
         //   so DVD5 or DVD9 is selected manually.
634 759
         $codec = $this->compute_codec();
635
-        switch(strtolower($codec)) {
760
+        switch (strtolower($codec)) {
636 761
             case 'x264':
637 762
             case 'h264':
638 763
                 return strtolower($this->bitdepth) == '10 bits' ?
@@ -649,25 +774,30 @@ class VideoSectionParser extends SectionParser {
649 774
             case 'mpeg-2':
650 775
                 return 'MPEG-2';
651 776
         }
652
-        switch(strtolower($this->codec)) {
777
+
778
+        switch (strtolower($this->codec)) {
653 779
             case 'wmv3':
654 780
                 return 'VC-1';
655 781
             case 'mp43':
656 782
                 return 'MPEG-4 v3';
657 783
         }
658
-        switch(strtolower($this->videoformat)) {
784
+
785
+        switch (strtolower($this->videoformat)) {
659 786
             case 'vc-1':
660 787
                 return 'VC-1';
661 788
             case 's-mpeg 4 v3':
662 789
                 return 'MPEG-4 v3';
663 790
         }
664 791
     }
665
-    protected function compute_form_resolution() {
792
+
793
+    protected function compute_form_resolution()
794
+    {
666 795
         global $Resolutions;
667 796
         $closest = null;
797
+        
668 798
         if (isset($this->height)) {
669 799
             $resolutions = $Resolutions;
670
-            foreach($resolutions as $resolution) {
800
+            foreach ($resolutions as $resolution) {
671 801
                 if (!isset($closest) || abs($this->height - $resolution) <
672 802
                         abs($this->height - $closest)) {
673 803
                     $closest = $resolution;

+ 27
- 24
classes/reports.class.php View File

@@ -1,27 +1,30 @@
1 1
 <?php
2
-class Reports {
3
-  /**
4
-   * This function formats a string containing a torrent's remaster information
5
-   * to be used in Reports v2.
6
-   *
7
-   * @param boolean  $Remastered - whether the torrent contains remaster information
8
-   * @param string   $RemasterTitle - the title of the remaster information
9
-   * @param string   $RemasterYear - the year of the remaster information
10
-   */
11
-  public static function format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear) {
12
-    if ($Remastered) {
13
-      $RemasterDisplayString = ' &lt;';
14
-      if ($RemasterTitle != '' && $RemasterYear != '') {
15
-        $RemasterDisplayString .= "$RemasterTitle - $RemasterYear";
16
-      } elseif ($RemasterTitle != '' && $RemasterYear == '') {
17
-        $RemasterDisplayString .= $RemasterTitle;
18
-      } elseif ($RemasterTitle == '' && $RemasterYear != '') {
19
-        $RemasterDisplayString .= $RemasterYear;
20
-      }
21
-      $RemasterDisplayString .= '&gt;';
22
-    } else {
23
-      $RemasterDisplayString = '';
2
+
3
+class Reports
4
+{
5
+    /**
6
+     * This function formats a string containing a torrent's remaster information
7
+     * to be used in Reports v2.
8
+     *
9
+     * @param boolean  $Remastered - whether the torrent contains remaster information
10
+     * @param string   $RemasterTitle - the title of the remaster information
11
+     * @param string   $RemasterYear - the year of the remaster information
12
+     */
13
+    public static function format_reports_remaster_info($Remastered, $RemasterTitle, $RemasterYear)
14
+    {
15
+        if ($Remastered) {
16
+            $RemasterDisplayString = ' &lt;';
17
+            if ($RemasterTitle !== '' && $RemasterYear !== '') {
18
+                $RemasterDisplayString .= "$RemasterTitle - $RemasterYear";
19
+            } elseif ($RemasterTitle !== '' && $RemasterYear === '') {
20
+                $RemasterDisplayString .= $RemasterTitle;
21
+            } elseif ($RemasterTitle === '' && $RemasterYear !== '') {
22
+                $RemasterDisplayString .= $RemasterYear;
23
+            }
24
+            $RemasterDisplayString .= '&gt;';
25
+        } else {
26
+            $RemasterDisplayString = '';
27
+        }
28
+        return $RemasterDisplayString;
24 29
     }
25
-    return $RemasterDisplayString;
26
-  }
27 30
 }

+ 77
- 68
classes/top10view.class.php View File

@@ -1,84 +1,93 @@
1
-<?
1
+<?php
2 2
 
3
-class Top10View {
3
+class Top10View
4
+{
5
+    public static function render_linkbox($Selected)
6
+    {
7
+        ?>
4 8
 
5
-  public static function render_linkbox($Selected) {
6
-?>
7
-    <div class="linkbox">
8
-      <a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected == "torrents")?></a>
9
-      <a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected == "users")?></a>
10
-      <a href="top10.php?type=tags" class="brackets"><?=self::get_selected_link("Tags", $Selected == "tags")?></a>
11
-<?  if (FEATURE_DONATE) { ?>
12
-      <a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected == "donors")?></a>
13
-<?  } ?>
14
-    </div>
15
-<?
16
-  }
9
+<div class="linkbox">
10
+  <a href="top10.php?type=torrents" class="brackets"><?=self::get_selected_link("Torrents", $Selected === "torrents")?></a>
11
+  <a href="top10.php?type=users" class="brackets"><?=self::get_selected_link("Users", $Selected === "users")?></a>
12
+  <a href="top10.php?type=tags" class="brackets"><?=self::get_selected_link("Tags", $Selected === "tags")?></a>
13
+  <?php if (FEATURE_DONATE) { ?>
14
+  <a href="top10.php?type=donors" class="brackets"><?=self::get_selected_link("Donors", $Selected === "donors")?></a>
15
+  <?php } ?>
16
+</div>
17 17
 
18
-  private static function get_selected_link($String, $Selected) {
19
-    if ($Selected) {
20
-      return "<strong>$String</strong>";
21
-    } else {
22
-      return $String;
18
+<?php
23 19
     }
24
-  }
25 20
 
26
-  public static function render_artist_tile($Artist, $Category) {
27
-    if (self::is_valid_artist($Artist)) {
28
-      switch ($Category) {
29
-        case 'weekly':
30
-        case 'hyped':
31
-          self::render_tile("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
32
-          break;
33
-        default:
34
-          break;
35
-      }
21
+    private static function get_selected_link($String, $Selected)
22
+    {
23
+        if ($Selected) {
24
+            return "<strong>$String</strong>";
25
+        } else {
26
+            return $String;
27
+        }
36 28
     }
37
-  }
38 29
 
39
-  private static function render_tile($Url, $Name, $Image) {
40
-    if (!empty($Image)) {
41
-      $Name = display_str($Name);
42
-?>
43
-      <li>
44
-        <a href="<?=$Url?><?=$Name?>">
45
-          <img class="tooltip large_tile" alt="<?=$Name?>" title="<?=$Name?>" src="<?=ImageTools::process($Image)?>" />
46
-        </a>
47
-      </li>
48
-<?
30
+    public static function render_artist_tile($Artist, $Category)
31
+    {
32
+        if (self::is_valid_artist($Artist)) {
33
+            switch ($Category) {
34
+              case 'weekly':
35
+              case 'hyped':
36
+                self::render_tile("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
37
+                break;
38
+              default:
39
+                break;
40
+            }
41
+        }
49 42
     }
50
-  }
51 43
 
44
+    private static function render_tile($Url, $Name, $Image)
45
+    {
46
+        if (!empty($Image)) {
47
+            $Name = display_str($Name); ?>
52 48
 
53
-  public static function render_artist_list($Artist, $Category) {
54
-    if (self::is_valid_artist($Artist)) {
55
-      switch ($Category) {
56
-
57
-        case 'weekly':
58
-        case 'hyped':
59
-          self::render_list("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
60
-          break;
61
-        default:
62
-          break;
63
-      }
49
+<li>
50
+  <a
51
+    href="<?=$Url?><?=$Name?>">
52
+    <img class="tooltip large_tile" alt="<?=$Name?>"
53
+      title="<?=$Name?>"
54
+      src="<?=ImageTools::process($Image)?>" />
55
+  </a>
56
+</li>
57
+<?php
58
+        }
64 59
     }
65
-  }
66 60
 
67
-  private static function render_list($Url, $Name, $Image) {
68
-    if (!empty($Image)) {
69
-      $Image = ImageTools::process($Image);
70
-      $Title = "title=\"&lt;img class=&quot;large_tile&quot; src=&quot;$Image&quot; alt=&quot;&quot; /&gt;\"";
71
-      $Name = display_str($Name);
72
-?>
73
-      <li>
74
-        <a class="tooltip_image" data-title-plain="<?=$Name?>" <?=$Title?> href="<?=$Url?><?=$Name?>"><?=$Name?></a>
75
-      </li>
76
-<?
61
+    public static function render_artist_list($Artist, $Category)
62
+    {
63
+        if (self::is_valid_artist($Artist)) {
64
+            switch ($Category) {
65
+              case 'weekly':
66
+              case 'hyped':
67
+                self::render_list("artist.php?artistname=", $Artist['name'], $Artist['image'][3]['#text']);
68
+                break;
69
+              default:
70
+                break;
71
+            }
72
+        }
77 73
     }
78
-  }
79 74
 
80
-  private static function is_valid_artist($Artist) {
81
-    return $Artist['name'] != '[unknown]';
82
-  }
75
+    private static function render_list($Url, $Name, $Image)
76
+    {
77
+        if (!empty($Image)) {
78
+            $Image = ImageTools::process($Image);
79
+            $Title = "title=\"&lt;img class=&quot;large_tile&quot; src=&quot;$Image&quot; alt=&quot;&quot; /&gt;\"";
80
+            $Name = display_str($Name); ?>
81
+
82
+<li>
83
+  <a class="tooltip_image" data-title-plain="<?=$Name?>" <?=$Title?> href="<?=$Url?><?=$Name?>"><?=$Name?></a>
84
+</li>
85
+<?php
86
+        }
87
+    }
83 88
 
89
+    private static function is_valid_artist($Artist)
90
+    {
91
+        return $Artist['name'] !== '[unknown]';
92
+    }
84 93
 }

+ 30
- 24
classes/util.php View File

@@ -52,6 +52,7 @@ function assert_numbers(&$Base, $Keys, $Error = 0)
52 52
     if (!is_array($Base) || !is_array($Keys)) {
53 53
         return;
54 54
     }
55
+
55 56
     foreach ($Keys as $Key) {
56 57
         if (!isset($Base[$Key]) || !is_number($Base[$Key])) {
57 58
             error($Error);
@@ -71,20 +72,22 @@ function is_bool_value($Value)
71 72
     if (is_bool($Value)) {
72 73
         return $Value;
73 74
     }
75
+
74 76
     if (is_string($Value)) {
75 77
         switch (strtolower($Value)) {
76
-      case 'true':
77
-      case 'yes':
78
-      case 'on':
79
-      case '1':
80
-        return true;
81
-      case 'false':
82
-      case 'no':
83
-      case 'off':
84
-      case '0':
85
-        return false;
86
-    }
78
+            case 'true':
79
+            case 'yes':
80
+            case 'on':
81
+            case '1':
82
+                return true;
83
+            case 'false':
84
+            case 'no':
85
+            case 'off':
86
+            case '0':
87
+                return false;
88
+        }
87 89
     }
90
+
88 91
     if (is_numeric($Value)) {
89 92
         if ($Value === 1) {
90 93
             return true;
@@ -92,6 +95,7 @@ function is_bool_value($Value)
92 95
             return false;
93 96
         }
94 97
     }
98
+
95 99
     return null;
96 100
 }
97 101
 
@@ -107,26 +111,27 @@ function display_str($Str)
107 111
     if ($Str === null || $Str === false || is_array($Str)) {
108 112
         return '';
109 113
     }
114
+
110 115
     if ($Str !== '' && !is_number($Str)) {
111 116
         $Str = Format::make_utf8($Str);
112 117
         $Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8');
113 118
         $Str = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,6};)/m", '&amp;', $Str);
114 119
 
115 120
         $Replace = array(
116
-      "'",'"',"<",">",
117
-      '&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;',
118
-      '&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;',
119
-      '&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;',
120
-      '&#156;','&#158;','&#159;'
121
-    );
121
+            "'",'"',"<",">",
122
+            '&#128;','&#130;','&#131;','&#132;','&#133;','&#134;','&#135;','&#136;',
123
+            '&#137;','&#138;','&#139;','&#140;','&#142;','&#145;','&#146;','&#147;',
124
+            '&#148;','&#149;','&#150;','&#151;','&#152;','&#153;','&#154;','&#155;',
125
+            '&#156;','&#158;','&#159;'
126
+        );
122 127
 
123 128
         $With = array(
124
-      '&#39;','&quot;','&lt;','&gt;',
125
-      '&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;',
126
-      '&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;',
127
-      '&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;',
128
-      '&#339;','&#382;','&#376;'
129
-    );
129
+            '&#39;','&quot;','&lt;','&gt;',
130
+            '&#8364;','&#8218;','&#402;','&#8222;','&#8230;','&#8224;','&#8225;','&#710;',
131
+            '&#8240;','&#352;','&#8249;','&#338;','&#381;','&#8216;','&#8217;','&#8220;',
132
+            '&#8221;','&#8226;','&#8211;','&#8212;','&#732;','&#8482;','&#353;','&#8250;',
133
+            '&#339;','&#382;','&#376;'
134
+        );
130 135
 
131 136
         $Str = str_replace($Replace, $With, $Str);
132 137
     }
@@ -147,6 +152,7 @@ function send_irc($Raw)
147 152
 
148 153
     $IRCSocket = fsockopen(SOCKET_LISTEN_ADDRESS, SOCKET_LISTEN_PORT);
149 154
     $Raw = str_replace(array("\n", "\r"), '', $Raw);
155
+
150 156
     fwrite($IRCSocket, $Raw);
151 157
     fclose($IRCSocket);
152 158
 }
@@ -163,7 +169,7 @@ function send_irc($Raw)
163 169
 function error($Error, $NoHTML = false, $Log = false)
164 170
 {
165 171
     global $Debug;
166
-    require(SERVER_ROOT.'/sections/error/index.php');
172
+    require SERVER_ROOT.'/sections/error/index.php';
167 173
     $Debug->profile();
168 174
     die();
169 175
 }

+ 40
- 38
sections/ajax/forum/thread.php View File

@@ -18,12 +18,13 @@ if (!isset($_GET['threadid']) || !is_number($_GET['threadid'])) {
18 18
         $ThreadID = $_GET['topicid'];
19 19
     } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
20 20
         $DB->query("
21
-      SELECT TopicID
22
-      FROM forums_posts
23
-      WHERE ID = $_GET[postid]");
21
+        SELECT TopicID
22
+        FROM forums_posts
23
+          WHERE ID = $_GET[postid]");
24 24
         list($ThreadID) = $DB->next_record();
25
+
25 26
         if ($ThreadID) {
26
-            //Redirect postid to threadid when necessary.
27
+            // Redirect postid to threadid when necessary
27 28
             header("Location: ajax.php?action=forum&type=viewthread&threadid=$ThreadID&postid=$_GET[postid]");
28 29
             die();
29 30
         } else {
@@ -67,10 +68,10 @@ if ($ThreadInfo['Posts'] > $PerPage) {
67 68
         $PostNum = $_GET['post'];
68 69
     } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) {
69 70
         $DB->query("
70
-      SELECT COUNT(ID)
71
-      FROM forums_posts
72
-      WHERE TopicID = $ThreadID
73
-        AND ID <= $_GET[postid]");
71
+        SELECT COUNT(ID)
72
+        FROM forums_posts
73
+          WHERE TopicID = $ThreadID
74
+          AND ID <= $_GET[postid]");
74 75
         list($PostNum) = $DB->next_record();
75 76
     } else {
76 77
         $PostNum = 1;
@@ -115,19 +116,20 @@ if ($_GET['updatelastread'] !== '0') {
115 116
     // Handle last read
116 117
     if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
117 118
         $DB->query("
118
-      SELECT PostID
119
-      FROM forums_last_read_topics
120
-      WHERE UserID = '$LoggedUser[ID]'
121
-        AND TopicID = '$ThreadID'");
119
+        SELECT PostID
120
+        FROM forums_last_read_topics
121
+          WHERE UserID = '$LoggedUser[ID]'
122
+          AND TopicID = '$ThreadID'");
122 123
         list($LastRead) = $DB->next_record();
124
+
123 125
         if ($LastRead < $LastPost) {
124 126
             $DB->query("
125
-        INSERT INTO forums_last_read_topics
126
-          (UserID, TopicID, PostID)
127
-        VALUES
128
-          ('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."')
129
-        ON DUPLICATE KEY UPDATE
130
-          PostID = '$LastPost'");
127
+            INSERT INTO forums_last_read_topics
128
+              (UserID, TopicID, PostID)
129
+            VALUES
130
+              ('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."')
131
+            ON DUPLICATE KEY UPDATE
132
+              PostID = '$LastPost'");
131 133
         }
132 134
     }
133 135
 }
@@ -144,19 +146,19 @@ if (in_array($ThreadID, $UserSubscriptions)) {
144 146
 }
145 147
 
146 148
 $JsonPoll = [];
147
-if ($ThreadInfo['NoPoll'] == 0) {
149
+if ($ThreadInfo['NoPoll'] === 0) {
148 150
     if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value("polls_$ThreadID")) {
149 151
         $DB->query("
150
-      SELECT Question, Answers, Featured, Closed
151
-      FROM forums_polls
152
-      WHERE TopicID = '$ThreadID'");
152
+        SELECT Question, Answers, Featured, Closed
153
+        FROM forums_polls
154
+          WHERE TopicID = '$ThreadID'");
153 155
         list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1));
154 156
         $Answers = unserialize($Answers);
155 157
         $DB->query("
156
-      SELECT Vote, COUNT(UserID)
157
-      FROM forums_polls_votes
158
-      WHERE TopicID = '$ThreadID'
159
-      GROUP BY Vote");
158
+        SELECT Vote, COUNT(UserID)
159
+        FROM forums_polls_votes
160
+          WHERE TopicID = '$ThreadID'
161
+        GROUP BY Vote");
160 162
         $VoteArray = $DB->to_array(false, MYSQLI_NUM);
161 163
 
162 164
         $Votes = [];
@@ -186,18 +188,18 @@ if ($ThreadInfo['NoPoll'] == 0) {
186 188
     $DB->query("
187 189
     SELECT Vote
188 190
     FROM forums_polls_votes
189
-    WHERE UserID = '".$LoggedUser['ID']."'
191
+      WHERE UserID = '".$LoggedUser['ID']."'
190 192
       AND TopicID = '$ThreadID'");
191 193
     list($UserResponse) = $DB->next_record();
192
-    if (!empty($UserResponse) && $UserResponse != 0) {
193
-        $Answers[$UserResponse] = '&raquo; '.$Answers[$UserResponse];
194
+    if (!empty($UserResponse) && $UserResponse !== 0) {
195
+        $Answers[$UserResponse] = ' '.$Answers[$UserResponse];
194 196
     } else {
195 197
         if (!empty($UserResponse) && $RevealVoters) {
196
-            $Answers[$UserResponse] = '&raquo; '.$Answers[$UserResponse];
198
+            $Answers[$UserResponse] = ' '.$Answers[$UserResponse];
197 199
         }
198 200
     }
199 201
 
200
-    $JsonPoll['closed'] = ($Closed == 1);
202
+    $JsonPoll['closed'] = ($Closed === 1);
201 203
     $JsonPoll['featured'] = $Featured;
202 204
     $JsonPoll['question'] = $Question;
203 205
     $JsonPoll['maxVotes'] = (int)$MaxVotes;
@@ -213,9 +215,9 @@ if ($ThreadInfo['NoPoll'] == 0) {
213 215
             $Percent = 0;
214 216
         }
215 217
         $JsonPollAnswers[] = array(
216
-      'answer' => $Answer,
217
-      'ratio' => $Ratio,
218
-      'percent' => $Percent
218
+            'answer' => $Answer,
219
+            'ratio' => $Ratio,
220
+            'percent' => $Percent
219 221
     );
220 222
     }
221 223
 
@@ -230,10 +232,10 @@ if ($ThreadInfo['NoPoll'] == 0) {
230 232
 
231 233
 // Sqeeze in stickypost
232 234
 if ($ThreadInfo['StickyPostID']) {
233
-    if ($ThreadInfo['StickyPostID'] != $Thread[0]['ID']) {
235
+    if ($ThreadInfo['StickyPostID'] !== $Thread[0]['ID']) {
234 236
         array_unshift($Thread, $ThreadInfo['StickyPost']);
235 237
     }
236
-    if ($ThreadInfo['StickyPostID'] != $Thread[count($Thread) - 1]['ID']) {
238
+    if ($ThreadInfo['StickyPostID'] !== $Thread[count($Thread) - 1]['ID']) {
237 239
         $Thread[] = $ThreadInfo['StickyPost'];
238 240
     }
239 241
 }
@@ -274,8 +276,8 @@ print json_encode([
274 276
     'threadId' => (int)$ThreadID,
275 277
     'threadTitle' => display_str($ThreadInfo['Title']),
276 278
     'subscribed' => in_array($ThreadID, $UserSubscriptions),
277
-    'locked' => $ThreadInfo['IsLocked'] == 1,
278
-    'sticky' => $ThreadInfo['IsSticky'] == 1,
279
+    'locked' => $ThreadInfo['IsLocked'] === 1,
280
+    'sticky' => $ThreadInfo['IsSticky'] === 1,
279 281
     'currentPage' => (int)$Page,
280 282
     'pages' => ceil($ThreadInfo['Posts'] / $PerPage),
281 283
     'poll' => empty($JsonPoll) ? null : $JsonPoll,

+ 5
- 5
sections/artist/artist.php View File

@@ -167,7 +167,7 @@ foreach ($TorrentList as $GroupID => $Group) {
167 167
 }
168 168
 
169 169
 $OpenTable = false;
170
-$ShowGroups = !isset($LoggedUser['TorrentGrouping']) || $LoggedUser['TorrentGrouping'] == 0;
170
+$ShowGroups = !isset($LoggedUser['TorrentGrouping']) || $LoggedUser['TorrentGrouping'] === 0;
171 171
 $HideTorrents = ($ShowGroups ? '' : ' hidden');
172 172
 $OldGroupID = 0;
173 173
 ?>
@@ -242,7 +242,7 @@ foreach ($TorrentList as $Group) {
242 242
         $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : ''); ?>
243 243
     <tr class="group<?=$SnatchedGroupClass?>">
244 244
       <?php
245
-    $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); ?>
245
+    $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
246 246
       <td class="center">
247 247
         <div id="showimg_<?=$GroupID?>"
248 248
           class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
@@ -315,7 +315,7 @@ foreach ($TorrentList as $Group) {
315 315
       <td class="number_column"><?=number_format($Torrent['Snatched'])?>
316 316
       </td>
317 317
       <td
318
-        class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
318
+        class="number_column<?=(($Torrent['Seeders'] === 0) ? ' r00' : '')?>">
319 319
         <?=number_format($Torrent['Seeders'])?>
320 320
       </td>
321 321
       <td class="number_column"><?=number_format($Torrent['Leechers'])?>
@@ -443,7 +443,7 @@ foreach ($TorrentList as $Group) {
443 443
       <td class="number_column"><?=number_format($Torrent['Snatched'])?>
444 444
       </td>
445 445
       <td
446
-        class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
446
+        class="number_column<?=(($Torrent['Seeders'] === 0) ? ' r00' : '')?>">
447 447
         <?=number_format($Torrent['Seeders'])?>
448 448
       </td>
449 449
       <td class="number_column"><?=number_format($Torrent['Leechers'])?>
@@ -560,7 +560,7 @@ if (check_perms('site_torrents_notify')) {
560 560
               value="<?=$Name?>" />
561 561
             <input type="hidden" name="action" value="advanced" />
562 562
             <input type="text" autocomplete="off" id="filelist" name="filelist" size="20" />
563
-            <input type="submit" value="&gt;" />
563
+            <input type="submit" value="»" />
564 564
           </form>
565 565
         </li>
566 566
       </ul>

+ 339
- 252
sections/bookmarks/torrents.php View File

@@ -1,28 +1,31 @@
1 1
 <?php
2
+
3
+# todo: Go through line by line
2 4
 ini_set('max_execution_time', 600);
3 5
 set_time_limit(0);
4 6
 
5 7
 //~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
6 8
 
7
-function compare($X, $Y) {
8
-  return($Y['count'] - $X['count']);
9
+function compare($X, $Y)
10
+{
11
+    return($Y['count'] - $X['count']);
9 12
 }
10 13
 
11 14
 if (!empty($_GET['userid'])) {
12
-  if (!check_perms('users_override_paranoia')) {
13
-    error(403);
14
-  }
15
-  $UserID = $_GET['userid'];
16
-  if (!is_number($UserID)) {
17
-    error(404);
18
-  }
19
-  $DB->query("
15
+    if (!check_perms('users_override_paranoia')) {
16
+        error(403);
17
+    }
18
+    $UserID = $_GET['userid'];
19
+    if (!is_number($UserID)) {
20
+        error(404);
21
+    }
22
+    $DB->query("
20 23
     SELECT Username
21 24
     FROM users_main
22 25
     WHERE ID = '$UserID'");
23
-  list($Username) = $DB->next_record();
26
+    list($Username) = $DB->next_record();
24 27
 } else {
25
-  $UserID = $LoggedUser['ID'];
28
+    $UserID = $LoggedUser['ID'];
26 29
 }
27 30
 
28 31
 $Sneaky = $UserID !== $LoggedUser['ID'];
@@ -38,310 +41,394 @@ $ArtistCount = [];
38 41
 
39 42
 list($GroupIDs, $CollageDataList, $TorrentList) = Users::get_bookmarks($UserID);
40 43
 foreach ($GroupIDs as $GroupID) {
41
-  if (!isset($TorrentList[$GroupID])) {
42
-    continue;
43
-  }
44
-  $Group = $TorrentList[$GroupID];
45
-  extract(Torrents::array_group($Group));
46
-  list(, $Sort, $AddedTime) = array_values($CollageDataList[$GroupID]);
47
-
48
-  // Handle stats and stuff
49
-  $NumGroups++;
50
-
51
-  if ($Artists) {
52
-    foreach ($Artists as $Artist) {
53
-      if (!isset($ArtistCount[$Artist['id']])) {
54
-        $ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
55
-      } else {
56
-        $ArtistCount[$Artist['id']]['count']++;
57
-      }
44
+    if (!isset($TorrentList[$GroupID])) {
45
+        continue;
58 46
     }
59
-  }
47
+    $Group = $TorrentList[$GroupID];
48
+    extract(Torrents::array_group($Group));
49
+    list(, $Sort, $AddedTime) = array_values($CollageDataList[$GroupID]);
60 50
 
61
-  $TorrentTags = new Tags($TagList);
51
+    // Handle stats and stuff
52
+    $NumGroups++;
62 53
 
63
-  $DisplayName = Artists::display_artists($Artists);
64
-
65
-  $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
66
-
67
-  $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" ';
68
-  if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
69
-    $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
70
-  }
71
-  $DisplayName .= ' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
72
-  if ($GroupYear > 0) {
73
-    $DisplayName = "$DisplayName [$GroupYear]";
74
-  }
75
-  $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
76
-
77
-  // Start an output buffer, so we can store this output in $TorrentTable
78
-  ob_start();
79
-  if (count($Torrents) > 1) {
80
-      // Grouped torrents
81
-      $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1);
82
-?>
83
-      <tr class="group" id="group_<?=$GroupID?>">
84
-        <td class="center">
85
-          <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
86
-            <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collape all groups on this page."></a>
87
-          </div>
88
-        </td>
89
-        <td class="center">
90
-          <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div>
91
-        </td>
92
-        <td colspan="5">
93
-          <?=$DisplayName?>
94
-          <span style="text-align: right;" class="float_right">
95
-            <?=time_diff($AddedTime);?>
96
-<?    if (!$Sneaky) { ?>
97
-            <br />
98
-            <a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a>
99
-<?    } ?>
100
-          </span>
101
-          <div class="tags"><?=$TorrentTags->format()?></div>
102
-        </td>
103
-      </tr>
104
-<?
105
-    foreach ($Torrents as $TorrentID => $Torrent) {
106
-      $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
107
-?>
108
-  <tr class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
109
-    <td colspan="3">
110
-      <span>[ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
111
-<?      if (Torrents::can_use_token($Torrent)) { ?>
112
-      | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
113
-<?      } ?>
114
-      | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
115
-      </span>
116
-      &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
117
-    </td>
118
-    <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
119
-    <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
120
-    <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
121
-    <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
122
-  </tr>
123
-<?
54
+    if ($Artists) {
55
+        foreach ($Artists as $Artist) {
56
+            if (!isset($ArtistCount[$Artist['id']])) {
57
+                $ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
58
+            } else {
59
+                $ArtistCount[$Artist['id']]['count']++;
60
+            }
61
+        }
124 62
     }
125
-  } else {
126
-    // Viewing a type that does not require grouping
127 63
 
128
-    $TorrentID = key($Torrents);
129
-    $Torrent = current($Torrents);
64
+    $TorrentTags = new Tags($TagList);
65
+
66
+    $DisplayName = Artists::display_artists($Artists);
130 67
 
131
-    $DisplayName = Artists::display_artists(Artists::get_artist($GroupID));
68
+    $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
132 69
 
133 70
     $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" ';
134 71
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
135
-      $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
72
+        $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
136 73
     }
137
-    $DisplayName .=' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
74
+    $DisplayName .= ' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
75
+    if ($GroupYear > 0) {
76
+        $DisplayName = "$DisplayName [$GroupYear]";
77
+    }
78
+    $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
79
+
80
+    // Start an output buffer, so we can store this output in $TorrentTable
81
+    ob_start();
82
+    if (count($Torrents) > 1) {
83
+        // Grouped torrents
84
+        $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
138 85
 
139
-    if ($Torrent['IsSnatched']) {
140
-      $DisplayName .= ' ' . Format::torrent_label('Snatched!');
86
+<tr class="group" id="group_<?=$GroupID?>">
87
+  <td class="center">
88
+    <div id="showimg_<?=$GroupID?>"
89
+      class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
90
+      <a class="tooltip show_torrents_link"
91
+        onclick="toggle_group(<?=$GroupID?>, this, event);"
92
+        title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collape all groups on this page."></a>
93
+    </div>
94
+  </td>
95
+  <td class="center">
96
+    <div title="<?=$TorrentTags->title()?>"
97
+      class="tooltip <?=Format::css_category($GroupCategoryID)?>">
98
+    </div>
99
+  </td>
100
+  <td colspan="5">
101
+    <?=$DisplayName?>
102
+    <span style="text-align: right;" class="float_right">
103
+      <?=time_diff($AddedTime); ?>
104
+      <?php if (!$Sneaky) { ?>
105
+      <br />
106
+      <a href="#group_<?=$GroupID?>" class="brackets remove_bookmark"
107
+        onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove
108
+        bookmark</a>
109
+      <?php } ?>
110
+    </span>
111
+    <div class="tags"><?=$TorrentTags->format()?>
112
+    </div>
113
+  </td>
114
+</tr>
115
+<?php
116
+    foreach ($Torrents as $TorrentID => $Torrent) {
117
+        $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>
118
+<tr
119
+  class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
120
+  <td colspan="3">
121
+    <span>[ <a
122
+        href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
123
+        class="tooltip" title="Download">DL</a>
124
+      <?php if (Torrents::can_use_token($Torrent)) { ?>
125
+      | <a
126
+        href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
127
+        class="tooltip" title="Use a FL Token"
128
+        onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
129
+      <?php } ?>
130
+      | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
131
+        class="tooltip" title="Report">RP</a> ]
132
+    </span>
133
+    &nbsp;&nbsp;&raquo;&nbsp; <a
134
+      href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
135
+  </td>
136
+  <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
137
+  </td>
138
+  <td class="number_column"><?=number_format($Torrent['Snatched'])?>
139
+  </td>
140
+  <td
141
+    class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
142
+    <?=number_format($Torrent['Seeders'])?>
143
+  </td>
144
+  <td class="number_column"><?=number_format($Torrent['Leechers'])?>
145
+  </td>
146
+</tr>
147
+<?php
141 148
     }
142
-    if ($Torrent['FreeTorrent'] === '1') {
143
-      $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
144
-    } elseif ($Torrent['FreeTorrent'] === '2') {
145
-      $DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
146
-    } elseif ($Torrent['PersonalFL']) {
147
-      $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
149
+    } else {
150
+        // Viewing a type that does not require grouping
151
+
152
+        $TorrentID = key($Torrents);
153
+        $Torrent = current($Torrents);
154
+
155
+        $DisplayName = Artists::display_artists(Artists::get_artist($GroupID));
156
+
157
+        $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" ';
158
+        if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
159
+            $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
160
+        }
161
+        $DisplayName .=' class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
162
+
163
+        if ($Torrent['IsSnatched']) {
164
+            $DisplayName .= ' ' . Format::torrent_label('Snatched!');
165
+        }
166
+        if ($Torrent['FreeTorrent'] === '1') {
167
+            $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
168
+        } elseif ($Torrent['FreeTorrent'] === '2') {
169
+            $DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
170
+        } elseif ($Torrent['PersonalFL']) {
171
+            $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
172
+        }
173
+        $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>
174
+<tr
175
+  class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>"
176
+  id="group_<?=$GroupID?>">
177
+  <td></td>
178
+  <td class="center">
179
+    <div title="<?=$TorrentTags->title()?>"
180
+      class="tooltip <?=Format::css_category($GroupCategoryID)?>">
181
+    </div>
182
+  </td>
183
+  <td>
184
+    <span>
185
+      [ <a
186
+        href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
187
+        class="tooltip" title="Download">DL</a>
188
+      <?php if (Torrents::can_use_token($Torrent)) { ?>
189
+      | <a
190
+        href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
191
+        class="tooltip" title="Use a FL Token"
192
+        onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
193
+      <?php } ?>
194
+      | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
195
+        class="tooltip" title="Report">RP</a> ]
196
+    </span>
197
+    <span class="float_right float_clear"><?=time_diff($AddedTime); ?></span>
198
+    <?php if (!$Sneaky) { ?>
199
+    <span class="float_right float_clear"><a
200
+        href="#group_<?=$GroupID?>" class="brackets remove_bookmark"
201
+        onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove
202
+        bookmark</a></span>
203
+    <?php } ?>
204
+    <?=$DisplayName?>
205
+    <div class="tags"><?=$TorrentTags->format()?>
206
+    </div>
207
+
208
+  </td>
209
+  <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
210
+  </td>
211
+  <td class="number_column"><?=number_format($Torrent['Snatched'])?>
212
+  </td>
213
+  <td
214
+    class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
215
+    <?=number_format($Torrent['Seeders'])?>
216
+  </td>
217
+  <td class="number_column"><?=number_format($Torrent['Leechers'])?>
218
+  </td>
219
+</tr>
220
+<?php
148 221
     }
149
-    $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
150
-?>
151
-  <tr class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>" id="group_<?=$GroupID?>">
152
-    <td></td>
153
-    <td class="center">
154
-      <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>">
155
-      </div>
156
-    </td>
157
-    <td>
158
-      <span>
159
-        [ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
160
-<?    if (Torrents::can_use_token($Torrent)) { ?>
161
-        | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
162
-<?    } ?>
163
-        | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
164
-      </span>
165
-      <span class="float_right float_clear"><?=time_diff($AddedTime);?></span>
166
-<?    if (!$Sneaky) { ?>
167
-      <span class="float_right float_clear"><a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a></span>
168
-<?    } ?>
169
-      <?=$DisplayName?>
170
-      <div class="tags"><?=$TorrentTags->format()?></div>
171
-
172
-    </td>
173
-    <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
174
-    <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
175
-    <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
176
-    <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
177
-  </tr>
178
-<?
179
-  }
180
-  $TorrentTable .= ob_get_clean();
222
+    $TorrentTable .= ob_get_clean();
181 223
 
182
-  // Album art
224
+    // Album art
183 225
 
184
-  ob_start();
226
+    ob_start();
185 227
 
186
-  $DisplayName = '';
228
+    $DisplayName = '';
187 229
 
188
-  $DisplayName .= Artists::display_artists($Artists, false);
230
+    $DisplayName .= Artists::display_artists($Artists, false);
189 231
 
190
-  $DisplayName .= $GroupName;
191
-  if ($GroupYear > 0) {
192
-    $DisplayName = "$DisplayName [$GroupYear]";
193
-  }
194
-  $Tags = display_str($TorrentTags->format());
195
-  $PlainTags = implode(', ', $TorrentTags->get_tags());
196
-?>
232
+    $DisplayName .= $GroupName;
233
+    if ($GroupYear > 0) {
234
+        $DisplayName = "$DisplayName [$GroupYear]";
235
+    }
236
+    $Tags = display_str($TorrentTags->format());
237
+    $PlainTags = implode(', ', $TorrentTags->get_tags()); ?>
197 238
 <div class='collage_image image_group_<?=$GroupID?>'>
198
-      <a href="torrents.php?id=<?=$GroupID?>" class="bookmark_<?=$GroupID?>">
199
-<?  if (!$WikiImage) {
200
-      $WikiImage = STATIC_SERVER.'common/noartwork/music.png';
201
-} ?>
202
-        <img class="tooltip_interactive" src="<?=ImageTools::process($WikiImage, 'thumb')?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?> <br /> <?=$Tags?>" data-title-plain="<?="$DisplayName ($PlainTags)"?>" width="100%" />
203
-      </a>
204
-    </div>
239
+  <a href="torrents.php?id=<?=$GroupID?>"
240
+    class="bookmark_<?=$GroupID?>">
241
+    <?php if (!$WikiImage) {
242
+        $WikiImage = STATIC_SERVER.'common/noartwork/music.png';
243
+    } ?>
244
+    <img class="tooltip_interactive"
245
+      src="<?=ImageTools::process($WikiImage, 'thumb')?>"
246
+      alt="<?=$DisplayName?>"
247
+      title="<?=$DisplayName?> <br /> <?=$Tags?>"
248
+      data-title-plain="<?="$DisplayName ($PlainTags)"?>"
249
+      width="100%" />
250
+  </a>
251
+</div>
205 252
 
206
-<?
253
+<?php
207 254
   $Collage[] = ob_get_clean();
208
-
209 255
 }
210 256
 
211 257
 $CollageCovers = isset($LoggedUser['CollageCovers']) ? (int)$LoggedUser['CollageCovers'] : 10;
212 258
 $CollagePages = [];
213 259
 if ($CollageCovers > 0) {
214
-  for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
215
-    $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
216
-    $CollagePage = '';
217
-    foreach ($Groups as $Group) {
218
-      $CollagePage .= $Group;
260
+    for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
261
+        $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
262
+        $CollagePage = '';
263
+        foreach ($Groups as $Group) {
264
+            $CollagePage .= $Group;
265
+        }
266
+        $CollagePages[] = $CollagePage;
219 267
     }
220
-    $CollagePages[] = $CollagePage;
221
-  }
222 268
 }
223 269
 
224 270
 View::show_header($Title, 'browse,collage,wall');
225 271
 ?>
226 272
 <div class="thin">
227 273
   <div class="header">
228
-    <h2><? if (!$Sneaky) { ?><a href="feeds.php?feed=torrents_bookmarks_t_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode(SITE_NAME.': Bookmarked Torrents')?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>&nbsp;<? } ?><?=$Title?></h2>
274
+    <h2><?php if (!$Sneaky) { ?><a
275
+        href="feeds.php?feed=torrents_bookmarks_t_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode(SITE_NAME.': Bookmarked Torrents')?>"><img
276
+          src="<?=STATIC_SERVER?>/common/symbols/rss.png"
277
+          alt="RSS feed" /></a>&nbsp;<?php } ?><?=$Title?>
278
+    </h2>
229 279
     <div class="linkbox">
230 280
       <a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
231 281
       <a href="bookmarks.php?type=artists" class="brackets">Artists</a>
232 282
       <a href="bookmarks.php?type=collages" class="brackets">Collections</a>
233 283
       <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
234
-<? if (count($TorrentList) > 0) { ?>
284
+      <?php if (count($TorrentList) > 0) { ?>
235 285
       <br /><br />
236
-      <a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">Remove snatched</a>
286
+      <a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>"
287
+        class="brackets"
288
+        onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">Remove
289
+        snatched</a>
237 290
       <a href="bookmarks.php?action=edit&amp;type=torrents" class="brackets">Manage torrents</a>
238
-<? } ?>
291
+      <?php } ?>
239 292
     </div>
240 293
   </div>
241
-<? if (count($TorrentList) === 0) { ?>
294
+  <?php if (count($TorrentList) === 0) { ?>
242 295
   <div class="box pad" align="center">
243 296
     <h2>You have not bookmarked any torrents.</h2>
244 297
   </div>
245
-</div><!--content-->
246
-<?
298
+</div>
299
+<!--content-->
300
+<?php
247 301
   View::show_footer();
248 302
   die();
249 303
 } ?>
250
-  <div class="sidebar">
251
-    <div class="box box_info box_statistics_bookmarked_torrents">
252
-      <div class="head"><strong>Stats</strong></div>
253
-      <ul class="stats nobullet">
254
-        <li>Torrent groups: <?=$NumGroups?></li>
255
-        <li>Artists: <?=count($ArtistCount)?></li>
256
-      </ul>
257
-    </div>
258
-    <div class="box box_tags">
259
-      <div class="head"><strong>Top Tags</strong></div>
260
-      <div class="pad">
261
-        <ol style="padding-left: 5px;">
262
-<? Tags::format_top(5) ?>
263
-        </ol>
264
-      </div>
304
+<div class="sidebar">
305
+  <div class="box box_info box_statistics_bookmarked_torrents">
306
+    <div class="head"><strong>Stats</strong></div>
307
+    <ul class="stats nobullet">
308
+      <li>Torrent groups: <?=$NumGroups?>
309
+      </li>
310
+      <li>Artists: <?=count($ArtistCount)?>
311
+      </li>
312
+    </ul>
313
+  </div>
314
+  <div class="box box_tags">
315
+    <div class="head"><strong>Top Tags</strong></div>
316
+    <div class="pad">
317
+      <ol style="padding-left: 5px;">
318
+        <?php Tags::format_top(5) ?>
319
+      </ol>
265 320
     </div>
266
-    <div class="box box_artists">
267
-      <div class="head"><strong>Top Artists</strong></div>
268
-      <div class="pad">
269
-<?
321
+  </div>
322
+  <div class="box box_artists">
323
+    <div class="head"><strong>Top Artists</strong></div>
324
+    <div class="pad">
325
+      <?php
270 326
   $Indent = "\t\t\t\t";
271 327
   if (count($ArtistCount) > 0) {
272
-    echo "$Indent<ol style=\"padding-left: 5px;\">\n";
273
-    uasort($ArtistCount, 'compare');
274
-    $i = 0;
275
-    foreach ($ArtistCount as $ID => $Artist) {
276
-      $i++;
277
-      if ($i > 10) {
278
-        break;
328
+      echo "$Indent<ol style=\"padding-left: 5px;\">\n";
329
+      uasort($ArtistCount, 'compare');
330
+      $i = 0;
331
+      foreach ($ArtistCount as $ID => $Artist) {
332
+          $i++;
333
+          if ($i > 10) {
334
+              break;
335
+          } ?>
336
+      <li><a href="artist.php?id=<?=$ID?>"><?=display_str($Artist['name'])?></a> (<?=$Artist['count']?>)</li>
337
+      <?php
279 338
       }
280
-?>
281
-          <li><a href="artist.php?id=<?=$ID?>"><?=display_str($Artist['name'])?></a> (<?=$Artist['count']?>)</li>
282
-<?
283
-    }
284
-    echo "$Indent</ol>\n";
339
+      echo "$Indent</ol>\n";
285 340
   } else {
286
-    echo "$Indent<ul class=\"nobullet\" style=\"padding-left: 5px;\">\n";
287
-    echo "$Indent\t<li>There are no artists to display.</li>\n";
288
-    echo "$Indent</ul>\n";
341
+      echo "$Indent<ul class=\"nobullet\" style=\"padding-left: 5px;\">\n";
342
+      echo "$Indent\t<li>There are no artists to display.</li>\n";
343
+      echo "$Indent</ul>\n";
289 344
   }
290 345
 ?>
291
-      </div>
292 346
     </div>
293 347
   </div>
294
-  <div class="main_column">
295
-<?
348
+</div>
349
+<div class="main_column">
350
+  <?php
296 351
 if ($CollageCovers !== 0) { ?>
297
-    <div id="coverart" class="box">
298
-      <div class="head" id="coverhead"><strong>Cover art</strong></div>
299
-      <div class="collage_images" id="collage_page0" data-wall-child=".collage_image" data-wall-size="4", data-wall-min="2">
300
-<?
352
+  <div id="coverart" class="box">
353
+    <div class="head" id="coverhead"><strong>Cover art</strong></div>
354
+    <div class="collage_images" id="collage_page0" data-wall-child=".collage_image" data-wall-size="4" ,
355
+      data-wall-min="2">
356
+      <?php
301 357
   $Page1 = array_slice($Collage, 0, $CollageCovers);
302 358
   foreach ($Page1 as $Group) {
303
-    echo $Group;
359
+      echo $Group;
304 360
   }
305 361
 ?>
306
-      </div>
307
-    </div>
308
-<?  if ($NumGroups > $CollageCovers) { ?>
309
-    <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
310
-      <span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">&lt;&lt; First</a> | </span>
311
-      <span id="prevpage" class="invisible"><a href="#" id="prevpage" class="pageslink" onclick="collageShow.prevPage(); return false;">&lt; Prev</a> | </span>
312
-<?    for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
313
-      <span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i === 0) ? ' selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); wall('.collage_images', '.collage_image', 4); return false;"><?=($CollageCovers * $i + 1)?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></a><?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
314
-<?    } ?>
315
-      <span id="nextbar" class="<?=(($NumGroups / $CollageCovers > 5) ? 'hidden' : '')?>"> | </span>
316
-      <span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); wall('.collage_images', '.collage_image', 4); return false;">Next &gt;</a></span>
317
-      <span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>"> | <a href="#" id="lastpage" class="pageslink" onclick="collageShow.page(<?=(ceil($NumGroups / $CollageCovers) - 1)?>, this); return false;">Last &gt;&gt;</a></span>
318 362
     </div>
319
-    <script type="text/javascript">
320
-      $(()=>collageShow.init(<?=json_encode($CollagePages)?>));
321
-    </script>
322
-<?
363
+  </div>
364
+  <?php if ($NumGroups > $CollageCovers) { ?>
365
+  <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
366
+    <span id="firstpage" class="invisible">
367
+      <a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">‹ First</a> |
368
+    </span>
369
+    <span id="prevpage" class="invisible">
370
+      <a href="#" id="prevpage" class="pageslink" onclick="collageShow.prevPage(); return false;">&lsaquo; Prev</a> |
371
+    </span>
372
+    <?php for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
373
+    <span id="pagelink<?=$i?>"
374
+      class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i === 0) ? ' selected' : '')?>">
375
+      <a href="#" class="pageslink"
376
+        onclick="collageShow.page(<?=$i?>, this); wall('.collage_images', '.collage_image', 4); return false;"><?=($CollageCovers * $i + 1)?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></a>
377
+      <?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?>
378
+    </span>
379
+    <?php } ?>
380
+    <span id="nextbar"
381
+      class="<?=(($NumGroups / $CollageCovers > 5) ? 'hidden' : '')?>">
382
+      | </span>
383
+    <span id="nextpage">
384
+      <a href="#" class="pageslink"
385
+        onclick="collageShow.nextPage(); wall('.collage_images', '.collage_image', 4); return false;">Next ›</a>
386
+    </span>
387
+    <span id="lastpage"
388
+      class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>">
389
+      | <a href="#" id="lastpage" class="pageslink"
390
+        onclick="collageShow.page(<?=(ceil($NumGroups / $CollageCovers) - 1)?>, this); return false;">Last
391
+        »</a>
392
+    </span>
393
+  </div>
394
+
395
+  <script type="text/javascript">
396
+    $(() => collageShow.init( <?=json_encode($CollagePages)?> ));
397
+  </script>
398
+  <?php
323 399
   }
324 400
 }
325 401
 ?>
326
-    <table class="torrent_table grouping cats" id="torrent_table">
327
-      <tr class="colhead_dark">
328
-        <td><!-- expand/collapse --></td>
329
-        <td><!-- Category --></td>
330
-        <td width="70%"><strong>Torrents</strong></td>
331
-        <td>Size</td>
332
-        <td class="sign snatches">
333
-          <a><svg width="15" height="15" fill="black" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></a>
334
-        </td>
335
-        <td class="sign seeders">
336
-          <a><svg width="11" height="15" fill="black" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></a>
337
-        </td>
338
-        <td class="sign leechers">
339
-          <a><svg width="11" height="15" fill="black" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></a>
340
-        </td>
341
-      </tr>
342
-<?=$TorrentTable?>
343
-    </table>
344
-  </div>
402
+
403
+  <table class="torrent_table grouping cats" id="torrent_table">
404
+    <tr class="colhead_dark">
405
+      <td>
406
+        <!-- Expand/Collapse -->
407
+      </td>
408
+      <td>
409
+        <!-- Category -->
410
+      </td>
411
+      <td width="70%"><strong>Torrents</strong></td>
412
+      <td>Size</td>
413
+      <td class="sign snatches">
414
+        <a><svg width="15" height="15" fill="black" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98">
415
+            <path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path>
416
+          </svg></a>
417
+      </td>
418
+      <td class="sign seeders">
419
+        <a><svg width="11" height="15" fill="black" class="tooltip" alt="Seeders" title="Seeders">
420
+            <polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon>
421
+          </svg></a>
422
+      </td>
423
+      <td class="sign leechers">
424
+        <a><svg width="11" height="15" fill="black" class="tooltip" alt="Leechers" title="Leechers">
425
+            <polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon>
426
+          </svg></a>
427
+      </td>
428
+    </tr>
429
+    <?=$TorrentTable?>
430
+  </table>
431
+</div>
345 432
 </div>
346
-<?
347
-View::show_footer();
433
+
434
+<?php View::show_footer();

+ 18
- 11
sections/collages/all_comments.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 /**********|| Page to show individual threads || ********************************\
3 4
 
4 5
 Things to expect in $_GET:
@@ -12,7 +13,7 @@ Things to expect in $_GET:
12 13
 
13 14
 // Check for lame SQL injection attempts
14 15
 if (!is_number($_GET['collageid'])) {
15
-  error(0);
16
+    error(0);
16 17
 }
17 18
 $CollageID = (int)$_GET['collageid'];
18 19
 
@@ -27,29 +28,33 @@ list($Name) = $DB->next_record();
27 28
 // Start printing
28 29
 View::show_header("Comments for collage $Name", 'comments,bbcode,subscriptions');
29 30
 ?>
31
+
30 32
 <div class="thin">
31 33
   <div class="header">
32 34
     <h2>
33
-      <a href="collages.php">Collages</a> &gt;
35
+      <a href="collages.php">Collages</a> 
34 36
       <a href="collages.php?id=<?=$CollageID?>"><?=$Name?></a>
35 37
     </h2>
38
+
36 39
     <div class="linkbox">
37
-      <a href="#" id="subscribelink_collages<?=$CollageID?>" class="brackets" onclick="SubscribeComments('collages', <?=$CollageID?>); return false;"><?=Subscriptions::has_subscribed_comments('collages', $CollageID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
38
-<?
40
+      <a href="#" id="subscribelink_collages<?=$CollageID?>"
41
+        class="brackets"
42
+        onclick="SubscribeComments('collages', <?=$CollageID?>); return false;"><?=Subscriptions::has_subscribed_comments('collages', $CollageID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
43
+      <?php
39 44
 $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9);
40 45
 if ($Pages) {
41
-  echo '<br /><br />' . $Pages;
46
+    echo '<br /><br />' . $Pages;
42 47
 }
43 48
 ?>
44 49
     </div>
45 50
   </div>
46
-<?
47 51
 
52
+  <?php
48 53
 //---------- Begin printing
49 54
 CommentsView::render_comments($Thread, $LastRead, "collages.php?action=comments&amp;collageid=$CollageID");
50 55
 if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
51
-  if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
52
-    View::parse('generic/reply/quickreply.php', array(
56
+    if ($ThreadInfo['MinClassWrite'] <= $LoggedUser['Class'] && !$LoggedUser['DisablePosting']) {
57
+        View::parse('generic/reply/quickreply.php', array(
53 58
       'InputName' => 'pageid',
54 59
       'InputID' => $CollageID,
55 60
       'Action' => 'comments.php?page=collages',
@@ -57,11 +62,13 @@ if (!$ThreadInfo['IsLocked'] || check_perms('site_moderate_forums')) {
57 62
       'TextareaCols' => 90,
58 63
       'SubscribeBox' => true
59 64
     ));
60
-  }
65
+    }
61 66
 }
62 67
 ?>
68
+
63 69
   <div class="linkbox">
64 70
     <?=$Pages?>
65 71
   </div>
66 72
 </div>
67
-<? View::show_footer(); ?>
73
+
74
+<?php View::show_footer();

+ 206
- 122
sections/collages/artist_collage.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 // todo: Cache this
3 4
 $DB->query("
4 5
   SELECT
@@ -24,42 +25,44 @@ $NumGroupsByUser = 0;
24 25
 $UserAdditions = [];
25 26
 
26 27
 foreach ($Artists as $Artist) {
27
-  $UserID = $Artist['UserID'];
28
-  if ($UserID == $LoggedUser['ID']) {
29
-    $NumGroupsByUser++;
30
-  }
28
+    $UserID = $Artist['UserID'];
29
+    if ($UserID === $LoggedUser['ID']) {
30
+        $NumGroupsByUser++;
31
+    }
31 32
 
32
-  if (!isset($UserAdditions[$UserID])) {
33
-    $UserAdditions[$UserID] = 0;
34
-  }
35
-  $UserAdditions[$UserID]++;
33
+    if (!isset($UserAdditions[$UserID])) {
34
+        $UserAdditions[$UserID] = 0;
35
+    }
36
+    $UserAdditions[$UserID]++;
36 37
 
37
-  ob_start();
38
-?>
39
-      <tr>
40
-        <td><a href="artist.php?id=<?=$Artist['ArtistID']?>"><?=$Artist['Name']?></a></td>
41
-      </tr>
42
-<?
38
+    ob_start(); ?>
39
+<tr>
40
+  <td><a
41
+      href="artist.php?id=<?=$Artist['ArtistID']?>"><?=$Artist['Name']?></a></td>
42
+</tr>
43
+<?php
43 44
   $ArtistTable .= ob_get_clean();
44 45
 
45
-  ob_start();
46
-  ?>
47
-        <li class="image_group_<?=$Artist['ArtistID']?>">
48
-          <a href="artist.php?id=<?=$Artist['ArtistID']?>">
49
-<?  if ($Artist['Image']) { ?>
50
-            <img class="tooltip" src="<?=ImageTools::process($Artist['Image'], 'thumb')?>" alt="<?=$Artist['Name']?>" title="<?=$Artist['Name']?>" width="118" />
51
-<?  } else { ?>
52
-            <span style="width: 107px; padding: 5px;"><?=$Artist['Name']?></span>
53
-<?  } ?>
54
-          </a>
55
-        </li>
56
-<?
46
+    ob_start(); ?>
47
+<li class="image_group_<?=$Artist['ArtistID']?>">
48
+  <a
49
+    href="artist.php?id=<?=$Artist['ArtistID']?>">
50
+    <?php if ($Artist['Image']) { ?>
51
+    <img class="tooltip"
52
+      src="<?=ImageTools::process($Artist['Image'], 'thumb')?>"
53
+      alt="<?=$Artist['Name']?>"
54
+      title="<?=$Artist['Name']?>" width="118" />
55
+    <?php } else { ?>
56
+    <span style="width: 107px; padding: 5px;"><?=$Artist['Name']?></span>
57
+    <?php } ?>
58
+  </a>
59
+</li>
60
+<?php
57 61
   $Collage[] = ob_get_clean();
58 62
 }
59 63
 
60
-
61 64
 if (!check_perms('site_collages_delete') && ($Locked || ($MaxGroups > 0 && $NumGroups >= $MaxGroups) || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser))) {
62
-  $PreventAdditions = true;
65
+    $PreventAdditions = true;
63 66
 }
64 67
 
65 68
 // Silly hack for people who are on the old setting
@@ -68,108 +71,139 @@ $CollagePages = [];
68 71
 
69 72
 // Pad it out
70 73
 if ($NumGroups > $CollageCovers) {
71
-  for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $CollageCovers) * $CollageCovers; $i++) {
72
-    $Collage[] = '<li></li>';
73
-  }
74
+    for ($i = $NumGroups + 1; $i <= ceil($NumGroups / $CollageCovers) * $CollageCovers; $i++) {
75
+        $Collage[] = '<li></li>';
76
+    }
74 77
 }
75 78
 
76 79
 for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
77
-  $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
78
-  $CollagePage = '';
79
-  foreach ($Groups as $Group) {
80
-    $CollagePage .= $Group;
81
-  }
82
-  $CollagePages[] = $CollagePage;
80
+    $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
81
+    $CollagePage = '';
82
+    foreach ($Groups as $Group) {
83
+        $CollagePage .= $Group;
84
+    }
85
+    $CollagePages[] = $CollagePage;
83 86
 }
84 87
 
85 88
 View::show_header($Name, 'browse,collage,bbcode,recommend');
86
-
87 89
 ?>
90
+
88 91
 <div class="thin">
89 92
   <div class="header">
90
-    <h2><?=$Name?></h2>
93
+    <h2><?=$Name?>
94
+    </h2>
91 95
     <div class="linkbox">
92 96
       <a href="collages.php" class="brackets">List of collections</a>
93
-<?  if (check_perms('site_collages_create')) { ?>
97
+      <?php if (check_perms('site_collages_create')) { ?>
94 98
       <a href="collages.php?action=new" class="brackets">New collage</a>
95
-<?  } ?>
99
+      <?php } ?>
96 100
       <br /><br />
97
-<?  if (check_perms('site_collages_subscribe')) { ?>
98
-      <a href="#" id="subscribelink<?=$CollageID?>" class="brackets" onclick="CollageSubscribe(<?=$CollageID?>); return false;"><?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
99
-<?
101
+      <?php if (check_perms('site_collages_subscribe')) { ?>
102
+      <a href="#" id="subscribelink<?=$CollageID?>" class="brackets"
103
+        onclick="CollageSubscribe(<?=$CollageID?>); return false;"><?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
104
+      <?php
100 105
   }
101 106
   if (check_perms('site_collages_delete') || (check_perms('site_edit_wiki') && !$Locked)) {
102
-?>
103
-      <a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>" class="brackets">Edit description</a>
104
-<?  } else { ?>
107
+      ?>
108
+      <a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>"
109
+        class="brackets">Edit description</a>
110
+      <?php
111
+  } else { ?>
105 112
       <span class="brackets">Locked</span>
106
-<?
113
+      <?php
107 114
   }
108 115
   if (Bookmarks::has_bookmarked('collage', $CollageID)) {
109
-?>
110
-      <a href="#" id="bookmarklink_collage_<?=$CollageID?>" class="brackets" onclick="Unbookmark('collage', <?=$CollageID?>, 'Bookmark'); return false;">Remove bookmark</a>
111
-<?  } else { ?>
112
-      <a href="#" id="bookmarklink_collage_<?=$CollageID?>" class="brackets" onclick="Bookmark('collage', <?=$CollageID?>, 'Remove bookmark'); return false;">Bookmark</a>
113
-<?
116
+      ?>
117
+      <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
118
+        class="brackets"
119
+        onclick="Unbookmark('collage', <?=$CollageID?>, 'Bookmark'); return false;">Remove
120
+        bookmark</a>
121
+      <?php
122
+  } else { ?>
123
+      <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
124
+        class="brackets"
125
+        onclick="Bookmark('collage', <?=$CollageID?>, 'Remove bookmark'); return false;">Bookmark</a>
126
+      <?php
114 127
   }
115 128
   if (check_perms('site_collages_manage') && !$Locked) {
116
-?>
117
-      <a href="collages.php?action=manage_artists&amp;collageid=<?=$CollageID?>" class="brackets">Manage artists</a>
118
-<?  } ?>
119
-      <a href="reports.php?action=report&amp;type=collage&amp;id=<?=$CollageID?>" class="brackets">Report collage</a>
120
-<?  if (check_perms('site_collages_delete') || $CreatorID == $LoggedUser['ID']) { ?>
121
-      <a href="collages.php?action=delete&amp;collageid=<?=$CollageID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to delete this collage?');">Delete</a>
122
-<?  } ?>
129
+      ?>
130
+      <a href="collages.php?action=manage_artists&amp;collageid=<?=$CollageID?>"
131
+        class="brackets">Manage artists</a>
132
+      <?php
133
+  } ?>
134
+      <a href="reports.php?action=report&amp;type=collage&amp;id=<?=$CollageID?>"
135
+        class="brackets">Report collage</a>
136
+      <?php if (check_perms('site_collages_delete') || $CreatorID === $LoggedUser['ID']) { ?>
137
+      <a href="collages.php?action=delete&amp;collageid=<?=$CollageID?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
138
+        class="brackets" onclick="return confirm('Are you sure you want to delete this collage?');">Delete</a>
139
+      <?php } ?>
123 140
     </div>
124 141
   </div>
142
+
125 143
   <div class="sidebar">
126 144
     <div class="box box_category">
127 145
       <div class="head"><strong>Category</strong></div>
128
-      <div class="pad"><a href="collages.php?action=search&amp;cats[<?=(int)$CollageCategoryID?>]=1"><?=$CollageCats[(int)$CollageCategoryID]?></a></div>
146
+      <div class="pad"><a
147
+          href="collages.php?action=search&amp;cats[<?=(int)$CollageCategoryID?>]=1"><?=$CollageCats[(int)$CollageCategoryID]?></a></div>
129 148
     </div>
149
+
130 150
     <div class="box box_description">
131 151
       <div class="head"><strong>Description</strong></div>
132
-      <div class="pad"><?=Text::full_format($Description)?></div>
152
+      <div class="pad"><?=Text::full_format($Description)?>
153
+      </div>
133 154
     </div>
155
+
134 156
     <div class="box box_info box_statistics_collage_torrents">
135 157
       <div class="head"><strong>Statistics</strong></div>
136 158
       <ul class="stats nobullet">
137
-        <li>Artists: <?=number_format($NumGroups)?></li>
138
-        <li>Subscribers: <?=number_format((int)$Subscribers)?></li>
139
-        <li>Built by <?=number_format(count($UserAdditions))?> user<?=(count($UserAdditions) > 1 ? 's' : '')?></li>
140
-        <li>Last updated: <?=time_diff($Updated)?></li>
159
+        <li>Artists: <?=number_format($NumGroups)?>
160
+        </li>
161
+        <li>Subscribers: <?=number_format((int)$Subscribers)?>
162
+        </li>
163
+        <li>Built by <?=number_format(count($UserAdditions))?>
164
+          user<?=(count($UserAdditions) > 1 ? 's' : '')?>
165
+        </li>
166
+        <li>Last updated: <?=time_diff($Updated)?>
167
+        </li>
141 168
       </ul>
142 169
     </div>
170
+
143 171
     <div class="box box_contributors">
144 172
       <div class="head"><strong>Top Contributors</strong></div>
145 173
       <div class="pad">
146 174
         <ol style="padding-left: 5px;">
147
-<?
175
+          <?php
148 176
 arsort($UserAdditions);
149 177
 $i = 0;
150 178
 foreach ($UserAdditions as $UserID => $Additions) {
151
-  $i++;
152
-  if ($i > 5) {
153
-    break;
154
-  }
155
-?>
156
-          <li><?=Users::format_username($UserID, false, false, false)?> (<?=number_format($Additions)?>)</li>
157
-<?
179
+    $i++;
180
+    if ($i > 5) {
181
+        break;
182
+    } ?>
183
+          <li><?=Users::format_username($UserID, false, false, false)?>
184
+            (<?=number_format($Additions)?>)</li>
185
+          <?php
158 186
 }
159 187
 ?>
160 188
         </ol>
161 189
       </div>
162 190
     </div>
163
-<? if (check_perms('site_collages_manage') && !isset($PreventAdditions)) { ?>
191
+
192
+    <?php if (check_perms('site_collages_manage') && !isset($PreventAdditions)) { ?>
164 193
     <div class="box box_addartist">
165
-      <div class="head"><strong>Add Artists</strong><span class="float_right"><a href="#" onclick="$('.add_artist_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML == 'Batch add' ? 'Individual add' : 'Batch add'); return false;" class="brackets">Batch add</a></span></div>
194
+      <div class="head"><strong>Add Artists</strong><span class="float_right"><a href="#"
195
+            onclick="$('.add_artist_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML === 'Batch add' ? 'Individual add' : 'Batch add'); return false;"
196
+            class="brackets">Batch add</a></span></div>
166 197
       <div class="pad add_artist_container">
167 198
         <form class="add_form" name="artist" action="collages.php" method="post">
168 199
           <input type="hidden" name="action" value="add_artist" />
169
-          <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
170
-          <input type="hidden" name="collageid" value="<?=$CollageID?>" />
200
+          <input type="hidden" name="auth"
201
+            value="<?=$LoggedUser['AuthKey']?>" />
202
+          <input type="hidden" name="collageid"
203
+            value="<?=$CollageID?>" />
171 204
           <div class="field_div">
172
-            <input type="text" id="artist" size="20" name="url"<? Users::has_autocomplete_enabled('other'); ?> />
205
+            <input type="text" id="artist" size="20" name="url" <?php Users::has_autocomplete_enabled('other'); ?>
206
+            />
173 207
           </div>
174 208
           <div class="submit_div">
175 209
             <input type="submit" value="Add" />
@@ -177,11 +211,14 @@ foreach ($UserAdditions as $UserID => $Additions) {
177 211
           <span style="font-style: italic;">Enter the URL of an artist on the site.</span>
178 212
         </form>
179 213
       </div>
214
+
180 215
       <div class="pad hidden add_artist_container">
181 216
         <form class="add_form" name="artists" action="collages.php" method="post">
182 217
           <input type="hidden" name="action" value="add_artist_batch" />
183
-          <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
184
-          <input type="hidden" name="collageid" value="<?=$CollageID?>" />
218
+          <input type="hidden" name="auth"
219
+            value="<?=$LoggedUser['AuthKey']?>" />
220
+          <input type="hidden" name="collageid"
221
+            value="<?=$CollageID?>" />
185 222
           <div class="field_div">
186 223
             <textarea name="urls" rows="5" cols="25" style="white-space: nowrap;"></textarea>
187 224
           </div>
@@ -192,11 +229,12 @@ foreach ($UserAdditions as $UserID => $Additions) {
192 229
         </form>
193 230
       </div>
194 231
     </div>
195
-<? } ?>
232
+    <?php } ?>
233
+
196 234
     <h3>Comments</h3>
197
-<?
235
+    <?php
198 236
 if ($CommentList === null) {
199
-  $DB->query("
237
+    $DB->query("
200 238
     SELECT
201 239
       c.ID,
202 240
       c.Body,
@@ -209,34 +247,42 @@ if ($CommentList === null) {
209 247
       AND c.PageID = $CollageID
210 248
     ORDER BY c.ID DESC
211 249
     LIMIT 15");
212
-  $CommentList = $DB->to_array(false, MYSQLI_NUM);
250
+    $CommentList = $DB->to_array(false, MYSQLI_NUM);
213 251
 }
252
+
214 253
 foreach ($CommentList as $Comment) {
215
-  list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment;
216
-?>
254
+    list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment; ?>
217 255
     <div class="box comment">
218 256
       <div class="head">
219
-        <?=Users::format_username($UserID, false, false, false) ?> <?=time_diff($CommentTime) ?>
257
+        <?=Users::format_username($UserID, false, false, false) ?>
258
+        <?=time_diff($CommentTime) ?>
220 259
         <br />
221
-        <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$CommentID?>" class="brackets">Report</a>
260
+        <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$CommentID?>"
261
+          class="brackets">Report</a>
262
+      </div>
263
+      <div class="pad"><?=Text::full_format($Body)?>
222 264
       </div>
223
-      <div class="pad"><?=Text::full_format($Body)?></div>
224 265
     </div>
225
-<?
266
+    <?php
226 267
 }
227 268
 ?>
269
+
228 270
     <div class="box pad">
229
-      <a href="collages.php?action=comments&amp;collageid=<?=$CollageID?>" class="brackets">View all comments</a>
271
+      <a href="collages.php?action=comments&amp;collageid=<?=$CollageID?>"
272
+        class="brackets">View all comments</a>
230 273
     </div>
231
-<?
274
+
275
+    <?php
232 276
 if (!$LoggedUser['DisablePosting']) {
233
-?>
277
+    ?>
234 278
     <div class="box box_addcomment">
235 279
       <div class="head"><strong>Comment</strong></div>
236
-      <form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="comments.php" method="post">
280
+      <form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;"
281
+        action="comments.php" method="post">
237 282
         <input type="hidden" name="action" value="take_post" />
238 283
         <input type="hidden" name="page" value="collages" />
239
-        <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
284
+        <input type="hidden" name="auth"
285
+          value="<?=$LoggedUser['AuthKey']?>" />
240 286
         <input type="hidden" name="pageid" value="<?=$CollageID?>" />
241 287
         <div class="pad">
242 288
           <div class="field_div">
@@ -248,53 +294,91 @@ if (!$LoggedUser['DisablePosting']) {
248 294
         </div>
249 295
       </form>
250 296
     </div>
251
-<?
297
+    <?php
252 298
 }
253 299
 ?>
254 300
   </div>
301
+
255 302
   <div class="main_column">
256
-<?
257
-if ($CollageCovers != 0) {
258
-?>
303
+    <?php
304
+if ($CollageCovers !== 0) {
305
+    ?>
259 306
     <div id="coverart" class="box">
260 307
       <div class="head" id="coverhead"><strong>Pictures</strong></div>
261 308
       <ul class="collage_images" id="collage_page0">
262
-<?
309
+        <?php
263 310
   $Page1 = array_slice($Collage, 0, $CollageCovers);
264
-  foreach ($Page1 as $Group) {
265
-    echo $Group;
266
-  }
267
-?>
311
+    foreach ($Page1 as $Group) {
312
+        echo $Group;
313
+    } ?>
268 314
       </ul>
269 315
     </div>
270
-<?  if ($NumGroups > $CollageCovers) { ?>
316
+    <?php if ($NumGroups > $CollageCovers) { ?>
271 317
     <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
272
-      <span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;"><strong>&lt;&lt; First</strong></a> | </span>
273
-      <span id="prevpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;"><strong>&lt; Prev</strong></a> | </span>
274
-<?    for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
275
-      <span id="pagelink<?=$i?>" class="<?=($i > 4 ? 'hidden' : '')?><?=($i == 0 ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
276
-<?    } ?>
277
-      <span id="nextbar" class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>"> | </span>
278
-      <span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;"><strong>Next &gt;</strong></a></span>
279
-      <span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>, this); return false;"><strong>Last &gt;&gt;</strong></a></span>
318
+
319
+      <span id="firstpage" class="invisible">
320
+        <a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">
321
+          <strong>&raquo; First</strong>
322
+        </a> |
323
+      </span>
324
+
325
+      <span id="prevpage" class="invisible">
326
+        <a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;">
327
+          <strong>‹ Prev</strong>
328
+        </a> |
329
+      </span>
330
+
331
+      <?php for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
332
+      <span id="pagelink<?=$i?>"
333
+        class="<?=($i > 4 ? 'hidden' : '')?><?=($i === 0 ? 'selected' : '')?>">
334
+        <a href="#" class="pageslink"
335
+          onclick="collageShow.page(<?=$i?>, this); return false;">
336
+          <strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong>
337
+        </a>
338
+        <?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?>
339
+      </span>
340
+      <?php } ?>
341
+
342
+      <span id="nextbar"
343
+        class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>">
344
+        | </span>
345
+
346
+      <span id="nextpage">
347
+        <a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;">
348
+          <strong>Next ›</strong>
349
+        </a>
350
+      </span>
351
+
352
+      <span id="lastpage"
353
+        class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>">
354
+        |
355
+        <a href="#" class="pageslink"
356
+          onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>, this); return false;">
357
+          <strong>Last »</strong>
358
+        </a>
359
+      </span>
280 360
     </div>
281
-    <script type="text/javascript">//<![CDATA[
282
-      collageShow.init(<?=json_encode($CollagePages)?>);
283
-    //]]></script>
284
-<?
361
+
362
+    <script type="text/javascript">
363
+      //<![CDATA[
364
+      collageShow.init( <?=json_encode($CollagePages)?> );
365
+      //]]>
366
+    </script>
367
+    <?php
285 368
   }
286 369
 }
287 370
 ?>
371
+
288 372
     <div class="box">
289 373
       <table class="artist_table grouping cats" id="discog_table">
290 374
         <tr class="colhead_dark">
291 375
           <td><strong>Artists</strong></td>
292 376
         </tr>
293
-<?=$ArtistTable?>
377
+        <?=$ArtistTable?>
294 378
       </table>
295 379
     </div>
296 380
   </div>
297 381
 </div>
298
-<?
382
+
383
+<?php
299 384
 View::show_footer();
300
-?>

+ 464
- 289
sections/collages/torrent_collage.php View File

@@ -1,6 +1,8 @@
1
-<?
2
-function compare($X, $Y) {
3
-  return($Y['count'] - $X['count']);
1
+<?php
2
+
3
+function compare($X, $Y)
4
+{
5
+    return($Y['count'] - $X['count']);
4 6
 }
5 7
 
6 8
 // Build the data for the collage and the torrent list
@@ -16,10 +18,11 @@ $DB->query("
16 18
 
17 19
 $GroupIDs = $DB->collect('GroupID');
18 20
 $Contributors = $DB->to_pair('GroupID', 'UserID', false);
21
+
19 22
 if (count($GroupIDs) > 0) {
20
-  $TorrentList = Torrents::get_groups($GroupIDs);
23
+    $TorrentList = Torrents::get_groups($GroupIDs);
21 24
 } else {
22
-  $TorrentList = [];
25
+    $TorrentList = [];
23 26
 }
24 27
 
25 28
 // Loop through the result set, building up $Collage and $TorrentTable
@@ -34,202 +37,275 @@ $UserAdditions = [];
34 37
 $Number = 0;
35 38
 
36 39
 foreach ($GroupIDs as $GroupID) {
37
-  if (!isset($TorrentList[$GroupID])) {
38
-    continue;
39
-  }
40
-  $Group = $TorrentList[$GroupID];
41
-  extract(Torrents::array_group($Group));
42
-  $UserID = $Contributors[$GroupID];
43
-  $TorrentTags = new Tags($TagList);
44
-
45
-  // Handle stats and stuff
46
-  $Number++;
47
-  if ($UserID == $LoggedUser['ID']) {
48
-    $NumGroupsByUser++;
49
-  }
40
+    if (!isset($TorrentList[$GroupID])) {
41
+        continue;
42
+    }
50 43
 
51
-  $CountArtists = $Artists;
44
+    $Group = $TorrentList[$GroupID];
45
+    extract(Torrents::array_group($Group));
46
+    $UserID = $Contributors[$GroupID];
47
+    $TorrentTags = new Tags($TagList);
52 48
 
53
-  if ($CountArtists) {
54
-    foreach ($CountArtists as $Artist) {
55
-      if (!isset($TopArtists[$Artist['id']])) {
56
-        $TopArtists[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
57
-      } else {
58
-        $TopArtists[$Artist['id']]['count']++;
59
-      }
49
+    // Handle stats and stuff
50
+    $Number++;
51
+    if ($UserID == $LoggedUser['ID']) {
52
+        $NumGroupsByUser++;
60 53
     }
61
-  }
62 54
 
63
-  if (!isset($UserAdditions[$UserID])) {
64
-    $UserAdditions[$UserID] = 0;
65
-  }
66
-  $UserAdditions[$UserID]++;
55
+    $CountArtists = $Artists;
56
+    if ($CountArtists) {
57
+        foreach ($CountArtists as $Artist) {
58
+            if (!isset($TopArtists[$Artist['id']])) {
59
+                $TopArtists[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
60
+            } else {
61
+                $TopArtists[$Artist['id']]['count']++;
62
+            }
63
+        }
64
+    }
67 65
 
68
-  $DisplayName = "$Number - ";
66
+    if (!isset($UserAdditions[$UserID])) {
67
+        $UserAdditions[$UserID] = 0;
68
+    }
69
+    $UserAdditions[$UserID]++;
69 70
 
70
-  $DisplayName .= Artists::display_artists($Artists);
71
+    $DisplayName = "$Number - ";
72
+    $DisplayName .= Artists::display_artists($Artists);
73
+    $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" ";
71 74
 
72
-  $DisplayName .= "<a href=\"torrents.php?id=$GroupID\" ";
73
-  if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
74
-    $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
75
-  }
76
-  $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
77
-  $DisplayName .= "dir=\"ltr\">$GroupName</a>";
78
-  if ($GroupYear > 0) {
79
-    $DisplayName = "$DisplayName [$GroupYear]";
80
-  }
81
-  if ($GroupStudio) {
82
-    $DisplayName .= " [$GroupStudio]";
83
-  }
84
-  if ($GroupCatalogueNumber) {
85
-    $DisplayName .= " [$GroupCatalogueNumber]";
86
-  }
87
-  if ($GroupDLSiteID) {
88
-    $DisplayName .= " [$GroupDLSiteID]";
89
-  }
90
-  $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
91
-  // Start an output buffer, so we can store this output in $TorrentTable
92
-  ob_start();
75
+    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
76
+        $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
77
+    }
93 78
 
94
-  if (count($Torrents) > 1) {
95
-    // Grouped torrents
96
-    $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
97
-?>
98
-      <tr class="group <?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
99
-        <td class="center">
100
-          <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
101
-            <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collapse all groups on this page."></a>
102
-          </div>
103
-        </td>
104
-        <td class="center">
105
-          <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>"></div>
106
-        </td>
107
-        <td colspan="5">
108
-          <?=$DisplayName?>
109
-<?    if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
110
-          <span class="remove_bookmark float_right">
111
-            <a class="float_right" href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
112
-          </span>
113
-<?    } else { ?>
114
-          <span class="add_bookmark float_right">
115
-            <a class="float_right" href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
116
-          </span>
117
-<?
79
+    $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
80
+    $DisplayName .= "dir=\"ltr\">$GroupName</a>";
81
+
82
+    if ($GroupYear > 0) {
83
+        $DisplayName = "$DisplayName<br />$GroupYear";
118 84
     }
119
-?>
120
-          <div class="tags"><?=$TorrentTags->format()?></div>
121
-        </td>
122
-      </tr>
123
-<?
124
-    foreach ($Torrents as $TorrentID => $Torrent) {
125
-      $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
126
-?>
127
-      <tr class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
128
-        <td colspan="3">
129
-          <span class="brackets">
130
-            <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
131
-<?      if (Torrents::can_use_token($Torrent)) { ?>
132
-            | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
133
-<?      } ?>
134
-            | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
135
-          </span>
136
-          &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
137
-        </td>
138
-        <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
139
-        <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
140
-        <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
141
-        <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
142
-      </tr>
143
-<?
85
+
86
+    if ($GroupStudio) {
87
+        $DisplayName .= " / $GroupStudio";
144 88
     }
145
-  } else {
146
-    // Viewing a type that does not require grouping
147 89
 
148
-    $TorrentID = key($Torrents);
149
-    $Torrent = current($Torrents);
90
+    if ($GroupCatalogueNumber) {
91
+        $DisplayName .= " / $GroupCatalogueNumber";
92
+    }
93
+
94
+    /*
95
+    if ($GroupDLSiteID) {
96
+        $DisplayName .= " [$GroupDLSiteID]";
97
+    }
98
+    */
99
+
100
+    $SnatchedGroupClass = ($GroupFlags['IsSnatched'] ? ' snatched_group' : '');
101
+    // Start an output buffer, so we can store this output in $TorrentTable
102
+    ob_start();
103
+
104
+    if (count($Torrents) > 1) {
105
+        // Grouped torrents
106
+        $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); ?>
107
+
108
+<tr class="group <?=$SnatchedGroupClass?>"
109
+  id="group_<?=$GroupID?>">
110
+  <td class="center">
111
+    <div id="showimg_<?=$GroupID?>"
112
+      class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
113
+      <a class="tooltip show_torrents_link"
114
+        onclick="toggle_group(<?=$GroupID?>, this, event);"
115
+        title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collapse all groups on this page."></a>
116
+    </div>
117
+  </td>
118
+
119
+  <td class="center">
120
+    <div title="<?=$TorrentTags->title()?>"
121
+      class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
122
+    </div>
123
+  </td>
124
+
125
+  <td colspan="5">
126
+    <?=$DisplayName?>
127
+    <?php if (Bookmarks::has_bookmarked('torrent', $GroupID)) { ?>
128
+    <span class="remove_bookmark float_right">
129
+      <a class="float_right" href="#"
130
+        id="bookmarklink_torrent_<?=$GroupID?>"
131
+        class="remove_bookmark brackets"
132
+        onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
133
+        bookmark</a>
134
+    </span>
135
+    <?php } else { ?>
136
+    <span class="add_bookmark float_right">
137
+      <a class="float_right" href="#"
138
+        id="bookmarklink_torrent_<?=$GroupID?>"
139
+        class="add_bookmark brackets"
140
+        onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
141
+    </span>
142
+    <?php
143
+    } ?>
144
+    <div class="tags"><?=$TorrentTags->format()?>
145
+    </div>
146
+  </td>
147
+</tr>
148
+
149
+<?php
150
+    foreach ($Torrents as $TorrentID => $Torrent) {
151
+        $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>
152
+<tr
153
+  class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
154
+
155
+  <td colspan="3">
156
+    <span class="brackets">
157
+      <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
158
+        class="tooltip" title="Download">DL</a>
159
+      <?php if (Torrents::can_use_token($Torrent)) { ?>
160
+      | <a
161
+        href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
162
+        class="tooltip" title="Use a FL Token"
163
+        onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
164
+      <?php } ?>
165
+      | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
166
+        class="tooltip" title="Report">RP</a>
167
+    </span>
168
+    &nbsp;&nbsp;&raquo;&nbsp; <a
169
+      href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
170
+  </td>
171
+
172
+  <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
173
+  </td>
174
+
175
+  <td class="number_column"><?=number_format($Torrent['Snatched'])?>
176
+  </td>
177
+
178
+  <td
179
+    class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
180
+    <?=number_format($Torrent['Seeders'])?>
181
+  </td>
150 182
 
151
-    if ($Torrent['IsLeeching']) {
152
-      $DisplayName .= ' ' . Format::torrent_label('Leeching');
153
-    } else if ($Torrent['IsSeeding']) {
154
-      $DisplayName .= ' ' . Format::torrent_label('Seeding');
155
-    } else if ($Torrent['IsSnatched']) {
156
-      $DisplayName .= ' ' . Format::torrent_label('Snatched');
183
+  <td class="number_column"><?=number_format($Torrent['Leechers'])?>
184
+  </td>
185
+</tr>
186
+
187
+<?php
157 188
     }
158
-    if ($Torrent['FreeTorrent'] == '1') {
159
-      $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
160
-    } elseif ($Torrent['FreeTorrent'] == '2') {
161
-      $DisplayName .= ' ' . Format::torrent_label('Neutral Leech!');
162
-    } elseif ($Torrent['PersonalFL']) {
163
-      $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
189
+    } else {
190
+        // Viewing a type that does not require grouping
191
+
192
+        $TorrentID = key($Torrents);
193
+        $Torrent = current($Torrents);
194
+
195
+        if ($Torrent['IsLeeching']) {
196
+            $DisplayName .= ' ' . Format::torrent_label('Leeching');
197
+        } elseif ($Torrent['IsSeeding']) {
198
+            $DisplayName .= ' ' . Format::torrent_label('Seeding');
199
+        } elseif ($Torrent['IsSnatched']) {
200
+            $DisplayName .= ' ' . Format::torrent_label('Snatched');
201
+        }
202
+
203
+        if ($Torrent['FreeTorrent'] == '1') {
204
+            $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
205
+        } elseif ($Torrent['FreeTorrent'] == '2') {
206
+            $DisplayName .= ' ' . Format::torrent_label('Neutral Leech!');
207
+        } elseif ($Torrent['PersonalFL']) {
208
+            $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
209
+        }
210
+
211
+        $SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : ''); ?>
212
+
213
+<tr
214
+  class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>"
215
+  id="group_<?=$GroupID?>">
216
+  <td></td>
217
+
218
+  <td class="center">
219
+    <div title="<?=$TorrentTags->title()?>"
220
+      class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
221
+    </div>
222
+  </td>
223
+
224
+  <td>
225
+    <span class="brackets">
226
+      <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
227
+        class="tooltip" title="Download">DL</a>
228
+      <?php    if (Torrents::can_use_token($Torrent)) { ?>
229
+      | <a
230
+        href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
231
+        class="tooltip" title="Use a FL Token"
232
+        onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
233
+      <?php    } ?>
234
+      | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
235
+        class="tooltip" title="Report">RP</a>
236
+    </span>
237
+    <?=$DisplayName?>
238
+    <div class="tags"><?=$TorrentTags->format()?>
239
+    </div>
240
+  </td>
241
+
242
+  <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
243
+  </td>
244
+
245
+  <td class="number_column"><?=number_format($Torrent['Snatched'])?>
246
+  </td>
247
+
248
+  <td
249
+    class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>">
250
+    <?=number_format($Torrent['Seeders'])?>
251
+  </td>
252
+
253
+  <td class="number_column"><?=number_format($Torrent['Leechers'])?>
254
+  </td>
255
+</tr>
256
+
257
+<?php
164 258
     }
165
-    $SnatchedTorrentClass = ($Torrent['IsSnatched'] ? ' snatched_torrent' : '');
166
-?>
167
-      <tr class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>" id="group_<?=$GroupID?>">
168
-        <td></td>
169
-        <td class="center">
170
-          <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
171
-          </div>
172
-        </td>
173
-        <td>
174
-          <span class="brackets">
175
-            <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
176
-<?    if (Torrents::can_use_token($Torrent)) { ?>
177
-            | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
178
-<?    } ?>
179
-            | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
180
-          </span>
181
-          <?=$DisplayName?>
182
-          <div class="tags"><?=$TorrentTags->format()?></div>
183
-        </td>
184
-        <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
185
-        <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
186
-        <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
187
-        <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
188
-      </tr>
189
-<?
190
-  }
191
-  $TorrentTable .= ob_get_clean();
259
+    $TorrentTable .= ob_get_clean();
192 260
 
193
-  // Album art
261
+    // Album art
194 262
 
195
-  ob_start();
263
+    ob_start();
196 264
 
197
-  $DisplayName = '';
265
+    $DisplayName = '';
198 266
 
199
-  $DisplayName .= Artists::display_artists($Artists, false);
200
-  $DisplayName .= $GroupName;
201
-  if ($GroupYear > 0) {
202
-    $DisplayName = "$DisplayName [$GroupYear]";
203
-  }
204
-  $Tags = display_str($TorrentTags->format());
205
-  $PlainTags = implode(', ', $TorrentTags->get_tags());
206
-?>
207
-        <div class="collage_image image_group_<?=$GroupID?>">
208
-          <a href="torrents.php?id=<?=$GroupID?>">
209
-<?  if (!$WikiImage) {
210
-      $WikiImage = STATIC_SERVER.'common/noartwork/music.png';
267
+    $DisplayName .= Artists::display_artists($Artists, false);
268
+    $DisplayName .= $GroupName;
269
+
270
+    if ($GroupYear > 0) {
271
+        $DisplayName = "$DisplayName [$GroupYear]";
272
+    }
273
+
274
+    $Tags = display_str($TorrentTags->format());
275
+    $PlainTags = implode(', ', $TorrentTags->get_tags()); ?>
276
+
277
+<div class="collage_image image_group_<?=$GroupID?>">
278
+  <a href="torrents.php?id=<?=$GroupID?>">
279
+    <?php if (!$WikiImage) {
280
+        $WikiImage = STATIC_SERVER.'common/noartwork/music.png';
211 281
     } ?>
212
-            <img class="tooltip_interactive" src="<?=ImageTools::process($WikiImage, 'thumb')?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?> <br /> <div class='tags'><?=$Tags?></div>" data-title-plain="<?="$DisplayName ($PlainTags)"?>" width="100%" />
213
-          </a>
214
-        </div>
215
-<?
282
+    <img class="tooltip_interactive"
283
+      src="<?=ImageTools::process($WikiImage, 'thumb')?>"
284
+      alt="<?=$DisplayName?>"
285
+      title="<?=$DisplayName?> <br /> <div class='tags'><?=$Tags?></div>"
286
+      data-title-plain="<?="$DisplayName ($PlainTags)"?>"
287
+      width="100%" />
288
+  </a>
289
+</div>
290
+
291
+<?php
216 292
   $Collage[] = ob_get_clean();
217 293
 }
218 294
 
219 295
 if ($CollageCategoryID === '0' && !check_perms('site_collages_delete')) {
220
-  if (!check_perms('site_collages_personal') || $CreatorID !== $LoggedUser['ID']) {
221
-    $PreventAdditions = true;
222
-  }
296
+    if (!check_perms('site_collages_personal') || $CreatorID !== $LoggedUser['ID']) {
297
+        $PreventAdditions = true;
298
+    }
223 299
 }
224 300
 
225 301
 if (!check_perms('site_collages_delete')
226 302
   && (
227
-    $Locked
303
+      $Locked
228 304
     || ($MaxGroups > 0 && $NumGroups >= $MaxGroups)
229 305
     || ($MaxGroupsPerUser > 0 && $NumGroupsByUser >= $MaxGroupsPerUser)
230 306
   )
231 307
 ) {
232
-  $PreventAdditions = true;
308
+    $PreventAdditions = true;
233 309
 }
234 310
 
235 311
 // Silly hack for people who are on the old setting
@@ -237,67 +313,84 @@ $CollageCovers = isset($LoggedUser['CollageCovers']) ? $LoggedUser['CollageCover
237 313
 $CollagePages = [];
238 314
 
239 315
 if ($CollageCovers) {
240
-  for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
241
-    $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
242
-    $CollagePage = '';
243
-    foreach ($Groups as $Group) {
244
-      $CollagePage .= $Group;
316
+    for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
317
+        $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
318
+        $CollagePage = '';
319
+        foreach ($Groups as $Group) {
320
+            $CollagePage .= $Group;
321
+        }
322
+        $CollagePages[] = $CollagePage;
245 323
     }
246
-    $CollagePages[] = $CollagePage;
247
-  }
248 324
 }
249 325
 
250 326
 View::show_header($Name, 'browse,collage,bbcode,recommend,wall');
251 327
 ?>
328
+
252 329
 <div class="thin">
253 330
   <div class="header">
254
-    <h2><?=$Name?></h2>
331
+    <h2><?=$Name?>
332
+    </h2>
255 333
     <div class="linkbox">
256 334
       <a href="collages.php" class="brackets">List of collections</a>
257
-<?  if (check_perms('site_collages_create')) { ?>
335
+      <?php  if (check_perms('site_collages_create')) { ?>
258 336
       <a href="collages.php?action=new" class="brackets">New collection</a>
259
-<?  } ?>
337
+      <?php  } ?>
260 338
       <br /><br />
261
-<?  if (check_perms('site_collages_subscribe')) { ?>
262
-      <a href="#" id="subscribelink<?=$CollageID?>" class="brackets" onclick="CollageSubscribe(<?=$CollageID?>); return false;"><?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
263
-<?
339
+      <?php  if (check_perms('site_collages_subscribe')) { ?>
340
+      <a href="#" id="subscribelink<?=$CollageID?>" class="brackets"
341
+        onclick="CollageSubscribe(<?=$CollageID?>); return false;"><?=(in_array($CollageID, $CollageSubscriptions) ? 'Unsubscribe' : 'Subscribe')?></a>
342
+      <?php
264 343
   }
265 344
   if (check_perms('site_collages_delete') || (check_perms('site_edit_wiki') && !$Locked)) {
266
-?>
267
-      <a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>" class="brackets">Edit description</a>
268
-<?  } else { ?>
345
+      ?>
346
+      <a href="collages.php?action=edit&amp;collageid=<?=$CollageID?>"
347
+        class="brackets">Edit description</a>
348
+      <?php
349
+  } else { ?>
269 350
       <span class="brackets">Locked</span>
270
-<?
351
+      <?php
271 352
   }
272 353
   if (Bookmarks::has_bookmarked('collage', $CollageID)) {
273
-?>
274
-      <a href="#" id="bookmarklink_collage_<?=$CollageID?>" class="brackets" onclick="Unbookmark('collage', <?=$CollageID?>, 'Bookmark'); return false;">Remove bookmark</a>
275
-<?  } else { ?>
276
-      <a href="#" id="bookmarklink_collage_<?=$CollageID?>" class="brackets" onclick="Bookmark('collage', <?=$CollageID?>, 'Remove bookmark'); return false;">Bookmark</a>
277
-<?  } ?>
278
-<!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
279
-<?
354
+      ?>
355
+      <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
356
+        class="brackets"
357
+        onclick="Unbookmark('collage', <?=$CollageID?>, 'Bookmark'); return false;">Remove
358
+        bookmark</a>
359
+      <?php
360
+  } else { ?>
361
+      <a href="#" id="bookmarklink_collage_<?=$CollageID?>"
362
+        class="brackets"
363
+        onclick="Bookmark('collage', <?=$CollageID?>, 'Remove bookmark'); return false;">Bookmark</a>
364
+      <?php  } ?>
365
+      <!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
366
+      <?php
280 367
   if (check_perms('site_collages_manage') && !$Locked) {
281
-?>
282
-      <a href="collages.php?action=manage&amp;collageid=<?=$CollageID?>" class="brackets">Manage torrents</a>
283
-<?  } ?>
284
-      <a href="reports.php?action=report&amp;type=collage&amp;id=<?=$CollageID?>" class="brackets">Report collection</a>
285
-<?  if (check_perms('site_collages_delete') || $CreatorID == $LoggedUser['ID']) { ?>
286
-      <a href="collages.php?action=delete&amp;collageid=<?=$CollageID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to delete this collage?');">Delete</a>
287
-<?  } ?>
368
+      ?>
369
+      <a href="collages.php?action=manage&amp;collageid=<?=$CollageID?>"
370
+        class="brackets">Manage torrents</a>
371
+      <?php
372
+  } ?>
373
+      <a href="reports.php?action=report&amp;type=collage&amp;id=<?=$CollageID?>"
374
+        class="brackets">Report collection</a>
375
+      <?php  if (check_perms('site_collages_delete') || $CreatorID == $LoggedUser['ID']) { ?>
376
+      <a href="collages.php?action=delete&amp;collageid=<?=$CollageID?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
377
+        class="brackets" onclick="return confirm('Are you sure you want to delete this collage?');">Delete</a>
378
+      <?php  } ?>
288 379
     </div>
289 380
   </div>
290
-<? /* Misc::display_recommend($CollageID, "collage"); */ ?>
381
+  <?php /* Misc::display_recommend($CollageID, "collage"); */ ?>
291 382
   <div class="sidebar">
292 383
     <div class="box box_category">
293 384
       <div class="head"><strong>Category</strong></div>
294
-      <div class="pad"><a href="collages.php?action=search&amp;cats[<?=(int)$CollageCategoryID?>]=1"><?=$CollageCats[(int)$CollageCategoryID]?></a></div>
385
+      <div class="pad"><a
386
+          href="collages.php?action=search&amp;cats[<?=(int)$CollageCategoryID?>]=1"><?=$CollageCats[(int)$CollageCategoryID]?></a></div>
295 387
     </div>
296 388
     <div class="box box_description">
297 389
       <div class="head"><strong>Description</strong></div>
298
-      <div class="pad"><?=Text::full_format($Description)?></div>
390
+      <div class="pad"><?=Text::full_format($Description)?>
391
+      </div>
299 392
     </div>
300
-<?
393
+    <?php
301 394
 // I'm actually commenting this out
302 395
 /*
303 396
 if (check_perms('zip_downloader')) {
@@ -364,78 +457,91 @@ foreach ($ZIPOptions as $Option) {
364 457
 <? }
365 458
 */
366 459
 ?>
460
+
367 461
     <div class="box box_info box_statistics_collage_torrents">
368 462
       <div class="head"><strong>Statistics</strong></div>
369 463
       <ul class="stats nobullet">
370
-        <li>Torrents: <?=number_format($NumGroups)?></li>
371
-<? if (!empty($TopArtists)) { ?>
372
-        <li>Artists: <?=number_format(count($TopArtists))?></li>
373
-<? } ?>
374
-        <li>Subscribers: <?=number_format((int)$Subscribers)?></li>
375
-        <li>Built by <?=number_format(count($UserAdditions))?> user<?=(count($UserAdditions) > 1 ? 's' : '')?></li>
376
-        <li>Last updated: <?=time_diff($Updated)?></li>
464
+        <li>Torrents: <?=number_format($NumGroups)?>
465
+        </li>
466
+        <?php if (!empty($TopArtists)) { ?>
467
+        <li>Artists: <?=number_format(count($TopArtists))?>
468
+        </li>
469
+        <?php } ?>
470
+        <li>Subscribers: <?=number_format((int)$Subscribers)?>
471
+        </li>
472
+        <li>Built by <?=number_format(count($UserAdditions))?>
473
+          user<?=(count($UserAdditions) > 1 ? 's' : '')?>
474
+        </li>
475
+        <li>Last updated: <?=time_diff($Updated)?>
476
+        </li>
377 477
       </ul>
378 478
     </div>
379 479
     <div class="box box_tags">
380 480
       <div class="head"><strong>Top Tags</strong></div>
381 481
       <div class="pad tags">
382 482
         <ol style="padding-left: 5px">
383
-<?
483
+          <?php
384 484
         Tags::format_top(5, 'collages.php?action=search&amp;tags=');
385 485
 ?>
386 486
         </ol>
387 487
       </div>
388 488
     </div>
389
-<?  if (!empty($TopArtists)) { ?>
489
+
490
+    <?php  if (!empty($TopArtists)) { ?>
390 491
     <div class="box box_artists">
391 492
       <div class="head"><strong>Top Artists</strong></div>
392 493
       <div class="pad">
393 494
         <ol style="padding-left: 5px;">
394
-<?
495
+          <?php
395 496
     uasort($TopArtists, 'compare');
396 497
     $i = 0;
397 498
     foreach ($TopArtists as $ID => $Artist) {
398
-      $i++;
399
-      if ($i > 10) {
400
-        break;
401
-      }
402
-?>
499
+        $i++;
500
+        if ($i > 10) {
501
+            break;
502
+        } ?>
403 503
           <li><a href="artist.php?id=<?=$ID?>"><?=$Artist['name']?></a> (<?=number_format($Artist['count'])?>)</li>
404
-<?
504
+          <?php
405 505
     }
406 506
 ?>
407 507
         </ol>
408 508
       </div>
409 509
     </div>
410
-<?  } ?>
510
+    <?php  } ?>
511
+
411 512
     <div class="box box_contributors">
412 513
       <div class="head"><strong>Top Contributors</strong></div>
413 514
       <div class="pad">
414 515
         <ol style="padding-left: 5px;">
415
-<?
516
+          <?php
416 517
 arsort($UserAdditions);
417 518
 $i = 0;
418 519
 foreach ($UserAdditions as $UserID => $Additions) {
419
-  $i++;
420
-  if ($i > 5) {
421
-    break;
422
-  }
423
-?>
424
-          <li><?=Users::format_username($UserID, false, false, false)?> (<?=number_format($Additions)?>)</li>
425
-<?
520
+    $i++;
521
+    if ($i > 5) {
522
+        break;
523
+    } ?>
524
+          <li><?=Users::format_username($UserID, false, false, false)?>
525
+            (<?=number_format($Additions)?>)</li>
526
+          <?php
426 527
 }
427 528
 ?>
428 529
         </ol>
429 530
       </div>
430 531
     </div>
431
-<? if (check_perms('site_collages_manage') && !isset($PreventAdditions)) { ?>
532
+
533
+    <?php if (check_perms('site_collages_manage') && !isset($PreventAdditions)) { ?>
432 534
     <div class="box box_addtorrent">
433
-      <div class="head"><strong>Add Torrent Group</strong><span class="float_right"><a href="#" onclick="$('.add_torrent_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML == 'Batch add' ? 'Individual add' : 'Batch add'); return false;" class="brackets">Batch add</a></span></div>
535
+      <div class="head"><strong>Add Torrent Group</strong><span class="float_right"><a href="#"
536
+            onclick="$('.add_torrent_container').toggle_class('hidden'); this.innerHTML = (this.innerHTML == 'Batch add' ? 'Individual add' : 'Batch add'); return false;"
537
+            class="brackets">Batch add</a></span></div>
434 538
       <div class="pad add_torrent_container">
435 539
         <form class="add_form" name="torrent" action="collages.php" method="post">
436 540
           <input type="hidden" name="action" value="add_torrent" />
437
-          <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
438
-          <input type="hidden" name="collageid" value="<?=$CollageID?>" />
541
+          <input type="hidden" name="auth"
542
+            value="<?=$LoggedUser['AuthKey']?>" />
543
+          <input type="hidden" name="collageid"
544
+            value="<?=$CollageID?>" />
439 545
           <div class="field_div">
440 546
             <input type="text" size="20" name="url" />
441 547
           </div>
@@ -445,14 +551,19 @@ foreach ($UserAdditions as $UserID => $Additions) {
445 551
           <span style="font-style: italic;">Enter the URL of a torrent group on the site.</span>
446 552
         </form>
447 553
       </div>
554
+
448 555
       <div class="pad hidden add_torrent_container">
449 556
         <form class="add_form" name="torrents" action="collages.php" method="post">
450 557
           <input type="hidden" name="action" value="add_torrent_batch" />
451
-          <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
452
-          <input type="hidden" name="collageid" value="<?=$CollageID?>" />
558
+          <input type="hidden" name="auth"
559
+            value="<?=$LoggedUser['AuthKey']?>" />
560
+          <input type="hidden" name="collageid"
561
+            value="<?=$CollageID?>" />
453 562
           <div class="field_div">
454
-            <textarea name="urls" rows="5" cols="25" style="white-space: pre; word-wrap: normal; overflow: auto;"></textarea>
563
+            <textarea name="urls" rows="5" cols="25"
564
+              style="white-space: pre; word-wrap: normal; overflow: auto;"></textarea>
455 565
           </div>
566
+
456 567
           <div class="submit_div">
457 568
             <input type="submit" value="Add" />
458 569
           </div>
@@ -460,11 +571,12 @@ foreach ($UserAdditions as $UserID => $Additions) {
460 571
         </form>
461 572
       </div>
462 573
     </div>
463
-<? } ?>
574
+    <?php } ?>
575
+
464 576
     <h3>Comments</h3>
465
-<?
577
+    <?php
466 578
 if ($CommentList === null) {
467
-  $DB->query("
579
+    $DB->query("
468 580
     SELECT
469 581
       c.ID,
470 582
       c.Body,
@@ -477,34 +589,41 @@ if ($CommentList === null) {
477 589
       AND c.PageID = $CollageID
478 590
     ORDER BY c.ID DESC
479 591
     LIMIT 15");
480
-  $CommentList = $DB->to_array(false, MYSQLI_NUM);
592
+    $CommentList = $DB->to_array(false, MYSQLI_NUM);
481 593
 }
482 594
 foreach ($CommentList as $Comment) {
483
-  list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment;
484
-?>
595
+    list($CommentID, $Body, $UserID, $Username, $CommentTime) = $Comment; ?>
485 596
     <div class="box comment">
486 597
       <div class="head">
487
-        <?=Users::format_username($UserID, false, false, false) ?> <?=time_diff($CommentTime) ?>
598
+        <?=Users::format_username($UserID, false, false, false) ?>
599
+        <?=time_diff($CommentTime) ?>
488 600
         <br />
489
-        <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$CommentID?>" class="brackets">Report</a>
601
+        <a href="reports.php?action=report&amp;type=comment&amp;id=<?=$CommentID?>"
602
+          class="brackets">Report</a>
603
+      </div>
604
+      <div class="pad"><?=Text::full_format($Body)?>
490 605
       </div>
491
-      <div class="pad"><?=Text::full_format($Body)?></div>
492 606
     </div>
493
-<?
607
+    <?php
494 608
 }
495 609
 ?>
610
+
496 611
     <div class="box pad">
497
-      <a href="collages.php?action=comments&amp;collageid=<?=$CollageID?>" class="brackets">View all comments</a>
612
+      <a href="collages.php?action=comments&amp;collageid=<?=$CollageID?>"
613
+        class="brackets">View all comments</a>
498 614
     </div>
499
-<?
615
+
616
+    <?php
500 617
 if (!$LoggedUser['DisablePosting']) {
501
-?>
618
+    ?>
502 619
     <div class="box box_addcomment">
503 620
       <div class="head"><strong>Comment</strong></div>
504
-      <form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;" action="comments.php" method="post">
621
+      <form class="send_form" name="comment" id="quickpostform" onsubmit="quickpostform.submit_button.disabled = true;"
622
+        action="comments.php" method="post">
505 623
         <input type="hidden" name="action" value="take_post" />
506 624
         <input type="hidden" name="page" value="collages" />
507
-        <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
625
+        <input type="hidden" name="auth"
626
+          value="<?=$LoggedUser['AuthKey']?>" />
508 627
         <input type="hidden" name="pageid" value="<?=$CollageID?>" />
509 628
         <div class="pad">
510 629
           <div class="field_div">
@@ -516,64 +635,120 @@ if (!$LoggedUser['DisablePosting']) {
516 635
         </div>
517 636
       </form>
518 637
     </div>
519
-<?
638
+    <?php
520 639
 }
521 640
 ?>
522 641
   </div>
642
+
523 643
   <div class="main_column">
524
-<?
644
+    <?php
525 645
 if ($CollageCovers != 0) { ?>
526 646
     <div id="coverart" class="box">
527 647
       <div class="head" id="coverhead"><strong>Pictures</strong></div>
528
-      <div class="collage_images" id="collage_page0" data-wall-child=".collage_image" data-wall-size="4" data-wall-min="2">
529
-<?
648
+      <div class="collage_images" id="collage_page0" data-wall-child=".collage_image" data-wall-size="4"
649
+        data-wall-min="2">
650
+        <?php
530 651
   $Page1 = array_slice($Collage, 0, $CollageCovers);
531 652
   foreach ($Page1 as $Group) {
532
-    echo $Group;
653
+      echo $Group;
533 654
   }
534 655
 ?>
535 656
       </div>
536 657
     </div>
537
-<?  if ($NumGroups > $CollageCovers) { ?>
658
+
659
+    <?php if ($NumGroups > $CollageCovers) { ?>
538 660
     <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
539
-      <span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;"><strong>&lt;&lt; First</strong></a> | </span>
540
-      <span id="prevpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;"><strong>&lt; Prev</strong></a> | </span>
541
-<?    for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
542
-      <span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i == 0) ? 'selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); return false;"><strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong></a><?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
543
-<?    } ?>
544
-      <span id="nextbar" class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>"> | </span>
545
-      <span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;"><strong>Next &gt;</strong></a></span>
546
-      <span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>"> | <a href="#" class="pageslink" onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>, this); return false;"><strong>Last &gt;&gt;</strong></a></span>
661
+
662
+      <span id="firstpage" class="invisible">
663
+        <a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">
664
+          <strong>« First</strong>
665
+        </a> |
666
+      </span>
667
+
668
+      <span id="prevpage" class="invisible">
669
+        <a href="#" class="pageslink" onclick="collageShow.prevPage(); return false;">
670
+          <strong>‹ Prev</strong>
671
+        </a> |
672
+      </span>
673
+
674
+      <?php for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
675
+      <span id="pagelink<?=$i?>"
676
+        class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i == 0) ? 'selected' : '')?>">
677
+        <a href="#" class="pageslink"
678
+          onclick="collageShow.page(<?=$i?>, this); return false;">
679
+          <strong><?=$CollageCovers * $i + 1?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></strong>
680
+        </a>
681
+        <?=(($i != ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?>
682
+      </span>
683
+      <?php } ?>
684
+
685
+      <span id="nextbar"
686
+        class="<?=($NumGroups / $CollageCovers > 5) ? 'hidden' : ''?>">
687
+        | </span>
688
+
689
+      <span id="nextpage">
690
+        <a href="#" class="pageslink" onclick="collageShow.nextPage(); return false;">
691
+          <strong>Next ›</strong>
692
+        </a>
693
+      </span>
694
+
695
+      <span id="lastpage"
696
+        class="<?=(ceil($NumGroups / $CollageCovers) == 2 ? 'invisible' : '')?>">
697
+        |
698
+        <a href="#" class="pageslink"
699
+          onclick="collageShow.page(<?=ceil($NumGroups / $CollageCovers) - 1?>, this); return false;">
700
+          <strong>Last »</strong>
701
+        </a>
702
+      </span>
547 703
     </div>
704
+
548 705
     <script type="text/javascript">
549
-      $(()=>collageShow.init(<?=json_encode($CollagePages)?>));
706
+      $(() => collageShow.init( <?=json_encode($CollagePages)?> ));
550 707
     </script>
551
-<?
708
+    <?php
552 709
   }
553 710
 }
554 711
 ?>
712
+
555 713
     <div class="box">
556
-    <table class="torrent_table grouping cats" id="discog_table">
557
-      <tr class="colhead_dark">
558
-        <td><!-- expand/collapse --></td>
559
-        <td><!-- Category --></td>
560
-        <td width="70%"><strong>Torrents</strong></td>
561
-        <td>Size</td>
562
-        <td class="sign snatches">
563
-          <a><svg width="15" height="15" fill="black" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></a>
564
-        </td>
565
-        <td class="sign seeders">
566
-          <a><svg width="11" height="15" fill="black" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></a>
567
-        </td>
568
-        <td class="sign leechers">
569
-          <a><svg width="11" height="15" fill="black" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></a>
570
-        </td>
571
-      </tr>
572
-<?=$TorrentTable?>
573
-    </table>
714
+      <table class="torrent_table grouping cats" id="discog_table">
715
+        <tr class="colhead_dark">
716
+          <td>
717
+            <!-- Expand/Collapse -->
718
+          </td>
719
+
720
+          <td>
721
+            <!-- Category -->
722
+          </td>
723
+
724
+          <td width="70%"><strong>Torrents</strong></td>
725
+
726
+          <td>Size</td>
727
+
728
+          <td class="sign snatches">
729
+            <a><svg width="15" height="15" fill="black" class="tooltip" alt="Snatches" title="Snatches"
730
+                viewBox="3 0 88 98">
731
+                <path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path>
732
+              </svg></a>
733
+          </td>
734
+
735
+          <td class="sign seeders">
736
+            <a><svg width="11" height="15" fill="black" class="tooltip" alt="Seeders" title="Seeders">
737
+                <polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon>
738
+              </svg></a>
739
+          </td>
740
+
741
+          <td class="sign leechers">
742
+            <a><svg width="11" height="15" fill="black" class="tooltip" alt="Leechers" title="Leechers">
743
+                <polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon>
744
+              </svg></a>
745
+          </td>
746
+        </tr>
747
+
748
+        <?=$TorrentTable?>
749
+
750
+      </table>
574 751
     </div>
575 752
   </div>
576 753
 </div>
577
-<?
578
-View::show_footer();
579
-?>
754
+<?php View::show_footer();

+ 33
- 32
sections/forums/edit_rules.php View File

@@ -1,52 +1,52 @@
1
-<?
1
+<?php
2 2
 
3 3
 enforce_login();
4 4
 if (!check_perms('site_moderate_forums')) {
5
-  error(403);
5
+    error(403);
6 6
 }
7 7
 
8
-
9 8
 $ForumID = $_GET['forumid'];
10 9
 if (!is_number($ForumID)) {
11
-  error(404);
10
+    error(404);
12 11
 }
13 12
 
14
-
15 13
 if (!empty($_POST['add']) || (!empty($_POST['del']))) {
16
-  if (!empty($_POST['add'])) {
17
-    if (is_number($_POST['new_thread'])) {
18
-      $DB->query("
19
-        INSERT INTO forums_specific_rules (ForumID, ThreadID)
20
-        VALUES ($ForumID, ".$_POST['new_thread'].')');
14
+    if (!empty($_POST['add'])) {
15
+        if (is_number($_POST['new_thread'])) {
16
+            $DB->query("
17
+            INSERT INTO forums_specific_rules (ForumID, ThreadID)
18
+            VALUES ($ForumID, ".$_POST['new_thread'].')');
19
+        }
21 20
     }
22
-  }
23
-  if (!empty($_POST['del'])) {
24
-    if (is_number($_POST['threadid'])) {
25
-      $DB->query("
26
-        DELETE FROM forums_specific_rules
27
-        WHERE ForumID = $ForumID
28
-          AND ThreadID = ".$_POST['threadid']);
21
+
22
+    if (!empty($_POST['del'])) {
23
+        if (is_number($_POST['threadid'])) {
24
+            $DB->query("
25
+            DELETE FROM forums_specific_rules
26
+            WHERE ForumID = $ForumID
27
+              AND ThreadID = ".$_POST['threadid']);
28
+        }
29 29
     }
30
-  }
31
-  $Cache->delete_value('forums_list');
30
+    $Cache->delete_value('forums_list');
32 31
 }
33 32
 
34
-
35 33
 $DB->query("
36
-  SELECT ThreadID
37
-  FROM forums_specific_rules
34
+SELECT ThreadID
35
+FROM forums_specific_rules
38 36
   WHERE ForumID = $ForumID");
39 37
 $ThreadIDs = $DB->collect('ThreadID');
40 38
 
41 39
 View::show_header();
42 40
 ?>
41
+
43 42
 <div class="thin box pad">
44 43
   <div class="header">
45 44
     <h2>
46 45
       <a href="forums.php">Forums</a>
47
-      &gt;
48
-      <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$Forums[$ForumID]['Name']?></a>
49
-      &gt;
46
+      ›
47
+      <a
48
+        href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$Forums[$ForumID]['Name']?></a>
49
+      ›
50 50
       Edit forum specific rules
51 51
     </h2>
52 52
   </div>
@@ -64,19 +64,20 @@ View::show_header();
64 64
           <input type="submit" name="add" value="Add thread" />
65 65
         </td>
66 66
       </form>
67
-<?  foreach ($ThreadIDs as $ThreadID) { ?>
67
+      <?php foreach ($ThreadIDs as $ThreadID) { ?>
68 68
     <tr>
69
-      <td><?=$ThreadID?></td>
69
+      <td><?=$ThreadID?>
70
+      </td>
70 71
       <td>
71 72
         <form class="delete_form" name="forum_rules" action="" method="post">
72
-          <input type="hidden" name="threadid" value="<?=$ThreadID?>" />
73
+          <input type="hidden" name="threadid"
74
+            value="<?=$ThreadID?>" />
73 75
           <input type="submit" name="del" value="Delete link" />
74 76
         </form>
75 77
       </td>
76 78
     </tr>
77
-<?  } ?>
79
+    <?php } ?>
78 80
   </table>
79 81
 </div>
80
-<?
81
-View::show_footer();
82
-?>
82
+
83
+<?php View::show_footer();

+ 138
- 120
sections/forums/forum.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 /**********|| Page to show individual forums || ********************************\
3 4
 
4 5
 Things to expect in $_GET:
@@ -13,15 +14,15 @@ Things to expect in $_GET:
13 14
 // Check for lame SQL injection attempts
14 15
 $ForumID = $_GET['forumid'];
15 16
 if (!is_number($ForumID)) {
16
-  error(0);
17
+    error(0);
17 18
 }
18 19
 
19 20
 $Tooltip = "tooltip";
20 21
 
21 22
 if (isset($LoggedUser['PostsPerPage'])) {
22
-  $PerPage = $LoggedUser['PostsPerPage'];
23
+    $PerPage = $LoggedUser['PostsPerPage'];
23 24
 } else {
24
-  $PerPage = POSTS_PER_PAGE;
25
+    $PerPage = POSTS_PER_PAGE;
25 26
 }
26 27
 
27 28
 list($Page, $Limit) = Format::page_limit(TOPICS_PER_PAGE);
@@ -30,11 +31,12 @@ list($Page, $Limit) = Format::page_limit(TOPICS_PER_PAGE);
30 31
 
31 32
 // Caching anything beyond the first page of any given forum is just wasting RAM.
32 33
 // Users are more likely to search than to browse to page 2.
33
-if ($Page == 1) {
34
-  list($Forum,,,$Stickies) = $Cache->get_value("forums_$ForumID");
34
+if ($Page === 1) {
35
+    list($Forum, , , $Stickies) = $Cache->get_value("forums_$ForumID");
35 36
 }
37
+
36 38
 if (!isset($Forum) || !is_array($Forum)) {
37
-  $DB->query("
39
+    $DB->query("
38 40
     SELECT
39 41
       ID,
40 42
       Title,
@@ -49,44 +51,47 @@ if (!isset($Forum) || !is_array($Forum)) {
49 51
     WHERE ForumID = '$ForumID'
50 52
     ORDER BY IsSticky DESC, Ranking ASC, LastPostTime DESC
51 53
     LIMIT $Limit"); // Can be cached until someone makes a new post
52
-  $Forum = $DB->to_array('ID', MYSQLI_ASSOC, false);
54
+    $Forum = $DB->to_array('ID', MYSQLI_ASSOC, false);
53 55
 
54
-  if ($Page == 1) {
55
-    $DB->query("
56
+    if ($Page === 1) {
57
+        $DB->query("
56 58
       SELECT COUNT(ID)
57 59
       FROM forums_topics
58 60
       WHERE ForumID = '$ForumID'
59 61
         AND IsSticky = '1'");
60
-    list($Stickies) = $DB->next_record();
61
-    $Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
62
-  }
62
+        list($Stickies) = $DB->next_record();
63
+        $Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
64
+    }
63 65
 }
64 66
 
65 67
 if (!isset($Forums[$ForumID])) {
66
-  error(404);
68
+    error(404);
67 69
 }
70
+
68 71
 // Make sure they're allowed to look at the page
69 72
 if (!check_perms('site_moderate_forums')) {
70
-  if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) {
71
-    error(403);
72
-  }
73
+    if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) {
74
+        error(403);
75
+    }
73 76
 }
74 77
 
75
-
76 78
 $ForumName = display_str($Forums[$ForumID]['Name']);
77 79
 if (!Forums::check_forumperm($ForumID)) {
78
-  error(403);
80
+    error(403);
79 81
 }
80 82
 
81 83
 // Start printing
82
-View::show_header('Forums &gt; '. $Forums[$ForumID]['Name'], '', '');
84
+View::show_header('Forums  '. $Forums[$ForumID]['Name'], '', '');
83 85
 ?>
86
+
84 87
 <div class="thin">
85
-  <h2><a href="forums.php">Forums</a> &gt; <?=$ForumName?></h2>
88
+  <h2><a href="forums.php">Forums</a> › <?=$ForumName?>
89
+  </h2>
86 90
   <div class="linkbox">
87
-<? if (Forums::check_forumperm($ForumID, 'Write') && Forums::check_forumperm($ForumID, 'Create')) { ?>
88
-    <a href="forums.php?action=new&amp;forumid=<?=$ForumID?>" class="brackets">New thread</a>
89
-<? } ?>
91
+    <?php if (Forums::check_forumperm($ForumID, 'Write') && Forums::check_forumperm($ForumID, 'Create')) { ?>
92
+    <a href="forums.php?action=new&amp;forumid=<?=$ForumID?>"
93
+      class="brackets">New thread</a>
94
+    <?php } ?>
90 95
     <a data-toggle-target="#searchforum" data-toggle-replace="Hide search" class="brackets">Search this forum</a>
91 96
     <div id="searchforum" class="hidden center">
92 97
       <div style="display: inline-block;">
@@ -96,7 +101,8 @@ View::show_header('Forums &gt; '. $Forums[$ForumID]['Name'], '', '');
96 101
             <tr>
97 102
               <td>
98 103
                 <input type="hidden" name="action" value="search" />
99
-                <input type="hidden" name="forums[]" value="<?=$ForumID?>" />
104
+                <input type="hidden" name="forums[]"
105
+                  value="<?=$ForumID?>" />
100 106
                 <strong>Search Terms</strong>
101 107
               </td>
102 108
               <td>
@@ -127,27 +133,29 @@ View::show_header('Forums &gt; '. $Forums[$ForumID]['Name'], '', '');
127 133
       </div>
128 134
     </div>
129 135
   </div>
130
-<?  if (check_perms('site_moderate_forums')) { ?>
136
+  <?php if (check_perms('site_moderate_forums')) { ?>
131 137
   <div class="linkbox">
132
-    <a href="forums.php?action=edit_rules&amp;forumid=<?=$ForumID?>" class="brackets">Change specific rules</a>
138
+    <a href="forums.php?action=edit_rules&amp;forumid=<?=$ForumID?>"
139
+      class="brackets">Change specific rules</a>
133 140
   </div>
134
-<?  } ?>
135
-<?  if (!empty($Forums[$ForumID]['SpecificRules'])) { ?>
141
+  <?php } ?>
142
+  <?php if (!empty($Forums[$ForumID]['SpecificRules'])) { ?>
136 143
   <div class="linkbox">
137
-      <strong>Forum Specific Rules</strong>
138
-<?    foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) {
139
-      $Thread = Forums::get_thread_info($ThreadIDs);
140
-      if ($Thread === null) {
144
+    <strong>Forum Specific Rules</strong>
145
+    <?php foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) {
146
+    $Thread = Forums::get_thread_info($ThreadIDs);
147
+    if ($Thread === null) {
141 148
         error(404);
142
-      }
143
-?>
149
+    } ?>
144 150
     <br />
145
-    <a href="forums.php?action=viewthread&amp;threadid=<?=$ThreadIDs?>" class="brackets"><?=display_str($Thread['Title'])?></a>
146
-<?    } ?>
151
+    <a href="forums.php?action=viewthread&amp;threadid=<?=$ThreadIDs?>"
152
+      class="brackets"><?=display_str($Thread['Title'])?></a>
153
+    <?php
154
+} ?>
147 155
   </div>
148
-<?  } ?>
156
+  <?php } ?>
149 157
   <div class="linkbox pager">
150
-<?
158
+    <?php
151 159
 $Pages = Format::get_pages($Page, $Forums[$ForumID]['NumTopics'], TOPICS_PER_PAGE, 9);
152 160
 echo $Pages;
153 161
 ?>
@@ -159,19 +167,19 @@ echo $Pages;
159 167
       <td style="width: 7%;">Replies</td>
160 168
       <td style="width: 14%;">Author</td>
161 169
     </tr>
162
-<?
170
+    <?php
163 171
 // Check that we have content to process
164 172
 if (count($Forum) === 0) {
165
-?>
173
+    ?>
166 174
     <tr>
167 175
       <td colspan="4">
168 176
         No threads to display in this forum!
169 177
       </td>
170 178
     </tr>
171
-<?
179
+    <?php
172 180
 } else {
173
-  // forums_last_read_topics is a record of the last post a user read in a topic, and what page that was on
174
-  $DB->query("
181
+        // forums_last_read_topics is a record of the last post a user read in a topic, and what page that was on
182
+        $DB->query("
175 183
     SELECT
176 184
       l.TopicID,
177 185
       l.PostID,
@@ -186,89 +194,99 @@ if (count($Forum) === 0) {
186 194
     WHERE l.TopicID IN (".implode(', ', array_keys($Forum)).')
187 195
       AND l.UserID = \''.$LoggedUser['ID'].'\'');
188 196
 
189
-  // Turns the result set into a multi-dimensional array, with
190
-  // forums_last_read_topics.TopicID as the key.
191
-  // This is done here so we get the benefit of the caching, and we
192
-  // don't have to make a database query for each topic on the page
193
-  $LastRead = $DB->to_array('TopicID');
197
+        // Turns the result set into a multi-dimensional array, with
198
+        // forums_last_read_topics.TopicID as the key.
199
+        // This is done here so we get the benefit of the caching, and we
200
+        // don't have to make a database query for each topic on the page
201
+        $LastRead = $DB->to_array('TopicID');
194 202
 
195
-  //---------- Begin printing
203
+        //---------- Begin printing
196 204
 
197
-  foreach ($Forum as $Topic) {
198
-    list($TopicID, $Title, $AuthorID, $Locked, $Sticky, $PostCount, $LastID, $LastTime, $LastAuthorID) = array_values($Topic);
199
-    // Build list of page links
200
-    // Only do this if there is more than one page
201
-    $PageLinks = [];
202
-    $ShownEllipses = false;
203
-    $PagesText = '';
204
-    $TopicPages = ceil($PostCount / $PerPage);
205
+        foreach ($Forum as $Topic) {
206
+            list($TopicID, $Title, $AuthorID, $Locked, $Sticky, $PostCount, $LastID, $LastTime, $LastAuthorID) = array_values($Topic);
207
+            // Build list of page links
208
+            // Only do this if there is more than one page
209
+            $PageLinks = [];
210
+            $ShownEllipses = false;
211
+            $PagesText = '';
212
+            $TopicPages = ceil($PostCount / $PerPage);
205 213
 
206
-    if ($TopicPages > 1) {
207
-      $PagesText = ' (';
208
-      for ($i = 1; $i <= $TopicPages; $i++) {
209
-        if ($TopicPages > 4 && ($i > 2 && $i <= $TopicPages - 2)) {
210
-          if (!$ShownEllipses) {
211
-            $PageLinks[] = '-';
212
-            $ShownEllipses = true;
213
-          }
214
-          continue;
215
-        }
216
-        $PageLinks[] = "<a href=\"forums.php?action=viewthread&amp;threadid=$TopicID&amp;page=$i\">$i</a>";
217
-      }
218
-      $PagesText .= implode(' ', $PageLinks);
219
-      $PagesText .= ')';
220
-    }
214
+            if ($TopicPages > 1) {
215
+                $PagesText = ' (';
216
+                for ($i = 1; $i <= $TopicPages; $i++) {
217
+                    if ($TopicPages > 4 && ($i > 2 && $i <= $TopicPages - 2)) {
218
+                        if (!$ShownEllipses) {
219
+                            $PageLinks[] = '-';
220
+                            $ShownEllipses = true;
221
+                        }
222
+                        continue;
223
+                    }
224
+                    $PageLinks[] = "<a href=\"forums.php?action=viewthread&amp;threadid=$TopicID&amp;page=$i\">$i</a>";
225
+                }
226
+                $PagesText .= implode(' ', $PageLinks);
227
+                $PagesText .= ')';
228
+            }
221 229
 
222
-    // handle read/unread posts - the reason we can't cache the whole page
223
-    if ((!$Locked || $Sticky) && ((empty($LastRead[$TopicID]) || $LastRead[$TopicID]['PostID'] < $LastID) && strtotime($LastTime) > $LoggedUser['CatchupTime'])) {
224
-      $Read = 'unread';
225
-    } else {
226
-      $Read = 'read';
227
-    }
228
-    if ($Locked) {
229
-      $Read .= '_locked';
230
-    }
231
-    if ($Sticky) {
232
-      $Read .= '_sticky';
233
-    }
234
-?>
235
-  <tr class="row">
236
-    <td class="<?=$Read?> <?=$Tooltip?>" title="<?=ucwords(str_replace('_', ' ', $Read))?>"></td>
237
-    <td>
238
-      <span class="float_left last_topic">
239
-<?
230
+            // handle read/unread posts - the reason we can't cache the whole page
231
+            if ((!$Locked || $Sticky) && ((empty($LastRead[$TopicID]) || $LastRead[$TopicID]['PostID'] < $LastID) && strtotime($LastTime) > $LoggedUser['CatchupTime'])) {
232
+                $Read = 'unread';
233
+            } else {
234
+                $Read = 'read';
235
+            }
236
+            if ($Locked) {
237
+                $Read .= '_locked';
238
+            }
239
+            if ($Sticky) {
240
+                $Read .= '_sticky';
241
+            } ?>
242
+    <tr class="row">
243
+      <td
244
+        class="<?=$Read?> <?=$Tooltip?>"
245
+        title="<?=ucwords(str_replace('_', ' ', $Read))?>">
246
+      </td>
247
+      <td>
248
+        <span class="float_left last_topic">
249
+          <?php
240 250
     $TopicLength = 75 - (2 * count($PageLinks));
241
-    unset($PageLinks);
242
-    $Title = display_str($Title);
243
-    $DisplayTitle = $Title;
244
-
245
-?>
246
-        <strong>
247
-          <a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>" class="tooltip" data-title-plain="<?=$Title?>"><?=Format::cut_string($DisplayTitle, $TopicLength) ?></a>
248
-        </strong>
249
-        <?=$PagesText?>
250
-      </span>
251
-<?    if (!empty($LastRead[$TopicID])) { ?>
252
-      <a class="<?=$Tooltip?> last_read" title="Jump to last read" href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>&amp;page=<?=$LastRead[$TopicID]['Page']?>#post<?=$LastRead[$TopicID]['PostID']?>">
253
-        <svg width="15" height="11"><polygon points="0,3 0,8 8,8 8,11 15,5.5 8,0 8,3"/></svg>
254
-      </a>
255
-<?    } ?>
256
-      <span class="float_right last_poster">
257
-        by <?=Users::format_username($LastAuthorID, false, false, false, false, false)?> <?=time_diff($LastTime,1)?>
258
-      </span>
259
-    </td>
260
-    <td class="number_column"><?=number_format($PostCount - 1)?></td>
261
-    <td><?=Users::format_username($AuthorID, false, false, false, false, false)?></td>
262
-  </tr>
263
-<?  }
264
-} ?>
265
-</table>
266
-<!--<div class="breadcrumbs">
267
-  <a href="forums.php">Forums</a> &gt; <?=$ForumName?>
268
-</div>-->
251
+            unset($PageLinks);
252
+            $Title = display_str($Title);
253
+            $DisplayTitle = $Title; ?>
254
+          <strong>
255
+            <a href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>"
256
+              class="tooltip" data-title-plain="<?=$Title?>"><?=Format::cut_string($DisplayTitle, $TopicLength) ?></a>
257
+          </strong>
258
+          <?=$PagesText?>
259
+        </span>
260
+        <?php if (!empty($LastRead[$TopicID])) { ?>
261
+        <a class="<?=$Tooltip?> last_read" title="Jump to last read"
262
+          href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>&amp;page=<?=$LastRead[$TopicID]['Page']?>#post<?=$LastRead[$TopicID]['PostID']?>">
263
+          <svg width="15" height="11">
264
+            <polygon points="0,3 0,8 8,8 8,11 15,5.5 8,0 8,3" /></svg>
265
+        </a>
266
+        <?php } ?>
267
+        <span class="float_right last_poster">
268
+          by <?=Users::format_username($LastAuthorID, false, false, false, false, false)?>
269
+          <?=time_diff($LastTime, 1)?>
270
+        </span>
271
+      </td>
272
+      <td class="number_column"><?=number_format($PostCount - 1)?>
273
+      </td>
274
+      <td><?=Users::format_username($AuthorID, false, false, false, false, false)?>
275
+      </td>
276
+    </tr>
277
+    <?php
278
+        }
279
+    } ?>
280
+  </table>
281
+  <div class="breadcrumbs">
282
+    <a href="forums.php">Forums</a> › <?=$ForumName?>
283
+  </div>
269 284
   <div class="linkbox pager">
270 285
     <?=$Pages?>
271 286
   </div>
272
-  <div class="linkbox"><a href="forums.php?action=catchup&amp;forumid=<?=$ForumID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a></div>
287
+  <div class="linkbox"><a
288
+      href="forums.php?action=catchup&amp;forumid=<?=$ForumID?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
289
+      class="brackets">Catch up</a></div>
273 290
 </div>
274
-<? View::show_footer(); ?>
291
+
292
+<?php View::show_footer();

+ 54
- 32
sections/forums/newthread.php View File

@@ -1,4 +1,5 @@
1
-<?
1
+<?php
2
+
2 3
 /*
3 4
 New post page
4 5
 
@@ -11,21 +12,33 @@ Information to be expected in $_GET:
11 12
 
12 13
 $ForumID = $_GET['forumid'];
13 14
 if (!is_number($ForumID)) {
14
-  error(404);
15
+    error(404);
15 16
 }
17
+
16 18
 $Forum = Forums::get_forum_info($ForumID);
17 19
 if ($Forum === false) {
18
-  error(404);
20
+    error(404);
19 21
 }
20 22
 
21
-
22 23
 if (!Forums::check_forumperm($ForumID, 'Write') || !Forums::check_forumperm($ForumID, 'Create')) {
23
-  error(403);
24
+    error(403);
24 25
 }
25
-View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbcode,jquery.validate,form_validate');
26
+
27
+View::show_header('Forums › '.$Forum['Name'].' › New Topic', 'comments,bbcode,jquery.validate,form_validate');
26 28
 ?>
29
+
27 30
 <div class="thin">
28
-  <h2><a href="forums.php">Forums</a> &gt; <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$Forum['Name']?></a> &gt; <span id="newthreadtitle">New Topic</span></h2>
31
+  <h2>
32
+    <a href="forums.php">Forums</a>
33
+    ›
34
+    <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>">
35
+      <?=$Forum['Name']?></a>
36
+    ›
37
+    <span id="newthreadtitle">
38
+      New Topic
39
+    </span>
40
+  </h2>
41
+
29 42
   <div class="hidden" id="newthreadpreview">
30 43
     <div class="linkbox">
31 44
       <div class="center">
@@ -33,29 +46,31 @@ View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbc
33 46
         <a href="#" onclick="return false;" class="brackets"><?=!empty($HeavyInfo['AutoSubscribe']) ? 'Unsubscribe' : 'Subscribe'?></a>
34 47
       </div>
35 48
     </div>
36
-<?  if (check_perms('forums_polls_create')) { ?>
49
+    <?php if (check_perms('forums_polls_create')) { ?>
37 50
     <div class="box thin clear hidden" id="pollpreview">
38
-      <div class="head colhead_dark"><strong>Poll</strong> <a data-toggle-target="#threadpoll" class="brackets">View</a></div>
51
+      <div class="head colhead_dark"><strong>Poll</strong> <a data-toggle-target="#threadpoll" class="brackets">View</a>
52
+      </div>
39 53
       <div class="pad" id="threadpoll">
40 54
         <p><strong id="pollquestion"></strong></p>
41 55
         <div id="pollanswers"></div>
42
-        <br /><input type="radio" name="vote" id="answer_0" value="0" /> <label for="answer_0">Blank&#8202;&mdash;&#8202;Show the results!</label><br /><br />
56
+        <br /><input type="radio" name="vote" id="answer_0" value="0" /> <label
57
+          for="answer_0">Blank&#8202;&mdash;&#8202;Show the results!</label><br /><br />
43 58
         <input type="button" class="float_left" value="Vote" />
44 59
       </div>
45 60
     </div>
46
-<?  } ?>
61
+    <?php } ?>
47 62
     <table class="forum_post box vertical_margin" style="text-align: left;">
48 63
       <colgroup>
49
-<?  if (Users::has_avatars_enabled()) { ?>
64
+        <?php if (Users::has_avatars_enabled()) { ?>
50 65
         <col class="col_avatar" />
51
-<?  } ?>
66
+        <?php } ?>
52 67
         <col class="col_post_body" />
53 68
       </colgroup>
54 69
       <tr class="colhead_dark">
55 70
         <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1 ?>">
56 71
           <span class="float_left"><a href="#newthreadpreview">#XXXXXX</a>
57 72
             by <strong><?=Users::format_username($LoggedUser['ID'], true, true, true, true, true)?></strong>
58
-          Just now
73
+            Just now
59 74
           </span>
60 75
           <span id="barpreview" class="float_right">
61 76
             <a href="#newthreadpreview" class="brackets">Report</a>
@@ -65,11 +80,11 @@ View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbc
65 80
         </td>
66 81
       </tr>
67 82
       <tr>
68
-<?  if (Users::has_avatars_enabled()) { ?>
83
+        <?php if (Users::has_avatars_enabled()) { ?>
69 84
         <td class="avatar" valign="top">
70 85
           <?=Users::show_avatar($LoggedUser['Avatar'], $LoggedUser['ID'], $LoggedUser['Username'], $HeavyInfo['DisableAvatars'])?>
71 86
         </td>
72
-<?  } ?>
87
+        <?php } ?>
73 88
         <td class="body" valign="top">
74 89
           <div id="contentpreview" style="text-align: left;"></div>
75 90
         </td>
@@ -79,7 +94,8 @@ View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbc
79 94
   <div class="box pad">
80 95
     <form class="create_form" name="forum_thread" action="" id="newthreadform" method="post">
81 96
       <input type="hidden" name="action" value="new" />
82
-      <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
97
+      <input type="hidden" name="auth"
98
+        value="<?=$LoggedUser['AuthKey']?>" />
83 99
       <input type="hidden" name="forum" value="<?=$ForumID?>" />
84 100
       <table id="newthreadtext" class="layout">
85 101
         <tr>
@@ -88,28 +104,31 @@ View::show_header('Forums &gt; '.$Forum['Name'].' &gt; New Topic', 'comments,bbc
88 104
         </tr>
89 105
         <tr>
90 106
           <td class="label">Body</td>
91
-          <td><textarea id="posttext" class="required bbcode_editor" style="width: 98%;" onkeyup="resize('posttext');" name="body" cols="90" rows="8"></textarea></td>
107
+          <td><textarea id="posttext" class="required bbcode_editor" style="width: 98%;" onkeyup="resize('posttext');"
108
+              name="body" cols="90" rows="8"></textarea></td>
92 109
         </tr>
93 110
         <tr>
94 111
           <td></td>
95 112
           <td>
96
-            <input id="subscribebox" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?> onchange="$('#subscribeboxpreview').raw().checked=this.checked;" />
113
+            <input id="subscribebox" type="checkbox" name="subscribe" <?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : ''?>
114
+            onchange="$('#subscribeboxpreview').raw().checked=this.checked;" />
97 115
             <label for="subscribebox">Subscribe to topic</label>
98 116
           </td>
99 117
         </tr>
100
-<?
118
+        <?php
101 119
 if (check_perms('forums_polls_create')) {
102
-?>
103
-        <script type="text/javascript">//<![CDATA[
104
-        var AnswerCount = 1;
120
+    ?>
121
+        <script type="text/javascript">
122
+          //<![CDATA[
123
+          var AnswerCount = 1;
105 124
 
106
-        function AddAnswerField() {
125
+          function AddAnswerField() {
107 126
             if (AnswerCount >= 25) {
108 127
               return;
109 128
             }
110 129
             var AnswerField = document.createElement("input");
111 130
             AnswerField.type = "text";
112
-            AnswerField.id = "answer_"+AnswerCount;
131
+            AnswerField.id = "answer_" + AnswerCount;
113 132
             AnswerField.className = "required";
114 133
             AnswerField.name = "answers[]";
115 134
             AnswerField.style.width = "90%";
@@ -118,9 +137,9 @@ if (check_perms('forums_polls_create')) {
118 137
             x.appendChild(document.createElement("br"));
119 138
             x.appendChild(AnswerField);
120 139
             AnswerCount++;
121
-        }
140
+          }
122 141
 
123
-        function RemoveAnswerField() {
142
+          function RemoveAnswerField() {
124 143
             if (AnswerCount == 1) {
125 144
               return;
126 145
             }
@@ -129,8 +148,8 @@ if (check_perms('forums_polls_create')) {
129 148
               x.removeChild(x.lastChild);
130 149
             }
131 150
             AnswerCount--;
132
-        }
133
-        //]]>
151
+          }
152
+          //]]>
134 153
         </script>
135 154
         <tr>
136 155
           <td colspan="2" class="center">
@@ -150,10 +169,12 @@ if (check_perms('forums_polls_create')) {
150 169
             <a href="#" onclick="RemoveAnswerField();return false;" class="brackets">&minus;</a>
151 170
           </td>
152 171
         </tr>
153
-<? } ?>
172
+        <?php
173
+} ?>
154 174
       </table>
155 175
       <div id="subscribediv" class="hidden">
156
-        <input id="subscribeboxpreview" type="checkbox" name="subscribe"<?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : '' ?> />
176
+        <input id="subscribeboxpreview" type="checkbox" name="subscribe" <?=!empty($HeavyInfo['AutoSubscribe']) ? ' checked="checked"' : '' ?>
177
+        />
157 178
         <label for="subscribebox">Subscribe to topic</label>
158 179
       </div>
159 180
       <div id="buttons" class="center">
@@ -164,4 +185,5 @@ if (check_perms('forums_polls_create')) {
164 185
     </form>
165 186
   </div>
166 187
 </div>
167
-<? View::show_footer(); ?>
188
+
189
+<?php View::show_footer();

+ 834
- 628
sections/user/edit.php
File diff suppressed because it is too large
View File


+ 100
- 73
sections/userhistory/subscriptions.php View File

@@ -1,16 +1,17 @@
1
-<?
1
+<?php
2
+
2 3
 /*
3
-User subscription page
4
-*/
4
+ * User subscription page
5
+ */
5 6
 
6 7
 if (isset($LoggedUser['PostsPerPage'])) {
7
-  $PerPage = $LoggedUser['PostsPerPage'];
8
+    $PerPage = $LoggedUser['PostsPerPage'];
8 9
 } else {
9
-  $PerPage = POSTS_PER_PAGE;
10
+    $PerPage = POSTS_PER_PAGE;
10 11
 }
11 12
 list($Page, $Limit) = Format::page_limit($PerPage);
12 13
 
13
-View::show_header('Subscriptions','subscriptions,bbcode');
14
+View::show_header('Subscriptions', 'subscriptions,bbcode');
14 15
 
15 16
 $ShowUnread = (!isset($_GET['showunread']) && !isset($HeavyInfo['SubscriptionsUnread']) || isset($HeavyInfo['SubscriptionsUnread']) && !!$HeavyInfo['SubscriptionsUnread'] || isset($_GET['showunread']) && !!$_GET['showunread']);
16 17
 $ShowCollapsed = (!isset($_GET['collapse']) && !isset($HeavyInfo['SubscriptionsCollapse']) || isset($HeavyInfo['SubscriptionsCollapse']) && !!$HeavyInfo['SubscriptionsCollapse'] || isset($_GET['collapse']) && !!$_GET['collapse']);
@@ -85,6 +86,7 @@ $DB->query("
85 86
   GROUP BY t.ID)
86 87
   ORDER BY LastPostTime DESC
87 88
   LIMIT $Limit");
89
+
88 90
 $Results = $DB->to_array(false, MYSQLI_ASSOC, false);
89 91
 $DB->query('SELECT FOUND_ROWS()');
90 92
 list($NumResults) = $DB->next_record();
@@ -93,63 +95,68 @@ $Debug->log_var($Results, 'Results');
93 95
 
94 96
 $TorrentGroups = $Requests = [];
95 97
 foreach ($Results as $Result) {
96
-  if ($Result['Page'] == 'torrents') {
97
-    $TorrentGroups[] = $Result['PageID'];
98
-  } elseif ($Result['Page'] == 'requests') {
99
-    $Requests[] = $Result['PageID'];
100
-  }
98
+    if ($Result['Page'] === 'torrents') {
99
+        $TorrentGroups[] = $Result['PageID'];
100
+    } elseif ($Result['Page'] === 'requests') {
101
+        $Requests[] = $Result['PageID'];
102
+    }
101 103
 }
102 104
 
103 105
 $TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false);
104 106
 $Requests = Requests::get_requests($Requests);
105
-
106 107
 ?>
108
+
107 109
 <div class="thin">
108 110
   <div class="header">
109
-    <h2>Subscriptions<?=$ShowUnread ? ' with unread posts' . ($NumResults ? ' (' . $NumResults . ' new)' : '') : ''?></h2>
111
+    <h2>Subscriptions<?=$ShowUnread ? ' with unread posts' . ($NumResults ? ' (' . $NumResults . ' new)' : '') : ''?>
112
+    </h2>
110 113
 
111 114
     <div class="linkbox">
112
-<?
115
+      <?php
113 116
 if (!$ShowUnread) {
114
-?>
117
+    ?>
115 118
       <br /><br />
116
-      <a href="userhistory.php?action=subscriptions&amp;showunread=1" class="brackets">Only display subscriptions with unread replies</a>&nbsp;&nbsp;&nbsp;
117
-<?
119
+      <a href="userhistory.php?action=subscriptions&amp;showunread=1" class="brackets">Only display subscriptions with
120
+        unread replies</a>&nbsp;&nbsp;&nbsp;
121
+      <?php
118 122
 } else {
119
-?>
123
+        ?>
120 124
       <br /><br />
121
-      <a href="userhistory.php?action=subscriptions&amp;showunread=0" class="brackets">Show all subscriptions</a>&nbsp;&nbsp;&nbsp;
122
-<?
123
-}
125
+      <a href="userhistory.php?action=subscriptions&amp;showunread=0" class="brackets">Show all
126
+        subscriptions</a>&nbsp;&nbsp;&nbsp;
127
+      <?php
128
+    }
124 129
 if ($NumResults) {
125
-?>
126
-      <a href="#" onclick="Collapse(); return false;" id="collapselink" class="brackets"><?=$ShowCollapsed ? 'Show' : 'Hide' ?> post bodies</a>&nbsp;&nbsp;&nbsp;
127
-<?
130
+    ?>
131
+      <a href="#" onclick="Collapse(); return false;" id="collapselink" class="brackets"><?=$ShowCollapsed ? 'Show' : 'Hide' ?>
132
+        post bodies</a>&nbsp;&nbsp;&nbsp;
133
+      <?php
128 134
 }
129 135
 ?>
130
-      <a href="userhistory.php?action=catchup&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
131
-      <a href="userhistory.php?action=posts&amp;userid=<?=$LoggedUser['ID']?>" class="brackets">Go to post history</a>&nbsp;&nbsp;&nbsp;
136
+      <a href="userhistory.php?action=catchup&amp;auth=<?=$LoggedUser['AuthKey']?>"
137
+        class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
138
+      <a href="userhistory.php?action=posts&amp;userid=<?=$LoggedUser['ID']?>"
139
+        class="brackets">Go to post history</a>&nbsp;&nbsp;&nbsp;
132 140
       <a href="userhistory.php?action=quote_notifications" class="brackets">Quote notifications</a>&nbsp;&nbsp;&nbsp;
133 141
     </div>
134 142
   </div>
135
-<?
143
+  <?php
136 144
 if (!$NumResults) {
137
-?>
145
+    ?>
138 146
   <div class="center">
139 147
     No subscriptions<?=$ShowUnread ? ' with unread posts' : ''?>
140 148
   </div>
141
-<?
149
+  <?php
142 150
 } else {
143
-?>
151
+        ?>
144 152
   <div class="linkbox">
145
-<?
153
+    <?php
146 154
   $Pages = Format::get_pages($Page, $NumResults, $PerPage, 11);
147
-  echo $Pages;
148
-?>
155
+        echo $Pages; ?>
149 156
   </div>
150
-<?
157
+  <?php
151 158
   foreach ($Results as $Result) {
152
-    switch ($Result['Page']) {
159
+      switch ($Result['Page']) {
153 160
       case 'artist':
154 161
         $Links = 'Artist: <a href="artist.php?id=' . $Result['PageID'] . '">' . display_str($Result['Name']) . '</a>';
155 162
         $JumpLink = 'artist.php?id=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
@@ -160,30 +167,32 @@ if (!$NumResults) {
160 167
         break;
161 168
       case 'requests':
162 169
         if (!isset($Requests[$Result['PageID']])) {
163
-          continue;
170
+            continue;
164 171
         }
165 172
         $Request = $Requests[$Result['PageID']];
166 173
         $CategoryName = $Categories[$CategoryID - 1];
167 174
 
168 175
         $Links = 'Request: ';
176
+        /*
169 177
         if ($CategoryName == 'Music' || $CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
170
-          $Links .= ($CategoryName == 'Music' ? Artists::display_artists(Requests::get_artists($Result['PageID'])) : '') . '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
178
+            $Links .= ($CategoryName == 'Music' ? Artists::display_artists(Requests::get_artists($Result['PageID'])) : '') . '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '" dir="ltr">' . $Request['Title'] . " [" . $Request['Year'] . "]</a>";
171 179
         } else {
172
-          $Links .= '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '">' . $Request['Title'] . "</a>";
173
-        }
180
+          */
181
+            $Links .= '<a href="requests.php?action=view&amp;id=' . $Result['PageID'] . '">' . $Request['Title'] . "</a>";
182
+        #} # else
174 183
         $JumpLink = 'requests.php?action=view&amp;id=' . $Result['PageID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
175 184
         break;
176 185
       case 'torrents':
177 186
         if (!isset($TorrentGroups[$Result['PageID']])) {
178
-          continue;
187
+            continue;
179 188
         }
180 189
         $GroupInfo = $TorrentGroups[$Result['PageID']];
181 190
         $Links = 'Torrent: ' . Artists::display_artists($GroupInfo['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupInfo['ID'] . '" dir="ltr">' . $GroupInfo['Name'] . '</a>';
182 191
         if ($GroupInfo['Year'] > 0) {
183
-          $Links .= " [" . $GroupInfo['Year'] . "]";
192
+            $Links .= " [" . $GroupInfo['Year'] . "]";
184 193
         }
185 194
         if ($GroupInfo['ReleaseType'] > 0) {
186
-          $Links .= " [" . $ReleaseTypes[$GroupInfo['ReleaseType']] . "]";
195
+            $Links .= " [" . $ReleaseTypes[$GroupInfo['ReleaseType']] . "]";
187 196
         }
188 197
         $JumpLink = 'torrents.php?id=' . $GroupInfo['ID'] . '&amp;postid=' . $Result['PostID'] . '#post' . $Result['PostID'];
189 198
         break;
@@ -197,59 +206,77 @@ if (!$NumResults) {
197 206
         break;
198 207
       default:
199 208
         error(0);
200
-    }
201
-?>
202
-  <table class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '')?>">
209
+    } ?>
210
+
211
+  <table
212
+    class="forum_post box vertical_margin<?=(!Users::has_avatars_enabled() ? ' noavatar' : '')?>">
203 213
     <colgroup>
204
-<?    if (Users::has_avatars_enabled()) { ?>
214
+      <?php if (Users::has_avatars_enabled()) { ?>
205 215
       <col class="col_avatar" />
206
-<?    } ?>
216
+      <?php } ?>
207 217
       <col class="col_post_body" />
208 218
     </colgroup>
209
-    <tr class="colhead_dark notify_<?=$Result['Page']?>">
219
+    <tr
220
+      class="colhead_dark notify_<?=$Result['Page']?>">
210 221
       <td colspan="<?=Users::has_avatars_enabled() ? 2 : 1 ?>">
211 222
         <span class="float_left">
212 223
           <?=$Links . ($Result['PostID'] < $Result['LastPost'] ? ' <span class="new">(New!)</span>' : '')?>
213 224
         </span>
214
-        <a class="tooltip last_read" title="Jump to last read" href="<?=$JumpLink?>">
215
-          <svg width="15" height="11"><polygon points="0,3 0,8 8,8 8,11 15,5.5 8,0 8,3"/></svg>
225
+        <a class="tooltip last_read" title="Jump to last read"
226
+          href="<?=$JumpLink?>">
227
+          <svg width="15" height="11">
228
+            <polygon points="0,3 0,8 8,8 8,11 15,5.5 8,0 8,3" /></svg>
216 229
         </a>
217
-<?    if ($Result['Page'] == 'forums') { ?>
218
-        <span id="bar<?=$Result['PostID'] ?>" class="float_right">
219
-          <a href="#" onclick="Subscribe(<?=$Result['PageID']?>); return false;" id="subscribelink<?=$Result['PageID']?>" class="brackets">Unsubscribe</a>
220
-<?    } else { ?>
221
-        <span id="bar_<?=$Result['Page'] . $Result['PostID'] ?>" class="float_right">
222
-          <a href="#" onclick="SubscribeComments('<?=$Result['Page']?>', <?=$Result['PageID']?>); return false;" id="subscribelink_<?=$Result['Page'] . $Result['PageID']?>" class="brackets">Unsubscribe</a>
223
-<?    } ?>
224
-          &nbsp;
225
-          <a href="#">&uarr;</a>
226
-        </span>
230
+        <?php if ($Result['Page'] === 'forums') { ?>
231
+        <span id="bar<?=$Result['PostID'] ?>"
232
+          class="float_right">
233
+          <a href="#"
234
+            onclick="Subscribe(<?=$Result['PageID']?>); return false;"
235
+            id="subscribelink<?=$Result['PageID']?>"
236
+            class="brackets">Unsubscribe</a>
237
+          <?php } else { ?>
238
+          <span
239
+            id="bar_<?=$Result['Page'] . $Result['PostID'] ?>"
240
+            class="float_right">
241
+            <a href="#"
242
+              onclick="SubscribeComments('<?=$Result['Page']?>', <?=$Result['PageID']?>); return false;"
243
+              id="subscribelink_<?=$Result['Page'] . $Result['PageID']?>"
244
+              class="brackets">Unsubscribe</a>
245
+            <?php } ?>
246
+            &nbsp;
247
+            <a href="#">&uarr;</a>
248
+          </span>
227 249
       </td>
228 250
     </tr>
229
-<?    if (!empty($Result['LastReadBody'])) { // if a user is subscribed to a topic/comments but hasn't accessed the site ever, LastReadBody will be null - in this case we don't display a post. ?>
230
-    <tr class="row<?=$ShowCollapsed ? ' hidden' : '' ?>">
231
-<?      if (Users::has_avatars_enabled()) { ?>
251
+    <?php if (!empty($Result['LastReadBody'])) { // if a user is subscribed to a topic/comments but hasn't accessed the site ever, LastReadBody will be null - in this case we don't display a post.?>
252
+    <tr
253
+      class="row<?=$ShowCollapsed ? ' hidden' : '' ?>">
254
+      <?php if (Users::has_avatars_enabled()) { ?>
232 255
       <td class="avatar" valign="top">
233 256
         <?=Users::show_avatar($Result['LastReadAvatar'], $Result['LastReadUserID'], $Result['LastReadUsername'], $HeavyInfo['DisableAvatars'])?>
234 257
       </td>
235
-<?      } ?>
258
+      <?php } ?>
236 259
       <td class="body" valign="top">
237 260
         <div class="content3">
238 261
           <?=Text::full_format($Result['LastReadBody']) ?>
239
-<?      if ($Result['LastReadEditedUserID']) { ?>
262
+          <?php if ($Result['LastReadEditedUserID']) { ?>
240 263
           <br /><br />
241
-          Last edited by <?=Users::format_username($Result['LastReadEditedUserID'], false, false, false) ?> <?=time_diff($Result['LastReadEditedTime'])?>
242
-<?      } ?>
264
+          Last edited by <?=Users::format_username($Result['LastReadEditedUserID'], false, false, false) ?>
265
+          <?=time_diff($Result['LastReadEditedTime'])?>
266
+          <?php } ?>
243 267
         </div>
244 268
       </td>
245 269
     </tr>
246
-<?    } ?>
270
+    <?php } ?>
247 271
   </table>
248
-<?  } ?>
272
+  <?php
273
+  } ?>
274
+
249 275
   <div class="linkbox">
250
-<?=$Pages?>
276
+    <?=$Pages?>
251 277
   </div>
252
-<? }?>
278
+  <?php
279
+    }?>
253 280
 </div>
254
-<?
255
-View::show_footer();
281
+
282
+<?php View::show_footer();

Loading…
Cancel
Save