Browse Source

Update torrent search and display, also cosmetic

pjc 5 years ago
parent
commit
8f51da3645

+ 415
- 400
classes/comments.class.php View File

@@ -1,442 +1,457 @@
1
-<?
2
-class Comments {
3
-  /*
4
-   * For all functions:
5
-   * $Page = 'artist', 'collages', 'requests' or 'torrents'
6
-   * $PageID = ArtistID, CollageID, RequestID or GroupID, respectively
7
-   */
8
-
9
-  /**
10
-   * Post a comment on an artist, request or torrent page.
11
-   * @param string $Page
12
-   * @param int $PageID
13
-   * @param string $Body
14
-   * @return int ID of the new comment
15
-   */
16
-  public static function post($Page, $PageID, $Body) {
17
-    $QueryID = G::$DB->get_query_id();
18
-    G::$DB->query("
19
-      SELECT
1
+<?php
2
+
3
+class Comments
4
+{
5
+    /*
6
+     * For all functions:
7
+     * $Page = 'artist', 'collages', 'requests' or 'torrents'
8
+     * $PageID = ArtistID, CollageID, RequestID or GroupID, respectively
9
+     */
10
+
11
+    /**
12
+     * Post a comment on an artist, request or torrent page.
13
+     * @param string $Page
14
+     * @param int $PageID
15
+     * @param string $Body
16
+     * @return int ID of the new comment
17
+     */
18
+    public static function post($Page, $PageID, $Body)
19
+    {
20
+        $QueryID = G::$DB->get_query_id();
21
+        G::$DB->query("
22
+        SELECT
20 23
         CEIL(
21 24
           (
22 25
             SELECT COUNT(ID) + 1
23 26
             FROM comments
24 27
             WHERE Page = '$Page'
25
-              AND PageID = $PageID
26
-          ) / " . TORRENT_COMMENTS_PER_PAGE . "
27
-        ) AS Pages");
28
-    list($Pages) = G::$DB->next_record();
29
-
30
-    G::$DB->query("
31
-      INSERT INTO comments (Page, PageID, AuthorID, AddedTime, Body)
32
-      VALUES ('$Page', $PageID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($Body) . "')");
33
-    $PostID = G::$DB->inserted_id();
34
-
35
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
36
-    G::$Cache->delete_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
37
-    G::$Cache->delete_value($Page.'_comments_'.$PageID);
38
-
39
-    Subscriptions::flush_subscriptions($Page, $PageID);
40
-    Subscriptions::quote_notify($Body, $PostID, $Page, $PageID);
41
-
42
-    G::$DB->set_query_id($QueryID);
43
-
44
-    return $PostID;
45
-  }
46
-
47
-  /**
48
-   * Edit a comment
49
-   * @param int $PostID
50
-   * @param string $NewBody
51
-   * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
52
-   * 
53
-   * todo: Move permission check out of here/remove hardcoded error(404)
54
-   */
55
-  public static function edit($PostID, $NewBody, $SendPM = false) {
56
-    $QueryID = G::$DB->get_query_id();
57
-
58
-    G::$DB->query("
59
-      SELECT
60
-        Body,
61
-        AuthorID,
62
-        Page,
63
-        PageID,
64
-        AddedTime
65
-      FROM comments
66
-      WHERE ID = $PostID");
67
-    if (!G::$DB->has_results()) {
68
-      return false;
69
-    }
70
-    list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
28
+            AND PageID = $PageID
29
+            ) / " . TORRENT_COMMENTS_PER_PAGE . "
30
+          ) AS Pages");
31
+        list($Pages) = G::$DB->next_record();
71 32
 
72
-    if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
73
-      return false;
74
-    }
33
+        G::$DB->query("
34
+        INSERT INTO comments (Page, PageID, AuthorID, AddedTime, Body)
35
+        VALUES ('$Page', $PageID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($Body) . "')");
36
+        $PostID = G::$DB->inserted_id();
75 37
 
76
-    G::$DB->query("
77
-      SELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
78
-      FROM comments
79
-      WHERE Page = '$Page'
80
-        AND PageID = $PageID
81
-        AND ID <= $PostID");
82
-    list($CommPage) = G::$DB->next_record();
83
-
84
-    // Perform the update
85
-    G::$DB->query("
86
-      UPDATE comments
87
-      SET
88
-        Body = '" . db_string($NewBody) . "',
89
-        EditedUserID = " . G::$LoggedUser['ID'] . ",
90
-        EditedTime = NOW()
91
-      WHERE ID = $PostID");
92
-
93
-    // Update the cache
94
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
95
-    G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
96
-
97
-    if ($Page == 'collages') {
98
-      // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
99
-      G::$Cache->delete_value('collage_' . $PageID);
100
-    }
38
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
39
+        G::$Cache->delete_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
40
+        G::$Cache->delete_value($Page.'_comments_'.$PageID);
101 41
 
102
-    G::$DB->query("
103
-      INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
104
-      VALUES ('$Page', $PostID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($OldBody) . "')");
42
+        Subscriptions::flush_subscriptions($Page, $PageID);
43
+        Subscriptions::quote_notify($Body, $PostID, $Page, $PageID);
105 44
 
106
-    G::$DB->set_query_id($QueryID);
45
+        G::$DB->set_query_id($QueryID);
107 46
 
108
-    if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
109
-      // Send a PM to the user to notify them of the edit
110
-      $PMSubject = "Your comment #$PostID has been edited";
111
-      $PMurl = site_url()."comments.php?action=jump&postid=$PostID";
112
-      $ProfLink = '[url='.site_url().'user.php?id='.G::$LoggedUser['ID'].']'.G::$LoggedUser['Username'].'[/url]';
113
-      $PMBody = "One of your comments has been edited by $ProfLink: [url]{$PMurl}[/url]";
114
-      Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
47
+        return $PostID;
115 48
     }
116 49
 
117
-    return true; // todo: This should reflect whether or not the update was actually successful, e.g., by checking G::$DB->affected_rows after the UPDATE query
118
-  }
119
-
120
-  /**
121
-   * Delete a comment
122
-   * @param int $PostID
123
-   */
124
-  public static function delete($PostID) {
125
-    $QueryID = G::$DB->get_query_id();
126
-    // Get page, pageid
127
-    G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
128
-    if (!G::$DB->has_results()) {
129
-      // no such comment?
130
-      G::$DB->set_query_id($QueryID);
131
-      return false;
132
-    }
133
-    list ($Page, $PageID) = G::$DB->next_record();
134
-    // get number of pages
135
-    G::$DB->query("
136
-      SELECT
137
-        CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
138
-        CEIL(SUM(IF(ID <= $PostID, 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
139
-      FROM comments
140
-      WHERE Page = '$Page'
141
-        AND PageID = $PageID
142
-      GROUP BY PageID");
143
-    if (!G::$DB->has_results()) {
144
-      // the comment $PostID was probably not posted on $Page
145
-      G::$DB->set_query_id($QueryID);
146
-      return false;
147
-    }
148
-    list($CommPages, $CommPage) = G::$DB->next_record();
149
-
150
-    // $CommPages = number of pages in the thread
151
-    // $CommPage = which page the post is on
152
-    // These are set for cache clearing.
153
-
154
-    G::$DB->query("
155
-      DELETE FROM comments
156
-      WHERE ID = $PostID");
157
-    G::$DB->query("
158
-      DELETE FROM comments_edits
159
-      WHERE Page = '$Page'
160
-        AND PostID = $PostID");
161
-
162
-    G::$DB->query("
163
-      DELETE FROM users_notify_quoted
164
-      WHERE Page = '$Page'
165
-        AND PostID = $PostID");
166
-
167
-    Subscriptions::flush_subscriptions($Page, $PageID);
168
-    Subscriptions::flush_quote_notifications($Page, $PageID);
169
-
170
-    //We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
171
-    $ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
172
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
173
-    for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
174
-      G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
175
-    }
50
+    /**
51
+     * Edit a comment
52
+     * @param int $PostID
53
+     * @param string $NewBody
54
+     * @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
55
+     *
56
+     * todo: Move permission check out of here/remove hardcoded error(404)
57
+     */
58
+    public static function edit($PostID, $NewBody, $SendPM = false)
59
+    {
60
+        $QueryID = G::$DB->get_query_id();
176 61
 
177
-    G::$Cache->delete_value($Page . '_comments_' . $PageID);
62
+        G::$DB->query("
63
+        SELECT
64
+          Body,
65
+          AuthorID,
66
+          Page,
67
+          PageID,
68
+          AddedTime
69
+        FROM comments
70
+          WHERE ID = $PostID");
71
+        if (!G::$DB->has_results()) {
72
+            return false;
73
+        }
74
+        list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
178 75
 
179
-    if ($Page == 'collages') {
180
-      // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
181
-      G::$Cache->delete_value("collage_$PageID");
182
-    }
76
+        if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
77
+            return false;
78
+        }
183 79
 
184
-    G::$DB->set_query_id($QueryID);
185
-
186
-    return true;
187
-  }
188
-
189
-  /**
190
-   * Get the URL to a comment, already knowing the Page and PostID
191
-   * @param string $Page
192
-   * @param int $PageID
193
-   * @param int $PostID
194
-   * @return string|bool The URL to the comment or false on error
195
-   */
196
-  public static function get_url($Page, $PageID, $PostID = null) {
197
-    $Post = (!empty($PostID) ? "&postid=$PostID#post$PostID" : '');
198
-    switch ($Page) {
199
-      case 'artist':
200
-        return "artist.php?id=$PageID$Post";
201
-      case 'collages':
202
-        return "collages.php?action=comments&collageid=$PageID$Post";
203
-      case 'requests':
204
-        return "requests.php?action=view&id=$PageID$Post";
205
-      case 'torrents':
206
-        return "torrents.php?id=$PageID$Post";
207
-      default:
208
-        return false;
209
-    }
210
-  }
211
-
212
-  /**
213
-   * Get the URL to a comment
214
-   * @param int $PostID
215
-   * @return string|bool The URL to the comment or false on error
216
-   */
217
-  public static function get_url_query($PostID) {
218
-    $QueryID = G::$DB->get_query_id();
219
-
220
-    G::$DB->query("
221
-      SELECT Page, PageID
222
-      FROM comments
223
-      WHERE ID = $PostID");
224
-    if (!G::$DB->has_results()) {
225
-      error(404);
226
-    }
227
-    list($Page, $PageID) = G::$DB->next_record();
228
-
229
-    G::$DB->set_query_id($QueryID);
230
-
231
-    return self::get_url($Page, $PageID, $PostID);
232
-  }
233
-
234
-  /**
235
-   * Load a page's comments. This takes care of `postid` and (indirectly) `page` parameters passed in $_GET.
236
-   * Quote notifications and last read are also handled here, unless $HandleSubscriptions = false is passed.
237
-   * @param string $Page
238
-   * @param int $PageID
239
-   * @param bool $HandleSubscriptions Whether or not to handle subscriptions (last read & quote notifications)
240
-   * @return array ($NumComments, $Page, $Thread, $LastRead)
241
-   *     $NumComments: the total number of comments on this artist/request/torrent group
242
-   *     $Page: the page we're currently on
243
-   *     $Thread: an array of all posts on this page
244
-   *     $LastRead: ID of the last comment read by the current user in this thread;
245
-   *                will be false if $HandleSubscriptions == false or if there are no comments on this page
246
-   */
247
-  public static function load($Page, $PageID, $HandleSubscriptions = true) {
248
-    $QueryID = G::$DB->get_query_id();
249
-
250
-    // Get the total number of comments
251
-    $NumComments = G::$Cache->get_value($Page."_comments_$PageID");
252
-    if ($NumComments === false) {
253
-      G::$DB->query("
254
-        SELECT COUNT(ID)
80
+        G::$DB->query("
81
+        SELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
255 82
         FROM comments
256
-        WHERE Page = '$Page'
257
-          AND PageID = $PageID");
258
-      list($NumComments) = G::$DB->next_record();
259
-      G::$Cache->cache_value($Page."_comments_$PageID", $NumComments, 0);
83
+          WHERE Page = '$Page'
84
+          AND PageID = $PageID
85
+          AND ID <= $PostID");
86
+        list($CommPage) = G::$DB->next_record();
87
+
88
+        // Perform the update
89
+        G::$DB->query("
90
+        UPDATE comments
91
+        SET
92
+          Body = '" . db_string($NewBody) . "',
93
+          EditedUserID = " . G::$LoggedUser['ID'] . ",
94
+          EditedTime = NOW()
95
+        WHERE ID = $PostID");
96
+
97
+        // Update the cache
98
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
99
+        G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
100
+
101
+        if ($Page == 'collages') {
102
+            // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
103
+            G::$Cache->delete_value('collage_' . $PageID);
104
+        }
105
+
106
+        G::$DB->query("
107
+        INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)
108
+        VALUES ('$Page', $PostID, " . G::$LoggedUser['ID'] . ", NOW(), '" . db_string($OldBody) . "')");
109
+
110
+        G::$DB->set_query_id($QueryID);
111
+
112
+        if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
113
+            // Send a PM to the user to notify them of the edit
114
+            $PMSubject = "Your comment #$PostID has been edited";
115
+            $PMurl = site_url()."comments.php?action=jump&postid=$PostID";
116
+            $ProfLink = '[url='.site_url().'user.php?id='.G::$LoggedUser['ID'].']'.G::$LoggedUser['Username'].'[/url]';
117
+            $PMBody = "One of your comments has been edited by $ProfLink: [url]{$PMurl}[/url]";
118
+            Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
119
+        }
120
+
121
+        return true; // todo: This should reflect whether or not the update was actually successful, e.g., by checking G::$DB->affected_rows after the UPDATE query
260 122
     }
261 123
 
262
-    // If a postid was passed, we need to determine which page that comment is on.
263
-    // Format::page_limit handles a potential $_GET['page']
264
-    if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
265
-      G::$DB->query("
266
-        SELECT COUNT(ID)
124
+    /**
125
+     * Delete a comment
126
+     * @param int $PostID
127
+     */
128
+    public static function delete($PostID)
129
+    {
130
+        $QueryID = G::$DB->get_query_id();
131
+        // Get page, pageid
132
+        G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = $PostID");
133
+        if (!G::$DB->has_results()) {
134
+            // no such comment?
135
+            G::$DB->set_query_id($QueryID);
136
+            return false;
137
+        }
138
+        list($Page, $PageID) = G::$DB->next_record();
139
+        // get number of pages
140
+        G::$DB->query("
141
+        SELECT
142
+          CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,
143
+          CEIL(SUM(IF(ID <= $PostID, 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page
267 144
         FROM comments
268
-        WHERE Page = '$Page'
145
+          WHERE Page = '$Page'
269 146
           AND PageID = $PageID
270
-          AND ID <= $_GET[postid]");
271
-      list($PostNum) = G::$DB->next_record();
272
-      list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
273
-    } else {
274
-      list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
275
-    }
147
+        GROUP BY PageID");
148
+        if (!G::$DB->has_results()) {
149
+            // the comment $PostID was probably not posted on $Page
150
+            G::$DB->set_query_id($QueryID);
151
+            return false;
152
+        }
153
+        list($CommPages, $CommPage) = G::$DB->next_record();
154
+
155
+        // $CommPages = number of pages in the thread
156
+        // $CommPage = which page the post is on
157
+        // These are set for cache clearing.
276 158
 
277
-    // Get the cache catalogue
278
-    $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
159
+        G::$DB->query("
160
+        DELETE FROM comments
161
+          WHERE ID = $PostID");
162
+        G::$DB->query("
163
+        DELETE FROM comments_edits
164
+          WHERE Page = '$Page'
165
+          AND PostID = $PostID");
279 166
 
280
-    // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
281
-    $Catalogue = G::$Cache->get_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
282
-    if ($Catalogue === false) {
283
-      $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
284
-      G::$DB->query("
285
-        SELECT
286
-          c.ID,
287
-          c.AuthorID,
288
-          c.AddedTime,
289
-          c.Body,
290
-          c.EditedUserID,
291
-          c.EditedTime,
292
-          u.Username
293
-        FROM comments AS c
294
-          LEFT JOIN users_main AS u ON u.ID = c.EditedUserID
295
-        WHERE c.Page = '$Page'
296
-          AND c.PageID = $PageID
297
-        ORDER BY c.ID
298
-        LIMIT $CatalogueLimit");
299
-      $Catalogue = G::$DB->to_array(false, MYSQLI_ASSOC);
300
-      G::$Cache->cache_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
167
+        G::$DB->query("
168
+        DELETE FROM users_notify_quoted
169
+          WHERE Page = '$Page'
170
+          AND PostID = $PostID");
171
+
172
+        Subscriptions::flush_subscriptions($Page, $PageID);
173
+        Subscriptions::flush_quote_notifications($Page, $PageID);
174
+
175
+        // We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
176
+        $ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
177
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
178
+        for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
179
+            G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
180
+        }
181
+
182
+        G::$Cache->delete_value($Page . '_comments_' . $PageID);
183
+
184
+        if ($Page === 'collages') {
185
+            // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
186
+            G::$Cache->delete_value("collage_$PageID");
187
+        }
188
+
189
+        G::$DB->set_query_id($QueryID);
190
+
191
+        return true;
301 192
     }
302 193
 
303
-    //This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
304
-    $Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
194
+    /**
195
+     * Get the URL to a comment, already knowing the Page and PostID
196
+     * @param string $Page
197
+     * @param int $PageID
198
+     * @param int $PostID
199
+     * @return string|bool The URL to the comment or false on error
200
+     */
201
+    public static function get_url($Page, $PageID, $PostID = null)
202
+    {
203
+        $Post = (!empty($PostID) ? "&postid=$PostID#post$PostID" : '');
204
+        switch ($Page) {
205
+        case 'artist':
206
+            return "artist.php?id=$PageID$Post";
207
+        case 'collages':
208
+            return "collages.php?action=comments&collageid=$PageID$Post";
209
+        case 'requests':
210
+            return "requests.php?action=view&id=$PageID$Post";
211
+        case 'torrents':
212
+            return "torrents.php?id=$PageID$Post";
213
+        default:
214
+            return false;
215
+        }
216
+    }
305 217
 
306
-    if ($HandleSubscriptions && count($Thread) > 0) {
307
-      // quote notifications
308
-      $LastPost = end($Thread);
309
-      $LastPost = $LastPost['ID'];
310
-      $FirstPost = reset($Thread);
311
-      $FirstPost = $FirstPost['ID'];
312
-      G::$DB->query("
313
-        UPDATE users_notify_quoted
314
-        SET UnRead = false
315
-        WHERE UserID = " . G::$LoggedUser['ID'] . "
316
-          AND Page = '$Page'
218
+    /**
219
+     * Get the URL to a comment
220
+     * @param int $PostID
221
+     * @return string|bool The URL to the comment or false on error
222
+     */
223
+    public static function get_url_query($PostID)
224
+    {
225
+        $QueryID = G::$DB->get_query_id();
226
+
227
+        G::$DB->query("
228
+        SELECT Page, PageID
229
+        FROM comments
230
+          WHERE ID = $PostID");
231
+
232
+        if (!G::$DB->has_results()) {
233
+            error(404);
234
+        }
235
+
236
+        list($Page, $PageID) = G::$DB->next_record();
237
+        G::$DB->set_query_id($QueryID);
238
+
239
+        return self::get_url($Page, $PageID, $PostID);
240
+    }
241
+
242
+    /**
243
+     * Load a page's comments. This takes care of `postid` and (indirectly) `page` parameters passed in $_GET.
244
+     * Quote notifications and last read are also handled here, unless $HandleSubscriptions = false is passed.
245
+     * @param string $Page
246
+     * @param int $PageID
247
+     * @param bool $HandleSubscriptions Whether or not to handle subscriptions (last read & quote notifications)
248
+     * @return array ($NumComments, $Page, $Thread, $LastRead)
249
+     *     $NumComments: the total number of comments on this artist/request/torrent group
250
+     *     $Page: the page we're currently on
251
+     *     $Thread: an array of all posts on this page
252
+     *     $LastRead: ID of the last comment read by the current user in this thread;
253
+     *                will be false if $HandleSubscriptions == false or if there are no comments on this page
254
+     */
255
+    public static function load($Page, $PageID, $HandleSubscriptions = true)
256
+    {
257
+        $QueryID = G::$DB->get_query_id();
258
+
259
+        // Get the total number of comments
260
+        $NumComments = G::$Cache->get_value($Page."_comments_$PageID");
261
+        if ($NumComments === false) {
262
+            G::$DB->query("
263
+            SELECT COUNT(ID)
264
+            FROM comments
265
+              WHERE Page = '$Page'
266
+              AND PageID = $PageID");
267
+            list($NumComments) = G::$DB->next_record();
268
+            G::$Cache->cache_value($Page."_comments_$PageID", $NumComments, 0);
269
+        }
270
+
271
+        // If a postid was passed, we need to determine which page that comment is on.
272
+        // Format::page_limit handles a potential $_GET['page']
273
+        if (isset($_GET['postid']) && is_number($_GET['postid']) && $NumComments > TORRENT_COMMENTS_PER_PAGE) {
274
+            G::$DB->query("
275
+        SELECT COUNT(ID)
276
+        FROM comments
277
+        WHERE Page = '$Page'
317 278
           AND PageID = $PageID
318
-          AND PostID >= $FirstPost
319
-          AND PostID <= $LastPost");
320
-      if (G::$DB->affected_rows()) {
321
-        G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
322
-      }
323
-
324
-      // last read
325
-      G::$DB->query("
279
+          AND ID <= $_GET[postid]");
280
+            list($PostNum) = G::$DB->next_record();
281
+            list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $PostNum);
282
+        } else {
283
+            list($CommPage, $Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE, $NumComments);
284
+        }
285
+
286
+        // Get the cache catalogue
287
+        $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
288
+
289
+        // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page
290
+        $Catalogue = G::$Cache->get_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID);
291
+        if ($Catalogue === false) {
292
+            $CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE;
293
+            G::$DB->query("
294
+                SELECT
295
+                  c.ID,
296
+                  c.AuthorID,
297
+                  c.AddedTime,
298
+                  c.Body,
299
+                  c.EditedUserID,
300
+                  c.EditedTime,
301
+                  u.Username
302
+                FROM comments AS c
303
+                  LEFT JOIN users_main AS u ON u.ID = c.EditedUserID
304
+                  WHERE c.Page = '$Page'
305
+                  AND c.PageID = $PageID
306
+                ORDER BY c.ID
307
+                LIMIT $CatalogueLimit");
308
+            $Catalogue = G::$DB->to_array(false, MYSQLI_ASSOC);
309
+            G::$Cache->cache_value($Page.'_comments_'.$PageID.'_catalogue_'.$CatalogueID, $Catalogue, 0);
310
+        }
311
+
312
+        // This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue
313
+        $Thread = array_slice($Catalogue, ((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE), TORRENT_COMMENTS_PER_PAGE, true);
314
+
315
+        if ($HandleSubscriptions && count($Thread) > 0) {
316
+            // Quote notifications
317
+            $LastPost = end($Thread);
318
+            $LastPost = $LastPost['ID'];
319
+            $FirstPost = reset($Thread);
320
+            $FirstPost = $FirstPost['ID'];
321
+            G::$DB->query("
322
+                UPDATE users_notify_quoted
323
+                SET UnRead = false
324
+                  WHERE UserID = " . G::$LoggedUser['ID'] . "
325
+                  AND Page = '$Page'
326
+                  AND PageID = $PageID
327
+                  AND PostID >= $FirstPost
328
+                  AND PostID <= $LastPost");
329
+            if (G::$DB->affected_rows()) {
330
+                G::$Cache->delete_value('notify_quoted_' . G::$LoggedUser['ID']);
331
+            }
332
+
333
+            // Last read
334
+            G::$DB->query("
326 335
         SELECT PostID
327 336
         FROM users_comments_last_read
328
-        WHERE UserID = " . G::$LoggedUser['ID'] . "
337
+          WHERE UserID = " . G::$LoggedUser['ID'] . "
329 338
           AND Page = '$Page'
330 339
           AND PageID = $PageID");
331
-      list($LastRead) = G::$DB->next_record();
332
-      if ($LastRead < $LastPost) {
333
-        G::$DB->query("
340
+            list($LastRead) = G::$DB->next_record();
341
+            if ($LastRead < $LastPost) {
342
+                G::$DB->query("
334 343
           INSERT INTO users_comments_last_read
335 344
             (UserID, Page, PageID, PostID)
336 345
           VALUES
337 346
             (" . G::$LoggedUser['ID'] . ", '$Page', $PageID, $LastPost)
338 347
           ON DUPLICATE KEY UPDATE
339 348
             PostID = $LastPost");
340
-        G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
341
-      }
342
-    } else {
343
-      $LastRead = false;
344
-    }
349
+                G::$Cache->delete_value('subscriptions_user_new_' . G::$LoggedUser['ID']);
350
+            }
351
+        } else {
352
+            $LastRead = false;
353
+        }
345 354
 
346
-    G::$DB->set_query_id($QueryID);
347
-
348
-    return array($NumComments, $CommPage, $Thread, $LastRead);
349
-  }
350
-
351
-  /**
352
-   * Merges all comments from $Page/$PageID into $Page/$TargetPageID. This also takes care of quote notifications, subscriptions and cache.
353
-   * @param type $Page
354
-   * @param type $PageID
355
-   * @param type $TargetPageID
356
-   */
357
-  public static function merge($Page, $PageID, $TargetPageID) {
358
-    $QueryID = G::$DB->get_query_id();
359
-
360
-    G::$DB->query("
361
-      UPDATE comments
362
-      SET PageID = $TargetPageID
363
-      WHERE Page = '$Page'
364
-        AND PageID = $PageID");
365
-
366
-    // quote notifications
367
-    G::$DB->query("
368
-      UPDATE users_notify_quoted
369
-      SET PageID = $TargetPageID
370
-      WHERE Page = '$Page'
371
-        AND PageID = $PageID");
372
-
373
-    // comment subscriptions
374
-    Subscriptions::move_subscriptions($Page, $PageID, $TargetPageID);
375
-
376
-    // cache (we need to clear all comment catalogues)
377
-    G::$DB->query("
378
-      SELECT
379
-        CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
380
-      FROM comments
381
-      WHERE Page = '$Page'
382
-        AND PageID = $TargetPageID
383
-      GROUP BY PageID");
384
-    list($CommPages) = G::$DB->next_record();
385
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
386
-    for ($i = 0; $i <= $LastCatalogue; ++$i) {
387
-      G::$Cache->delete_value($Page . "_comments_$TargetPageID" . "_catalogue_$i");
388
-    }
389
-    G::$Cache->delete_value($Page."_comments_$TargetPageID");
390
-    G::$DB->set_query_id($QueryID);
391
-  }
392
-
393
-  /**
394
-   * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
395
-   * @param string $Page
396
-   * @param int $PageID
397
-   * @return boolean
398
-   */
399
-  public static function delete_page($Page, $PageID) {
400
-    $QueryID = G::$DB->get_query_id();
401
-
402
-    // get number of pages
403
-    G::$DB->query("
404
-      SELECT
405
-        CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
406
-      FROM comments
407
-      WHERE Page = '$Page'
408
-        AND PageID = $PageID
409
-      GROUP BY PageID");
410
-    if (!G::$DB->has_results()) {
411
-      return false;
355
+        G::$DB->set_query_id($QueryID);
356
+
357
+        return array($NumComments, $CommPage, $Thread, $LastRead);
412 358
     }
413
-    list($CommPages) = G::$DB->next_record();
414
-
415
-    // Delete comments
416
-    G::$DB->query("
417
-      DELETE FROM comments
418
-      WHERE Page = '$Page'
419
-        AND PageID = $PageID");
420
-
421
-    // Delete quote notifications
422
-    Subscriptions::flush_quote_notifications($Page, $PageID);
423
-    G::$DB->query("
424
-      DELETE FROM users_notify_quoted
425
-      WHERE Page = '$Page'
426
-        AND PageID = $PageID");
427
-
428
-    // Deal with subscriptions
429
-    Subscriptions::move_subscriptions($Page, $PageID, null);
430
-
431
-    // Clear cache
432
-    $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
433
-    for ($i = 0; $i <= $LastCatalogue; ++$i) {
434
-      G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
359
+
360
+    /**
361
+     * Merges all comments from $Page/$PageID into $Page/$TargetPageID. This also takes care of quote notifications, subscriptions and cache.
362
+     * @param type $Page
363
+     * @param type $PageID
364
+     * @param type $TargetPageID
365
+     */
366
+    public static function merge($Page, $PageID, $TargetPageID)
367
+    {
368
+        $QueryID = G::$DB->get_query_id();
369
+
370
+        G::$DB->query("
371
+        UPDATE comments
372
+        SET PageID = $TargetPageID
373
+          WHERE Page = '$Page'
374
+          AND PageID = $PageID");
375
+
376
+        // quote notifications
377
+        G::$DB->query("
378
+        UPDATE users_notify_quoted
379
+        SET PageID = $TargetPageID
380
+          WHERE Page = '$Page'
381
+          AND PageID = $PageID");
382
+
383
+        // comment subscriptions
384
+        Subscriptions::move_subscriptions($Page, $PageID, $TargetPageID);
385
+
386
+        // cache (we need to clear all comment catalogues)
387
+        G::$DB->query("
388
+        SELECT
389
+          CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
390
+        FROM comments
391
+          WHERE Page = '$Page'
392
+          AND PageID = $TargetPageID
393
+        GROUP BY PageID");
394
+
395
+        list($CommPages) = G::$DB->next_record();
396
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
397
+        
398
+        for ($i = 0; $i <= $LastCatalogue; ++$i) {
399
+            G::$Cache->delete_value($Page . "_comments_$TargetPageID" . "_catalogue_$i");
400
+        }
401
+
402
+        G::$Cache->delete_value($Page."_comments_$TargetPageID");
403
+        G::$DB->set_query_id($QueryID);
435 404
     }
436
-    G::$Cache->delete_value($Page.'_comments_'.$PageID);
437 405
 
438
-    G::$DB->set_query_id($QueryID);
406
+    /**
407
+     * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
408
+     * @param string $Page
409
+     * @param int $PageID
410
+     * @return boolean
411
+     */
412
+    public static function delete_page($Page, $PageID)
413
+    {
414
+        $QueryID = G::$DB->get_query_id();
415
+
416
+        // get number of pages
417
+        G::$DB->query("
418
+        SELECT
419
+          CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages
420
+        FROM comments
421
+          WHERE Page = '$Page'
422
+          AND PageID = $PageID
423
+        GROUP BY PageID");
424
+
425
+        if (!G::$DB->has_results()) {
426
+            return false;
427
+        }
428
+        list($CommPages) = G::$DB->next_record();
429
+
430
+        // Delete comments
431
+        G::$DB->query("
432
+        DELETE FROM comments
433
+          WHERE Page = '$Page'
434
+          AND PageID = $PageID");
439 435
 
440
-    return true;
441
-  }
436
+        // Delete quote notifications
437
+        Subscriptions::flush_quote_notifications($Page, $PageID);
438
+        G::$DB->query("
439
+        DELETE FROM users_notify_quoted
440
+          WHERE Page = '$Page'
441
+          AND PageID = $PageID");
442
+
443
+        // Deal with subscriptions
444
+        Subscriptions::move_subscriptions($Page, $PageID, null);
445
+
446
+        // Clear cache
447
+        $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
448
+        for ($i = 0; $i <= $LastCatalogue; ++$i) {
449
+            G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
450
+        }
451
+
452
+        G::$Cache->delete_value($Page.'_comments_'.$PageID);
453
+        G::$DB->set_query_id($QueryID);
454
+
455
+        return true;
456
+    }
442 457
 }

+ 25
- 22
classes/format.class.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 class Format
3 4
 {
4 5
 
@@ -47,7 +48,7 @@ class Format
47 48
     public static function cut_string($Str, $Length, $Hard = false, $ShowDots = true)
48 49
     {
49 50
         if (mb_strlen($Str, 'UTF-8') > $Length) {
50
-            if ($Hard == 0) {
51
+            if ($Hard === 0) {
51 52
                 // Not hard, cut at closest word
52 53
                 $CutDesc = mb_substr($Str, 0, $Length, 'UTF-8');
53 54
                 $DescArr = explode(' ', $CutDesc);
@@ -130,7 +131,7 @@ class Format
130 131
         $Ratio = self::get_ratio($Dividend, $Divisor);
131 132
 
132 133
         if ($Ratio === false) {
133
-            return '--';
134
+            return '&ndash;';
134 135
         }
135 136
         if ($Ratio === '∞') {
136 137
             return '<span class="tooltip r99" title="Infinite">∞</span>';
@@ -156,10 +157,10 @@ class Format
156 157
      */
157 158
     public static function get_ratio($Dividend, $Divisor, $Decimal = 2)
158 159
     {
159
-        if ($Divisor == 0 && $Dividend == 0) {
160
+        if ($Divisor === 0 && $Dividend === 0) {
160 161
             return false;
161 162
         }
162
-        if ($Divisor == 0) {
163
+        if ($Divisor === 0) {
163 164
             return '∞';
164 165
         }
165 166
         return number_format(max($Dividend / $Divisor - (0.5 / pow(10, $Decimal)), 0), $Decimal);
@@ -206,6 +207,7 @@ class Format
206 207
     {
207 208
         if (!isset($_GET['page'])) {
208 209
             $Page = ceil($DefaultResult / $PerPage);
210
+            # todo: Strict equality breaks comment fetching
209 211
             if ($Page == 0) {
210 212
                 $Page = 1;
211 213
             }
@@ -224,7 +226,7 @@ class Format
224 226
     }
225 227
 
226 228
     // A9 magic. Some other poor soul can write the phpdoc.
227
-    // For data stored in memcached catalogues (giant arrays), e.g. forum threads
229
+    // For data stored in memcached catalogues (giant arrays), e.g., forum threads
228 230
     public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500)
229 231
     {
230 232
         $CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);
@@ -237,7 +239,8 @@ class Format
237 239
         return array_slice($Catalogue, (($PerPage * $Page - $PerPage) % $CatalogueSize), $PerPage, true);
238 240
     }
239 241
 
240
-    /* Get pages
242
+    /*
243
+     * Get pages
241 244
      * Returns a page list, given certain information about the pages.
242 245
      *
243 246
      * @param int $StartPage: The current record the page you're on starts with.
@@ -285,7 +288,7 @@ class Format
285 288
             $StartPosition = max($StartPosition, 1);
286 289
 
287 290
             $QueryString = self::get_url(array('page', 'post'));
288
-            if ($QueryString != '') {
291
+            if ($QueryString !== '') {
289 292
                 $QueryString = "&amp;$QueryString";
290 293
             }
291 294
 
@@ -299,7 +302,7 @@ class Format
299 302
 
300 303
             if (!$Mobile) {
301 304
                 for ($i = $StartPosition; $i <= $StopPage; $i++) {
302
-                    if ($i != $StartPage) {
305
+                    if ($i !== $StartPage) {
303 306
                         $Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
304 307
                     }
305 308
                     $Pages .= '<strong>';
@@ -310,7 +313,7 @@ class Format
310 313
                     }
311 314
 
312 315
                     $Pages .= '</strong>';
313
-                    if ($i != $StartPage) {
316
+                    if ($i !== $StartPage) {
314 317
                         $Pages .= '</a>';
315 318
                     }
316 319
                     if ($i < $StopPage) {
@@ -346,7 +349,7 @@ class Format
346 349
         $Size = (double)$Size;
347 350
         for ($Steps = 0; abs($Size) >= 1024 && $Steps < count($Units); $Size /= 1024, $Steps++) {
348 351
         }
349
-        if (func_num_args() == 1 && $Steps >= 4) {
352
+        if (func_num_args() === 1 && $Steps >= 4) {
350 353
             $Levels++;
351 354
         }
352 355
         return number_format($Size, $Levels) . ' ' . $Units[$Steps];
@@ -445,7 +448,7 @@ class Format
445 448
             $Array = $_GET;
446 449
         }
447 450
         if (isset($Array[$Name]) && $Array[$Name] !== '') {
448
-            if ($Array[$Name] == $Value) {
451
+            if ($Array[$Name] === $Value) {
449 452
                 echo " $Attribute=\"$Attribute\"";
450 453
             }
451 454
         }
@@ -515,7 +518,7 @@ class Format
515 518
      */
516 519
     public static function make_utf8($Str)
517 520
     {
518
-        if ($Str != '') {
521
+        if ($Str !== '') {
519 522
             if (self::is_utf8($Str)) {
520 523
                 $Encoding = 'UTF-8';
521 524
             }
@@ -525,7 +528,7 @@ class Format
525 528
             if (empty($Encoding)) {
526 529
                 $Encoding = 'ISO-8859-1';
527 530
             }
528
-            if ($Encoding == 'UTF-8') {
531
+            if ($Encoding === 'UTF-8') {
529 532
                 return $Str;
530 533
             } else {
531 534
                 return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
@@ -543,15 +546,15 @@ class Format
543 546
     {
544 547
         return preg_match(
545 548
             '%^(?:
546
-      [\x09\x0A\x0D\x20-\x7E]              // ASCII
547
-      | [\xC2-\xDF][\x80-\xBF]             // non-overlong 2-byte
548
-      | \xE0[\xA0-\xBF][\x80-\xBF]         // excluding overlongs
549
-      | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  // straight 3-byte
550
-      | \xED[\x80-\x9F][\x80-\xBF]         // excluding surrogates
551
-      | \xF0[\x90-\xBF][\x80-\xBF]{2}      // planes 1-3
552
-      | [\xF1-\xF3][\x80-\xBF]{3}          // planes 4-15
553
-      | \xF4[\x80-\x8F][\x80-\xBF]{2}      // plane 16
554
-      )*$%xs',
549
+            [\x09\x0A\x0D\x20-\x7E]            // ASCII
550
+          | [\xC2-\xDF][\x80-\xBF]             // Non-overlong 2-byte
551
+          | \xE0[\xA0-\xBF][\x80-\xBF]         // Excluding overlongs
552
+          | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  // Straight 3-byte
553
+          | \xED[\x80-\x9F][\x80-\xBF]         // Excluding surrogates
554
+          | \xF0[\x90-\xBF][\x80-\xBF]{2}      // Planes 1-3
555
+          | [\xF1-\xF3][\x80-\xBF]{3}          // Planes 4-15
556
+          | \xF4[\x80-\x8F][\x80-\xBF]{2}      // Plane 16
557
+            )*$%xs',
555 558
             $Str
556 559
         );
557 560
     }

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

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 if (!extension_loaded('mysqli')) {
3 4
     error('Mysqli Extension not loaded.');
4 5
 }
@@ -15,7 +16,6 @@ class Sphinxql extends mysqli
15 16
     public static $Queries = [];
16 17
     public static $Time = 0.0;
17 18
 
18
-
19 19
     /**
20 20
      * Initialize Sphinxql object
21 21
      *

+ 1
- 0
classes/sphinxqlquery.class.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 class SphinxqlQuery
3 4
 {
4 5
     private $Sphinxql;

+ 1
- 0
classes/sphinxqlresult.class.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 class SphinxqlResult
3 4
 {
4 5
     private $Result;

+ 63
- 42
classes/torrents.class.php View File

@@ -60,7 +60,7 @@ class Torrents
60 60
                 continue;
61 61
             }
62 62
             $Data = G::$Cache->get_value($Key . $GroupID, true);
63
-            if (!empty($Data) && is_array($Data) && $Data['ver'] == Cache::GROUP_VERSION) {
63
+            if (!empty($Data) && is_array($Data) && $Data['ver'] === Cache::GROUP_VERSION) {
64 64
                 unset($NotFound[$GroupID]);
65 65
                 $Found[$GroupID] = $Data['d'];
66 66
             }
@@ -83,10 +83,10 @@ class Torrents
83 83
             $NotFound = [];
84 84
             $QueryID = G::$DB->get_query_id();
85 85
             G::$DB->query("
86
-        SELECT
87
-          ID, Name, NameRJ, NameJP, Year, CatalogueNumber, Pages, Studio, Series, DLSiteID, TagList, WikiImage, CategoryID
88
-        FROM torrents_group
89
-        WHERE ID IN ($IDs)");
86
+                SELECT
87
+                 ID, Name, NameRJ, NameJP, Year, CatalogueNumber, Pages, Studio, Series, DLSiteID, TagList, WikiImage, CategoryID
88
+                FROM torrents_group
89
+                WHERE ID IN ($IDs)");
90 90
 
91 91
             while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
92 92
                 $NotFound[$Group['ID']] = $Group;
@@ -115,15 +115,15 @@ class Torrents
115 115
             if ($Torrents) {
116 116
                 $QueryID = G::$DB->get_query_id();
117 117
                 G::$DB->query("
118
-          SELECT
119
-            ID, GroupID, Media, Container, Codec, Resolution, AudioFormat,
120
-            Language, Subbing, Subber, Censored, Archive, FileCount, FreeTorrent,
121
-            Size, Leechers, Seeders, Snatched, Time, f.ExpiryTime, ID AS HasFile,
122
-            FreeLeechType, hex(info_hash) as info_hash
123
-          FROM torrents
124
-          LEFT JOIN shop_freeleeches AS f ON f.TorrentID=ID
125
-          WHERE GroupID IN ($IDs)
126
-          ORDER BY GroupID, Media, Container, Codec, ID");
118
+                    SELECT
119
+                      ID, GroupID, Media, Container, Codec, Resolution, AudioFormat,
120
+                      Language, Subbing, Subber, Censored, Archive, FileCount, FreeTorrent,
121
+                      Size, Leechers, Seeders, Snatched, Time, f.ExpiryTime, ID AS HasFile,
122
+                      FreeLeechType, hex(info_hash) as info_hash
123
+                    FROM torrents
124
+                      LEFT JOIN shop_freeleeches AS f ON f.TorrentID=ID
125
+                    WHERE GroupID IN ($IDs)
126
+                    ORDER BY GroupID, Media, Container, Codec, ID");
127 127
                 while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
128 128
                     $NotFound[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
129 129
                 }
@@ -137,7 +137,7 @@ class Torrents
137 137
             $Found = $NotFound + $Found;
138 138
         }
139 139
 
140
-        // Filter out orphans (elements that are == false)
140
+        // Filter out orphans (elements that are === false)
141 141
         $Found = array_filter($Found);
142 142
 
143 143
         if ($GetArtists) {
@@ -208,20 +208,25 @@ class Torrents
208 208
      */
209 209
     public static function torrent_properties(&$Torrent, &$Flags)
210 210
     {
211
+        # FL Token
211 212
         $Torrent['PersonalFL'] = empty($Torrent['FreeTorrent']) && self::has_token($Torrent['ID']);
212
-        if ($Torrent['IsSnatched'] = self::has_snatched($Torrent['ID'])) {
213
+
214
+        # Snatched
215
+        if ($Torrent['IsSnatched'] === self::has_snatched($Torrent['ID'])) {
213 216
             $Flags['IsSnatched'] = true;
214 217
         } else {
215 218
             $Flags['IsSnatched'] = false;
216 219
         }
217 220
 
218
-        if ($Torrent['IsSeeding'] = self::is_seeding($Torrent['ID'])) {
221
+        # Seeding
222
+        if ($Torrent['IsSeeding'] === self::is_seeding($Torrent['ID'])) {
219 223
             $Flags['IsSeeding'] = true;
220 224
         } else {
221 225
             $Flags['IsSeeding'] = false;
222 226
         }
223 227
 
224
-        if ($Torrent['IsLeeching'] = self::is_leeching($Torrent['ID'])) {
228
+        # Leeching
229
+        if ($Torrent['IsLeeching'] === self::is_leeching($Torrent['ID'])) {
225 230
             $Flags['IsLeeching'] = true;
226 231
         } else {
227 232
             $Flags['IsLeeching'] = false;
@@ -664,23 +669,45 @@ class Torrents
664 669
     public static function torrent_info($Data, $ShowMedia = true, $ShowEdition = false, $HTMLy = true)
665 670
     {
666 671
         $Info = [];
672
+
673
+        # Platform
667 674
         if ($ShowMedia && !empty($Data['Media'])) {
668
-            $Info[] = $Data['Media'];
675
+            $Info[] = display_str($Data['Media']);
669 676
         }
677
+
678
+        # Format
670 679
         if (!empty($Data['Container'])) {
671
-            $Info[] = $Data['Container'];
680
+            $Info[] = display_str($Data['Container']);
672 681
         }
673
-        if (!empty($Data['Codec'])) {
674
-            $Info[] = $Data['Codec'];
682
+
683
+        # Archive
684
+        if (!empty($Data['Archive'])) {
685
+            $Info[] = display_str($Data['Archive']);
675 686
         }
687
+
688
+        # Resolution
676 689
         if (!empty($Data['Resolution'])) {
677
-            $Info[] = $Data['Resolution'];
690
+            $Info[] = display_str($Data['Resolution']);
691
+        }
692
+        
693
+        # License
694
+        if (!empty($Data['Codec'])) {
695
+            $Info[] = display_str($Data['Codec']);
696
+        }
697
+
698
+        # Alignned/Annotated
699
+        if ($Data['Censored'] === 1) {
700
+            $Info[] = 'Aligned';
701
+        } else {
702
+            $Info[] = 'Unaligned';
678 703
         }
704
+
679 705
         /*
680 706
         if (!empty($Data['AudioFormat'])) {
681 707
           $Info[] = $Data['AudioFormat'];
682 708
         }
683 709
         */
710
+
684 711
         /*
685 712
         if (!empty($Data['Language'])) {
686 713
           if (!empty($Data['Subber']) && isset($Data['CategoryID']) && ($Data['CategoryID'] == 3 || $Data['CategoryID'] == 4)) {
@@ -690,6 +717,7 @@ class Torrents
690 717
           }
691 718
         }
692 719
         */
720
+
693 721
         /*
694 722
         if (!empty($Data['Subbing'])) {
695 723
           if (!empty($Data['Subber'])) {
@@ -701,38 +729,31 @@ class Torrents
701 729
           }
702 730
         }
703 731
         */
704
-        if (!empty($Data['Archive'])) {
705
-            $Info[] = $Data['Archive'];
706
-        }
707
-        if ($Data['Censored'] === 1) {
708
-            $Info[] = 'Aligned';
709
-        } else {
710
-            $Info[] = 'Unaligned';
711
-        }
732
+
712 733
         if ($Data['IsLeeching']) {
713
-            $Info[] = $HTMLy ? Format::torrent_label('Leeching') : 'Leeching';
734
+            $Info[] = $HTMLy ? Format::torrent_label('Leeching', 'important_text') : 'Leeching';
714 735
         } elseif ($Data['IsSeeding']) {
715
-            $Info[] = $HTMLy ? Format::torrent_label('Seeding') : 'Seeding';
736
+            $Info[] = $HTMLy ? Format::torrent_label('Seeding', 'important_text_alt') : 'Seeding';
716 737
         } elseif ($Data['IsSnatched']) {
717
-            $Info[] = $HTMLy ? Format::torrent_label('Snatched') : 'Snatched';
738
+            $Info[] = $HTMLy ? Format::torrent_label('Snatched', 'bold') : 'Snatched';
718 739
         }
719
-        # todo: Check strict equality
720
-        if ($Data['FreeTorrent'] == '1') {
721
-            if ($Data['FreeLeechType'] == '3') {
740
+
741
+        if ($Data['FreeTorrent'] === '1') {
742
+            if ($Data['FreeLeechType'] === '3') {
722 743
                 if ($Data['ExpiryTime']) {
723
-                    $Info[] = ($HTMLy ? Format::torrent_label('Freeleech!') : 'Freeleech!') . ($HTMLy ? " <strong>(" : " (") . str_replace(['week','day','hour','min','Just now','s',' '], ['w','d','h','m','0m'], time_diff(max(strtotime($Data['ExpiryTime']), time()), 1, false)) . ($HTMLy ? ")</strong>" : ")");
744
+                    $Info[] = ($HTMLy ? Format::torrent_label('Freeleech!', 'important_text_alt') : 'Freeleech!') . ($HTMLy ? " <strong>(" : " (") . str_replace(['week','day','hour','min','Just now','s',' '], ['w','d','h','m','0m'], time_diff(max(strtotime($Data['ExpiryTime']), time()), 1, false)) . ($HTMLy ? ")</strong>" : ")");
724 745
                 } else {
725
-                    $Info[] = $HTMLy ? Format::torrent_label('Freeleech!') : 'Freeleech!';
746
+                    $Info[] = $HTMLy ? Format::torrent_label('Freeleech!', 'important_text_alt') : 'Freeleech!';
726 747
                 }
727 748
             } else {
728
-                $Info[] = $HTMLy ? Format::torrent_label('Freeleech!') : 'Freeleech!';
749
+                $Info[] = $HTMLy ? Format::torrent_label('Freeleech!', 'important_text_alt') : 'Freeleech!';
729 750
             }
730 751
         }
731 752
         if ($Data['FreeTorrent'] == '2') {
732
-            $Info[] = $HTMLy ? Format::torrent_label('Neutral Leech!') : 'Neutral Leech!';
753
+            $Info[] = $HTMLy ? Format::torrent_label('Neutral Leech!', 'bold') : 'Neutral Leech!';
733 754
         }
734 755
         if ($Data['PersonalFL']) {
735
-            $Info[] = $HTMLy ? Format::torrent_label('Personal Freeleech!') : 'Personal Freeleech!';
756
+            $Info[] = $HTMLy ? Format::torrent_label('Personal Freeleech!', 'important_text_alt') : 'Personal Freeleech!';
736 757
         }
737 758
         return implode(' / ', $Info);
738 759
     }

+ 24
- 19
classes/torrentsearch.class.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 class TorrentSearch
3 4
 {
4 5
     const TAGS_ANY = 0;
@@ -50,26 +51,28 @@ class TorrentSearch
50 51
 
51 52
     // List of fields that can be used for fulltext searches
52 53
     private static $Fields = [
53
-    'artistname' => 1,
54
-    'audioformat' => 1,
55
-    'cataloguenumber' => 1,
56
-    'codec' => 1,
57
-    'container' => 1,
58
-    'description' => 1,
59
-    #'dlsiteid' => 1,
54
+    'artistname' => 1, # Author
55
+    'audioformat' => 1, # Version
56
+    'cataloguenumber' => 1, # Accession Number
57
+    'numbers' => 1, # Combined ↑
58
+    'codec' => 1, # License
59
+    'container' => 1, # Format
60
+    'description' => 1, # Not group desc
61
+    'dlsiteid' => 1,
60 62
     'filelist' => 1,
61
-    'groupname' => 1,
62
-    'groupnamerj' => 1,
63
-    'groupnamejp' => 1,
63
+    'groupname' => 1, # Title
64
+    'groupnamerj' => 1, # Organism
65
+    'groupnamejp' => 1, # Strain
64 66
     'advgroupname' => 1,
65
-    #'language' => 1,
66
-    'media' => 1,
67
-    'resolution' => 1,
67
+    'language' => 1,
68
+    'media' => 1, # Platform
69
+    'resolution' => 1, # Assembly Level
68 70
     'searchstr' => 1,
69
-    'series' => 1,
70
-    'studio' => 1,
71
-    #'subber' => 1,
72
-    #'subbing' => 1,
71
+    'series' => 1, # Location
72
+    'studio' => 1, # Department/Lab
73
+    'location' => 1,
74
+    'subber' => 1,
75
+    'subbing' => 1,
73 76
     'taglist' => 1
74 77
   ];
75 78
 
@@ -86,9 +89,11 @@ class TorrentSearch
86 89
 
87 90
     // Some form field names don't match the ones in the index
88 91
     private static $FormsToFields = [
89
-        # todo: Make these filters significantly less broad
92
+        # todo: Keep testing the granularity of filter combos
90 93
         'searchstr' => '*',
91
-        'advgroupname' => '*'
94
+        'advgroupname' => '*', # todo: Fix this ;)
95
+        'numbers' => '(cataloguenumber,audioformat)',
96
+        'location' => '(studio,series)'
92 97
         #'searchstr' => '(groupname,groupnamerj,groupnamejp,artistname,studio,series,dlsiteid,cataloguenumber,yearfulltext)',
93 98
         #'advgroupname' => '(groupname,groupnamerj,groupnamejp)'
94 99
   ];

+ 562
- 448
sections/artist/artist.php
File diff suppressed because it is too large
View File


+ 167
- 77
sections/torrents/browse.php View File

@@ -25,7 +25,7 @@ if (!empty($_GET['searchstr']) || !empty($_GET['groupname'])) {
25 25
         $InfoHash = $_GET['groupname'];
26 26
     }
27 27
 
28
-    // Search by infohash
28
+    // Search by info hash
29 29
     if ($InfoHash = is_valid_torrenthash($InfoHash)) {
30 30
         $InfoHash = db_string(pack('H*', $InfoHash));
31 31
         $DB->query("
@@ -111,15 +111,22 @@ if (empty($_GET['order_by']) || !isset(TorrentSearch::$SortOrders[$_GET['order_b
111 111
 
112 112
 $Page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
113 113
 $Search = new TorrentSearch($GroupResults, $OrderBy, $OrderWay, $Page, TORRENTS_PER_PAGE);
114
+
115
+# Three profile toggle options
114 116
 if (isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] === 1) {
115 117
     $Search->insert_hidden_tags('!lolicon !shotacon !toddlercon');
116 118
 }
119
+
120
+# 2
117 121
 if (isset($LoggedUser['HideScat']) && $LoggedUser['HideScat'] === 1) {
118 122
     $Search->insert_hidden_tags('!scat');
119 123
 }
124
+
125
+# 3
120 126
 if (isset($LoggedUser['HideSnuff']) && $LoggedUser['HideSnuff'] === 1) {
121 127
     $Search->insert_hidden_tags('!snuff');
122 128
 }
129
+
123 130
 $Results = $Search->query($_GET);
124 131
 $Groups = $Search->get_groups();
125 132
 $NumResults = $Search->record_count();
@@ -140,9 +147,11 @@ if ($AdvancedSearch) {
140 147
 }
141 148
 
142 149
 # Start the search form
150
+# Fortunately it's very easy to search via
151
+# torrentsearch.class.php
143 152
 View::show_header('Browse Torrents', 'browse');
144
-
145 153
 ?>
154
+
146 155
 <div class="thin widethin">
147 156
   <div class="header">
148 157
     <h2>Torrents</h2>
@@ -162,35 +171,42 @@ View::show_header('Browse Torrents', 'browse');
162 171
       </div>
163 172
       <div id="ft_container"
164 173
         class="pad<?=$HideFilter ? ' hidden' : ''?>">
165
-        <?php if ((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] === 1)
166
-   || (isset($LoggedUser['HideScat'])    && $LoggedUser['HideScat']    === 1)
167
-   || (isset($LoggedUser['HideSnuff'])   && $LoggedUser['HideSnuff']   === 1)
168
-   ) { ?>
174
+        <?php
175
+        # Three profile toggles
176
+        if ((isset($LoggedUser['HideLolicon']) && $LoggedUser['HideLolicon'] === 1)
177
+         || (isset($LoggedUser['HideScat'])    && $LoggedUser['HideScat']    === 1)
178
+         || (isset($LoggedUser['HideSnuff'])   && $LoggedUser['HideSnuff']   === 1)
179
+        ) { ?>
169 180
         <svg title="Your profile settings exclude some results" class="search_warning tooltip" width="10" height="15">
170 181
           <rect x=3 width="4" height="10" rx="2" ry="2" />
171 182
           <circle cx="5" cy="13" r="2" /></svg>
172
-        <?php } ?>
183
+        <?php
184
+        } ?>
185
+
173 186
         <table class="layout">
174
-          <tr id="catalogue_number"
187
+          <tr id="numbers"
175 188
             class="ftr_advanced<?=$HideAdvanced?>">
176 189
             <td class="label">
177
-              <!-- Catalogue Number -->
190
+              <!--
191
+                Catalogue Number / AudioFormat
192
+                Accession Number / Version
193
+              -->
178 194
             </td>
179
-            <td class="ft_cataloguenumber">
180
-              <input type="search" size="19" name="cataloguenumber" class="inputtext smallest fti_advanced"
181
-                placeholder="Accession Number"
182
-                value="<?Format::form('cataloguenumber')?>" />
195
+            <td class="ft_numbers">
196
+              <input type="search" size="30" name="numbers" class="inputtext smallest fti_advanced"
197
+                placeholder="Accession Number / Version"
198
+                value="<?Format::form('numbers')?>" />
183 199
             </td>
184 200
           </tr>
185 201
 
186 202
           <tr id="album_torrent_name"
187 203
             class="ftr_advanced<?=$HideAdvanced?>">
188 204
             <td class="label">
189
-              <!-- Torrent Name -->
205
+              <!-- Torrent Title / Organism / Strain or Variety -->
190 206
             </td>
191 207
             <td class="ft_groupname">
192 208
               <input type="search" spellcheck="false" size="65" name="advgroupname"
193
-                class="inputtext smaller fti_advanced" placeholder="Torrent Title"
209
+                class="inputtext smaller fti_advanced" placeholder="Torrent Title / Organism / Strain or Variety"
194 210
                 value="<?Format::form('advgroupname')?>" />
195 211
             </td>
196 212
           </tr>
@@ -202,20 +218,26 @@ View::show_header('Browse Torrents', 'browse');
202 218
             </td>
203 219
             <td class="ft_artistname">
204 220
               <input type="search" spellcheck="false" size="65" id="artist" name="artistname"
205
-                class="inputtext smaller fti_advanced" placeholder="Author Name"
221
+                class="inputtext smaller fti_advanced" placeholder="Author (ORCiD pending)"
206 222
                 value="<?Format::form('artistname')?>"
207 223
                 <?php Users::has_autocomplete_enabled('other'); ?>/>
208 224
             </td>
209 225
           </tr>
210 226
 
211
-          <tr id="year" class="ftr_advanced<?=$HideAdvanced?>">
227
+          <tr id="location" class="ftr_advanced<?=$HideAdvanced?>">
212 228
             <td class="label">
213
-              <!-- Year -->
229
+              <!-- Studio / Series -->
214 230
             </td>
215
-            <td class="ft_year">
231
+            <td class="ft_location">
232
+              <input type="search" name="location" class="inputtext smallest fti_advanced"
233
+                placeholder="Department or Lab / Location"
234
+                value="<?Format::form('location')?>"
235
+                size="40" />
236
+
237
+              <!-- Year -->
216 238
               <input type="search" name="year" class="inputtext smallest fti_advanced" placeholder="Year"
217 239
                 value="<?Format::form('year')?>"
218
-                size="12" />
240
+                size="20" />
219 241
             </td>
220 242
           </tr>
221 243
 
@@ -239,7 +261,8 @@ View::show_header('Browse Torrents', 'browse');
239 261
             <td class="ft_filelist">
240 262
               <input type="search" spellcheck="false" size="65" name="filelist" class="inputtext fti_advanced"
241 263
                 placeholder="File List"
242
-                value="<?Format::form('filelist')?>" />
264
+                value="<?Format::form('filelist')?>" /><br /><br />
265
+              Universal Search finds info hashes
243 266
             </td>
244 267
           </tr>
245 268
 
@@ -252,7 +275,7 @@ View::show_header('Browse Torrents', 'browse');
252 275
               <select name="media" class="ft_media fti_advanced">
253 276
                 <option value="">Sequencing</option>
254 277
                 <?php  foreach ($Media as $MediaName) { ?>
255
-                <option value="<?=display_str($MediaName); ?>"
278
+                <option value="<?=display_str($MediaName); # pcs-comment-start; keep quote ?>"
256 279
                 <?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?>
257 280
                 </option>
258 281
                 <?php  } ?>
@@ -261,7 +284,7 @@ View::show_header('Browse Torrents', 'browse');
261 284
               <select name="media" class="ft_media fti_advanced">
262 285
                 <option value="">Imaging</option>
263 286
                 <?php  foreach ($MediaManga as $MediaName) { ?>
264
-                <option value="<?=display_str($MediaName); ?>"
287
+                <option value="<?=display_str($MediaName); # pcs-comment-start; keep quote ?>"
265 288
                 <?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?>
266 289
                 </option>
267 290
                 <?php  } ?>
@@ -275,36 +298,40 @@ View::show_header('Browse Torrents', 'browse');
275 298
             <td class="label">Formats</td>
276 299
             <td class="nobr ft_ripspecifics">
277 300
 
301
+              <!-- 1 -->
278 302
               <select id=" container" name="container" class="ft_container fti_advanced">
279 303
                 <option value="">DNA/RNA</option>
280
-                <?php  foreach ($Containers as $Key => $Container) { ?>
304
+                <?php foreach ($Containers as $Key => $Container) { ?>
281 305
                 <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
282 306
                 </option>
283
-                <?php  } ?>
307
+                <?php } ?>
284 308
               </select>
285 309
 
310
+              <!-- 2 -->
286 311
               <select id=" container" name="container" class="ft_container fti_advanced">
287 312
                 <option value="">Proteins</option>
288
-                <?php  foreach ($ContainersProt as $Key => $Container) { ?>
313
+                <?php foreach ($ContainersProt as $Key => $Container) { ?>
289 314
                 <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
290 315
                 </option>
291
-                <?php  } ?>
316
+                <?php } ?>
292 317
               </select>
293 318
 
319
+              <!-- 3 -->
294 320
               <select id=" container" name="container" class="ft_container fti_advanced">
295 321
                 <option value="">Imaging</option>
296
-                <?php  foreach ($ContainersGames as $Key => $Container) { ?>
322
+                <?php foreach ($ContainersGames as $Key => $Container) { ?>
297 323
                 <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
298 324
                 </option>
299
-                <?php  } ?>
325
+                <?php } ?>
300 326
               </select>
301 327
 
328
+              <!-- 4 -->
302 329
               <select id=" container" name="container" class="ft_container fti_advanced">
303 330
                 <option value="">Extras</option>
304
-                <?php  foreach ($ContainersExtra as $Key => $Container) { ?>
305
-                <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
331
+                <?php foreach ($ContainersExtra as $Key => $Container) { ?>
332
+                  <option value="<?=display_str($Key);?>" <?Format::selected('container', $Key)?>><?=display_str($Key);?>
306 333
                 </option>
307
-                <?php  } ?>
334
+                <?php } ?>
308 335
               </select>
309 336
             </td>
310 337
           </tr>
@@ -317,12 +344,13 @@ View::show_header('Browse Torrents', 'browse');
317 344
               <select name="resolution" class="ft_resolution fti_advanced">
318 345
                 <option value="">Assembly Level</option>
319 346
                 <?php  foreach ($Resolutions as $Resolution) { ?>
320
-                <option value="<?=display_str($Resolution); ?>"
347
+                <option value="<?=display_str($Resolution); # pcs-comment-start; keep quote ?>"
321 348
                 <?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?>
322 349
                 </option>
323 350
                 <?php  } ?>
324 351
               </select>
325 352
 
353
+              <!-- Aligned/Censored -->
326 354
               <select name=" censored" class="ft_censored fti_advanced">
327 355
                 <option value="">Alignment</option>
328 356
                 <option value="1" <?Format::selected('censored', 1)?>>Aligned
@@ -331,6 +359,7 @@ View::show_header('Browse Torrents', 'browse');
331 359
                 </option>
332 360
               </select>
333 361
 
362
+              <!-- Leech Status -->
334 363
               <select name="freetorrent" class="ft_freetorrent fti_advanced">
335 364
                 <option value="">Leech Status</option>
336 365
                 <option value="1" <?Format::selected('freetorrent', 1)?>>Freeleech
@@ -343,6 +372,7 @@ View::show_header('Browse Torrents', 'browse');
343 372
                 </option>
344 373
               </select>
345 374
 
375
+              <!-- Codec/License -->
346 376
               <select name="codec" class="ft_codec fti_advanced">
347 377
                 <option value="">License</option>
348 378
                 <?php  foreach ($Codecs as $Codec) { ?>
@@ -383,11 +413,11 @@ View::show_header('Browse Torrents', 'browse');
383 413
           <!-- Start basic search options -->
384 414
           <tr id="search_terms" class="ftr_basic<?=$HideBasic?>">
385 415
             <td class="label">
386
-              <!-- Search Terms -->
416
+              <!-- Universal Search -->
387 417
             </td>
388 418
             <td class="ftb_searchstr">
389 419
               <input type="search" spellcheck="false" size="48" name="searchstr" class="inputtext fti_basic"
390
-                placeholder="Search Terms"
420
+                placeholder="Universal Search"
391 421
                 value="<?Format::form('searchstr')?>"
392 422
                 aria-label="Terms to search">
393 423
             </td>
@@ -411,6 +441,7 @@ View::show_header('Browse Torrents', 'browse');
411 441
             </td>
412 442
           </tr>
413 443
 
444
+          <!-- Order By -->
414 445
           <tr id="order">
415 446
             <td class="label">Order By</td>
416 447
             <td class="ft_order">
@@ -442,6 +473,7 @@ View::show_header('Browse Torrents', 'browse');
442 473
             </td>
443 474
           </tr>
444 475
 
476
+          <!-- Use torrent groups? -->
445 477
           <tr id="search_group_results">
446 478
             <td class="label">
447 479
               <label for="group_results">Group Torrents</label>
@@ -455,19 +487,19 @@ View::show_header('Browse Torrents', 'browse');
455 487
 
456 488
         <table class="layout cat_list ft_cat_list">
457 489
           <?php
458
-  $x = 0;
459
-  reset($Categories);
460
-  foreach ($Categories as $CatKey => $CatName) {
461
-      if ($x % 7 === 0) {
462
-          if ($x > 0) {
463
-              ?>
490
+            $x = 0;
491
+            reset($Categories);
492
+            foreach ($Categories as $CatKey => $CatName) {
493
+                if ($x % 7 === 0) {
494
+                    if ($x > 0) {
495
+                        ?>
464 496
           </tr>
465 497
           <?php
466
-          } ?>
498
+                    } ?>
467 499
           <tr>
468 500
             <?php
469
-      }
470
-      $x++; ?>
501
+                }
502
+                $x++; ?>
471 503
             <td>
472 504
               <input type="checkbox"
473 505
                 name="filter_cat[<?=($CatKey + 1)?>]"
@@ -476,8 +508,7 @@ View::show_header('Browse Torrents', 'browse');
476 508
               <label for="cat_<?=($CatKey + 1)?>"><?=$CatName?></label>
477 509
             </td>
478 510
             <?php
479
-  }
480
-  ?>
511
+            } ?>
481 512
           </tr>
482 513
         </table>
483 514
         <table
@@ -490,7 +521,7 @@ View::show_header('Browse Torrents', 'browse');
490 521
       $DB->query('
491 522
       SELECT Name
492 523
       FROM tags
493
-      WHERE TagType = \'genre\'
524
+        WHERE TagType = \'genre\'
494 525
       ORDER BY Name');
495 526
       $GenreTags = $DB->collect('Name');
496 527
       $Cache->cache_value('genre_tags', $GenreTags, 3600 * 6);
@@ -516,6 +547,8 @@ View::show_header('Browse Torrents', 'browse');
516 547
             <?php } ?>
517 548
           </tr>
518 549
         </table>
550
+
551
+        <!-- Categories -->
519 552
         <table class="layout cat_list">
520 553
           <tr>
521 554
             <td class="label">
@@ -524,6 +557,8 @@ View::show_header('Browse Torrents', 'browse');
524 557
             </td>
525 558
           </tr>
526 559
         </table>
560
+
561
+        <!-- Result count and submit button -->
527 562
         <div class="submit ft_submit">
528 563
           <span class="float_left"><?=number_format($NumResults)?>
529 564
             Results</span>
@@ -534,21 +569,23 @@ View::show_header('Browse Torrents', 'browse');
534 569
           <input type="button" value="Reset"
535 570
             onclick="location.href = 'torrents.php<?php if (isset($_GET['action']) && $_GET['action'] === 'advanced') { ?>?action=advanced<?php } ?>'" />
536 571
           &nbsp;&nbsp;
537
-          <?php    if ($Search->has_filters()) { ?>
572
+          <?php if ($Search->has_filters()) { ?>
538 573
           <input type="submit" name="setdefault" value="Make Default" />
539
-          <?php    }
574
+          <?php }
540 575
 
541 576
       if (!empty($LoggedUser['DefaultSearch'])) { ?>
542 577
           <input type="submit" name="cleardefault" value="Clear Default" />
543
-          <?php    } ?>
578
+          <?php } ?>
544 579
         </div>
545 580
       </div>
546 581
     </div>
547 582
   </form>
583
+
584
+  <!-- No results message -->
548 585
   <?php if ($NumResults === 0) { ?>
549 586
   <div class="torrents_nomatch box pad" align="center">
550
-    <h2>Your search did not match anything.</h2>
551
-    <p>Make sure all names are spelled correctly, or try making your search less specific.</p>
587
+    <h2>Your search did not match anything</h2>
588
+    <p>Make sure all names are spelled correctly, or try making your search less specific</p>
552 589
   </div>
553 590
 </div>
554 591
 <?php
@@ -559,14 +596,17 @@ die();
559 596
   if ($NumResults < ($Page - 1) * TORRENTS_PER_PAGE + 1) {
560 597
       $LastPage = ceil($NumResults / TORRENTS_PER_PAGE);
561 598
       $Pages = Format::get_pages(0, $NumResults, TORRENTS_PER_PAGE); ?>
599
+
562 600
 <div class="torrents_nomatch box pad" align="center">
563
-  <h2>The requested page contains no matches.</h2>
601
+  <h2>The requested page contains no matches</h2>
564 602
   <p>You are requesting page <?=$Page?>, but the search returned only
565
-    <?=number_format($LastPage) ?> pages.</p>
603
+    <?=number_format($LastPage) ?> pages</p>
566 604
 </div>
605
+
567 606
 <div class="linkbox">Go to page <?=$Pages?>
568 607
 </div>
569 608
 </div>
609
+
570 610
 <?php
571 611
     View::show_footer();
572 612
       die();
@@ -581,6 +621,7 @@ die();
581 621
 <div class="linkbox"><?=$Pages?>
582 622
 </div>
583 623
 
624
+<!-- Results table headings -->
584 625
 <table
585 626
   class="box torrent_table cats <?=$GroupResults ? 'grouping' : 'no_grouping'?>"
586 627
   id="torrent_table">
@@ -669,28 +710,44 @@ die();
669 710
           // These torrents are in a group
670 711
           $CoverArt = $GroupInfo['WikiImage'];
671 712
           $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
713
+
714
+          # No cover art
672 715
           if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
673 716
               $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
674 717
           }
718
+
719
+          # Japanese
675 720
           $DisplayName .= "dir=\"ltr\">$GroupName</a>";
721
+
722
+          # Year
676 723
           if ($GroupYear) {
677
-              $DisplayName .= " [$GroupYear]";
724
+              $DisplayName .= "<br />$GroupYear";
678 725
           }
726
+        
727
+          # Studio
679 728
           if ($GroupStudio) {
680
-              $DisplayName .= " [$GroupStudio]";
729
+              $DisplayName .= " / $GroupStudio";
681 730
           }
731
+
732
+          # Catalogue Number
682 733
           if ($GroupCatalogueNumber) {
683
-              $DisplayName .= " [$GroupCatalogueNumber]";
734
+              $DisplayName .= " / $GroupCatalogueNumber";
684 735
           }
736
+
737
+          /*
685 738
           if ($GroupPages) {
686 739
               $DisplayName .= " [{$GroupPages}p]";
687 740
           }
741
+          */
742
+
743
+          /*
688 744
           if ($GroupDLsiteID) {
689 745
               $DisplayName .= " [$GroupDLsiteID]";
690
-          } ?>
746
+          }
747
+          */ ?>
691 748
   <tr class="group<?=$SnatchedGroupClass?>">
692 749
     <?php
693
-$ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
750
+      $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
694 751
     <td class="center">
695 752
       <div id="showimg_<?=$GroupID?>"
696 753
         class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
@@ -699,14 +756,19 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
699 756
           title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
700 757
       </div>
701 758
     </td>
759
+
760
+    <!-- Category icon -->
702 761
     <td class="center cats_col">
703 762
       <div title="<?=Format::pretty_category($CategoryID)?>"
704 763
         class="tooltip <?=Format::css_category($CategoryID)?>">
705 764
       </div>
706 765
     </td>
766
+
767
+    <!-- [ DL | RP ] and [Bookmark] -->
707 768
     <td colspan="2" class="big_info">
708 769
       <div class="group_info clear">
709 770
         <?=$DisplayName?>
771
+
710 772
         <?php  if (in_array($GroupID, $Bookmarks)) { ?>
711 773
         <span class="remove_bookmark float_right">
712 774
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
@@ -714,6 +776,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
714 776
             onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
715 777
             bookmark</a>
716 778
         </span>
779
+
717 780
         <?php  } else { ?>
718 781
         <span class="add_bookmark float_right">
719 782
           <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
@@ -722,14 +785,21 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
722 785
         </span>
723 786
         <?php  } ?>
724 787
         <br />
788
+
789
+        <!-- Tags -->
725 790
         <div class="tags"><?=$TorrentTags->format('torrents.php?'.$Action.'&amp;taglist=')?>
726 791
         </div>
727 792
       </div>
728 793
     </td>
794
+
795
+    <!-- Time -->
729 796
     <td class="nobr"><?=time_diff($GroupTime, 1)?>
730 797
     </td>
731
-    <td class="number_column nobr"><?=Format::get_size($MaxSize)?>
732
-      (Max)</td>
798
+
799
+    <!-- Size -->
800
+    <td class="number_column nobr"><?=Format::get_size($MaxSize)?>(Max)</td>
801
+
802
+    <!-- Snatches, seeders, and leechers -->
733 803
     <td class="number_column"><?=number_format($TotalSnatched)?>
734 804
     </td>
735 805
     <td
@@ -739,6 +809,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
739 809
     <td class="number_column"><?=number_format($TotalLeechers)?>
740 810
     </td>
741 811
   </tr>
812
+
742 813
   <?php
743 814
     foreach ($Torrents as $TorrentID => $Data) {
744 815
         $Data['CategoryID'] = $CategoryID;
@@ -761,6 +832,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
761 832
                 $TorrentFileName = $Tor->Dec['info']['name'];
762 833
                 $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
763 834
             }
835
+            # Magnet link 1337 h4x
764 836
             $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'];
765 837
         } ?>
766 838
   <tr
@@ -769,16 +841,16 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
769 841
       <span>
770 842
         [ <a href="<?=$TorrentDL?>" class="tooltip"
771 843
           title="Download"><?=$Data['HasFile'] ? 'DL' : 'Missing'?></a>
772
-        <?php      if (isset($TorrentMG)) { ?>
844
+        <?php if (isset($TorrentMG)) { ?>
773 845
         | <a href="<?=$TorrentMG?>" class="tooltip"
774 846
           title="Magnet Link">MG</a>
775
-        <?php      }
847
+        <?php }
776 848
         if (Torrents::can_use_token($Data)) { ?>
777 849
         | <a
778 850
           href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
779 851
           class="tooltip" title="Use a FL Token"
780 852
           onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
781
-        <?php      } ?>
853
+        <?php } ?>
782 854
         | <a
783 855
           href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
784 856
           class="tooltip" title="Report">RP</a> ]
@@ -807,7 +879,6 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
807 879
     }
808 880
       } else {
809 881
           // Viewing a type that does not require grouping
810
-
811 882
           $TorrentID = key($Torrents);
812 883
           $Data = current($Torrents);
813 884
 
@@ -817,29 +888,47 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
817 888
               $Reported = true;
818 889
           }
819 890
 
891
+          # Main search result title link
820 892
           $Data['CategoryID'] = $CategoryID;
821 893
           $CoverArt = $GroupInfo['WikiImage'];
822 894
           $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
895
+
823 896
           if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
824 897
               $DisplayName .= 'data-cover="'.ImageTools::process($CoverArt, 'thumb').'" ';
825 898
           }
899
+
900
+          # Japanese
826 901
           $DisplayName .= "dir=\"ltr\">$GroupName</a>";
902
+
827 903
           if (isset($GroupedCategories[$CategoryID - 1])) {
904
+              # Year
905
+              # Sh!t h4x; Year is mandatory
828 906
               if ($GroupYear) {
829
-                  $DisplayName .= " [$GroupYear]";
907
+                  $DisplayName .= "<br /> $GroupYear";
830 908
               }
909
+
910
+              # Studio
831 911
               if ($GroupStudio) {
832
-                  $DisplayName .= " [$GroupStudio]";
912
+                  $DisplayName .= " &ndash; $GroupStudio";
833 913
               }
914
+
915
+              # Catalogue Number
834 916
               if ($GroupCatalogueNumber) {
835
-                  $DisplayName .= " [$GroupCatalogueNumber]";
917
+                  $DisplayName .= " &ndash; $GroupCatalogueNumber";
836 918
               }
919
+
920
+              /*
837 921
               if ($GroupPages) {
838 922
                   $DisplayName .= " [{$GroupPages}p]";
839 923
               }
924
+              */
925
+
926
+              /*
840 927
               if ($GroupDLsiteID) {
841 928
                   $DisplayName .= " [$GroupDLsiteID]";
842 929
               }
930
+              */
931
+              
843 932
               $ExtraInfo = Torrents::torrent_info($Data, true, true);
844 933
           } elseif ($Data['IsSnatched']) {
845 934
               $ExtraInfo = Format::torrent_label('Snatched!');
@@ -860,9 +949,9 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
860 949
           } ?>
861 950
   <tr
862 951
     class="torrent<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
863
-    <?php    if ($GroupResults) { ?>
952
+    <?php if ($GroupResults) { ?>
864 953
     <td></td>
865
-    <?php    } ?>
954
+    <?php } ?>
866 955
     <td class="center cats_col">
867 956
       <div title="<?=Format::pretty_category($CategoryID)?>"
868 957
         class="tooltip <?=Format::css_category($CategoryID)?>"></div>
@@ -873,35 +962,35 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
873 962
           <span>
874 963
             [ <a href="<?=$TorrentDL?>" class="tooltip"
875 964
               title="Download">DL</a>
876
-            <?php    if (isset($TorrentMG)) { ?>
965
+            <?php if (isset($TorrentMG)) { ?>
877 966
             | <a href="<?=$TorrentMG?>" class="tooltip"
878 967
               title="Magnet Link">MG</a>
879
-            <?php    }
968
+            <?php }
880 969
           if (Torrents::can_use_token($Data)) { ?>
881 970
             | <a
882 971
               href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
883 972
               class="tooltip" title="Use a FL Token"
884 973
               onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
885
-            <?php    } ?>
974
+            <?php } ?>
886 975
             | <a
887 976
               href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
888 977
               class="tooltip" title="Report">RP</a> ]
889 978
           </span>
890 979
           <br />
891
-          <?php  if (in_array($GroupID, $Bookmarks)) { ?>
980
+          <?php if (in_array($GroupID, $Bookmarks)) { ?>
892 981
           <span class="remove_bookmark float_right">
893 982
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
894 983
               class="brackets"
895 984
               onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
896 985
               bookmark</a>
897 986
           </span>
898
-          <?php  } else { ?>
987
+          <?php } else { ?>
899 988
           <span class="add_bookmark float_right">
900 989
             <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
901 990
               class="brackets"
902 991
               onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
903 992
           </span>
904
-          <?php  } ?>
993
+          <?php } ?>
905 994
         </div>
906 995
         <?=$DisplayName?>
907 996
         <br />
@@ -936,4 +1025,5 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
936 1025
 <div class="linkbox"><?=$Pages?>
937 1026
 </div>
938 1027
 </div>
939
-<?php View::show_footer();
1028
+<?php
1029
+View::show_footer();

+ 142
- 106
sections/torrents/details.php View File

@@ -1,9 +1,10 @@
1 1
 <?php
2 2
 
3
-function compare($X, $Y)
3
+function compare($x, $y)
4 4
 {
5
-    return($Y['name'] < $X['name']);
5
+    return($y['name'] < $x['name']);
6 6
 }
7
+
7 8
 define('MAX_PERS_COLLAGES', 3); // How many personal collages should be shown by default
8 9
 define('MAX_COLLAGES', 5); // How many normal collages should be shown by default
9 10
 
@@ -16,6 +17,7 @@ if (!empty($_GET['revisionid']) && is_number($_GET['revisionid'])) {
16 17
 
17 18
 include(SERVER_ROOT.'/sections/torrents/functions.php');
18 19
 include(SERVER_ROOT.'/classes/mediainfo.class.php');
20
+
19 21
 $TorrentCache = get_group_info($GroupID, true, $RevisionID);
20 22
 $TorrentDetails = $TorrentCache[0];
21 23
 $TorrentList = $TorrentCache[1];
@@ -34,19 +36,24 @@ if (!$GroupName) {
34 36
     }
35 37
 }
36 38
 
37
-$DisplayName = "<span dir='ltr'>$GroupName</span><br />";
39
+# Make the main headings
40
+$DisplayName = "$GroupName<br />";
38 41
 $AltName = $GroupName; // Goes in the alt text of the image
39 42
 $Title = $GroupName; // Goes in <title>
40 43
 $WikiBody = Text::full_format($WikiBody);
41 44
 
42 45
 $Artists = Artists::get_artist($GroupID);
43 46
 
44
-if ($GroupNameRJ && $GroupNameRJ != $GroupName) {
45
-    $DisplayName .= "<span dir='ltr'>$GroupNameRJ</span><br />";
47
+if ($GroupNameRJ && $GroupNameRJ !== $GroupName) {
48
+    $DisplayName .= "<em>$GroupNameRJ</em> ";
46 49
 }
47 50
 
48
-if ($GroupNameJP && $GroupNameJP != $GroupName) {
49
-    $DisplayName .= "<span dir='ltr'>$GroupNameJP</span><br />";
51
+if ($GroupNameJP && $GroupNameJP !== $GroupName) {
52
+    $DisplayName .= "$GroupNameJP";
53
+}
54
+
55
+if ($GroupNameRJ || $GroupNameJP) {
56
+    $DisplayName .= '<br />';
50 57
 }
51 58
 
52 59
 if ($Artists) {
@@ -60,29 +67,33 @@ if ($GroupCategoryID) {
60 67
 }
61 68
 
62 69
 if ($GroupYear > 0) {
63
-    $DisplayName .= " [$GroupYear]";
70
+    $DisplayName .= "$GroupYear";
64 71
     $AltName .= " [$GroupYear]";
65 72
     $Title .= " [$GroupYear]";
66 73
 }
67 74
 
68 75
 if ($GroupStudio) {
69
-    $DisplayName .= " [$GroupStudio]";
76
+    $DisplayName .= " &ndash; $GroupStudio";
70 77
 }
71 78
 
72 79
 if ($GroupCatalogueNumber) {
73
-    $DisplayName .= " [$GroupCatalogueNumber]";
80
+    $DisplayName .= "  &ndash; $GroupCatalogueNumber";
74 81
 }
75 82
 
83
+/*
76 84
 if ($GroupPages) {
77 85
     $DisplayName .= " [{$GroupPages}p]";
78 86
 }
87
+*/
79 88
 
89
+/*
80 90
 if ($GroupDLsiteID) {
81 91
     $DisplayName .= " [$GroupDLsiteID]";
82 92
 }
93
+*/
83 94
 
84 95
 $Tags = [];
85
-if ($TorrentTags != '') {
96
+if ($TorrentTags !== '') {
86 97
     $TorrentTags = explode('|', $TorrentTags);
87 98
     $TorrentTagIDs = explode('|', $TorrentTagIDs);
88 99
     $TorrentTagUserIDs = explode('|', $TorrentTagUserIDs);
@@ -104,7 +115,7 @@ if (!$CoverArt) {
104 115
     $DB->query("
105 116
     SELECT ID, Image, Summary, UserID, Time
106 117
     FROM cover_art
107
-    WHERE GroupID = '$GroupID'
118
+      WHERE GroupID = '$GroupID'
108 119
     ORDER BY Time ASC");
109 120
     $CoverArt = [];
110 121
     $CoverArt = $DB->to_array();
@@ -119,69 +130,71 @@ list($NumComments, $Page, $Thread, $LastRead) = Comments::load('torrents', $Grou
119 130
 // Start output
120 131
 View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,subscriptions');
121 132
 ?>
133
+
122 134
 <div class="thin">
123 135
   <div class="header">
124 136
     <h2><?=$DisplayName?>
125 137
     </h2>
126 138
     <div class="linkbox">
127
-      <?php  if (check_perms('site_edit_wiki')) { ?>
139
+      <?php if (check_perms('site_edit_wiki')) { ?>
128 140
       <a href="torrents.php?action=editgroup&amp;groupid=<?=$GroupID?>"
129 141
         class="brackets">Edit group</a>
130
-      <?php  } ?>
142
+      <?php } ?>
131 143
       <a href="torrents.php?action=history&amp;groupid=<?=$GroupID?>"
132 144
         class="brackets">View history</a>
133
-      <?php  if ($RevisionID && check_perms('site_edit_wiki')) { ?>
145
+      <?php if ($RevisionID && check_perms('site_edit_wiki')) { ?>
134 146
       <a href="torrents.php?action=revert&amp;groupid=<?=$GroupID ?>&amp;revisionid=<?=$RevisionID ?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
135 147
         class="brackets">Revert to this revision</a>
136 148
       <?php
137
-  }
138
-  if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
139
-      ?>
149
+      }
150
+      if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
151
+          ?>
140 152
       <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
141 153
         class="remove_bookmark brackets"
142 154
         onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove
143 155
         bookmark</a>
144 156
       <?php
145
-  } else { ?>
157
+      } else { ?>
146 158
       <a href="#" id="bookmarklink_torrent_<?=$GroupID?>"
147 159
         class="add_bookmark brackets"
148 160
         onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
149
-      <?php  } ?>
161
+      <?php } ?>
150 162
       <a href="#" id="subscribelink_torrents<?=$GroupID?>"
151 163
         class="brackets"
152 164
         onclick="SubscribeComments('torrents', <?=$GroupID?>); return false;"><?=Subscriptions::has_subscribed_comments('torrents', $GroupID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
153 165
       <?php
154
-  if ($Categories[$GroupCategoryID-1] == 'Movies' || $Categories[$GroupCategoryID-1] == 'Anime' || $Categories[$GroupCategoryID-1] == 'Manga' || $Categories[$GroupCategoryID-1] == 'Games') { ?>
166
+      # Remove category-specific options to add a new format
167
+      if ($Categories[$GroupCategoryID-1]) { ?>
155 168
       <a href="upload.php?groupid=<?=$GroupID?>" class="brackets">Add
156 169
         format</a>
157 170
       <?php
158
-  }
159
-  if (check_perms('site_submit_requests')) { ?>
171
+      }
172
+      if (check_perms('site_submit_requests')) { ?>
160 173
       <a href="requests.php?action=new&amp;groupid=<?=$GroupID?>"
161 174
         class="brackets">Request format</a>
162
-      <?php  } ?>
175
+      <?php } ?>
163 176
       <a href="torrents.php?action=grouplog&amp;groupid=<?=$GroupID?>"
164 177
         class="brackets">View log</a>
165 178
     </div>
166 179
   </div>
167
-  <?php /* Misc::display_recommend($GroupID, "torrent"); */ ?>
180
+  <?php Misc::display_recommend($GroupID, "torrent"); ?>
168 181
   <div class="sidebar">
169 182
     <div class="box box_image box_image_albumart box_albumart">
170 183
       <!-- .box_albumart deprecated -->
171 184
       <div class="head">
172 185
         <strong><?=(count($CoverArt) > 0 ? 'Pictures (' . (count($CoverArt) + 1) . ')' : 'Picture')?></strong>
173 186
         <?php
174
-      if (count($CoverArt) > 0) {
175
-          if (empty($LoggedUser['ShowExtraCovers'])) {
176
-              for ($Index = 0; $Index <= count($CoverArt); $Index++) { ?>
187
+        if (count($CoverArt) > 0) {
188
+            if (empty($LoggedUser['ShowExtraCovers'])) {
189
+                for ($Index = 0; $Index <= count($CoverArt); $Index++) { ?>
177 190
         <span id="cover_controls_<?=($Index)?>" <?=($Index > 0 ? ' style="display: none;"' : '')?>>
178
-          <?php            if ($Index == count($CoverArt)) { ?>
191
+          <?php if ($Index === count($CoverArt)) { ?>
179 192
           <a class="brackets prev_cover"
180 193
             data-gazelle-prev-cover="<?=($Index - 1)?>"
181 194
             href="#">Prev</a>
182 195
           <a class="brackets show_all_covers" href="#">Show all</a>
183 196
           <span class="brackets next_cover">Next</span>
184
-          <?php            } elseif ($Index > 0) { ?>
197
+          <?php } elseif ($Index > 0) { ?>
185 198
           <a class="brackets prev_cover"
186 199
             data-gazelle-prev-cover="<?=($Index - 1)?>"
187 200
             href="#">Prev</a>
@@ -189,33 +202,34 @@ View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,su
189 202
           <a class="brackets next_cover"
190 203
             data-gazelle-next-cover="<?=($Index + 1)?>"
191 204
             href="#">Next</a>
192
-          <?php            } elseif ($Index == 0 && count($CoverArt) > 0) { ?>
205
+          <?php } elseif ($Index === 0 && count($CoverArt) > 0) { ?>
193 206
           <span class="brackets prev_cover">Prev</span>
194 207
           <a class="brackets show_all_covers" href="#">Show all</a>
195 208
           <a class="brackets next_cover"
196 209
             data-gazelle-next-cover="<?=($Index + 1)?>"
197 210
             href="#">Next</a>
198
-          <?php            } ?>
211
+          <?php } ?>
199 212
         </span>
200 213
         <?php
201 214
           }
202
-          } else { ?>
215
+            } else { ?>
203 216
         <span>
204 217
           <a class="brackets show_all_covers" href="#">Hide</a>
205 218
         </span>
206 219
         <?php
220
+          }
207 221
         }
208
-      } ?>
222
+        ?>
209 223
       </div>
210 224
       <?php $Index = 0; ?>
211 225
       <div id="covers">
212 226
         <div id="cover_div_<?=$Index?>">
213
-          <?php  if ($WikiImage != '') { ?>
227
+          <?php if ($WikiImage !== '') { ?>
214 228
           <div><img width="100%" class="lightbox-init"
215 229
               src="<?=ImageTools::process($WikiImage, 'thumb')?>"
216 230
               lightbox-img="<?=ImageTools::process($WikiImage)?>"
217 231
               alt="<?=$AltName?>" /></div>
218
-          <?php  } else { ?>
232
+          <?php } else { ?>
219 233
           <div><img width="100%"
220 234
               src="<?=STATIC_SERVER?>common/noartwork/music.png"
221 235
               alt="<?=$Categories[$GroupCategoryID - 1]?>"
@@ -226,8 +240,9 @@ View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,su
226 240
 $Index++;
227 241
 ?>
228 242
         </div>
229
-        <?php      foreach ($CoverArt as $Cover) {
230
-    list($ImageID, $Image, $Summary, $AddedBy) = $Cover; ?>
243
+        <?php
244
+        foreach ($CoverArt as $Cover) {
245
+            list($ImageID, $Image, $Summary, $AddedBy) = $Cover; ?>
231 246
         <div id="cover_div_<?=$Index?>" <?=(empty($LoggedUser['ShowExtraCovers']) ? ' style="display: none;"' : '')?>>
232 247
           <div>
233 248
             <?php
@@ -244,18 +259,18 @@ $Index++;
244 259
               <?=$Summary?>
245 260
               <?=(check_perms('users_mod') ? ' added by ' . Users::format_username($AddedBy, false, false, false, false, false) : '')?>
246 261
               <span class="remove remove_cover_art"><a href="#"
247
-                  onclick="if (confirm('Do not delete valid alternative cover art. Are you sure you want to delete this cover art?') == true) { ajax.get('torrents.php?action=remove_cover_art&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;id=<?=$ImageID?>&amp;groupid=<?=$GroupID?>'); this.parentNode.parentNode.parentNode.style.display = 'none'; this.parentNode.parentNode.parentNode.previousElementSibling.style.display = 'none'; } else { return false; }"
262
+                  onclick="if (confirm('Do not delete useful alternative pictures. Are you sure you want to delete this picture?') === true) { ajax.get('torrents.php?action=remove_cover_art&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;id=<?=$ImageID?>&amp;groupid=<?=$GroupID?>'); this.parentNode.parentNode.parentNode.style.display = 'none'; this.parentNode.parentNode.parentNode.previousElementSibling.style.display = 'none'; } else { return false; }"
248 263
                   class="brackets tooltip" title="Remove image">X</a></span>
249 264
             </li>
250 265
           </ul>
251 266
         </div>
252 267
         <?php
253 268
         $Index++;
254
-} ?>
269
+        } ?>
255 270
       </div>
256 271
 
257 272
       <?php
258
-    if (check_perms('site_edit_wiki') && $WikiImage != '') { ?>
273
+    if (check_perms('site_edit_wiki') && $WikiImage !== '') { ?>
259 274
       <div id="add_cover_div">
260 275
         <div style="padding: 10px;">
261 276
           <span class="additional_add_artists float_right">
@@ -274,7 +289,7 @@ $Index++;
274 289
           </form>
275 290
         </div>
276 291
       </div>
277
-      <?php    } ?>
292
+      <?php } ?>
278 293
 
279 294
     </div>
280 295
     <div class="box box_artists">
@@ -282,7 +297,7 @@ $Index++;
282 297
         <?=check_perms('torrents_edit') ? '<span class="edit_artists"><a onclick="ArtistManager(); return false;" href="#" class="brackets float_right">Edit</a></span>' : ''?>
283 298
       </div>
284 299
       <ul class="stats nobullet" id="artist_list">
285
-        <?php      foreach ($Artists as $Num => $Artist) { ?>
300
+        <?php foreach ($Artists as $Num => $Artist) { ?>
286 301
         <li class="artist"><?=Artists::display_artist($Artist)?>
287 302
           <?php if (check_perms('torrents_edit')) { ?>
288 303
           <span class="remove remove_artist float_right"><a href="javascript:void(0);"
@@ -290,10 +305,11 @@ $Index++;
290 305
               class="brackets tooltip" title="Remove artist">X</a></span>
291 306
           <?php } ?>
292 307
         </li>
293
-        <?php        } ?>
308
+        <?php } ?>
294 309
       </ul>
295 310
     </div>
296
-    <?php    if (check_perms('torrents_add_artist')) { ?>
311
+    <?php
312
+    if (check_perms('torrents_add_artist')) { ?>
297 313
     <div class="box box_addartists">
298 314
       <div class="head"><strong>Add Author</strong></div>
299 315
       <div class="body">
@@ -310,8 +326,8 @@ $Index++;
310 326
       </div>
311 327
     </div>
312 328
     <?php
313
-    }
314
-?>
329
+    } ?>
330
+
315 331
     <div class="box box_tags">
316 332
       <div class="head">
317 333
         <strong>Tags</strong>
@@ -330,46 +346,44 @@ $Index++;
330 346
         </form>
331 347
         <a class="brackets" href="#" onclick="$('#undo_tag_delete_form').raw().submit(); return false;">Undo delete</a>
332 348
 
333
-        <?php        } ?>
349
+        <?php } ?>
334 350
       </div>
335 351
       <?php
336
-if (count($Tags) > 0) {
337
-            ?>
352
+      if (count($Tags) > 0) {
353
+          ?>
338 354
       <ul class="stats nobullet">
339 355
         <?php
340
-  foreach ($Tags as $TagKey=>$Tag) {
341
-      ?>
356
+        foreach ($Tags as $TagKey=>$Tag) {
357
+            ?>
342 358
         <li>
343 359
           <a href="torrents.php?taglist=<?=$Tag['name']?>"
344 360
             class="<?=display_str($Tag['class'])?>"><?=display_str($Tag['display'])?></a>
345 361
           <div class="edit_tags_votes float_right">
346
-            <?php    if (check_perms('users_warn')) { ?>
362
+            <?php if (check_perms('users_warn')) { ?>
347 363
             <a href="user.php?id=<?=$Tag['userid']?>"
348 364
               title="View the profile of the user that added this tag" class="brackets tooltip view_tag_user">U</a>
349
-            <?php    } ?>
350
-            <?php    if (empty($LoggedUser['DisableTagging']) && check_perms('site_delete_tag')) { ?>
365
+            <?php } ?>
366
+            <?php if (empty($LoggedUser['DisableTagging']) && check_perms('site_delete_tag')) { ?>
351 367
             <span class="remove remove_tag"><a
352 368
                 href="torrents.php?action=delete_tag&amp;groupid=<?=$GroupID?>&amp;tagid=<?=$Tag['id']?>&amp;auth=<?=$LoggedUser['AuthKey']?>"
353 369
                 class="brackets tooltip" title="Remove tag">X</a></span>
354
-            <?php    } ?>
370
+            <?php } ?>
355 371
           </div>
356 372
         </li>
357 373
         <?php
358
-  } ?>
374
+        } ?>
359 375
       </ul>
360 376
       <?php
361
-        } else { // The "no tags to display" message was wrapped in <ul> tags to pad the text.
362
-?>
377
+      } else { // The "no tags to display" message was wrapped in <ul> tags to pad the text
378
+      ?>
363 379
       <ul>
364
-        <li>There are no tags to display.</li>
380
+        <li>There are no tags to display</li>
365 381
       </ul>
366
-      <?php
367
-}
368
-?>
382
+      <?php } ?>
369 383
     </div>
370 384
     <?php
371
-if (empty($LoggedUser['DisableTagging'])) {
372
-    ?>
385
+    if (empty($LoggedUser['DisableTagging'])) {
386
+        ?>
373 387
     <div class="box box_addtag">
374 388
       <div class="head"><strong>Add Tag</strong></div>
375 389
       <div class="body">
@@ -388,9 +402,10 @@ if (empty($LoggedUser['DisableTagging'])) {
388 402
       </div>
389 403
     </div>
390 404
     <?php
391
-}
392
-?>
405
+    } ?>
393 406
   </div>
407
+
408
+  <!-- Main torrent display -->
394 409
   <div class="main_column">
395 410
     <div class="box">
396 411
       <table
@@ -417,9 +432,9 @@ if (empty($LoggedUser['DisableTagging'])) {
417 432
         </tr>
418 433
         <?php
419 434
 function filelist($Str)
420
-{
421
-    return "</td><td>".Format::get_size($Str[1])."</td></tr>";
422
-}
435
+    {
436
+        return "</td><td>".Format::get_size($Str[1])."</td></tr>";
437
+    }
423 438
 
424 439
 foreach ($TorrentList as $Torrent) {
425 440
     list($TorrentID, $Media, $Container, $Codec, $Resolution, $AudioFormat, $Subbing,
@@ -484,7 +499,7 @@ foreach ($TorrentList as $Torrent) {
484 499
         <strong>Size</strong>
485 500
       </td>
486 501
     </tr>';
487
-    if (substr($FileList, -3) == '}}}') { // Old style
502
+    if (substr($FileList, -3) === '}}}') { // Old style
488 503
         $FileListSplit = explode('|||', $FileList);
489 504
         foreach ($FileListSplit as $File) {
490 505
             $NameEnd = strrpos($File, '{{{');
@@ -505,31 +520,41 @@ foreach ($TorrentList as $Torrent) {
505 520
     $FileTable .= '
506 521
   </table>';
507 522
 
508
-    $ExtraInfo = ''; // String that contains information on the torrent (e.g. format and encoding)
509
-  $AddExtra = ''; // Separator between torrent properties
523
+    $ExtraInfo = ''; // String that contains information on the torrent (e.g., format and encoding)
524
+    $AddExtra = ''; // Separator between torrent properties
510 525
 
511 526
   // Similar to Torrents::torrent_info()
512 527
     if ($Media) {
513 528
         $ExtraInfo.=display_str($Media);
514 529
         $AddExtra=" / ";
515 530
     }
531
+
516 532
     if ($Container) {
517 533
         $ExtraInfo.=$AddExtra.display_str($Container);
518 534
         $AddExtra=' / ';
519 535
     }
536
+
537
+    if ($Archive) {
538
+        $ExtraInfo .= $AddExtra.display_str($Archive);
539
+        $AddExtra=' / ';
540
+    }
541
+
520 542
     if ($Codec) {
521 543
         $ExtraInfo.=$AddExtra.display_str($Codec);
522 544
         $AddExtra=' / ';
523 545
     }
546
+
524 547
     if ($Resolution) {
525 548
         $ExtraInfo.=$AddExtra.display_str($Resolution);
526 549
         $AddExtra=' / ';
527 550
     }
551
+
528 552
     /*
529 553
     if ($AudioFormat) {
530 554
       $ExtraInfo.=$AddExtra.display_str($AudioFormat);
531 555
       $AddExtra=' / '; }
532 556
       */
557
+
533 558
     /*
534 559
     if ($Language) {
535 560
       if ($Subber && ($GroupCategoryID == 3 || $GroupCategoryID == 4)) {
@@ -540,6 +565,7 @@ foreach ($TorrentList as $Torrent) {
540 565
       }
541 566
     }
542 567
     */
568
+
543 569
     /*
544 570
     if ($Subbing) {
545 571
       if ($Subber) {
@@ -551,10 +577,7 @@ foreach ($TorrentList as $Torrent) {
551 577
       }
552 578
     }
553 579
     */
554
-    if ($Archive) {
555
-        $ExtraInfo .= $AddExtra.display_str($Archive);
556
-        $AddExtra=' / ';
557
-    }
580
+
558 581
     if ($Censored) {
559 582
         $ExtraInfo .= $AddExtra.display_str('Aligned');
560 583
         $AddExtra=' / ';
@@ -562,28 +585,33 @@ foreach ($TorrentList as $Torrent) {
562 585
         $ExtraInfo .= $AddExtra.display_str('Unaligned');
563 586
         $AddExtra=' / ';
564 587
     }
588
+
565 589
     if (!$ExtraInfo) {
566 590
         $ExtraInfo = $GroupName;
567 591
         $AddExtra=' / ';
568 592
     }
593
+
569 594
     if ($IsLeeching) {
570
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Leeching');
595
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Leeching', 'important_text');
571 596
         $AddExtra=' / ';
572 597
     } elseif ($IsSeeding) {
573
-        $ExtraInfo.=$AddExtra . Format::torrent_label('Seeding');
598
+        $ExtraInfo.=$AddExtra . Format::torrent_label('Seeding', 'important_text_alt');
574 599
         $AddExtra=' / ';
575 600
     } elseif ($IsSnatched) {
576
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Snatched!');
601
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Snatched!', 'bold');
577 602
         $AddExtra=' / ';
578 603
     }
579
-    if ($FreeTorrent == '1') {
580
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!');
604
+
605
+    if ($FreeTorrent === '1') {
606
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!', 'important_text_alt');
581 607
         $AddExtra=' / ';
582 608
     }
583
-    if ($FreeTorrent == '2') {
584
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Neutral Leech!');
609
+
610
+    if ($FreeTorrent === '2') {
611
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Neutral Leech!', 'bold');
585 612
         $AddExtra=' / ';
586 613
     }
614
+
587 615
     // Freleechizer
588 616
     if ($FreeLeechType == '3') {
589 617
         $DB->query("
@@ -595,24 +623,31 @@ foreach ($TorrentList as $Torrent) {
595 623
             $ExtraInfo .= " <strong>(" . str_replace(['week','day','hour','min','Just now','s',' '], ['w','d','h','m','0m'], time_diff(max($ExpiryTime, time()), 1, false)) . ")</strong>";
596 624
         }
597 625
     }
626
+
598 627
     if ($PersonalFL) {
599
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Personal Freeleech!');
628
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Personal Freeleech!', 'important_text_alt');
600 629
         $AddExtra=' / ';
601 630
     }
631
+
602 632
     if ($Reported) {
603
-        $ExtraInfo.=$AddExtra.'<strong class="torrent_label tl_reported tooltip" title="Type: '.ucfirst($Reports[0]['Type']).'<br>Comment: '.htmlentities(htmlentities($Reports[0]['UserComment'])).'">Reported</strong>';
633
+        $HtmlReportType = ucfirst($Reports[0]['Type']);
634
+        $HtmlReportComment = htmlentities(htmlentities($Reports[0]['UserComment']));
635
+        $ExtraInfo.=$AddExtra. "<strong class='torrent_label tl_reported tooltip' title='Type: $HtmlReportType<br>Comment: HtmlReportComment'>".Format::torrent_label('Reported', 'important_text')."</strong>";
604 636
         $AddExtra=' / ';
605 637
     }
638
+
606 639
     if (!empty($BadTags)) {
607
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Tags');
640
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Tags', 'important_text');
608 641
         $AddExtra=' / ';
609 642
     }
643
+
610 644
     if (!empty($BadFolders)) {
611
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Folders');
645
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Folders', 'important_text');
612 646
         $AddExtra=' / ';
613 647
     }
648
+
614 649
     if (!empty($BadFiles)) {
615
-        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad File Names');
650
+        $ExtraInfo.=$AddExtra. Format::torrent_label('Bad File Names', 'important_text');
616 651
         $AddExtra=' / ';
617 652
     }
618 653
 
@@ -624,6 +659,7 @@ foreach ($TorrentList as $Torrent) {
624 659
             $TorrentFileName = $Tor->Dec['info']['name'];
625 660
             $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
626 661
         }
662
+        # Magnet link h4x
627 663
         $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$InfoHash."&as=https://".SITE_DOMAIN."/".str_replace('&amp;', '%26', $TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=", ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Size;
628 664
     } ?>
629 665
 
@@ -633,29 +669,29 @@ foreach ($TorrentList as $Torrent) {
633 669
           <td>
634 670
             <span>[ <a href="<?=$TorrentDL?>" class="tooltip"
635 671
                 title="Download"><?=($HasFile ? 'DL' : 'Missing')?></a>
636
-              <?php  if (isset($TorrentMG)) { ?>
672
+              <?php if (isset($TorrentMG)) { ?>
637 673
               | <a href="<?=$TorrentMG?>" class="tooltip"
638 674
                 title="Magnet Link">MG</a>
639
-              <?php  }
675
+              <?php }
640 676
     if (Torrents::can_use_token($Torrent)) { ?>
641 677
               | <a
642 678
                 href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1"
643 679
                 class="tooltip" title="Use a FL Token"
644 680
                 onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
645
-              <?php  } ?>
681
+              <?php } ?>
646 682
               | <a
647 683
                 href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
648 684
                 class="tooltip" title="Report">RP</a>
649
-              <?php  if ($CanEdit) { ?>
685
+              <?php if ($CanEdit) { ?>
650 686
               | <a
651 687
                 href="torrents.php?action=edit&amp;id=<?=$TorrentID ?>"
652 688
                 class="tooltip" title="Edit release">ED</a>
653
-              <?php  }
689
+              <?php }
654 690
     if (check_perms('torrents_delete') || $UserID == $LoggedUser['ID']) { ?>
655 691
               | <a
656 692
                 href="torrents.php?action=delete&amp;torrentid=<?=$TorrentID ?>"
657 693
                 class="tooltip" title="Remove">RM</a>
658
-              <?php  } ?>
694
+              <?php } ?>
659 695
               | <a href="torrents.php?torrentid=<?=$TorrentID ?>"
660 696
                 class="tooltip" title="Permalink">PL</a>
661 697
               ]</span>
@@ -688,47 +724,47 @@ foreach ($TorrentList as $Torrent) {
688 724
   } else {
689 725
       print Users::format_username($UserID, false, false, false);
690 726
   } ?> <?=time_diff($TorrentTime); ?>
691
-                <?php  if ($Seeders == 0) {
727
+                <?php if ($Seeders === 0) {
692 728
       if ($LastActive && time() - strtotime($LastActive) >= 1209600) { ?>
693 729
                 <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
694
-                <?php    } else { ?>
730
+                <?php } else { ?>
695 731
                 <br />Last active: <?=time_diff($LastActive); ?>
696
-                <?php    }
732
+                <?php }
697 733
   }
698 734
 
699
-    if (($Seeders == 0 && $LastActive && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
735
+    if (($Seeders === 0 && $LastActive && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
700 736
                 <br /><a
701 737
                   href="torrents.php?action=reseed&amp;torrentid=<?=$TorrentID?>&amp;groupid=<?=$GroupID?>"
702 738
                   class="brackets">Request re-seed</a>
703
-                <?php  } ?>
739
+                <?php } ?>
704 740
               </blockquote>
705 741
             </div>
706
-            <?php  if (check_perms('site_moderate_requests')) { ?>
742
+            <?php if (check_perms('site_moderate_requests')) { ?>
707 743
             <div class="linkbox">
708 744
               <a href="torrents.php?action=masspm&amp;id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"
709 745
                 class="brackets">Mass PM snatchers</a>
710 746
             </div>
711
-            <?php  } ?>
747
+            <?php } ?>
712 748
             <div class="linkbox">
713 749
               <a href="#" class="brackets"
714 750
                 onclick="show_peers('<?=$TorrentID?>', 0); return false;">View
715 751
                 peer list</a>
716
-              <?php  if (check_perms('site_view_torrent_snatchlist')) { ?>
752
+              <?php if (check_perms('site_view_torrent_snatchlist')) { ?>
717 753
               <a href="#" class="brackets tooltip"
718 754
                 onclick="show_downloads('<?=$TorrentID?>', 0); return false;"
719 755
                 title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
720 756
               <a href="#" class="brackets tooltip"
721 757
                 onclick="show_snatches('<?=$TorrentID?>', 0); return false;"
722 758
                 title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
723
-              <?php  } ?>
759
+              <?php } ?>
724 760
               <a href="#" class="brackets"
725 761
                 onclick="show_files('<?=$TorrentID?>'); return false;">View
726 762
                 file list</a>
727
-              <?php  if ($Reported) { ?>
763
+              <?php if ($Reported) { ?>
728 764
               <a href="#" class="brackets"
729 765
                 onclick="show_reported('<?=$TorrentID?>'); return false;">View
730 766
                 report information</a>
731
-              <?php  } ?>
767
+              <?php } ?>
732 768
             </div>
733 769
             <div id="peers_<?=$TorrentID?>" class="hidden"></div>
734 770
             <div id="downloads_<?=$TorrentID?>" class="hidden"></div>

+ 4
- 0
static/styles/global.css View File

@@ -235,6 +235,10 @@ strong.important_text_alt {
235 235
   font-weight: bold;
236 236
 }
237 237
 
238
+strong.bold {
239
+  font-weight: bold;
240
+}
241
+
238 242
 .invalid, .warning, .error, .new {
239 243
   color: #ff0000;
240 244
 }

Loading…
Cancel
Save