PHP 클래스 Torrent, torrent-rw

파일 보기 프로젝트 열기: adriengibrat/torrent-rw 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_errors List of error occured

공개 메소드들

메소드 설명
__construct ( $data = null, $meta = [], $piece_length = 256 ) Read and decode torrent file/data OR build a torrent from source folder/file(s) Supported signatures: - Torrent(); // get an instance (usefull to scrape and check errors) - Torrent( string $torrent ); // analyse a torrent file - Torrent( string $torrent, string $announce ); - Torrent( string $torrent, array $meta ); - Torrent( string $file_or_folder ); // create a torrent file - Torrent( string $file_or_folder, string $announce_url, [int $piece_length] ); - Torrent( string $file_or_folder, array $meta, [int $piece_length] ); - Torrent( array $files_list ); - Torrent( array $files_list, string $announce_url, [int $piece_length] ); - Torrent( array $files_list, array $meta, [int $piece_length] );
__toString ( ) : string Convert the current Torrent instance in torrent format
announce ( $announce = null ) : string | array | null Getter and setter of torrent announce url / list If the argument is a string, announce url is added to announce list (or set as announce if announce is not set) If the argument is an array/object, set announce url (with first url) and list (if array has more than one url), tiered list supported If the argument is false announce url & list are unset
comment ( $comment = null ) : string | null Getter and setter of torrent comment
content ( $precision = null ) : array List torrent content
encode ( $mixed ) : string Encode torrent data
error ( ) : string | boolean Return last error message
errors ( ) : array | boolean Return Errors
file_get_contents ( $file, $timeout = self::timeout, $offset = null, $length = null ) : string | boolean Helper to get (distant) file content
filesize ( $file ) : double | boolean Helper to return filesize (even bigger than 2Gb -linux only- and distant files size)
fopen ( $file, $size = null ) : ressource | boolean Helper to open file to read (even bigger than 2Gb, linux only)
format ( $size, $precision = 2 ) : string Helper to format size in bytes to human readable
hash_info ( ) : string Compute hash info
httpseeds ( $urls = null ) : array | null Getter and setter of httpseed(s) url list ( Bittornado implementation )
is_private ( $private = null ) : boolean Getter and setter of private flag
is_torrent ( $file, $timeout = self::timeout ) : boolean Helper to check if a file is a torrent
is_url ( $url ) : boolean Helper to check if string is an url (http)
magnet ( $html = true ) : string Get magnet link
name ( $name = null ) : string | null Getter and setter of torrent name
offset ( ) : array List torrent content pieces and offset(s)
piece_length ( ) : integer Get piece length
save ( $filename = null ) : boolean Save torrent file to disk
scandir ( $dir ) : array Helper to scan directories files and sub directories recursivly
scrape ( $announce = null, $hash_info = null, $timeout = self::timeout ) * static
send ( $filename = null ) : void Send torrent file to client
size ( $precision = null ) : integer | string Sum torrent content size
source ( $source = null ) : string | null Getter and setter of torrent source
untier ( $announces ) : array Flatten announces list
url_exists ( $url ) : boolean Helper to check if url exists
url_list ( $urls = null ) : string | array | null Getter and setter of webseed(s) url list ( GetRight implementation )

보호된 메소드들

메소드 설명
announce_list ( $announce, $merge = [] ) : array Build announce list
build ( $data, $piece_length ) : array | boolean Build torrent info
decode ( $string ) : array Decode torrent data or file
first_announce ( $announce ) : string Get the first announce url in a list
is_list ( $array ) : boolean Helper to test if an array is a list
pack ( &$data ) : string Helper to pack data hash
path ( $path, $folder ) : string Helper to build file path
path_explode ( $path ) : array Helper to explode file path
set_error ( $exception, $message = false ) : boolean | string Add an error to errors stack
touch ( $void = null ) : any Set torrent creator and creation date

비공개 메소드들

