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/IndexController.php (11 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\Models\Game;
12
use App\Models\News;
13
use App\Models\User;
14
use App\Models\Comment;
15
use App\Models\Shoutbox;
16
use App\Helpers\MiscHelper;
17
use App\Models\BoardThread;
18
use App\Models\GamesCoupdecoeur;
19
20
class IndexController extends Controller
21
{
22
    public function index()
23
    {
24
        $gametypes = \DB::table('games_files_types')
25
            ->select('id', 'title', 'short')
26
            ->get();
27
        $gtypes = [];
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...
28
        foreach ($gametypes as $gt) {
29
            $t['title'] = $gt->title;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$t was never initialized. Although not strictly required by PHP, it is generally a good practice to add $t = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
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...
30
            $t['short'] = $gt->short;
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...
31
            $gtypes[$gt->id] = $t;
32
        }
33
34
        $news = News::with('user', 'comments')->orderBy('created_at', 'desc')->where('approved', '=', 1)->get()->take(5);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 11 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...
35
        $shoutbox = Shoutbox::with('user')->orderBy('created_at', 'desc')->limit(5)->get()->reverse();
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...
36
        $cdc = GamesCoupdecoeur::with('game')->orderBy('created_at', 'desc')->get()->first();
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 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...
37
        $latestadded = Game::with('maker', 'gamefiles', 'language', 'developers')->orderBy('created_at', 'desc')->limit(5)->get();
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...
38
        $latestreleased = Game::where('release_type', '!=', 99)->orderBy('release_date', 'desc')->limit(5)->get();
39
        $threads = BoardThread::with('posts', 'user', 'last_user')->orderBy('last_created_at', 'desc')->limit(10)->get();
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...
40
41
        $topusers = \DB::table('users as u')
42
            ->leftJoin('user_role_user as uru', 'u.id', '=', 'uru.user_id')
43
            ->leftJoin('user_roles as ur', 'ur.id', '=', 'uru.role_id')
44
            ->select([
45
                'u.id as userid',
46
                'u.name as username',
47
                'u.created_at as usercreated_at',
48
                'ur.display_name as rolename',
49
                'ur.description as roledesc',
50
            ])
51
            ->selectRaw('(SELECT SUM(obyx.value) FROM user_obyx LEFT JOIN obyx ON obyx.id = user_obyx.obyx_id WHERE user_obyx.user_id = u.id) as obyx')
52
            ->orderBy('obyx', 'desc')
53
            ->limit(5)
54
            ->get();
55
56
        $obyxmax = \DB::table('user_obyx as uo')
57
            ->leftJoin('obyx as o', 'o.id', '=', 'uo.obyx_id')
58
            ->selectRaw('SUM(o.value) as value')
59
            ->groupBy('uo.user_id')
60
            ->orderByRaw('SUM(o.value) DESC')
61
            ->first();
62
63
        if (\Auth::check()) {
64
            $pm = \Auth::user()->newThreadsCount();
65
        } else {
66
            $pm = '';
67
        }
68
69
        $stats = \DB::table('games')
70
            ->selectRaw('COUNT(id) as gamecount')
71
            ->selectRaw('(SELECT COUNT(id) FROM makers) as makercount')
72
            ->selectRaw('(SELECT COUNT(id) FROM developer) as developercount')
73
            ->selectRaw('(SELECT COUNT(id) FROM users) as usercount')
74
            ->selectRaw('(SELECT COUNT(id) FROM board_threads) as threadcount')
75
            ->selectRaw('(SELECT COUNT(id) FROM board_posts) as postcount')
76
            ->selectRaw('(SELECT COUNT(id) FROM shoutbox) as shoutboxcount')
77
            ->selectRAW('(SELECT COUNT(id) FROM comments) as commentcount')
78
            ->selectRaw('(SELECT COUNT(id) FROM logos) as logocount')
79
            ->selectRaw('(SELECT SUM(downloadcount) FROM games_files) as downloadcount')
80
            ->selectRaw('(SELECT SUM(filesize) FROM games_files) as totalsize')
81
            ->selectRaw('(SELECT COUNT(id) FROM games_files) as filecount')
82
            ->first();
83
84
        $size = \DB::table('games_files')
85
            ->selectRaw('SUM(filesize * downloadcount) as downsize')
86
            ->groupBy('id')
87
            ->get();
88
89
        $res = 0;
90
        foreach ($size as $s) {
91
            $res += $s->downsize;
92
        }
93
        $size = MiscHelper::getReadableBytes($res);
94
95
        $topmonth = \DB::table('games')
96
            ->leftJoin('games_developer', 'games.id', '=', 'games_developer.game_id')
97
            ->leftJoin('developer', 'games_developer.developer_id', '=', 'developer.id')
98
            ->leftJoin('makers', 'makers.id', '=', 'games.maker_id')
99
            ->leftJoin('languages', 'languages.id', '=', 'games.lang_id')
100
            ->leftJoin('comments', function ($join) {
101
                $join->on('comments.content_id', '=', 'games.id');
102
                $join->on('comments.content_type', '=', \DB::raw("'game'"));
103
            })
104
            ->leftJoin('games_files', 'games_files.game_id', '=', 'games.id')
105
            ->leftJoin('users', 'games_developer.user_id', '=', 'users.id')
106
            ->select([
107
                'games.id as gameid',
108
                'games.title as gametitle',
109
                'games.subtitle as gamesubtitle',
110
                'developer.name as developername',
111
                'developer.id as developerid',
112
                'developer.created_at as developerdate',
113
                'developer.user_id as developeruserid',
114
                'users.name as developerusername',
115
                'games.created_at as gamecreated_at',
116
                'makers.short as makershort',
117
                'makers.title as makertitle',
118
                'makers.id as makerid',
119
                'languages.id as lang_id',
120
                'languages.name as lang_name',
121
                'languages.short as lang_short',
122
            ])
123
            ->selectRaw('(SELECT COUNT(id) FROM comments WHERE content_id = games.id AND content_type = "game") as commentcount')
124
            ->selectRaw('(SELECT SUM(vote_up) FROM comments WHERE content_id = games.id AND content_type = "game") as voteup')
125
            ->selectRaw('(SELECT SUM(vote_down) FROM comments WHERE content_id = games.id AND content_type = "game") as votedown')
126
            ->selectRaw('MAX(games_files.release_type) as gametype')
127
            ->selectRaw("(SELECT STR_TO_DATE(CONCAT(release_year,'-',release_month,'-',release_day ), '%Y-%m-%d') FROM games_files WHERE game_id = games.id ORDER BY release_year DESC, release_month DESC, release_day DESC LIMIT 1) as releasedate")
128
            ->selectRaw('(SELECT COUNT(id) FROM games_coupdecoeur WHERE game_id = games.id) as cdccount')
129
            ->where('comments.created_at', '>', Carbon::today()->addMonth(-1)->toDateString())
130
            ->orderByRaw('(voteup - votedown) / (voteup + votedown) DESC')
131
            ->groupBy('games.id')
132
            ->limit(5)->get();
133
134
        $topalltime = Game::orderBy('avg', 'desc')->limit(5)->get();
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...
135
        $latestcomments = Comment::with('game')->whereContentType('game')->orderBy('created_at', 'desc')->limit(5)->get();
136
        $randomgame = Game::inRandomOrder()->first();
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...
137
138
        $newuser = User::orderBy('created_at', 'desc')->first();
139
140
        return view('index.index', [
141
            'news'           => $news,
142
            'shoutbox'       => $shoutbox,
143
            'cdc'            => $cdc,
144
            'latestadded'    => $latestadded,
145
            'gametypes'      => $gtypes,
146
            'latestreleased' => $latestreleased,
147
            'threads'        => $threads,
148
            'obeymax'        => $obyxmax,
149
            'topusers'       => $topusers,
150
            'pm'             => $pm,
151
            'stats'          => $stats,
152
            'topmonth'       => $topmonth,
153
            'topalltime'     => $topalltime,
154
            'latestcomments' => $latestcomments,
155
            'size'           => $size,
156
            'randomgame'     => $randomgame,
157
            'newuser'        => $newuser,
158
        ]);
159
    }
160
}
161