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
     <tr>
94
     <tr>
95
       <td>
95
       <td>
96
         <a href="reportsv2.php?view=report&amp;id=<?=$ReportID?>">Somebody has already resolved this report</a>
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
       </td>
98
       </td>
99
     </tr>
99
     </tr>
100
   </table>
100
   </table>
205
     $DB->query("
205
     $DB->query("
206
       SELECT
206
       SELECT
207
         r.ExtraID,
207
         r.ExtraID,
208
-        t.info_hash
208
+        HEX(t.info_hash)
209
       FROM reportsv2 AS r
209
       FROM reportsv2 AS r
210
       LEFT JOIN torrents AS t ON r.ExtraID = t.ID
210
       LEFT JOIN torrents AS t ON r.ExtraID = t.ID
211
       WHERE r.ID = $ReportID");
211
       WHERE r.ID = $ReportID");
231
         }
231
         }
232
       }
232
       }
233
       foreach ($AffectedUsers as $UserID) {
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
         $DB->query("
235
         $DB->query("
236
           INSERT INTO users_freeleeches (UserID, TorrentID, Time)
236
           INSERT INTO users_freeleeches (UserID, TorrentID, Time)
237
           VALUES ($UserID, $ExtraID, NOW())
237
           VALUES ($UserID, $ExtraID, NOW())

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

12
   }
12
   }
13
 
13
 
14
   $DB->query("
14
   $DB->query("
15
-    SELECT uf.UserID, t.info_hash
15
+    SELECT uf.UserID, HEX(t.info_hash)
16
     FROM users_freeleeches AS uf
16
     FROM users_freeleeches AS uf
17
       JOIN torrents AS t ON uf.TorrentID = t.ID
17
       JOIN torrents AS t ON uf.TorrentID = t.ID
18
     WHERE uf.Expired = FALSE
18
     WHERE uf.Expired = FALSE
19
       AND uf.Time < (NOW() - INTERVAL 4 DAY)");
19
       AND uf.Time < (NOW() - INTERVAL 4 DAY)");
20
   while (list($UserID, $InfoHash) = $DB->next_record(MYSQLI_NUM, false)) {
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
   $DB->query("
23
   $DB->query("
24
     UPDATE users_freeleeches
24
     UPDATE users_freeleeches

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

74
       tg.CategoryID,
74
       tg.CategoryID,
75
       t.Size,
75
       t.Size,
76
       t.FreeTorrent,
76
       t.FreeTorrent,
77
-      t.info_hash
77
+      HEX(t.info_hash)
78
     FROM torrents AS t
78
     FROM torrents AS t
79
       INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
79
       INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
80
     WHERE t.ID = '".db_string($TorrentID)."'");
80
     WHERE t.ID = '".db_string($TorrentID)."'");
121
     }
121
     }
122
 
122
 
123
     // Let the tracker know about this
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
       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.');
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
     error(403);
38
     error(403);
39
   }
39
   }
40
   $DB->query("
40
   $DB->query("
41
-    SELECT info_hash
41
+    SELECT HEX(info_hash)
42
     FROM torrents
42
     FROM torrents
43
     WHERE ID = $TorrentID");
43
     WHERE ID = $TorrentID");
44
   if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
44
   if (list($InfoHash) = $DB->next_record(MYSQLI_NUM, FALSE)) {
48
       WHERE UserID = $UserID
48
       WHERE UserID = $UserID
49
         AND TorrentID = $TorrentID");
49
         AND TorrentID = $TorrentID");
50
     $Cache->delete_value("users_tokens_$UserID");
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
   header("Location: userhistory.php?action=token_history&userid=$UserID");
53
   header("Location: userhistory.php?action=token_history&userid=$UserID");
54
 }
54
 }

Loading…
Cancel
Save