コード例 #1
1
ファイル: Download.php プロジェクト: krisives/voltage
 public function __construct(Torrent $torrent, $dir)
 {
     parent::__construct();
     $dir = realpath($dir);
     $dir = rtrim($dir, '/');
     if (!is_dir($dir)) {
         throw new Exception("Cannot find download directory '{$dir}'");
     }
     $this->torrent = $torrent;
     $this->dir = $dir;
     $this->myPeerID = sha1(time() . rand(), true);
     $this->pieceCache = new PieceCache($torrent, $dir);
     $this->lastFlush = time();
     $this->peers = array();
     $this->streams = array();
     $this->streamLookup = array();
     $this->trackers = array();
     $this->udp = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if (empty($this->udp)) {
         throw new Exception("Cannot create UDP socket");
     }
     foreach ($torrent->getTrackers() as $url) {
         $this->addTracker($url);
     }
 }
コード例 #2
0
ファイル: check.php プロジェクト: NetOverflow/ruTorrent
 public static function run_ex($hash, $fname)
 {
     $torrent = new Torrent($fname);
     if (!$torrent->errors()) {
         foreach (self::$TRACKERS as $key => $value) {
             if (strpos($torrent->comment(), $key) !== FALSE) {
                 return call_user_func($value, $torrent->comment(), $hash, $torrent);
             }
         }
     }
     return self::STE_NOT_NEED;
 }
コード例 #3
0
ファイル: PieceCache.php プロジェクト: krisives/voltage
 public function __construct(Torrent $torrent, $dir)
 {
     $this->torrent = $torrent;
     $this->dir = $dir;
     $this->pieceSize = $torrent->getPieceSize();
     $this->pieceCount = $torrent->getPieceCount();
     $this->maxPieces = self::calculateMaxPieces($this->pieceSize);
     $this->openFiles = array();
     $this->pieces = array();
     $this->dirty = array();
     $this->pieceSequences = array_fill(0, $this->pieceCount, 0);
 }
コード例 #4
0
 private function getFileInformation($hash)
 {
     $shrinkWrap = $this->shrinkWrapper;
     $results = $shrinkWrap->query("SELECT SQL_NO_CACHE * FROM  `file_info` WHERE  `torrent_hash` = '{$hash}'");
     if (empty($results)) {
         $torrentFile = "C:/xampp/htdocs/apps/strike/torrents/api/download/" . $hash . ".torrent";
         $torrentTitle = $value["torrent_title"];
         if (!file_exists($torrentFile)) {
             $remoteTorrent = "http://torcache.net/torrent/{$hash}.torrent";
             $file_headers = @get_headers($file);
             if ($file_headers[0] == 'HTTP/1.1 404 Not Found') {
                 $exists = false;
             } else {
                 $this->downloadFile($remoteTorrent, "C:/xampp/htdocs/apps/strike/torrents/api/download/" . $hash . ".torrent");
             }
         }
         $torrent = new Torrent($torrentFile);
         $file_names = array_keys($torrent->content());
         $file_lengths = array_values($torrent->content());
         $fileNameRecord = "";
         $fileLengthRecord = "";
         foreach ($file_names as &$value) {
             $fileNameRecord .= strlen($fileNameRecord) == 0 ? trim($value) : ", " . trim($value);
         }
         foreach ($file_lengths as &$value) {
             $fileLengthRecord .= strlen($fileLengthRecord) == 0 ? trim($value) : ", " . trim($value);
         }
         if (strpos($fileNameRecord, 'xampp') !== false) {
             $fileNameRecord = "Error";
         }
         $lengthArray = json_decode('[' . $fileLengthRecord . ']', true);
         $nameArray = explode(',', $fileNameRecord);
         $fileData = array(file_names => $nameArray, file_lengths => $lengthArray);
         $fileNameRecord = $this->shrinkWrapper->escape($fileNameRecord);
         $fileLengthRecord = $this->shrinkWrapper->escape($fileLengthRecord);
         $insertFileNames = $shrinkWrap->query("REPLACE into file_info (torrent_hash, file_names, file_sizes) values(\"{$hash}\", \"{$fileNameRecord}\", \"{$fileLengthRecord}\")");
         return $fileData;
     } else {
         $fileLengthRecord = $results[0]["file_sizes"];
         $fileNameRecord = $results[0]["file_names"];
         if (strpos($fileNameRecord, 'xampp') !== false) {
             $fileNameRecord = "Error";
         }
         $lengthArray = json_decode('[' . $fileLengthRecord . ']', true);
         $nameArray = explode(',', $fileNameRecord);
         $fileData = array(file_names => $nameArray, file_lengths => $lengthArray);
         return $fileData;
     }
 }
