Browse Source

Make minor search forms consistent

pjc 5 years ago
parent
commit
b4b896a630

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

@@ -1,48 +1,52 @@
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 8
       UPDATE collages
7 9
       SET Subscribers = Subscribers + 1
8 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 18
       UPDATE collages
16 19
       SET Subscribers = IF(Subscribers < 1, 0, Subscribers - 1)
17 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 27
       SELECT
24 28
         COUNT(ID)
25 29
       FROM collages
26 30
       WHERE UserID = '" . G::$LoggedUser['ID'] . "'
27 31
         AND CategoryID = '0'
28 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 44
       INSERT INTO collages
41 45
         (Name, Description, CategoryID, UserID)
42 46
       VALUES
43 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,7 +49,7 @@ class Comments {
49 49
    * @param int $PostID
50 50
    * @param string $NewBody
51 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 54
   public static function edit($PostID, $NewBody, $SendPM = false) {
55 55
     $QueryID = G::$DB->get_query_id();

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

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

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

@@ -20,7 +20,7 @@ if (!empty($_GET['type'])) {
20 20
 }
21 21
 
22 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 24
   $Search = db_string(trim($_GET['search']));
25 25
   // Break search string down into individual words
26 26
   $Words = explode(' ', $Search);
@@ -176,13 +176,13 @@ View::show_header(($BookmarkView) ? 'Your bookmarked collections' : 'Collections
176 176
       <div><input type="hidden" name="action" value="search" /></div>
177 177
       <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
178 178
         <tr id="search_terms">
179
-          <td class="label">Search terms:</td>
179
+          <td class="label">Search Terms</td>
180 180
           <td>
181 181
             <input type="search" name="search" size="70" value="<?=(!empty($_GET['search']) ? display_str($_GET['search']) : '')?>" />
182 182
           </td>
183 183
         </tr>
184 184
         <tr id="tagfilter">
185
-          <td class="label">Tags (comma-separated):</td>
185
+          <td class="label">Tags (comma-separated)</td>
186 186
           <td>
187 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 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,7 +190,7 @@ View::show_header(($BookmarkView) ? 'Your bookmarked collections' : 'Collections
190 190
           </td>
191 191
         </tr>
192 192
         <tr id="categories">
193
-          <td class="label">Categories:</td>
193
+          <td class="label">Categories</td>
194 194
           <td>
195 195
 <?    foreach ($CollageCats as $ID => $Cat) { ?>
196 196
             <input type="checkbox" value="1" name="cats[<?=$ID?>]" id="cats_<?=$ID?>"<? if (in_array($ID, $Categories)) { echo ' checked="checked"'; } ?> />
@@ -199,14 +199,14 @@ View::show_header(($BookmarkView) ? 'Your bookmarked collections' : 'Collections
199 199
           </td>
200 200
         </tr>
201 201
         <tr id="search_name_description">
202
-          <td class="label">Search in:</td>
202
+          <td class="label">Search In</td>
203 203
           <td>
204 204
             <input type="radio" name="type" value="c.name" <? if ($Type === 'c.name') { echo 'checked="checked" '; } ?>/> Names&nbsp;&nbsp;
205 205
             <input type="radio" name="type" value="description" <? if ($Type === 'description') { echo 'checked="checked" '; } ?>/> Descriptions
206 206
           </td>
207 207
         </tr>
208 208
         <tr id="order_by">
209
-          <td class="label">Order by:</td>
209
+          <td class="label">Order By</td>
210 210
           <td>
211 211
             <select name="order_by" class="ft_order_by">
212 212
 <?    foreach ($OrderVals as $Cur) { ?>

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

@@ -1,5 +1,7 @@
1
-<?
2
-//TODO: Clean up this fucking mess
1
+<?php
2
+
3
+// @todo Clean up this fucking mess
4
+
3 5
 /*
4 6
 Forums search result page
5 7
 */
@@ -7,86 +9,87 @@ Forums search result page
7 9
 list($Page, $Limit) = Format::page_limit(POSTS_PER_PAGE);
8 10
 
9 11
 if (isset($_GET['type']) && $_GET['type'] === 'body') {
10
-  $Type = 'body';
12
+    $Type = 'body';
11 13
 } else {
12
-  $Type = 'title';
14
+    $Type = 'title';
13 15
 }
14 16
 
15 17
 // What are we looking for? Let's make sure it isn't dangerous.
16 18
 if (isset($_GET['search'])) {
17
-  $Search = trim($_GET['search']);
19
+    $Search = trim($_GET['search']);
18 20
 } else {
19
-  $Search = '';
21
+    $Search = '';
20 22
 }
21 23
 
22 24
 $ThreadAfterDate = db_string($_GET['thread_created_after']);
23 25
 $ThreadBeforeDate = db_string($_GET['thread_created_before']);
24 26
 
25 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 31
 $PostAfterDate = db_string($_GET['post_created_after']);
30 32
 $PostBeforeDate = db_string($_GET['post_created_before']);
31 33
 
32 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 38
 // Searching for posts by a specific user
37 39
 if (!empty($_GET['user'])) {
38
-  $User = trim($_GET['user']);
39
-  $DB->query("
40
+    $User = trim($_GET['user']);
41
+    $DB->query("
40 42
     SELECT ID
41 43
     FROM users_main
42 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 51
 } else {
50
-  $User = '';
52
+    $User = '';
51 53
 }
52 54
 
53 55
 // Are we looking in individual forums?
54 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 68
 // Searching for posts in a specific thread
67 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 73
     SELECT
72 74
       Title
73 75
     FROM forums_topics AS t
74 76
       JOIN forums AS f ON f.ID = t.ForumID
75 77
     WHERE t.ID = $ThreadID
76 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 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 90
 View::show_header('Forums &gt; Search', 'bbcode,forum_search');
89 91
 ?>
92
+
90 93
 <div class="thin">
91 94
   <div class="header">
92 95
     <h2><a href="forums.php">Forums</a> &gt; Search<?=$Title?></h2>
@@ -95,39 +98,45 @@ View::show_header('Forums &gt; Search', 'bbcode,forum_search');
95 98
     <input type="hidden" name="action" value="search" />
96 99
     <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
97 100
       <tr>
98
-        <td><strong>Search for:</strong></td>
101
+        <td><strong>Search Terms</strong></td>
99 102
         <td>
100 103
           <input type="search" name="search" size="70" value="<?=display_str($Search)?>" />
101 104
         </td>
102 105
       </tr>
103 106
       <tr>
104
-        <td><strong>Posted by:</strong></td>
107
+        <td><strong>Posted By</strong></td>
105 108
         <td>
106 109
           <input type="search" name="user" placeholder="Username" size="70" value="<?=display_str($User)?>" />
107 110
         </td>
108 111
       </tr>
109 112
       <tr>
110
-        <td><strong>Topic created:</strong></td>
113
+        <td><strong>Topic Created</strong></td>
111 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 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 119
         </td>
117 120
       </tr>
118
-<?
121
+<?php
119 122
 if (empty($ThreadID)) {
120
-?>
123
+    ?>
121 124
       <tr>
122
-        <td><strong>Search in:</strong></td>
125
+        <td><strong>Search In</strong></td>
123 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 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 135
         </td>
129 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 140
         <td><strong>Post created:</strong></td>
132 141
         <td>
133 142
           After:
@@ -137,40 +146,37 @@ if (empty($ThreadID)) {
137 146
         </td>
138 147
       </tr>
139 148
       <tr>
140
-        <td><strong>Forums:</strong></td>
149
+        <td><strong>Forums</strong></td>
141 150
         <td>
142 151
     <table id="forum_search_cat_list" class="cat_list layout">
143 152
 
144 153
 
145
-<?
154
+<?php
146 155
   // List of forums
147 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 171
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
163
-<?
164
-        }
165
-
166
-?>
172
+<?php
173
+        } ?>
167 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 180
       <tr>
175 181
         <td colspan="5" class="forum_cat">
176 182
           <strong><?=$ForumCats[$Forum['CategoryID']]?></strong>
@@ -178,23 +184,28 @@ if (empty($ThreadID)) {
178 184
         </td>
179 185
       </tr>
180 186
       <tr>
181
-<?    } elseif ($Columns % 5 == 0) { ?>
187
+<?php
188
+        } elseif ($Columns % 5 == 0) { ?>
182 189
       </tr>
183 190
       <tr>
184
-<?    } ?>
191
+<?php    } ?>
185 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 196
           <label for="forum_<?=$Forum['ID']?>"><?=htmlspecialchars($Forum['Name'])?></label>
188 197
         </td>
189
-<?  }
190
-  if ($Columns % 5) { ?>
198
+<?php
199
+    }
200
+    if ($Columns % 5) { ?>
191 201
         <td colspan="<?=(5 - ($Columns % 5))?>"></td>
192
-<?  } ?>
202
+<?php  } ?>
193 203
       </tr>
194 204
     </table>
195
-<? } else { ?>
205
+<?php
206
+} else { ?>
196 207
             <input type="hidden" name="threadid" value="<?=$ThreadID?>" />
197
-<? } ?>
208
+<?php } ?>
198 209
           </td>
199 210
         </tr>
200 211
         <tr>
@@ -205,14 +216,13 @@ if (empty($ThreadID)) {
205 216
       </table>
206 217
     </form>
207 218
   <div class="linkbox">
208
-<?
219
+<?php
209 220
 
210 221
 // Break search string down into individual words
211 222
 $Words = explode(' ', db_string($Search));
212 223
 
213 224
 if ($Type == 'body') {
214
-
215
-  $SQL = "
225
+    $SQL = "
216 226
     SELECT
217 227
       SQL_CALC_FOUND_ROWS
218 228
       t.ID,
@@ -228,43 +238,42 @@ if ($Type == 'body') {
228 238
       JOIN forums AS f ON f.ID = t.ForumID
229 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 273
     ORDER BY p.AddedTime DESC
264 274
     LIMIT $Limit";
265
-
266 275
 } else {
267
-  $SQL = "
276
+    $SQL = "
268 277
     SELECT
269 278
       SQL_CALC_FOUND_ROWS
270 279
       t.ID,
@@ -278,22 +287,22 @@ if ($Type == 'body') {
278 287
     FROM forums_topics AS t
279 288
       JOIN forums AS f ON f.ID = t.ForumID
280 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 306
     ORDER BY t.LastPostTime DESC
298 307
     LIMIT $Limit";
299 308
 }
@@ -315,27 +324,28 @@ echo $Pages;
315 324
     <td>Topic creation time</td>
316 325
     <td>Last post time</td>
317 326
   </tr>
318
-<? if (!$DB->has_results()) { ?>
327
+<?php if (!$DB->has_results()) { ?>
319 328
     <tr><td colspan="4">Nothing found<?=((isset($AuthorID) && $AuthorID == 0) ? ' (unknown username)' : '')?>!</td></tr>
320
-<? }
329
+<?php }
321 330
 
322 331
 while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $ThreadCreatedTime) = $DB->next_record()) {
323
-  // Print results
324
-?>
332
+    // Print results?>
325 333
     <tr class="row">
326 334
       <td>
327 335
         <a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>"><?=$ForumName?></a>
328 336
       </td>
329 337
       <td>
330
-<?  if (empty($ThreadID)) { ?>
338
+<?php  if (empty($ThreadID)) { ?>
331 339
         <a href="forums.php?action=viewthread&amp;threadid=<?=$ID?>"><?=Format::cut_string($Title, 80); ?></a>
332
-<?  } else { ?>
340
+<?php  } else { ?>
333 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 349
       </td>
340 350
       <td>
341 351
         <?=time_diff($ThreadCreatedTime)?>
@@ -344,11 +354,11 @@ while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $Threa
344 354
         <?=time_diff($LastTime)?>
345 355
       </td>
346 356
     </tr>
347
-<?  if ($Type == 'body') { ?>
357
+<?php  if ($Type == 'body') { ?>
348 358
     <tr class="row hidden" id="post_<?=$PostID?>_text">
349 359
       <td colspan="4"><?=Text::full_format($Body)?></td>
350 360
     </tr>
351
-<?  }
361
+<?php  }
352 362
 }
353 363
 ?>
354 364
   </table>
@@ -357,4 +367,4 @@ while (list($ID, $Title, $ForumID, $ForumName, $LastTime, $PostID, $Body, $Threa
357 367
     <?=$Pages?>
358 368
   </div>
359 369
 </div>
360
-<? View::show_footer(); ?>
370
+<?php View::show_footer(); ?>

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

@@ -12,82 +12,82 @@ $SortOrders = [
12 12
 ];
13 13
 
14 14
 if (empty($_GET['order']) || !isset($SortOrders[$_GET['order']])) {
15
-  $_GET['order'] = 'created';
15
+    $_GET['order'] = 'created';
16 16
 }
17 17
 $OrderBy = $_GET['order'];
18 18
 
19 19
 if (!empty($_GET['sort']) && $_GET['sort'] === 'asc') {
20
-  $OrderWay = 'asc';
20
+    $OrderWay = 'asc';
21 21
 } else {
22
-  $_GET['sort'] = 'desc';
23
-  $OrderWay = 'desc';
22
+    $_GET['sort'] = 'desc';
23
+    $OrderWay = 'desc';
24 24
 }
25 25
 $NewSort = $_GET['sort'] === 'asc' ? 'desc' : 'asc';
26 26
 
27 27
 if ($OrderBy === 'random') {
28
-  $SphQL->order_by('RAND()', '');
29
-  unset($_GET['page']);
28
+    $SphQL->order_by('RAND()', '');
29
+    unset($_GET['page']);
30 30
 } else {
31
-  $SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
31
+    $SphQL->order_by($SortOrders[$OrderBy], $OrderWay);
32 32
 }
33 33
 
34 34
 $Submitted = !empty($_GET['submit']);
35 35
 
36
-//Paranoia
36
+// Paranoia
37 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 48
 $BookmarkView = false;
49 49
 
50 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 55
 } else {
56
-  switch ($_GET['type']) {
56
+    switch ($_GET['type']) {
57 57
     case 'created':
58 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 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 68
       break;
69 69
     case 'voted':
70 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 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 80
       break;
81 81
     case 'filled':
82 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 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 92
       break;
93 93
     case 'bookmarks':
@@ -101,287 +101,289 @@ if (empty($_GET['type'])) {
101 101
 }
102 102
 
103 103
 if ($Submitted && empty($_GET['show_filled'])) {
104
-  $SphQL->where('torrentid', 0);
104
+    $SphQL->where('torrentid', 0);
105 105
 }
106 106
 
107 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 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 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 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 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 197
 } else {
198
-  $TagType = 0;
199
-  $_GET['tags_type'] = '0';
198
+    $TagType = 0;
199
+    $_GET['tags_type'] = '0';
200 200
 }
201 201
 
202 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 224
 } elseif (!isset($_GET['tags_type']) || $_GET['tags_type'] !== '0') {
226
-  $_GET['tags_type'] = 1;
225
+    $_GET['tags_type'] = 1;
227 226
 } else {
228
-  $_GET['tags_type'] = 0;
227
+    $_GET['tags_type'] = 0;
229 228
 }
230 229
 
231 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 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 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 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 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 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 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 299
 $SphQLResult = $SphQL->query();
301 300
 $NumResults = (int)$SphQLResult->get_meta('total_found');
302 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 314
 $CurrentURL = Format::get_url(array('order', 'sort', 'page'));
316 315
 View::show_header($Title, 'requests');
317
-
318 316
 ?>
317
+
319 318
 <div class="thin">
320 319
   <div class="header">
321 320
     <h2><?=$Title?></h2>
322 321
   </div>
323 322
   <div class="linkbox">
324
-<?  if (!$BookmarkView) {
323
+<?php  if (!$BookmarkView) {
325 324
     if (check_perms('site_submit_requests')) { ?>
326 325
     <a href="requests.php?action=new" class="brackets">New request</a>
327 326
     <a href="requests.php?type=created" class="brackets">My requests</a>
328
-<?    }
327
+<?php    }
329 328
     if (check_perms('site_vote')) { ?>
330 329
     <a href="requests.php?type=voted" class="brackets">Requests I've voted on</a>
331
-<?    } ?>
330
+<?php    } ?>
332 331
     <a href="bookmarks.php?type=requests" class="brackets">Bookmarked requests</a>
333
-<?  } else { ?>
332
+<?php
333
+} else { ?>
334 334
     <a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
335 335
     <a href="bookmarks.php?type=artists" class="brackets">Artists</a>
336 336
     <a href="bookmarks.php?type=collages" class="brackets">Collections</a>
337 337
     <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
338
-<?  } ?>
338
+<?php  } ?>
339 339
   </div>
340
-<?  if ($BookmarkView && $NumResults === 0) { ?>
340
+<?php  if ($BookmarkView && $NumResults === 0) { ?>
341 341
   <div class="box pad" align="center">
342 342
     <h2>You have not bookmarked any requests.</h2>
343 343
   </div>
344
-<?  } else { ?>
344
+<?php  } else { ?>
345 345
   <form class="search_form" name="requests" action="" method="get">
346
-<?    if ($BookmarkView) { ?>
346
+<?php    if ($BookmarkView) { ?>
347 347
     <input type="hidden" name="action" value="view" />
348 348
     <input type="hidden" name="type" value="requests" />
349
-<?    } elseif (isset($_GET['type'])) { ?>
349
+<?php    } elseif (isset($_GET['type'])) { ?>
350 350
     <input type="hidden" name="type" value="<?=$_GET['type']?>" />
351
-<?    } ?>
351
+<?php    } ?>
352 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 354
     <input type="hidden" name="userid" value="<?=$_GET['userid']?>" />
355
-<?    } ?>
355
+<?php    } ?>
356 356
     <div class="box pad">
357 357
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
358 358
       <tr id="search_terms">
359
-        <td class="label"><!--Search terms:--></td>
359
+        <td class="label"><!--Search Terms--></td>
360 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 364
         </td>
363 365
       </tr>
364 366
       <tr id="tagfilter">
365
-        <td class="label"><!--Tags (comma-separated):--></td>
367
+        <td class="label"><!--Tags (comma-separated)--></td>
366 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 372
         </td>
371 373
       </tr>
372 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 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 378
         </td>
377 379
       </tr>
378 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 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 384
         </td>
383 385
       </tr>
384
-<?    /* ?>
386
+<?php    /* ?>
385 387
       <tr>
386 388
         <td class="label">Requested by:</td>
387 389
         <td>
@@ -391,40 +393,41 @@ View::show_header($Title, 'requests');
391 393
 <?    */ ?>
392 394
     </table>
393 395
     <table class="layout cat_list">
394
-<?
396
+<?php
395 397
     $x = 1;
396 398
     reset($Categories);
397 399
     foreach ($Categories as $CatKey => $CatName) {
398
-      if ($x % 8 === 0 || $x === 1) {
399
-?>
400
+        if ($x % 8 === 0 || $x === 1) {
401
+            ?>
400 402
         <tr>
401
-<?      } ?>
403
+<?php
404
+        } ?>
402 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 407
             <label for="cat_<?=($CatKey + 1) ?>"><?=$CatName?></label>
405 408
           </td>
406
-<?      if ($x % 7 === 0) { ?>
409
+<?php      if ($x % 7 === 0) { ?>
407 410
         </tr>
408
-<?
411
+<?php
409 412
       }
410
-      $x++;
413
+        $x++;
411 414
     }
412 415
 ?>
413 416
     </table>
414 417
     <table class="layout">
415 418
       <tr>
416 419
         <td colspan="2" class="center">
417
-          <input type="submit" value="Search requests" />
420
+          <input type="submit" value="Search" />
418 421
         </td>
419 422
       </tr>
420 423
     </table>
421 424
     </div>
422 425
   </form>
423
-<?    if (isset($PageLinks)) { ?>
426
+<?php    if (isset($PageLinks)) { ?>
424 427
   <div class="linkbox">
425 428
     <?= $PageLinks?>
426 429
   </div>
427
-<?    } ?>
430
+<?php    } ?>
428 431
   <table id="request_table" class="request_table border" cellpadding="6" cellspacing="1" border="0" width="100%">
429 432
     <tr class="colhead_dark">
430 433
       <td class="small cats_col"></td>
@@ -453,68 +456,67 @@ View::show_header($Title, 'requests');
453 456
         <a href="?order=lastvote&amp;sort=<?=($OrderBy === 'lastvote' ? $NewSort : 'desc')?>&amp;<?=$CurrentURL?>"><strong>Last vote</strong></a>
454 457
       </td>
455 458
     </tr>
456
-<?
459
+<?php
457 460
     if ($NumResults === 0) {
458
-      // not viewing bookmarks but no requests found
461
+        // not viewing bookmarks but no requests found
459 462
 ?>
460 463
     <tr class="row">
461 464
       <td colspan="8">
462 465
         Nothing found!
463 466
       </td>
464 467
     </tr>
465
-<?    } elseif ($Page === 0) { ?>
468
+<?php
469
+    } elseif ($Page === 0) { ?>
466 470
     <tr class="row">
467 471
       <td colspan="8">
468 472
         The requested page contains no matches!
469 473
       </td>
470 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 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 520
     <tr class="request">
519 521
       <td class="center cats_col">
520 522
         <div title="<?=Format::pretty_category($Request['CategoryID'])?>" class="tooltip <?=Format::css_category($Request['CategoryID'])?>"></div>
@@ -522,43 +524,42 @@ View::show_header($Title, 'requests');
522 524
       <td>
523 525
         <?=$FullName?>
524 526
         <div class="tags">
525
-<?
527
+<?php
526 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 534
           <?=$TagList?>
534 535
         </div>
535 536
       </td>
536 537
       <td class="nobr">
537 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 540
         &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets"><strong>+</strong></a>
540
-<?    } ?>
541
+<?php    } ?>
541 542
       </td>
542 543
       <td class="number_column nobr">
543 544
         <?=Format::get_size($Bounty)?>
544 545
       </td>
545 546
       <td class="nobr">
546
-<?    if ($IsFilled) { ?>
547
+<?php    if ($IsFilled) { ?>
547 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 550
         <strong>No</strong>
550
-<?    } ?>
551
+<?php    } ?>
551 552
       </td>
552 553
       <td>
553
-<?    if ($IsFilled) {
554
-        if ($Request['AnonymousFill']) { ?>
554
+<?php    if ($IsFilled) {
555
+                if ($Request['AnonymousFill']) { ?>
555 556
           <em>Anonymous</em>
556
-<?      } else { ?>
557
+<?php      } else { ?>
557 558
           <a href="user.php?id=<?=$FillerInfo['ID']?>"><?=$FillerInfo['Username']?></a>
558
-<?      }
559
-      } else { ?>
559
+<?php      }
560
+            } else { ?>
560 561
         &mdash;
561
-<?    } ?>
562
+<?php    } ?>
562 563
       </td>
563 564
       <td>
564 565
         <a href="user.php?id=<?=$Request['UserID']?>"><?=Users::format_username($Request['UserID'], false, false, false)?></a>
@@ -570,16 +571,16 @@ View::show_header($Title, 'requests');
570 571
         <?=time_diff($Request['LastVote'], 1)?>
571 572
       </td>
572 573
     </tr>
573
-<?
574
-  } // foreach
574
+<?php
575
+        } // foreach
575 576
     } // else
576 577
   } // if ($BookmarkView && $NumResults < 1)
577 578
 ?>
578 579
   </table>
579
-<? if (isset($PageLinks)) { ?>
580
+<?php if (isset($PageLinks)) { ?>
580 581
   <div class="linkbox">
581 582
     <?=$PageLinks?>
582 583
   </div>
583
-<? } ?>
584
+<?php } ?>
584 585
 </div>
585
-<? View::show_footer(); ?>
586
+<?php View::show_footer(); ?>

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

@@ -1,153 +1,157 @@
1
-<?
1
+<?php
2 2
 $Where = [];
3 3
 
4 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 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 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 47
 $Filtered = !empty($Where);
49 48
 View::show_header("Top $Limit Torrents", 'browse');
50 49
 ?>
50
+
51 51
 <div class="thin">
52 52
   <div class="header">
53 53
     <h2>Top <?=$Limit?> Torrents</h2>
54
-    <? Top10View::render_linkbox("torrents"); ?>
54
+    <?php Top10View::render_linkbox("torrents"); ?>
55 55
   </div>
56
-<?
56
+<?php
57 57
 
58 58
 if (check_perms('site_advanced_top10')) {
59
-?>
59
+    ?>
60 60
   <div class="box pad">
61 61
   <form class="search_form" name="torrents" action="" method="get">
62 62
     <input type="hidden" name="advanced" value="1" />
63 63
     <table cellpadding="6" cellspacing="1" border="0" class="layout" width="100%">
64 64
       <tr id="tagfilter">
65
-        <td class="label">Tags (comma-separated):</td>
65
+        <td class="label">Tags (comma-separated)</td>
66 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 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 71
           <input type="radio" id="rdoAny" name="anyall" value="any"<?=((!isset($_GET['anyall'])||$_GET['anyall']=='any')?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
70 72
         </td>
71 73
       </tr>
72 74
       <tr>
73
-        <td class="label">Category:</td>
75
+        <td class="label">Category</td>
74 76
         <td>
75 77
           <select name="category" style="width: auto;" class="ft_format">
76 78
             <option value="">Any</option>
77
-<?  foreach ($Categories as $CategoryName) { ?>
79
+<?php  foreach ($Categories as $CategoryName) { ?>
78 80
             <option value="<?=display_str($CategoryName)?>"<?=(($CategoryName==($_GET['category']??false))?'selected="selected"':'')?>><?=display_str($CategoryName)?></option>
79
-<?  } ?>
81
+<?php  } ?>
80 82
           </select>
81 83
         </td>
82 84
       </tr>
83 85
       <tr>
84 86
         <td colspan="2" class="center">
85
-          <input type="submit" value="Filter torrents" />
87
+          <input type="submit" value="Search" />
86 88
         </td>
87 89
       </tr>
88 90
     </table>
89 91
   </form>
90 92
   </div>
91
-<?
93
+<?php
92 94
 }
93 95
 
94
-// default setting to have them shown
96
+// Default setting to have them shown
95 97
 $DisableFreeTorrentTop10 = (isset($LoggedUser['DisableFreeTorrentTop10']) ? $LoggedUser['DisableFreeTorrentTop10'] : 0);
96
-// did they just toggle it?
98
+// Did they just toggle it?
97 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 110
 // Modify the Where query
109 111
 if ($DisableFreeTorrentTop10) {
110
-  $Where[] = "t.FreeTorrent='0'";
112
+    $Where[] = "t.FreeTorrent='0'";
111 113
 }
112 114
 
113 115
 // The link should say the opposite of the current setting
114 116
 $FreeleechToggleName = ($DisableFreeTorrentTop10 ? 'show' : 'hide');
115 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 123
 $FreeleechToggleQuery .= 'freeleech=' . $FreeleechToggleName;
121 124
 
122 125
 $GroupByToggleName = ((isset($_GET['groups']) && $_GET['groups'] == 'show') ? 'hide' : 'show');
123 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 132
 $GroupByToggleQuery .= 'groups=' . $GroupByToggleName;
129 133
 
130 134
 $GroupBySum = '';
131 135
 $GroupBy = '';
132 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 142
   <div style="text-align: right;" class="linkbox">
139 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 145
       <a href="top10.php?<?=$GroupByToggleQuery?>" class="brackets"><?=ucfirst($GroupByToggleName)?> top groups</a>
142
-<?    } ?>
146
+<?php    } ?>
143 147
   </div>
144
-<?
148
+<?php
145 149
 
146 150
 if (!empty($Where)) {
147
-  $Where = '('.implode(' AND ', $Where).')';
148
-  $WhereSum = md5($Where);
151
+    $Where = '('.implode(' AND ', $Where).')';
152
+    $WhereSum = md5($Where);
149 153
 } else {
150
-  $WhereSum = '';
154
+    $WhereSum = '';
151 155
 }
152 156
 $BaseQuery = '
153 157
   SELECT
@@ -170,241 +174,241 @@ $BaseQuery = '
170 174
     LEFT JOIN torrents_group AS g ON g.ID = t.GroupID';
171 175
 
172 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 186
         t.Time>'$DayAgo'
183 187
         $GroupBy
184 188
         ORDER BY (t.Seeders + t.Leechers) DESC
185 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 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 210
         t.Time>'$WeekAgo'
207 211
         $GroupBy
208 212
         ORDER BY (t.Seeders + t.Leechers) DESC
209 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 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 234
         t.Time > NOW() - INTERVAL 1 MONTH
231 235
         $GroupBy
232 236
         ORDER BY (t.Seeders + t.Leechers) DESC
233 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 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 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 264
         t.Time > NOW() - INTERVAL 1 YEAR
261 265
         $GroupBy
262 266
         ORDER BY (t.Seeders + t.Leechers) DESC
263 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 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 294
         $GroupBy
291 295
         ORDER BY (t.Seeders + t.Leechers) DESC
292 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 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 317
         $GroupBy
314 318
         ORDER BY t.Snatched DESC
315 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 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 344
         $GroupBy
341 345
         ORDER BY Data DESC
342 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 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 367
         $GroupBy
364 368
         ORDER BY t.Seeders DESC
365 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 382
 </div>
379
-<?
383
+<?php
380 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 390
     <h3>Top <?="$Limit $Caption"?>
387
-<?  if (empty($_GET['advanced'])) { ?>
391
+<?php  if (empty($_GET['advanced'])) { ?>
388 392
     <small class="top10_quantity_links">
389
-<?
393
+<?php
390 394
     switch ($Limit) {
391 395
       case 100: ?>
392 396
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
393 397
         - <span class="brackets">Top 100</span>
394 398
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
395
-<?        break;
399
+<?php        break;
396 400
       case 250: ?>
397 401
         - <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
398 402
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
399 403
         - <span class="brackets">Top 250</span>
400
-<?        break;
404
+<?php        break;
401 405
       default: ?>
402 406
         - <span class="brackets">Top 10</span>
403 407
         - <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
404 408
         - <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
405
-<?    } ?>
409
+<?php    } ?>
406 410
     </small>
407
-<?  } ?>
411
+<?php  } ?>
408 412
     </h3>
409 413
   <table class="torrent_table cats numbering border">
410 414
   <tr class="colhead">
@@ -418,96 +422,95 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
418 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 423
     <td style="text-align: right;">Peers</td>
420 424
   </tr>
421
-<?
425
+<?php
422 426
   // Server is already processing a top10 query. Starting another one will make things slow
423 427
   if ($Details === false) {
424
-?>
428
+      ?>
425 429
     <tr class="row">
426 430
       <td colspan="9" class="center">
427 431
         Server is busy processing another top list request. Please try again in a minute.
428 432
       </td>
429 433
     </tr>
430 434
     </table><br />
431
-<?
435
+<?php
432 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 441
     <tr class="row">
438 442
       <td colspan="9" class="center">
439 443
         Found no torrents matching the criteria.
440 444
       </td>
441 445
     </tr>
442 446
     </table><br />
443
-<?
447
+<?php
444 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 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 514
   <tr class="torrent row<?=($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '')?>">
512 515
     <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
513 516
     <td class="center cats_col"><div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div></td>
@@ -516,18 +519,19 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
516 519
 
517 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 524
     if ($IsBookmarked) {
522
-?>
525
+        ?>
523 526
         <span class="remove_bookmark float_right">
524 527
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
525 528
         </span>
526
-<?    } else { ?>
529
+<?php
530
+    } else { ?>
527 531
         <span class="add_bookmark float_right">
528 532
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
529 533
         </span>
530
-<?    } ?>
534
+<?php    } ?>
531 535
         <div class="tags"><?=$TorrentTags->format()?></div>
532 536
       </div>
533 537
     </td>
@@ -538,10 +542,10 @@ function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
538 542
     <td class="number_column"><?=number_format((double)$Leechers)?></td>
539 543
     <td class="number_column"><?=number_format($Seeders + $Leechers)?></td>
540 544
   </tr>
541
-<?
542
-  } //foreach ($Details as $Detail)
545
+<?php
546
+    } // foreach ($Details as $Detail)
543 547
 ?>
