This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | class SetupController extends GameController |
||
3 | { |
||
4 | public function actionPassword() |
||
0 ignored issues
–
show
|
|||
5 | { |
||
6 | $model=new Account('changePassword'); |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
7 | |||
8 | if (isset($_POST['Account'])) { |
||
9 | $model->attributes=$_POST['Account']; |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
10 | if ($model->validate()) { |
||
11 | $account=$this->loadModel(Yii::app()->player->uid); |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
12 | |||
13 | if ($account->validatePassword($model->oldPassword)) { |
||
14 | $account->password = password_hash($model->password, PASSWORD_BCRYPT); |
||
15 | $account->save(false); |
||
16 | |||
17 | Yii::app()->user->setFlash('success', 'A jelszócsere sikerült.'); |
||
18 | $this->redirect(['/player']); |
||
19 | } else { |
||
20 | $model->addError('oldPassword', 'A megadott régi jelszó nem érvényes.'); |
||
21 | } |
||
22 | } |
||
23 | } |
||
24 | |||
25 | $this->render('changePassword', ['model'=>$model]); |
||
26 | } |
||
27 | |||
28 | public function actionEmail() |
||
0 ignored issues
–
show
actionEmail uses the super-global variable $_POST which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
|||
29 | { |
||
30 | $model=new Account('changeEmail'); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 0 spaces
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. ![]() |
|||
31 | $account = $this->loadModel(Yii::app()->player->uid); |
||
32 | |||
33 | if (isset($_POST['Account'])) { |
||
34 | $model->attributes=$_POST['Account']; |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
35 | if ($model->validate()) { |
||
36 | if ($account->validatePassword($model->password)) { |
||
37 | if (!$account->changeMailCode) { |
||
38 | $account->changeMailCode = $account->generateCode(); |
||
39 | } |
||
40 | |||
41 | Account::model()->updateByPk(Yii::app()->player->uid, array( |
||
42 | 'changeMailCode' => $account->changeMailCode, |
||
43 | 'emailTemp' => $model->email |
||
44 | )); |
||
45 | |||
46 | // Send verification mail |
||
47 | $mail=Yii::app()->smtpmail; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 0 spaces
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. ![]() |
|||
48 | $mail->CharSet = 'utf-8'; |
||
49 | $mail->SetFrom('[email protected]', 'ced.local'); //todo: activate sender |
||
0 ignored issues
–
show
|
|||
50 | $mail->Subject = "Carp-e Diem e-mail cím beállítása"; |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 4 spaces
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. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
Carp-e Diem e-mail cím beállítása 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 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 ( 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: 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. ![]() |
|||
51 | $message = $this->renderPartial('_changeEmail', ['model'=>$account], true); |
||
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. ![]() |
|||
52 | $mail->MsgHTML($message); |
||
53 | $mail->AddAddress($model->email, ""); |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
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 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 ( 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: 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. ![]() |
|||
54 | $sent = $mail->Send(); |
||
55 | if (!$sent) { |
||
56 | Yii::app()->user->setFlash('error', 'Az új e-mail cím aktiválásához szükséges információkat nem sikerült elküldeni. Kérlek próbálkozz később.'); |
||
57 | } else { |
||
58 | Yii::app()->user->setFlash('success', 'Az új e-mail cím aktiválásához szükséges teendőket elküldtük e-mailben.'); |
||
59 | $this->redirect('email'); |
||
60 | } |
||
61 | |||
62 | } else { |
||
63 | $model->addError('password', 'A megadott jelszó nem érvényes.'); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | |||
68 | $this->render('changeEmail', [ |
||
69 | 'model'=>$model, |
||
70 | 'account'=>$account, |
||
71 | ]); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Returns the data model based on the primary key given in the GET variable. |
||
76 | * If the data model is not found, an HTTP exception will be raised. |
||
77 | * @param integer $id the ID of the model to be loaded |
||
78 | * @return Account the loaded model |
||
79 | * @throws CHttpException |
||
80 | */ |
||
81 | View Code Duplication | public function loadModel($id) |
|
0 ignored issues
–
show
This method seems to be duplicated in 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. ![]() |
|||
82 | { |
||
83 | $model=Account::model()->findByPk((int)$id); |
||
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. ![]() |
|||
84 | |||
85 | if ($model===null) { |
||
86 | throw new CHttpException(1, 'A keresett játékos nem található.'); |
||
87 | } |
||
88 | |||
89 | return $model; |
||
90 | } |
||
91 | } |
||
0 ignored issues
–
show
|
|||
92 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: