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 AccountController extends Controller |
||
3 | { |
||
4 | public $layout='//layouts/columnGuest'; |
||
5 | |||
6 | /** |
||
7 | * Registers a new account. |
||
8 | * If registration is successful, the browser will be redirected to the to the previous page. |
||
9 | */ |
||
10 | public function actionSignup() |
||
11 | { |
||
12 | $this->signupNoMail(); |
||
13 | } |
||
14 | |||
15 | private function signupNoMail() |
||
16 | { |
||
17 | $model=new Account('signupNoMail'); |
||
18 | |||
19 | if (isset($_POST['Account'])) { |
||
20 | $model->attributes=$_POST['Account']; |
||
21 | $originalPassword = $model->password; |
||
22 | $valid = $model->validate(); |
||
23 | |||
24 | if ($valid) { |
||
25 | $hash = password_hash($model->password, PASSWORD_BCRYPT); |
||
26 | |||
27 | if (password_verify($model->password, $hash)) { |
||
28 | $model->password = $hash; |
||
29 | $model->verifyCode = null; |
||
30 | $model->verified = new CDbExpression('NOW()'); |
||
31 | |||
32 | $transaction = $model->getDbConnection()->beginTransaction(); |
||
33 | try { |
||
34 | $model->save(false); |
||
35 | $model->refresh(); |
||
36 | |||
37 | $this->createPlayer($model); |
||
38 | |||
39 | $transaction->commit(); |
||
40 | |||
41 | Yii::app()->user->setFlash('success', $model->username . ', a regisztrációd elkészült! Bejelentkezhetsz.'); |
||
42 | $this->redirect('/'); |
||
43 | } catch (Exception $e) { |
||
44 | $transaction->rollback(); |
||
45 | Yii::app()->user->setFlash('error', 'Hiba lépett fel a játékos mentése során.'); |
||
46 | } |
||
47 | $model->password = $originalPassword; |
||
48 | |||
49 | } else { |
||
50 | Yii::app()->user->setFlash('error', 'Hiba lépett fel a jelszó titkosítása során..'); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | $this->render('signupNoMail', array( |
||
56 | 'model'=>$model, |
||
57 | )); |
||
58 | } |
||
59 | private function signupWithMail() |
||
60 | { |
||
61 | $model=new Account('signupWithMail'); |
||
62 | |||
63 | if (isset($_POST['Account'])) { |
||
64 | $model->attributes=$_POST['Account']; |
||
65 | if ($model->validate()) { |
||
66 | // Create account |
||
67 | $model->save(false); |
||
68 | $model->verifyCode = $model->generateCode(); |
||
69 | |||
70 | // Send verification mail |
||
71 | $mail=Yii::app()->smtpmail; |
||
72 | $mail->CharSet = 'utf-8'; |
||
73 | $mail->SetFrom('[email protected]', 'ced.local'); //todo: activate sender |
||
74 | $mail->Subject = "Carp-e Diem regisztráció"; |
||
0 ignored issues
–
show
|
|||
75 | $message = $this->renderPartial('_verification', ['model'=>$model], true); |
||
76 | $mail->MsgHTML($message); |
||
77 | $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. ![]() |
|||
78 | $sent = $mail->Send(); |
||
79 | if (!$sent) { |
||
80 | Yii::app()->user->setFlash('error', 'A regisztráció befejezéséhez szükséges információkat nem sikerült elküldeni. Kérlek próbálkozz később.'); |
||
81 | } else { |
||
82 | $model->save(false); |
||
83 | Yii::app()->user->setFlash('success', 'A regisztráció befejezéséhez szükséges teendőket elküldtük e-mailben.'); |
||
84 | $this->redirect('/'); |
||
85 | } |
||
86 | |||
87 | } |
||
88 | } |
||
89 | |||
90 | $this->render('signup', array( |
||
91 | 'model'=>$model, |
||
92 | )); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Completes an account registration |
||
97 | * @param string $id Account id |
||
98 | * @param string $code Verification code |
||
99 | */ |
||
100 | public function actionCompleteSignup($id, $code) |
||
101 | { |
||
102 | $model = $this->loadModel($id); |
||
103 | $model->scenario = 'completeSignup'; |
||
104 | |||
105 | if (!$model->verifyCode || $model->username) { |
||
106 | Yii::app()->user->setFlash('info', 'Már állítottál be magadnak felhasználónevet. Kérlek jelentkezz be.'); |
||
107 | $this->redirect('/'); |
||
108 | } |
||
109 | |||
110 | if ($model->verifyCode !== $code) { |
||
111 | Yii::app()->user->setFlash('error', 'Az első belépéshez szükséges oldal címe nem érvényes. Pontosan másoltad be az e-mailből?'); |
||
112 | $this->redirect('/'); |
||
113 | } |
||
114 | |||
115 | if (isset($_POST['Account'])) { |
||
116 | $model->attributes=$_POST['Account']; |
||
117 | $originalPassword = $model->password; |
||
118 | $valid = $model->validate(); |
||
119 | |||
120 | if ($valid) { |
||
121 | $hash = password_hash($model->password, PASSWORD_BCRYPT); |
||
122 | |||
123 | if (password_verify($model->password, $hash)) { |
||
124 | $model->password = $hash; |
||
125 | $model->verifyCode = null; |
||
126 | $model->verified = new CDbExpression('NOW()'); |
||
127 | |||
128 | $transaction = $model->getDbConnection()->beginTransaction(); |
||
129 | try { |
||
130 | $model->save(false); |
||
131 | $model->refresh(); |
||
132 | |||
133 | $this->createPlayer($model); |
||
134 | |||
135 | $transaction->commit(); |
||
136 | |||
137 | Yii::app()->user->setFlash('success', $model->username . ', üdvözöllek a játékban!'); |
||
138 | Yii::app()->session->open(); |
||
139 | |||
140 | $model->password = $originalPassword; |
||
141 | $model->login(); |
||
142 | $this->redirect('/site'); |
||
143 | } catch (Exception $e) { |
||
144 | $transaction->rollback(); |
||
145 | Yii::app()->user->setFlash('error', 'Hiba lépett fel a játékos mentése során.'); |
||
146 | } |
||
147 | $model->password = $originalPassword; |
||
148 | |||
149 | } else { |
||
150 | Yii::app()->user->setFlash('error', 'Hiba lépett fel a jelszó titkosítása során.'); |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | |||
155 | $this->render('completeSignup', ['model' => $model]); |
||
156 | } |
||
157 | |||
158 | public function actionResetPassword() |
||
159 | { |
||
160 | $model = new Account('resetPassword'); |
||
161 | |||
162 | if (isset($_POST['Account'])) { |
||
163 | $model->attributes=$_POST['Account']; |
||
164 | |||
165 | if ($model->validate()) { |
||
166 | // Find account |
||
167 | $model = Account::model()->findByEmail($model->email); |
||
168 | |||
169 | if (!$model->password) { |
||
170 | $model->addError('email', 'A megadott e-mail címhez tartozó játékost még nem regisztráltad.'); |
||
171 | } else { |
||
172 | $this->sendResetLink($model); |
||
173 | } |
||
174 | } |
||
175 | } |
||
176 | |||
177 | $this->render('resetPassword', array( |
||
178 | 'model'=>$model, |
||
179 | )); |
||
180 | } |
||
181 | |||
182 | public function actionCompleteResetPassword($id, $code) |
||
183 | { |
||
184 | $model = $this->loadModel($id); |
||
185 | $model->password = false; |
||
186 | $model->scenario = 'completeResetPassword'; |
||
187 | |||
188 | if (!$model->resetPasswordCode) { |
||
189 | Yii::app()->user->setFlash('error', 'A jelszó visszaállításához szükséges oldal címe nem érvényes. Pontosan másoltad be az e-mailből?'); |
||
190 | $this->redirect('/'); |
||
191 | } |
||
192 | |||
193 | if ($model->resetPasswordCode !== $code) { |
||
194 | Yii::app()->user->setFlash('error', 'A jelszó visszaállításához szükséges oldal címe nem érvényes. Pontosan másoltad be az e-mailből?'); |
||
195 | $this->redirect('/'); |
||
196 | } |
||
197 | |||
198 | if (isset($_POST['Account'])) { |
||
199 | $model->attributes=$_POST['Account']; |
||
200 | $originalPassword = $model->password; |
||
201 | |||
202 | if ($model->validate()) { |
||
203 | $hash = password_hash($model->password, PASSWORD_BCRYPT); |
||
204 | |||
205 | if (password_verify($model->password, $hash)) { |
||
206 | //delete passwordCode |
||
207 | $model->resetPasswordCode = null; |
||
208 | |||
209 | //set new password |
||
210 | $model->password = $hash; |
||
211 | $model->save(false); |
||
212 | $model->refresh(); |
||
213 | |||
214 | Yii::app()->user->setFlash('success', $model->username . ', a jelszó mentése sikerült!'); |
||
215 | Yii::app()->session->open(); |
||
216 | |||
217 | $model->password = $originalPassword; |
||
218 | $model->login(); |
||
219 | $this->redirect('/site'); |
||
220 | |||
221 | } else { |
||
222 | Yii::app()->user->setFlash('error', 'Hiba lépett fel a jelszó titkosítása során.'); |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | |||
227 | $this->render('completeResetPassword', ['model' => $model]); |
||
228 | } |
||
229 | |||
230 | public function actionCompleteChangeEmail($id, $code) |
||
231 | { |
||
232 | $model = $this->loadModel($id); |
||
233 | if (!$model->changeMailCode) { |
||
234 | Yii::app()->user->setFlash('error', 'A beállított e-mail címed már aktiválva van.'); |
||
235 | $this->redirect('/'); |
||
236 | } |
||
237 | |||
238 | if ($model->changeMailCode !== $code) { |
||
239 | Yii::app()->user->setFlash('error', 'Az e-mail aktiválásához szükséges oldal címe nem érvényes.'); |
||
240 | $this->redirect('/'); |
||
241 | } |
||
242 | |||
243 | $account=$this->loadModel($id); |
||
244 | $account->email = $account->emailTemp; |
||
245 | $account->emailTemp = ''; |
||
246 | $account->changeMailCode = ''; |
||
247 | $account->save(); |
||
248 | |||
249 | Yii::app()->user->setFlash('success', 'Sikeresen aktiváltuk az e-mail címedet.'); |
||
250 | $this->redirect('/'); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @param Account $model |
||
255 | */ |
||
256 | private function sendResetLink($model) |
||
257 | { |
||
258 | // New verification if not exists |
||
259 | if (!$model->resetPasswordCode) { |
||
260 | $model->resetPasswordCode = $model->generateCode(); |
||
261 | $model->save(false); |
||
262 | } |
||
263 | |||
264 | // Send verification mail |
||
265 | $mail=Yii::app()->smtpmail; |
||
266 | $mail->CharSet = 'utf-8'; |
||
267 | $mail->SetFrom('[email protected]', 'ced.local'); //todo: activate sender |
||
268 | $mail->Subject = "Carp-e Diem elfelejtett jelszó"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
Carp-e Diem elfelejtett jelszó 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. ![]() |
|||
269 | $message = $this->renderPartial('_resetPassword', ['model'=>$model], true); |
||
270 | $mail->MsgHTML($message); |
||
271 | $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. ![]() |
|||
272 | $sent = $mail->Send(); |
||
273 | if (!$sent) { |
||
274 | Yii::app()->user->setFlash('error', 'A jelszó visszaállításához szükséges információkat nem sikerült elküldeni. Kérlek próbálkozz később.'); |
||
275 | } else { |
||
276 | Yii::app()->user->setFlash('success', 'A jelszó visszaállításához szükséges teendőket elküldtük e-mailben.'); |
||
277 | $this->redirect('/'); |
||
278 | } |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * @param Account $model |
||
283 | */ |
||
284 | private function createPlayer($model) |
||
285 | { |
||
286 | $command = Yii::app()->db->createCommand(); |
||
287 | $command->insert('main', [ |
||
288 | 'uid'=>$model->id, |
||
289 | 'user'=>$model->username, |
||
290 | ]); |
||
291 | |||
292 | $command->insert('users_items', [ |
||
293 | 'uid'=>$model->id, |
||
294 | 'item_id'=>1, |
||
295 | 'skill'=>1, |
||
296 | 'item_count'=>1, |
||
297 | ]); |
||
298 | |||
299 | $command->insert('users_baits', [ |
||
300 | 'uid'=>$model->id, |
||
301 | 'item_id'=>1, |
||
302 | 'skill'=>1, |
||
303 | 'item_count'=>1, |
||
304 | ]); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * Returns the data model based on the primary key given in the GET variable. |
||
309 | * If the data model is not found, an HTTP exception will be raised. |
||
310 | * @param integer $id the ID of the model to be loaded |
||
311 | * @return Account the loaded model |
||
312 | * @throws CHttpException |
||
313 | */ |
||
314 | View Code Duplication | public function loadModel($id) |
|
315 | { |
||
316 | $model=Account::model()->findByPk((int)$id); |
||
317 | |||
318 | if ($model===null) { |
||
319 | throw new CHttpException(1, 'A keresett játékos nem található. Ezen könnyen segíthetsz: ' . CHtml::link('regisztráld be.', ['signup'])); |
||
320 | } |
||
321 | |||
322 | return $model; |
||
323 | } |
||
324 | |||
325 | View Code Duplication | protected function beforeAction($action) |
|
326 | { |
||
327 | if (Yii::app()->params['isPartOfWline']) { |
||
328 | throw new CHttpException(1, 'Ez az aloldal nem használható. ' . CHtml::link('főoldal', ['/site'])); //own nick |
||
329 | } |
||
330 | |||
331 | return true; |
||
332 | } |
||
333 | } |
||
334 |
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.
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.