コード例 #5
0
ファイル: edit_torrent.php プロジェクト: skygunner/PT-PORTER
function checktorrent($filename)
{
    $torrent = new Torrent($filename);
    echo 'check torrent: ' . $filename . "\n";
    $file_media = $torrent->file_media();
    $count = count($file_media);
    for ($i = 0; $i + 0 < $count + 0; $i++) {
        if ($file_media[$i] + 0 < 0) {
            echo $file_media[$i] . "\n";
            $file_media[$i] = 0;
        }
    }
    $torrent->file_media($file_media);
    $torrent->save($filename);
    echo 'check torrent: ' . $filename . " over \n";
}
コード例 #6
0
ファイル: UserController.php プロジェクト: ne0lite/Tracker
 public function user($id)
 {
     if (Auth::check()) {
         $torrents = Torrent::where('uploader_id', '=', $id)->orderBy('created_at', 'desc');
         return View::make('user', array('torrents' => $torrents->get()));
     }
     return Redirect::to('/login');
 }
コード例 #7
0
 /** @function TorrentGen() Inserts the new torrent or updates if it already exists.
  * @return $Torrent returns the torrent.
  */
 private function TorrentGen()
 {
     $Torrent = current($this->getClass('TorrentManager')->find(array('hash' => bin2hex($_REQUEST['info_hash']))));
     if (!$Torrent || !$Torrent->isValid()) {
         $Torrent = new Torrent(array('hash' => bin2hex($_REQUEST['info_hash'])));
     } else {
         $Torrent->set('hash', bin2hex($_REQUEST['info_hash']));
     }
     $Torrent->save();
     return $Torrent;
 }
コード例 #8
0
 public static function getSource($hash)
 {
     $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_session"), new rXMLRPCCommand("d.get_tied_to_file", $hash)));
     if ($req->run() && !$req->fault) {
         $fname = $req->val[0] . $hash . ".torrent";
         if (empty($req->val[0]) || !is_readable($fname)) {
             if (strlen($req->val[1]) && is_readable($req->val[1])) {
                 $fname = $req->val[1];
             } else {
                 $fname = null;
             }
         }
         if ($fname) {
             $torrent = new Torrent($fname);
             if (!$torrent->errors()) {
                 return $torrent;
             }
         }
     }
     return false;
 }
コード例 #9
0
ファイル: add-torrents.php プロジェクト: nylen/rtgui
function process_torrent_data($content, $filename, $create_file = true)
{
    global $tmp_add_dir;
    set_error_handler('handleError');
    try {
        $torrent = new Torrent($content);
        if ($error = $torrent->error()) {
            return array('error' => 'Error parsing .torrent file: ' . $error);
        }
        $hash = $torrent->hash_info();
        $filename = "{$tmp_add_dir}/{$filename}";
        if ($create_file) {
            $filename = get_filename_no_clobber($filename);
            file_put_contents($filename, $content);
        }
    } catch (Exception $e) {
        restore_error_handler();
        return array('error' => $e->getMessage());
    }
    restore_error_handler();
    return save_add_data($hash, array('name' => $torrent->name(), 'files' => $torrent->content(), 'filename' => str_replace("{$tmp_add_dir}/", '', $filename)));
}
コード例 #10
0
ファイル: HomeController.php プロジェクト: raphaeljorge/tor
 /**
  * Search for torrents
  *
  * @access public
  * @return View page.torrents
  *
  */
 public function search()
 {
     // Only post request is accepted
     if (Request::isMethod('post')) {
         // Search terms
         $search = Input::get('search');
         // Fetch torrents that correspond the request
         $torrents = Torrent::where('name', 'LIKE', '%' . $search . '%')->paginate(20);
         return View::make('home.search', array('torrents' => $torrents));
     } else {
         // No post method
         return Redirect::to('/');
     }
 }
