Browse Source

Web seeds will come with OPS's bencode libraries

pjc 5 years ago
parent
commit
fb441f833f

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

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 /**
3 4
  * If we're running a 32bit PHP version, we use small objects to store ints.
4 5
  * Overhead from the function calls is small enough to not worry about

+ 3
- 4
classes/bencodedecode.class.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * The decode class is simple and straightforward. The only thing to
5 4
  * note is that empty dictionaries are represented by boolean trues
@@ -93,7 +92,7 @@ class BencodeDecode extends Bencode
93 92
       case 'i':
94 93
         $this->Pos++;
95 94
         $Value = substr($this->Data, $this->Pos, strpos($this->Data, 'e', $this->Pos) - $this->Pos);
96
-        if (!ctype_digit($Value) && !($Value[0] === '-' && ctype_digit(substr($Value, 1)))) {
95
+        if (!ctype_digit($Value) && !($Value[0] == '-' && ctype_digit(substr($Value, 1)))) {
97 96
             return $this->error();
98 97
         }
99 98
         $this->Pos += strlen($Value) + 1;
@@ -102,7 +101,7 @@ class BencodeDecode extends Bencode
102 101
       case 'l':
103 102
         $Value = [];
104 103
         $this->Pos++;
105
-        while ($this->Data[$this->Pos] !== 'e') {
104
+        while ($this->Data[$this->Pos] != 'e') {
106 105
             if ($this->Pos >= $this->Length) {
107 106
                 return $this->error();
108 107
             }
@@ -114,7 +113,7 @@ class BencodeDecode extends Bencode
114 113
       case 'd':
115 114
         $Value = [];
116 115
         $this->Pos++;
117
-        while ($this->Data[$this->Pos] !== 'e') {
116
+        while ($this->Data[$this->Pos] != 'e') {
118 117
             $Length = substr($this->Data, $this->Pos, strpos($this->Data, ':', $this->Pos) - $this->Pos);
119 118
             if (!ctype_digit($Length)) {
120 119
                 return $this->error();

+ 2
- 20
classes/bencodetorrent.class.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * Torrent class that contains some convenient functions related to torrent meta data
5 4
  */
@@ -93,9 +92,8 @@ class BencodeTorrent extends BencodeDecode
93 92
         if (empty($this->Dec)) {
94 93
             return false;
95 94
         }
96
-        return isset($this->Dec['info']['private']) && Int64::get($this->Dec['info']['private']) === 1;
95
+        return isset($this->Dec['info']['private']) && Int64::get($this->Dec['info']['private']) == 1;
97 96
     }
98
-    
99 97
     /**
100 98
      * Add the "private" flag to the torrent
101 99
      *
@@ -125,7 +123,7 @@ class BencodeTorrent extends BencodeDecode
125 123
         if (empty($this->Dec)) {
126 124
             return false;
127 125
         }
128
-        if (isset($this->Dec['info']['source']) && ($this->Dec['info']['source'] === $Sources[0] || $this->Dec['info']['source'] === $Sources[1])) {
126
+        if (isset($this->Dec['info']['source']) && ($this->Dec['info']['source'] == $Sources[0] || $this->Dec['info']['source'] == $Sources[1])) {
129 127
             return false;
130 128
         }
131 129
         $this->Dec['info']['source'] = $Sources[0];
@@ -169,20 +167,4 @@ class BencodeTorrent extends BencodeDecode
169 167
         }
170 168
         return $r.'e'.substr($Data, 1);
171 169
     }
172
-
173
-    /**
174
-     * Add list of web seeds to a torrent
175
-     */
176
-    public static function add_web_seeds($Data, $Urls)
177
-    {
178
-        $r = 'd8:url-listl';
179
-        for ($i = 0; $i < count($Urls); $i++) {
180
-            $r .= 'l';
181
-            for ($j = 0; $j < count($Urls[$i]); $j++) {
182
-                $r .= strlen($Urls[$i][$j]).':'.$Urls[$i][$j];
183
-            }
184
-            $r .= 'e';
185
-        }
186
-        return $r.'e'.substr($Data, 1);
187
-    }
188 170
 }

