Skip to content

Commit

Permalink
Refactor account routes into sub folders
Browse files Browse the repository at this point in the history
  • Loading branch information
slawkens committed Jun 13, 2024
1 parent c7a6a53 commit bdc0c43
Show file tree
Hide file tree
Showing 24 changed files with 64 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
$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
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
$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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$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
{
Expand Down Expand Up @@ -52,7 +52,7 @@
$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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
defined('MYAAC') or die('Direct access not allowed!');

$title = 'Change Comment';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';

if(!$logged) {
return;
Expand Down Expand Up @@ -68,7 +68,7 @@
}

if(isset($player) && $player) {
$twig->display('account.change_comment.html.twig', array(
$twig->display('account.characters.change-comment.html.twig', array(
'player' => $player->toArray()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,7 +109,7 @@
$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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,7 +88,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
defined('MYAAC') or die('Direct access not allowed!');

$title = 'Create Character';
require __DIR__ . '/base.php';
require PAGES . 'account/base.php';

if(!$logged) {
return;
Expand Down Expand Up @@ -43,7 +43,7 @@
}

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,5 +93,5 @@
$twig->display('error_box.html.twig', array('errors' => $errors));
}

$twig->display('account.delete_character.html.twig');
$twig->display('account.characters.delete.html.twig');
}
File renamed without changes.
2 changes: 1 addition & 1 deletion system/pages/account/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
$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)
Expand Down
2 changes: 1 addition & 1 deletion system/pages/account/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
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>';
}
Expand Down
File renamed without changes.
27 changes: 17 additions & 10 deletions system/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,7 @@
['*', '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'],
Expand Down Expand Up @@ -56,4 +47,20 @@
'/^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'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
24 changes: 12 additions & 12 deletions system/templates/account.management.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand Down Expand Up @@ -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') %}
Expand All @@ -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') %}
Expand Down Expand Up @@ -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') %}
Expand Down Expand Up @@ -183,23 +183,23 @@
<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>
<br/>
<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') %}
</form>
</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') %}
Expand All @@ -208,15 +208,15 @@
{% 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') %}
</form>
</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') %}
Expand Down
Loading

0 comments on commit bdc0c43

Please sign in to comment.