Browse Source

Make minor search forms consistent

pjc 6 years ago
parent
commit
b4b896a630

+ 32
- 28
classes/collages.class.php View File

1
-<?
2
-class Collages {
3
-  public static function increase_subscriptions($CollageID) {
4
-    $QueryID = G::$DB->get_query_id();
5
-    G::$DB->query("
1
+<?php
2
+class Collages
3
+{
4
+    public static function increase_subscriptions($CollageID)
5
+    {
6
+        $QueryID = G::$DB->get_query_id();
7
+        G::$DB->query("
6
       UPDATE collages
8
       UPDATE collages
7
       SET Subscribers = Subscribers + 1
9
       SET Subscribers = Subscribers + 1
8
       WHERE ID = '$CollageID'");
10
       WHERE ID = '$CollageID'");
9
-    G::$DB->set_query_id($QueryID);
10
-  }
11
+        G::$DB->set_query_id($QueryID);
12
+    }
11
 
13
 
12
-  public static function decrease_subscriptions($CollageID) {
13
-    $QueryID = G::$DB->get_query_id();
14
-    G::$DB->query("
14
+    public static function decrease_subscriptions($CollageID)
15
+    {
16
+        $QueryID = G::$DB->get_query_id();
17
+        G::$DB->query("
15
       UPDATE collages
18
       UPDATE collages
16
       SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
19
       SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
17
       WHERE ID = '$CollageID'");
20
       WHERE ID = '$CollageID'");
18
-    G::$DB->set_query_id($QueryID);
19
-  }
21
+        G::$DB->set_query_id($QueryID);
22
+    }
20
 
23
 
21
-  public static function create_personal_collage() {
22
-    G::$DB->query("
24
+    public static function create_personal_collage()
25
+    {
26
+        G::$DB->query("
23
       SELECT
27
       SELECT
24
         COUNT(ID)
28
         COUNT(ID)
25
       FROM collages
29
       FROM collages
26
       WHERE UserID = '" . G::$LoggedUser['ID'] . "'
30
       WHERE UserID = '" . G::$LoggedUser['ID'] . "'
27
         AND CategoryID = '0'
31
         AND CategoryID = '0'
28
         AND Deleted = '0'");
32
         AND Deleted = '0'");
29
-    list($CollageCount) = G::$DB->next_record();
33
+        list($CollageCount) = G::$DB->next_record();
30
 
34
 
31
-    if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
32
-      // TODO: fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
33
-      list($CollageID) = G::$DB->next_record();
34
-      header('Location: collage.php?id='.$CollageID);
35
-      die();
36
-    }
37
-    $NameStr = db_string(G::$LoggedUser['Username'] . "'s personal collage" . ($CollageCount > 0 ? ' no. ' . ($CollageCount + 1) : ''));
38
-    $Description = db_string('Personal collage for ' . G::$LoggedUser['Username'] . '. The first 5 albums will appear on his or her [url=' . site_url() . 'user.php?id= ' . G::$LoggedUser['ID'] . ']profile[/url].');
39
-    G::$DB->query("
35
+        if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
36
+            // @todo Fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
37
+            list($CollageID) = G::$DB->next_record();
38
+            header('Location: collage.php?id='.$CollageID);
39
+            die();
40
+        }
41
+        $NameStr = db_string(G::$LoggedUser['Username'] . "'s personal collage" . ($CollageCount > 0 ? ' no. ' . ($CollageCount + 1) : ''));
42
+        $Description = db_string('Personal collage for ' . G::$LoggedUser['Username'] . '. The first 5 albums will appear on his or her [url=' . site_url() . 'user.php?id= ' . G::$LoggedUser['ID'] . ']profile[/url].');
43
+        G::$DB->query("
40
       INSERT INTO collages
44
       INSERT INTO collages
41
         (Name, Description, CategoryID, UserID)
45
         (Name, Description, CategoryID, UserID)
42
       VALUES
46
       VALUES
43
         ('$NameStr', '$Description', '0', " . G::$LoggedUser['ID'] . ")");
47
         ('$NameStr', '$Description', '0', " . G::$LoggedUser['ID'] . ")");
44
-    $CollageID = G::$DB->inserted_id();
45
-    header('Location: collage.php?id='.$CollageID);
46
-    die();
47
-  }
48
+        $CollageID = G::$DB->inserted_id();
49
+        header('Location: collage.php?id='.$CollageID);
50
+        die();
51
+    }
48
 }
52
 }

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

49
    * @param int $PostID
49
    * @param int $PostID
50
    * @param string $NewBody
50
    * @param string $NewBody
51
    * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
51
    * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
52
-   * @todo move permission check out of here/remove hardcoded error(404)
52
+   * @todo Move permission check out of here/remove hardcoded error(404)
53
    */
53
    */
54
   public static function edit($PostID, $NewBody, $SendPM = false) {
54
   public static function edit($PostID, $NewBody, $SendPM = false) {
55
     $QueryID = G::$DB->get_query_id();
55
     $QueryID = G::$DB->get_query_id();

+ 9
- 10
classes/torrent_form.class.php View File

10
     #var $Formats = [];
10
     #var $Formats = [];
11
     #var $Bitrates = [];
11
     #var $Bitrates = [];
12
     public $Media = [];
12
     public $Media = [];
13
-    var $MediaManga = [];
13
+    public $MediaManga = [];
14
     public $Containers = [];
14
     public $Containers = [];
15
     #var $ContainersGames = [];
15
     #var $ContainersGames = [];
16
     public $Codecs = [];
16
     public $Codecs = [];
212
         </td>
212
         </td>
213
       </tr>
213
       </tr>
214
       <?php
214
       <?php
215
-          }
216
-        }
217
-      ?>
215
+            }
216
+        } ?>
218
 
217
 
219
       <!-- Rules notice and submit button -->
218
       <!-- Rules notice and submit button -->
220
       <tr>
219
       <tr>
330
       One per field, e.g., Robert K. Mortimer [+] David Schild<br />
329
       One per field, e.g., Robert K. Mortimer [+] David Schild<br />
331
       <?php
330
       <?php
332
         if (!empty($Torrent['Artists'])) {
331
         if (!empty($Torrent['Artists'])) {
333
-          foreach ($Torrent['Artists'] as $Num => $Artist) {
334
-      ?>
332
+            foreach ($Torrent['Artists'] as $Num => $Artist) {
333
+                ?>
335
       <input type="text" id="idols_<?= $Num ?>" name="idols[]"
334
       <input type="text" id="idols_<?= $Num ?>" name="idols[]"
336
         size="45" value="<?= display_str($Artist['name']) ?>"
335
         size="45" value="<?= display_str($Artist['name']) ?>"
337
         <?= $this->Disabled ?>/>
336
         <?= $this->Disabled ?>/>
340
       <a class="remove_artist_button brackets">&minus;</a>
339
       <a class="remove_artist_button brackets">&minus;</a>
341
       <?php
340
       <?php
342
             }
341
             }
343
-          }
342
+            }
344
         } else {
343
         } else {
345
-      ?>
344
+            ?>
346
       <input type="text" id="idols_0" name="idols[]" size="45" value="" <?= $this->Disabled ?> />
345
       <input type="text" id="idols_0" name="idols[]" size="45" value="" <?= $this->Disabled ?> />
347
       <a class="add_artist_button brackets">+</a>
346
       <a class="add_artist_button brackets">+</a>
348
       <a class="remove_artist_button brackets">&minus;</a>
347
       <a class="remove_artist_button brackets">&minus;</a>
586
 
585
 
587
   <!-- Boolean options -->
586
   <!-- Boolean options -->
588
   <tr id="censored_tr">
587
   <tr id="censored_tr">
589
-    <td class="label">Aligned Sequence?</td>
588
+    <td class="label">Aligned Sequence</td>
590
     <td>
589
     <td>
591
       <input type="checkbox" name="censored" value="1"
590
       <input type="checkbox" name="censored" value="1"
592
         <?= (($Torrent['Censored'] ?? 0) ? 'checked ' : '') ?>/>
591
         <?= (($Torrent['Censored'] ?? 0) ? 'checked ' : '') ?>/>
595
   </tr>
594
   </tr>
596
 
595
 
597
   <tr id="anon_tr">
596
   <tr id="anon_tr">
598
-    <td class="label">Upload Anonymously?</td>
597
+    <td class="label">Upload Anonymously</td>
599
     <td>
598
     <td>
600
       <input type="checkbox" name="anonymous" value="1"
599
       <input type="checkbox" name="anonymous" value="1"
601
         <?= (($Torrent['Anonymous'] ?? false) ? 'checked ' : '') ?>/>
600
         <?= (($Torrent['Anonymous'] ?? false) ? 'checked ' : '') ?>/>

+ 6
- 6
sections/collages/browse.php View File

20
 }
20
 }
21
 
21
 
22
 if (!empty($_GET['search'])) {
22
 if (!empty($_GET['search'])) {
23
-  // What are we looking for? Let's make sure it isn't dangerous.
23
+  // What are we looking for? Let's make sure it isn't dangerous
24
   $Search = db_string(trim($_GET['search']));
24
   $Search = db_string(trim($_GET['search']));
25
   // Break search string down into individual words
25
   // Break search string down into individual words
26
   $Words = explode(' ', $Search);
26
   $Words = explode(' ', $Search);
176
       <div><input type="hidden" name="action" value="search" /></div>
176
       <div><input type="hidden" name="action" value="search" /></div>
177
       <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
177
       <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
178
         <tr id="search_terms">
178
         <tr id="search_terms">
179
-          <td class="label">Search terms:</td>
179
+          <td class="label">Search Terms</td>
180
           <td>
180
           <td>
181
             <input type="search" name="search" size="70" value="<?=(!empty($_GET['search']) ? display_str($_GET['search']) : '')?>" />
181
             <input type="search" name="search" size="70" value="<?=(!empty($_GET['search']) ? display_str($_GET['search']) : '')?>" />
182
           </td>
182
           </td>
183
         </tr>
183
         </tr>
184
         <tr id="tagfilter">
184
         <tr id="tagfilter">
185
-          <td class="label">Tags (comma-separated):</td>
185
+          <td class="label">Tags (comma-separated)</td>
186
           <td>
186
           <td>
187
             <input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
187
             <input type="text" id="tags" name="tags" size="70" value="<?=(!empty($_GET['tags']) ? display_str($_GET['tags']) : '')?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
188
             <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
188
             <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
190
           </td>
190
           </td>
191
         </tr>
191
         </tr>
192
         <tr id="categories">
192
         <tr id="categories">
193
-          <td class="label">Categories:</td>
193
+          <td class="label">Categories</td>
194
           <td>
194
           <td>
195
 <?    foreach ($CollageCats as $ID => $Cat) { ?>
195
 <?    foreach ($CollageCats as $ID => $Cat) { ?>
196
             <input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<? if (in_array($ID, $Categories)) { echo ' checked="checked"'; } ?> />
196
             <input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<? if (in_array($ID, $Categories)) { echo ' checked="checked"'; } ?> />
199
           </td>
199
           </td>
200
         </tr>
200
         </tr>
201
         <tr id="search_name_description">
201
         <tr id="search_name_description">
202
-          <td class="label">Search in:</td>
202
+          <td class="label">Search In</td>
203
           <td>
203
           <td>
204
             <input type="radio" name="type" value="c.name" <? if ($Type === 'c.name') { echo 'checked="checked" '; } ?>/> Names&nbsp;&nbsp;
204
             <input type="radio" name="type" value="c.name" <? if ($Type === 'c.name') { echo 'checked="checked" '; } ?>/> Names&nbsp;&nbsp;
205
             <input type="radio" name="type" value="description" <? if ($Type === 'description') { echo 'checked="checked" '; } ?>/> Descriptions
205
             <input type="radio" name="type" value="description" <? if ($Type === 'description') { echo 'checked="checked" '; } ?>/> Descriptions
206
           </td>
206
           </td>
207
         </tr>
207
         </tr>
208
         <tr id="order_by">
208
         <tr id="order_by">
209
-          <td class="label">Order by:</td>
209
+          <td class="label">Order By</td>
210
           <td>
210
           <td>
211
             <select name="order_by" class="ft_order_by">
211
             <select name="order_by" class="ft_order_by">
212
 <?    foreach ($OrderVals as $Cur) { ?>
212
 <?    foreach ($OrderVals as $Cur) { ?>

+ 154
- 144
sections/forums/search.php View File

1
-<?
2
-//TODO: Clean up this fucking mess
1
+<?php
2
+
3
+// @todo Clean up this fucking mess
4
+
3
 /*
5
 /*
4
 Forums search result page
6
 Forums search result page
5
 */
7
 */
7
 list($Page, $Limit) = Format::page_limit(POSTS_PER_PAGE);
9
 list($Page, $Limit) = Format::page_limit(POSTS_PER_PAGE);
8
 
10
 
9
 if (isset($_GET['type']) && $_GET['type'] === 'body') {
11
 if (isset($_GET['type']) && $_GET['type'] === 'body') {
10
-  $Type = 'body';
12
+    $Type = 'body';
11
 } else {
13
 } else {
12
-  $Type = 'title';
14
+    $Type = 'title';
13
 }
15
 }
14
 
16
 
15
 // What are we looking for? Let's make sure it isn't dangerous.
17
 // What are we looking for? Let's make sure it isn't dangerous.
16
 if (isset($_GET['search'])) {
18
 if (isset($_GET['search'])) {
17
-  $Search = trim($_GET['search']);
19
+    $Search = trim($_GET['search']);
18
 } else {
20
 } else {
19
-  $Search = '';
21
+    $Search = '';
20
 }
22
 }
21
 
23
 
22
 $ThreadAfterDate = db_string($_GET['thread_created_after']);
24
 $ThreadAfterDate = db_string($_GET['thread_created_after']);
23
 $ThreadBeforeDate = db_string($_GET['thread_created_before']);
25
 $ThreadBeforeDate = db_string($_GET['thread_created_before']);
24
 
26
 
25
 if ((!empty($ThreadAfterDate) && !is_valid_date($ThreadAfterDate)) || (!empty($ThreadBeforeDate) && !is_valid_date($ThreadBeforeDate))) {
27
 if ((!empty($ThreadAfterDate) && !is_valid_date($ThreadAfterDate)) || (!empty($ThreadBeforeDate) && !is_valid_date($ThreadBeforeDate))) {
26
-  error("Incorrect topic created date");
28
+    error("Incorrect topic created date");
27
 }
29
 }
28
 
30
 
29
 $PostAfterDate = db_string($_GET['post_created_after']);
31
 $PostAfterDate = db_string($_GET['post_created_after']);
30
 $PostBeforeDate = db_string($_GET['post_created_before']);
32
 $PostBeforeDate = db_string($_GET['post_created_before']);
31
 
33
 
32
 if ((!empty($PostAfterDate) && !is_valid_date($PostAfterDate)) || (!empty($PostBeforeDate) && !is_valid_date($PostBeforeDate))) {
34
 if ((!empty($PostAfterDate) && !is_valid_date($PostAfterDate)) || (!empty($PostBeforeDate) && !is_valid_date($PostBeforeDate))) {
33
-  error("Incorrect post created date");
35
+    error("Incorrect post created date");
34
 }
36
 }
35
 
37
 
36
 // Searching for posts by a specific user
38
 // Searching for posts by a specific user
37
 if (!empty($_GET['user'])) {
39
 if (!empty($_GET['user'])) {
38
-  $User = trim($_GET['user']);
39
-  $DB->query("
40
+    $User = trim($_GET['user']);
41
+    $DB->query("
40
     SELECT ID
42
     SELECT ID
41
     FROM users_main
43
     FROM users_main
42
     WHERE Username = '".db_string($User)."'");
44
     WHERE Username = '".db_string($User)."'");
43
-  list($AuthorID) = $DB->next_record();
44
-  if ($AuthorID === null) {
45
-    $AuthorID = 0;
46
-    //this will cause the search to return 0 results.
47
-    //workaround in line 276 to display that the username was wrong.
48
-  }
45
+    list($AuthorID) = $DB->next_record();
46
+    if ($AuthorID === null) {
47
+        $AuthorID = 0;
48
+        // This will cause the search to return 0 results
49
+        // Workaround in line 276 to display that the username was wrong
50
+    }
49
 } else {
51
 } else {
50
-  $User = '';
52
+    $User = '';
51
 }
53
 }
52
 
54
 
53
 // Are we looking in individual forums?
55
 // Are we looking in individual forums?
54
 if (isset($_GET['forums']) && is_array($_GET['forums'])) {
56
 if (isset($_GET['forums']) && is_array($_GET['forums'])) {
55
-  $ForumArray = [];
56
-  foreach ($_GET['forums'] as $Forum) {
57
-    if (is_number($Forum)) {
58
-      $ForumArray[] = $Forum;
57
+    $ForumArray = [];
58
+    foreach ($_GET['forums'] as $Forum) {
59
+        if (is_number($Forum)) {
60
+            $ForumArray[] = $Forum;
61
+        }
62
+    }
63
+    if (count($ForumArray) > 0) {
64
+        $SearchForums = implode(', ', $ForumArray);
59
     }
65
     }
60
-  }
61
-  if (count($ForumArray) > 0) {
62
-    $SearchForums = implode(', ', $ForumArray);
63
-  }
64
 }
66
 }
65
 
67
 
66
 // Searching for posts in a specific thread
68
 // Searching for posts in a specific thread
67
 if (!empty($_GET['threadid']) && is_number($_GET['threadid'])) {
69
 if (!empty($_GET['threadid']) && is_number($_GET['threadid'])) {
68
-  $ThreadID = $_GET['threadid'];
69
-  $Type = 'body';
70
-  $SQL = "
70
+    $ThreadID = $_GET['threadid'];
71
+    $Type = 'body';
72
+    $SQL = "
71
     SELECT
73
     SELECT
72
       Title
74
       Title
73
     FROM forums_topics AS t
75
     FROM forums_topics AS t
74
       JOIN forums AS f ON f.ID = t.ForumID
76
       JOIN forums AS f ON f.ID = t.ForumID
75
     WHERE t.ID = $ThreadID
77
     WHERE t.ID = $ThreadID
76
       AND " . Forums::user_forums_sql();
78
       AND " . Forums::user_forums_sql();
77
-  $DB->query($SQL);
78
-  if (list($Title) = $DB->next_record()) {
79
-    $Title = " &gt; <a href=\"forums.php?action=viewthread&amp;threadid=$ThreadID\">$Title</a>";
80
-  } else {
81
-    error(404);
82
-  }
79
+    $DB->query($SQL);
80
+    if (list($Title) = $DB->next_record()) {
81
+        $Title = " &gt; <a href=\"forums.php?action=viewthread&amp;threadid=$ThreadID\">$Title</a>";
82
+    } else {
83
+        error(404);
84
+    }
83
 } else {
85
 } else {
84
-  $ThreadID = '';
86
+    $ThreadID = '';
85
 }
87
 }
86
 
88
 
87
-// Let's hope we got some results - start printing out the content.
89
+// Let's hope we got some results - start printing out the content
88
 View::show_header('Forums &gt; Search', 'bbcode,forum_search');
90
 View::show_header('Forums &gt; Search', 'bbcode,forum_search');
89
 ?>
91
 ?>
92
+
90
 <div class="thin">
93
 <div class="thin">
91
   <div class="header">
94
   <div class="header">
92
     <h2><a href="forums.php">Forums</a> &gt; Search<?=$Title?></h2>
95
     <h2><a href="forums.php">Forums</a> &gt; Search<?=$Title?></h2>
95
     <input type="hidden" name="action" value="search" />
98
     <input type="hidden" name="action" value="search" />
96
     <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
99
     <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
97
       <tr>
100
       <tr>
98
-        <td><strong>Search for:</strong></td>
101
+        <td><strong>Search Terms</strong></td>
99
         <td>
102
         <td>
100
           <input type="search" name="search" size="70" value="<?=display_str($Search)?>" />
103
           <input type="search" name="search" size="70" value="<?=display_str($Search)?>" />
101
         </td>
104
         </td>
102
       </tr>
105
       </tr>
103
       <tr>
106
       <tr>
104
-        <td><strong>Posted by:</strong></td>
107
+        <td><strong>Posted By</strong></td>
105
         <td>
108
         <td>
106
           <input type="search" name="user" placeholder="Username" size="70" value="<?=display_str($User)?>" />
109
           <input type="search" name="user" placeholder="Username" size="70" value="<?=display_str($User)?>" />
107
         </td>
110
         </td>
108
       </tr>
111
       </tr>
109
       <tr>
112
       <tr>
110
-        <td><strong>Topic created:</strong></td>
113
+        <td><strong>Topic Created</strong></td>
111
         <td>
114
         <td>
112
-          After:
113
-          <input type="text" name="thread_created_after" id="thread_created_after" placeholder="YYYY-MM-DD" pattern="[1-2][0-9]{3}-[0-9]{2}-[0-9]{2}" value="<?=$ThreadAfterDate?>" />
114
-          Before:
115
+          After
116
+          <input type="text" name="thread_created_after" id="thread_created_after" placeholder="YYYY-MM-DD" pattern="[1-2][0-9]{3}-[0-9]{2}-[0-9]{2}" value="<?=$ThreadAfterDate?>" />&nbsp;&nbsp;
117
+          Before
115
           <input type="text" name="thread_created_before" id="thread_created_before" placeholder="YYYY-MM-DD" pattern="[1-2][0-9]{3}-[0-9]{2}-[0-9]{2}" value="<?=$ThreadBeforeDate?>" />
118
           <input type="text" name="thread_created_before" id="thread_created_before" placeholder="YYYY-MM-DD" pattern="[1-2][0-9]{3}-[0-9]{2}-[0-9]{2}" value="<?=$ThreadBeforeDate?>" />
116
         </td>
119
         </td>
117
       </tr>
120
       </tr>
118
-<?
121
+<?php
119
 if (empty($ThreadID)) {
122
 if (empty($ThreadID)) {
120
-?>
123
+    ?>
121
       <tr>
124
       <tr>
122
-        <td><strong>Search in:</strong></td>
125
+        <td><strong>Search In</strong></td>
123
         <td>
126
         <td>
124
-          <input type="radio" name="type" id="type_title" value="title"<? if ($Type == 'title') { echo ' checked="checked"'; } ?> />
127
+          <input type="radio" name="type" id="type_title" value="title"<?php if ($Type == 'title') {
128
+        echo ' checked="checked"';
129
+    } ?> />
125
           <label for="type_title">Titles</label>
130
           <label for="type_title">Titles</label>
126
-          <input type="radio" name="type" id="type_body" value="body"<? if ($Type == 'body') { echo ' checked="checked"'; } ?> />
127
-          <label for="type_body">Post bodies</label>
131
+          <input type="radio" name="type" id="type_body" value="body"<?php if ($Type == 'body') {
132
+        echo ' checked="checked"';
133
+    } ?> />&nbsp;&nbsp;
134
+          <label for="type_body">Body</label>
128
         </td>
135
         </td>
129
       </tr>
136
       </tr>
130
-      <tr id="post_created_row" <? if ($Type == 'title') { echo "class='hidden'"; } ?>>
137
+      <tr id="post_created_row" <?php if ($Type == 'title') {
138
+        echo "class='hidden'";
139
+    } ?>>
131
         <td><strong>Post created:</strong></td>
140
         <td><strong>Post created:</strong></td>
132
         <td>
141
         <td>
133
           After:
142
           After:
137
         </td>
146
         </td>
138
       </tr>
147
       </tr>
139
       <tr>
148
       <tr>
140
-        <td><strong>Forums:</strong></td>
149
+        <td><strong>Forums</strong></td>
141
         <td>
150
         <td>
142
     <table id="forum_search_cat_list" class="cat_list layout">
151
     <table id="forum_search_cat_list" class="cat_list layout">
143
 
152
 
144
 
153
 
145
-<?
154
+<?php
146
   // List of forums
155
   // List of forums
147
   $Open = false;
156
   $Open = false;
148
-  $LastCategoryID = -1;
149
-  $Columns = 0;
150
-  $i = 0;
151
-  foreach ($Forums as $Forum) {
152
-    if (!Forums::check_forumperm($Forum['ID'])) {
153
-      continue;
154
-    }
157
+    $LastCategoryID = -1;
158
+    $Columns = 0;
159
+    $i = 0;
160
+    foreach ($Forums as $Forum) {
161
+        if (!Forums::check_forumperm($Forum['ID'])) {
162
+            continue;
163
+        }
155
 
164
 
156
-    $Columns++;
165
+        $Columns++;
157
 
166
 
158
-    if ($Forum['CategoryID'] != $LastCategoryID) {
159
-      $LastCategoryID = $Forum['CategoryID'];
160
-      if ($Open) {
161
-        if ($Columns % 5) { ?>
167
+        if ($Forum['CategoryID'] != $LastCategoryID) {
168
+            $LastCategoryID = $Forum['CategoryID'];
169
+            if ($Open) {
170
+                if ($Columns % 5) { ?>
162
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
171
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
163
-<?
164
-        }
165
-
166
-?>
172
+<?php
173
+        } ?>
167
       </tr>
174
       </tr>
168
-<?
169
-      }
170
-      $Columns = 0;
171
-      $Open = true;
172
-      $i++;
173
-?>
175
+<?php
176
+            }
177
+            $Columns = 0;
178
+            $Open = true;
179
+            $i++; ?>
174
       <tr>
180
       <tr>
175
         <td colspan="5" class="forum_cat">
181
         <td colspan="5" class="forum_cat">
176
           <strong><?=$ForumCats[$Forum['CategoryID']]?></strong>
182
           <strong><?=$ForumCats[$Forum['CategoryID']]?></strong>
178
         </td>
184
         </td>
179
       </tr>
185
       </tr>
180
       <tr>
186
       <tr>
181
-<?    } elseif ($Columns % 5 == 0) { ?>
187
+<?php
188
+        } elseif ($Columns % 5 == 0) { ?>
182
       </tr>
189
       </tr>
183
       <tr>
190
       <tr>
184
-<?    } ?>
191
+<?php    } ?>
185
         <td>
192
         <td>
186
-          <input type="checkbox" name="forums[]" value="<?=$Forum['ID']?>" data-category="forum_category_<?=$i?>" id="forum_<?=$Forum['ID']?>"<? if (isset($_GET['forums']) && in_array($Forum['ID'], $_GET['forums'])) { echo ' checked="checked"';} ?> />
193
+          <input type="checkbox" name="forums[]" value="<?=$Forum['ID']?>" data-category="forum_category_<?=$i?>" id="forum_<?=$Forum['ID']?>"<?php if (isset($_GET['forums']) && in_array($Forum['ID'], $_GET['forums'])) {
194
+            echo ' checked="checked"';
195
+        } ?> />
187
           <label for="forum_<?=$Forum['ID']?>"><?=htmlspecialchars($Forum['Name'])?></label>
196
           <label for="forum_<?=$Forum['ID']?>"><?=htmlspecialchars($Forum['Name'])?></label>
188
         </td>
197
         </td>
189
-<?  }
190
-  if ($Columns % 5) { ?>
198
+<?php
199
+    }
200
+    if ($Columns % 5) { ?>
191
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
201
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
192
-<?  } ?>
202
+<?php  } ?>
193
       </tr>
203
       </tr>
194
     </table>
204
     </table>
195
-<? } else { ?>
205
+<?php
206
+} else { ?>
196
             <input type="hidden" name="threadid" value="<?=$ThreadID?>" />
207
             <input type="hidden" name="threadid" value="<?=$ThreadID?>" />
197
-<? } ?>
208
+<?php } ?>
198
           </td>
209
           </td>
199
         </tr>
210
         </tr>
200
         <tr>
211
         <tr>
205
       </table>
216
       </table>
206
     </form>
217
     </form>
207
   <div class="linkbox">
218
   <div class="linkbox">
208
-<?
219
+<?php
209
 
220
 
210
 // Break search string down into individual words
221
 // Break search string down into individual words
211
 $Words = explode(' ', db_string($Search));
222
 $Words = explode(' ', db_string($Search));
212
 
223
 
213
 if ($Type == 'body') {
224
 if ($Type == 'body') {
214
-
215
-  $SQL = "
225
+    $SQL = "
216
     SELECT
226
     SELECT
217
       SQL_CALC_FOUND_ROWS
227
       SQL_CALC_FOUND_ROWS
218
       t.ID,
228
       t.ID,
228
       JOIN forums AS f ON f.ID = t.ForumID
238
       JOIN forums AS f ON f.ID = t.ForumID
229
     WHERE " . Forums::user_forums_sql() . ' AND ';
239
     WHERE " . Forums::user_forums_sql() . ' AND ';
230
 
240
 
231
-  //In tests, this is significantly faster than LOCATE
232
-  $SQL .= "p.Body LIKE '%";
233
-  $SQL .= implode("%' AND p.Body LIKE '%", $Words);
234
-  $SQL .= "%' ";
241
+    // In tests, this is significantly faster than LOCATE
242
+    $SQL .= "p.Body LIKE '%";
243
+    $SQL .= implode("%' AND p.Body LIKE '%", $Words);
244
+    $SQL .= "%' ";
235
 
245
 
236
-  //$SQL .= "LOCATE('";
237
-  //$SQL .= implode("', p.Body) AND LOCATE('", $Words);
238
-  //$SQL .= "', p.Body) ";
246
+    //$SQL .= "LOCATE('";
247
+    //$SQL .= implode("', p.Body) AND LOCATE('", $Words);
248
+    //$SQL .= "', p.Body) ";
239
 
249
 
240
-  if (isset($SearchForums)) {
241
-    $SQL .= " AND f.ID IN ($SearchForums)";
242
-  }
243
-  if (isset($AuthorID)) {
244
-    $SQL .= " AND p.AuthorID = '$AuthorID' ";
245
-  }
246
-  if (!empty($ThreadID)) {
247
-    $SQL .= " AND t.ID = '$ThreadID' ";
248
-  }
249
-  if (!empty($ThreadAfterDate)) {
250
-    $SQL .= " AND t.CreatedTime >= '$ThreadAfterDate'";
251
-  }
252
-  if (!empty($ThreadBeforeDate)) {
253
-    $SQL .= " AND t.CreatedTime <= '$ThreadBeforeDate'";
254
-  }
255
-  if (!empty($PostAfterDate)) {
256
-    $SQL .= " AND p.AddedTime >= '$PostAfterDate'";
257
-  }
258
-  if (!empty($PostBeforeDate)) {
259
-    $SQL .= " AND p.AddedTime <= '$PostBeforeDate'";
260
-  }
250
+    if (isset($SearchForums)) {
251
+        $SQL .= " AND f.ID IN ($SearchForums)";
252
+    }
253
+    if (isset($AuthorID)) {
254
+        $SQL .= " AND p.AuthorID = '$AuthorID' ";
255
+    }
256
+    if (!empty($ThreadID)) {
257
+        $SQL .= " AND t.ID = '$ThreadID' ";
258
+    }
259
+    if (!empty($ThreadAfterDate)) {
260
+        $SQL .= " AND t.CreatedTime >= '$ThreadAfterDate'";
261
+    }
262
+    if (!empty($ThreadBeforeDate)) {
263
+        $SQL .= " AND t.CreatedTime <= '$ThreadBeforeDate'";
264
+    }
265
+    if (!empty($PostAfterDate)) {
266
+        $SQL .= " AND p.AddedTime >= '$PostAfterDate'";
267
+    }
268
+    if (!empty($PostBeforeDate)) {
269
+        $SQL .= " AND p.AddedTime <= '$PostBeforeDate'";
270
+    }
261
 
271
 
262
-  $SQL .= "
272
+    $SQL .= "
263
     ORDER BY p.AddedTime DESC
273
     ORDER BY p.AddedTime DESC
264
     LIMIT $Limit";
274
     LIMIT $Limit";
265
-
266
 } else {
275
 } else {
267
-  $SQL = "
276
+    $SQL = "
268
     SELECT
277
     SELECT
269
       SQL_CALC_FOUND_ROWS
278
       SQL_CALC_FOUND_ROWS
270
       t.ID,
279
       t.ID,
278
     FROM forums_topics AS t
287
     FROM forums_topics AS t
279
       JOIN forums AS f ON f.ID = t.ForumID
288
       JOIN forums AS f ON f.ID = t.ForumID
280
     WHERE " . Forums::user_forums_sql() . ' AND ';
289
     WHERE " . Forums::user_forums_sql() . ' AND ';
281
-  $SQL .= "t.Title LIKE '%";
282
-  $SQL .= implode("%' AND t.Title LIKE '%", $Words);
283
-  $SQL .= "%' ";
284
-  if (isset($SearchForums)) {
285
-    $SQL .= " AND f.ID IN ($SearchForums)";
286
-  }
287
-  if (isset($AuthorID)) {
288
-    $SQL .= " AND t.AuthorID = '$AuthorID' ";
289
-  }
290
-  if (!empty($ThreadAfterDate)) {
291
-    $SQL .= " AND t.CreatedTime >= '$ThreadAfterDate'";
292
-  }
293
-  if (!empty($ThreadBeforeDate)) {
294
-    $SQL .= " AND t.CreatedTime <= '$ThreadBeforeDate'";
295
-  }
296
-  $SQL .= "
290
+    $SQL .= "t.Title LIKE '%";
291
+    $SQL .= implode("%' AND t.Title LIKE '%", $Words);
292
+    $SQL .= "%' ";
293
+    if (isset($SearchForums)) {
294
+        $SQL .= " AND f.ID IN ($SearchForums)";
295
+    }
296
+    if (isset($AuthorID)) {
297
+        $SQL .= " AND t.AuthorID = '$AuthorID' ";
298
+    }
299
+    if (!empty($ThreadAfterDate)) {
300
+        $SQL .= " AND t.CreatedTime >= '$ThreadAfterDate'";
301
+    }
302
+    if (!empty($ThreadBeforeDate)) {
303
+        $SQL .= " AND t.CreatedTime <= '$ThreadBeforeDate'";
304
+    }
305
+    $SQL .= "
297
     ORDER BY t.LastPostTime DESC
306
     ORDER BY t.LastPostTime DESC
298
     LIMIT $Limit";
307
     LIMIT $Limit";
299
 }
308
 }
315
     <td>Topic creation time</td>
324
     <td>Topic creation time</td>
316
     <td>Last post time</td>
325
     <td>Last post time</td>
317
   </tr>
326
   </tr>
318
-<? if (!$DB->has_results()) { ?>
327
+<?php if (!$DB->has_results()) { ?>
319
     <tr><td colspan="4">Nothing found<?=((isset($AuthorID) && $AuthorID == 0) ? ' (unknown username)' : '')?>!</td></tr>
328
     <tr><td colspan="4">Nothing found<?=((isset($AuthorID) && $AuthorID == 0) ? ' (unknown username)' : '')?>!</td></tr>
320
-<? }
329
+<?php }
321
 
330
 
322
 while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $ThreadCreatedTime) = $DB->next_record()) {
331
 while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $ThreadCreatedTime) = $DB->next_record()) {
323
-  // Print results
324
-?>
332
+    // Print results?>
325
     <tr class="row">
333
     <tr class="row">
326
       <td>
334
       <td>
327
         <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$ForumName?></a>
335
         <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$ForumName?></a>
328
       </td>
336
       </td>
329
       <td>
337
       <td>
330
-<?  if (empty($ThreadID)) { ?>
338
+<?php  if (empty($ThreadID)) { ?>
331
         <a href="forums.php?action=viewthread&amp;threadid=<?=$ID?>"><?=Format::cut_string($Title, 80); ?></a>
339
         <a href="forums.php?action=viewthread&amp;threadid=<?=$ID?>"><?=Format::cut_string($Title, 80); ?></a>
332
-<?  } else { ?>
340
+<?php  } else { ?>
333
         <?=Format::cut_string($Title, 80); ?>
341
         <?=Format::cut_string($Title, 80); ?>
334
-<?
342
+<?php
335
   }
343
   }
336
-  if ($Type == 'body') { ?>
337
-        <a data-toggle-target="#post_<?=$PostID?>_text">(Show)</a> <span class="float_right tooltip last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><? if (!empty($PostID)) { echo "&amp;postid=$PostID#post$PostID"; } ?>"></a></span>
338
-<?  } ?>
344
+    if ($Type == 'body') { ?>
345
+        <a data-toggle-target="#post_<?=$PostID?>_text">(Show)</a> <span class="float_right tooltip last_read" title="Jump to post"><a href="forums.php?action=viewthread&amp;threadid=<?=$ID?><?php if (!empty($PostID)) {
346
+        echo "&amp;postid=$PostID#post$PostID";
347
+    } ?>"></a></span>
348
+<?php  } ?>
339
       </td>
349
       </td>
340
       <td>
350
       <td>
341
         <?=time_diff($ThreadCreatedTime)?>
351
         <?=time_diff($ThreadCreatedTime)?>
344
         <?=time_diff($LastTime)?>
354
         <?=time_diff($LastTime)?>
345
       </td>
355
       </td>
346
     </tr>
356
     </tr>
347
-<?  if ($Type == 'body') { ?>
357
+<?php  if ($Type == 'body') { ?>
348
     <tr class="row hidden" id="post_<?=$PostID?>_text">
358
     <tr class="row hidden" id="post_<?=$PostID?>_text">
349
       <td colspan="4"><?=Text::full_format($Body)?></td>
359
       <td colspan="4"><?=Text::full_format($Body)?></td>
350
     </tr>
360
     </tr>
351
-<?  }
361
+<?php  }
352
 }
362
 }
353
 ?>
363
 ?>
354
   </table>
364
   </table>
357
     <?=$Pages?>
367
     <?=$Pages?>
358
   </div>
368
   </div>
359
 </div>
369
 </div>
360
-<? View::show_footer(); ?>
370
+<?php View::show_footer(); ?>

+ 301
- 300
sections/requests/requests.php View File

12
 ];
12
 ];
13
 
13
 
14
 if (empty($_GET['order']) || !isset($SortOrders[$_GET['order']])) {
14
 if (empty($_GET['order']) || !isset($SortOrders[$_GET['order']])) {
15
-  $_GET['order'] = 'created';
15
+    $_GET['order'] = 'created';
16
 }
16
 }
17
 $OrderBy = $_GET['order'];
17
 $OrderBy = $_GET['order'];
18
 
18
 
19
 if (!empty($_GET['sort']) && $_GET['sort'] === 'asc') {
19
 if (!empty($_GET['sort']) && $_GET['sort'] === 'asc') {
20
-  $OrderWay = 'asc';
20
+    $OrderWay = 'asc';
21
 } else {
21
 } else {
22
-  $_GET['sort'] = 'desc';
23
-  $OrderWay = 'desc';
22
+    $_GET['sort'] = 'desc';
23
+    $OrderWay = 'desc';
24
 }
24
 }
25
 $NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
25
 $NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
26
 
26
 
27
 if ($OrderBy === 'random') {
27
 if ($OrderBy === 'random') {
28
-  $SphQL->order_by('RAND()', '');
29
-  unset($_GET['page']);
28
+    $SphQL->order_by('RAND()', '');
29
+    unset($_GET['page']);
30
 } else {
30
 } else {
31
-  $SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
31
+    $SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
32
 }
32
 }
33
 
33
 
34
 $Submitted = !empty($_GET['submit']);
34
 $Submitted = !empty($_GET['submit']);
35
 
35
 
36
-//Paranoia
36
+// Paranoia
37
 if (!empty($_GET['userid'])) {
37
 if (!empty($_GET['userid'])) {
38
-  if (!is_number($_GET['userid'])) {
39
-    error('User ID must be an integer');
40
-  }
41
-  $UserInfo = Users::user_info($_GET['userid']);
42
-  if (empty($UserInfo)) {
43
-    error('That user does not exist');
44
-  }
45
-  $Perms = Permissions::get_permissions($UserInfo['PermissionID']);
46
-  $UserClass = $Perms['Class'];
38
+    if (!is_number($_GET['userid'])) {
39
+        error('User ID must be an integer');
40
+    }
41
+    $UserInfo = Users::user_info($_GET['userid']);
42
+    if (empty($UserInfo)) {
43
+        error('That user does not exist');
44
+    }
45
+    $Perms = Permissions::get_permissions($UserInfo['PermissionID']);
46
+    $UserClass = $Perms['Class'];
47
 }
47
 }
48
 $BookmarkView = false;
48
 $BookmarkView = false;
49
 
49
 
50
 if (empty($_GET['type'])) {
50
 if (empty($_GET['type'])) {
51
-  $Title = 'Requests';
52
-  if (empty($_GET['showall'])) {
53
-    $SphQL->where('visible', 1);
54
-  }
51
+    $Title = 'Requests';
52
+    if (empty($_GET['showall'])) {
53
+        $SphQL->where('visible', 1);
54
+    }
55
 } else {
55
 } else {
56
-  switch ($_GET['type']) {
56
+    switch ($_GET['type']) {
57
     case 'created':
57
     case 'created':
58
       if (!empty($UserInfo)) {
58
       if (!empty($UserInfo)) {
59
-        if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
60
-          error(403);
61
-        }
62
-        $Title = "Requests created by $UserInfo[Username]";
63
-        $SphQL->where('userid', $UserInfo['ID']);
59
+          if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
60
+              error(403);
61
+          }
62
+          $Title = "Requests created by $UserInfo[Username]";
63
+          $SphQL->where('userid', $UserInfo['ID']);
64
       } else {
64
       } else {
65
-        $Title = 'My requests';
66
-        $SphQL->where('userid', $LoggedUser['ID']);
65
+          $Title = 'My requests';
66
+          $SphQL->where('userid', $LoggedUser['ID']);
67
       }
67
       }
68
       break;
68
       break;
69
     case 'voted':
69
     case 'voted':
70
       if (!empty($UserInfo)) {
70
       if (!empty($UserInfo)) {
71
-        if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
72
-          error(403);
73
-        }
74
-        $Title = "Requests voted for by $UserInfo[Username]";
75
-        $SphQL->where('voter', $UserInfo['ID']);
71
+          if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
72
+              error(403);
73
+          }
74
+          $Title = "Requests voted for by $UserInfo[Username]";
75
+          $SphQL->where('voter', $UserInfo['ID']);
76
       } else {
76
       } else {
77
-        $Title = 'Requests I have voted on';
78
-        $SphQL->where('voter', $LoggedUser['ID']);
77
+          $Title = 'Requests I have voted on';
78
+          $SphQL->where('voter', $LoggedUser['ID']);
79
       }
79
       }
80
       break;
80
       break;
81
     case 'filled':
81
     case 'filled':
82
       if (!empty($UserInfo)) {
82
       if (!empty($UserInfo)) {
83
-        if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
84
-          error(403);
85
-        }
86
-        $Title = "Requests filled by $UserInfo[Username]";
87
-        $SphQL->where('fillerid', $UserInfo['ID']);
83
+          if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $UserInfo['ID'])) {
84
+              error(403);
85
+          }
86
+          $Title = "Requests filled by $UserInfo[Username]";
87
+          $SphQL->where('fillerid', $UserInfo['ID']);
88
       } else {
88
       } else {
89
-        $Title = 'Requests I have filled';
90
-        $SphQL->where('fillerid', $LoggedUser['ID']);
89
+          $Title = 'Requests I have filled';
90
+          $SphQL->where('fillerid', $LoggedUser['ID']);
91
       }
91
       }