메소드 설명
char ( $data ) : string | boolean Helper to return the first char of encoded data
decode_data ( &$data ) : array Decode torrent data
decode_dictionary ( &$data ) : array Decode torrent dictionary
decode_integer ( &$data ) : integer Decode torrent integer
decode_list ( &$data ) : array Decode torrent list
decode_string ( &$data ) : string Decode torrent string
encode_array ( $array ) : string Encode torrent dictionary or list
encode_integer ( $integer ) : string Encode torrent integer
encode_string ( $string ) : string Encode torrent string
file ( $file, $piece_length ) : array Build torrent info from single file
files ( $files, $piece_length ) : array Build torrent info from files
folder ( $dir, $piece_length ) : array Build torrent info from folder content
pieces ( $handle, $piece_length, $last = true ) : string Build pieces depending on piece length from a file handler

메소드 상세

__construct() 공개 메소드

Read and decode torrent file/data OR build a torrent from source folder/file(s) Supported signatures: - Torrent(); // get an instance (usefull to scrape and check errors) - Torrent( string $torrent ); // analyse a torrent file - Torrent( string $torrent, string $announce ); - Torrent( string $torrent, array $meta ); - Torrent( string $file_or_folder ); // create a torrent file - Torrent( string $file_or_folder, string $announce_url, [int $piece_length] ); - Torrent( string $file_or_folder, array $meta, [int $piece_length] ); - Torrent( array $files_list ); - Torrent( array $files_list, string $announce_url, [int $piece_length] ); - Torrent( array $files_list, array $meta, [int $piece_length] );
public __construct ( $data = null, $meta = [], $piece_length = 256 )

__toString() 공개 메소드

Convert the current Torrent instance in torrent format
public __toString ( ) : string
리턴 string encoded torrent data

announce() 공개 메소드

Getter and setter of torrent announce url / list If the argument is a string, announce url is added to announce list (or set as announce if announce is not set) If the argument is an array/object, set announce url (with first url) and list (if array has more than one url), tiered list supported If the argument is false announce url & list are unset
public announce ( $announce = null ) : string | array | null
리턴 string | array | null announce url / list or null if not set

announce_list() 보호된 정적인 메소드

Build announce list
protected static announce_list ( $announce, $merge = [] ) : array
리턴 array announce list (array of arrays)

build() 보호된 메소드

Build torrent info
protected build ( $data, $piece_length ) : array | boolean
리턴 array | boolean torrent info or false if data isn't folder/file(s)

comment() 공개 메소드

Getter and setter of torrent comment
public comment ( $comment = null ) : string | null
리턴 string | null comment or null if not set

content() 공개 메소드

List torrent content
public content ( $precision = null ) : array
리턴 array file(s) and size(s) list, files as keys and sizes as values

decode() 보호된 정적인 메소드

Decode torrent data or file
protected static decode ( $string ) : array
리턴 array decoded torrent data

encode() 공개 정적인 메소드

Encode torrent data
public static encode ( $mixed ) : string
리턴 string torrent encoded data

error() 공개 메소드

Return last error message
public error ( ) : string | boolean
리턴 string | boolean last error message or false if none

errors() 공개 메소드

Return Errors
public errors ( ) : array | boolean
리턴 array | boolean error list or false if none

file_get_contents() 공개 정적인 메소드

Helper to get (distant) file content
public static file_get_contents ( $file, $timeout = self::timeout, $offset = null, $length = null ) : string | boolean
리턴 string | boolean file content or false if error

filesize() 공개 정적인 메소드

Helper to return filesize (even bigger than 2Gb -linux only- and distant files size)
public static filesize ( $file ) : double | boolean
리턴 double | boolean filesize or false if error

first_announce() 보호된 정적인 메소드

Get the first announce url in a list
protected static first_announce ( $announce ) : string
리턴 string first announce url

fopen() 공개 정적인 메소드

