';
+ }
+ else
+ echo 'Account of this character has no recovery key!';
+}
+else {
+ echo 'Player or account of player ' . htmlspecialchars($nick) . ' doesn\'t exist.';
+}
+
+$twig->display('account.back_button.html.twig', [
+ 'new_line' => true,
+ 'center' => true,
+ 'action' => getLink('account/lost'),
+]);
diff --git a/system/pages/account/lost/step2.php b/system/pages/account/lost/step2.php
new file mode 100644
index 00000000..d9533031
--- /dev/null
+++ b/system/pages/account/lost/step2.php
@@ -0,0 +1,37 @@
+find($nick);
+if($player->isLoaded()) {
+ $account = $player->getAccount();
+}
+
+if($account->isLoaded()) {
+ $accountKey = $account->getCustomField('key');
+ if(!empty($accountKey)) {
+ if($accountKey == $recKey) {
+ $twig->display('account.lost.step2.html.twig', [
+ 'nick' => $nick,
+ 'recKey' => $recKey,
+ ]);
+ }
+ else {
+ echo 'Wrong recovery key!';
+ }
+ }
+ else {
+ echo 'Account of this character has no recovery key!';
+ }
+}
+else
+ echo "Player or account of player " . htmlspecialchars($nick) . " doesn't exist.";
+
+$twig->display('account.back_button.html.twig', [
+ 'new_line' => true,
+ 'center' => true,
+ 'action' => getLink('account/lost') . '?action=step1&action_type=reckey&nick=' . urlencode($nick),
+]);
diff --git a/system/pages/account/lost/step3.php b/system/pages/account/lost/step3.php
new file mode 100644
index 00000000..44a69cec
--- /dev/null
+++ b/system/pages/account/lost/step3.php
@@ -0,0 +1,87 @@
+find($nick);
+if($player->isLoaded()) {
+ $account = $player->getAccount();
+}
+
+if($account->isLoaded())
+{
+ $accountKey = $account->getCustomField('key');
+ if(!empty($accountKey)) {
+ if($accountKey == $recKey) {
+ if(Validator::password($newPassword)) {
+ if(Validator::email($newEmail)) {
+ $account->setEMail($newEmail);
+
+ $tmp_new_pass = $newPassword;
+ if(USE_ACCOUNT_SALT)
+ {
+ $salt = generateRandomString(10, false, true, true);
+ $tmp_new_pass = $salt . $newPassword;
+ }
+
+ $account->setPassword(encrypt($tmp_new_pass));
+ $account->save();
+
+ if(USE_ACCOUNT_SALT) {
+ $account->setCustomField('salt', $salt);
+ }
+
+ $statusMsg = '';
+ if($account->getCustomField('email_next') < time()) {
+ $mailBody = $twig->render('mail.account.lost.new-email.html.twig', [
+ 'account' => $account,
+ 'newPassword' => $newPassword,
+ 'newEmail' => $newEmail,
+ ]);
+
+ if(_mail($account->getCustomField('email'), $config['lua']['serverName']." - New password to your account", $mailBody)) {
+ $statusMsg = ' Sent e-mail with your account name and password to new e-mail. You should receive this e-mail in 15 minutes. You can login now with new password!';
+ }
+ else {
+ $statusMsg = '
An error occurred while sending email! You will not receive e-mail with this informations. For Admin: More info can be found in system/logs/mailer-error.log
';
+ }
+ }
+ else {
+ $statusMsg = ' You will not receive e-mail with this informations.';
+ }
+
+ $twig->display('account.lost.finish.new-email.html.twig', [
+ 'statusMsg' => $statusMsg,
+ 'account' => $account,
+ 'newPassword' => $newPassword,
+ 'newEmail' => $newEmail,
+ ]);
+ }
+ else {
+ echo Validator::getLastError();
+ }
+ }
+ else {
+ echo Validator::getLastError();
+ }
+ }
+ else {
+ echo 'Wrong recovery key!';
+ }
+ }
+ else {
+ echo 'Account of this character has no recovery key!';
+ }
+}
+else {
+ echo "Player or account of player " . htmlspecialchars($nick) . " doesn't exist.";
+}
+
+$twig->display('account.back_button.html.twig', [
+ 'new_line' => true,
+ 'center' => true,
+ 'action' => getLink('account/lost') . '?action=step1&action_type=reckey&nick=' . urlencode($nick),
+]);
diff --git a/system/templates/account.back_button.html.twig b/system/templates/account.back_button.html.twig
index e2d784ca..90d92aa3 100644
--- a/system/templates/account.back_button.html.twig
+++ b/system/templates/account.back_button.html.twig
@@ -1,7 +1,26 @@
{% if new_line is defined and new_line %}
{% endif %}
-
+{% endif %}
diff --git a/system/templates/account.lost.check-code.html.twig b/system/templates/account.lost.check-code.html.twig
new file mode 100644
index 00000000..1ee60406
--- /dev/null
+++ b/system/templates/account.lost.check-code.html.twig
@@ -0,0 +1,24 @@
+Please enter code from e-mail and name of one character from account. Then press Submit.
+
+
+
+
+ Code & character name
+
+
+
+
+ Your code:
+ Character:
+
+
+
+
+
+
+
+ {{ include('buttons.submit.html.twig') }}
+
+
+
+
diff --git a/system/templates/account.lost.finish.new-email.html.twig b/system/templates/account.lost.finish.new-email.html.twig
new file mode 100644
index 00000000..4fd6d3d6
--- /dev/null
+++ b/system/templates/account.lost.finish.new-email.html.twig
@@ -0,0 +1,26 @@
+Your account name, new password and new e-mail.
+
+
+
+ Your account name, new password and new e-mail
+
diff --git a/system/templates/account.lost.finish.new-password.html.twig b/system/templates/account.lost.finish.new-password.html.twig
new file mode 100644
index 00000000..72af2fe5
--- /dev/null
+++ b/system/templates/account.lost.finish.new-password.html.twig
@@ -0,0 +1,23 @@
+New password to your account is below. Now you can login.
+
+
+
Changed password
+
+
+
+ New password: {{ newPassword }}
+ Account name: (Already on your e-mail)
+ {{ statusMsg|raw }}
+
+
+
+
+
+
+
+
+ {{ include('buttons.submit.html.twig') }}
+
+
+
+
diff --git a/system/templates/account.lost.step1-email.html.twig b/system/templates/account.lost.step1-email.html.twig
new file mode 100644
index 00000000..c51510df
--- /dev/null
+++ b/system/templates/account.lost.step1-email.html.twig
@@ -0,0 +1,23 @@
+Please enter e-mail to account with this character.
+
+
+
+
+
Please enter e-mail to account
+
+
+
+ Character:
+ E-mail to account:
+
+
+
+
+
+
+
+ {{ include('buttons.submit.html.twig') }}
+
+
+
+
diff --git a/system/templates/account.lost.step2.html.twig b/system/templates/account.lost.step2.html.twig
new file mode 100644
index 00000000..2849fae2
--- /dev/null
+++ b/system/templates/account.lost.step2.html.twig
@@ -0,0 +1,27 @@
+Set new password and e-mail to your account.
+
+
+
+
+
+ Please enter new password and e-mail
+
+
+
+
+ Account of character:
+ New password:
+ Repeat new password:
+ New e-mail address:
+
+
+
+
+
+
+
+ {{ include('buttons.submit.html.twig') }}
+
+
+
+
diff --git a/system/templates/mail.account.lost.code.html.twig b/system/templates/mail.account.lost.code.html.twig
new file mode 100644
index 00000000..cf0f1fd3
--- /dev/null
+++ b/system/templates/mail.account.lost.code.html.twig
@@ -0,0 +1,10 @@
+You asked to reset your {{ config('lua')['serverName'] }} password.
+
or open page: {{ getLink('account/lost') }}?action=check-code and in field "code" write {{ newCode }}
+
+
If you did not request a password change, you may ignore this message and your password will remain unchanged.
diff --git a/system/templates/mail.account.lost.new-email.html.twig b/system/templates/mail.account.lost.new-email.html.twig
new file mode 100644
index 00000000..af22cc79
--- /dev/null
+++ b/system/templates/mail.account.lost.new-email.html.twig
@@ -0,0 +1,7 @@
+