Refactor account routes into sub folders

This commit is contained in:
slawkens 2024-06-13 22:23:43 +02:00
parent c7a6a539a9
commit bdc0c43d3f
24 changed files with 64 additions and 57 deletions

View File

@ -57,14 +57,14 @@ if($email_new_time < 10) {
$twig->display('error_box.html.twig', array('errors' => $errors));
//show form
$twig->display('account.change_mail.html.twig', array(
$twig->display('account.change-email.html.twig', array(
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
));
}
}
else
{
$twig->display('account.change_mail.html.twig', array(
$twig->display('account.change-email.html.twig', array(
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
));
}

View File

@ -76,7 +76,7 @@ if($show_form) {
$countries[$code] = $country;
}
$twig->display('account.change_info.html.twig', array(
$twig->display('account.change-info.html.twig', array(
'countries' => $countries ?? [],
'account_rlname' => $account_rlname,
'account_location' => $account_location,

View File

@ -21,7 +21,7 @@ $new_password = $_POST['newpassword'] ?? NULL;
$new_password_confirm = $_POST['newpassword_confirm'] ?? NULL;
$old_password = $_POST['oldpassword'] ?? NULL;
if(empty($new_password) && empty($new_password_confirm) && empty($old_password)) {
$twig->display('account.change_password.html.twig');
$twig->display('account.change-password.html.twig');
}
else
{
@ -52,7 +52,7 @@ else
$twig->display('error_box.html.twig', array('errors' => $errors));
//show form
$twig->display('account.change_password.html.twig');
$twig->display('account.change-password.html.twig');
}
else {
$org_pass = $new_password;

View File

@ -14,7 +14,7 @@ use MyAAC\Models\Player;
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Change Comment';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';
if(!$logged) {
return;
@ -68,7 +68,7 @@ if($show_form) {
}
if(isset($player) && $player) {
$twig->display('account.change_comment.html.twig', array(
$twig->display('account.characters.change-comment.html.twig', array(
'player' => $player->toArray()
));
}

View File

@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Change Name';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';
if(!$logged) {
return;
@ -109,7 +109,7 @@ else
$twig->display('error_box.html.twig', array('errors' => $errors));
}
$twig->display('account.change_name.html.twig', array(
$twig->display('account.characters.change-name.html.twig', array(
'points' => $points,
'errors' => $errors
//'account_players' => $account_logged->getPlayersList()

View File

@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Change Sex';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';
if(!$logged) {
return;
@ -88,7 +88,7 @@ else
if(!empty($errors)) {
$twig->display('error_box.html.twig', array('errors' => $errors));
}
$twig->display('account.change_sex.html.twig', array(
$twig->display('account.characters.change-sex.html.twig', array(
'players' => $account_logged->getPlayersList(false),
'player_sex' => isset($player) ? $player->getSex() : -1,
'points' => $points

View File

@ -14,7 +14,7 @@ use MyAAC\CreateCharacter;
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Create Character';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';
if(!$logged) {
return;
@ -43,7 +43,7 @@ if(count($errors) > 0) {
}
if(!$character_created) {
$twig->display('account.create_character.html.twig', array(
$twig->display('account.characters.create.html.twig', array(
'name' => $character_name,
'sex' => $character_sex,
'vocation' => $character_vocation,

View File

@ -11,7 +11,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Delete Character';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';
if(!$logged) {
return;
@ -93,5 +93,5 @@ if($show_form) {
$twig->display('error_box.html.twig', array('errors' => $errors));
}
$twig->display('account.delete_character.html.twig');
$twig->display('account.characters.delete.html.twig');
}

View File

@ -227,7 +227,7 @@ if($save)
$hash = md5(generateRandomString(16, true, true) . $email);
$new_account->setCustomField('email_hash', $hash);
$verify_url = getLink('account/confirm_email/' . $hash);
$verify_url = getLink('account/confirm-email/' . $hash);
$body_html = $twig->render('mail.account.verify.html.twig', array(
'account' => $tmp_account,
'verify_url' => generateLink($verify_url, $verify_url, true)

View File

@ -52,7 +52,7 @@ if(empty($recovery_key))
else
{
if(setting('core.account_generate_new_reckey') && setting('core.mail_enabled'))
$account_registered = '<b><span style="color: green">Yes ( <a href="' . getLink('account/register/new') . '"> Buy new Recovery Key </a> )</span></b>';
$account_registered = '<b><span style="color: green">Yes ( <a href="' . getLink('account/register-new') . '"> Buy new Recovery Key </a> )</span></b>';
else
$account_registered = '<b><span style="color: green">Yes</span></b>';
}

View File

@ -19,16 +19,7 @@ return [
['*', 'forum/base', '404.php', 10],
['*', 'guilds/base', '404.php', 10],
[['GET', 'POST'], 'account/password', 'account/change_password.php'],
[['GET', 'POST'], 'account/register/new', 'account/register_new.php'],
[['GET', 'POST'], 'account/email', 'account/change_email.php'],
[['GET', 'POST'], 'account/info', 'account/change_info.php'],
[['GET', 'POST'], 'account/character/create', 'account/create_character.php'],
[['GET', 'POST'], 'account/character/name', 'account/change_name.php'],
[['GET', 'POST'], 'account/character/sex', 'account/change_sex.php'],
[['GET', 'POST'], 'account/character/delete', 'account/delete_character.php'],
[['GET', 'POST'], 'account/character/comment[/{name:string}]', 'account/change_comment.php'],
['GET', 'account/confirm_email/{hash:alphanum}', 'account/confirm_email.php'],
['GET', 'account/confirm-email/{hash:alphanum}', 'account/confirm-email.php'],
['GET', 'bans/{page:int}', 'bans.php'],
[['GET', 'POST'], 'characters[/{name:string}]', 'characters.php'],
@ -56,4 +47,20 @@ return [
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
'/^houses\/view\/?$/' => array('subtopic' => 'houses', 'page' => 'view')*/
/**
* Deprecated
* To be removed in next versions
* Kept just for compatibility
*/
[['GET', 'POST'], 'account/password', 'account/change-password.php'],
[['GET', 'POST'], 'account/register/new', 'account/register-new.php'],
[['GET', 'POST'], 'account/email', 'account/change-email.php'],
[['GET', 'POST'], 'account/info', 'account/change-info.php'],
[['GET', 'POST'], 'account/character/create', 'account/characters/create.php'],
[['GET', 'POST'], 'account/character/name', 'account/characters/change-name.php'],
[['GET', 'POST'], 'account/character/sex', 'account/characters/change-sex.php'],
[['GET', 'POST'], 'account/character/delete', 'account/characters/delete.php'],
[['GET', 'POST'], 'account/character/comment[/{name:string}]', 'account/characters/change-comment.php'],
['GET', 'account/confirm_email/{hash:alphanum}', 'account/confirm-email.php'],
];

View File

@ -29,7 +29,7 @@ Please enter your password and the new email address. Make sure that you enter a
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/email') }}" method="post">
<form id="form" action="{{ getLink('account/change-email') }}" method="post">
{{ csrf() }}
<input type="hidden" name="changeemailsave" value="1"/>
{{ include('buttons.submit.html.twig') }}

View File

@ -59,7 +59,7 @@ Here you can tell other players about yourself. This information will be display
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;" >
<form id="form" action="{{ getLink('account/info') }}" method="post">
<form id="form" action="{{ getLink('account/change-info') }}" method="post">
{{ csrf() }}
<input type="hidden" name="changeinfosave" value="1">
{{ include('buttons.submit.html.twig') }}

View File

@ -38,7 +38,7 @@ Please enter your current password and a new password. For your security, please
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/password') }}" method="post">
<form id="form" action="{{ getLink('account/change-password') }}" method="post">
{{ csrf() }}
{{ include('buttons.submit.html.twig') }}
</form>

View File

@ -1,6 +1,6 @@
Here you can see and edit the information about your character.<br/>
If you do not want to specify a certain field, just leave it blank.<br/><br/>
<form action="{{ getLink('account/character/comment') }}" method="post">
<form action="{{ getLink('account/characters/change-comment') }}" method="post">
{{ csrf() }}
<div class="TableContainer" >
<table class="Table5" cellpadding="0" cellspacing="0">

View File

@ -36,7 +36,7 @@ To change a name of character select player and choose a new name.<br/>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/character/name') }}" method="post">
<form id="form" action="{{ getLink('account/characters/change-name') }}" method="post">
{{ csrf() }}
<input type="hidden" name="changenamesave" value="1">
{{ include('buttons.submit.html.twig') }}

View File

@ -36,7 +36,7 @@ To change a sex of character select player and choose a new sex.<br/>
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/character/sex') }}" method="post">
<form id="form" action="{{ getLink('account/characters/change-sex') }}" method="post">
{{ csrf() }}
<input type="hidden" name="changesexsave" value="1"/>
{{ include('buttons.submit.html.twig') }}

View File

@ -142,7 +142,7 @@ In any case the name must not violate the naming conventions stated in the <a hr
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/character/create') }}" method="post">
<form id="form" action="{{ getLink('account/characters/create') }}" method="post">
{{ csrf() }}
<input type="hidden" name="save" value="1">
{{ include('buttons.submit.html.twig') }}

View File

@ -25,7 +25,7 @@ To delete a character enter the name of the character and your password.<br/><br
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/character/delete') }}" method="post">
<form id="form" action="{{ getLink('account/characters/delete') }}" method="post">
{{ csrf() }}
<input type="hidden" name="deletecharactersave" value="1"/>
{{ include('buttons.submit.html.twig') }}

View File

@ -19,7 +19,7 @@ To generate new recovery key for your account please enter your password.<br/>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
<form id="form" action="{{ getLink('account/register/new') }}" method="post">
<form id="form" action="{{ getLink('account/register-new') }}" method="post">
{{ csrf() }}
<input type="hidden" name="registeraccountsave" value="1">
{{ include('buttons.submit.html.twig') }}

View File

@ -26,8 +26,8 @@
}
</style>
{% set menus = {
'Create Character': 'account/character/create','Delete Character': 'account/character/delete',
'Change Info': 'account/info', 'Change Password': 'account/password', 'Change Email': 'account/email'
'Create Character': 'account/characters/create','Delete Character': 'account/characters/delete',
'Change Info': 'account/change-info', 'Change Password': 'account/change-password', 'Change Email': 'account/change-email'
} %}
<div id="account-manage">
<div id="one">
@ -40,10 +40,10 @@
<a href="{{ getLink(link) }}">{{ name }}</a>
{% endfor %}
{% if setting('core.account_change_character_name') %}
<a href="{{ getLink('account/character/name') }}">Change Name</a>
<a href="{{ getLink('account/characters/change-name') }}">Change Name</a>
{% endif %}
{% if setting('core.account_change_character_sex') %}
<a href="{{ getLink('account/character/sex') }}">Change Sex</a>
<a href="{{ getLink('account/characters/change-sex') }}">Change Sex</a>
{% endif %}
<a href="{{ getLink('account/logout') }}">Logout</a>
</div>
@ -80,7 +80,7 @@
<div style="text-align:center">
A request has been submitted to change the email address of this account to <b>{{ email_new }}</b>. After <b>{{ email_new_time|date("j F Y, G:i:s") }}</b> you can accept the new email address and finish the process. Please cancel the request if you do not want your email address to be changed! Also cancel the request if you have no access to the new email address!
<form action="{{ getLink('account/email') }}" method="post">
<form action="{{ getLink('account/change-email') }}" method="post">
{{ csrf() }}
{% set button_name = 'Edit' %}
{% include('buttons.base.html.twig') %}
@ -100,7 +100,7 @@
<tr style="background-color: {{ config.darkborder }};" >
<td style="width: 90px;">Email Address:</td>
<td>{{ account_email }}{{ email_change|raw }}
<form action="{{ getLink('account/email') }}" method="post">
<form action="{{ getLink('account/change-email') }}" method="post">
{{ csrf() }}
{% set button_name = 'Change Email' %}
{% include('buttons.base.html.twig') %}
@ -139,7 +139,7 @@
<td >{{ account_location }}</td>
</tr>
</table>
<form action="{{ getLink('account/info') }}" method="post">
<form action="{{ getLink('account/change-info') }}" method="post">
{{ csrf() }}
{% set button_name = 'Change Info' %}
{% include('buttons.base.html.twig') %}
@ -183,7 +183,7 @@
<td>{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %}</td>
<td>{% if player.isOnline() %}<span style="color: green">ONLINE</span>{% else %}<span style="color: red">Offline</span>{% endif %}</td>
<td>{% if player.isHidden() %}Hidden{% else %}Visible{% endif %}</td>
<td>{% if not player.isDeleted() %}[<a href="{{ getLink('account/character/comment/' ~ player.getName|urlencode) }}" >Edit</a>]{% endif %}</td>
<td>{% if not player.isDeleted() %}[<a href="{{ getLink('account/characters/change-comment?name=' ~ player.getName()|urlencode) }}" >Edit</a>]{% endif %}</td>
</tr>
{% endfor %}
</table>
@ -191,7 +191,7 @@
<table>
<tr>
<td>
<form action="{{ getLink('account/character/create') }}" method="post" >
<form action="{{ getLink('account/characters/create') }}" method="post" >
{{ csrf() }}
{% set button_name = 'Create Character' %}
{% include('buttons.base.html.twig') %}
@ -199,7 +199,7 @@
</td>
{% if setting('core.account_change_character_name') %}
<td>
<form action="{{ getLink('account/character/name') }}" method="post" >
<form action="{{ getLink('account/characters/change-name') }}" method="post" >
{{ csrf() }}
{% set button_name = 'Change Name' %}
{% include('buttons.base.html.twig') %}
@ -208,7 +208,7 @@
{% endif %}
{% if setting('core.account_change_character_sex') %}
<td>
<form action="{{ getLink('account/character/sex') }}" method="post" >
<form action="{{ getLink('account/characters/change-sex') }}" method="post" >
{{ csrf() }}
{% set button_name = 'Change Sex' %}
{% include('buttons.base.html.twig') %}
@ -216,7 +216,7 @@
</td>
{% endif %}
<td>
<form action="{{ getLink('account/character/delete') }}" method="post">
<form action="{{ getLink('account/characters/delete') }}" method="post">
{{ csrf() }}
{% set button_name = 'Delete Character' %}
{% include('buttons.base.html.twig') %}

View File

@ -94,7 +94,7 @@
</table>
<div style="text-align:center">
<table border="0" cellspacing="0" cellpadding="0">
<form action="{{ getLink('account/email') }}" method="post">
<form action="{{ getLink('account/change-email') }}" method="post">
<tr>
<td style="border:0px;">
{{ include('buttons.edit.html.twig') }}
@ -176,7 +176,7 @@
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<form action="{{ getLink('account/password') }}" method="post">
<form action="{{ getLink('account/change-password') }}" method="post">
<tr>
<td style="border:0px;" >
{{ include('buttons.change_password.html.twig') }}
@ -187,7 +187,7 @@
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<form action="{{ getLink('account/email') }}" method="post">
<form action="{{ getLink('account/change-email') }}" method="post">
<tr>
<td style="border:0px;">
<input type="hidden" name="newemail" value=""/>
@ -256,7 +256,7 @@
</td>
<td align=right>
<table border="0" cellspacing="0" cellpadding="0">
<form action="{{ getLink('account/info') }}" method="post">
<form action="{{ getLink('account/change-info') }}" method="post">
<tr>
<td style="border:0px;">
{{ include('buttons.edit.html.twig') }}
@ -373,7 +373,7 @@
{% else %}
<td><span style="color: red"><b>Offline</b></span></td>
{% endif %}
<td>{% if not player.isDeleted() %}[<a href="{{ getLink('account/character/comment/' ~ player.getName|urlencode) }}" >Edit</a>]{% endif %}</td>
<td>{% if not player.isDeleted() %}[<a href="{{ getLink('account/characters/change-comment?name=' ~ player.getName|urlencode) }}" >Edit</a>]{% endif %}</td>
</tr>
{% endfor %}
</table>
@ -395,7 +395,7 @@
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;">
<form action="{{ getLink('account/character/create') }}" method="post" >
<form action="{{ getLink('account/characters/create') }}" method="post" >
{{ include('buttons.create_character.html.twig') }}
</form>
</td>
@ -407,7 +407,7 @@
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;">
<form action="{{ getLink('account/character/name') }}" method="post" >
<form action="{{ getLink('account/characters/change-name') }}" method="post" >
{{ include('buttons.change_name.html.twig') }}
</form>
</td>
@ -420,7 +420,7 @@
<table border="0" cellspacing="0" cellpadding="0" >
<tr>
<td style="border:0px;">
<form action="{{ getLink('account/character/sex') }}" method="post">
<form action="{{ getLink('account/characters/change-sex') }}" method="post">
{{ include('buttons.change_sex.html.twig') }}
</form>
</td>
@ -433,7 +433,7 @@
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border: 0px;">
<form action="{{ getLink('account/character/delete') }}" method="post">
<form action="{{ getLink('account/characters/delete') }}" method="post">
{{ include('buttons.delete_character.html.twig') }}
</form>
</td>