Helper to open file to read (even bigger than 2Gb, linux only)
public static fopen ( $file, $size = null ) : ressource | boolean
리턴 ressource | boolean file handle or false if error

format() 공개 정적인 메소드

Helper to format size in bytes to human readable
public static format ( $size, $precision = 2 ) : string
리턴 string formated size in appropriate unit

hash_info() 공개 메소드

Compute hash info
public hash_info ( ) : string
리턴 string hash info or null if info not set

httpseeds() 공개 메소드

Getter and setter of httpseed(s) url list ( Bittornado implementation )
public httpseeds ( $urls = null ) : array | null
리턴 array | null httpseed(s) or null if not set

is_list() 보호된 정적인 메소드

Helper to test if an array is a list
protected static is_list ( $array ) : boolean
리턴 boolean is the array a list or not

is_private() 공개 메소드

Getter and setter of private flag
public is_private ( $private = null ) : boolean
리턴 boolean private flag

is_torrent() 공개 정적인 메소드

Helper to check if a file is a torrent
public static is_torrent ( $file, $timeout = self::timeout ) : boolean
리턴 boolean is the file a torrent or not

is_url() 공개 정적인 메소드

Helper to check if string is an url (http)
public static is_url ( $url ) : boolean
리턴 boolean is string an url

magnet() 공개 메소드

Get magnet link
public magnet ( $html = true ) : string
리턴 string magnet link

name() 공개 메소드

Getter and setter of torrent name
public name ( $name = null ) : string | null
리턴 string | null name or null if not set

offset() 공개 메소드

List torrent content pieces and offset(s)
public offset ( ) : array
리턴 array file(s) and pieces/offset(s) list, file(s) as keys and pieces/offset(s) as values

pack() 보호된 정적인 메소드

Helper to pack data hash
protected static pack ( &$data ) : string
리턴 string packed data hash

path() 보호된 정적인 메소드

Helper to build file path
protected static path ( $path, $folder ) : string
리턴 string real file path

path_explode() 보호된 정적인 메소드

Helper to explode file path
protected static path_explode ( $path ) : array
리턴 array file path

piece_length() 공개 메소드

Get piece length
public piece_length ( ) : integer
리턴 integer piece length or null if not set

save() 공개 메소드

Save torrent file to disk
public save ( $filename = null ) : boolean
리턴 boolean file has been saved or not

scandir() 공개 정적인 메소드

Helper to scan directories files and sub directories recursivly
public static scandir ( $dir ) : array
리턴 array directory content list

scrape() 공개 메소드

* static
public scrape ( $announce = null, $hash_info = null, $timeout = self::timeout )

send() 공개 메소드

Send torrent file to client
public send ( $filename = null ) : void
리턴 void script exit

set_error() 보호된 정적인 메소드

Add an error to errors stack
protected static set_error ( $exception, $message = false ) : boolean | string
리턴 boolean | string return false or error message if requested

size() 공개 메소드

Sum torrent content size
public size ( $precision = null ) : integer | string
리턴 integer | string file(s) size

source() 공개 메소드

Getter and setter of torrent source
public source ( $source = null ) : string | null
리턴 string | null source or null if not set

touch() 보호된 메소드

Set torrent creator and creation date
protected touch ( $void = null ) : any
리턴 any param

untier() 공개 정적인 메소드

Flatten announces list
public static untier ( $announces ) : array
리턴 array flattened annonces list

url_exists() 공개 정적인 메소드

Helper to check if url exists
public static url_exists ( $url ) : boolean
리턴 boolean does the url exist or not

url_list() 공개 메소드

Getter and setter of webseed(s) url list ( GetRight implementation )
public url_list ( $urls = null ) : string | array | null
리턴 string | array | null webseed(s) or null if not set

프로퍼티 상세

$_errors 보호되어 있는 정적으로 프로퍼티

List of error occured
protected static $_errors