|
@@ -1,4 +1,5 @@
|
1
|
1
|
<?php
|
|
2
|
+
|
2
|
3
|
/*******************************************************************************
|
3
|
4
|
|~~~~ Gazelle bencode parser ~~~~|
|
4
|
5
|
--------------------------------------------------------------------------------
|
|
@@ -158,12 +159,12 @@ class BENCODE_LIST extends BENCODE2
|
158
|
159
|
|
159
|
160
|
if ($Type === 'e') { // End of list
|
160
|
161
|
$this->Pos += 1;
|
161
|
|
- unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
|
|
162
|
+ unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster
|
162
|
163
|
return;
|
163
|
164
|
}
|
164
|
165
|
|
165
|
|
- // Decode the bencoded element.
|
166
|
|
- // This function changes $this->Pos and $this->Val, so you don't have to.
|
|
166
|
+ // Decode the bencoded element
|
|
167
|
+ // This function changes $this->Pos and $this->Val, so you don't have to
|
167
|
168
|
$this->decode($Type, $Key);
|
168
|
169
|
++$Key;
|
169
|
170
|
}
|
|
@@ -193,7 +194,7 @@ class BENCODE_DICT extends BENCODE2
|
193
|
194
|
while ($this->Pos<$Length) {
|
194
|
195
|
if ($this->Str[$this->Pos] === 'e') { // End of dictionary
|
195
|
196
|
$this->Pos += 1;
|
196
|
|
- unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster.
|
|
197
|
+ unset($this->Str); // Since we're finished parsing the string, we don't need to store it anymore. Benchmarked - this makes the parser run way faster
|
197
|
198
|
return;
|
198
|
199
|
}
|
199
|
200
|
|
|
@@ -219,15 +220,14 @@ class BENCODE_DICT extends BENCODE2
|
219
|
220
|
// $Type now indicates what type of element we're dealing with
|
220
|
221
|
// It's either an integer (string), 'i' (an integer), 'l' (a list), 'd' (a dictionary), or 'e' (end of dictionary/list)
|
221
|
222
|
|
222
|
|
- // Decode the bencoded element.
|
223
|
|
- // This function changes $this->Pos and $this->Val, so you don't have to.
|
|
223
|
+ // Decode the bencoded element
|
|
224
|
+ // This function changes $this->Pos and $this->Val, so you don't have to
|
224
|
225
|
$this->decode($Type, $Key);
|
225
|
226
|
}
|
226
|
227
|
return true;
|
227
|
228
|
}
|
228
|
229
|
}
|
229
|
230
|
|
230
|
|
-
|
231
|
231
|
class TORRENT extends BENCODE_DICT
|
232
|
232
|
{
|
233
|
233
|
public function dump()
|
|
@@ -328,7 +328,7 @@ class TORRENT extends BENCODE_DICT
|
328
|
328
|
return true; // Torrent is private
|
329
|
329
|
} else {
|
330
|
330
|
// Torrent is not private!
|
331
|
|
- // add private tracker flag and sort info dictionary
|
|
331
|
+ // Add private tracker flag and sort info dictionary
|
332
|
332
|
$this->Val['info']->Val['private'] = 1;
|
333
|
333
|
ksort($this->Val['info']->Val);
|
334
|
334
|
return false;
|