92
       break;
92
       break;
93
     case 'bookmarks':
93
     case 'bookmarks':
101
 }
101
 }
102
 
102
 
103
 if ($Submitted && empty($_GET['show_filled'])) {
103
 if ($Submitted && empty($_GET['show_filled'])) {
104
-  $SphQL->where('torrentid', 0);
104
+    $SphQL->where('torrentid', 0);
105
 }
105
 }
106
 
106
 
107
 if (!empty($_GET['formats'])) {
107
 if (!empty($_GET['formats'])) {
108
-  $FormatArray = $_GET['formats'];
109
-  if (count($FormatArray) !== count($Formats)) {
110
-    $FormatNameArray = [];
111
-    foreach ($FormatArray as $Index => $MasterIndex) {
112
-      if (isset($Formats[$MasterIndex])) {
113
-        $FormatNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Formats[$MasterIndex]), '-.', '  ') . '"';
114
-      }
115
-    }
116
-    if (count($FormatNameArray) >= 1) {
117
-      if (!empty($_GET['formats_strict'])) {
118
-        $SearchString = '(' . implode(' | ', $FormatNameArray) . ')';
119
-      } else {
120
-        $SearchString = '(any | ' . implode(' | ', $FormatNameArray) . ')';
121
-      }
122
-      $SphQL->where_match($SearchString, 'formatlist', false);
108
+    $FormatArray = $_GET['formats'];
109
+    if (count($FormatArray) !== count($Formats)) {
110
+        $FormatNameArray = [];
111
+        foreach ($FormatArray as $Index => $MasterIndex) {
112
+            if (isset($Formats[$MasterIndex])) {
113
+                $FormatNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Formats[$MasterIndex]), '-.', '  ') . '"';
114
+            }
115
+        }
116
+        if (count($FormatNameArray) >= 1) {
117
+            if (!empty($_GET['formats_strict'])) {
118
+                $SearchString = '(' . implode(' | ', $FormatNameArray) . ')';
119
+            } else {
120
+                $SearchString = '(any | ' . implode(' | ', $FormatNameArray) . ')';
121
+            }
122
+            $SphQL->where_match($SearchString, 'formatlist', false);
123
+        }
123
     }
