Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method #5

Closed
HDVinnie opened this issue Apr 9, 2017 · 1 comment
Closed

undefined method #5

HDVinnie opened this issue Apr 9, 2017 · 1 comment

Comments

@HDVinnie
Copy link

HDVinnie commented Apr 9, 2017

FatalThrowableError in SecureHeadersMiddleware.php line 26:
Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header()

when I use this function:

    /**
    * 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->getRatio() < config('other.ratio') && config('other.freeleech') == false) {
                return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with(Toastr::warning('Your Ratio Is To Low To Download!!!', 'Error!', ['options']));
            }
        } 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', ['slug' => $torrent->slug, 'id' => $torrent->id])
            ->with(Toastr::warning('Torrent File Not Found! Please Report This Torrent!', 'Error!', ['options']));
        } 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('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', ['passkey' => $user->passkey]);
                // Remove Other announce url
                unset($dict['announce-list']);
            } else {
                return redirect('/login');
            }
        }

        $fileToDownload = Bencode::bencode($dict);
        file_put_contents(getcwd() . '/files/tmp/' . $tmpFileName, $fileToDownload);
        return Response::download(getcwd() . '/files/tmp/' . $tmpFileName);
    }

@bepsvpt
Copy link
Owner

bepsvpt commented Apr 9, 2017

Thanks for reporting the bug, it had been fixed.

@bepsvpt bepsvpt closed this as completed Apr 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants