-
Notifications
You must be signed in to change notification settings - Fork 2
/
passwordrecovery.php
124 lines (98 loc) · 3.51 KB
/
passwordrecovery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
declare(strict_types=1);
/**
* This file is part of the VitexSoftware package
*
* https://vitexsoftware.com/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace VSCZ\ui;
require_once 'includes/VSInit.php';
$success = false;
$emailTo = $oPage->getPostValue('Email');
if (empty($emailTo)) {
$oUser->addStatusMessage(_('Please enter your email.'));
} else {
$userEmail = addslashes($emailTo);
$controlUser = new \VSCZ\User();
$controlData = $controlUser->getColumnsFromSql(
[$controlUser->getkeyColumn()],
['email' => $userEmail],
);
if (empty($controlData)) {
\Ease\Shared::user()->addStatusMessage(sprintf(
_('unknow email address %s'),
'<strong>'.$_REQUEST['Email'].'</strong>',
), 'warning');
} else {
$controlUser->loadFromSQL((int) $controlData[0][$controlUser->getkeyColumn()]);
$userLogin = $controlUser->getUserLogin();
$newPassword = \Ease\Functions::randomString(8);
if ($controlUser->passwordChange($newPassword)) {
$email = $oPage->addItem(new \Ease\HtmlMailer(
$userEmail,
\constant('EASE_APPNAME').' -'.sprintf(
_('New password for %s'),
$_SERVER['SERVER_NAME'],
),
));
$email->setMailHeaders(['From' => \constant('EMAIL_FROM')]);
$email->addItem(_('Sign On informations was changed').":\n");
$email->addItem(_('Username').': '.$userLogin."\n");
$email->addItem(_('Password').': '.$newPassword."\n");
$email->send();
$oUser->addStatusMessage(sprintf(
_('Your new password was sent to %s'),
'<strong>'.$emailTo.'</strong>',
));
$success = true;
}
}
}
$oPage->addItem(new PageTop(_('Lost password recovery')));
$pageRow = new \Ease\TWB5\Row();
$columnI = $pageRow->addColumn('4');
$columnII = $pageRow->addColumn('4');
$columnIII = $pageRow->addColumn('4');
$oPage->addItem($pageRow);
if (!$success) {
$columnIII->addItem(new \Ease\TWB5\Badge( _('Tip')));
$columnIII->addItem(new \Ease\TWB5\Card(
_('Forgot your password? Enter your e-mail address you entered during the registration and we will send you a new one.'),
));
$titlerow = new \Ease\TWB5\Row();
$titlerow->addColumn(4, new \Ease\Html\ImgTag('img/keys.svg', _('Password'), ['style' => 'height: 40px;']));
$titlerow->addColumn(8, new \Ease\Html\H3Tag(_('Password Recovery')));
$loginPanel = new \Ease\TWB5\Panel(
new \Ease\TWB5\Container($titlerow),
'success',
null,
new \Ease\TWB5\SubmitButton(_('Sent New Password'), 'success'),
);
$loginPanel->addItem(new \Ease\TWB5\FormGroup(
_('Email'),
new \Ease\Html\InputTextTag(
'Email',
$emailTo,
['type' => 'email'],
),
));
$loginPanel->body->setTagProperties(['style' => 'margin: 20px']);
$mailForm = $columnII->addItem(new \Ease\TWB5\Form(['name' => 'PasswordRecovery']));
$mailForm->addItem($loginPanel);
if ($oPage->isPosted()) {
$mailForm->fillUp($_POST);
}
} else {
$columnII->addItem(new \Ease\TWB5\LinkButton(
'login.php',
_('Continue'),
));
$oPage->redirect('login.php');
}
$oPage->addItem(new PageBottom());
$oPage->draw();