File_Bittorrent2
[ class tree: File_Bittorrent2 ] [ index: File_Bittorrent2 ] [ all elements ]

Class: File_Bittorrent2_Decode

Source Location: /File_Bittorrent2-1.3.1/File/Bittorrent2/Decode.php

Class Overview


Encode data in Bittorrent format


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 73]
Encode data in Bittorrent format

Based on Original Python implementation by Petru Paler <petru@paler.net> PHP translation by Gerard Krijgsman <webmaster@animesuki.com> Gerard's regular expressions removed by Carl Ritson <critson@perlfu.co.uk> Info on the .torrent file format BEncoding is a simple, easy to implement method of associating data types with information in a file. The values in a torrent file are bEncoded. There are 4 different data types that can be bEncoded: Integers, Strings, Lists and Dictionaries. [http://www.monduna.com/bt/faq.html]



[ Top ]


Class Variables

$announce =  ''

[line 113]

  • Var: tracker (the tracker the torrent has been received from)
  • Access: protected

Type:   string


[ Top ]

$announce_list = array()

[line 118]

  • Var: List of known trackers for the torrent
  • Access: protected

Type:   array


[ Top ]

$comment =  ''

[line 88]

  • Var: Comment
  • Access: protected

Type:   string


[ Top ]

$created_by =  ''

[line 108]

  • Var: Signature of the software which created the torrent
  • Access: protected

Type:   string


[ Top ]

$date =  0

[line 93]

  • Var: Creation date as unix timestamp
  • Access: protected

Type:   int


[ Top ]

$decoded = array()

[line 138]

  • Var: Decoded data from File_Bittorrent2_Decode::decodeFile()
  • Access: protected

Type:   array


[ Top ]

$filename =  ''

[line 83]

  • Var: Filename of the torrent
  • Access: protected

Type:   string


[ Top ]

$files = array()

[line 98]

  • Var: Files in the torrent
  • Access: protected

Type:   array


[ Top ]

$is_private =  false

[line 143]

  • Var: Torrent is marked as 'private'.
  • Access: protected

Type:   bool


[ Top ]

$name =  ''

[line 78]

  • Var: Name of the torrent
  • Access: protected

Type:   string


[ Top ]

$position =  0

[line 133]

  • Var: Current position of the string
  • Access: protected

Type:   int


[ Top ]

$size =  0

[line 103]

  • Var: Size of of the full torrent (after download)
  • Access: protected

Type:   int


[ Top ]

$source =  ''

[line 123]

  • Var: Source string
  • Access: protected

Type:   string


[ Top ]

$source_length =  0

[line 128]

  • Var: Source length
  • Access: protected

Type:   int


[ Top ]



Method Detail

bdecode   [line 278]

mixed bdecode( )

Decode a BEncoded String
  • Return: Returns the representation of the data in the BEncoded string or false on error
  • Access: protected

[ Top ]

decode   [line 152]

mixed decode( string $str)

Decode a Bencoded string
  • Throws: File_Bittorrent2_Exception if decoded data contains trailing garbage

Parameters:

string   $str   — 

[ Top ]

decodeFile   [line 171]

mixed decodeFile( string $file)

Decode .torrent file and accumulate information
  • Return: Returns an arrayon success or false on error
  • Throws: File_Bittorrent2_Exception if no file given or bencoded data is corrupt

Parameters:

string   $file   —  Filename

[ Top ]

decode_dict   [line 309]

array decode_dict( )

Decode a BEncoded dictionary

Dictionaries are prefixed with a d and terminated by an e. They are similar to list, except that items are in key value pairs. The dictionary {"key":"value", "Monduna":"com", "bit":"Torrents", "number":7} would bEncode to d3:key5:value7:Monduna3:com3:bit:8:Torrents6:numberi7ee

  • Throws: File_Bittorrent2_Exception if bencoded dictionary contains invalid data
  • Access: protected

[ Top ]

decode_int   [line 391]

int decode_int( )

Decode a BEncoded integer

Integers are prefixed with an i and terminated by an e. For example, 123 would bEcode to i123e, -3272002 would bEncode to i-3272002e.

  • Throws: File_Bittorrent2_Exception if bencoded data is invalid
  • Access: protected

[ Top ]

decode_list   [line 428]

array decode_list( )

Decode a BEncoded list

Lists are prefixed with a l and terminated by an e. The list should contain a series of bEncoded elements. For example, the list of strings ["Monduna", "Bit", "Torrents"] would bEncode to l7:Monduna3:Bit8:Torrentse. The list [1, "Monduna", 3, ["Sub", "List"]] would bEncode to li1e7:Mondunai3el3:Sub4:Listee

  • Throws: File_Bittorrent2_Exception if bencoded data is invalid
  • Access: protected

[ Top ]

decode_string   [line 353]

string|false decode_string( )

Decode a BEncoded string

Strings are prefixed with their length followed by a colon. For example, "Monduna" would bEncode to 7:Monduna and "BitTorrents" would bEncode to 11:BitTorrents.

  • Throws: File_Bittorrent2_Exception if bencoded data is invalid
  • Access: protected

[ Top ]

getAnnounce   [line 561]

string getAnnounce( )

Returns the the tracker the torrent has been received from

[ Top ]

getAnnounceList   [line 571]

array getAnnounceList( )

Returns the known tracker list of the torrent

[ Top ]

getChar   [line 455]

string|false getChar( )

Get the char at the current position
  • Access: protected

[ Top ]

getComment   [line 521]

string getComment( )

Returns the Comment of the torrent

[ Top ]

getCreator   [line 541]

string getCreator( )

Returns the Creator info of the torrent

[ Top ]

getDate   [line 531]

string getDate( )

Returns the Date of the torrent

[ Top ]

getFilename   [line 511]

string getFilename( )

Returns the Filename of the torrent

[ Top ]

getFiles   [line 551]

array getFiles( )

Returns the Files of the torrent

[ Top ]

getInfoHash   [line 582]

string getInfoHash( [ $raw = false])

Returns the info hash of the torrent

Parameters:

   $raw   — 

[ Top ]

getName   [line 501]

string getName( )

Returns the Name of the torrent

[ Top ]

getStats   [line 468]

array|false getStats( )

Returns the online stats for the torrent
  • Throws: File_Bittorrent2_Exception if allow_url_fopen is disabled or scrape data is invalid

[ Top ]

isPrivate   [line 602]

bool isPrivate( )

Returns whether the torrent is marked as 'private'

Taken from http://www.azureuswiki.com/index.php/Secure_Torrents

Tracker sites wanting to ensure that [clients] only obtains peers directly from the tracker itself (besides incoming connections) should embed the key "private" with the value "1" inside the "info" dict of the .torrent file:

  1. infod6:lengthi136547e4:name6:a............7:privatei1ee

  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:31:15 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.