+ 60
- 51
classes/file_checker.class.php View File

@@ -1,78 +1,87 @@
1 1
 <?php
2
+
2 3
 $ComicsExtensions = array_fill_keys(array('cbr', 'cbz', 'gif', 'jpeg', 'jpg', 'pdf', 'png'), true);
3 4
 $MusicExtensions = array_fill_keys(
4
-  array(
5
+    array(
5 6
     'ac3', 'accurip', 'azw3', 'chm', 'cue', 'djv', 'djvu', 'doc', 'dts', 'epub', 'ffp',
6 7
     'flac', 'gif', 'htm', 'html', 'jpeg', 'jpg', 'lit', 'log', 'm3u', 'm3u8', 'm4a', 'm4b',
7 8
     'md5', 'mobi', 'mp3', 'mp4', 'nfo', 'pdf', 'pls', 'png', 'rtf', 'sfv', 'txt'),
8
-  true);
9
+    true
10
+);
9 11
 $Keywords = array(
10 12
   'ahashare.com', 'demonoid.com', 'demonoid.me', 'djtunes.com', 'h33t', 'housexclusive.net',
11 13
   'limetorrents.com', 'mixesdb.com', 'mixfiend.blogstop', 'mixtapetorrent.blogspot',
12 14
   'plixid.com', 'reggaeme.com' , 'scc.nfo', 'thepiratebay.org', 'torrentday');
13 15
 