コード例 #11
0
 /**
  * Ajoute un commentaire sur un torrent
  * 
  * @param $slug Slug du torrent
  * @param $id Id tu torrent
  */
 public function torrent($slug, $id)
 {
     $torrent = Torrent::find($id);
     $user = Auth::user();
     $comment = new Comment();
     $comment->content = Input::get('content');
     $comment->user_id = $user->id;
     $comment->torrent_id = $torrent->id;
     $v = Validator::make($comment->toArray(), array('content' => 'required', 'user_id' => 'required', 'torrent_id' => 'required'));
     if ($v->passes()) {
         $comment->save();
         Session::put('message', 'Your comment has been added');
     } else {
         Session::put('message', 'An error has occurred');
     }
     return Redirect::route('torrent', array('slug' => $torrent->slug, 'id' => $torrent->id));
 }
コード例 #12
0
ファイル: stats.model.php プロジェクト: Jatax/TKS
 /**
  * Retourne les statistiques globales
  * @return array
  */
 public static function getGlobalStats()
 {
     $oMysqli = Database::getInstance();
     $aStats = array();
     // Récupération du nombre de releases
     $iNbReleases = Release::getCount();
     $aStats[] = array("text" => $iNbReleases, "icon" => "fa-film", "subtext" => "releases", "color" => "green");
     // Récupération du nombre de torrents
     $iNbTorrents = Torrent::getCount();
     $aStats[] = array("text" => $iNbTorrents, "icon" => "fa-magnet", "subtext" => "torrents", "color" => "blue");
     // Récupération du nombre d'utilisateur
     $oResult = $oMysqli->query("SELECT COUNT(*) AS nbusers FROM tks_users");
     $iNbUsers = $oResult->fetch_assoc()['nbusers'];
     $aStats[] = array("text" => $iNbUsers, "icon" => "fa-users", "subtext" => "utilisateurs", "color" => "brown");
     // Récupération du nombre de trackers
     $oResult = $oMysqli->query("SELECT COUNT(*) AS nbtrackers FROM tks_trackers");
     $iNbTrackers = $oResult->fetch_assoc()['nbtrackers'];
     $aStats[] = array("text" => $iNbTrackers, "icon" => "fa-link", "subtext" => "trackers", "color" => "red");
     return $aStats;
 }
コード例 #13
0
ファイル: page.php プロジェクト: bencochran/yeti
 public function actionView($pageName = 'home')
 {
     $active_user = User::require_active_user();
     $this->setLayoutVar('active_user', $active_user);
     $this->setVar('active_user', $active_user);
     if (strpos($pageName, '../') !== false) {
         throw new Lvc_Exception('File Not Found: ' . $sourceFile);
     }
     switch ($pageName) {
         case 'home':
             $torrents = Torrent::browse(array('category_cid' => -1, 'window' => 5, 'page' => 1));
             $news = $this->requestAction('newest', array(), 'news');
             //$currently_seeding = User::currently_seeding($active_user);
             $this->setVar('torrents', $torrents['torrents']);
             $this->setVar('latest_news', $news);
             $this->setVar('total_torrents', $torrents['count']);
             $this->setVar('currently_seeding', $currently_seeding['users']);
             $this->setVar('currently_seeding_count', $currently_seeding['count']);
             break;
         case 'help':
             $this->setLayoutVar('pageTitle', 'Help');
             $this->setLayoutVar('pageHead', 'Help');
             break;
         case 'help/transmission':
             $this->setLayoutVar('pageTitle', 'Transmission Upload Guide');
             $this->setLayoutVar('pageHead', 'Transmission Upload Guide');
             break;
         case 'help/utorrent':
             $this->setLayoutVar('pageTitle', 'uTorrent Upload Guide');
             $this->setLayoutVar('pageHead', 'uTorrent Upload Guide');
             break;
         case 'faq':
             $this->setLayoutVar('pageTitle', 'FAQ');
             $this->setLayoutVar('pageHead', 'Frequently Asked Questions');
             break;
     }
     $this->loadView('page/' . rtrim($pageName, '/'));
 }
