Browse Source

Don't abort page creation if magnet link fails to generate

spaghetti 7 years ago
parent
commit
bdbbbc17bb
3 changed files with 14 additions and 11 deletions
  1. 10
    7
      classes/bencodedecode.class.php
  2. 2
    2
      sections/torrents/browse.php
  3. 2
    2
      sections/torrents/takedelete.php

+ 10
- 7
classes/bencodedecode.class.php View File

@@ -18,7 +18,10 @@ class BencodeDecode extends Bencode {
18 18
    * @param bool $IsPath needs to be true if $Arg is a path
19 19
    * @return decoded data with a suitable structure
20 20
    */
21
-  function __construct($Arg = false, $IsPath = false) {
21
+  function __construct($Arg = false, $IsPath = false, $Strict = true) {
22
+    if (!$Strict) {
23
+      $this->ExitOnError = false;
24
+    }
22 25
     if ($Arg === false) {
23 26
       if (empty($this->Enc)) {
24 27
         return false;
@@ -169,13 +172,13 @@ class BencodeDecode extends Bencode {
169 172
       // The recursive nature of the class requires this to avoid duplicate error messages
170 173
       return false;
171 174
     }
172
-    if ($ErrMsg === false) {
173
-      printf("Malformed string. Invalid character at pos 0x%X: %s\n",
174
-          $this->Pos, str_replace(array("\r","\n"), array('',' '), htmlentities(substr($this->Data, $this->Pos, self::SnipLength))));
175
-    } else {
176
-      echo $ErrMsg;
177
-    }
178 175
     if ($this->ExitOnError) {
176
+      if ($ErrMsg === false) {
177
+        printf("Malformed string. Invalid character at pos 0x%X: %s\n",
178
+            $this->Pos, str_replace(array("\r","\n"), array('',' '), htmlentities(substr($this->Data, $this->Pos, self::SnipLength))));
179
+      } else {
180
+        echo $ErrMsg;
181
+      }
179 182
       exit();
180 183
     }
181 184
     $ErrorPos = $this->Pos;

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

@@ -596,7 +596,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
596 596
       if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
597 597
         if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
598 598
           $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
599
-          $Tor = new BencodeTorrent($TorrentFile);
599
+          $Tor = new BencodeTorrent($TorrentFile, false, false);
600 600
           $TorrentFileName = $Tor->Dec['info']['name'];
601 601
           $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
602 602
         }
@@ -674,7 +674,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
674 674
     if (!empty(G::$LoggedUser) && (G::$LoggedUser['ShowMagnets'] ?? false)) {
675 675
       if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
676 676
         $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
677
-        $Tor = new BencodeTorrent($TorrentFile);
677
+        $Tor = new BencodeTorrent($TorrentFile, false, false);
678 678
         $TorrentFileName = $Tor->Dec['info']['name'];
679 679
         $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
680 680
       }

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

@@ -26,9 +26,9 @@ $DB->query("
26 26
     LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
27 27
     LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
28 28
   WHERE t.ID = '$TorrentID'");
29
-list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
29
+list($UploaderID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
30 30
 
31
-if ($LoggedUser['ID'] != $UserID && !check_perms('torrents_delete')) {
31
+if ($LoggedUser['ID'] != $UploaderID && !check_perms('torrents_delete')) {
32 32
   error(403);
33 33
 }
34 34
 

Loading…
Cancel
Save