diff --git a/system/pages/account/lost.php b/system/pages/account/lost.php index 42e23d38..c0dc5965 100644 --- a/system/pages/account/lost.php +++ b/system/pages/account/lost.php @@ -11,37 +11,9 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Lost Account Interface'; -if(!setting('core.mail_enabled')) -{ - echo 'Account maker is not configured to send e-mails, you can\'t use Lost Account Interface. Contact with admin to get help.'; +if(!setting('core.mail_enabled')) { + echo "Account maker is not configured to send e-mails, you can't use Lost Account Interface. Contact with admin to get help."; return; } -$action_type = $_REQUEST['action_type'] ?? ''; -if($action == '') { - $twig->display('account.lost.form.html.twig'); -} -else if($action == 'step1' && $action_type == '') { - $twig->display('account.lost.noaction.html.twig'); -} -elseif($action == 'step1' && $action_type == 'email') { - require PAGES . 'account/lost/step1-email.php'; -} -elseif($action == 'send-code') { - require PAGES . 'account/lost/send-code.php'; -} -elseif($action == 'step1' && $action_type == 'reckey') { - require PAGES . 'account/lost/step1-reckey.php'; -} -elseif($action == 'step2') { - require PAGES . 'account/lost/step2.php'; -} -elseif($action == 'step3') { - require PAGES . 'account/lost/step3.php'; -} -elseif($action == 'check-code') { - require PAGES . 'account/lost/check-code.php'; -} -elseif($action == 'set-new-password') { - require PAGES . 'account/lost/set-new-password.php'; -} +$twig->display('account/lost/form.html.twig'); diff --git a/system/pages/account/lost/check-code.php b/system/pages/account/lost/check-code.php index 42c1ae1c..3500299b 100644 --- a/system/pages/account/lost/check-code.php +++ b/system/pages/account/lost/check-code.php @@ -1,9 +1,11 @@ display('account.lost.check-code.html.twig', [ + $twig->display('account/lost/check-code.html.twig', [ 'code' => $code, 'characters' => $character, ]); @@ -18,22 +20,10 @@ else if($account->isLoaded()) { if($account->getCustomField('email_code') == $code) { - echo ' - Please enter new password to your account and repeat to make sure you remember password.
-
- - - - - -
Passwords
- New password:      
- Repeat new password: 
-
-
-
- ' . $twig->render('buttons.submit.html.twig') . '
-
'; + $twig->display('account/lost/check-code.finish.html.twig', [ + 'character' => $character, + 'code' => $code, + ]); } else { $error = 'Wrong code to change password.'; @@ -51,7 +41,7 @@ if(!empty($error)) { echo '
'; - $twig->display('account.lost.check-code.html.twig', [ + $twig->display('account/lost/check-code.html.twig', [ ]); } diff --git a/system/pages/account/lost/send-code.php b/system/pages/account/lost/email/send-code.php similarity index 76% rename from system/pages/account/lost/send-code.php rename to system/pages/account/lost/email/send-code.php index b7d51298..fb1998dc 100644 --- a/system/pages/account/lost/send-code.php +++ b/system/pages/account/lost/email/send-code.php @@ -1,4 +1,5 @@ isLoaded()) { } } else { - $insec = (int)$account->getCustomField('email_next') - time(); - $minutesleft = floor($insec / 60); - $secondsleft = $insec - ($minutesleft * 60); - $timeleft = $minutesleft.' minutes '.$secondsleft.' seconds'; + $inSec = (int)$account->getCustomField('email_next') - time(); + $minutesLeft = floor($inSec / 60); + $secondsLeft = $inSec - ($minutesLeft * 60); + $timeLeft = $minutesLeft.' minutes '.$secondsLeft.' seconds'; - echo 'Account of selected character (' . htmlspecialchars($nick) . ') received e-mail in last '.ceil(setting('core.mail_lost_account_interval') / 60) . ' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.'; + $timeRounded = ceil(setting('core.mail_lost_account_interval') / 60); + + echo "Account of selected character (" . escapeHtml($nick) . ") received e-mail in last $timeRounded minutes. You must wait $timeLeft before you can use Lost Account Interface again."; } } else { diff --git a/system/pages/account/lost/set-new-password.php b/system/pages/account/lost/email/set-new-password.php similarity index 76% rename from system/pages/account/lost/set-new-password.php rename to system/pages/account/lost/email/set-new-password.php index 2fabe078..8762035c 100644 --- a/system/pages/account/lost/set-new-password.php +++ b/system/pages/account/lost/email/set-new-password.php @@ -1,4 +1,6 @@ display('account.back_button.html.twig', [ 'new_line' => true, 'center' => true, - 'action' => getLink('account/lost') . '?action=check-code', + 'action' => getLink('account/lost/check-code') ]); } else @@ -21,15 +23,11 @@ else $account = $player->getAccount(); } - if($account->isLoaded()) - { - if($account->getCustomField('email_code') == $code) - { - if(Validator::password($newPassword)) - { + if($account->isLoaded()) { + if($account->getCustomField('email_code') == $code) { + if(Validator::password($newPassword)) { $tmp_new_pass = $newPassword; - if(USE_ACCOUNT_SALT) - { + if(USE_ACCOUNT_SALT) { $salt = generateRandomString(10, false, true, true); $tmp_new_pass = $salt . $newPassword; $account->setCustomField('salt', $salt); @@ -52,19 +50,22 @@ else $statusMsg = '

New password work! An error occurred while sending email! You will not receive e-mail with new password. For Admin: More info can be found in system/logs/mailer-error.log'; } - $twig->display('account.lost.finish.new-password.html.twig', [ + $twig->display('account/lost/finish.new-password.html.twig', [ 'statusMsg' => $statusMsg, 'newPassword' => $newPassword, ]); } - else - $error= Validator::getLastError(); + else { + $error = Validator::getLastError(); + } + } + else { + $error = 'Wrong code to change password.'; } - else - $error= 'Wrong code to change password.'; } - else - $error = 'Account of this character or this character doesn\'t exist.'; + else { + $error = "Account of this character or this character doesn't exist."; + } } if(!empty($error)) { @@ -74,7 +75,7 @@ if(!empty($error)) { echo '
'; - $twig->display('account.lost.check-code.html.twig', [ + $twig->display('account/lost/check-code.html.twig', [ 'code' => $code, 'character' => $character, ]); diff --git a/system/pages/account/lost/email/step-1.php b/system/pages/account/lost/email/step-1.php new file mode 100644 index 00000000..f2796eb1 --- /dev/null +++ b/system/pages/account/lost/email/step-1.php @@ -0,0 +1,28 @@ +isLoaded()) { + if($account->getCustomField('email_next') < time()) { + $twig->display('account/lost/email.html.twig', [ + 'nick' => $nick, + ]); + } + else { + $inSec = (int)$account->getCustomField('email_next') - time(); + $minutesLeft = floor($inSec / 60); + $secondsLeft = $inSec - ($minutesLeft * 60); + $timeLeft = $minutesLeft.' minutes '.$secondsLeft.' seconds'; + + $timeRounded = ceil(setting('core.mail_lost_account_interval') / 60); + + echo "Account of selected character (" . escapeHtml($nick) . ") received e-mail in last $timeRounded minutes. You must wait $timeLeft before you can use Lost Account Interface again."; + } +} +else { + echo "Player or account of player " . escapeHtml($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/recovery-key/step-1.php b/system/pages/account/lost/recovery-key/step-1.php new file mode 100644 index 00000000..c1da7f63 --- /dev/null +++ b/system/pages/account/lost/recovery-key/step-1.php @@ -0,0 +1,24 @@ +isLoaded()) { + $account_key = $account->getCustomField('key'); + + if(!empty($account_key)) { + $twig->display('account/lost/recovery-key.html.twig', [ + 'nick' => $nick, + ]); + } + else { + echo 'Account of this character has no recovery key!'; + } +} +else { + echo "Player or account of player " . escapeHtml($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/recovery-key/step-2.php similarity index 79% rename from system/pages/account/lost/step2.php rename to system/pages/account/lost/recovery-key/step-2.php index d9533031..523e1b28 100644 --- a/system/pages/account/lost/step2.php +++ b/system/pages/account/lost/recovery-key/step-2.php @@ -1,4 +1,5 @@ isLoaded()) { $accountKey = $account->getCustomField('key'); if(!empty($accountKey)) { if($accountKey == $recKey) { - $twig->display('account.lost.step2.html.twig', [ + $twig->display('account/lost/step2.html.twig', [ 'nick' => $nick, 'recKey' => $recKey, ]); @@ -28,7 +29,7 @@ if($account->isLoaded()) { } } else - echo "Player or account of player " . htmlspecialchars($nick) . " doesn't exist."; + echo "Player or account of player " . escapeHtml($nick) . " doesn't exist."; $twig->display('account.back_button.html.twig', [ 'new_line' => true, diff --git a/system/pages/account/lost/step3.php b/system/pages/account/lost/recovery-key/step-3.php similarity index 91% rename from system/pages/account/lost/step3.php rename to system/pages/account/lost/recovery-key/step-3.php index 44a69cec..27a2e799 100644 --- a/system/pages/account/lost/step3.php +++ b/system/pages/account/lost/recovery-key/step-3.php @@ -1,4 +1,6 @@ isLoaded()) { $account = $player->getAccount(); } -if($account->isLoaded()) -{ +if($account->isLoaded()) { $accountKey = $account->getCustomField('key'); + if(!empty($accountKey)) { if($accountKey == $recKey) { if(Validator::password($newPassword)) { @@ -53,7 +55,7 @@ if($account->isLoaded()) $statusMsg = '
You will not receive e-mail with this informations.'; } - $twig->display('account.lost.finish.new-email.html.twig', [ + $twig->display('account/lost/finish.new-email.html.twig', [ 'statusMsg' => $statusMsg, 'account' => $account, 'newPassword' => $newPassword, @@ -77,7 +79,7 @@ if($account->isLoaded()) } } else { - echo "Player or account of player " . htmlspecialchars($nick) . " doesn't exist."; + echo "Player or account of player " . escapeHtml($nick) . " doesn't exist."; } $twig->display('account.back_button.html.twig', [ diff --git a/system/pages/account/lost/step-1.php b/system/pages/account/lost/step-1.php new file mode 100644 index 00000000..fe8c0008 --- /dev/null +++ b/system/pages/account/lost/step-1.php @@ -0,0 +1,22 @@ +find($nick); +if($player->isLoaded()) { + $account = $player->getAccount(); +} + +if (ACTION == 'email') { + require __DIR__ . '/email/step-1.php'; +} +else if (ACTION == 'recovery-key') { + require __DIR__ . '/recovery-key/step-1.php'; +} +else { + $twig->display('account/lost/no-action.html.twig'); +} + diff --git a/system/pages/account/lost/step1-email.php b/system/pages/account/lost/step1-email.php deleted file mode 100644 index 596b6b52..00000000 --- a/system/pages/account/lost/step1-email.php +++ /dev/null @@ -1,36 +0,0 @@ -find($nick); -if($player->isLoaded()) { - $account = $player->getAccount(); -} - -if($account->isLoaded()) { - if($account->getCustomField('email_next') < time()) { - $twig->display('account.lost.step1-email.html.twig', [ - 'nick' => $nick, - ]); - } - else - { - $insec = (int)$account->getCustomField('email_next') - time(); - $minutesleft = floor($insec / 60); - $secondsleft = $insec - ($minutesleft * 60); - $timeleft = $minutesleft.' minutes '.$secondsleft.' seconds'; - - echo 'Account of selected character ('.$nick.') received e-mail in last '.ceil(setting('core.mail_lost_account_interval') / 60).' minutes. You must wait '.$timeleft.' before you can use Lost Account Interface again.'; - } -} -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/step1-reckey.php b/system/pages/account/lost/step1-reckey.php deleted file mode 100644 index 66a78e5c..00000000 --- a/system/pages/account/lost/step1-reckey.php +++ /dev/null @@ -1,39 +0,0 @@ -find($nick); -if($player->isLoaded()) - $account = $player->getAccount(); -if($account->isLoaded()) -{ - $account_key = $account->getCustomField('key'); - if(!empty($account_key)) - { - echo 'If you enter right recovery key you will see form to set new e-mail and password to account. To this e-mail will be send your new password and account name.
-

- - - -
Please enter your recovery key
- Character name: 
- Recovery key:    
-
-
-
- ' . $twig->render('buttons.submit.html.twig') . '
-
'; - } - 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/templates/account.lost.finish.new-password.html.twig b/system/templates/account.lost.finish.new-password.html.twig deleted file mode 100644 index 72af2fe5..00000000 --- a/system/templates/account.lost.finish.new-password.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -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.form.html.twig b/system/templates/account.lost.form.html.twig deleted file mode 100644 index fd3c1312..00000000 --- a/system/templates/account.lost.form.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -The Lost Account Interface can help you to get back your account name and password. Please enter your character name and select what you want to do.
-
- {{ csrf() }} - - - - - - - - -
Please enter your character name
-
-
- - - - - - - -
What do you want?
- -
- -
-
-
- - - - -
- {{ include('buttons.submit.html.twig') }} -
-
diff --git a/system/templates/account.lost.noaction.html.twig b/system/templates/account.lost.noaction.html.twig deleted file mode 100644 index c74ca45b..00000000 --- a/system/templates/account.lost.noaction.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -Please select action.
- - - - -
- - {{ include('buttons.back.html.twig') }} - -
\ No newline at end of file diff --git a/system/templates/account.lost.step1-email.html.twig b/system/templates/account.lost.step1-email.html.twig deleted file mode 100644 index c51510df..00000000 --- a/system/templates/account.lost.step1-email.html.twig +++ /dev/null @@ -1,23 +0,0 @@ -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/check-code.finish.html.twig b/system/templates/account/lost/check-code.finish.html.twig new file mode 100644 index 00000000..8541deda --- /dev/null +++ b/system/templates/account/lost/check-code.finish.html.twig @@ -0,0 +1,26 @@ +Please enter new password to your account and repeat to make sure you remember password.
+
+ + + + + + + + +
Passwords
+ New password:      
+ Repeat new password: 
+
+
+ + + + +
+
+ {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %} +
+
+
diff --git a/system/templates/account.lost.check-code.html.twig b/system/templates/account/lost/check-code.html.twig similarity index 53% rename from system/templates/account.lost.check-code.html.twig rename to system/templates/account/lost/check-code.html.twig index 1ee60406..f688ad61 100644 --- a/system/templates/account.lost.check-code.html.twig +++ b/system/templates/account/lost/check-code.html.twig @@ -1,23 +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') }} + {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %}
diff --git a/system/templates/account/lost/email.html.twig b/system/templates/account/lost/email.html.twig new file mode 100644 index 00000000..d02c5be8 --- /dev/null +++ b/system/templates/account/lost/email.html.twig @@ -0,0 +1,26 @@ +Please enter e-mail to account with this character.
+ + + + + + + + + +
Please enter e-mail to account
+ Character:
+ E-mail to account:
+
+
+ + + + +
+
+ {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %} +
+
+
diff --git a/system/templates/account.lost.finish.new-email.html.twig b/system/templates/account/lost/finish.new-email.html.twig similarity index 71% rename from system/templates/account.lost.finish.new-email.html.twig rename to system/templates/account/lost/finish.new-email.html.twig index 4fd6d3d6..6e33b852 100644 --- a/system/templates/account.lost.finish.new-email.html.twig +++ b/system/templates/account/lost/finish.new-email.html.twig @@ -1,12 +1,12 @@ Your account name, new password and new e-mail.
- +
- -
+ Your account name, new password and new e-mail
+ Account name:     {{ account.getName() }}
New password:        {{ newPassword }}
New e-mail address: {{ newEmail }}
@@ -15,7 +15,7 @@ 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..64efd811 --- /dev/null +++ b/system/templates/account/lost/finish.new-password.html.twig @@ -0,0 +1,24 @@ +New password to your account is below. Now you can log in.
+ + + + + + + +
Changed password
+ New password: {{ newPassword }}
+ Account name:   (Already on your e-mail)
+ {{ statusMsg|raw }} +
+
+ + + + +
+ + {% set button_name = 'Login' %} + {% include('buttons.base.html.twig') %} + +
diff --git a/system/templates/account/lost/form.html.twig b/system/templates/account/lost/form.html.twig new file mode 100644 index 00000000..4c907c0e --- /dev/null +++ b/system/templates/account/lost/form.html.twig @@ -0,0 +1,37 @@ +The Lost Account Interface can help you to get back your account name and password. Please enter your character name and select what you want to do.
+
+ {{ csrf() }} + + + + + + + + +
Please enter your character name
+
+
+ + + + + + + +
What do you want?
+ +
+ +
+
+
+ + + + +
+ {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %} +
+
diff --git a/system/templates/account/lost/no-action.html.twig b/system/templates/account/lost/no-action.html.twig new file mode 100644 index 00000000..84b97e82 --- /dev/null +++ b/system/templates/account/lost/no-action.html.twig @@ -0,0 +1,10 @@ +Please select action.
+ + + + +
+ + {{ include('buttons.back.html.twig') }} + +
diff --git a/system/templates/account/lost/recovery-key.html.twig b/system/templates/account/lost/recovery-key.html.twig new file mode 100644 index 00000000..a2232d46 --- /dev/null +++ b/system/templates/account/lost/recovery-key.html.twig @@ -0,0 +1,27 @@ +If you enter right recovery key you will see form to set new e-mail and password to account. To this e-mail will be send your new password and account name.
+
+ + + + + + + +
+ Please enter your recovery key +
+ Character name: 
+ Recovery key:    
+
+
+ + + + +
+
+ {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %} +
+
+
diff --git a/system/templates/account.lost.step2.html.twig b/system/templates/account/lost/step2.html.twig similarity index 63% rename from system/templates/account.lost.step2.html.twig rename to system/templates/account/lost/step2.html.twig index 2849fae2..f2e2380e 100644 --- a/system/templates/account.lost.step2.html.twig +++ b/system/templates/account/lost/step2.html.twig @@ -1,26 +1,28 @@ 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') }} + {% set button_name = 'Submit' %} + {% include('buttons.base.html.twig') %}
diff --git a/system/templates/mail.account.lost.code.html.twig b/system/templates/mail.account.lost.code.html.twig index cf0f1fd3..fa476405 100644 --- a/system/templates/mail.account.lost.code.html.twig +++ b/system/templates/mail.account.lost.code.html.twig @@ -3,8 +3,8 @@ You asked to reset your {{ config('lua')['serverName'] }} password.

To do so, please click this link:

- {{ getLink('account/lost') }}?action=check-code&code={{ newCode }}&character={{ nick|urlencode }} + {{ getLink('account/lost/check-code') }}?code={{ newCode }}&character={{ nick|urlencode }}

-

or open page: {{ getLink('account/lost') }}?action=check-code and in field "code" write {{ newCode }}

+

or open page: {{ getLink('account/lost/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-password.html.twig b/system/templates/mail.account.lost.new-password.html.twig index 17eca26d..bffb9ca5 100644 --- a/system/templates/mail.account.lost.new-password.html.twig +++ b/system/templates/mail.account.lost.new-password.html.twig @@ -1,5 +1,5 @@

Your account name and password!

-

Changed password to your account in Lost Account Interface on server config('lua')['serverName'] }}

+

Changed password to your account in Lost Account Interface on server {{ config('lua')['serverName'] }}

Account name: {{ account.getName() }}

New password: {{ newPassword }}