Browse Source

Query infohash in an encoding-safe way

spaghetti 7 years ago
parent
commit
7a88e46d1b

+ 3
- 3
sections/reportsv2/takeresolve.php View File

@@ -94,7 +94,7 @@ if (($Escaped['resolve_type'] == 'manual' || $Escaped['resolve_type'] == 'dismis
94 94
     <tr>
95 95
       <td>
96 96
         <a href="reportsv2.php?view=report&amp;id=<?=$ReportID?>">Somebody has already resolved this report</a>
97
-        <input type="button" value="Clear" onclick="ClearReport(<?=$ReportID?>);" />
97
+        <input type="button" value="Clear" o nclick="ClearReport(<?=$ReportID?>);" />
98 98
       </td>
99 99
     </tr>
100 100
   </table>
@@ -205,7 +205,7 @@ if ($DB->affected_rows() > 0 || !$Report) {
205 205
     $DB->query("
206 206
       SELECT
207 207
         r.ExtraID,
208
-        t.info_hash
208
+        HEX(t.info_hash)
209 209
       FROM reportsv2 AS r
210 210
       LEFT JOIN torrents AS t ON r.ExtraID = t.ID
211 211
       WHERE r.ID = $ReportID");
@@ -231,7 +231,7 @@ if ($DB->affected_rows() > 0 || !$Report) {
231 231
         }
232 232
       }
233 233
       foreach ($AffectedUsers as $UserID) {
234
-        Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
234
+        Tracker::update_tracker('add_token', ['info_hash' => substr('%'.chunk_split($InfoHash,2,'%'),0,-1), 'userid' => $UserID]);
235 235
         $DB->query("
236 236
           INSERT INTO users_freeleeches (UserID, TorrentID, Time)
237 237
           VALUES ($UserID, $ExtraID, NOW())

+ 2
- 2
sections/schedule/every/expire_tokens.php View File

@@ -12,13 +12,13 @@ if ($DB->has_results()) {
12 12
   }
13 13
 
14 14
   $DB->query("
15
-    SELECT uf.UserID, t.info_hash
15
+    SELECT uf.UserID, HEX(t.info_hash)
16 16
     FROM users_freeleeches AS uf
17 17
       JOIN torrents AS t ON uf.TorrentID = t.ID
18 18
     WHERE uf.Expired = FALSE
19 19
       AND uf.Time < (NOW() - INTERVAL 4 DAY)");
20 20
   while (list($UserID, $InfoHash) = $DB->next_record(MYSQLI_NUM, false)) {
21
-    Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
21
+    Tracker::update_tracker('remove_token', ['info_hash' => substr('%'.chunk_split($InfoHash,2,'%'),0,-1), 'userid' => $UserID]);
22 22
   }
23 23
   $DB->query("
24 24
     UPDATE users_freeleeches

+ 2
- 2
sections/torrents/download.php View File

@@ -74,7 +74,7 @@ if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[
74 74
       tg.CategoryID,
75 75
       t.Size,
76 76
       t.FreeTorrent,
77
-      t.info_hash
77
+      HEX(t.info_hash)
78 78
     FROM torrents AS t
79 79
       INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
80 80
     WHERE t.ID = '".db_string($TorrentID)."'");
@@ -121,7 +121,7 @@ if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
121 121
     }
122 122
 
123 123
     // Let the tracker know about this
124
-    if (!Tracker::update_tracker('add_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID))) {
124
+    if (!Tracker::update_tracker('add_token', ['info_hash' => substr('%'.chunk_split($InfoHash,2,'%'),0,-1), 'userid' => $UserID])) {
125 125
       error('Sorry! An error occurred while trying to register your token. Most often, this is due to the tracker being down or under heavy load. Please try again later.');
126 126
     }
127 127
 

+ 2
- 2
sections/userhistory/token_history.php View File

@@ -38,7 +38,7 @@ if (isset($_GET['expire'])) {
38 38
     error(403);
39 39
   }
40 40
   $DB->query("
41
-    SELECT info_hash
41
+    SELECT HEX(info_hash)
42 42
     FROM torrents
43 43
     WHERE ID = $TorrentID");
44 44
   if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
@@ -48,7 +48,7 @@ if (isset($_GET['expire'])) {
48 48
       WHERE UserID = $UserID
49 49
         AND TorrentID = $TorrentID");
50 50
     $Cache->delete_value("users_tokens_$UserID");
51
-    Tracker::update_tracker('remove_token', array('info_hash' => rawurlencode($InfoHash), 'userid' => $UserID));
51
+    Tracker::update_tracker('remove_token', ['info_hash' => substr('%'.chunk_split($InfoHash,2,'%'),0,-1), 'userid' => $UserID]);
52 52
   }
53 53
   header("Location: userhistory.php?action=token_history&userid=$UserID");
54 54
 }

Loading…
Cancel
Save