14
-function check_file($Type, $Name) {
15
-  check_name($Name);
16
-  check_extensions($Type, $Name);
16
+function check_file($Type, $Name)
17
+{
18
+    check_name($Name);
19
+    check_extensions($Type, $Name);
17 20
 }
18 21
 
19
-function check_name($Name) {
20
-  global $Keywords;
21
-  $NameLC = strtolower($Name);
22
-  foreach ($Keywords as &$Value) {
23
-    if (strpos($NameLC, $Value) !== false) {
24
-      forbidden_error($Name);
22
+function check_name($Name)
23
+{
24
+    global $Keywords;
25
+    $NameLC = strtolower($Name);
26
+    foreach ($Keywords as &$Value) {
27
+        if (strpos($NameLC, $Value) !== false) {
28
+            forbidden_error($Name);
29
+        }
30
+    }
31
+    if (preg_match('/INCOMPLETE~\*/i', $Name)) {
32
+        forbidden_error($Name);
25 33
     }
26
-  }
27
-  if (preg_match('/INCOMPLETE~\*/i', $Name)) {
28
-    forbidden_error($Name);
29
-  }
30 34
 
31
-  /*
32
-   * These characters are invalid in NTFS on Windows systems:
33
-   *    : ? / < > \ * | "
34
-   *
35
-   * todo: Add "/" to the blacklist. Adding "/" to the blacklist causes problems with nested dirs, apparently
36
-   *
37
-   * Only the following characters need to be escaped (see the link below):
38
-   *    \ - ^ ]
39
-   *
40
-   * http://www.php.net/manual/en/regexp.reference.character-classes.php
41
-   */
42
-  $AllBlockedChars = ' : ? < > \ * | " ';
43
-  if (preg_match('/[\\:?<>*|"]/', $Name, $Matches)) {
44
-    character_error($Matches[0], $AllBlockedChars);
45
-  }
35
+    /*
36
+     * These characters are invalid in NTFS on Windows systems:
37
+     *    : ? / < > \ * | "
38
+     *
39
+     * todo: Add "/" to the blacklist. Adding "/" to the blacklist causes problems with nested dirs, apparently
40
+     *
41
+     * Only the following characters need to be escaped (see the link below):
42
+     *    \ - ^ ]
43
+     *
44
+     * http://www.php.net/manual/en/regexp.reference.character-classes.php
45
+     */
46
+    $AllBlockedChars = ' : ? < > \ * | " ';
47
+    if (preg_match('/[\\:?<>*|"]/', $Name, $Matches)) {
48
+        character_error($Matches[0], $AllBlockedChars);
49
+    }
46 50
 }
47 51
 
48
-function check_extensions($Type, $Name) {
49
-  global $MusicExtensions, $ComicsExtensions;
50
-  if ($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy' || $Type == 'E-Books') {
51
-    if (!isset($MusicExtensions[get_file_extension($Name)])) {
52
-      invalid_error($Name);
53
-    }
54
-  } elseif ($Type == 'Comics') {
55
-    if (!isset($ComicsExtensions[get_file_extension($Name)])) {
56
-      invalid_error($Name);
52
+function check_extensions($Type, $Name)
53
+{
54
+    global $MusicExtensions, $ComicsExtensions;
55
+    if ($Type == 'Music' || $Type == 'Audiobooks' || $Type == 'Comedy' || $Type == 'E-Books') {
56
+        if (!isset($MusicExtensions[get_file_extension($Name)])) {
57
+            invalid_error($Name);
58
+        }
59
+    } elseif ($Type == 'Comics') {
60
+        if (!isset($ComicsExtensions[get_file_extension($Name)])) {
61
+            invalid_error($Name);
62
+        }
57 63
     }
58
-  }
59 64
 }
60 65
 
61
-function get_file_extension($FileName) {
62
-  return strtolower(substr(strrchr($FileName, '.'), 1));
66
+function get_file_extension($FileName)
67
+{
68
+    return strtolower(substr(strrchr($FileName, '.'), 1));
63 69
 }
64 70
 
65
-function invalid_error($Name) {
66
-  global $Err;
67
-  $Err = 'The torrent contained one or more invalid files (' . display_str($Name) . ')';
71
+function invalid_error($Name)
72
+{
73
+    global $Err;
74
+    $Err = 'The torrent contained one or more invalid files (' . display_str($Name) . ')';
68 75
 }
69 76
 
70
-function forbidden_error($Name) {
71
-  global $Err;
72
-  $Err = 'The torrent contained one or more forbidden files (' . display_str($Name) . ')';
77
+function forbidden_error($Name)
78
+{
79
+    global $Err;
80
+    $Err = 'The torrent contained one or more forbidden files (' . display_str($Name) . ')';
73 81
 }
74 82
 
75
-function character_error($Character, $AllBlockedChars) {
76
-  global $Err;
77
-  $Err = "One or more of the files or folders in the torrent has a name that contains the forbidden character '$Character'. Please rename the files as necessary and recreate the torrent.<br /><br />\nNote: The complete list of characters that are disallowed are shown below:<br />\n\t\t$AllBlockedChars";
83
+function character_error($Character, $AllBlockedChars)
84
+{
85
+    global $Err;
86
+    $Err = "One or more of the files or folders in the torrent has a name that contains the forbidden character '$Character'. Please rename the files as necessary and recreate the torrent.<br /><br />\nNote: The complete list of characters that are disallowed are shown below:<br />\n\t\t$AllBlockedChars";
78 87
 }

+ 2
- 2
classes/torrents.class.php View File

@@ -2,7 +2,7 @@
2 2
 
3 3
 class Torrents
4 4
 {
5
-  const FILELIST_DELIM = 0xF7; // Hex for &divide; Must be the same as phrase_boundary in sphinx.conf!
5
+    const FILELIST_DELIM = 0xF7; // Hex for &divide; Must be the same as phrase_boundary in sphinx.conf!
6 6
   const SNATCHED_UPDATE_INTERVAL = 3600; // How often we want to update users' snatch lists
7 7
   const SNATCHED_UPDATE_AFTERDL = 300; // How long after a torrent download we want to update a user's snatch lists
8 8
 
@@ -1230,7 +1230,7 @@ class Torrents
1230 1230
         return $EditionName;
1231 1231
     }
1232 1232
 
1233
-    //Used to get reports info on a unison cache in both browsing pages and torrent pages.
1233
+    // Used to get reports info on a unison cache in both browsing pages and torrent pages.
1234 1234
     public static function get_reports($TorrentID)
1235 1235
     {
1236 1236
         $Reports = G::$Cache->get_value("reports_torrent_$TorrentID");

+ 7
- 28
classes/torrentsdl.class.php View File

@@ -1,5 +1,4 @@
1 1
 <?php
2
-
3 2
 /**
4 3
  * Class for functions related to the features involving torrent downloads
5 4
  */
@@ -19,7 +18,6 @@ class TorrentsDL
19 18
     private $User;
20 19
     private $AnnounceURL;
21 20
     private $AnnounceList;
22
-    private $WebSeeds;
23 21
 
24 22
     /**
25 23
      * Create a Zip object and store the query results
@@ -31,20 +29,17 @@ class TorrentsDL
31 29
     public function __construct(&$QueryResult, $Title)
32 30
     {
33 31
         G::$Cache->InternalCache = false; // The internal cache is almost completely useless for this
34
-        Zip::unlimit(); // Need more memory and longer timeout
35
-        $this->QueryResult = $QueryResult;
32
+    Zip::unlimit(); // Need more memory and longer timeout
33
+    $this->QueryResult = $QueryResult;
36 34
         $this->Title = $Title;
37 35
         $this->User = G::$LoggedUser;
38
-        $this->AnnounceURL = ANNOUNCE_URLS[0][0].'/'.G::$LoggedUser['torrent_pass'].'/announce';
39
-
36
+        $this->AnnounceURL = ANNOUNCE_URLS[0][0]."/".G::$LoggedUser['torrent_pass']."/announce";
40 37
         function add_passkey($Ann)
41 38
         {
42
-            return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann.'/'.G::$LoggedUser['torrent_pass'].'/announce';
39
+            return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann."/".G::$LoggedUser['torrent_pass']."/announce";
43 40
         }
44
-
45 41
         $this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
46
-        #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
47
-        $this->WebSeeds = [];
42
+        #$this->AnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
48 43
         $this->Zip = new Zip(Misc::file_string($Title));
49 44
     }
50 45
 
@@ -241,38 +236,22 @@ class TorrentsDL
241 236
      * @param mixed $TorrentData bencoded torrent without announce URL (new format) or TORRENT object (old format)
242 237
      * @return bencoded string
243 238
      */
244
-    public static function get_file(&$TorrentData, $AnnounceURL, $AnnounceList = [], $WebSeeds = [])
239
+    public static function get_file(&$TorrentData, $AnnounceURL, $AnnounceList = [])
245 240
     {
246 241
         if (Misc::is_new_torrent($TorrentData)) {
247 242
             $Bencode = BencodeTorrent::add_announce_url($TorrentData, $AnnounceURL);
248
-
249
-            # Announce list
250 243
             if (!empty($AnnounceList)) {
251 244
                 $Bencode = BencodeTorrent::add_announce_list($Bencode, $AnnounceList);
252 245
             }
253
-
254
-            # Web seeds
255
-            if (!empty($WebSeeds)) {
256
-                $Bencode = BencodeTorrent::add_web_seeds($Bencode, $WebSeeds);
257
-            }
258 246
             return $Bencode;
259 247
         }
260
-
261 248
         $Tor = new TORRENT(unserialize(base64_decode($TorrentData)), true);
262 249
         $Tor->set_announce_url($AnnounceURL);
263 250
         unset($Tor->Val['announce-list']);
264
-
265
-        # Announce list
266 251
         if (!empty($AnnounceList)) {
267 252
             $Tor->set_announce_list($AnnounceList);
268 253
         }
269
-
270
-        # Web seeds
271
-        if (!empty($WebSeeds)) {
272
-            $Tor->add_web_seeds($WebSeeds);
273
-        }
274
-        
275
-        #unset($Tor->Val['url-list']);
254
+        unset($Tor->Val['url-list']);
276 255
         unset($Tor->Val['libtorrent_resume']);
277 256
         return $Tor->enc();
278 257
     }

+ 2
- 2
sections/requests/new_edit.php View File

@@ -121,8 +121,8 @@ View::show_header(($NewRequest ? 'Create Request' : 'Edit Request'), 'bbcode,req
121 121
       <!-- Main table -->
122 122
       <table class="layout">
123 123
         <tr>
124
-          <td colspan="2" class="center">Please make sure your request follows <a href="rules.php?p=requests">the
125
-              request rules</a>!</td>
124
+          <td colspan="2" class="center">Please make sure your request follows the
125
+            <a href="rules.php?p=requests">request rules</a>!</td>
126 126
         </tr>
127 127
         <?php  if ($NewRequest || $CanEdit) { ?>
128 128
 

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

@@ -250,7 +250,7 @@ View::show_header('Browse Torrents', 'browse');
250 250
             <td class="nobr ft_ripspecifics">
251 251
 
252 252
               <select name="media" class="ft_media fti_advanced">
253
-                <option value="">DNA/RNA/Proteins</option>
253
+                <option value="">Sequencing</option>
254 254
                 <?php  foreach ($Media as $MediaName) { ?>
255 255
                 <option value="<?=display_str($MediaName); ?>"
256 256
                 <?Format::selected('media', $MediaName)?>><?=display_str($MediaName); ?>
@@ -318,7 +318,7 @@ View::show_header('Browse Torrents', 'browse');
318 318
                 <option value="">Assembly Level</option>
319 319
                 <?php  foreach ($Resolutions as $Resolution) { ?>
320 320
                 <option value="<?=display_str($Resolution); ?>"
321
-                <?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?>"
321
+                <?Format::selected('resolution', $Resolution)?>><?=display_str($Resolution); ?>
322 322
                 </option>
323 323
                 <?php  } ?>
324 324
               </select>

+ 4
- 3
sections/torrents/details.php View File

@@ -1,4 +1,5 @@
1 1
 <?php
2
+
2 3
 function compare($X, $Y)
3 4
 {
4 5
     return($Y['name'] < $X['name']);
@@ -964,12 +965,12 @@ if (count($PersonalCollages) > 0) {
964 965
       </div>
965 966
     </div>
966 967
 
967
-        <!-- Mirrors -->
968
-        <div class="box torrent_mirrors_box <?php if (!count($Mirrors)) {
968
+    <!-- Mirrors -->
969
+    <div class="box torrent_mirrors_box <?php if (!count($Mirrors)) {
969 970
     echo 'dead';
970 971
 } ?>">
971 972
       <div class="head"><a href="#">&uarr;</a>&nbsp;<strong>
972
-      Mirrors (<?= count($Mirrors) ?>)</strong>
973
+          Mirrors (<?= count($Mirrors) ?>)</strong>
973 974
         <?php
974 975
     if (count($Mirrors) > 0) {
975 976
         ?>

+ 26
- 36
sections/torrents/download.php View File

@@ -13,41 +13,40 @@ if (!isset($_REQUEST['authkey']) || !isset($_REQUEST['torrent_pass'])) {
13 13
     $UserInfo = $Cache->get_value('user_'.$_REQUEST['torrent_pass']);
14 14
     if (!is_array($UserInfo)) {
15 15
         $DB->query("
16
-        SELECT ID, la.UserID
17
-          FROM users_main AS m
16
+      SELECT ID, la.UserID
17
+      FROM users_main AS m
18 18
         INNER JOIN users_info AS i ON i.UserID = m.ID
19 19
         LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
20
-          WHERE m.torrent_pass = '".db_string($_REQUEST['torrent_pass'])."'
21
-          AND m.Enabled = '1'");
20
+      WHERE m.torrent_pass = '".db_string($_REQUEST['torrent_pass'])."'
21
+        AND m.Enabled = '1'");
22 22
         $UserInfo = $DB->next_record();
23 23
         $Cache->cache_value('user_'.$_REQUEST['torrent_pass'], $UserInfo, 3600);
24 24
     }
25
-
26 25
     $UserInfo = array($UserInfo);
27 26
     list($UserID, $Locked) = array_shift($UserInfo);
28 27
     if (!$UserID) {
29 28
         error(0);
30 29
     }
31
-
32 30
     $TorrentPass = $_REQUEST['torrent_pass'];
33 31
     $AuthKey = $_REQUEST['authkey'];
34 32
 
35
-    if ($Locked === $UserID) {
33
+    if ($Locked == $UserID) {
36 34
         header('HTTP/1.1 403 Forbidden');
37 35
         die();
38 36
     }
39 37
 }
40 38
 
41 39
 $TorrentID = $_REQUEST['id'];
40
+
42 41
 if (!is_number($TorrentID)) {
43 42
     error(0);
44 43
 }
45 44
 
46 45
 /*
47
- * uTorrent Remote and various scripts redownload .torrent files periodically.
48
- * To prevent this retardation from blowing bandwidth etc., let's block it
49
- * if the .torrent file has been downloaded four times before
50
-*/
46
+  uTorrent Remote and various scripts redownload .torrent files periodically.
47
+  To prevent this retardation from blowing bandwidth etc., let's block it
48
+  if the .torrent file has been downloaded four times before
49
+ */
51 50
 $ScriptUAs = array('BTWebClient*', 'Python-urllib*', 'python-requests*');
52 51
 if (Misc::in_array_partial($_SERVER['HTTP_USER_AGENT'], $ScriptUAs)) {
53 52
     $DB->query("
@@ -56,7 +55,6 @@ if (Misc::in_array_partial($_SERVER['HTTP_USER_AGENT'], $ScriptUAs)) {
56 55
     WHERE UserID = $UserID
57 56
       AND TorrentID = $TorrentID
58 57
     LIMIT 4");
59
-
60 58
     if ($DB->record_count() === 4) {
61 59
         error('You have already downloaded this torrent file four times. If you need to download it again, please do so from your browser.', true);
62 60
         die();
@@ -75,36 +73,29 @@ if (!is_array($Info) || !array_key_exists('PlainArtists', $Info) || empty($Info[
75 73
       COALESCE(NULLIF(tg.Name,''), NULLIF(tg.NameRJ,''), tg.NameJP) AS Name,
76 74
       tg.WikiImage,
77 75
       tg.CategoryID,
78
-      tm.Resource,
79 76
       t.Size,
80 77
       t.FreeTorrent,
81 78
       HEX(t.info_hash)
82 79
     FROM torrents AS t
83 80
       INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID
84
-      LEFT JOIN torrents_mirrors AS tm ON tm.ID = t.GroupID
85 81
     WHERE t.ID = '".db_string($TorrentID)."'");
86
-
87 82
     if (!$DB->has_results()) {
88 83
         error(404);
89 84
     }
90
-
91 85
     $Info = array($DB->next_record(MYSQLI_NUM, array(4, 5, 6, 10)));
92 86
     $Artists = Artists::get_artist($Info[0][4], false);
93 87
     $Info['Artists'] = Artists::display_artists($Artists, false, true);
94 88
     $Info['PlainArtists'] = Artists::display_artists($Artists, false, true, false);
95 89
     $Cache->cache_value("torrent_download_$TorrentID", $Info, 0);
96 90
 }
97
-
98 91
 if (!is_array($Info[0])) {
99 92
     error(404);
100 93
 }
101
-
102
-list($Media, $Format, $Encoding, $Year, $GroupID, $Name, $Image, $CategoryID, $Resources, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // Used for generating the filename
94
+list($Media, $Format, $Encoding, $Year, $GroupID, $Name, $Image, $CategoryID, $Size, $FreeTorrent, $InfoHash) = array_shift($Info); // used for generating the filename
103 95
 $Artists = $Info['Artists'];
104 96
 
105 97
 // If he's trying use a token on this, we need to make sure he has one,
106 98
 // deduct it, add this to the FLs table, and update his cache key.
107
-// todo: Make sure strict equality works
108 99
 if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
109 100
     if (isset($LoggedUser)) {
110 101
         $FLTokens = $LoggedUser['FLTokens'];
@@ -135,16 +126,16 @@ if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
135 126
 
136 127
         if (!Torrents::has_token($TorrentID)) {
137 128
             $DB->query("
138
-            INSERT INTO users_freeleeches (UserID, TorrentID, Time)
139
-            VALUES ($UserID, $TorrentID, NOW())
140
-            ON DUPLICATE KEY UPDATE
141
-              Time = VALUES(Time),
142
-              Expired = FALSE,
143
-              Uses = Uses + 1");
129
+        INSERT INTO users_freeleeches (UserID, TorrentID, Time)
130
+        VALUES ($UserID, $TorrentID, NOW())
131
+        ON DUPLICATE KEY UPDATE
132
+          Time = VALUES(Time),
133
+          Expired = FALSE,
134
+          Uses = Uses + 1");
144 135
             $DB->query("
145
-            UPDATE users_main
146
-            SET FLTokens = FLTokens - 1
147
-            WHERE ID = $UserID");
136
+        UPDATE users_main
137
+        SET FLTokens = FLTokens - 1
138
+        WHERE ID = $UserID");
148 139
 
149 140
             // Fix for downloadthemall messing with the cached token count
150 141
             $UInfo = Users::user_heavy_info($UserID);
@@ -159,7 +150,7 @@ if ($_REQUEST['usetoken'] && $FreeTorrent == '0') {
159 150
     }
160 151
 }
161 152
 
162
-// Stupid Recent Snatches on User Page
153
+// Stupid Recent Snatches On User Page
163 154
 if ($Image != '') {
164 155
     $RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
165 156
     if (!empty($RecentSnatches)) {
@@ -191,16 +182,15 @@ $FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year,
191 182
 header('Content-Type: application/x-bittorrent; charset=utf-8');
192 183
 header('Content-disposition: attachment; filename="'.$FileName.'"');
193 184
 
194
-function add_passkey($Ann)
185
+function add_passkey($ann)
195 186
 {
196 187
     global $TorrentPass;
197
-    return (is_array($Ann)) ? array_map('add_passkey', $Ann) : $Ann.'/'.$TorrentPass.'/announce';
188
+    return (is_array($ann)) ? array_map("add_passkey", $ann) : $ann."/".$TorrentPass."/announce";
198 189
 }
199
-
200
-$UserAnnounceURL = ANNOUNCE_URLS[0][0].'/'.$TorrentPass.'/announce';
190
+$UserAnnounceURL = ANNOUNCE_URLS[0][0]."/".$TorrentPass."/announce";
201 191
 $UserAnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array(array_map('add_passkey', ANNOUNCE_URLS[0]), ANNOUNCE_URLS[1]);
202
-#$UserAnnounceList = (sizeof(ANNOUNCE_URLS) === 1 && sizeof(ANNOUNCE_URLS[0]) === 1) ? [] : array_map('add_passkey', ANNOUNCE_URLS);
192
+#$UserAnnounceList = (sizeof(ANNOUNCE_URLS) == 1 && sizeof(ANNOUNCE_URLS[0]) == 1) ? [] : array_map("add_passkey", ANNOUNCE_URLS);
203 193
 
204
-echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList, $Resources);
194
+echo TorrentsDL::get_file($Contents, $UserAnnounceURL, $UserAnnounceList);
205 195
 
206 196
 define('SKIP_NO_CACHE_HEADERS', 1);

Loading…
Cancel
Save