Ejemplo n.º 1
0
 public function download($id)
 {
     $config = config('settings');
     $torrent = Torrent::getByStringID($id);
     $dictionary = $torrent->getDictionary();
     $current_user = Auth::user();
     // Get global announce urls
     $announce_url = $config['global_announce_urls'];
     $announce_url_with_passkey = array();
     foreach ($announce_url as $url) {
         $announce_url_with_passkey[] = sprintf("%s?passkey=%s", $url, $current_user->passkeys->passkey);
     }
     Log::info($dictionary);
     // Set them to the dictionary
     $dictionary["value"]["announce"] = array("type" => "string", "value" => $announce_url_with_passkey[0]);
     $encoded = BencodeHelper::bencode($dictionary);
     Log::info($dictionary);
     $temp_file_path = $config['tmp_dir'] . $current_user->passkeys->passkey . "_" . $torrent->hash . ".torrent";
     $user_file_name = $torrent->filename;
     $tmp_file = File::put($temp_file_path, $encoded);
     return Response::download($temp_file_path, $user_file_name, ['content-type' => 'application/x-bittorrent']);
 }