544 548
   </table><br />
545
-<?
549
+<?php
546 550
 }
547 551
 ?>

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

@@ -1,122 +1,125 @@
1
-<?
1
+<?php
2
+
3
+# @todo Go through line by line
4
+
2 5
 include(SERVER_ROOT.'/sections/torrents/functions.php');
3 6
 
4 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 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 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 34
       SELECT ID, GroupID
32 35
       FROM torrents
33 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 45
 // Setting default search options
43 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 51
     SELECT SiteOptions
49 52
     FROM users_info
50 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 58
     UPDATE users_info
56 59
     SET SiteOptions = ?
57 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 65
 // Clearing default search options
63 66
 } elseif (!empty($_GET['cleardefault'])) {
64
-  $DB->query("
67
+    $DB->query("
65 68
     SELECT SiteOptions
66 69
     FROM users_info
67 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 75
     UPDATE users_info
73 76
     SET SiteOptions = ?
74 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 82
 // Use default search options
80 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 94
 // Terms were not submitted via the search form
92 95
 if (isset($_GET['searchsubmit'])) {
93
-  $GroupResults = !empty($_GET['group_results']);
96
+    $GroupResults = !empty($_GET['group_results']);
94 97
 } else {
95
-  $GroupResults = !$LoggedUser['DisableGrouping2'];
98
+    $GroupResults = !$LoggedUser['DisableGrouping2'];
96 99
 }
97 100
 
98 101
 if (!empty($_GET['order_way']) && $_GET['order_way'] == 'asc') {
99
-  $OrderWay = 'asc';
102
+    $OrderWay = 'asc';
100 103
 } else {
101
-  $OrderWay = 'desc';
104
+    $OrderWay = 'desc';
102 105
 }
103 106
 
104 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 109
 } else {
107
-  $OrderBy = $_GET['order_by'];
110
+    $OrderBy = $_GET['order_by'];
108 111
 }
109 112
 
110 113
 $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
111 114
 $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
112 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 118
 if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] == 1) {
116
-  $Search->insert_hidden_tags('!scat');
119
+    $Search->insert_hidden_tags('!scat');
117 120
 }
