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
-<?
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
         CEIL(
23
         CEIL(
21
           (
24
           (
22
             SELECT COUNT(ID) + 1
25
             SELECT COUNT(ID) + 1
23
             FROM comments
26
             FROM comments
24
             WHERE Page = '$Page'
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
         FROM comments
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
         FROM comments
144
         FROM comments
268
-        WHERE Page = '$Page'
145
+          WHERE Page = '$Page'
269
           AND PageID = $PageID
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
           AND PageID = $PageID
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
         SELECT PostID
335
         SELECT PostID
327
         FROM users_comments_last_read
336
         FROM users_comments_last_read
328
-        WHERE UserID = " . G::$LoggedUser['ID'] . "
337
+          WHERE UserID = " . G::$LoggedUser['ID'] . "
329
           AND Page = '$Page'
338
           AND Page = '$Page'
330
           AND PageID = $PageID");
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
           INSERT INTO users_comments_last_read
343
           INSERT INTO users_comments_last_read
335
             (UserID, Page, PageID, PostID)
344
             (UserID, Page, PageID, PostID)
336
           VALUES
345
           VALUES
337
             (" . G::$LoggedUser['ID'] . ", '$Page', $PageID, $LastPost)
346
             (" . G::$LoggedUser['ID'] . ", '$Page', $PageID, $LastPost)
338
           ON DUPLICATE KEY UPDATE
347
           ON DUPLICATE KEY UPDATE
339
             PostID = $LastPost");
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
 <?php
1
 <?php
2
+
2
 class Format
3
 class Format
3
 {
4
 {
4
 
5
 
47
     public static function cut_string($Str, $Length, $Hard = false, $ShowDots = true)
48
     public static function cut_string($Str, $Length, $Hard = false, $ShowDots = true)
48
     {
49
     {
49
         if (mb_strlen($Str, 'UTF-8') > $Length) {
50
         if (mb_strlen($Str, 'UTF-8') > $Length) {
50
-            if ($Hard == 0) {
51
+            if ($Hard === 0) {
51
                 // Not hard, cut at closest word
52
                 // Not hard, cut at closest word
52
                 $CutDesc = mb_substr($Str, 0, $Length, 'UTF-8');
53
                 $CutDesc = mb_substr($Str, 0, $Length, 'UTF-8');
53
                 $DescArr = explode(' ', $CutDesc);
54
                 $DescArr = explode(' ', $CutDesc);
130
         $Ratio = self::get_ratio($Dividend, $Divisor);
131
         $Ratio = self::get_ratio($Dividend, $Divisor);
131
 
132
 
132
         if ($Ratio === false) {
133
         if ($Ratio === false) {
133
-            return '--';
134
+            return '&ndash;';
134
         }
135
         }
135
         if ($Ratio === '∞') {
136
         if ($Ratio === '∞') {
136
             return '<span class="tooltip r99" title="Infinite">∞</span>';
137
             return '<span class="tooltip r99" title="Infinite">∞</span>';
156
      */
157
      */
157
     public static function get_ratio($Dividend, $Divisor, $Decimal = 2)
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
             return false;
161
             return false;
161
         }
162
         }
162
-        if ($Divisor == 0) {
163
+        if ($Divisor === 0) {
163
             return '∞';
164
             return '∞';
164
         }
165
         }
165
         return number_format(max($Dividend / $Divisor - (0.5 / pow(10, $Decimal)), 0), $Decimal);
166
         return number_format(max($Dividend / $Divisor - (0.5 / pow(10, $Decimal)), 0), $Decimal);
206
     {
207
     {
207
         if (!isset($_GET['page'])) {
208
         if (!isset($_GET['page'])) {
208
             $Page = ceil($DefaultResult / $PerPage);
209
             $Page = ceil($DefaultResult / $PerPage);
210
+            # todo: Strict equality breaks comment fetching
209
             if ($Page == 0) {
211
             if ($Page == 0) {
210
                 $Page = 1;
212
                 $Page = 1;
211
             }
213
             }
224
     }
226
     }
225
 
227
 
226
     // A9 magic. Some other poor soul can write the phpdoc.
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
     public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500)
230
     public static function catalogue_limit($Page, $PerPage, $CatalogueSize = 500)
229
     {
231
     {
230
         $CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);
232
         $CatalogueID = floor(($PerPage * $Page - $PerPage) / $CatalogueSize);
237
         return array_slice($Catalogue, (($PerPage * $Page - $PerPage) % $CatalogueSize), $PerPage, true);
239
         return array_slice($Catalogue, (($PerPage * $Page - $PerPage) % $CatalogueSize), $PerPage, true);
238
     }
240
     }
239
 
241
 
240
-    /* Get pages
242
+    /*
243
+     * Get pages
241
      * Returns a page list, given certain information about the pages.
244
      * Returns a page list, given certain information about the pages.
242
      *
245
      *
243
      * @param int $StartPage: The current record the page you're on starts with.
246
      * @param int $StartPage: The current record the page you're on starts with.
285
             $StartPosition = max($StartPosition, 1);
288
             $StartPosition = max($StartPosition, 1);
286
 
289
 
287
             $QueryString = self::get_url(array('page', 'post'));
290
             $QueryString = self::get_url(array('page', 'post'));
288
-            if ($QueryString != '') {
291
+            if ($QueryString !== '') {
289
                 $QueryString = "&amp;$QueryString";
292
                 $QueryString = "&amp;$QueryString";
290
             }
293
             }
291
 
294
 
299
 
302
 
300
             if (!$Mobile) {
303
             if (!$Mobile) {
301
                 for ($i = $StartPosition; $i <= $StopPage; $i++) {
304
                 for ($i = $StartPosition; $i <= $StopPage; $i++) {
302
-                    if ($i != $StartPage) {
305
+                    if ($i !== $StartPage) {
303
                         $Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
306
                         $Pages .= "<a href=\"$Location?page=$i$QueryString$Anchor\">";
304
                     }
307
                     }
305
                     $Pages .= '<strong>';
308
                     $Pages .= '<strong>';
310
                     }
313
                     }
311
 
314
 
312
                     $Pages .= '</strong>';
315
                     $Pages .= '</strong>';
313
-                    if ($i != $StartPage) {
316
+                    if ($i !== $StartPage) {
314
                         $Pages .= '</a>';
317
                         $Pages .= '</a>';
315
                     }
318
                     }
316
                     if ($i < $StopPage) {
319
                     if ($i < $StopPage) {
346
         $Size = (double)$Size;
349
         $Size = (double)$Size;
347
         for ($Steps = 0; abs($Size) >= 1024 && $Steps < count($Units); $Size /= 1024, $Steps++) {
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
             $Levels++;
353
             $Levels++;
351
         }
354
         }
352
         return number_format($Size, $Levels) . ' ' . $Units[$Steps];
355
         return number_format($Size, $Levels) . ' ' . $Units[$Steps];
445
             $Array = $_GET;
448
             $Array = $_GET;
446
         }
449
         }
447
         if (isset($Array[$Name]) && $Array[$Name] !== '') {
450
         if (isset($Array[$Name]) && $Array[$Name] !== '') {
448
-            if ($Array[$Name] == $Value) {
451
+            if ($Array[$Name] === $Value) {
449
                 echo " $Attribute=\"$Attribute\"";
452
                 echo " $Attribute=\"$Attribute\"";
450
             }
453
             }
451
         }
454
         }
515
      */
518
      */
516
     public static function make_utf8($Str)
519
     public static function make_utf8($Str)
517
     {
520
     {
518
-        if ($Str != '') {
521
+        if ($Str !== '') {
519
             if (self::is_utf8($Str)) {
522
             if (self::is_utf8($Str)) {
520
                 $Encoding = 'UTF-8';
523
                 $Encoding = 'UTF-8';
521
             }
524
             }
525
             if (empty($Encoding)) {
528
             if (empty($Encoding)) {
526
                 $Encoding = 'ISO-8859-1';
529
                 $Encoding = 'ISO-8859-1';
527
             }
530
             }
528
-            if ($Encoding == 'UTF-8') {
531
+            if ($Encoding === 'UTF-8') {
529
                 return $Str;
532
                 return $Str;
530
             } else {
533
             } else {
531
                 return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
534
                 return @mb_convert_encoding($Str, 'UTF-8', $Encoding);
543
     {
546
     {
544
         return preg_match(
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
             $Str
558
             $Str
556
         );
559
         );
557
     }
560
     }

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

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

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

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

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

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

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

60
                 continue;
60
                 continue;
61
             }
61
             }
62
             $Data = G::$Cache->get_value($Key . $GroupID, true);
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
                 unset($NotFound[$GroupID]);
64
                 unset($NotFound[$GroupID]);
65
                 $Found[$GroupID] = $Data['d'];
65
                 $Found[$GroupID] = $Data['d'];
66
             }
66
             }
83
             $NotFound = [];
83
             $NotFound = [];
84
             $QueryID = G::$DB->get_query_id();
84
             $QueryID = G::$DB->get_query_id();
85
             G::$DB->query("
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
             while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
91
             while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) {
92
                 $NotFound[$Group['ID']] = $Group;
92
                 $NotFound[$Group['ID']] = $Group;
115
             if ($Torrents) {
115
             if ($Torrents) {
116
                 $QueryID = G::$DB->get_query_id();
116
                 $QueryID = G::$DB->get_query_id();
117
                 G::$DB->query("
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
                 while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
127
                 while ($Torrent = G::$DB->next_record(MYSQLI_ASSOC, true)) {
128
                     $NotFound[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
128
                     $NotFound[$Torrent['GroupID']]['Torrents'][$Torrent['ID']] = $Torrent;
129
                 }
129
                 }
137
             $Found = $NotFound + $Found;
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
         $Found = array_filter($Found);
141
         $Found = array_filter($Found);
142
 
142
 
143
         if ($GetArtists) {
143
         if ($GetArtists) {
208
      */
208
      */
209
     public static function torrent_properties(&$Torrent, &$Flags)
209
     public static function torrent_properties(&$Torrent, &$Flags)
210
     {
210
     {
211
+        # FL Token
211
         $Torrent['PersonalFL'] = empty($Torrent['FreeTorrent']) && self::has_token($Torrent['ID']);
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
             $Flags['IsSnatched'] = true;
216
             $Flags['IsSnatched'] = true;
214
         } else {
217
         } else {
215
             $Flags['IsSnatched'] = false;
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
             $Flags['IsSeeding'] = true;
223
             $Flags['IsSeeding'] = true;
220
         } else {
224
         } else {
221
             $Flags['IsSeeding'] = false;
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
             $Flags['IsLeeching'] = true;
230
             $Flags['IsLeeching'] = true;
226
         } else {
231
         } else {
227
             $Flags['IsLeeching'] = false;
232
             $Flags['IsLeeching'] = false;
664
     public static function torrent_info($Data, $ShowMedia = true, $ShowEdition = false, $HTMLy = true)
669
     public static function torrent_info($Data, $ShowMedia = true, $ShowEdition = false, $HTMLy = true)
665
     {
670
     {
666
         $Info = [];
671
         $Info = [];
672
+
673
+        # Platform
667
         if ($ShowMedia && !empty($Data['Media'])) {
674
         if ($ShowMedia && !empty($Data['Media'])) {
668
-            $Info[] = $Data['Media'];
675
+            $Info[] = display_str($Data['Media']);
669
         }
676
         }
677
+
678
+        # Format
670
         if (!empty($Data['Container'])) {
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
         if (!empty($Data['Resolution'])) {
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
         if (!empty($Data['AudioFormat'])) {
706
         if (!empty($Data['AudioFormat'])) {
681
           $Info[] = $Data['AudioFormat'];
707
           $Info[] = $Data['AudioFormat'];
682
         }
708
         }
683
         */
709
         */
710
+
684
         /*
711
         /*
685
         if (!empty($Data['Language'])) {
712
         if (!empty($Data['Language'])) {
686
           if (!empty($Data['Subber']) && isset($Data['CategoryID']) && ($Data['CategoryID'] == 3 || $Data['CategoryID'] == 4)) {
713
           if (!empty($Data['Subber']) && isset($Data['CategoryID']) && ($Data['CategoryID'] == 3 || $Data['CategoryID'] == 4)) {
690
           }
717
           }
691
         }
718
         }
692
         */
719
         */
720
+
693
         /*
721
         /*
694
         if (!empty($Data['Subbing'])) {
722
         if (!empty($Data['Subbing'])) {
695
           if (!empty($Data['Subber'])) {
723
           if (!empty($Data['Subber'])) {
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
         if ($Data['IsLeeching']) {
733
         if ($Data['IsLeeching']) {
713
-            $Info[] = $HTMLy ? Format::torrent_label('Leeching') : 'Leeching';
734
+            $Info[] = $HTMLy ? Format::torrent_label('Leeching', 'important_text') : 'Leeching';
714
         } elseif ($Data['IsSeeding']) {
735
         } elseif ($Data['IsSeeding']) {
715
-            $Info[] = $HTMLy ? Format::torrent_label('Seeding') : 'Seeding';
736
+            $Info[] = $HTMLy ? Format::torrent_label('Seeding', 'important_text_alt') : 'Seeding';
716
         } elseif ($Data['IsSnatched']) {
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
                 if ($Data['ExpiryTime']) {
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
                 } else {
745
                 } else {
725
-                    $Info[] = $HTMLy ? Format::torrent_label('Freeleech!') : 'Freeleech!';
746
+                    $Info[] = $HTMLy ? Format::torrent_label('Freeleech!', 'important_text_alt') : 'Freeleech!';
726
                 }
747
                 }
727
             } else {
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
         if ($Data['FreeTorrent'] == '2') {
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
         if ($Data['PersonalFL']) {
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
         return implode(' / ', $Info);
758
         return implode(' / ', $Info);
738
     }
759
     }

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

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

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

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

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

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

Loading…
Cancel
Save