コード例 #14
0
 public function announce($tid, $uid)
 {
     // torrent klients (utorrent) atver šādu adresi
     // http://xxx/announce/2/2?info_hash=xxxx&peer_id=xxxx&numwant=50&event=started&port=123&left=0
     // parametru skaidrojums
     // https://wiki.theory.org/BitTorrentSpecification (Tracker Request Parameters)
     $torrent = Torrent::findOrFail($tid);
     $user = User::findOrFail($uid);
     Eloquent::unguard();
     // atlasa ierakstu vai izveido jaunu
     $data = TorrentUser::firstOrCreate(array('torrent_id' => $torrent->id, 'user_id' => $user->id, 'peer_id' => @$_GET['peer_id']));
     $data->ip = $_SERVER['REMOTE_ADDR'];
     // utorrent ip adrese
     $data->port = (int) @$_GET['port'];
     // utorrent ports
     $data->peer_id = @$_GET['peer_id'];
     // utorrent kaut kāds id
     $data->seeding = @$_GET['left'] == 0;
     // cik baiti atlikuši lejuplādēt (0 = pabeigts)
     if (@$_GET['event'] == 'stopped') {
         $data->delete();
         // nospieda stop pogu, dzēšam
     } else {
         $data->save();
     }
     $numwant = isset($_GET['numwant']) ? (int) $_GET['numwant'] : 50;
     // cik datus par citiem lietotājiem grib
     $complete = TorrentUser::where('torrent_id', $torrent->id)->where('seeding', true)->count();
     // saskaita šim torrentam seederus
     $incomplete = TorrentUser::where('torrent_id', $torrent->id)->where('seeding', false)->count();
     // saskaita šim torrentam leecherus
     $peers = TorrentUser::where('torrent_id', $torrent->id)->select('peer_id', 'ip', 'port')->take($numwant)->get()->toArray();
     // https://wiki.theory.org/BitTorrentSpecification (Tracker Response)
     $response = array('interval' => 60, 'tracker id' => 'tracker', 'complete' => $complete, 'incomplete' => $incomplete, 'peers' => $peers);
     $response = Response::make(Bencode::encode($response), 200);
     $response->header('Content-Type', 'text/plain');
     return $response;
 }