118 121
 if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] == 1) {
119
-  $Search->insert_hidden_tags('!snuff');
122
+    $Search->insert_hidden_tags('!snuff');
120 123
 }
121 124
 $Results = $Search->query($_GET);
122 125
 $Groups = $Search->get_groups();
@@ -128,13 +131,13 @@ $AdvancedSearch = !empty($_GET['action']) && $_GET['action'] == 'advanced';
128 131
 $AdvancedSearch |= !empty($LoggedUser['SearchType']) && (empty($_GET['action']) || $_GET['action'] == 'advanced');
129 132
 $AdvancedSearch &= check_perms('site_advanced_search');
130 133
 if ($AdvancedSearch) {
131
-  $Action = 'action=advanced';
132
-  $HideBasic = ' hidden';
133
-  $HideAdvanced = '';
134
+    $Action = 'action=advanced';
135
+    $HideBasic = ' hidden';
136
+    $HideAdvanced = '';
134 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 143
 View::show_header('Browse Torrents', 'browse');
@@ -156,12 +159,12 @@ View::show_header('Browse Torrents', 'browse');
156 159
       </span>
157 160
     </div>
158 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 163
    || (isset($LoggedUser['HideScat'])    && $LoggedUser['HideScat']    == 1)
161 164
    || (isset($LoggedUser['HideSnuff'])   && $LoggedUser['HideSnuff']   == 1)
162 165
    ) { ?>
163 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 168
       <table class="layout">
166 169
         <tr id="artist_name" class="ftr_advanced<?=$HideAdvanced?>">
167 170
           <td class="label"><!--Artist name:--></td>
@@ -196,35 +199,36 @@ View::show_header('Browse Torrents', 'browse');
196 199
         <tr id="torrent_description" class="ftr_advanced<?=$HideAdvanced?>">
197 200
           <td class="label"><!--<span title="Search torrent descriptions (not group information)" class="tooltip">Torrent description:</span>--></td>
198 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 204
           </td>
201 205
         </tr>
202 206
         <tr id="rip_specifics" class="ftr_advanced<?=$HideAdvanced?>">
203
-          <td class="label">Release Specifics</td>
207
+          <td class="label">Specifics</td>
204 208
           <td class="nobr ft_ripspecifics">
205 209
             <select id="container" name="container" class="ft_container fti_advanced">
206 210
               <option value="">Format</option>
207
-  <?  foreach ($Containers as $Container) { ?>
211
+  <?php  foreach ($Containers as $Container) { ?>
208 212
               <option value="<?=display_str($Container);?>" <?Format::selected('container', $Container)?>><?=display_str($Container);?></option>
209
-  <?  } ?>
213
+  <?php  } ?>
210 214
             </select>
211 215
             <select name="codec" class="ft_codec fti_advanced">
212 216
               <option value="">License</option>
213
-  <?  foreach ($Codecs as $Codec) { ?>
217
+  <?php  foreach ($Codecs as $Codec) { ?>
214 218
               <option value="<?=display_str($Codec); ?>"<?Format::selected('codec', $Codec)?>><?=display_str($Codec); ?></option>
215
-  <?  } ?>
219
+  <?php  } ?>
216 220
             </select>
217 221
             <select name="media" class="ft_media fti_advanced">
218 222
               <option value="">Platform</option>
219
-  <?  foreach ($Media as $MediaName) { ?>
223
+  <?php  foreach ($Media as $MediaName) { ?>
220 224
               <option value="<?=display_str($MediaName); ?>"<?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?></option>
221
-  <?  } ?>
225
+  <?php  } ?>
222 226
             </select>
223 227
             <select name="resolution" class="ft_resolution fti_advanced">
224 228
               <option value="">Assembly Level</option>
225
-  <?  foreach ($Resolutions as $Resolution) { ?>
229
+  <?php  foreach ($Resolutions as $Resolution) { ?>
226 230
               <option value="<?=display_str($Resolution); ?>"<?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?></option>
227
-  <?  } ?>
231
+  <?php  } ?>
228 232
             </select>
229 233
           </td>
230 234
         </tr>
@@ -254,7 +258,7 @@ View::show_header('Browse Torrents', 'browse');
254 258
               <option value="0"<?Format::selected('freetorrent', 0)?>>Normal</option>
255 259
             </select>
256 260
             <select name="censored" class="ft_censored fti_advanced">
257
-              <option value="">Aligned Sequence?</option>
261
+              <option value="">Alignment</option>
258 262
               <option value="1"<?Format::selected('censored', 1)?>>Aligned</option>
259 263
               <option value="0"<?Format::selected('censored', 0)?>>Unaligned</option>
260 264
             </select>
@@ -269,9 +273,10 @@ View::show_header('Browse Torrents', 'browse');
269 273
         <tr id="tagfilter">
270 274
           <td class="label"><!--<span title="Use !tag to exclude tag" class="tooltip">Tags (comma-separated):</span>--></td>
271 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 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 280
           </td>
276 281
         </tr>
277 282
         <tr id="order">
@@ -295,7 +300,7 @@ View::show_header('Browse Torrents', 'browse');
295 300
         </tr>
296 301
         <tr id="search_group_results">
297 302
           <td class="label">
298
-            <label for="group_results">Group by Release?</label>
303
+            <label for="group_results">Group Torrents</label>
299 304
           </td>
300 305
           <td class="ft_group_results">
301 306
             <input type="checkbox" value="1" name="group_results" id="group_results"<?=$GroupResults ? ' checked="checked"' : ''?> />
@@ -303,60 +308,60 @@ View::show_header('Browse Torrents', 'browse');
303 308
         </tr>
304 309
       </table>
305 310
       <table class="layout cat_list ft_cat_list">
306
-  <?
311
+  <?php
307 312
   $x = 0;
308 313
   reset($Categories);
309 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 318
         </tr>
314
-  <?    } ?>
319
+  <?php
320
+          } ?>
315 321
         <tr>