124
     }
124
-  }
125
 }
125
 }
126
 
126
 
127
 if (!empty($_GET['media'])) {
127
 if (!empty($_GET['media'])) {
128
-  $MediaArray = $_GET['media'];
129
-  if (count($MediaArray) !== count($Media)) {
130
-    $MediaNameArray = [];
131
-    foreach ($MediaArray as $Index => $MasterIndex) {
132
-      if (isset($Media[$MasterIndex])) {
133
-        $MediaNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Media[$MasterIndex]), '-.', '  ') . '"';
134
-      }
135
-    }
128
+    $MediaArray = $_GET['media'];
129
+    if (count($MediaArray) !== count($Media)) {
130
+        $MediaNameArray = [];
131
+        foreach ($MediaArray as $Index => $MasterIndex) {
132
+            if (isset($Media[$MasterIndex])) {
133
+                $MediaNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Media[$MasterIndex]), '-.', '  ') . '"';
134
+            }
135
+        }
136
 
136
 
137
-    if (count($MediaNameArray) >= 1) {
138
-      if (!empty($_GET['media_strict'])) {
139
-        $SearchString = '(' . implode(' | ', $MediaNameArray) . ')';
140
-      } else {
141
-        $SearchString = '(any | ' . implode(' | ', $MediaNameArray) . ')';
142
-      }
143
-      $SphQL->where_match($SearchString, 'medialist', false);
137
+        if (count($MediaNameArray) >= 1) {
138
+            if (!empty($_GET['media_strict'])) {
139
+                $SearchString = '(' . implode(' | ', $MediaNameArray) . ')';
140
+            } else {
141
+                $SearchString = '(any | ' . implode(' | ', $MediaNameArray) . ')';
142
+            }
143
+            $SphQL->where_match($SearchString, 'medialist', false);
144
+        }
144
     }
145
     }
145
-  }
146
 }
146
 }
147
 
147
 
148
 if (!empty($_GET['bitrates'])) {
148
 if (!empty($_GET['bitrates'])) {
149
-  $BitrateArray = $_GET['bitrates'];
150
-  if (count($BitrateArray) !== count($Bitrates)) {
151
-    $BitrateNameArray = [];
152
-    foreach ($BitrateArray as $Index => $MasterIndex) {
153
-      if (isset($Bitrates[$MasterIndex])) {
154
-        $BitrateNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Bitrates[$MasterIndex]), '-.', '  ') . '"';
155
-      }
156
-    }
149
+    $BitrateArray = $_GET['bitrates'];
150
+    if (count($BitrateArray) !== count($Bitrates)) {
151
+        $BitrateNameArray = [];
152
+        foreach ($BitrateArray as $Index => $MasterIndex) {
153
+            if (isset($Bitrates[$MasterIndex])) {
154
+                $BitrateNameArray[$Index] = '"' . strtr(Sphinxql::sph_escape_string($Bitrates[$MasterIndex]), '-.', '  ') . '"';
155
+            }
156
+        }
157
 
157
 
158
-    if (count($BitrateNameArray) >= 1) {
159
-      if (!empty($_GET['bitrate_strict'])) {
160
-        $SearchString = '(' . implode(' | ', $BitrateNameArray) . ')';
161
-      } else {
162
-        $SearchString = '(any | ' . implode(' | ', $BitrateNameArray) . ')';
163
-      }
164
-      $SphQL->where_match($SearchString, 'bitratelist', false);
158
+        if (count($BitrateNameArray) >= 1) {
159
+            if (!empty($_GET['bitrate_strict'])) {
160
+                $SearchString = '(' . implode(' | ', $BitrateNameArray) . ')';
161
+            } else {
162
+                $SearchString = '(any | ' . implode(' | ', $BitrateNameArray) . ')';
163
+            }
164
+            $SphQL->where_match($SearchString, 'bitratelist', false);
165
+        }
165
     }
166
     }
166
-  }
167
 }
167
 }
168
 
168
 
169
 if (!empty($_GET['search'])) {
169
 if (!empty($_GET['search'])) {
170
-  $SearchString = trim($_GET['search']);
171
-
172
-  if ($SearchString !== '') {
173
-    $SearchWords = array('include' => [], 'exclude' => []);
174
-    $Words = explode(' ', $SearchString);
175
-    foreach ($Words as $Word) {
176
-      $Word = trim($Word);
177
-      // Skip isolated hyphens to enable "Artist - Title" searches
178
-      if ($Word === '-') {
179
-        continue;
180
-      }
181
-      if ($Word[0] === '!' && strlen($Word) >= 2) {
182
-        if (strpos($Word, '!', 1) === false) {
183
-          $SearchWords['exclude'][] = $Word;
184
-        } else {
185
-          $SearchWords['include'][] = $Word;
170
+    $SearchString = trim($_GET['search']);
171
+
172
+    if ($SearchString !== '') {
173
+        $SearchWords = array('include' => [], 'exclude' => []);
174
+        $Words = explode(' ', $SearchString);
175
+        foreach ($Words as $Word) {
176
+            $Word = trim($Word);
177
+            // Skip isolated hyphens to enable "Artist - Title" searches
178
+            if ($Word === '-') {
179
+                continue;
180
+            }
181
+            if ($Word[0] === '!' && strlen($Word) >= 2) {
182
+                if (strpos($Word, '!', 1) === false) {
183
+                    $SearchWords['exclude'][] = $Word;
184
+                } else {
185
+                    $SearchWords['include'][] = $Word;
186
+                }
187
+            } elseif ($Word !== '') {
188
+                $SearchWords['include'][] = $Word;
189
+            }
186
         }
190
         }
187
-      } elseif ($Word !== '') {
188
-        $SearchWords['include'][] = $Word;
189
-      }
190
     }
191
     }
191
-  }
192
 }
192
 }
193
 
193
 
194
 if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') {
194
 if (!isset($_GET['tags_type']) || $_GET['tags_type'] === '1') {
195
-  $TagType = 1;
196
-  $_GET['tags_type'] = '1';
195
+    $TagType = 1;
196
+    $_GET['tags_type'] = '1';
197
 } else {
197
 } else {
198
-  $TagType = 0;
199
-  $_GET['tags_type'] = '0';
198
+    $TagType = 0;
199
+    $_GET['tags_type'] = '0';
200
 }
200
 }
201
 
201
 
202
 if (!empty($_GET['tags'])) {
202
 if (!empty($_GET['tags'])) {
203
-  $SearchTags = array('include' => [], 'exclude' => []);
204
-  $Tags = explode(',', str_replace('.', '_', $_GET['tags']));
205
-  foreach ($Tags as $Tag) {
206
-    $Tag = trim($Tag);
207
-    if ($Tag[0] === '!' && strlen($Tag) >= 2) {
208
-      if (strpos($Tag, '!', 1) === false) {
209
-        $SearchTags['exclude'][] = $Tag;
210
-      } else {
211
-        $SearchTags['include'][] = $Tag;
212
-      }
213
-    } elseif ($Tag !== '') {
214
-      $SearchTags['include'][] = $Tag;
203
+    $SearchTags = array('include' => [], 'exclude' => []);
204
+    $Tags = explode(',', str_replace('.', '_', $_GET['tags']));
205
+    foreach ($Tags as $Tag) {
206
+        $Tag = trim($Tag);
207
+        if ($Tag[0] === '!' && strlen($Tag) >= 2) {
208
+            if (strpos($Tag, '!', 1) === false) {
209
+                $SearchTags['exclude'][] = $Tag;
210
+            } else {
211
+                $SearchTags['include'][] = $Tag;
212
+            }
213
+        } elseif ($Tag !== '') {
214
+            $SearchTags['include'][] = $Tag;
215
+        }
215
     }
216
     }
216
-  }
217
 
217
 
218
-  $TagFilter = Tags::tag_filter_sph($SearchTags, $TagType);
219
-  $TagNames = $TagFilter['input'];
220
-
221
-  if (!empty($TagFilter['predicate'])) {
222
-    $SphQL->where_match($TagFilter['predicate'], 'taglist', false);
223
-  }
218
+    $TagFilter = Tags::tag_filter_sph($SearchTags, $TagType);
219
+    $TagNames = $TagFilter['input'];
224
 
220
 
221
+    if (!empty($TagFilter['predicate'])) {
222
+        $SphQL->where_match($TagFilter['predicate'], 'taglist', false);
223
+    }
225
 } elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') {
224
 } elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') {
226
-  $_GET['tags_type'] = 1;
225
+    $_GET['tags_type'] = 1;
227
 } else {
226
 } else {
228
-  $_GET['tags_type'] = 0;
227
+    $_GET['tags_type'] = 0;
229
 }
228
 }
230
 
229
 
231
 if (isset($SearchWords)) {
230
 if (isset($SearchWords)) {
232
-  $QueryParts = [];
233
-  foreach ($SearchWords['include'] as $Word) {
234
-    $QueryParts[] = Sphinxql::sph_escape_string($Word);
235
-  }
236
-  if (!empty($SearchWords['exclude'])) {
237
-    foreach ($SearchWords['exclude'] as $Word) {
238
-      $QueryParts[] = '!' . Sphinxql::sph_escape_string(substr($Word, 1));
231
+    $QueryParts = [];
232
+    foreach ($SearchWords['include'] as $Word) {
233
+        $QueryParts[] = Sphinxql::sph_escape_string($Word);
234
+    }
235
+    if (!empty($SearchWords['exclude'])) {
236
+        foreach ($SearchWords['exclude'] as $Word) {
237
+            $QueryParts[] = '!' . Sphinxql::sph_escape_string(substr($Word, 1));
238
+        }
239
+    }
240
+    if (!empty($QueryParts)) {
241
+        $SearchString = implode(' ', $QueryParts);
242
+        $SphQL->where_match($SearchString, '*', false);
239
     }
243
     }
240
-  }
241
-  if (!empty($QueryParts)) {
242
-    $SearchString = implode(' ', $QueryParts);
243
-    $SphQL->where_match($SearchString, '*', false);
244
-  }
245
 }
244
 }
246
 
245
 
247
 if (!empty($_GET['filter_cat'])) {
246
 if (!empty($_GET['filter_cat'])) {
248
-  $CategoryArray = array_keys($_GET['filter_cat']);
249
-  if (count($CategoryArray) !== count($Categories)) {
250
-    foreach ($CategoryArray as $Key => $Index) {
251
-      if (!isset($Categories[$Index - 1])) {
252
-        unset($CategoryArray[$Key]);
253
-      }
254
-    }
255
-    if (count($CategoryArray) >= 1) {
256
-      $SphQL->where('categoryid', $CategoryArray);
247
+    $CategoryArray = array_keys($_GET['filter_cat']);
248
+    if (count($CategoryArray) !== count($Categories)) {
249
+        foreach ($CategoryArray as $Key => $Index) {
250
+            if (!isset($Categories[$Index - 1])) {
251
+                unset($CategoryArray[$Key]);
252
+            }
253
+        }
254
+        if (count($CategoryArray) >= 1) {
255
+            $SphQL->where('categoryid', $CategoryArray);
256
+        }
257
     }
257
     }
258
-  }
259
 }
258
 }
260
 
259
 
261
 if (!empty($_GET['releases'])) {
260
 if (!empty($_GET['releases'])) {
262
-  $ReleaseArray = $_GET['releases'];
263
-  if (count($ReleaseArray) !== count($ReleaseTypes)) {
264
-    foreach ($ReleaseArray as $Index => $Value) {
265
-      if (!isset($ReleaseTypes[$Value])) {
266
-        unset($ReleaseArray[$Index]);
267
-      }
268
-    }
269
-    if (count($ReleaseArray) >= 1) {
270
-      $SphQL->where('releasetype', $ReleaseArray);
261
+    $ReleaseArray = $_GET['releases'];
262
+    if (count($ReleaseArray) !== count($ReleaseTypes)) {
263
+        foreach ($ReleaseArray as $Index => $Value) {
264
+            if (!isset($ReleaseTypes[$Value])) {
265
+                unset($ReleaseArray[$Index]);
266
+            }
267
+        }
268
+        if (count($ReleaseArray) >= 1) {
269
+            $SphQL->where('releasetype', $ReleaseArray);
270
+        }
271
     }
271
     }
272
-  }
273
 }
272
 }
274
 
273
 
275
 if (!empty($_GET['requestor'])) {
274
 if (!empty($_GET['requestor'])) {
276
-  if (is_number($_GET['requestor'])) {
277
-    $SphQL->where('userid', $_GET['requestor']);
278
-  } else {
279
-    error(404);
280
-  }
275
+    if (is_number($_GET['requestor'])) {
276
+        $SphQL->where('userid', $_GET['requestor']);
277
+    } else {
278
+        error(404);
279
+    }
281
 }
280
 }
282
 
281
 
283
 if (isset($_GET['year'])) {
282
 if (isset($_GET['year'])) {
284
-  if (is_number($_GET['year']) || $_GET['year'] === '0') {
285
-    $SphQL->where('year', $_GET['year']);
286
-  } else {
287
-    error(404);
288
-  }
283
+    if (is_number($_GET['year']) || $_GET['year'] === '0') {
284
+        $SphQL->where('year', $_GET['year']);
285
+    } else {
286
+        error(404);
287
+    }
289
 }
288
 }
290
 
289
 
291
 if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
290
 if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
292
-  $Page = $_GET['page'];
293
-  $Offset = ($Page - 1) * REQUESTS_PER_PAGE;
294
-  $SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
291
+    $Page = $_GET['page'];
292
+    $Offset = ($Page - 1) * REQUESTS_PER_PAGE;
293
+    $SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
295
 } else {
294
 } else {
296
-  $Page = 1;
297
-  $SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
295
+    $Page = 1;
296
+    $SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
298
 }
297
 }
299
 
298
 
300
 $SphQLResult = $SphQL->query();
299
 $SphQLResult = $SphQL->query();
301
 $NumResults = (int)$SphQLResult->get_meta('total_found');
300
 $NumResults = (int)$SphQLResult->get_meta('total_found');
302
 if ($NumResults > 0) {
301
 if ($NumResults > 0) {
303
-  $SphRequests = $SphQLResult->to_array('id');
304
-  if ($OrderBy === 'random') {
305
-    $NumResults = count($SphRequests);
306
-  }
307
-  if ($NumResults > REQUESTS_PER_PAGE) {
308
-    if (($Page - 1) * REQUESTS_PER_PAGE > $NumResults) {
309
-      $Page = 0;
302
+    $SphRequests = $SphQLResult->to_array('id');
303
+    if ($OrderBy === 'random') {
304
+        $NumResults = count($SphRequests);
305
+    }
306
+    if ($NumResults > REQUESTS_PER_PAGE) {
307
+        if (($Page - 1) * REQUESTS_PER_PAGE > $NumResults) {
308
+            $Page = 0;
309
+        }
310
+        $PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
310
     }
311
     }
311
-    $PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
312
-  }
313
 }
312
 }
314
 
313
 
315
 $CurrentURL = Format::get_url(array('order', 'sort', 'page'));
314
 $CurrentURL = Format::get_url(array('order', 'sort', 'page'));
316
 View::show_header($Title, 'requests');
315
 View::show_header($Title, 'requests');
317
-
318
 ?>
316
 ?>
317
+
319
 <div class="thin">
318
 <div class="thin">
320
   <div class="header">
319
   <div class="header">
321
     <h2><?=$Title?></h2>
320
     <h2><?=$Title?></h2>
322
   </div>
321
   </div>
323
   <div class="linkbox">
322
   <div class="linkbox">
324
-<?  if (!$BookmarkView) {
323
+<?php  if (!$BookmarkView) {
325
     if (check_perms('site_submit_requests')) { ?>
324
     if (check_perms('site_submit_requests')) { ?>
326
     <a href="requests.php?action=new" class="brackets">New request</a>
325
     <a href="requests.php?action=new" class="brackets">New request</a>
327
     <a href="requests.php?type=created" class="brackets">My requests</a>
326
     <a href="requests.php?type=created" class="brackets">My requests</a>
328
-<?    }
327
+<?php    }
329
     if (check_perms('site_vote')) { ?>
328
     if (check_perms('site_vote')) { ?>
330
     <a href="requests.php?type=voted" class="brackets">Requests I've voted on</a>
329
     <a href="requests.php?type=voted" class="brackets">Requests I've voted on</a>
331
-<?    } ?>
330
+<?php    } ?>
332
     <a href="bookmarks.php?type=requests" class="brackets">Bookmarked requests</a>
331
     <a href="bookmarks.php?type=requests" class="brackets">Bookmarked requests</a>
333
-<?  } else { ?>
332
+<?php
333
+} else { ?>
334
     <a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
334
     <a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
335
     <a href="bookmarks.php?type=artists" class="brackets">Artists</a>
335
     <a href="bookmarks.php?type=artists" class="brackets">Artists</a>
336
     <a href="bookmarks.php?type=collages" class="brackets">Collections</a>
336
     <a href="bookmarks.php?type=collages" class="brackets">Collections</a>
337
     <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
337
     <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
338
-<?  } ?>
338
+<?php  } ?>
339
   </div>
339
   </div>
