<?php /** * Created by PhpStorm. * User: xoo * Date: 26.09.2015 * Time: 22:52 */ include_once '../src/Role.php'; include_once '../src/Torrent.php'; \avs\ROLE::server(); // generate n values const N = 1000; const SIZE = 10; $torrent = Torrent::randomInit(N, SIZE); // save Torrent::put($torrent); $torrent1 = Torrent::get(); var_dump($torrent1);
$movieData = new MovieData($db); $sweTv = new SweTv($db); $subtitles = new Subtitles($db, $user); $torrent = new Torrent($db, $user, $log, $movieData, $sweTv, null, null, $subtitles); $torrent->update((int) $params[1], $postdata); httpResponse(); break; case validateRoute('GET', 'torrents/\\d+/multi'): $torrent = new Torrent($db, $user); $subtitles = new Subtitles($db, $user); $requests = new Requests($db, $user); $movieData = new MovieData($db); $watching = new Watching($db, $user); $sweTv = new SweTv($db); $watchSubtitles = new WatchingSubtitles($db, $user); $myTorrent = $torrent->get($params[1], true); if ($myTorrent["imdbid"] > 0) { $relatedTorrents = $torrent->getRelated($myTorrent["imdbid"], $myTorrent["id"]); $watching = $watching->query($user->getId(), $myTorrent["imdbid"]); $moviedata = $movieData->getData($myTorrent["imdbid"]); } $subtitles = $subtitles->fetch($myTorrent["id"]); if ($myTorrent["reqid"] > 1) { $request = $requests->get($myTorrent["reqid"]); } httpResponse(array("torrent" => $myTorrent, "packContent" => $torrent->getPackFolders($myTorrent["id"]), "movieData" => $moviedata, "relatedTorrents" => $relatedTorrents, "subtitles" => $subtitles, "watching" => is_array($watching) ? $watching[0] : null, "request" => $request, "watchSubtitles" => $watchSubtitles->getByTorrentId($params[1]), "tvChannel" => $sweTv->getChannel($myTorrent["tv_kanalid"]))); break; case validateRoute('GET', 'related-torrents/\\d+'): $torrent = new Torrent($db, $user); $relatedTorrents = $torrent->getRelated((int) $params[1], 0); httpResponse($relatedTorrents);
<?php /** * Created by PhpStorm. * User: xoo * Date: 26.09.2015 * Time: 22:52 */ include_once '../src/Torrent.php'; include_once '../src/Slice.php'; include_once '../src/TorrentIPs.php'; const AMOUNT = 'n'; const DEF = 2; $count = isset($_GET[AMOUNT]) ? $_GET[AMOUNT] : DEF; $torrent = Torrent::get(); // init slice response $sliceResponse = new \avs\SliceResponse(); $sliceResponse->count = $torrent->count; // get slices for ($x = 0; $x < $count; $x++) { $id = rand(0, $torrent->count); $message = $torrent->messages[$id]; $slice = new \avs\Slice(); $slice->id = $id; $slice->message = $message; array_push($sliceResponse->slices, $slice); } // get torrent IPs $foreignIP = \avs\TorrentIPs::foreignIP(); \avs\TorrentIPs::add($foreignIP); $torrentIPs = \avs\TorrentIPs::get();