コード例 #15
0
ファイル: action.php プロジェクト: NetOverflow/ruTorrent
 $throttle = null;
 if (rTorrentSettings::get()->isPluginRegistered("throttle")) {
     $req->addCommand(new rXMLRPCCommand("d.get_throttle_name", $hash));
 }
 if ($req->run() && !$req->fault) {
     $isStart = $req->val[1] != 0 && $req->val[2] != 0 && $req->val[3] != 0;
     $fname = $req->val[0] . $hash . ".torrent";
     if (empty($req->val[0]) || !is_readable($fname)) {
         if (strlen($req->val[4]) && is_readable($req->val[4])) {
             $fname = $req->val[4];
         } else {
             $fname = null;
         }
     }
     if ($fname) {
         $torrent = new Torrent($fname);
         if (!$torrent->errors()) {
             if ($setPrivate) {
                 $torrent->is_private($private);
             }
             if ($setTrackers) {
                 $torrent->clear_announce();
                 $torrent->clear_announce_list();
                 if (count($announce_list) > 0) {
                     $torrent->announce($announce_list[0][0]);
                     if ($trackersCount > 1) {
                         $torrent->announce_list($announce_list);
                     }
                 }
             }
             if ($setComment) {
コード例 #16
0
 /**
  * Test create torrent
  *
  * @return string
  */
 protected function createTorrent()
 {
     $core = new Core($this->persistence);
     $core->setIp('127.0.0.1')->setInterval(60);
     $file = new File\File(dirname(__FILE__) . '/../Fixtures/' . self::FILE_TO_DOWNLOAD);
     $torrent = new Torrent($file, self::PIECE_LENGTH);
     $torrent->setAnnounceList(array(self::ANNOUNCE_URL));
     return $core->addTorrent($torrent);
 }
コード例 #17
0
 /**
  * Create torrent file
  *
  * @return string
  */
 protected function createTorrentFile()
 {
     $persistence = new Persistence\Pdo('sqlite:' . $this->db_path);
     $core = new Core($persistence);
     $file = new File\File(dirname(__FILE__) . '/../Fixtures/' . self::FILE_TO_DOWNLOAD);
     $torrent = new Torrent($file, self::PIECE_LENGTH);
     $torrent->setAnnounceList(array('http://' . self::ANNOUNCE_SERVER_IP . ':' . self::ANNOUNCE_SERVER_PORT . '/announce.php'));
     $contents = $core->addTorrent($torrent);
     $file_name = sys_get_temp_dir() . "/phptracker_torrent" . uniqid() . '.torrent';
     file_put_contents($file_name, $contents);
     return $file_name;
 }
コード例 #18
0
ファイル: correct.php プロジェクト: NetOverflow/ruTorrent
         $value = trim($value);
         if (strlen($value)) {
             $trackers[] = $value;
             $trackersCount = $trackersCount + 1;
         } else {
             if (count($trackers) > 0) {
                 $announce_list[] = $trackers;
                 $trackers = array();
             }
         }
     }
 }
 if (count($trackers) > 0) {
     $announce_list[] = $trackers;
 }
 $torrent = new Torrent($tname);
 $torrent->clear_announce();
 if (count($announce_list) > 0) {
     $torrent->announce($announce_list[0][0]);
     if ($trackersCount > 1) {
         $torrent->announce_list($announce_list);
     }
 }
 if (isset($request['comment'])) {
     $comment = trim($request['comment']);
     if (strlen($comment)) {
         $torrent->comment($comment);
     }
 }
 if ($request['private']) {
     $torrent->is_private(true);
コード例 #19
0
ファイル: torrent.class.php プロジェクト: OwlManAtt/itorrent
 /**
  * Find a torrent by its hash. 
  * 
  * @param mixed $rpc_url 
  * @param mixed $hash 
  * @return Torrent|null
  * @todo Inefficient. Re-implement to not suck.
  **/
 public static function findOneByHash($rpc_url, $hash)
 {
     $torrents = Torrent::findByStatus($rpc_url, 'all');
     foreach ($torrents as $torrent) {
         if ($torrent->getHash() == $hash) {
             return $torrent;
         }
     }
     // end loop
     return null;
 }
コード例 #20
0
ファイル: TorrentController.php プロジェクト: boozaa/swatt
 /**
  * Telecharge le torrent
  *
  * @access public
  * @param string $slug Slug du torrent
  * @param int $id Id du torrent 
  * @return file
  */
 public function download($slug, $id)
 {
     // Find the torrent in the database
     $torrent = Torrent::find($id);
     if (Auth::check()) {
         // Current user is the logged in user
         $user = Auth::user();
         // User's ratio is too low
         if ($user->getDownloaded() / $user->getUploaded() < Config::get('other.ratio') && Config::get('other.freeleech') == false) {
             return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', 'You can\'t download torrents anymore your ratio is too low');
         }
     } else {
         $user = null;
     }
     // Define the filename for the download
     $tmpFileName = $torrent->slug . '.torrent';
     // The torrent file exist ?
     if (!file_exists(getcwd() . '/files/torrents/' . $torrent->file_name)) {
         return Redirect::route('torrent', array('slug' => $torrent->slug, 'id' => $torrent->id))->with('message', 'The torrent file is currently unavailable');
     } else {
         // Delete the last torrent tmp file
         if (file_exists(getcwd() . '/files/tmp/' . $tmpFileName)) {
             unlink(getcwd() . '/files/tmp/' . $tmpFileName);
         }
     }
     // Get the content of the torrent
     $dict = Bencode::bdecode(file_get_contents(getcwd() . '/files/torrents/' . $torrent->file_name));
     // Freeleech ?
     if (Config::get('other.freeleech') == true) {
         // Set the announce key only
         $dict['announce'] = route('announce');
     } else {
         if (Auth::check()) {
             // Set the announce key and add the user passkey
             $dict['announce'] = route('announce', array('passkey' => $user->passkey));
             // Remove Other announce url
             unset($dict['announce-list']);
         } else {
             return Redirect::to('/login');
         }
     }
     $fileToDownload = Bencode::bencode($dict);
     file_put_contents(getcwd() . '/files/tmp/' . $tmpFileName, $fileToDownload);
     return Response::download(getcwd() . '/files/tmp/' . $tmpFileName);
 }
コード例 #21
0
ファイル: update.php プロジェクト: NetOverflow/ruTorrent
if (count($argv) > 1) {
    $hash = $argv[1];
    $req = new rXMLRPCRequest(array(new rXMLRPCCommand("get_session"), new rXMLRPCCommand("d.get_custom4", $hash), new rXMLRPCCommand("d.get_tied_to_file", $hash), new rXMLRPCCommand("d.get_custom1", $hash), new rXMLRPCCommand("d.get_directory_base", $hash), new rXMLRPCCommand("d.is_private", $hash), new rXMLRPCCommand("d.get_name", $hash)));
    if ($req->success()) {
        $isStart = $req->val[1] != 0;
        if ((count($trks->list) || count($trks->todelete)) && !($req->val[5] && $trks->dontAddPrivate) && $req->val[6] != $hash . ".meta") {
            $fname = $req->val[0] . $hash . ".torrent";
            if (empty($req->val[0]) || !is_readable($fname)) {
                if (strlen($req->val[2]) && is_readable($req->val[2])) {
                    $fname = $req->val[2];
                } else {
                    $fname = null;
                }
            }
            if ($fname) {
                $torrent = new Torrent($fname);
                if (!$torrent->errors()) {
                    $needToProcessed = true;
                    $lst = $torrent->announce_list();
                    if (!$lst) {
                        if (count($trks->list)) {
                            if ($torrent->announce()) {
                                $torrent->announce_list($trks->addToBegin ? array_merge($trks->list, array(array($torrent->announce()))) : array_merge(array(array($torrent->announce())), $trks->list));
                            } else {
                                $torrent->announce($trks->list[0][0]);
                                $torrent->announce_list($trks->list);
                            }
                        } else {
                            $needToProcessed = false;
                        }
                    } else {
コード例 #22
0
ファイル: rss.model.php プロジェクト: Jatax/TKS
 /**
  * Parse le flux RSS pour trouver les Torrents
  * @param Passkey $p_oPasskey
  * @return array
  */
 public function parse($p_oPasskey)
 {
     $aTorrents = array();
     //Ouverture du flux RSS
     libxml_use_internal_errors(true);
     if ($this->isPasskey()) {
         $sUrlWithPasskey = $p_oPasskey->getLinkWithPasskey($this->sUrl);
     } else {
         $sUrlWithPasskey = $this->sUrl;
     }
     $oRssDoc = simpleXML_load_file($sUrlWithPasskey);
     if (!$oRssDoc) {
         return array('error' => "Impossible d'ouvrir le flux : " . $this->sUrl);
     }
     //Traitement des items
     foreach ($oRssDoc->channel->item as $oRssItem) {
         //Traitement des jeux de caractères
         if ($this->sEncoding === "UTF-8") {
             $sPubDate = $oRssItem->pubDate;
             $sTitle = $oRssItem->title;
             $sLink = $oRssItem->link;
         } else {
             $sPubDate = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->pubDate);
             $sTitle = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->title);
             $sLink = iconv($this->sEncoding, "UTF-8//TRANSLIT", $oRssItem->link);
         }
         //On regarde si on a une date de publication :
         if (empty($sPubDate) || $this->bForcedate) {
             $sPubDate = date("Y-m-j G:i:s");
         }
         if (strtotime($sPubDate) > strtotime($this->sLastCheck)) {
             $oTorrent = new Torrent($sTitle);
             $oTorrent->setDate(date("Y-m-j G:i:s", strtotime($sPubDate)));
             $oTorrent->setIdLink($this->getIdLink($sLink, $p_oPasskey));
             $oTorrent->setTracker($this->iTracker);
             $aTorrents[] = $oTorrent;
         }
     }
     return $aTorrents;
 }
コード例 #23
0
ファイル: remove.php プロジェクト: OwlManAtt/itorrent
 * be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE.  See the GNU General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU General
 * Public License along with 'iTorrent'; if not,
 * write to the Free Software Foundation, Inc., 51
 * Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @author Nicholas 'Owl' Evans <*****@*****.**>
 * @copyright Nicolas Evans, 2007
 * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
 * @package iTorrent
 * @version 1.0.0
 **/
$hash_id = stripinput($_POST['hash_id']);
$torrent = Torrent::findOneByHash($APP_CONFIG['rpc_uri'], $hash_id);
if ($torrent == null) {
    draw_errors('Invalid torrent hash specified.');
} else {
    $name = $torrent->getTitle();
    $torrent->remove($APP_CONFIG['rpc_uri']);
    $_SESSION['torrents_alert'] = "{$name} was removed.";
    if ($UI_TYPE == 'iphone') {
        redirect(null, null, "torrents/#torrent_{$torrent->getHash()}");
    } else {
        redirect('torrents');
    }
}
// end change status
コード例 #24
0
     }
 }
 if (count($trackers) > 0) {
     $announce_list[] = $trackers;
 }
 $path_edit = trim($request['path_edit']);
 $piece_size = $request['piece_size'];
 $callback_log = create_function('$msg', '$fp=fopen("php://stdout","w"); fputs($fp, $msg."\\n"); fclose($fp);');
 $callback_err = create_function('$msg', '$fp=fopen("php://stderr","w"); fputs($fp, $msg."\\n"); fclose($fp);');
 if (count($announce_list) > 0) {
     $torrent = new Torrent($path_edit, $announce_list[0][0], $piece_size, $callback_log, $callback_err);
     if ($trackersCount > 1) {
         $torrent->announce_list($announce_list);
     }
 } else {
     $torrent = new Torrent($path_edit, array(), $piece_size, $callback_log, $callback_err);
 }
 if (isset($request['comment'])) {
     $comment = trim($request['comment']);
     if (strlen($comment)) {
         $torrent->comment($comment);
     }
 }
 if ($request['private']) {
     $torrent->is_private(true);
 }
 $fname = rTask::formatPath($taskNo) . '/result.torrent';
 $torrent->save($fname);
 if ($request['start_seeding']) {
     $fname = getUniqueUploadedFilename($torrent->info['name'] . '.torrent');
     $path_edit = trim($request['path_edit']);
コード例 #25
0
ファイル: metalink.php プロジェクト: j883376/metalink-library
 function create_torrent($torrent_trackers, $torrent)
 {
     $t = new Torrent($torrent);
     $data = array('comment' => $this->description, 'files' => array(array($this->file->filename, (int) $this->file->size)), 'piece length' => (int) $this->file->hashes->piecelength, 'pieces' => $this->file->hashes->pieces, 'trackers' => $torrent_trackers, 'created by' => $GLOBALS['generator'], 'encoding' => 'UTF-8');
     return $t->create($data);
 }
コード例 #26
0
ファイル: TorrentController.php プロジェクト: ne0lite/Tracker
 public function deleteTorrent($id)
 {
     TorrentFile::where('torrent_id', '=', $id)->delete();
     Torrent::where('id', '=', $id)->delete();
     return Redirect::to('/')->with('success', 'Torrent deleted.');
 }
コード例 #27
0
ファイル: api-v1.php プロジェクト: lordgabber/rartracker
     httpResponse($suggestions->create($postdata));
     break;
 case validateRoute('PATCH', 'suggestions/\\d+'):
     $suggestions = new Suggestions($db, $user);
     httpResponse($suggestions->update($params[1], $postdata));
     break;
 case validateRoute('GET', 'sweTvGuide'):
     $week = (int) $_GET["week"];
     $cacheId = 'swetvguide-' . $week;
     if ($memcache && ($cached = $memcache->get($cacheId))) {
         if ($week == 0) {
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($cached);
     } else {
         $torrent = new Torrent($db, $user);
         if ($week > 3) {
             $week = 4;
         }
         $array = array();
         for ($i = 0; $i < 8; ++$i) {
             $d = time() - 86400 * $i - $week * 604800;
             $startDate = strtotime(date("Y-m-d", $d) . ' 00:00');
             $endDate = strtotime(date("Y-m-d", $d) . ' 23:59');
             $array[] = $torrents = $torrent->getSweTvGuideTorrents($startDate, $endDate);
         }
         $memcache && $memcache->set($cacheId, $array, MEMCACHE_COMPRESSED, 60 * 15);
         if ($week == 0) {
             $user->updateLastTorrentViewAccess('last_tvbrowse');
         }
         httpResponse($array);
コード例 #28
0
ファイル: list.php プロジェクト: OwlManAtt/itorrent
$feed_id = stripinput($_REQUEST['feed_id']);
$feed = new RSSFeed($db);
if ($feed_id == null) {
    $feed = $feed->findOneByDefault('Y');
} else {
    $feed = $feed->findOneByRssFeedId($feed_id);
}
if ($feed == null) {
    $ERRORS[] = 'RSS feed not found.';
}
if (sizeof($ERRORS) > 0) {
    draw_errors($ERRORS);
} else {
    // Build a hash of torrents being downloaded. The RSS feed's items will
    // be compared against this hash, and any matching item are surpressed.
    $torrents = Torrent::findByStatus($APP_CONFIG['rpc_uri'], 'all');
    $TORRENTING = array();
    foreach ($torrents as $torrent) {
        $TORRENTING[] = $torrent->getTitle();
        /*
        print "<pre>\n";
            var_dump($torrent->getTitle());
            print ' - ';
            print mb_detect_encoding($torrent->getTitle());
        print "</pre>\n";
        */
    }
    // end array
    // Get the list of feeds for the dropdown menu.
    $feed_list = new RSSFeed($db);
    $feed_list = $feed_list->findBy(array());
コード例 #29
0
ファイル: ingest.controller.php プロジェクト: Jatax/TKS
 public function procede()
 {
     if (!$this->oRequest->existParam('key')) {
         throw new Error('Vous devez renseigner la clé.', 3003);
     }
     if ($this->oRequest->getParam('key', 'string') != Config::get('ingestkey')) {
         throw new Error('La clé est invalide.', 3003);
     }
     //Ajoute du titre
     $this->oView->addData('titre', 'Analyse des flux RSS');
     //On récupère les éléments pour les statistiques
     $iNbReleases = Release::getCount();
     $iNbTorrents = Torrent::getCount();
     $iStartTime = time();
     //Traitement des Trackers
     $aTrackers = Tracker::getTrackers();
     //Ajout des flux
     $aRssList = Rss::getFlux();
     foreach ($aRssList as $oRss) {
         $aTrackers[$oRss->getTrackerId()]->addFlux($oRss);
     }
     //Parsage des flux
     $aResults = array();
     foreach ($aTrackers as $oTracker) {
         $aResults = array_merge($aResults, $oTracker->parseRss());
     }
     //Traitement des résultats
     $oTable = new TableGenerator();
     $oTable->setId(md5('Ingest'));
     $oTable->addColumn('Tags');
     $oTable->addColumn('Tracker');
     $oTable->addColumn('Release');
     foreach ($aResults as $oResult) {
         if (is_string($oResult)) {
             Logger::log('ingest', $oResult);
             $this->oView->addAlert($oResult, 'danger');
         } else {
             $oResult->store();
             $sTags = '';
             foreach ($oResult->getTags() as $oTag) {
                 $oTagView = new View('label');
                 $oTagView->addData('type', 'info');
                 $oTagView->addData('text', $oTag->getName());
                 $oTagView->create();
                 $sTags .= $oTagView->getCode() . '&nbsp;';
             }
             $oTable->addLine(array($sTags, $aTrackers[$oResult->getTracker()]->getName(), $oResult->getReleaseName()));
         }
     }
     //Statistiques
     $iNewReleases = Release::getCount() - $iNbReleases;
     $iNewTorrents = Torrent::getCount() - $iNbTorrents;
     Stats::storeIngestStats($iNewReleases, $iNewTorrents, date("Y-m-j G:i:s", $iStartTime));
     //Enregistrement de la dernière date de vérification
     Rss::updateLastCheck(date("Y-m-j G:i:s", $iStartTime));
     Logger::log('ingest', $iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->setBottom($iNewReleases . ' nouvelles releases et ' . $iNewTorrents . ' nouveaux torrents.');
     $oTable->create();
     $this->oView->addData('content', $oTable->getCode());
     $this->oView->Create();
 }
コード例 #30
0
ファイル: action.php プロジェクト: Rapiddot/ruTorrent
                    } else {
                        if ($useExternal === false) {
                            $useExternal = "inner";
                        }
                    }
                    $task = new rTask(array('arg' => call_user_func('getFileName', $path_edit), 'requester' => 'create', 'name' => 'create', 'path_edit' => $_REQUEST['path_edit'], 'trackers' => $_REQUEST['trackers'], 'comment' => $_REQUEST['comment'], 'start_seeding' => $_REQUEST['start_seeding'], 'piece_size' => $_REQUEST['piece_size'], 'private' => $_REQUEST['private']));
                    $commands = array();
                    $commands[] = escapeshellarg($rootPath . '/plugins/create/' . $useExternal . '.sh') . " " . $task->id . " " . escapeshellarg(getPHP()) . " " . escapeshellarg($pathToCreatetorrent) . " " . escapeshellarg($path_edit) . " " . $piece_size . " " . escapeshellarg(getUser()) . " " . escapeshellarg(rTask::formatPath($task->id));
                    $commands[] = '{';
                    $commands[] = 'chmod a+r "${dir}"/result.torrent';
                    $commands[] = '}';
                    $ret = $task->start($commands, 0);
                    break;
                } else {
                    $error = 'Incorrect directory (' . mb_substr($path_edit, mb_strlen($topDirectory) - 1) . ')';
                }
            }
            $ret = array("no" => -1, "pid" => 0, "status" => 255, "log" => array(), "errors" => array($error));
            break;
        case "getfile":
            $dir = rTask::formatPath($_REQUEST['no']);
            $torrent = new Torrent($dir . "/result.torrent");
            if (!$torrent->errors()) {
                $torrent->send();
            } else {
                header('HTTP/1.0 404 Not Found');
            }
            exit;
    }
}
cachedEcho(safe_json_encode($ret), "application/json");