Issues (1020)

Security Analysis    no vulnerabilities found

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.

models/LocationAction.php (31 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
 * @property integer $completedId
4
 */
5
class LocationAction extends CModel
6
{
7
    private $location;
8
    private $completedId = 0;
9
10
    public function attributeNames()
11
    {
12
        return [];
13
    }
14
15
    public function setLocation($location)
16
    {
17
        $this->location = $location;
18
    }
19
20
    public function getCompletedId()
21
    {
22
        return $this->completedId;
23
    }
24
25
    private function getReduction()
26
    {
27
        $reduction = 0;
28
29
        if ($this->location->routine >= 3) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
30
            $reduction = 1; // silver
31
        }
32
33
        if ($this->location->routine >= 9) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
34
            $reduction = 2; // gold
35
        }
36
37
        if ($this->location->routine >= 27) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
38
            $reduction = 3; // emerald
39
        }
40
41
        if ($this->location->routine >= 81) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
42
            $reduction = 4; // diamant
43
        }
44
45
        if ($this->location->routine >= 243) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
46
            $reduction = 5; // 3 diamants
47
        }
48
49
        return $reduction;
50
    }
51
52
    public function completeMission($id)
53
    {
54
        if (!isset($this->location->missions[$id])) {
0 ignored issues
show
The property missions cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
55
            return false;
56
        }
57
58
        //max routine
59
        if ($this->location->routine >= 243) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
60
            Yii::app()->user->setFlash('info', 'Ezen a helyszínen már elérted a legnagyobb helyszínrutint, így nem teljesítheted a megbízást.');
61
            return false; //max routine reached
62
        }
63
64
        $this->completedId = $id;
65
        $m = $this->location->missions[$id];
0 ignored issues
show
The property missions cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
Equals sign not aligned with surrounding assignments; expected 17 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...
66
        if ($m->gate) {
67
            $m->locationRoutinesFull = $this->allMissionRoutinesAreFull();
68
        }
69
70
        $m->routine_reduction = $this->getReduction();
71
        $m->complete();
72
        if ($m->gate && $m->action->success) {
73
            $this->incrementRoutine();
74
            $this->visitNewLocation($m);
75
        }
76
    }
77
78
    private function allMissionRoutinesAreFull()
79
    {
80 View Code Duplication
        foreach ($this->location->missions as $mission) {
0 ignored issues
show
The property missions cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
            if (!$mission->gate && $mission->routine < 100) {
82
                return false;
83
            }
84
        }
85
        return true;
86
    }
87
88
    private function incrementRoutine()
89
    {
90
        $uid = Yii::app()->player->model->uid;
91
92
        //increment location routine
93
        Yii::app()->db
94
            ->createCommand("UPDATE visited SET routine=routine+1 WHERE uid=:uid AND water_id=:water_id")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal UPDATE visited SET routi... AND water_id=:water_id does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
95
            ->bindValues([':uid'=>$uid, ':water_id'=>$this->location->id])
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
96
            ->execute();
97
98
        //reset all missions routine on this location
99
        Yii::app()->db
100
            ->createCommand("UPDATE users_missions SET routine=0 WHERE uid=:uid AND water_id=:water_id")
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal UPDATE users_missions SE... AND water_id=:water_id does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
101
            ->bindValues([':uid'=>$uid, ':water_id'=>$this->location->id])
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
102
            ->execute();
103
104
        //refresh objects
105
        foreach ($this->location->missions as $mission) {
0 ignored issues
show
The property missions cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
106
            $mission->routine = 0;
107
        }
108
        $this->location->incrementRoutine();
109
        Yii::app()->badge->model->triggerLocationRoutine($this->location->id, $this->location->routine);
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
110
111
        //add routine awards
112
        $this->addAwardForRoutine();
113
    }
114
115
    private function addAwardForRoutine()
116
    {
117
        if ($this->location->routine == 9) { //gold
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
118
            $this->addAward(1, Yii::app()->params['routineAwardForGold'], 'az arany');
119
        }
120
121
        if ($this->location->routine == 81) { //diamant
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
122
            $this->addAward(1, Yii::app()->params['routineAwardForDiamant'], 'a gyémánt');
123
        }
124
    }
125
126
    /**
127
     * @param integer $sp
128
     * @param integer $gold
129
     * @param string $title
130
     */
131
    private function addAward($sp, $gold, $title)
132
    {
133
        $player = Yii::app()->player->model;
134
135
        $logger = new Logger;
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...
136
        $logger->key = 'routineAward:'.$player->uid;
0 ignored issues
show
The property key cannot be accessed from this context as it is declared private in class Logger.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
137
        $logger->addToSet('----start: '.date('Y.m.d. H:i:s').'----');
138
        $logger->addToSet('id: ' . $this->location->id . ', routine: ' . $this->location->routine);
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
139
        $logger->addToSet('before: ' . $player->status_points . 'sp, ' . $player->gold . 'gold');
140
141
        $player->updateAttributes(['status_points'=>$sp, 'gold'=>$gold], []);
142
        Yii::app()->user->setFlash('info', "Gratulálok, elérted <strong> {$title} </strong> helyszínrutint!<br/>Jutalmad: {$sp} státuszpont és {$gold} arany.");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $title instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $sp instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $gold instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
143
144
        $logger->addToSet('after: ' . $player->status_points . 'sp, ' . $player->gold . 'gold');
145
146
        Yii::app()->gameLogger->log(['type'=>'routine_award', 'water_id'=>$this->location->id, 'routine'=>$this->location->routine]);
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
The property routine cannot be accessed from this context as it is declared private in class Location.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
147
    }
148
149
    private function visitNewLocation($mission)
150
    {
151
        if ($mission->gate_visited) {
152
            return false; //do not open the same location twice
153
        }
154
155
        $player = Yii::app()->player->model;
156
        $gate = (int)$mission->gate;
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...
157
158
        $location = Yii::app()->db->createCommand()
159
            ->select('uid, water_id')
160
            ->from('visited')
161
            ->where('uid=:uid AND water_id=:water_id', [':uid'=>$player->uid, ':water_id'=>$gate])
162
            ->queryScalar();
163
164
        if (!$location) {
165
            Yii::app()->db->createCommand()
166
                ->insert('visited', [
167
                'uid'=>$player->uid,
168
                'water_id'=>$gate,
169
                'skill_extended_at_visit'=>(int)$player->skill_extended,
170
                ]);
171
        }
172
        $mission->action->gained_visit = true;
173
        Yii::app()->gameLogger->log(['type'=>'travel', 'traveled_to'=>$gate]);
174
175
        Yii::app()->badge->model->triggerTravel($gate);
176
    }
177
}
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
178