Issues (1925)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Http/Controllers/GameController.php (32 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * rmarchiv.tk
5
 * (c) 2016-2017 by Marcel 'ryg' Hering
6
 */
7
8
namespace App\Http\Controllers;
9
10
use Carbon\Carbon;
11
use App\Events\Obyx;
12
use App\Models\Game;
13
use App\Models\Comment;
14
use App\Models\License;
15
use App\Events\GameView;
16
use App\Models\Language;
17
use App\Models\GamesFile;
18
use App\Models\Screenshot;
19
use App\Models\TagRelation;
20
use Illuminate\Http\Request;
21
use App\Models\GamesDeveloper;
22
use App\Helpers\DatabaseHelper;
23
use Illuminate\Support\Facades\Input;
24
25
class GameController extends Controller
26
{
27
    /**
28
     * Display a listing of the resource.
29
     *
30
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
31
     */
32
    public function index($orderby = 'title', $direction = 'asc')
33
    {
34
        $rows = (\Auth::check()) ? \Auth::user()->settings->rows_per_page_games : config('app.rows_per_page_games');
35
36
        if ($orderby == 'developer.name') {
37
            $games = Game::Join('games_developer', 'games.id', '=', 'games_developer.game_id')
38
                ->Join('developer', 'games_developer.developer_id', '=', 'developer.id')
39
                ->orderBy($orderby, $direction)->select('games.*')->paginate($rows);
40
        } else {
41
            $games = Game::orderBy($orderby, $direction)->orderBy('title')->orderBy('subtitle')->paginate($rows);
42
        }
43
44
        return view('games.index', [
45
            'games'     => $games,
46
            'maxviews'  => DatabaseHelper::getGameViewsMax(),
47
            'orderby'   => $orderby,
48
            'direction' => $direction,
49
        ]);
50
    }
51
52
    /**
53
     * Show the form for creating a new resource.
54
     *
55
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
56
     */
57
    public function create()
58
    {
59
        $maker = \DB::table('makers')
60
            ->orderBy('makers.title')
61
            ->get();
62
63
        $langs = \DB::table('languages')
64
            ->orderBy('id')
65
            ->get();
66
67
        $licenses = License::all();
68
69
        return view('games.create', ['makers' => $maker, 'langs' => $langs, 'licenses' => $licenses]);
70
    }
71
72
    /**
73
     * Store a newly created resource in storage.
74
     *
75
     * @param \Illuminate\Http\Request $request
76
     *
77
     * @return \Illuminate\Http\RedirectResponse
78
     */
79
    public function store(Request $request)
80
    {
81
        $this->validate($request, [
82
            'title'     => 'required',
83
            'maker'     => 'required|not_in:0',
84
            'language'  => 'required|not_in:0',
85
            'developer' => 'required',
86
        ]);
87
88
        $devid = DatabaseHelper::developerId_from_developerName($request->get('developer'));
89
        if ($devid == 0) {
90
            $devid = DatabaseHelper::developer_add_and_get_developerId($request->get('developer'));
91
            event(new Obyx('dev-add', \Auth::id()));
92
        }
93
94
        $langid = DatabaseHelper::langId_from_short($request->get('language'));
95
96
        $g = new Game();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
97
        $g->title = $request->get('title');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
98
        $g->subtitle = $request->get('subtitle', '');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
99
        $g->desc_md = $request->get('msg');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
100
        $g->desc_html = \Markdown::convertToHtml($request->get('msg'));
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
101
        $g->website_url = $request->get('websiteurl', '');
102
        $g->maker_id = $request->get('maker');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
103
        $g->lang_id = $langid;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
104
        $g->user_id = \Auth::id();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
105
        $g->youtube = $request->get('youtube');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
106
        $g->atelier_id = $request->get('atelier_id');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
107
        $g->license_id = $request->get('license');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
108
        $g->save();
109
110
        \DB::table('games_developer')->insert([
111
            'user_id'      => \Auth::id(),
112
            'game_id'      => $g->id,
113
            'developer_id' => $devid,
114
            'created_at'   => Carbon::now(),
115
        ]);
116
117
        event(new Obyx('game-add', \Auth::id()));
118
119
        return redirect()->action('MsgBoxController@game_add', [$g->id]);
120
    }
121
122
    /**
123
     * Add developer to game.
124
     *
125
     * @param Request $request
126
     * @param $id
127
     *
128
     * @return \Illuminate\Http\RedirectResponse
129
     */
130
    public function store_developer(Request $request, $id)
131
    {
132
        $this->validate($request, [
133
            'developer' => 'required',
134
        ]);
135
136
        $devid = DatabaseHelper::developerId_from_developerName($request->get('developer'));
137
        if ($devid == 0) {
138
            $devid = DatabaseHelper::developer_add_and_get_developerId($request->get('developer'));
139
        }
140
141
        \DB::table('games_developer')->insert([
142
            'user_id'      => \Auth::id(),
143
            'game_id'      => $id,
144
            'developer_id' => $devid,
145
            'created_at'   => Carbon::now(),
146
        ]);
147
148
        return redirect()->action('GameController@edit', [$id]);
149
    }
150
151
    /**
152
     * Display the specified resource.
153
     *
154
     * @param int $id
155
     *
156
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
157
     */
158
    public function show($id)
159
    {
160
        $game = Game::with('developers')->whereId($id)->first();
161
162
        event(new GameView($id));
163
164
        return view('games.show', [
165
            'game' => $game,
166
        ]);
167
    }
168
169
    /**
170
     * Show the form for editing the specified resource.
171
     *
172
     * @param int $id
173
     *
174
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
175
     */
176
    public function edit($id)
177
    {
178
        $makers = \DB::table('makers')
179
            ->get();
180
181
        $langs = \DB::table('languages')
182
            ->get();
183
184
        $creds = \DB::table('user_credit_types')
185
            ->orderBy('title')
186
            ->get();
187
188
        $credittypes = [];
189
        foreach ($creds as $cred) {
190
            $credittypes[$cred->id]['title'] = $cred->title;
191
            $credittypes[$cred->id]['id'] = $cred->id;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
192
        }
193
194
        $licenses = License::get();
195
196
        $game = Game::whereId($id)->first();
197
198
        return view('games.edit', [
199
            'game'     => $game,
200
            'makers'   => $makers,
201
            //'developers'  => $developers,
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
202
            'langs'    => $langs,
203
            'licenses' => $licenses,
204
            //'credittypes' => $credittypes,
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
205
            //'credits'     => $credits,
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
206
            //'tags' => $tags,
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
207
        ]);
208
    }
209
210
    /**
211
     * Update the specified resource in storage.
212
     *
213
     * @param \Illuminate\Http\Request $request
214
     * @param int                      $id
215
     *
216
     * @return \Illuminate\Http\RedirectResponse
217
     */
218
    public function update(Request $request, $id)
219
    {
220
        $lang = Language::whereShort($request->get('language'))->first();
221
222
        $game = Game::whereId($id)->first();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 15 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
223
        $game->title = $request->get('title');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
224
        $game->subtitle = $request->get('subtitle');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
225
        $game->maker_id = $request->get('maker');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
226
        $game->lang_id = $lang->id;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
227
        $game->desc_md = $request->get('msg');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
228
        $game->desc_html = \Markdown::convertToHtml($request->get('msg'));
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
229
        $game->website_url = $request->get('websiteurl');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
230
        $game->youtube = $request->get('youtube');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
231
        $game->atelier_id = $request->get('atelier_id');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
232
        $game->release_date = Carbon::createFromDate($request->get('releasedate_year'), $request->get('releasedate_month'), $request->get('releasedate_day'));
233
        $game->license_id = $request->get('license');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
234
        $game->save();
235
236
        return redirect()->action('GameController@edit', [$id]);
237
    }
238
239
    /**
240
     * Remove the specified resource from storage.
241
     *
242
     * @param int $id
243
     *
244
     * @return \Illuminate\Http\RedirectResponse
245
     */
246
    public function destroy($id)
247
    {
248
        $validate = Input::get('confirm', '');
249
        if (\Auth::check()) {
250
            if (\Auth::user()->can('delete-games')) {
251
                if ($validate == 'CONFIRM+'.$id) {
252
                    Game::whereId($id)->delete();
253
                    GamesFile::whereGameId($id)->delete();
254
                    Screenshot::whereGameId($id)->delete();
255
                    GamesDeveloper::whereGameId($id)->delete();
256
                    Comment::whereContentId($id)->where('content_type', '=', 'game')->delete();
257
                    TagRelation::whereContentId($id)->where('content_type', '=', 'game')->delete();
258
                } else {
259
                    return redirect()->action('GameController@edit', $id);
0 ignored issues
show
$id is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
260
                }
261
            }
262
        }
263
264
        return redirect()->route('home');
265
    }
266
267
    public function destroy_developer(Request $request, $id)
268
    {
269
        \DB::table('games_developer')
270
            ->where('game_id', '=', $id)
271
            ->where('developer_id', '=', $request->get('devid'))
272
            ->delete();
273
274
        return redirect()->action('GameController@edit', [$id]);
275
    }
276
}
277