340
-<?  if ($BookmarkView && $NumResults === 0) { ?>
340
+<?php  if ($BookmarkView && $NumResults === 0) { ?>
341
   <div class="box pad" align="center">
341
   <div class="box pad" align="center">
342
     <h2>You have not bookmarked any requests.</h2>
342
     <h2>You have not bookmarked any requests.</h2>
343
   </div>
343
   </div>
344
-<?  } else { ?>
344
+<?php  } else { ?>
345
   <form class="search_form" name="requests" action="" method="get">
345
   <form class="search_form" name="requests" action="" method="get">
346
-<?    if ($BookmarkView) { ?>
346
+<?php    if ($BookmarkView) { ?>
347
     <input type="hidden" name="action" value="view" />
347
     <input type="hidden" name="action" value="view" />
348
     <input type="hidden" name="type" value="requests" />
348
     <input type="hidden" name="type" value="requests" />
349
-<?    } elseif (isset($_GET['type'])) { ?>
349
+<?php    } elseif (isset($_GET['type'])) { ?>
350
     <input type="hidden" name="type" value="<?=$_GET['type']?>" />
350
     <input type="hidden" name="type" value="<?=$_GET['type']?>" />
351
-<?    } ?>
351
+<?php    } ?>
352
     <input type="hidden" name="submit" value="true" />
352
     <input type="hidden" name="submit" value="true" />
353
-<?    if (!empty($_GET['userid']) && is_number($_GET['userid'])) { ?>
353
+<?php    if (!empty($_GET['userid']) && is_number($_GET['userid'])) { ?>
354
     <input type="hidden" name="userid" value="<?=$_GET['userid']?>" />
354
     <input type="hidden" name="userid" value="<?=$_GET['userid']?>" />
355
-<?    } ?>
355
+<?php    } ?>
356
     <div class="box pad">
356
     <div class="box pad">
357
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
357
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
358
       <tr id="search_terms">
358
       <tr id="search_terms">
359
-        <td class="label"><!--Search terms:--></td>
359
+        <td class="label"><!--Search Terms--></td>
360
         <td>
360
         <td>
361
-          <input type="search" name="search" size="60" class="inputtext" placeholder="Search terms" value="<? if (isset($_GET['search'])) { echo display_str($_GET['search']); } ?>" />
361
+          <input type="search" name="search" size="60" class="inputtext" placeholder="Search Terms" value="<?php if (isset($_GET['search'])) {
362
+        echo display_str($_GET['search']);
363
+    } ?>" />
362
         </td>
364
         </td>
363
       </tr>
365
       </tr>
364
       <tr id="tagfilter">
366
       <tr id="tagfilter">
365
-        <td class="label"><!--Tags (comma-separated):--></td>
367
+        <td class="label"><!--Tags (comma-separated)--></td>
366
         <td>
368
         <td>
367
-          <input type="search" name="tags" id="tags" size="49" class="inputtext" placeholder="Tags (comma-separated)" value="<?=!empty($TagNames) ? display_str($TagNames) : ''?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
368
-          <input type="radio" name="tags_type" id="tags_type0" value="0"<? Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
369
-          <input type="radio" name="tags_type" id="tags_type1" value="1"<? Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
369
+          <input type="search" name="tags" id="tags" size="49" class="inputtext" placeholder="Tags (comma-separated)" value="<?=!empty($TagNames) ? display_str($TagNames) : ''?>"<?php Users::has_autocomplete_enabled('other'); ?> />&nbsp;
370
+          <input type="radio" name="tags_type" id="tags_type0" value="0"<?php Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
371
+          <input type="radio" name="tags_type" id="tags_type1" value="1"<?php Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
370
         </td>
372
         </td>
371
       </tr>
373
       </tr>
372
       <tr id="include_filled">
374
       <tr id="include_filled">
373
-        <td class="label"><label for="include_filled_box">Include filled:</label></td>
375
+        <td class="label"><label for="include_filled_box">Include Filled</label></td>
374
         <td>
376
         <td>
375
-          <input type="checkbox" id="include_filled_box" name="show_filled"<? if (!$Submitted || !empty($_GET['show_filled']) || (!$Submitted && !empty($_GET['type']) && $_GET['type'] === 'filled')) { ?> checked="checked"<? } ?> />
377
+          <input type="checkbox" id="include_filled_box" name="show_filled"<?php if (!$Submitted || !empty($_GET['show_filled']) || (!$Submitted && !empty($_GET['type']) && $_GET['type'] === 'filled')) { ?> checked="checked"<?php } ?> />
376
         </td>
378
         </td>
377
       </tr>
379
       </tr>
378
       <tr id="include_old">
380
       <tr id="include_old">
379
-        <td class="label"><label for="include_old_box">Include old:</label></td>
381
+        <td class="label"><label for="include_old_box">Include Old</label></td>
380
         <td>
382
         <td>
381
-          <input type="checkbox" id="include_old_box" name="showall"<? if (!empty($_GET['showall'])) { ?> checked="checked"<? } ?> />
383
+          <input type="checkbox" id="include_old_box" name="showall"<?php if (!empty($_GET['showall'])) { ?> checked="checked"<?php } ?> />
382
         </td>
384
         </td>
383
       </tr>
385
       </tr>
384
-<?    /* ?>
386
+<?php    /* ?>
385
       <tr>
387
       <tr>
386
         <td class="label">Requested by:</td>
388
         <td class="label">Requested by:</td>
387
         <td>
389
         <td>
391
 <?    */ ?>
393
 <?    */ ?>
392
     </table>
394
     </table>
393
     <table class="layout cat_list">
395
     <table class="layout cat_list">
394
-<?
396
+<?php
395
     $x = 1;
397
     $x = 1;
396
     reset($Categories);
398
     reset($Categories);
397
     foreach ($Categories as $CatKey => $CatName) {
399
     foreach ($Categories as $CatKey => $CatName) {
398
-      if ($x % 8 === 0 || $x === 1) {
399
-?>
400
+        if ($x % 8 === 0 || $x === 1) {
401
+            ?>
400
         <tr>
402
         <tr>
401
-<?      } ?>
403
+<?php
404
+        } ?>
402
           <td>
405
           <td>
403
-            <input type="checkbox" name="filter_cat[<?=($CatKey + 1) ?>]" id="cat_<?=($CatKey + 1) ?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
406
+            <input type="checkbox" name="filter_cat[<?=($CatKey + 1) ?>]" id="cat_<?=($CatKey + 1) ?>" value="1"<?php if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<?php } ?> />
404
             <label for="cat_<?=($CatKey + 1) ?>"><?=$CatName?></label>
407
             <label for="cat_<?=($CatKey + 1) ?>"><?=$CatName?></label>
405
           </td>
408
           </td>
406
-<?      if ($x % 7 === 0) { ?>
409
+<?php      if ($x % 7 === 0) { ?>
407
         </tr>
410
         </tr>
408
-<?
411
+<?php
409
       }
412
       }
410
-      $x++;
413
+        $x++;
411
     }
414
     }
412
 ?>
415
 ?>
413
     </table>
416
     </table>
414
     <table class="layout">
417
     <table class="layout">
415
       <tr>
418
       <tr>
416
         <td colspan="2" class="center">
419
         <td colspan="2" class="center">
417
-          <input type="submit" value="Search requests" />
420
+          <input type="submit" value="Search" />
418
         </td>
421
         </td>
419
       </tr>
422
       </tr>
420
     </table>
423
     </table>
421
     </div>
424
     </div>
422
   </form>
425
   </form>
423
-<?    if (isset($PageLinks)) { ?>
426
+<?php    if (isset($PageLinks)) { ?>
424
   <div class="linkbox">
427
   <div class="linkbox">
425
     <?= $PageLinks?>
428
     <?= $PageLinks?>
426
   </div>
429
   </div>
427
-<?    } ?>
430
+<?php    } ?>
428
   <table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
431
   <table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
429
     <tr class="colhead_dark">
432
     <tr class="colhead_dark">
430
       <td class="small cats_col"></td>
433
       <td class="small cats_col"></td>
453
         <a href="?order=lastvote&amp;sort=<?=($OrderBy === 'lastvote' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Last vote</strong></a>
456
         <a href="?order=lastvote&amp;sort=<?=($OrderBy === 'lastvote' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Last vote</strong></a>
454
       </td>
457
       </td>
455
     </tr>
458
     </tr>
456
-<?
459
+<?php
457
     if ($NumResults === 0) {
460
     if ($NumResults === 0) {
458
-      // not viewing bookmarks but no requests found
461
+        // not viewing bookmarks but no requests found
459
 ?>
462
 ?>
460
     <tr class="row">
463
     <tr class="row">
461
       <td colspan="8">
464
       <td colspan="8">
462
         Nothing found!
465
         Nothing found!
463
       </td>
466
       </td>
464
     </tr>
467
     </tr>
465
-<?    } elseif ($Page === 0) { ?>
468
+<?php
469
+    } elseif ($Page === 0) { ?>
466
     <tr class="row">
470
     <tr class="row">
467
       <td colspan="8">
471
       <td colspan="8">
468
         The requested page contains no matches!
472
         The requested page contains no matches!
469
       </td>
473
       </td>
470
     </tr>
474
     </tr>
471
-<?
472
-    } else {
473
-
474
-  $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
475
-  $Requests = Requests::get_requests(array_keys($SphRequests));
476
-  foreach ($Requests as $RequestID => $Request) {
477
-    $SphRequest = $SphRequests[$RequestID];
478
-    $Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
479
-    $VoteCount = $SphRequest['votes'];
480
-
481
-    if ($Request['CategoryID'] == 0) {
482
-      $CategoryName = 'Unknown';
483
-    } else {
484
-      $CategoryName = $Categories[$Request['CategoryID'] - 1];
485
-    }
486
-
487
-    if ($Request['TorrentID'] != 0) {
488
-      $IsFilled = true;
489
-      $FillerInfo = Users::user_info($Request['FillerID']);
475
+<?php
490
     } else {
476
     } else {
491
-      $IsFilled = false;
492
-    }
493
-
494
-    $Title = empty($Request['Title']) ? (empty($Request['TitleRJ']) ? $Request['TitleJP'] : $Request['TitleRJ']) : $Request['Title'];
495
-
496
-    $ArtistForm = Requests::get_artists($RequestID);
497
-    $ArtistLink = Artists::display_artists($ArtistForm, true, true);
498
-    $FullName = "$ArtistLink<a href=\"requests.php?action=view&amp;id=$RequestID\"><span ";
499
-    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
500
-      $FullName .= 'data-cover="'.ImageTools::process($Request['Image']).'" ';
501
-    }
502
-    $FullName .= "dir=\"ltr\">$Title</span></a>";
503
-
504
-    $ExtraInfo = '';
505
-
506
-    if (!empty($Request['CatalogueNumber'])) {
507
-      $ExtraInfo .= " [$Request[CatalogueNumber]]";
508
-    }
509
-
510
-    if (!empty($Request['DLsiteID'])) {
511
-      $ExtraInfo .= " [$Request[DLsiteID]]";
512
-    }
513
-    if ($ExtraInfo) {
514
-      $FullName .= " $ExtraInfo";
515
-    }
516
-    $Tags = $Request['Tags'];
517
-?>
477
+        $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18
478
+        $Requests = Requests::get_requests(array_keys($SphRequests));
479
+        foreach ($Requests as $RequestID => $Request) {
480
+            $SphRequest = $SphRequests[$RequestID];
481
+            $Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
482
+            $VoteCount = $SphRequest['votes'];
483
+
484
+            if ($Request['CategoryID'] === 0) {
485
+                $CategoryName = 'Unknown';
486
+            } else {
487
+                $CategoryName = $Categories[$Request['CategoryID'] - 1];
488
+            }
489
+
490
+            if ($Request['TorrentID'] !== 0) {
491
+                $IsFilled = true;
492
+                $FillerInfo = Users::user_info($Request['FillerID']);
493
+            } else {
494
+                $IsFilled = false;
495
+            }
496
+
497
+            $Title = empty($Request['Title']) ? (empty($Request['TitleRJ']) ? $Request['TitleJP'] : $Request['TitleRJ']) : $Request['Title'];
498
+
499
+            $ArtistForm = Requests::get_artists($RequestID);
500
+            $ArtistLink = Artists::display_artists($ArtistForm, true, true);
501
+            $FullName = "$ArtistLink<a href=\"requests.php?action=view&amp;id=$RequestID\"><span ";
502
+            if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
503
+                $FullName .= 'data-cover="'.ImageTools::process($Request['Image']).'" ';
504
+            }
505
+            $FullName .= "dir=\"ltr\">$Title</span></a>";
506
+
507
+            $ExtraInfo = '';
508
+
509
+            if (!empty($Request['CatalogueNumber'])) {
510
+                $ExtraInfo .= " [$Request[CatalogueNumber]]";
511
+            }
512
+
513
+            if (!empty($Request['DLsiteID'])) {
514
+                $ExtraInfo .= " [$Request[DLsiteID]]";
515
+            }
516
+            if ($ExtraInfo) {
517
+                $FullName .= " $ExtraInfo";
518
+            }
519
+            $Tags = $Request['Tags']; ?>
518
     <tr class="request">
520
     <tr class="request">
519
       <td class="center cats_col">
521
       <td class="center cats_col">
520
         <div title="<?=Format::pretty_category($Request['CategoryID'])?>" class="tooltip <?=Format::css_category($Request['CategoryID'])?>"></div>
522
         <div title="<?=Format::pretty_category($Request['CategoryID'])?>" class="tooltip <?=Format::css_category($Request['CategoryID'])?>"></div>
522
       <td>
524
       <td>
523
         <?=$FullName?>
525
         <?=$FullName?>
524
         <div class="tags">
526
         <div class="tags">
525
-<?
527
+<?php
526
     $TagList = [];
528
     $TagList = [];
527
-    foreach ($Request['Tags'] as $TagID => $TagName) {
528
-      $Split = Tags::get_name_and_class($TagName);
529
-      $TagList[] = '<a class="'.$Split['class'].'" href="?tags='.$TagName.($BookmarkView ? '&amp;type=requests' : '').'">'.display_str($Split['name']).'</a>';
530
-    }
531
-    $TagList = implode(', ', $TagList);
532
-?>
529
+            foreach ($Request['Tags'] as $TagID => $TagName) {
530
+                $Split = Tags::get_name_and_class($TagName);
531
+                $TagList[] = '<a class="'.$Split['class'].'" href="?tags='.$TagName.($BookmarkView ? '&amp;type=requests' : '').'">'.display_str($Split['name']).'</a>';
532
+            }
533
+            $TagList = implode(', ', $TagList); ?>
533
           <?=$TagList?>
534
           <?=$TagList?>
534
         </div>
535
         </div>
535
       </td>
536
       </td>
536
       <td class="nobr">
537
       <td class="nobr">
537
         <span id="vote_count_<?=$RequestID?>"><?=number_format($VoteCount)?></span>
538
         <span id="vote_count_<?=$RequestID?>"><?=number_format($VoteCount)?></span>
538
-<?    if (!$IsFilled && check_perms('site_vote')) { ?>
539
+<?php    if (!$IsFilled && check_perms('site_vote')) { ?>
539
         &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
540
         &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
540
-<?    } ?>
541
+<?php    } ?>
541
       </td>
542
       </td>
542
       <td class="number_column nobr">
543
       <td class="number_column nobr">
543
         <?=Format::get_size($Bounty)?>
544
         <?=Format::get_size($Bounty)?>
544
       </td>
545
       </td>
545
       <td class="nobr">
546
       <td class="nobr">
546
-<?    if ($IsFilled) { ?>
547
+<?php    if ($IsFilled) { ?>
547
         <a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>"><strong><?=time_diff($Request['TimeFilled'], 1)?></strong></a>
548
         <a href="torrents.php?<?=(strtotime($Request['TimeFilled']) < $TimeCompare ? 'id=' : 'torrentid=') . $Request['TorrentID']?>"><strong><?=time_diff($Request['TimeFilled'], 1)?></strong></a>
548
-<?    } else { ?>
549
+<?php    } else { ?>
549
         <strong>No</strong>
550
         <strong>No</strong>
550
-<?    } ?>
551
+<?php    } ?>
551
       </td>
552
       </td>
552
       <td>
553
       <td>
553
-<?    if ($IsFilled) {
554
-        if ($Request['AnonymousFill']) { ?>
554
+<?php    if ($IsFilled) {
555
+                if ($Request['AnonymousFill']) { ?>
555
           <em>Anonymous</em>
556
           <em>Anonymous</em>
556
-<?      } else { ?>
557
+<?php      } else { ?>
557
           <a href="user.php?id=<?=$FillerInfo['ID']?>"><?=$FillerInfo['Username']?></a>
558
           <a href="user.php?id=<?=$FillerInfo['ID']?>"><?=$FillerInfo['Username']?></a>
558
-<?      }
559
-      } else { ?>
559
+<?php      }
560
+            } else { ?>
560
         &mdash;
561
         &mdash;
561
-<?    } ?>
562
+<?php    } ?>
562
       </td>
563
       </td>
563
       <td>
564
       <td>
564
         <a href="user.php?id=<?=$Request['UserID']?>"><?=Users::format_username($Request['UserID'], false, false, false)?></a>
565
         <a href="user.php?id=<?=$Request['UserID']?>"><?=Users::format_username($Request['UserID'], false, false, false)?></a>
570
         <?=time_diff($Request['LastVote'], 1)?>
571
         <?=time_diff($Request['LastVote'], 1)?>
571
       </td>
572
       </td>
572
     </tr>
573
     </tr>
573
-<?
574
-  } // foreach
574
+<?php
575
+        } // foreach
575
     } // else
576
     } // else
576
   } // if ($BookmarkView && $NumResults < 1)
577
   } // if ($BookmarkView && $NumResults < 1)
577
 ?>
578
 ?>
578
   </table>
579
   </table>
579
-<? if (isset($PageLinks)) { ?>
580
+<?php if (isset($PageLinks)) { ?>
580
   <div class="linkbox">
581
   <div class="linkbox">
581
     <?=$PageLinks?>
582
     <?=$PageLinks?>
582
   </div>
583
   </div>
583
-<? } ?>
584
+<?php } ?>
584
 </div>
585
 </div>
585
-<? View::show_footer(); ?>
586
+<?php View::show_footer(); ?>

+ 296
- 292
sections/top10/torrents.php View File

1
-<?
1
+<?php
2
 $Where = [];
2
 $Where = [];
3
 
3
 
4
 if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
4
 if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
5
-  $Details = 'all';
6
-  $Limit = 10;
7
-
8
-  if ($_GET['tags']) {
9
-    $TagWhere = [];
10
-    $Tags = explode(',', str_replace('.', '_', trim($_GET['tags'])));
11
-    foreach ($Tags as $Tag) {
12
-      $Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
13
-      if ($Tag != '') {
14
-        $TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
15
-      }
16
-    }
17
-    if (!empty($TagWhere)) {
18
-      if ($_GET['anyall'] == 'any') {
19
-        $Where[] = '('.implode(' OR ', $TagWhere).')';
20
-      } else {
21
-        $Where[] = '('.implode(' AND ', $TagWhere).')';
22
-      }
5
+    $Details = 'all';
6
+    $Limit = 10;
7
+
8
+    if ($_GET['tags']) {
9
+        $TagWhere = [];
10
+        $Tags = explode(',', str_replace('.', '_', trim($_GET['tags'])));
11
+        foreach ($Tags as $Tag) {
12
+            $Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
13
+            if ($Tag != '') {
14
+                $TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
15
+            }
16
+        }
17
+        if (!empty($TagWhere)) {
18
+            if ($_GET['anyall'] == 'any') {
19
+                $Where[] = '('.implode(' OR ', $TagWhere).')';
20
+            } else {
21
+                $Where[] = '('.implode(' AND ', $TagWhere).')';
22
+            }
23
+        }
23
     }
24
     }
24
-  }
25
 
25
 
26
-  if ($_GET['category']) {
27
-    if (in_array($_GET['category'], $Categories)) {
28
-      $Where[] = "g.CategoryID = '".(array_search($_GET['category'], $Categories)+1)."'";
26
+    if ($_GET['category']) {
27
+        if (in_array($_GET['category'], $Categories)) {
28
+            $Where[] = "g.CategoryID = '".(array_search($_GET['category'], $Categories)+1)."'";
29
+        }
29
     }
30
     }
30
-  }
31
-
32
 } else {
31
 } else {
33
-  // error out on invalid requests (before caching)
34
-  if (isset($_GET['details'])) {
35
-    if (in_array($_GET['details'], array('day', 'week', 'overall', 'snatched', 'data', 'seeded', 'month', 'year'))) {
36
-      $Details = $_GET['details'];
32
+    // Error out on invalid requests (before caching)
33
+    if (isset($_GET['details'])) {
34
+        if (in_array($_GET['details'], array('day', 'week', 'overall', 'snatched', 'data', 'seeded', 'month', 'year'))) {
35
+            $Details = $_GET['details'];
36
+        } else {
37
+            error(404);
38
+        }
37
     } else {
39
     } else {
38
-      error(404);
40
+        $Details = 'all';
39
     }
41
     }
40
-  } else {
41
-    $Details = 'all';
42
-  }
43
 
42
 
44
-  // defaults to 10 (duh)
45
-  $Limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 10);
46
-  $Limit = (in_array($Limit, array(10, 100, 250)) ? $Limit : 10);
43
+    // Defaults to 10 (duh)
44
+    $Limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 10);
45
+    $Limit = (in_array($Limit, array(10, 100, 250)) ? $Limit : 10);
47
 }
46
 }
48
 $Filtered = !empty($Where);
47
 $Filtered = !empty($Where);
49
 View::show_header("Top $Limit Torrents", 'browse');
48
 View::show_header("Top $Limit Torrents", 'browse');
50
 ?>
49
 ?>
50
+
51
 <div class="thin">
51
 <div class="thin">
52
   <div class="header">
52
   <div class="header">
53
     <h2>Top <?=$Limit?> Torrents</h2>
53
     <h2>Top <?=$Limit?> Torrents</h2>
54
-    <? Top10View::render_linkbox("torrents"); ?>
54
+    <?php Top10View::render_linkbox("torrents"); ?>
55
   </div>
55
   </div>
56
-<?
56
+<?php
57
 
57
 