316
-  <?
317
-    }
318
-    $x++;
319
-  ?>
322
+  <?php
323
+      }
324
+      $x++; ?>
320 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 327
             <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
323 328
           </td>
324
-  <?
329
+  <?php
325 330
   }
326 331
   ?>
327 332
         </tr>
328 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 335
         <tr>
331
-  <?
336
+  <?php
332 337
   $GenreTags = $Cache->get_value('genre_tags');
333 338
   if (!$GenreTags) {
334
-    $DB->query('
339
+      $DB->query('
335 340
       SELECT Name
336 341
       FROM tags
337 342
       WHERE TagType = \'genre\'
338 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 348
   $x = 0;
344 349
   foreach ($GenreTags as $Tag) {
345
-  ?>
350
+      ?>
346 351
           <td><a href="#" onclick="add_tag('<?=$Tag?>'); return false;"><?=$Tag?></a></td>
347
-  <?
352
+  <?php
348 353
     $x++;
349
-    if ($x % 7 == 0) {
350
-  ?>
354
+      if ($x % 7 == 0) {
355
+          ?>
351 356
         </tr>
352 357
         <tr>
353
-  <?
354
-    }
358
+  <?php
359
+      }
355 360
   }
356 361
   if ($x % 7 != 0) { // Padding
357 362
   ?>
358 363
           <td colspan="<?=(7 - ($x % 7))?>"> </td>
359
-  <? } ?>
364
+  <?php } ?>
360 365
         </tr>
361 366
       </table>
362 367
       <table class="layout cat_list">
@@ -368,43 +373,43 @@ View::show_header('Browse Torrents', 'browse');
368 373
       </table>
369 374
       <div class="submit ft_submit">
370 375
         <span class="float_left"><?=number_format($NumResults)?> Results</span>
371
-        <input type="submit" value="Filter torrents" />
376
+        <input type="submit" value="Search" />
372 377
         <input type="hidden" name="action" id="ft_type" value="<?=($AdvancedSearch ? 'advanced' : 'basic')?>" />
373 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 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 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 388
       </div>
384 389
     </div>
385 390
   </div>
386 391
   </form>
387
-<? if ($NumResults == 0) { ?>
392
+<?php if ($NumResults == 0) { ?>
388 393
   <div class="torrents_nomatch box pad" align="center">
389 394
     <h2>Your search did not match anything.</h2>
390 395
     <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
391 396
   </div>
392 397
   </div>
393
-<?    View::show_footer();die();
398
+<?php    View::show_footer();die();
394 399
   }
395 400
 
396 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 404
   <div class="torrents_nomatch box pad" align="center">
401 405
     <h2>The requested page contains no matches.</h2>
402 406
     <p>You are requesting page <?=$Page?>, but the search returned only <?=number_format($LastPage) ?> pages.</p>
403 407
   </div>
404 408
   <div class="linkbox">Go to page <?=$Pages?></div>
405 409
   </div>
406
-<?
407
-    View::show_footer();die();
410
+<?php
411
+    View::show_footer();
412
+      die();
408 413
   }
409 414
 
410 415
   // List of pages
@@ -417,9 +422,9 @@ View::show_header('Browse Torrents', 'browse');
417 422
 
418 423
   <table class="box torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>" id="torrent_table">
419 424
     <tr class="colhead">
420
-  <?  if ($GroupResults) { ?>
425
+  <?php  if ($GroupResults) { ?>
421 426
       <td class="small"></td>
422
-  <?  } ?>
427
+  <?php  } ?>
423 428
       <td class="small cats_col"></td>
424 429
       <td>Name / <a href="<?=header_link('year')?>">Year</a></td>
425 430
       <td>Files</td>
@@ -441,75 +446,73 @@ View::show_header('Browse Torrents', 'browse');
441 446
         </a>
442 447
       </td>
443 448
     </tr>
444
-  <?
449
+  <?php
445 450
 
446 451
   // Start printing torrent list
447 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 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 516
     <td class="center">
514 517
       <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
515 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,15 +525,15 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
522 525
     <td colspan="2" class="big_info">
523 526
       <div class="group_info clear">
524 527
       <?=$DisplayName?>
525
-<?  if (in_array($GroupID, $Bookmarks)) { ?>
528
+<?php  if (in_array($GroupID, $Bookmarks)) { ?>
526 529
         <span class="remove_bookmark float_right">
527 530
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
528 531
         </span>
529
-<?  } else { ?>
532
+<?php  } else { ?>
530 533
         <span class="add_bookmark float_right">
531 534
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
532 535
         </span>
533
-<?  } ?>
536
+<?php  } ?>
534 537
         <br />
535 538
         <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?></div>
536 539
       </div>
@@ -541,45 +544,43 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
541 544
     <td class="number_column<?=($TotalSeeders == 0 ? ' r00' : '')?>"><?=number_format($TotalSeeders)?></td>
542 545
     <td class="number_column"><?=number_format($TotalLeechers)?></td>
543 546
   </tr>
544
-<?
547
+<?php
545 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 571
   <tr class="group_torrent groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1 ? ' hidden' : '')?>">
571 572
     <td colspan="3">
572 573
       <span>
573 574
         [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
574
-<?      if (isset($TorrentMG)) { ?>
575
+<?php      if (isset($TorrentMG)) { ?>
575 576
         | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
576
-<?      }
577
+<?php      }
577 578
         if (Torrents::can_use_token($Data)) { ?>
578 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 581
         | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
581 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 584
     </td>
584 585
     <td class="number_column"><?=$Data['FileCount']?></td>
585 586
     <td class="nobr"><?=time_diff($Data['Time'], 1)?></td>
@@ -588,66 +589,65 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
588 589
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
589 590
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
590 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 647
   <tr class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
648
-<?    if ($GroupResults) { ?>
648
+<?php    if ($GroupResults) { ?>
649 649
     <td></td>
650
-<?    } ?>
650
+<?php    } ?>
651 651
     <td class="center cats_col">
652 652
       <div title="<?=Format::pretty_category($CategoryID)?>" class="tooltip <?=Format::css_category($CategoryID)?>"></div>
653 653
     </td>
@@ -656,28 +656,28 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
656 656
         <div class="float_right">
657 657
           <span>
658 658
           [ <a href="<?=$TorrentDL?>" class="tooltip" title="Download">DL</a>
659
-<?    if (isset($TorrentMG)) { ?>
659
+<?php    if (isset($TorrentMG)) { ?>
660 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 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 665
           | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
666 666
           </span>
667 667
           <br />
668
-<?  if (in_array($GroupID, $Bookmarks)) { ?>
668
+<?php  if (in_array($GroupID, $Bookmarks)) { ?>
669 669
           <span class="remove_bookmark float_right">
670 670
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
671 671
           </span>
672
-<?  } else { ?>
672
+<?php  } else { ?>
673 673
           <span class="add_bookmark float_right">
674 674
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
675 675
           </span>
676
-<?  } ?>
676
+<?php  } ?>
677 677
         </div>
678 678
         <?=$DisplayName?>
679 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 681
         <div class="tags"><?=$TorrentTags->format("torrents.php?$Action&amp;taglist=")?></div>
682 682
       </div>
683 683
     </td>
@@ -688,11 +688,11 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
688 688
     <td class="number_column<?=($Data['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Data['Seeders'])?></td>
689 689
     <td class="number_column"><?=number_format($Data['Leechers'])?></td>
690 690
   </tr>
691
-<?
691
+<?php
692
+      }
692 693
   }
693
-}
694 694
 ?>
695 695
 </table>
696 696
 <div class="linkbox"><?=$Pages?></div>
697 697
 </div>
698
-<? View::show_footer(); ?>
698
+<?php View::show_footer(); ?>

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

@@ -1,11 +1,11 @@
1 1
 <?php
2 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 11
 define('ARTICLES_PER_PAGE', 25);
@@ -17,11 +17,11 @@ $TypeTable = array('Title'=>'Title', 'Body'=>'Body');
17 17
 $OrderTable = array('Title'=>'Title', 'Created'=>'ID', 'Edited'=>'Date');
18 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 21
 $Search = db_string(trim($_GET['search']));
22 22
 
23 23
 if (!in_array($Type, array('Title', 'Body'))) {
24
-  $Type = 'Title';
24
+    $Type = 'Title';
25 25
 }
26 26
 
27 27
 // Break search string down into individual words
@@ -29,17 +29,17 @@ $Words = explode(' ', $Search);
29 29
 
30 30
 $Type = $TypeTable[$_GET['type']];
31 31
 if (!$Type) {
32
-  $Type = 'Title';
32
+    $Type = 'Title';
33 33
 }
34 34
 
35 35
 $Order = $OrderTable[$_GET['order']];
36 36
 if (!$Order) {
37
-  $Order = 'ID';
37
+    $Order = 'ID';
38 38
 }
39 39
 
40 40
 $Way = $WayTable[$_GET['way']];
41 41
 if (!$Way) {
42
-  $Way = 'DESC';
42
+    $Way = 'DESC';
43 43
 }
44 44
 
45 45
 $SQL = "
@@ -52,9 +52,9 @@ $SQL = "
52 52
   FROM wiki_articles
53 53
   WHERE MinClassRead <= '".$LoggedUser['EffectiveClass']."'";
54 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 60
 $SQL .= "
@@ -65,9 +65,10 @@ $DB->query("
65 65
   SELECT FOUND_ROWS()");
66 66
 list($NumResults) = $DB->next_record();
67 67
 
68
-View::show_header('Search articles');
68
+View::show_header('Search Articles');
69 69
 $DB->set_query_id($RS);
70 70
 ?>
71
+
71 72
 <div class="thin">
72 73
   <div class="header">
73 74
     <h2>Search articles</h2>
@@ -83,28 +84,36 @@ $DB->set_query_id($RS);
83 84
       </div>
84 85
       <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
85 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 88
           <td colspan="3">
88 89
             <input type="search" name="search" id="search" size="70" value="<?=display_str($_GET['search'])?>" />
89 90
           </td>
90 91
         </tr>
91 92
         <tr>
92
-          <td class="label"><strong>Search in:</strong></td>
93
+          <td class="label"><strong>Search In</strong></td>
93 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 101
           </td>
97
-          <td class="label"><strong>Order by:</strong></td>
102
+          <td class="label"><strong>Order By</strong></td>
98 103
           <td>
99 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 110
             </select>
104 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 117
             </select>
109 118
           </td>
110 119
         </tr>
@@ -117,25 +126,25 @@ $DB->set_query_id($RS);
117 126
     </form>
118 127
   </div>
119 128
   <br />
120
-<?
129
+<?php
121 130
   $Pages = Format::get_pages($Page, $NumResults, ARTICLES_PER_PAGE);
122 131
   if ($Pages) { ?>
123 132
   <div class="linkbox pager"><?=($Pages)?></div>
124
-<?  } ?>
133
+<?php  } ?>
125 134
 <table width="100%">
126 135
   <tr class="colhead">
127 136
     <td>Article</td>
128 137
     <td>Last updated on</td>
129 138
     <td>Last edited by</td>
130 139
   </tr>
131
-<?  while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
140
+<?php  while (list($ID, $Title, $Date, $UserID) = $DB->next_record()) { ?>
132 141
   <tr>
133 142
     <td><a href="wiki.php?action=article&amp;id=<?=$ID?>"><?=$Title?></a></td>
134 143
     <td><?=$Date?></td>
135 144
     <td><?=Users::format_username($UserID, false, false, false)?></td>
136 145
   </tr>
137
-<?  } ?>
146
+<?php  } ?>
138 147
 </table>
139 148
   <div class="linkbox"><?=$Pages?></div>
140 149
 </div>
141
-<? View::show_footer(); ?>
150
+<?php View::show_footer(); ?>

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


Loading…
Cancel
Save