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/MissionAction.php (37 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 array $reqPassed
4
 * @property boolean $success
5
 * @property integer $gained_xp
6
 * @property integer $gained_dollar
7
 * @property integer $gained_routine
8
 * @property boolean $gained_visit
9
 * @property Item $found_setpart
10
 */
11
class MissionAction extends CModel
12
{
13
    private $mission;
14
    private $reqPassed = [];
15
    private $success;
16
    private $gained_xp;
17
    private $gained_dollar;
18
    private $gained_routine;
19
    private $gained_visit;
20
    private $found_setpart;
21
22
    public function getReqPassed()
23
    {
24
        return $this->reqPassed;
25
    }
26
27
    public function getSuccess()
28
    {
29
        return $this->success;
30
    }
31
32
    public function getGained_xp()
33
    {
34
        return (int)$this->gained_xp;
35
    }
36
37
    public function getGained_dollar()
38
    {
39
        return (int)$this->gained_dollar;
40
    }
41
42
    public function getGained_routine()
43
    {
44
        return (int)$this->gained_routine;
45
    }
46
47
    public function getGained_visit()
48
    {
49
        return (bool)$this->gained_visit;
50
    }
51
52
    public function getFound_setpart()
53
    {
54
        return $this->found_setpart;
55
    }
56
57
    public function setMission($mission)
58
    {
59
        $this->mission = $mission;
60
    }
61
62
    public function setGained_visit($visit)
63
    {
64
        $this->gained_visit = (bool)$visit;
65
        $this->mission->gate_visited = (bool)$visit;
0 ignored issues
show
The property gate_visited cannot be accessed from this context as it is declared private in class Mission.

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...
66
    }
67
68
    public function attributeNames()
69
    {
70
        return [];
71
    }
72
73
    public function complete()
74
    {
75
        if (!$this->requirementsOk()) {
76
            return false;
77
        }
78
79
        if (!$this->doMission()) {
80
            throw new CFlashException('A követelményeknek megfelelsz, mégsem sikerül teljesíteni a megbízást mivel csak '. $this->mission->chance .'% esélyed volt rá.<br/>
0 ignored issues
show
The property chance cannot be accessed from this context as it is declared private in class Mission.

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...
81
                Nagyobb szakértelemmel (több felszereléssel és csalival) ez növelhető.');
82
        }
83
        $this->incrementRoutine();
84
    }
85
86
    private function requirementsOk()
87
    {
88
        $player = Yii::app()->player->model;
89
90
        //check if the mission is gate and the submissions are maxed out
91
        if ($this->mission->gate) {
0 ignored issues
show
The property gate cannot be accessed from this context as it is declared private in class Mission.

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...
92
            $this->reqPassed['routinesFull'] = $this->mission->locationRoutinesFull;
0 ignored issues
show
The property locationRoutinesFull cannot be accessed from this context as it is declared private in class Mission.

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...
93
        }
94
95
        //check energy
96
        $this->reqPassed['energy'] = ($player->energy >= $this->mission->req_energy);
0 ignored issues
show
The property req_energy cannot be accessed from this context as it is declared private in class Mission.

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...
97
98
        //check baits
99
        foreach ($this->mission->req_baits as $req) {
0 ignored issues
show
The property req_baits cannot be accessed from this context as it is declared private in class Mission.

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...
100
            $this->reqPassed['bait_'.$req['item']->id] = $req['haveEnought'];
101
        }
102
103
        foreach ($this->reqPassed as $passed) {
104
            if (!$passed) {
105
                throw new CFlashException('Nem tudod elvégezni a megbízást, mert nem teljesíted a követelményeket.');
106
            }
107
        }
108
109
        //routine full
110
        if ($this->mission->routine >= 100) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Mission.

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...
111
            throw new CFlashException('Ezt a megbízást már 100% rutinnal végzed, ezért unalmas lenne ismételgetni.');
112
        }
113
114
        return true;
115
    }
116
117
    private function doMission()
118
    {
119
        $incr = $decr = [];
120
121
        //take requirements
122
        $decr['energy'] = $this->mission->req_energy;
0 ignored issues
show
The property req_energy cannot be accessed from this context as it is declared private in class Mission.

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...
123
124
        //complete
125
        $this->success = $this->beatMission();
126
127
        //add awards
128
        $incr['xp_all'] = $incr['xp_delta'] = $this->gainXP();
129
        $incr['dollar'] = $this->gainDollar();
130
131
        if ($this->success) {
132
            if ($this->mission->gate && !$this->mission->gate_visited) {
0 ignored issues
show
The property gate cannot be accessed from this context as it is declared private in class Mission.

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 gate_visited cannot be accessed from this context as it is declared private in class Mission.

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...
133
                $incr['gold'] = Yii::app()->params['goldPerGateMission'];
134
            }
135
            if ($this->mission->award_setpart) {
0 ignored issues
show
The property award_setpart cannot be accessed from this context as it is declared private in class Mission.

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...
136
                $this->addSetPart();
137
            }
138
        }
139
140
        Yii::app()->player->model->updateAttributes($incr, $decr);
141
142
        //increment contest points
143
        $contest = new Contest;
144
        $contest->addPoints(Yii::app()->player->uid, Contest::ACT_MISSION, $decr['energy'], $incr['xp_all'], $incr['dollar']);
145
146
        return $this->success;
147
    }
148
149
    private function incrementRoutine()
150
    {
151
        if ($this->mission->gate) {
0 ignored issues
show
The property gate cannot be accessed from this context as it is declared private in class Mission.

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...
152
            return false; //do not increment for gate missions
153
        }
154
        if (!$this->success) {
155
            return false; // do not increment on failed missions
156
        }
157
158
        $uid = Yii::app()->player->model->uid;
159
        $routine = (int)$this->mission->routine_gain;
0 ignored issues
show
The property routine_gain cannot be accessed from this context as it is declared private in class Mission.

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...
160
        if ($routine<1) {
161
            $routine = 1;
162
        }
163
164
        if ($this->mission->routine >= 100) {
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Mission.

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...
165
            $this->mission->routine_gain = 0;
0 ignored issues
show
The property routine_gain cannot be accessed from this context as it is declared private in class Mission.

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...
166
            return false;
167
        }
168
169
        $update = Yii::app()->db
170
            ->createCommand("UPDATE users_missions SET routine=routine+:routine WHERE uid=:uid AND id=:id")
171
            ->bindValues([':uid'=>$uid, 'id'=>(int)$this->mission->id, ':routine'=>$routine])
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Mission.

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...
172
            ->execute();
173
174 View Code Duplication
        if (!$update) {
175
            Yii::app()->db->createCommand()
176
                ->insert('users_missions', [
177
                'uid'=>$uid,
178
                'id'=>(int)$this->mission->id,
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Mission.

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...
179
                'water_id'=>(int)$this->mission->water_id,
0 ignored issues
show
The property water_id cannot be accessed from this context as it is declared private in class Mission.

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...
180
                'routine'=>$routine
181
                ]);
182
        }
183
        $this->mission->routine += $routine;
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Mission.

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...
184
        $this->gained_routine = $routine;
185
        Yii::app()->badge->model->triggerRoutine($this->mission->routine);
0 ignored issues
show
The property routine cannot be accessed from this context as it is declared private in class Mission.

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...
186
    }
187
188
    private function beatMission()
189
    {
190
        $random = rand(1, 100);
191
        $success = ($random <= $this->mission->chance); //win
0 ignored issues
show
The property chance cannot be accessed from this context as it is declared private in class Mission.

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...
192
193
        //log mission counter
194
        $cell = 'mission_' . ($this->mission->gate ? 'gate_' : '') . ($success ? 'success' : 'fail');
0 ignored issues
show
The property gate cannot be accessed from this context as it is declared private in class Mission.

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...
195
196
        $logger = new Logger;
197
        $logger->uid = Yii::app()->player->model->uid;
0 ignored issues
show
The property uid 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...
198
        $logger->level = Yii::app()->player->model->level;
0 ignored issues
show
The property level 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...
199
        $logger->increment($cell, 1);
200
201
        return $success;
202
    }
203
204
    private function gainXP()
205
    {
206
        $xp = $this->mission->award_xp;
0 ignored issues
show
The property award_xp cannot be accessed from this context as it is declared private in class Mission.

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...
207
        if (!$this->success) {
208
            $xp = round($this->mission->award_xp / 10);
0 ignored issues
show
The property award_xp cannot be accessed from this context as it is declared private in class Mission.

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...
209
        }
210
        $this->gained_xp = $xp;
211
212
        return $xp;
213
    }
214
215
    private function gainDollar()
216
    {
217
        $dollar = 0;
218
        if ($this->success) {
219
            $dollar = rand($this->mission->award_dollar_min, $this->mission->award_dollar_max);
0 ignored issues
show
The property award_dollar_min cannot be accessed from this context as it is declared private in class Mission.

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 award_dollar_max cannot be accessed from this context as it is declared private in class Mission.

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...
220
        }
221
        $this->gained_dollar = $dollar;
222
223
        return $dollar;
224
    }
225
226
    private function addSetPart()
227
    {
228
        $player = Yii::app()->player->model;
229
230
        $logger = new Logger;
231
        $logger->key = 'setitem:'.$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...
232
        $logger->addToSet('----start: '.date('Y.m.d. H:i:s').'----');
233
234
        $findChance = Yii::app()->params['setPartFindChanceInitial']; //  Chance % to find something
235
        $logger->addToSet('initialize variables');
236
237
        $now = time();
238
        if ($now - strtotime($player->found_setitem_time) < Yii::app()->params['setPartFindTimeLimit']) {
239
            $findChance = Yii::app()->params['setPartFindChanceTimeLimit']; //decrease chance in last 24 hour
240
        }
241
        if ($player->xp_all - $player->found_setitem_xp < Yii::app()->params['setPartFindXpLimit']) {
242
            $findChance = Yii::app()->params['setPartFindChanceXpLimit']; //decrease chance in last xp interval
243
        }
244
245
        $rnd = rand(1, 100);
246
        $logger->addToSet('chance: '. $rnd .'/'.$findChance);
247
        if ($rnd > $findChance) {
248
            return false;
249
        }
250
251
        //select rnd setitem
252
        $items = Yii::app()->db->createCommand()
253
            ->select('id')
254
            ->from('parts')
255
            ->where('level < :minLevel', [':minLevel'=>$player->level+1])
256
            ->queryAll();
257
258
        $rnd = array_rand($items);
259
        $logger->addToSet('items key: '.$rnd);
260
        $itemId = isset($items[$rnd]) ? $items[$rnd]['id'] : false;
261
        $logger->addToSet('itemId: '. $itemId);
262
        if (!$itemId) {
263
            return false;
264
        }
265
266
        $i = new Item;
267
        $i->id = $itemId;
0 ignored issues
show
The property id cannot be accessed from this context as it is declared private in class Item.

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...
268
        $i->item_type = Item::TYPE_PART;
0 ignored issues
show
The property item_type cannot be accessed from this context as it is declared private in class Item.

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...
269
        $i->fetch();
270
        $logger->addToSet('item: '. $i->title);
0 ignored issues
show
The property title cannot be accessed from this context as it is declared private in class Item.

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...
271
272
        //add to inventory
273
        $i->buy(1);
274
        $logger->addToSet('errors: '. CJSON::encode($i->errors));
0 ignored issues
show
The property errors cannot be accessed from this context as it is declared private in class Item.

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...
275
        $logger->addToSet('price: '. $i->price);
0 ignored issues
show
The property price cannot be accessed from this context as it is declared private in class Item.

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...
276
        $player->rewriteAttributes([
277
            'found_setitem_time'=>date("Y-m-d H:i:s", $now),
278
            'found_setitem_xp'=>$player->xp_all,
279
            ]);
280
        $this->found_setpart = $i;
281
        $logger->addToSet('item bought');
282
283
        //log found part
284
        Yii::app()->gameLogger->log(['type'=>'setpart', 'found_setpart'=>$i->title]);
0 ignored issues
show
The property title cannot be accessed from this context as it is declared private in class Item.

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...
285
        $logger->addToSet('---- end: '.date('Y.m.d. H:i:s').'----');
286
287
        //stat
288
        $logger->uid = $player->uid;
0 ignored issues
show
The property uid 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...
289
        $logger->level = $player->level;
0 ignored issues
show
The property level 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...
290
        $found = $logger->increment('found_part', 1);
291
        Yii::app()->badge->model->triggerSetPart($found);
292
    }
293
}
294