58
 if (check_perms('site_advanced_top10')) {
58
 if (check_perms('site_advanced_top10')) {
59
-?>
59
+    ?>
60
   <div class="box pad">
60
   <div class="box pad">
61
   <form class="search_form" name="torrents" action="" method="get">
61
   <form class="search_form" name="torrents" action="" method="get">
62
     <input type="hidden" name="advanced" value="1" />
62
     <input type="hidden" name="advanced" value="1" />
63
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
63
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
64
       <tr id="tagfilter">
64
       <tr id="tagfilter">
65
-        <td class="label">Tags (comma-separated):</td>
65
+        <td class="label">Tags (comma-separated)</td>
66
         <td class="ft_taglist">
66
         <td class="ft_taglist">
67
-          <input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
67
+          <input type="text" name="tags" id="tags" size="75" value="<?php if (!empty($_GET['tags'])) {
68
+        echo display_str($_GET['tags']);
69
+    } ?>"<?php Users::has_autocomplete_enabled('other'); ?> />&nbsp;
68
           <input type="radio" id="rdoAll" name="anyall" value="all"<?=((!isset($_GET['anyall'])||$_GET['anyall']!='any')?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
70
           <input type="radio" id="rdoAll" name="anyall" value="all"<?=((!isset($_GET['anyall'])||$_GET['anyall']!='any')?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
69
           <input type="radio" id="rdoAny" name="anyall" value="any"<?=((!isset($_GET['anyall'])||$_GET['anyall']=='any')?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
71
           <input type="radio" id="rdoAny" name="anyall" value="any"<?=((!isset($_GET['anyall'])||$_GET['anyall']=='any')?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
70
         </td>
72
         </td>
71
       </tr>
73
       </tr>
72
       <tr>
74
       <tr>
73
-        <td class="label">Category:</td>
75
+        <td class="label">Category</td>
74
         <td>
76
         <td>
75
           <select name="category" style="width: auto;" class="ft_format">
77
           <select name="category" style="width: auto;" class="ft_format">
76
             <option value="">Any</option>
78
             <option value="">Any</option>
77
-<?  foreach ($Categories as $CategoryName) { ?>
79
+<?php  foreach ($Categories as $CategoryName) { ?>
78
             <option value="<?=display_str($CategoryName)?>"<?=(($CategoryName==($_GET['category']??false))?'selected="selected"':'')?>><?=display_str($CategoryName)?></option>
80
             <option value="<?=display_str($CategoryName)?>"<?=(($CategoryName==($_GET['category']??false))?'selected="selected"':'')?>><?=display_str($CategoryName)?></option>
79
-<?  } ?>
81
+<?php  } ?>
80
           </select>
82
           </select>
81
         </td>
83
         </td>
82
       </tr>
84
       </tr>
83
       <tr>
85
       <tr>
84
         <td colspan="2" class="center">
86
         <td colspan="2" class="center">
85
-          <input type="submit" value="Filter torrents" />
87
+          <input type="submit" value="Search" />
86
         </td>
88
         </td>
87
       </tr>
89
       </tr>
88
     </table>
90
     </table>
89
   </form>
91
   </form>
90
   </div>
92
   </div>
91
-<?
93
+<?php
92
 }
94
 }
93
 
95
 
94
-// default setting to have them shown
96
+// Default setting to have them shown
95
 $DisableFreeTorrentTop10 = (isset($LoggedUser['DisableFreeTorrentTop10']) ? $LoggedUser['DisableFreeTorrentTop10'] : 0);
97
 $DisableFreeTorrentTop10 = (isset($LoggedUser['DisableFreeTorrentTop10']) ? $LoggedUser['DisableFreeTorrentTop10'] : 0);
96
-// did they just toggle it?
98
+// Did they just toggle it?
97
 if (isset($_GET['freeleech'])) {
99
 if (isset($_GET['freeleech'])) {
98
-  // what did they choose?
99
-  $NewPref = (($_GET['freeleech'] == 'hide') ? 1 : 0);
100
+    // what did they choose?
101
+    $NewPref = (($_GET['freeleech'] == 'hide') ? 1 : 0);
100
 
102
 
101
-  // Pref id different
102
-  if ($NewPref != $DisableFreeTorrentTop10) {
103
-    $DisableFreeTorrentTop10 = $NewPref;
104
-    Users::update_site_options($LoggedUser['ID'], array('DisableFreeTorrentTop10' => $DisableFreeTorrentTop10));
105
-  }
103
+    // Pref id different
104
+    if ($NewPref != $DisableFreeTorrentTop10) {
105
+        $DisableFreeTorrentTop10 = $NewPref;
106
+        Users::update_site_options($LoggedUser['ID'], array('DisableFreeTorrentTop10' => $DisableFreeTorrentTop10));
107
+    }
106
 }
108
 }
107
 
109
 
108
 // Modify the Where query
110
 // Modify the Where query
109
 if ($DisableFreeTorrentTop10) {
111
 if ($DisableFreeTorrentTop10) {
110
-  $Where[] = "t.FreeTorrent='0'";
112
+    $Where[] = "t.FreeTorrent='0'";
111
 }
113
 }
112
 
114
 
113
 // The link should say the opposite of the current setting
115
 // The link should say the opposite of the current setting
114
 $FreeleechToggleName = ($DisableFreeTorrentTop10 ? 'show' : 'hide');
116
 $FreeleechToggleName = ($DisableFreeTorrentTop10 ? 'show' : 'hide');
115
 $FreeleechToggleQuery = Format::get_url(array('freeleech', 'groups'));
117
 $FreeleechToggleQuery = Format::get_url(array('freeleech', 'groups'));
116
 
118
 
117
-if (!empty($FreeleechToggleQuery))
118
-  $FreeleechToggleQuery .= '&amp;';
119
+if (!empty($FreeleechToggleQuery)) {
120
+    $FreeleechToggleQuery .= '&amp;';
121
+}
119
 
122
 
120
 $FreeleechToggleQuery .= 'freeleech=' . $FreeleechToggleName;
123
 $FreeleechToggleQuery .= 'freeleech=' . $FreeleechToggleName;
121
 
124
 
122
 $GroupByToggleName = ((isset($_GET['groups']) && $_GET['groups'] == 'show') ? 'hide' : 'show');
125
 $GroupByToggleName = ((isset($_GET['groups']) && $_GET['groups'] == 'show') ? 'hide' : 'show');
123
 $GroupByToggleQuery = Format::get_url(array('freeleech', 'groups'));
126
 $GroupByToggleQuery = Format::get_url(array('freeleech', 'groups'));
124
 
127
 
125
-if (!empty($GroupByToggleQuery))
126
-  $GroupByToggleQuery .= '&amp;';
128
+if (!empty($GroupByToggleQuery)) {
129
+    $GroupByToggleQuery .= '&amp;';
130
+}
127
 
131
 
128
 $GroupByToggleQuery .= 'groups=' . $GroupByToggleName;
132
 $GroupByToggleQuery .= 'groups=' . $GroupByToggleName;
129
 
133
 
130
 $GroupBySum = '';
134
 $GroupBySum = '';
131
 $GroupBy = '';
135
 $GroupBy = '';
132
 if (isset($_GET['groups']) && $_GET['groups'] == 'show') {
136
 if (isset($_GET['groups']) && $_GET['groups'] == 'show') {
133
-  $GroupBy = ' GROUP BY g.ID ';
134
-  $GroupBySum = md5($GroupBy);
137
+    $GroupBy = ' GROUP BY g.ID ';
138
+    $GroupBySum = md5($GroupBy);
135
 }
139
 }
136
 
140
 
137
 ?>
141
 ?>
138
   <div style="text-align: right;" class="linkbox">
142
   <div style="text-align: right;" class="linkbox">
139
     <a href="top10.php?<?=$FreeleechToggleQuery?>" class="brackets"><?=ucfirst($FreeleechToggleName)?> freeleech in Top 10</a>
143
     <a href="top10.php?<?=$FreeleechToggleQuery?>" class="brackets"><?=ucfirst($FreeleechToggleName)?> freeleech in Top 10</a>
140
-<?    if (check_perms('users_mod')) { ?>
144
+<?php    if (check_perms('users_mod')) { ?>
141
       <a href="top10.php?<?=$GroupByToggleQuery?>" class="brackets"><?=ucfirst($GroupByToggleName)?> top groups</a>
145
       <a href="top10.php?<?=$GroupByToggleQuery?>" class="brackets"><?=ucfirst($GroupByToggleName)?> top groups</a>
142
-<?    } ?>
146
+<?php    } ?>
143
   </div>
147
   </div>
144
-<?
148
+<?php
145
 
149
 
146
 if (!empty($Where)) {
150
 if (!empty($Where)) {
147
-  $Where = '('.implode(' AND ', $Where).')';
148
-  $WhereSum = md5($Where);
151
+    $Where = '('.implode(' AND ', $Where).')';
152
+    $WhereSum = md5($Where);
149
 } else {
153
 } else {
150
-  $WhereSum = '';
154
+    $WhereSum = '';
151
 }
155
 }
152
 $BaseQuery = '
156
 $BaseQuery = '
153
   SELECT
157
   SELECT
170
     LEFT JOIN torrents_group AS g ON g.ID = t.GroupID';
174
     LEFT JOIN torrents_group AS g ON g.ID = t.GroupID';
171
 
175
 
172
 if ($Details == 'all' || $Details == 'day') {
176
 if ($Details == 'all' || $Details == 'day') {
173
-  $TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum);
174
-  if ($TopTorrentsActiveLastDay === false) {
175
-    if ($Cache->get_query_lock('top10')) {
176
-      $DayAgo = time_minus(86400);
177
-      $Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
178
-      if (!empty($Where)) {
179
-        $Query .= $Where.' AND ';
180
-      }
181
-      $Query .= "
177
+    $TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum);
178
+    if ($TopTorrentsActiveLastDay === false) {
179
+        if ($Cache->get_query_lock('top10')) {
180
+            $DayAgo = time_minus(86400);
181
+            $Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
182
+            if (!empty($Where)) {
183
+                $Query .= $Where.' AND ';
184
+            }
185
+            $Query .= "
182
         t.Time>'$DayAgo'
186
         t.Time>'$DayAgo'
183
         $GroupBy
187
         $GroupBy
184
         ORDER BY (t.Seeders + t.Leechers) DESC
188
         ORDER BY (t.Seeders + t.Leechers) DESC
185
         LIMIT $Limit;";
189
         LIMIT $Limit;";
186
-      $DB->query($Query);
187
-      $TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
188
-      $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
189
-      $Cache->clear_query_lock('top10');
190
-    } else {
191
-      $TopTorrentsActiveLastDay = false;
190
+            $DB->query($Query);
191
+            $TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
192
+            $Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
193
+            $Cache->clear_query_lock('top10');
194
+        } else {
195
+            $TopTorrentsActiveLastDay = false;
196
+        }
192
     }
197
     }
193
-  }
194
-  generate_torrent_table('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
198
+    generate_torrent_table('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
195
 }
199
 }
196
 if ($Details == 'all' || $Details == 'week') {
200
 if ($Details == 'all' || $Details == 'week') {
197
-  $TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum);
198
-  if ($TopTorrentsActiveLastWeek === false) {
199
-    if ($Cache->get_query_lock('top10')) {
200
-      $WeekAgo = time_minus(604800);
201
-      $Query = $BaseQuery.' WHERE ';
202
-      if (!empty($Where)) {
203
-        $Query .= $Where.' AND ';
204
-      }
205
-      $Query .= "
201
+    $TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum);
202
+    if ($TopTorrentsActiveLastWeek === false) {
203
+        if ($Cache->get_query_lock('top10')) {
204
+            $WeekAgo = time_minus(604800);
205
+            $Query = $BaseQuery.' WHERE ';
206
+            if (!empty($Where)) {
207
+                $Query .= $Where.' AND ';
208
+            }
209
+            $Query .= "
206
         t.Time>'$WeekAgo'
210
         t.Time>'$WeekAgo'
207
         $GroupBy
211
         $GroupBy
208
         ORDER BY (t.Seeders + t.Leechers) DESC
212
         ORDER BY (t.Seeders + t.Leechers) DESC
209
         LIMIT $Limit;";
213
         LIMIT $Limit;";
210
-      $DB->query($Query);
211
-      $TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
212
-      $Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
213
-      $Cache->clear_query_lock('top10');
214
-    } else {
215
-      $TopTorrentsActiveLastWeek = false;
214
+            $DB->query($Query);
215
+            $TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
216
+            $Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
217
+            $Cache->clear_query_lock('top10');
218
+        } else {
219
+            $TopTorrentsActiveLastWeek = false;
220
+        }
216
     }
221
     }
217
-  }
218
-  generate_torrent_table('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
222
+    generate_torrent_table('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
219
 }
223
 }
220
 
224
 
221
 if ($Details == 'all' || $Details == 'month') {
225
 if ($Details == 'all' || $Details == 'month') {
222
-  $TopTorrentsActiveLastMonth = $Cache->get_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum);
223
-  if ($TopTorrentsActiveLastMonth === false) {
224
-    if ($Cache->get_query_lock('top10')) {
225
-      $Query = $BaseQuery.' WHERE ';
226
-      if (!empty($Where)) {
227
-        $Query .= $Where.' AND ';
228
-      }
229
-      $Query .= "
226
+    $TopTorrentsActiveLastMonth = $Cache->get_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum);
227
+    if ($TopTorrentsActiveLastMonth === false) {
228
+        if ($Cache->get_query_lock('top10')) {
229
+            $Query = $BaseQuery.' WHERE ';
230
+            if (!empty($Where)) {
231
+                $Query .= $Where.' AND ';
232
+            }
233
+            $Query .= "
230
         t.Time > NOW() - INTERVAL 1 MONTH
234
         t.Time > NOW() - INTERVAL 1 MONTH
231
         $GroupBy
235
         $GroupBy
232
         ORDER BY (t.Seeders + t.Leechers) DESC
236
         ORDER BY (t.Seeders + t.Leechers) DESC
233
         LIMIT $Limit;";
237
         LIMIT $Limit;";
234
-      $DB->query($Query);
235
-      $TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
236
-      $Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
237
-      $Cache->clear_query_lock('top10');
238
-    } else {
239
-      $TopTorrentsActiveLastMonth = false;
238
+            $DB->query($Query);
239
+            $TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
240
+            $Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
241
+            $Cache->clear_query_lock('top10');
242
+        } else {
243
+            $TopTorrentsActiveLastMonth = false;
244
+        }
240
     }
245
     }
241
-  }
242
-  generate_torrent_table('Most Active Torrents Uploaded in the Past Month', 'month', $TopTorrentsActiveLastMonth, $Limit);
246
+    generate_torrent_table('Most Active Torrents Uploaded in the Past Month', 'month', $TopTorrentsActiveLastMonth, $Limit);
243
 }
247
 }
244
 
248
 
245
 if ($Details == 'all' || $Details == 'year') {
249
 if ($Details == 'all' || $Details == 'year') {
246
-  $TopTorrentsActiveLastYear = $Cache->get_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum);
247
-  if ($TopTorrentsActiveLastYear === false) {
248
-    if ($Cache->get_query_lock('top10')) {
249
-      // IMPORTANT NOTE - we use WHERE t.Seeders>200 in order to speed up this query. You should remove it!
250
-      $Query = $BaseQuery.' WHERE ';
251
-      if ($Details == 'all' && !$Filtered) {
250
+    $TopTorrentsActiveLastYear = $Cache->get_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum);
251
+    if ($TopTorrentsActiveLastYear === false) {
252
+        if ($Cache->get_query_lock('top10')) {
253
+            // IMPORTANT NOTE - we use WHERE t.Seeders>200 in order to speed up this query. You should remove it!
254
+            $Query = $BaseQuery.' WHERE ';
255
+            if ($Details == 'all' && !$Filtered) {
252
 //        $Query .= 't.Seeders>=200 AND ';
256
 //        $Query .= 't.Seeders>=200 AND ';
253
-        if (!empty($Where)) {
254
-          $Query .= $Where.' AND ';
255
-        }
256
-      } elseif (!empty($Where)) {
257
-        $Query .= $Where.' AND ';
258
-      }
259
-      $Query .= "
257
+                if (!empty($Where)) {
258
+                    $Query .= $Where.' AND ';
259
+                }
260
+            } elseif (!empty($Where)) {
261
+                $Query .= $Where.' AND ';
262
+            }
263
+            $Query .= "
260
         t.Time > NOW() - INTERVAL 1 YEAR
264
         t.Time > NOW() - INTERVAL 1 YEAR
261
         $GroupBy
265
         $GroupBy
262
         ORDER BY (t.Seeders + t.Leechers) DESC
266
         ORDER BY (t.Seeders + t.Leechers) DESC
263
         LIMIT $Limit;";
267
         LIMIT $Limit;";
264
-      $DB->query($Query);
265
-      $TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
266
-      $Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
267
-      $Cache->clear_query_lock('top10');
268
-    } else {
269
-      $TopTorrentsActiveLastYear = false;
268
+            $DB->query($Query);
269
+            $TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
270
+            $Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
271
+            $Cache->clear_query_lock('top10');
272
+        } else {
273
+            $TopTorrentsActiveLastYear = false;
274
+        }
270
     }
275
     }
271
-  }
272
-  generate_torrent_table('Most Active Torrents Uploaded in the Past Year', 'year', $TopTorrentsActiveLastYear, $Limit);
276
+    generate_torrent_table('Most Active Torrents Uploaded in the Past Year', 'year', $TopTorrentsActiveLastYear, $Limit);
273
 }
277
 }
274
 
278
 
275
 if ($Details == 'all' || $Details == 'overall') {
279
 if ($Details == 'all' || $Details == 'overall') {
276
-  $TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum);
277
-  if ($TopTorrentsActiveAllTime === false) {
278
-    if ($Cache->get_query_lock('top10')) {
279
-      // IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
280
-      $Query = $BaseQuery;
281
-      if ($Details=='all' && !$Filtered) {
282
-//        $Query .= "t.Seeders>=500 ";
283
-        if (!empty($Where)) {
284
-          $Query .= ' WHERE '.$Where;
285
-        }
286
-      } elseif (!empty($Where)) {
287
-        $Query .= ' WHERE '.$Where;
288
-      }
289
-      $Query .= "
280
+    $TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum);
281
+    if ($TopTorrentsActiveAllTime === false) {
282
+        if ($Cache->get_query_lock('top10')) {
283
+            // IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
284
+            $Query = $BaseQuery;
285
+            if ($Details=='all' && !$Filtered) {
286
+                //$Query .= "t.Seeders>=500 ";
287
+                if (!empty($Where)) {
288
+                    $Query .= ' WHERE '.$Where;
289
+                }
290
+            } elseif (!empty($Where)) {
291
+                $Query .= ' WHERE '.$Where;
292
+            }
293
+            $Query .= "
290
         $GroupBy
294
         $GroupBy
291
         ORDER BY (t.Seeders + t.Leechers) DESC
295
         ORDER BY (t.Seeders + t.Leechers) DESC
292
         LIMIT $Limit;";
296
         LIMIT $Limit;";
293
-      $DB->query($Query);
294
-      $TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
295
-      $Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
296
-      $Cache->clear_query_lock('top10');
297
-    } else {
298
-      $TopTorrentsActiveAllTime = false;
297
+            $DB->query($Query);
298
+            $TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
299
+            $Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
300
+            $Cache->clear_query_lock('top10');
301
+        } else {
302
+            $TopTorrentsActiveAllTime = false;
303
+        }
299
     }
304
     }
300
-  }
301
-  generate_torrent_table('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
305
+    generate_torrent_table('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
302
 }
306
 }
303
 
307
 
304
 if (($Details == 'all' || $Details == 'snatched') && !$Filtered) {
308
 if (($Details == 'all' || $Details == 'snatched') && !$Filtered) {
305
-  $TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum);
306
-  if ($TopTorrentsSnatched === false) {
307
-    if ($Cache->get_query_lock('top10')) {
308
-      $Query = $BaseQuery;
309
-      if (!empty($Where)) {
310
-        $Query .= ' WHERE '.$Where;
311
-      }
312
-      $Query .= "
309
+    $TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum);
310
+    if ($TopTorrentsSnatched === false) {
311
+        if ($Cache->get_query_lock('top10')) {
312
+            $Query = $BaseQuery;
313
+            if (!empty($Where)) {
314
+                $Query .= ' WHERE '.$Where;
315
+            }
316
+            $Query .= "
313
         $GroupBy
317
         $GroupBy
314
         ORDER BY t.Snatched DESC
318
         ORDER BY t.Snatched DESC
315
         LIMIT $Limit;";
319
         LIMIT $Limit;";
316
-      $DB->query($Query);
317
-      $TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
318
-      $Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
319
-      $Cache->clear_query_lock('top10');
320
-    } else {
321
-      $TopTorrentsSnatched = false;
320
+            $DB->query($Query);
321
+            $TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
322
+            $Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
323
+            $Cache->clear_query_lock('top10');
324
+        } else {
325
+            $TopTorrentsSnatched = false;
326
+        }
322
     }
327
     }
323
-  }
324
-  generate_torrent_table('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
328
+    generate_torrent_table('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
325
 }
329
 }
326
 
330
 
