Coder Social home page Coder Social logo

alphaone89 / php-class-torrent-create-read-write Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adriengibrat/torrent-rw

0.0 1.0 0.0 153 KB

PHP class that allows to create, read and write torrent files.

License: GNU General Public License v3.0

PHP 100.00%

php-class-torrent-create-read-write's Introduction

PHP Class Torrent Create Read Write

Features

  • Decode torrent file or data
  • Build torrent from source folder/file(s)
  • Silent Exception error system

Usage

<?php

     header( 'Content-Type:text/plain' );

     require_once 'php-class-torrent-create-read-write.php';

    # GET TORRENT INFOS

    $torrent = new Torrent( './test.torrent' );

    echo 'IS PRIVATE -- ' . ( $torrent->is_private() ? 'yes' : 'no' ) . PHP_EOL;

    echo 'ANNOUNCE -- ' . $torrent->announce() . PHP_EOL;

    echo 'NAME -- ' . $torrent->name() . PHP_EOL;

    echo 'COMMENT -- ' . $torrent->comment() . PHP_EOL;

    echo 'PIECE LENGTH -- ' . $torrent->piece_length() . PHP_EOL;

    echo 'SIZE -- ' . $torrent->size( 2 ) . PHP_EOL;

    echo 'HASH INFO -- ' .  $torrent->hash_info() . PHP_EOL;

    echo 'STATS' . PHP_EOL;

    var_dump( $torrent->scrape() ) . PHP_EOL;

    echo 'CONTENT' . PHP_EOL;

    var_dump( $torrent->content() ) . PHP_EOL;

    echo 'SOURCE -- ' . $torrent;

    # GET MAGNET LINK

    $torrent->magnet(); 
    
    // use $torrent->magnet( false ); to get non html encoded ampersand

    # CREATE TORRENT

    $torrent = new Torrent( array( 'test.mp3', 'test.jpg' ), 'http://torrent.tracker/annonce' );

    $torrent->save( 'test.torrent' ); // save to disk

    # MODIFY TORRENT

    $torrent->announce( 'http://alternate-torrent.tracker/annonce' ); // add a tracker

    $torrent->announce( false ); // reset announce trackers

    $torrent->announce( array( 'http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce' ) ); // set tracker( s ), it also works with a 'one tracker' array...

    $torrent->announce( array( array( 'http://torrent.tracker/annonce', 'http://alternate-torrent.tracker/annonce' ), 'http://another-torrent.tracker/annonce' ) ); // set tiered trackers

    $torrent->comment( 'hello world' );

    $torrent->name( 'test torrent' );

    $torrent->is_private( true );

    $torrent->httpseeds( 'http://file-hosting.domain/path/' ); // BitTornado implementation

    $torrent->url_list( array( 'http://file-hosting.domain/path/','http://another-file-hosting.domain/path/' ) ); // GetRight implementation

    # PRINT ERRORS / SEND

    if ( $errors = $torrent->errors() )
    {
        var_dump( $errors );
    }
    else
    {
        $torrent->send();
    }

?>

Requirements

  • PHP >= 5.2

Contributing

You can help the project by adding features, cleaning the code, adding composer and other.

  1. Fork it
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

php-class-torrent-create-read-write's People

Contributors

aberaud avatar adriengibrat avatar alphaone89 avatar darkalchemy avatar dimak08 avatar drsdavidsoft avatar rudde avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.