Issues (435)

app/Http/Controllers/DetailsController.php (5 issues)

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\DnzbFailure;
6
use App\Models\Predb;
7
use App\Models\Release;
8
use App\Models\ReleaseComment;
9
use App\Models\ReleaseFile;
10
use App\Models\ReleaseNfo;
11
use App\Models\ReleaseRegex;
12
use App\Models\Settings;
13
use App\Models\UserDownload;
14
use App\Models\Video;
15
use Blacklight\AniDB;
16
use Blacklight\Books;
17
use Blacklight\Console;
18
use Blacklight\Games;
19
use Blacklight\Movie;
20
use Blacklight\Music;
21
use Blacklight\ReleaseExtra;
22
use Blacklight\Releases;
23
use Blacklight\XXX;
24
use Illuminate\Http\Request;
25
26
class DetailsController extends BasePageController
27
{
28
    public function show(Request $request, string $guid)
29
    {
30
        if ($guid !== null) {
0 ignored issues
show
The condition $guid !== null is always true.
Loading history...
31
            $releases = new Releases;
32
            $re = new ReleaseExtra;
33
            $data = Release::getByGuid($guid);
34
            $releaseRegex = '';
35
            if (! empty($data)) {
36
                $releaseRegex = ReleaseRegex::query()->where('releases_id', '=', $data['id'])->first();
37
            }
38
39
            if (! $data) {
40
                return redirect()->back();
41
            }
42
43
            if ($this->isPostBack($request)) {
44
                ReleaseComment::addComment($data['id'], $data['gid'], $request->input('txtAddComment'), $this->userdata->id, $request->ip());
45
46
                return redirect()->route('details', ['guid' => $guid])->with('success', 'Comment posted successfully!');
47
            }
48
49
            $nfoData = ReleaseNfo::getReleaseNfo($data['id']);
50
            $nfo = $nfoData ? $nfoData->nfo : null;
51
            $reVideo = $re->getVideo($data['id']);
52
            $reAudio = $re->getAudio($data['id']);
53
            $reSubs = $re->getSubs($data['id']);
54
            $comments = ReleaseComment::getComments($data['id']);
55
            $similars = $releases->searchSimilar($data['id'], $data['searchname'], $this->userdata->categoryexclusions);
0 ignored issues
show
The property categoryexclusions does not seem to exist on App\Models\User.
Loading history...
56
            $failed = DnzbFailure::getFailedCount($data['id']);
57
            $downloadedBy = UserDownload::query()->with('user')->where('releases_id', $data['id'])->get(['users_id']);
58
59
            $showInfo = '';
60
            if ($data['videos_id'] > 0) {
61
                $showInfo = Video::getByVideoID($data['videos_id']);
62
            }
63
64
            $mov = '';
65
            if ($data['imdbid'] !== '' && $data['imdbid'] !== 0000000) {
66
                $movie = new Movie(['Settings' => $this->settings]);
0 ignored issues
show
The call to Blacklight\Movie::__construct() has too many arguments starting with array('Settings' => $this->settings). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

66
                $movie = /** @scrutinizer ignore-call */ new Movie(['Settings' => $this->settings]);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
67
                $mov = $movie->getMovieInfo($data['imdbid']);
68
                if (! empty($mov['title'])) {
69
                    $mov['title'] = str_replace(['/', '\\'], '', $mov['title']);
70
                    $mov['actors'] = makeFieldLinks($mov, 'actors', 'movies');
71
                    $mov['genre'] = makeFieldLinks($mov, 'genre', 'movies');
72
                    $mov['director'] = makeFieldLinks($mov, 'director', 'movies');
73
                    if (Settings::settingValue('trailers_display')) {
74
                        $trailer = empty($mov['trailer']) || $mov['trailer'] === '' ? $movie->getTrailer($data['imdbid']) : $mov['trailer'];
75
                        if ($trailer) {
76
                            $mov['trailer'] = sprintf('<iframe width="%d" height="%d" src="%s"></iframe>', Settings::settingValue('trailers_size_x'), Settings::settingValue('trailers_size_y'), $trailer);
0 ignored issues
show
It seems like $trailer can also be of type true; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
                            $mov['trailer'] = sprintf('<iframe width="%d" height="%d" src="%s"></iframe>', Settings::settingValue('trailers_size_x'), Settings::settingValue('trailers_size_y'), /** @scrutinizer ignore-type */ $trailer);
Loading history...
77
                        }
78
                    }
79
                }
80
            }
81
82
            $xxx = '';
83
            if ($data['xxxinfo_id'] !== '' && $data['xxxinfo_id'] !== 0) {
84
                $x = new XXX;
85
                $xxx = $x->getXXXInfo($data['xxxinfo_id']);
86
87
                if (isset($xxx['trailers'])) {
88
                    $xxx['trailers'] = $x->insertSwf($xxx['classused'], $xxx['trailers']);
89
                }
90
91
                if ($xxx && isset($xxx['title'])) {
92
                    $xxx['title'] = str_replace(['/', '\\'], '', $xxx['title']);
93
                    $xxx['actors'] = makeFieldLinks($xxx, 'actors', 'xxx');
94
                    $xxx['genre'] = makeFieldLinks($xxx, 'genre', 'xxx');
95
                    $xxx['director'] = makeFieldLinks($xxx, 'director', 'xxx');
96
                } else {
97
                    $xxx = false;
98
                }
99
            }
100
101
            $game = '';
102
            if ($data['gamesinfo_id'] !== '') {
103
                $game = (new Games)->getGamesInfoById($data['gamesinfo_id']);
104
            }
105
106
            $mus = '';
107
            if ($data['musicinfo_id'] !== '') {
108
                $mus = (new Music)->getMusicInfo($data['musicinfo_id']);
109
            }
110
111
            $book = '';
112
            if ($data['bookinfo_id'] !== '') {
113
                $book = (new Books)->getBookInfo($data['bookinfo_id']);
114
            }
115
116
            $con = '';
117
            if ($data['consoleinfo_id'] !== '') {
118
                $con = (new Console)->getConsoleInfo($data['consoleinfo_id']);
119
            }
120
121
            $AniDBAPIArray = '';
122
            if ($data['anidbid'] > 0) {
123
                $AniDBAPIArray = (new AniDB)->getAnimeInfo($data['anidbid']);
124
            }
125
126
            $pre = Predb::getForRelease($data['predb_id']);
127
128
            $releasefiles = ReleaseFile::getReleaseFiles($data['id']);
129
130
            $this->viewData = array_merge($this->viewData, [
131
                'releasefiles' => $releasefiles,
132
                'release' => $data,
133
                'reVideo' => $reVideo,
134
                'reAudio' => $reAudio,
135
                'reSubs' => $reSubs,
136
                'nfo' => $nfo,
137
                'show' => $showInfo,
138
                'movie' => $mov,
139
                'xxx' => $xxx,
140
                'anidb' => $AniDBAPIArray,
141
                'music' => $mus,
142
                'con' => $con,
143
                'game' => $game,
144
                'book' => $book,
145
                'predb' => $pre,
146
                'comments' => $comments,
147
                'files' => $releasefiles,
148
                'searchname' => getSimilarName($data['searchname']),
149
                'similars' => $similars !== false ? $similars : [],
0 ignored issues
show
The condition $similars !== false is always true.
Loading history...
150
                'privateprofiles' => config('nntmux_settings.private_profiles'),
151
                'failed' => $failed,
152
                'regex' => $releaseRegex,
153
                'downloadedby' => $downloadedBy,
154
                'meta_title' => 'View NZB',
155
                'meta_keywords' => 'view,nzb,description,details',
156
                'meta_description' => 'View NZB for '.$data['searchname'],
157
            ]);
158
159
            return view('details.index', $this->viewData);
160
        }
161
162
        return redirect()->back()->with('error', 'Release not found');
163
    }
164
}
165