327
 if (($Details == 'all' || $Details == 'data') && !$Filtered) {
331
 if (($Details == 'all' || $Details == 'data') && !$Filtered) {
328
-  $TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum);
329
-  if ($TopTorrentsTransferred === false) {
330
-    if ($Cache->get_query_lock('top10')) {
331
-      // IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
332
-      $Query = $BaseQuery;
333
-      if ($Details=='all') {
334
-//        $Query .= " WHERE t.Snatched>=100 ";
335
-        if (!empty($Where)) {
336
-          $Query .= ' WHERE '.$Where;
337
-        }
338
-      }
339
-      $Query .= "
332
+    $TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum);
333
+    if ($TopTorrentsTransferred === false) {
334
+        if ($Cache->get_query_lock('top10')) {
335
+            // IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
336
+            $Query = $BaseQuery;
337
+            if ($Details=='all') {
338
+                //$Query .= " WHERE t.Snatched>=100 ";
339
+                if (!empty($Where)) {
340
+                    $Query .= ' WHERE '.$Where;
341
+                }
342
+            }
343
+            $Query .= "
340
         $GroupBy
344
         $GroupBy
341
         ORDER BY Data DESC
345
         ORDER BY Data DESC
342
         LIMIT $Limit;";
346
         LIMIT $Limit;";
343
-      $DB->query($Query);
344
-      $TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
345
-      $Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
346
-      $Cache->clear_query_lock('top10');
347
-    } else {
348
-      $TopTorrentsTransferred = false;
347
+            $DB->query($Query);
348
+            $TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
349
+            $Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
350
+            $Cache->clear_query_lock('top10');
351
+        } else {
352
+            $TopTorrentsTransferred = false;
353
+        }
349
     }
354
     }
350
-  }
351
-  generate_torrent_table('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
355
+    generate_torrent_table('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
352
 }
356
 }
353
 
357
 
354
 if (($Details == 'all' || $Details == 'seeded') && !$Filtered) {
358
 if (($Details == 'all' || $Details == 'seeded') && !$Filtered) {
355
-  $TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum);
356
-  if ($TopTorrentsSeeded === false) {
357
-    if ($Cache->get_query_lock('top10')) {
358
-      $Query = $BaseQuery;
359
-      if (!empty($Where)) {
360
-        $Query .= ' WHERE '.$Where;
361
-      }
362
-      $Query .= "
359
+    $TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum);
360
+    if ($TopTorrentsSeeded === false) {
361
+        if ($Cache->get_query_lock('top10')) {
362
+            $Query = $BaseQuery;
363
+            if (!empty($Where)) {
364
+                $Query .= ' WHERE '.$Where;
365
+            }
366
+            $Query .= "
363
         $GroupBy
367
         $GroupBy
364
         ORDER BY t.Seeders DESC
368
         ORDER BY t.Seeders DESC
365
         LIMIT $Limit;";
369
         LIMIT $Limit;";
366
-      $DB->query($Query);
367
-      $TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
368
-      $Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
369
-      $Cache->clear_query_lock('top10');
370
-    } else {
371
-      $TopTorrentsSeeded = false;
370
+            $DB->query($Query);
371
+            $TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
372
+            $Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
373
+            $Cache->clear_query_lock('top10');
374
+        } else {
375
+            $TopTorrentsSeeded = false;
376
+        }
372
     }
377
     }
373
-  }
374
-  generate_torrent_table('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
378
+    generate_torrent_table('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
375
 }
379
 }
376
 
380
 
377
 ?>
381
 ?>
378
 </div>
382
 </div>
379
-<?
383
+<?php
380
 View::show_footer();
384
 View::show_footer();
381
 
385
 
382
-// generate a table based on data from most recent query to $DB
383
-function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
384
-  global $LoggedUser, $Categories, $ReleaseTypes, $GroupBy;
385
-?>
386
+// Generate a table based on data from most recent query to $DB
387
+function generate_torrent_table($Caption, $Tag, $Details, $Limit)
388
+{
389
+    global $LoggedUser, $Categories, $ReleaseTypes, $GroupBy; ?>
386
     <h3>Top <?="$Limit $Caption"?>
390
     <h3>Top <?="$Limit $Caption"?>
387
-<?  if (empty($_GET['advanced'])) { ?>
391
+<?php  if (empty($_GET['advanced'])) { ?>
388
     <small class="top10_quantity_links">
392
     <small class="top10_quantity_links">
389
-<?
393
+<?php
390
     switch ($Limit) {
394
     switch ($Limit) {
391
       case 100: ?>
395
       case 100: ?>
392
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
396
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
393
         - <span class="brackets">Top 100</span>
397
         - <span class="brackets">Top 100</span>
394
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
398
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
395
-<?        break;
399
+<?php        break;
396
       case 250: ?>
400
       case 250: ?>
397
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
401
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
398
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
402
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
399
         - <span class="brackets">Top 250</span>
403
         - <span class="brackets">Top 250</span>
400
-<?        break;
404
+<?php        break;
401
       default: ?>
405
       default: ?>
402
         - <span class="brackets">Top 10</span>
406
         - <span class="brackets">Top 10</span>
403
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
407
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
404
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
408
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
405
-<?    } ?>
409
+<?php    } ?>
406
     </small>
410
     </small>
407
-<?  } ?>
411
+<?php  } ?>
408
     </h3>
412
     </h3>
409
   <table class="torrent_table cats numbering border">
413
   <table class="torrent_table cats numbering border">
410
   <tr class="colhead">
414
   <tr class="colhead">
418
     <td style="text-align: right;" class="sign leechers"><svg width="11" height="15" fill="white" 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></td>
422
     <td style="text-align: right;" class="sign leechers"><svg width="11" height="15" fill="white" 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></td>
419
     <td style="text-align: right;">Peers</td>
423
     <td style="text-align: right;">Peers</td>
420
   </tr>
424
   </tr>
421
-<?
425
+<?php
422
   // Server is already processing a top10 query. Starting another one will make things slow
426
   // Server is already processing a top10 query. Starting another one will make things slow
423
   if ($Details === false) {
427
   if ($Details === false) {
424
-?>
428
+      ?>
425
     <tr class="row">
429
     <tr class="row">
426
       <td colspan="9" class="center">
430
       <td colspan="9" class="center">
427
         Server is busy processing another top list request. Please try again in a minute.
431
         Server is busy processing another top list request. Please try again in a minute.
428
       </td>
432
       </td>
429
     </tr>
433
     </tr>
430
     </table><br />
434
     </table><br />
431
-<?
435
+<?php
432
     return;
436
     return;
433
   }
437
   }
434
-  // in the unlikely event that query finds 0 rows...
435
-  if (empty($Details)) {
436
-?>
438
+    // iIn the unlikely event that query finds 0 rows...
439
+    if (empty($Details)) {
440
+        ?>
437
     <tr class="row">
441
     <tr class="row">
438
       <td colspan="9" class="center">
442
       <td colspan="9" class="center">
439
         Found no torrents matching the criteria.
443
         Found no torrents matching the criteria.
440
       </td>
444
       </td>
441
     </tr>
445
     </tr>
442
     </table><br />
446
     </table><br />
443
-<?
447
+<?php
444
     return;
448
     return;
445
-  }
446
-  $Rank = 0;
447
-  foreach ($Details as $Detail) {
448
-    $GroupIDs[] = $Detail[1];
449
-  }
450
-  $Artists = Artists::get_artists($GroupIDs);
449
+    }
450
+    $Rank = 0;
451
+    foreach ($Details as $Detail) {
452
+        $GroupIDs[] = $Detail[1];
453
+    }
454
+    $Artists = Artists::get_artists($GroupIDs);
451
 
455
 
452
-  foreach ($Details as $Detail) {
453
-    list($TorrentID, $GroupID, $GroupName, $GroupNameRJ, $GroupNameJP, $GroupCategoryID, $WikiImage, $TagsList,
456
+    foreach ($Details as $Detail) {
457
+        list($TorrentID, $GroupID, $GroupName, $GroupNameRJ, $GroupNameJP, $GroupCategoryID, $WikiImage, $TagsList,
454
       $Media, $Year, $Snatched, $Seeders, $Leechers, $Data, $Size) = $Detail;
458
       $Media, $Year, $Snatched, $Seeders, $Leechers, $Data, $Size) = $Detail;
455
 
459
 
456
-    $IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
457
-    $IsSnatched = Torrents::has_snatched($TorrentID);
460
+        $IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
461
+        $IsSnatched = Torrents::has_snatched($TorrentID);
458
 
462
 
459
-    $Rank++;
463
+        $Rank++;
460
 
464
 
461
-    // generate torrent's title
462
-    $DisplayName = '';
465
+        // Generate torrent's title
466
+        $DisplayName = '';
463
 
467
 
464
-    if (!empty($Artists[$GroupID])) {
465
-      $DisplayName = Artists::display_artists($Artists[$GroupID], true, true);
466
-    }
468
+        if (!empty($Artists[$GroupID])) {
469
+            $DisplayName = Artists::display_artists($Artists[$GroupID], true, true);
470
+        }
467
 
471
 
468
-    $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" ";
469
-    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
470
-      $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
471
-    }
472
+        $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" ";
473
+        if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
474
+            $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage, 'thumb').'" ';
475
+        }
472
 
476
 
473
 
477
 
474
-    $Name = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
475
-    $DisplayName .= "dir=\"ltr\">$Name</a>";
476
-
477
-    // append extra info to torrent title
478
-    $ExtraInfo = '';
479
-    $AddExtra = '';
480
-    if (empty($GroupBy)) {
481
-      if ($Media) {
482
-        $ExtraInfo .= $AddExtra.$Media;
483
-        $AddExtra = ' / ';
484
-      }
485
-      if ($Year > 0) {
486
-        $ExtraInfo .= $AddExtra.$Year;
487
-        $AddExtra = ' ';
488
-      }
489
-      if ($IsSnatched) {
490
-        if ($GroupCategoryID != 5) {
491
-          $ExtraInfo .= ' / ';
478
+        $Name = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
479
+        $DisplayName .= "dir=\"ltr\">$Name</a>";
480
+
481
+        // Append extra info to torrent title
482
+        $ExtraInfo = '';
483
+        $AddExtra = '';
484
+        if (empty($GroupBy)) {
485
+            if ($Media) {
486
+                $ExtraInfo .= $AddExtra.$Media;
487
+                $AddExtra = ' / ';
488
+            }
489
+            if ($Year > 0) {
490
+                $ExtraInfo .= $AddExtra.$Year;
491
+                $AddExtra = ' ';
492
+            }
493
+            if ($IsSnatched) {
494
+                if ($GroupCategoryID != 5) {
495
+                    $ExtraInfo .= ' / ';
496
+                }
497
+                $ExtraInfo .= Format::torrent_label('Snatched!');
498
+            }
499
+            if ($ExtraInfo != '') {
500
+                $ExtraInfo = "- [$ExtraInfo]";
501
+            }
492
         }
502
         }
493
-        $ExtraInfo .= Format::torrent_label('Snatched!');
494
-      }
495
-      if ($ExtraInfo != '') {
496
-        $ExtraInfo = "- [$ExtraInfo]";
497
-      }
498
-    }
499
 
503
 
500
-    $TorrentTags = new Tags($TagsList);
504
+        $TorrentTags = new Tags($TagsList);
501
 
505
 
502
-    //Get report info, use the cache if available, if not, add to it.
503
-    $Reported = false;
504
-    $Reports = Torrents::get_reports($TorrentID);
505
-    if (count($Reports) > 0) {
506
-      $Reported = true;
507
-    }
506
+        // Get report info, use the cache if available. If not, add to it
507
+        $Reported = false;
508
+        $Reports = Torrents::get_reports($TorrentID);
509
+        if (count($Reports) > 0) {
510
+            $Reported = true;
511
+        }
508
 
512
 
509
-    // print row
510
-?>
513
+        // Print row?>
511
   <tr class="torrent row<?=($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '')?>">
514
   <tr class="torrent row<?=($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '')?>">
512
     <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
515
     <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
513
     <td class="center cats_col"><div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div></td>
516
     <td class="center cats_col"><div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div></td>
516
 
519
 
517
         <span><a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a></span>
520
         <span><a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets tooltip">DL</a></span>
518
 
521
 
519
-        <?=$DisplayName?> <?=$ExtraInfo?><? if ($Reported) { ?> - <strong class="torrent_label tl_reported">Reported</strong><? } ?>
520
-<?
522
+        <?=$DisplayName?> <?=$ExtraInfo?><?php if ($Reported) { ?> - <strong class="torrent_label tl_reported">Reported</strong><?php } ?>
523
+<?php
521
     if ($IsBookmarked) {
524
     if ($IsBookmarked) {
522
-?>
525
+        ?>
523
         <span class="remove_bookmark float_right">
526
         <span class="remove_bookmark float_right">
524
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
527
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
525
         </span>
528
         </span>
526
-<?    } else { ?>
529
+<?php
530
+    } else { ?>
527
         <span class="add_bookmark float_right">
531
         <span class="add_bookmark float_right">
528
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
532
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
529
         </span>
533
         </span>
530
-<?    } ?>
534
+<?php    } ?>
531
         <div class="tags"><?=$TorrentTags->format()?></div>
535
         <div class="tags"><?=$TorrentTags->format()?></div>
532
       </div>
536
       </div>
533
     </td>
537
     </td>
538
     <td class="number_column"><?=number_format((double)$Leechers)?></td>
542
     <td class="number_column"><?=number_format((double)$Leechers)?></td>
539
     <td class="number_column"><?=number_format($Seeders + $Leechers)?></td>
543
     <td class="number_column"><?=number_format($Seeders + $Leechers)?></td>
540
   </tr>
544
   </tr>
541
-<?
542
-  } //foreach ($Details as $Detail)
545
+<?php
546
+    } // foreach ($Details as $Detail)
543
 ?>
547
 ?>
544
   </table><br />
548
   </table><br />
545
-<?
549
+<?php
546
 }
550
 }
547
 ?>
551
 ?>

+ 282
- 282
sections/torrents/browse.php View File

1
-<?
1
+<?php
2
+
3
+# @todo Go through line by line
4
+
2
 include(SERVER_ROOT.'/sections/torrents/functions.php');
5
 include(SERVER_ROOT.'/sections/torrents/functions.php');
3
 
6
 
4
 // The "order by x" links on columns headers
7
 // The "order by x" links on columns headers
5
-function header_link($SortKey, $DefaultWay = 'desc') {
6
-  global $OrderBy, $OrderWay;
7
-  if ($SortKey == $OrderBy) {
8
-    if ($OrderWay == 'desc') {
9
-      $NewWay = 'asc';
8
+function header_link($SortKey, $DefaultWay = 'desc')
9
+{
10
+    global $OrderBy, $OrderWay;
11
+    if ($SortKey == $OrderBy) {
12
+        if ($OrderWay == 'desc') {
13
+            $NewWay = 'asc';
14
+        } else {
15
+            $NewWay = 'desc';
16
+        }
10
     } else {
17
     } else {
11
-      $NewWay = 'desc';
18
+        $NewWay = $DefaultWay;
12
     }
19
     }
13
-  } else {
14
-    $NewWay = $DefaultWay;
15
-  }
16
-  return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(['order_way', 'order_by']);
20
+    return "torrents.php?order_way=$NewWay&amp;order_by=$SortKey&amp;".Format::get_url(['order_way', 'order_by']);
17
 }
21
 }
18
 
22
 
19
 if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
23
 if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
20
-  if (!empty($_GET['searchstr'])) {
21
-    $InfoHash = $_GET['searchstr'];
22
-
23
-  } else {
24
-    $InfoHash = $_GET['groupname'];
25
-  }
24
+    if (!empty($_GET['searchstr'])) {
25
+        $InfoHash = $_GET['searchstr'];
26
+    } else {
27
+        $InfoHash = $_GET['groupname'];
28
+    }
26
 
29
 
27
-  // Search by infohash
28
-  if ($InfoHash = is_valid_torrenthash($InfoHash)) {
29
-    $InfoHash = db_string(pack('H*', $InfoHash));
30
-    $DB->query("
30
+    // Search by infohash
31
+    if ($InfoHash = is_valid_torrenthash($InfoHash)) {
32
+        $InfoHash = db_string(pack('H*', $InfoHash));
33
+        $DB->query("
31
       SELECT ID, GroupID
34
       SELECT ID, GroupID
32
       FROM torrents
35
       FROM torrents
33
       WHERE info_hash = '$InfoHash'");
36
       WHERE info_hash = '$InfoHash'");
34
-    if ($DB->has_results()) {
35
-      list($ID, $GroupID) = $DB->next_record();
36
-      header("Location: torrents.php?id=$GroupID&torrentid=$ID");
37
-      die();
37
+        if ($DB->has_results()) {
38
+            list($ID, $GroupID) = $DB->next_record();
39
+            header("Location: torrents.php?id=$GroupID&torrentid=$ID");
40
+            die();
41
+        }
38
     }
42
     }
39
-  }
40
 }
43
 }
41
 
44
 
42
 // Setting default search options
45
 // Setting default search options
43
 if (!empty($_GET['setdefault'])) {
46
 if (!empty($_GET['setdefault'])) {
44
-  $UnsetList = ['page', 'setdefault'];
45
-  $UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
47
+    $UnsetList = ['page', 'setdefault'];
48
+    $UnsetRegexp = '/(&|^)('.implode('|', $UnsetList).')=.*?(&|$)/i';
46
 
49
 
47
-  $DB->query("
50
+    $DB->query("
48
     SELECT SiteOptions
51
     SELECT SiteOptions
49
     FROM users_info
52
     FROM users_info
50
     WHERE UserID = ?", $LoggedUser['ID']);
53
     WHERE UserID = ?", $LoggedUser['ID']);
51
-  list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
52
-  $SiteOptions = json_decode($SiteOptions, true) ?? [];
53
-  $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
54
-  $DB->query("
54
+    list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
55
+    $SiteOptions = json_decode($SiteOptions, true) ?? [];
56
+    $SiteOptions['DefaultSearch'] = preg_replace($UnsetRegexp, '', $_SERVER['QUERY_STRING']);
57
+    $DB->query("
55
     UPDATE users_info
58
     UPDATE users_info
56
     SET SiteOptions = ?
59
     SET SiteOptions = ?
57
     WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
60
     WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
58
-  $Cache->begin_transaction("user_info_heavy_$UserID");
59
-  $Cache->update_row(false, ['DefaultSearch' => $SiteOptions['DefaultSearch']]);
60
-  $Cache->commit_transaction(0);
61
+    $Cache->begin_transaction("user_info_heavy_$UserID");
62
+    $Cache->update_row(false, ['DefaultSearch' => $SiteOptions['DefaultSearch']]);
63
+    $Cache->commit_transaction(0);
61
 
64
 
62
 // Clearing default search options
65
 // Clearing default search options
63
 } elseif (!empty($_GET['cleardefault'])) {
66
 } elseif (!empty($_GET['cleardefault'])) {
64
-  $DB->query("
67
+    $DB->query("
65
     SELECT SiteOptions
68
     SELECT SiteOptions
66
     FROM users_info
69
     FROM users_info
67
     WHERE UserID = ?", $LoggedUser['ID']);
70
     WHERE UserID = ?", $LoggedUser['ID']);
68
-  list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
69
-  $SiteOptions = json_decode($SiteOptions, true) ?? [];
70
-  $SiteOptions['DefaultSearch'] = '';
71
-  $DB->query("
71
+    list($SiteOptions) = $DB->next_record(MYSQLI_NUM, false);
72
+    $SiteOptions = json_decode($SiteOptions, true) ?? [];
73
+    $SiteOptions['DefaultSearch'] = '';
74
+    $DB->query("
72
     UPDATE users_info
75
     UPDATE users_info
73
     SET SiteOptions = ?
76
     SET SiteOptions = ?
74
     WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
77
     WHERE UserID = ?", json_encode($SiteOptions), $LoggedUser['ID']);
75
-  $Cache->begin_transaction("user_info_heavy_$UserID");
76
-  $Cache->update_row(false, ['DefaultSearch' => '']);
77
-  $Cache->commit_transaction(0);
78
+    $Cache->begin_transaction("user_info_heavy_$UserID");
79
+    $Cache->update_row(false, ['DefaultSearch' => '']);
80
+    $Cache->commit_transaction(0);
78
 
81
 
79
 // Use default search options
82
 // Use default search options
80
 } elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
83
 } elseif (empty($_SERVER['QUERY_STRING']) || (count($_GET) === 1 && isset($_GET['page']))) {
81
-  if (!empty($LoggedUser['DefaultSearch'])) {
82
-    if (!empty($_GET['page'])) {
83
-      $Page = $_GET['page'];
84
-      parse_str($LoggedUser['DefaultSearch'], $_GET);
85
-      $_GET['page'] = $Page;
86
-    } else {
87
-      parse_str($LoggedUser['DefaultSearch'], $_GET);
84
+    if (!empty($LoggedUser['DefaultSearch'])) {
85
+        if (!empty($_GET['page'])) {
86
+            $Page = $_GET['page'];
87
+            parse_str($LoggedUser['DefaultSearch'], $_GET);
88
+            $_GET['page'] = $Page;
89
+        } else {
90
+            parse_str($LoggedUser['DefaultSearch'], $_GET);
91
+        }
88
     }
92
     }
89
-  }
90
 }
93
 }
91
 // Terms were not submitted via the search form
94
 // Terms were not submitted via the search form
92
 if (isset($_GET['searchsubmit'])) {
95
 if (isset($_GET['searchsubmit'])) {
93
-  $GroupResults = !empty($_GET['group_results']);
96
+    $GroupResults = !empty($_GET['group_results']);
94
 } else {
97
 } else {
95
-  $GroupResults = !$LoggedUser['DisableGrouping2'];
98
+    $GroupResults = !$LoggedUser['DisableGrouping2'];
96
 }
99
 }
97
 
100
 
98
 if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
101
 if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
99
-  $OrderWay = 'asc';
102
+    $OrderWay = 'asc';
100
 } else {
103
 } else {
101
-  $OrderWay = 'desc';
104
+    $OrderWay = 'desc';
102
 }
105
 }
103
 
106
 
104
 if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
107
 if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_by']])) {
105
-  $OrderBy = 'time'; // For header links
108
+    $OrderBy = 'time'; // For header links
106
 } else {
109
 } else {
107
-  $OrderBy = $_GET['order_by'];
110
+    $OrderBy = $_GET['order_by'];
108
 }
111
 }
109
 
112
 
110
 $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
113
 $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
111
 $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
114
 $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
112
 if (isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1) {
115
 if (isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1) {
113
-  $Search->insert_hidden_tags('!lolicon !shotacon !toddlercon');
116
+    $Search->insert_hidden_tags('!lolicon !shotacon !toddlercon');
114
 }
117
 }
115
 if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] == 1) {
118
 if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] == 1) {
116
-  $Search->insert_hidden_tags('!scat');
119
+    $Search->insert_hidden_tags('!scat');
117
 }
120
 }
118
 if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] == 1) {
121
 if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] == 1) {
119
-  $Search->insert_hidden_tags('!snuff');
122
+    $Search->insert_hidden_tags('!snuff');
120
 }
123
 }
121
 $Results = $Search->query($_GET);
124
 $Results = $Search->query($_GET);
122
 $Groups = $Search->get_groups();
125
 $Groups = $Search->get_groups();
128
 $AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] == 'advanced');
131
 $AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] == 'advanced');
129
 $AdvancedSearch &= check_perms('site_advanced_search');
132
 $AdvancedSearch &= check_perms('site_advanced_search');
130
 if ($AdvancedSearch) {
133
 if ($AdvancedSearch) {
131
-  $Action = 'action=advanced';
132
-  $HideBasic = ' hidden';
133
-  $HideAdvanced = '';
134
+    $Action = 'action=advanced';
135
+    $HideBasic = ' hidden';
136
+    $HideAdvanced = '';
134
 } else {
137
 } else {
135
-  $Action = 'action=basic';
136
-  $HideBasic = '';
137
-  $HideAdvanced = ' hidden';
138
+    $Action = 'action=basic';
139
+    $HideBasic = '';
140
+    $HideAdvanced = ' hidden';
138
 }
141
 }
139
 
142
 
140
 View::show_header('Browse Torrents', 'browse');
143
 View::show_header('Browse Torrents', 'browse');
156
       </span>
159
       </span>
157
     </div>
160
     </div>
158
     <div id="ft_container" class="pad<?=$HideFilter ? ' hidden' : ''?>">
161
     <div id="ft_container" class="pad<?=$HideFilter ? ' hidden' : ''?>">
159
-<? if((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1)
162
+<?php if ((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] == 1)
160
    || (isset($LoggedUser['HideScat'])    && $LoggedUser['HideScat']    == 1)
163
    || (isset($LoggedUser['HideScat'])    && $LoggedUser['HideScat']    == 1)
161
    || (isset($LoggedUser['HideSnuff'])   && $LoggedUser['HideSnuff']   == 1)
164
    || (isset($LoggedUser['HideSnuff'])   && $LoggedUser['HideSnuff']   == 1)
162
    ) { ?>
165
    ) { ?>
163
     <svg title="Your profile settings exclude some results" class="search_warning tooltip" width="10" height="15"><rect x=3 width="4" height="10" rx="2" ry="2"/><circle cx="5" cy="13" r="2"/></svg>
166
     <svg title="Your profile settings exclude some results" class="search_warning tooltip" width="10" height="15"><rect x=3 width="4" height="10" rx="2" ry="2"/><circle cx="5" cy="13" r="2"/></svg>
164
-<? } ?>
167
+<?php } ?>
165
       <table class="layout">
168
       <table class="layout">
166
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
169
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
167
           <td class="label"><!--Artist name:--></td>
170
           <td class="label"><!--Artist name:--></td>
196
         <tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
199
         <tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
197
           <td class="label"><!--<span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span>--></td>
200
           <td class="label"><!--<span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span>--></td>
198
           <td class="ft_description">
201
           <td class="ft_description">
199
-            <input type="search" spellcheck="false" size="65" name="description" class="inputtext fti_advanced tooltip_left" placeholder="Torrent Description" title="Search torrent descriptions (not group information)" value="<?Format::form('description')?>" />
202
+            <input type="search" spellcheck="false" size="65" name="description" class="inputtext fti_advanced" placeholder="Torrent Description" value="<?php Format::form('description') ?>" /><br /><br />
203
+            Search torrent descriptions (not group information)
200
           </td>
204
           </td>
201
         </tr>
205
         </tr>
202
         <tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
206
         <tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
203
-          <td class="label">Release Specifics</td>
207
+          <td class="label">Specifics</td>
204
           <td class="nobr ft_ripspecifics">
208
           <td class="nobr ft_ripspecifics">
205
             <select id="container" name="container" class="ft_container fti_advanced">
209
             <select id="container" name="container" class="ft_container fti_advanced">
206
               <option value="">Format</option>
210
               <option value="">Format</option>
207
-  <?  foreach ($Containers as $Container) { ?>
211
+  <?php  foreach ($Containers as $Container) { ?>
208
               <option value="<?=display_str($Container);?>" <?Format::selected('container', $Container)?>><?=display_str($Container);?></option>
212
               <option value="<?=display_str($Container);?>" <?Format::selected('container', $Container)?>><?=display_str($Container);?></option>
209
-  <?  } ?>
213
+  <?php  } ?>
210
             </select>
214
             </select>
211
             <select name="codec" class="ft_codec fti_advanced">
215
             <select name="codec" class="ft_codec fti_advanced">
212
               <option value="">License</option>
216
               <option value="">License</option>
213
-  <?  foreach ($Codecs as $Codec) { ?>
217
+  <?php  foreach ($Codecs as $Codec) { ?>
214
               <option value="<?=display_str($Codec); ?>"<?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?></option>
218
               <option value="<?=display_str($Codec); ?>"<?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?></option>
215
-  <?  } ?>
219
+  <?php  } ?>
216
             </select>
220
             </select>
217
             <select name="media" class="ft_media fti_advanced">
221
             <select name="media" class="ft_media fti_advanced">
218
               <option value="">Platform</option>
222
               <option value="">Platform</option>
219
-  <?  foreach ($Media as $MediaName) { ?>
223
+  <?php  foreach ($Media as $MediaName) { ?>
220
               <option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
224
               <option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
221
-  <?  } ?>
225
+  <?php  } ?>
222
             </select>
226
             </select>
223
             <select name="resolution" class="ft_resolution fti_advanced">
227
             <select name="resolution" class="ft_resolution fti_advanced">
224
               <option value="">Assembly Level</option>
228
               <option value="">Assembly Level</option>
225
-  <?  foreach ($Resolutions as $Resolution) { ?>
229
+  <?php  foreach ($Resolutions as $Resolution) { ?>
226
               <option value="<?=display_str($Resolution); ?>"<?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?></option>
230
               <option value="<?=display_str($Resolution); ?>"<?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?></option>
227
-  <?  } ?>
231
+  <?php  } ?>
228
             </select>
232
             </select>
229
           </td>
233
           </td>
230
         </tr>
234
         </tr>
254
               <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
258
               <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
255
             </select>
259
             </select>
256
             <select name="censored" class="ft_censored fti_advanced">
260
             <select name="censored" class="ft_censored fti_advanced">
257
-              <option value="">Aligned Sequence?</option>
261
+              <option value="">Alignment</option>
258
               <option value="1"<?Format::selected('censored', 1)?>>Aligned</option>
262
               <option value="1"<?Format::selected('censored', 1)?>>Aligned</option>
259
               <option value="0"<?Format::selected('censored', 0)?>>Unaligned</option>
263
               <option value="0"<?Format::selected('censored', 0)?>>Unaligned</option>
260
             </select>
264
             </select>
269
         <tr id="tagfilter">
273
         <tr id="tagfilter">
270
           <td class="label"><!--<span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span>--></td>
274
           <td class="label"><!--<span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span>--></td>
271
           <td class="ft_taglist">
275
           <td class="ft_taglist">
272
-            <input type="search" size="37" id="tags" name="taglist" class="inputtext smaller tooltip_left" title="Use !tag to exclude tag" placeholder="Tags (comma-separated)" value="<?=display_str($Search->get_terms('taglist'))?>"<? Users::has_autocomplete_enabled('other'); ?> aria-label="Tags to search">&nbsp;
276
+            <input type="search" size="37" id="tags" name="taglist" class="inputtext smaller" placeholder="Tags (comma-separated)" value="<?=display_str($Search->get_terms('taglist'))?>"<?php Users::has_autocomplete_enabled('other'); ?> aria-label="Tags to search">&nbsp;
273
             <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
277
             <input type="radio" name="tags_type" id="tags_type0" value="0"<?Format::selected('tags_type', 0, 'checked')?> /><label for="tags_type0"> Any</label>&nbsp;&nbsp;
274
-            <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label>
278
+            <input type="radio" name="tags_type" id="tags_type1" value="1"<?Format::selected('tags_type', 1, 'checked')?> /><label for="tags_type1"> All</label><br /><br />
279
+            Use !tag to exclude tags
275
           </td>
280
           </td>
276
         </tr>
281
         </tr>
277
         <tr id="order">
282
         <tr id="order">
295
         </tr>
300
         </tr>
296
         <tr id="search_group_results">
301
         <tr id="search_group_results">
297
           <td class="label">
302
           <td class="label">
298
-            <label for="group_results">Group by Release?</label>
303
+            <label for="group_results">Group Torrents</label>
299
           </td>
304
           </td>
300
           <td class="ft_group_results">
305
           <td class="ft_group_results">
301
             <input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
306
             <input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
303
         </tr>
308
         </tr>
304
       </table>
309
       </table>
305
       <table class="layout cat_list ft_cat_list">
310
       <table class="layout cat_list ft_cat_list">
306
-  <?
311
+  <?php
307
   $x = 0;
312
   $x = 0;
308
   reset($Categories);
313
   reset($Categories);
309
   foreach ($Categories as $CatKey => $CatName) {
314
   foreach ($Categories as $CatKey => $CatName) {
310
-    if ($x % 7 == 0) {
311
-      if ($x > 0) {
312
-  ?>
315
+      if ($x % 7 == 0) {
316
+          if ($x > 0) {
317
+              ?>
313
         </tr>
318
         </tr>
314
-  <?    } ?>
319
+  <?php
320
+          } ?>
315
         <tr>
321
         <tr>
316
-  <?
317
-    }
318
-    $x++;
319
-  ?>
322
+  <?php
323
+      }
324
+      $x++; ?>
320
           <td>
325
           <td>
321
-            <input type="checkbox" name="filter_cat[<?=($CatKey + 1)?>]" id="cat_<?=($CatKey + 1)?>" value="1"<? if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<? } ?> />
326
+            <input type="checkbox" name="filter_cat[<?=($CatKey + 1)?>]" id="cat_<?=($CatKey + 1)?>" value="1"<?php if (isset($_GET['filter_cat'][$CatKey + 1])) { ?> checked="checked"<?php } ?> />
322
             <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
327
             <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
323
           </td>
328
           </td>
324
-  <?
329
+  <?php
325
   }
330
   }
326
   ?>
331
   ?>
327
         </tr>
332
         </tr>
328
       </table>
333
       </table>
329
-      <table class="layout cat_list<? if (empty($LoggedUser['ShowTags'])) { ?> hidden<? } ?>" id="taglist">
334
+      <table class="layout cat_list<?php if (empty($LoggedUser['ShowTags'])) { ?> hidden<?php } ?>" id="taglist">
330
         <tr>
335
         <tr>
331
-  <?
336
+  <?php
332
   $GenreTags = $Cache->get_value('genre_tags');
337
   $GenreTags = $Cache->get_value('genre_tags');
333
   if (!$GenreTags) {
338
   if (!$GenreTags) {
334
-    $DB->query('
339
+      $DB->query('
335
       SELECT Name
340
       SELECT Name
336
       FROM tags
341
       FROM tags
337
       WHERE TagType = \'genre\'
342
       WHERE TagType = \'genre\'
338
       ORDER BY Name');
343
       ORDER BY Name');
339
-    $GenreTags = $DB->collect('Name');
340
-    $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
344
+      $GenreTags = $DB->collect('Name');
345
+      $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
341
   }
346
   }
342
 
347
 
343
   $x = 0;
348
   $x = 0;
344
   foreach ($GenreTags as $Tag) {
349
   foreach ($GenreTags as $Tag) {
345
-  ?>
350
+      ?>
346
           <td><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
351
           <td><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
347
-  <?
352
+  <?php
348
     $x++;
353
     $x++;
349
-    if ($x % 7 == 0) {
350
-  ?>
354
+      if ($x % 7 == 0) {
355
+          ?>
351
         </tr>
356
         </tr>
352
         <tr>
357
         <tr>
353
-  <?
354
-    }
358
+  <?php
359
+      }
355
   }
360
   }
356
   if ($x % 7 != 0) { // Padding
361
   if ($x % 7 != 0) { // Padding
357
   ?>
362
   ?>
358
           <td colspan="<?=(7 - ($x % 7))?>"> </td>
363
           <td colspan="<?=(7 - ($x % 7))?>"> </td>
359
-  <? } ?>
364
+  <?php } ?>
360
         </tr>
365
         </tr>
361
       </table>
366
       </table>
362
       <table class="layout cat_list">
367
       <table class="layout cat_list">
368
       </table>
373
       </table>
369
       <div class="submit ft_submit">
374
       <div class="submit ft_submit">
370
         <span class="float_left"><?=number_format($NumResults)?> Results</span>
375
         <span class="float_left"><?=number_format($NumResults)?> Results</span>
371
-        <input type="submit" value="Filter torrents" />
376
+        <input type="submit" value="Search" />
372
         <input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
377
         <input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
373
         <input type="hidden" name="searchsubmit" value="1" />
378
         <input type="hidden" name="searchsubmit" value="1" />
374
-        <input type="button" value="Reset" onclick="location.href = 'torrents.php<? if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<? } ?>'" />
379
+        <input type="button" value="Reset" onclick="location.href = 'torrents.php<?php if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<?php } ?>'" />
375
         &nbsp;&nbsp;
380
         &nbsp;&nbsp;
376
-<?    if ($Search->has_filters()) { ?>
377
-        <input type="submit" name="setdefault" value="Make default" />
378
-<?    }
381
+<?php    if ($Search->has_filters()) { ?>
382
+        <input type="submit" name="setdefault" value="Make Default" />
383
+<?php    }
379
 
384
 
380
       if (!empty($LoggedUser['DefaultSearch'])) { ?>
385
       if (!empty($LoggedUser['DefaultSearch'])) { ?>
381
-        <input type="submit" name="cleardefault" value="Clear default" />
382
-<?    } ?>
386
+        <input type="submit" name="cleardefault" value="Clear Default" />
387
+<?php    } ?>
383
       </div>
388
       </div>
384
     </div>
389
     </div>
385
   </div>
390
   </div>
386
   </form>
391
   </form>
387
-<? if ($NumResults == 0) { ?>
392
+<?php if ($NumResults == 0) { ?>
388
   <div class="torrents_nomatch box pad" align="center">
393
   <div class="torrents_nomatch box pad" align="center">
389
     <h2>Your search did not match anything.</h2>
394
     <h2>Your search did not match anything.</h2>
390
     <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
395
     <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
391
   </div>
396
   </div>
392
   </div>
397
   </div>
393
-<?    View::show_footer();die();
398
+<?php    View::show_footer();die();
394
   }
399
   }
395
 
400
 
396
   if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
401
   if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
397
-    $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
398
-    $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE);
399
-?>
402
+      $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
403
+      $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE); ?>
400
   <div class="torrents_nomatch box pad" align="center">
404
   <div class="torrents_nomatch box pad" align="center">
401
     <h2>The requested page contains no matches.</h2>
405
     <h2>The requested page contains no matches.</h2>
402
     <p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
406
     <p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
403
   </div>
407
   </div>
404
   <div class="linkbox">Go to page <?=$Pages?></div>
408
   <div class="linkbox">Go to page <?=$Pages?></div>
405
   </div>
409
   </div>
406
-<?
407
-    View::show_footer();die();
410
+<?php
411
+    View::show_footer();
412
+      die();
408
   }
413
   }
409
 
414
 
410
   // List of pages
415
   // List of pages
417
 
422
 
418
   <table class="box torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
423
   <table class="box torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
419
     <tr class="colhead">
424
     <tr class="colhead">
420
-  <?  if ($GroupResults) { ?>
425
+  <?php  if ($GroupResults) { ?>
421
       <td class="small"></td>
426
       <td class="small"></td>
422
-  <?  } ?>
427
+  <?php  } ?>
423
       <td class="small cats_col"></td>
428
       <td class="small cats_col"></td>
424
       <td>Name / <a href="<?=header_link('year')?>">Year</a></td>
429
       <td>Name / <a href="<?=header_link('year')?>">Year</a></td>
425
       <td>Files</td>
430
       <td>Files</td>
441
         </a>
446
         </a>
442
       </td>
447
       </td>
443
     </tr>
448
     </tr>
444
-  <?
449
+  <?php
445
 
450
 
446
   // Start printing torrent list
451
   // Start printing torrent list
447
   foreach ($Results as $Key => $GroupID) {
452
   foreach ($Results as $Key => $GroupID) {
448
-    $GroupInfo = $Groups[$GroupID];
449
-  if (empty($GroupInfo['Torrents'])) {
450
-    continue;
451
-  }
452
-  $CategoryID = $GroupInfo['CategoryID'];
453
-  $GroupYear = $GroupInfo['Year'];
454
-  $Artists = $GroupInfo['Artists'];
455
-  $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
456
-  $GroupPages = $GroupInfo['Pages'];
457
-  $GroupStudio = $GroupInfo['Studio'];
458
-  $GroupDLsiteID = $GroupInfo['DLSiteID'];
459
-  $GroupName = empty($GroupInfo['Name']) ? (empty($GroupInfo['NameRJ']) ? $GroupInfo['NameJP'] : $GroupInfo['NameRJ']) : $GroupInfo['Name'];
460
-  if ($GroupResults) {
461
-    $Torrents = $GroupInfo['Torrents'];
462
-    $GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
463
-    foreach ($Torrents as $T) {
464
-      $GroupTime = max($GroupTime, strtotime($T['Time']));
465
-      $MaxSize = max($MaxSize, $T['Size']);
466
-      $TotalLeechers += $T['Leechers'];
467
-      $TotalSeeders += $T['Seeders'];
468
-      $TotalSnatched += $T['Snatched'];
469
-    }
470
-  } else {
471
-    $TorrentID = $Key;
472
-    $Torrents = [$TorrentID => $GroupInfo['Torrents'][$TorrentID]];
473
-  }
474
-
475
-  $TorrentTags = new Tags($GroupInfo['TagList']);
453
+      $GroupInfo = $Groups[$GroupID];
454
+      if (empty($GroupInfo['Torrents'])) {
455
+          continue;
456
+      }
457
+      $CategoryID = $GroupInfo['CategoryID'];
458
+      $GroupYear = $GroupInfo['Year'];
459
+      $Artists = $GroupInfo['Artists'];
460
+      $GroupCatalogueNumber = $GroupInfo['CatalogueNumber'];
461
+      $GroupPages = $GroupInfo['Pages'];
462
+      $GroupStudio = $GroupInfo['Studio'];
463
+      $GroupDLsiteID = $GroupInfo['DLSiteID'];
464
+      $GroupName = empty($GroupInfo['Name']) ? (empty($GroupInfo['NameRJ']) ? $GroupInfo['NameJP'] : $GroupInfo['NameRJ']) : $GroupInfo['Name'];
465
+      if ($GroupResults) {
466
+          $Torrents = $GroupInfo['Torrents'];
467
+          $GroupTime = $MaxSize = $TotalLeechers = $TotalSeeders = $TotalSnatched = 0;
468
+          foreach ($Torrents as $T) {
469
+              $GroupTime = max($GroupTime, strtotime($T['Time']));
470
+              $MaxSize = max($MaxSize, $T['Size']);
471
+              $TotalLeechers += $T['Leechers'];
472
+              $TotalSeeders += $T['Seeders'];
473
+              $TotalSnatched += $T['Snatched'];
474
+          }
475
+      } else {
476
+          $TorrentID = $Key;
477
+          $Torrents = [$TorrentID => $GroupInfo['Torrents'][$TorrentID]];
478
+      }
476
 
479
 
477
-  if (isset($Artists)) {
478
-    $DisplayName = '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
479
-  } else {
480
-    $DisplayName = '';
481
-  }
480
+      $TorrentTags = new Tags($GroupInfo['TagList']);
482
 
481
 
483
-  $SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
482
+      if (isset($Artists)) {
483
+          $DisplayName = '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
484
+      } else {
485
+          $DisplayName = '';
486
+      }
484
 
487
 
485
-  if ($GroupResults && (count($Torrents) > 1 && isset($GroupedCategories[$CategoryID - 1]))) {
486
-    // These torrents are in a group
487
-    $CoverArt = $GroupInfo['WikiImage'];
488
-    $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
489
-    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
490
-      $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
491
-    }
492
-    $DisplayName .= "dir=\"ltr\">$GroupName</a>";
493
-    if ($GroupYear) {
494
-      $DisplayName .= " [$GroupYear]";
495
-    }
496
-    if ($GroupStudio) {
497
-      $DisplayName .= " [$GroupStudio]";
498
-    }
499
-    if ($GroupCatalogueNumber) {
500
-      $DisplayName .= " [$GroupCatalogueNumber]";
501
-    }
502
-    if ($GroupPages) {
503
-      $DisplayName .= " [{$GroupPages}p]";
504
-    }
505
-    if ($GroupDLsiteID) {
506
-      $DisplayName .= " [$GroupDLsiteID]";
507
-    }
508
-?>
488
+      $SnatchedGroupClass = $GroupInfo['Flags']['IsSnatched'] ? ' snatched_group' : '';
489
+
490
+      if ($GroupResults && (count($Torrents) > 1 && isset($GroupedCategories[$CategoryID - 1]))) {
491
+          // These torrents are in a group
492
+          $CoverArt = $GroupInfo['WikiImage'];
493
+          $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
494
+          if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
495
+              $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
496
+          }
497
+          $DisplayName .= "dir=\"ltr\">$GroupName</a>";
498
+          if ($GroupYear) {
499
+              $DisplayName .= " [$GroupYear]";
500
+          }
501
+          if ($GroupStudio) {
502
+              $DisplayName .= " [$GroupStudio]";
503
+          }
504
+          if ($GroupCatalogueNumber) {
505
+              $DisplayName .= " [$GroupCatalogueNumber]";
506
+          }
507
+          if ($GroupPages) {
508
+              $DisplayName .= " [{$GroupPages}p]";
509
+          }
510
+          if ($GroupDLsiteID) {
511
+              $DisplayName .= " [$GroupDLsiteID]";
512
+          } ?>
509
   <tr class="group<?=$SnatchedGroupClass?>">
513
   <tr class="group<?=$SnatchedGroupClass?>">
510
-<?
511
-$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1);
512
-?>
514
+<?php
515
+$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); ?>
513
     <td class="center">
516
     <td class="center">
514
       <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
517
       <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
515
         <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
518
         <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event)" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
522
     <td colspan="2" class="big_info">
525
     <td colspan="2" class="big_info">
523
       <div class="group_info clear">
526
       <div class="group_info clear">
524
       <?=$DisplayName?>
527
       <?=$DisplayName?>
525
-<?  if (in_array($GroupID, $Bookmarks)) { ?>
528
+<?php  if (in_array($GroupID, $Bookmarks)) { ?>
526
         <span class="remove_bookmark float_right">
529
         <span class="remove_bookmark float_right">
527
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
530
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
528
         </span>
531
         </span>
529
-<?  } else { ?>
532
+<?php  } else { ?>
530
         <span class="add_bookmark float_right">
533
         <span class="add_bookmark float_right">
531
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
534
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
532
         </span>
535
         </span>
533
-<?  } ?>
536
+<?php  } ?>
534
         <br />
537
         <br />
535
         <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
538
         <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
536
       </div>
539
       </div>
541
     <td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
544
     <td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
542
     <td class="number_column"><?=number_format($TotalLeechers)?></td>
545
     <td class="number_column"><?=number_format($TotalLeechers)?></td>
543
   </tr>
546
   </tr>
544
-<?
547
+<?php
545
     foreach ($Torrents as $TorrentID => $Data) {
548
     foreach ($Torrents as $TorrentID => $Data) {
546
-      $Data['CategoryID'] = $CategoryID;
547
-      // All of the individual torrents in the group
548
-
549
-      //Get report info for each torrent, use the cache if available, if not, add to it.
550
-      $Reported = false;
551
-      $Reports = Torrents::get_reports($TorrentID);
552
-      if (count($Reports) > 0) {
553
-        $Reported = true;
554
-      }
555
-
556
-      $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
557
-      $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
558
-
559
-      if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
560
-        if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
561
-          $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
562
-          $Tor = new BencodeTorrent($TorrentFile, false, false);
563
-          $TorrentFileName = $Tor->Dec['info']['name'];
564
-          $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
549
+        $Data['CategoryID'] = $CategoryID;
550
+        // All of the individual torrents in the group
551
+
552
+        //Get report info for each torrent, use the cache if available, if not, add to it.
553
+        $Reported = false;
554
+        $Reports = Torrents::get_reports($TorrentID);
555
+        if (count($Reports) > 0) {
556
+            $Reported = true;
565
         }
557
         }
566
-        $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
567
-      }
568
 
558
 
569
-?>
559
+        $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
560
+        $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
561
+
562
+        if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
563
+            if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
564
+                $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
565
+                $Tor = new BencodeTorrent($TorrentFile, false, false);
566
+                $TorrentFileName = $Tor->Dec['info']['name'];
567
+                $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
568
+            }
569
+            $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;', '%26', $TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=", ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
570
+        } ?>
570
   <tr class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
571
   <tr class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
571
     <td colspan="3">
572
     <td colspan="3">
572
       <span>
573
       <span>
573
         [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
574
         [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
574
-<?      if (isset($TorrentMG)) { ?>
575
+<?php      if (isset($TorrentMG)) { ?>
575
         | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
576
         | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
576
-<?      }
577
+<?php      }
577
         if (Torrents::can_use_token($Data)) { ?>
578
         if (Torrents::can_use_token($Data)) { ?>
578
         | <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>
579
         | <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>
579
-<?      } ?>
580
+<?php      } ?>
580
         | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
581
         | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
581
       </span>
582
       </span>
582
-      &raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Data)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported tooltip" title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><? } ?></a>
583
+      &raquo; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Data)?><?php if ($Reported) { ?> / <strong class="torrent_label tl_reported tooltip" title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><?php } ?></a>
583
     </td>
584
     </td>
584
     <td class="number_column"><?=$Data['FileCount']?></td>
585
     <td class="number_column"><?=$Data['FileCount']?></td>
585
     <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
586
     <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
588
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
589
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
589
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
590
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
590
   </tr>
591
   </tr>
591
-<?
592
+<?php
592
     }
593
     }
593
-  } else {
594
-    // Viewing a type that does not require grouping
595
-
596
-    $TorrentID = key($Torrents);
597
-    $Data = current($Torrents);
598
-
599
-    $Reported = false;
600
-    $Reports = Torrents::get_reports($TorrentID);
601
-    if (count($Reports) > 0) {
602
-      $Reported = true;
603
-    }
604
-
605
-    $Data['CategoryID'] = $CategoryID;
606
-    $CoverArt = $GroupInfo['WikiImage'];
607
-    $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
608
-    if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
609
-      $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
610
-    }
611
-    $DisplayName .= "dir=\"ltr\">$GroupName</a>";
612
-    if (isset($GroupedCategories[$CategoryID - 1])) {
613
-      if ($GroupYear) {
614
-        $DisplayName .= " [$GroupYear]";
615
-      }
616
-      if ($GroupStudio) {
617
-        $DisplayName .= " [$GroupStudio]";
618
-      }
619
-      if ($GroupCatalogueNumber) {
620
-        $DisplayName .= " [$GroupCatalogueNumber]";
621
-      }
622
-      if ($GroupPages) {
623
-        $DisplayName .= " [{$GroupPages}p]";
624
-      }
625
-      if ($GroupDLsiteID) {
626
-        $DisplayName .= " [$GroupDLsiteID]";
627
-      }
628
-      $ExtraInfo = Torrents::torrent_info($Data, true, true);
629
-    } elseif ($Data['IsSnatched']) {
630
-      $ExtraInfo = Format::torrent_label('Snatched!');
631
-    } else {
632
-      $ExtraInfo = '';
633
-    }
634
-    $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
635
-    $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
636
-
637
-    if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
638
-      if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
639
-        $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
640
-        $Tor = new BencodeTorrent($TorrentFile, false, false);
641
-        $TorrentFileName = $Tor->Dec['info']['name'];
642
-        $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
643
-      }
644
-      $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
645
-    }
646
-?>
594
+      } else {
595
+          // Viewing a type that does not require grouping
596
+
597
+          $TorrentID = key($Torrents);
598
+          $Data = current($Torrents);
599
+
600
+          $Reported = false;
601
+          $Reports = Torrents::get_reports($TorrentID);
602
+          if (count($Reports) > 0) {
603
+              $Reported = true;
604
+          }
605
+
606
+          $Data['CategoryID'] = $CategoryID;
607
+          $CoverArt = $GroupInfo['WikiImage'];
608
+          $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
609
+          if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
610
+              $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
611
+          }
612
+          $DisplayName .= "dir=\"ltr\">$GroupName</a>";
613
+          if (isset($GroupedCategories[$CategoryID - 1])) {
614
+              if ($GroupYear) {
615
+                  $DisplayName .= " [$GroupYear]";
616
+              }
617
+              if ($GroupStudio) {
618
+                  $DisplayName .= " [$GroupStudio]";
619
+              }
620
+              if ($GroupCatalogueNumber) {
621
+                  $DisplayName .= " [$GroupCatalogueNumber]";
622
+              }
623
+              if ($GroupPages) {
624
+                  $DisplayName .= " [{$GroupPages}p]";
625
+              }
626
+              if ($GroupDLsiteID) {
627
+                  $DisplayName .= " [$GroupDLsiteID]";
628
+              }
629
+              $ExtraInfo = Torrents::torrent_info($Data, true, true);
630
+          } elseif ($Data['IsSnatched']) {
631
+              $ExtraInfo = Format::torrent_label('Snatched!');
632
+          } else {
633
+              $ExtraInfo = '';
634
+          }
635
+          $SnatchedTorrentClass = $Data['IsSnatched'] ? ' snatched_torrent' : '';
636
+          $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
637
+
638
+          if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
639
+              if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
640
+                  $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
641
+                  $Tor = new BencodeTorrent($TorrentFile, false, false);
642
+                  $TorrentFileName = $Tor->Dec['info']['name'];
643
+                  $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
644
+              }
645
+              $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$Data['info_hash']."&as=https://".SITE_DOMAIN."/".str_replace('&amp;', '%26', $TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=", ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Data['Size'];
646
+          } ?>
647
   <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
647
   <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
648
-<?    if ($GroupResults) { ?>
648
+<?php    if ($GroupResults) { ?>
649
     <td></td>
649
     <td></td>
650
-<?    } ?>
650
+<?php    } ?>
651
     <td class="center cats_col">
651
     <td class="center cats_col">
652
       <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>"></div>
652
       <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>"></div>
653
     </td>
653
     </td>
656
         <div class="float_right">
656
         <div class="float_right">
657
           <span>
657
           <span>
658
           [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
658
           [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
659
-<?    if (isset($TorrentMG)) { ?>
659
+<?php    if (isset($TorrentMG)) { ?>
660
           | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
660
           | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
661
-<?    }
662
-      if (Torrents::can_use_token($Data)) { ?>
661
+<?php    }
662
+          if (Torrents::can_use_token($Data)) { ?>
663
           | <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>
663
           | <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>
664
-<?    } ?>
664
+<?php    } ?>
665
           | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
665
           | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
666
           </span>
666
           </span>
667
           <br />
667
           <br />
668
-<?  if (in_array($GroupID, $Bookmarks)) { ?>
668
+<?php  if (in_array($GroupID, $Bookmarks)) { ?>
669
           <span class="remove_bookmark float_right">
669
           <span class="remove_bookmark float_right">
670
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
670
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
671
           </span>
671
           </span>
672
-<?  } else { ?>
672
+<?php  } else { ?>
673
           <span class="add_bookmark float_right">
673
           <span class="add_bookmark float_right">
674
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
674
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
675
           </span>
675
           </span>
676
-<?  } ?>
676
+<?php  } ?>
677
         </div>
677
         </div>
678
         <?=$DisplayName?>
678
         <?=$DisplayName?>
679
         <br />
679
         <br />
680
-        <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported tooltip" title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><? } ?></div>
680
+        <div style="display: inline;" class="torrent_info"><?=$ExtraInfo?><?php if ($Reported) { ?> / <strong class="torrent_label tl_reported tooltip" title="Type: <?=ucfirst($Reports[0]['Type'])?><br>Comment: <?=htmlentities(htmlentities($Reports[0]['UserComment']))?>">Reported</strong><?php } ?></div>
681
         <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
681
         <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
682
       </div>
682
       </div>
683
     </td>
683
     </td>
688
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
688
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
689
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
689
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
690
   </tr>
690
   </tr>
691
-<?
691
+<?php
692
+      }
692
   }
693
   }
693
-}
694
 ?>
694
 ?>
695
 </table>
695
 </table>
696
 <div class="linkbox"><?=$Pages?></div>
696
 <div class="linkbox"><?=$Pages?></div>
697
 </div>
697
 </div>
698
-<? View::show_footer(); ?>
698
+<?php View::show_footer(); ?>

+ 40
- 31
sections/wiki/search.php View File

1
 <?php
1
 <?php
2
 if (empty($_GET['nojump'])) {
2
 if (empty($_GET['nojump'])) {
3
-  $ArticleID = Wiki::alias_to_id($_GET['search']);
4
-  if ($ArticleID) {
5
-    //Found the article!
6
-    header('Location: wiki.php?action=article&id='.$ArticleID);
7
-    die();
8
-  }
3
+    $ArticleID = Wiki::alias_to_id($_GET['search']);
4
+    if ($ArticleID) {
5
+        // Found the article!
6
+        header('Location: wiki.php?action=article&id='.$ArticleID);
7
+        die();
8
+    }
9
 }
9
 }
10
 
10
 
11
 define('ARTICLES_PER_PAGE', 25);
11
 define('ARTICLES_PER_PAGE', 25);
17
 $OrderTable = array('Title'=>'Title', 'Created'=>'ID', 'Edited'=>'Date');
17
 $OrderTable = array('Title'=>'Title', 'Created'=>'ID', 'Edited'=>'Date');
18
 $WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC');
18
 $WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC');
19
 
19
 
20
-// What are we looking for? Let's make sure it isn't dangerous.
20
+// What are we looking for? Let's make sure it isn't dangerous
21
 $Search = db_string(trim($_GET['search']));
21
 $Search = db_string(trim($_GET['search']));
22
 
22
 
23
 if (!in_array($Type, array('Title', 'Body'))) {
23
 if (!in_array($Type, array('Title', 'Body'))) {
24
-  $Type = 'Title';
24
+    $Type = 'Title';
25
 }
25
 }
26
 
26
 
27
 // Break search string down into individual words
27
 // Break search string down into individual words
29
 
29
 
30
 $Type = $TypeTable[$_GET['type']];
30
 $Type = $TypeTable[$_GET['type']];
31
 if (!$Type) {
31
 if (!$Type) {
32
-  $Type = 'Title';
32
+    $Type = 'Title';
33
 }
33
 }
34
 
34
 
35
 $Order = $OrderTable[$_GET['order']];
35
 $Order = $OrderTable[$_GET['order']];
36
 if (!$Order) {
36
 if (!$Order) {
37
-  $Order = 'ID';
37
+    $Order = 'ID';
38
 }
38
 }
39
 
39
 
40
 $Way = $WayTable[$_GET['way']];
40
 $Way = $WayTable[$_GET['way']];
41
 if (!$Way) {
41
 if (!$Way) {
42
-  $Way = 'DESC';
42
+    $Way = 'DESC';
43
 }
43
 }
44
 
44
 
45
 $SQL = "
45
 $SQL = "
52
   FROM wiki_articles
52
   FROM wiki_articles
53
   WHERE MinClassRead <= '".$LoggedUser['EffectiveClass']."'";
53
   WHERE MinClassRead <= '".$LoggedUser['EffectiveClass']."'";
54
 if ($Search != '') {
54
 if ($Search != '') {
55
-  $SQL .= " AND $Type LIKE '%";
56
-  $SQL .= implode("%' AND $Type LIKE '%", $Words);
57
-  $SQL .= "%' ";
55
+    $SQL .= " AND $Type LIKE '%";
56
+    $SQL .= implode("%' AND $Type LIKE '%", $Words);
57
+    $SQL .= "%' ";
58
 }
58
 }
59
 
59
 
60
 $SQL .= "
60
 $SQL .= "
65
   SELECT FOUND_ROWS()");
65
   SELECT FOUND_ROWS()");
66
 list($NumResults) = $DB->next_record();
66
 list($NumResults) = $DB->next_record();
67
 
67
 
68
-View::show_header('Search articles');
68
+View::show_header('Search Articles');
69
 $DB->set_query_id($RS);
69
 $DB->set_query_id($RS);
70
 ?>
70
 ?>
71
+
71
 <div class="thin">
72
 <div class="thin">
72
   <div class="header">
73
   <div class="header">
73
     <h2>Search articles</h2>
74
     <h2>Search articles</h2>
83
       </div>
84
       </div>
84
       <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
85
       <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
85
         <tr>
86
         <tr>
86
-          <td class="label"><label for="search"><strong>Search for:</strong></label></td>
87
+          <td class="label"><label for="search"><strong>Search Terms</strong></label></td>
87
           <td colspan="3">
88
           <td colspan="3">
88
             <input type="search" name="search" id="search" size="70" value="<?=display_str($_GET['search'])?>" />
89
             <input type="search" name="search" id="search" size="70" value="<?=display_str($_GET['search'])?>" />
89
           </td>
90
           </td>
90
         </tr>
91
         </tr>
91
         <tr>
92
         <tr>
92
-          <td class="label"><strong>Search in:</strong></td>
93
+          <td class="label"><strong>Search In</strong></td>
93
           <td>
94
           <td>
94
-            <label><input type="radio" name="type" value="Title" <? if ($Type == 'Title') { echo 'checked="checked" '; } ?>/> Title</label>
95
-            <label><input type="radio" name="type" value="Body" <? if ($Type == 'Body') { echo 'checked="checked" '; } ?>/> Body</label>
95
+            <label><input type="radio" name="type" value="Title" <?php if ($Type == 'Title') {
96
+    echo 'checked="checked" ';
97
+} ?>/> Title</label>&nbsp;&nbsp;
98
+            <label><input type="radio" name="type" value="Body" <?php if ($Type == 'Body') {
99
+    echo 'checked="checked" ';
100
+} ?>/> Body</label>
96
           </td>
101
           </td>
97
-          <td class="label"><strong>Order by:</strong></td>
102
+          <td class="label"><strong>Order By</strong></td>
98
           <td>
103
           <td>
99
             <select name="order">
104
             <select name="order">
100
-<?          foreach ($OrderVals as $Cur) { ?>
101
-              <option value="<?=$Cur?>"<? if ($_GET['order'] == $Cur || (!$_GET['order'] && $Cur == 'Time')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
102
-<?          } ?>
105
+<?php          foreach ($OrderVals as $Cur) { ?>
106
+              <option value="<?=$Cur?>"<?php if ($_GET['order'] == $Cur || (!$_GET['order'] && $Cur == 'Time')) {
107
+    echo ' selected="selected"';
108
+} ?>><?=$Cur?></option>
109
+<?php          } ?>
103
             </select>
110
             </select>
104
             <select name="way">
111
             <select name="way">
105
-<?          foreach ($WayVals as $Cur) { ?>
106
-              <option value="<?=$Cur?>"<? if ($_GET['way'] == $Cur || (!$_GET['way'] && $Cur == 'Descending')) { echo ' selected="selected"'; } ?>><?=$Cur?></option>
107
-<?          } ?>
112
+<?php          foreach ($WayVals as $Cur) { ?>
113
+              <option value="<?=$Cur?>"<?php if ($_GET['way'] == $Cur || (!$_GET['way'] && $Cur == 'Descending')) {
114
+    echo ' selected="selected"';
115
+} ?>><?=$Cur?></option>
116
+<?php          } ?>
108
             </select>
117
             </select>
109
           </td>
118
           </td>
110
         </tr>
119
         </tr>
117
     </form>
126
     </form>
118
   </div>
127
   </div>
119
   <br />
128
   <br />
120
-<?
129
+<?php
121
   $Pages = Format::get_pages($Page, $NumResults, ARTICLES_PER_PAGE);
130
   $Pages = Format::get_pages($Page, $NumResults, ARTICLES_PER_PAGE);
122
   if ($Pages) { ?>
131
   if ($Pages) { ?>
123
   <div class="linkbox pager"><?=($Pages)?></div>
132
   <div class="linkbox pager"><?=($Pages)?></div>
124
-<?  } ?>
133
+<?php  } ?>
125
 <table width="100%">
134
 <table width="100%">
126
   <tr class="colhead">
135
   <tr class="colhead">
127
     <td>Article</td>
136
     <td>Article</td>
128
     <td>Last updated on</td>
137
     <td>Last updated on</td>
129
     <td>Last edited by</td>
138
     <td>Last edited by</td>
130
   </tr>
139
   </tr>
131
-<?  while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
140
+<?php  while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
132
   <tr>
141
   <tr>
133
     <td><a href="wiki.php?action=article&amp;id=<?=$ID?>"><?=$Title?></a></td>
142
     <td><a href="wiki.php?action=article&amp;id=<?=$ID?>"><?=$Title?></a></td>
134
     <td><?=$Date?></td>
143
     <td><?=$Date?></td>
135
     <td><?=Users::format_username($UserID, false, false, false)?></td>
144
     <td><?=Users::format_username($UserID, false, false, false)?></td>
136
   </tr>
145
   </tr>
137
-<?  } ?>
146
+<?php  } ?>
138
 </table>
147
 </table>
139
   <div class="linkbox"><?=$Pages?></div>
148
   <div class="linkbox"><?=$Pages?></div>
140
 </div>
149
 </div>
141
-<? View::show_footer(); ?>
150
+<?php View::show_footer(); ?>

BIN
static/common/bioicons/orcid.png View File


Loading…
Cancel
Save