From bdc0c43d3fd3a51030c3e916bdb9f008468f5ecd Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 13 Jun 2024 22:23:43 +0200 Subject: [PATCH] Refactor account routes into sub folders --- .../{change_email.php => change-email.php} | 4 +-- .../{change_info.php => change-info.php} | 2 +- ...hange_password.php => change-password.php} | 4 +-- .../change-comment.php} | 4 +-- .../change-name.php} | 4 +-- .../change-sex.php} | 4 +-- .../create.php} | 4 +-- .../delete.php} | 4 +-- .../{confirm_email.php => confirm-email.php} | 0 system/pages/account/create.php | 2 +- system/pages/account/manage.php | 2 +- .../{register_new.php => register-new.php} | 0 system/routes.php | 27 ++++++++++++------- ...ml.twig => account.change-email.html.twig} | 2 +- ...tml.twig => account.change-info.html.twig} | 2 +- ...twig => account.change-password.html.twig} | 2 +- ...count.characters.change-comment.html.twig} | 2 +- ... account.characters.change-name.html.twig} | 2 +- ...> account.characters.change-sex.html.twig} | 2 +- ...ig => account.characters.create.html.twig} | 2 +- ...ig => account.characters.delete.html.twig} | 2 +- ...ccount.generate_new_recovery_key.html.twig | 2 +- system/templates/account.management.html.twig | 24 ++++++++--------- .../tibiacom/account.management.html.twig | 18 ++++++------- 24 files changed, 64 insertions(+), 57 deletions(-) rename system/pages/account/{change_email.php => change-email.php} (97%) rename system/pages/account/{change_info.php => change-info.php} (97%) rename system/pages/account/{change_password.php => change-password.php} (96%) rename system/pages/account/{change_comment.php => characters/change-comment.php} (94%) rename system/pages/account/{change_name.php => characters/change-name.php} (97%) rename system/pages/account/{change_sex.php => characters/change-sex.php} (96%) rename system/pages/account/{create_character.php => characters/create.php} (93%) rename system/pages/account/{delete_character.php => characters/delete.php} (96%) rename system/pages/account/{confirm_email.php => confirm-email.php} (100%) rename system/pages/account/{register_new.php => register-new.php} (100%) rename system/templates/{account.change_mail.html.twig => account.change-email.html.twig} (94%) rename system/templates/{account.change_info.html.twig => account.change-info.html.twig} (96%) rename system/templates/{account.change_password.html.twig => account.change-password.html.twig} (94%) rename system/templates/{account.change_comment.html.twig => account.characters.change-comment.html.twig} (98%) rename system/templates/{account.change_name.html.twig => account.characters.change-name.html.twig} (95%) rename system/templates/{account.change_sex.html.twig => account.characters.change-sex.html.twig} (94%) rename system/templates/{account.create_character.html.twig => account.characters.create.html.twig} (98%) rename system/templates/{account.delete_character.html.twig => account.characters.delete.html.twig} (93%) diff --git a/system/pages/account/change_email.php b/system/pages/account/change-email.php similarity index 97% rename from system/pages/account/change_email.php rename to system/pages/account/change-email.php index 954d596b3d..c97b554197 100644 --- a/system/pages/account/change_email.php +++ b/system/pages/account/change-email.php @@ -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 )); } diff --git a/system/pages/account/change_info.php b/system/pages/account/change-info.php similarity index 97% rename from system/pages/account/change_info.php rename to system/pages/account/change-info.php index 2b7234b51d..709dce27a7 100644 --- a/system/pages/account/change_info.php +++ b/system/pages/account/change-info.php @@ -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, diff --git a/system/pages/account/change_password.php b/system/pages/account/change-password.php similarity index 96% rename from system/pages/account/change_password.php rename to system/pages/account/change-password.php index 309c8dee13..bf172455e4 100644 --- a/system/pages/account/change_password.php +++ b/system/pages/account/change-password.php @@ -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 { @@ -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; diff --git a/system/pages/account/change_comment.php b/system/pages/account/characters/change-comment.php similarity index 94% rename from system/pages/account/change_comment.php rename to system/pages/account/characters/change-comment.php index e4fb6e428c..7fa10c6936 100644 --- a/system/pages/account/change_comment.php +++ b/system/pages/account/characters/change-comment.php @@ -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; @@ -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() )); } diff --git a/system/pages/account/change_name.php b/system/pages/account/characters/change-name.php similarity index 97% rename from system/pages/account/change_name.php rename to system/pages/account/characters/change-name.php index ef82b9add1..4a23131db8 100644 --- a/system/pages/account/change_name.php +++ b/system/pages/account/characters/change-name.php @@ -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 @@ $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() diff --git a/system/pages/account/change_sex.php b/system/pages/account/characters/change-sex.php similarity index 96% rename from system/pages/account/change_sex.php rename to system/pages/account/characters/change-sex.php index 7e43b6fffb..6c95a6e742 100644 --- a/system/pages/account/change_sex.php +++ b/system/pages/account/characters/change-sex.php @@ -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 @@ 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 diff --git a/system/pages/account/create_character.php b/system/pages/account/characters/create.php similarity index 93% rename from system/pages/account/create_character.php rename to system/pages/account/characters/create.php index e68c877351..5ad21dab74 100644 --- a/system/pages/account/create_character.php +++ b/system/pages/account/characters/create.php @@ -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; @@ -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, diff --git a/system/pages/account/delete_character.php b/system/pages/account/characters/delete.php similarity index 96% rename from system/pages/account/delete_character.php rename to system/pages/account/characters/delete.php index 7804f01de0..af32070b63 100644 --- a/system/pages/account/delete_character.php +++ b/system/pages/account/characters/delete.php @@ -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 @@ $twig->display('error_box.html.twig', array('errors' => $errors)); } - $twig->display('account.delete_character.html.twig'); + $twig->display('account.characters.delete.html.twig'); } diff --git a/system/pages/account/confirm_email.php b/system/pages/account/confirm-email.php similarity index 100% rename from system/pages/account/confirm_email.php rename to system/pages/account/confirm-email.php diff --git a/system/pages/account/create.php b/system/pages/account/create.php index 58e72356c1..34e4689d14 100644 --- a/system/pages/account/create.php +++ b/system/pages/account/create.php @@ -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) diff --git a/system/pages/account/manage.php b/system/pages/account/manage.php index e3003e25d1..eff71c7849 100644 --- a/system/pages/account/manage.php +++ b/system/pages/account/manage.php @@ -52,7 +52,7 @@ else { if(setting('core.account_generate_new_reckey') && setting('core.mail_enabled')) - $account_registered = 'Yes ( Buy new Recovery Key )'; + $account_registered = 'Yes ( Buy new Recovery Key )'; else $account_registered = 'Yes'; } diff --git a/system/pages/account/register_new.php b/system/pages/account/register-new.php similarity index 100% rename from system/pages/account/register_new.php rename to system/pages/account/register-new.php diff --git a/system/routes.php b/system/routes.php index 576c14b237..c49b16b1fc 100644 --- a/system/routes.php +++ b/system/routes.php @@ -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'], @@ -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'], ]; diff --git a/system/templates/account.change_mail.html.twig b/system/templates/account.change-email.html.twig similarity index 94% rename from system/templates/account.change_mail.html.twig rename to system/templates/account.change-email.html.twig index 83fe9ce30d..ea627cc744 100644 --- a/system/templates/account.change_mail.html.twig +++ b/system/templates/account.change-email.html.twig @@ -29,7 +29,7 @@ Please enter your password and the new email address. Make sure that you enter a
-
+ {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.change_info.html.twig b/system/templates/account.change-info.html.twig similarity index 96% rename from system/templates/account.change_info.html.twig rename to system/templates/account.change-info.html.twig index aa09798887..e34814727a 100644 --- a/system/templates/account.change_info.html.twig +++ b/system/templates/account.change-info.html.twig @@ -59,7 +59,7 @@ Here you can tell other players about yourself. This information will be display
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.change_password.html.twig b/system/templates/account.change-password.html.twig similarity index 94% rename from system/templates/account.change_password.html.twig rename to system/templates/account.change-password.html.twig index bfece75746..56e52c08f1 100644 --- a/system/templates/account.change_password.html.twig +++ b/system/templates/account.change-password.html.twig @@ -38,7 +38,7 @@ Please enter your current password and a new password. For your security, please
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.change_comment.html.twig b/system/templates/account.characters.change-comment.html.twig similarity index 98% rename from system/templates/account.change_comment.html.twig rename to system/templates/account.characters.change-comment.html.twig index 04e20c0bf6..8bb94c80d1 100644 --- a/system/templates/account.change_comment.html.twig +++ b/system/templates/account.characters.change-comment.html.twig @@ -1,6 +1,6 @@ Here you can see and edit the information about your character.
If you do not want to specify a certain field, just leave it blank.

-
+ {{ csrf() }}
diff --git a/system/templates/account.change_name.html.twig b/system/templates/account.characters.change-name.html.twig similarity index 95% rename from system/templates/account.change_name.html.twig rename to system/templates/account.characters.change-name.html.twig index e40ea6edd8..7c0d18f383 100644 --- a/system/templates/account.change_name.html.twig +++ b/system/templates/account.characters.change-name.html.twig @@ -36,7 +36,7 @@ To change a name of character select player and choose a new name.
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.change_sex.html.twig b/system/templates/account.characters.change-sex.html.twig similarity index 94% rename from system/templates/account.change_sex.html.twig rename to system/templates/account.characters.change-sex.html.twig index 244418cfbe..440fed9fca 100644 --- a/system/templates/account.change_sex.html.twig +++ b/system/templates/account.characters.change-sex.html.twig @@ -36,7 +36,7 @@ To change a sex of character select player and choose a new sex.
- + {% endfor %}
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.create_character.html.twig b/system/templates/account.characters.create.html.twig similarity index 98% rename from system/templates/account.create_character.html.twig rename to system/templates/account.characters.create.html.twig index 937f09a5e0..6e2b613d99 100644 --- a/system/templates/account.create_character.html.twig +++ b/system/templates/account.characters.create.html.twig @@ -142,7 +142,7 @@ In any case the name must not violate the naming conventions stated in the
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.delete_character.html.twig b/system/templates/account.characters.delete.html.twig similarity index 93% rename from system/templates/account.delete_character.html.twig rename to system/templates/account.characters.delete.html.twig index cc0ca0f5ef..8593f7ed40 100644 --- a/system/templates/account.delete_character.html.twig +++ b/system/templates/account.characters.delete.html.twig @@ -25,7 +25,7 @@ To delete a character enter the name of the character and your password.

- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.generate_new_recovery_key.html.twig b/system/templates/account.generate_new_recovery_key.html.twig index fc378d54db..fc48d3a92d 100644 --- a/system/templates/account.generate_new_recovery_key.html.twig +++ b/system/templates/account.generate_new_recovery_key.html.twig @@ -19,7 +19,7 @@ To generate new recovery key for your account please enter your password.
- + {{ csrf() }} {{ include('buttons.submit.html.twig') }} diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index 5819ed0d5b..db8c766fa4 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -26,8 +26,8 @@ } {% 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' } %}
@@ -40,10 +40,10 @@ {{ name }} {% endfor %} {% if setting('core.account_change_character_name') %} - Change Name + Change Name {% endif %} {% if setting('core.account_change_character_sex') %} - Change Sex + Change Sex {% endif %} Logout
@@ -80,7 +80,7 @@
A request has been submitted to change the email address of this account to {{ email_new }}. After {{ email_new_time|date("j F Y, G:i:s") }} 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! - + {{ csrf() }} {% set button_name = 'Edit' %} {% include('buttons.base.html.twig') %} @@ -100,7 +100,7 @@
Email Address: {{ account_email }}{{ email_change|raw }} - + {{ csrf() }} {% set button_name = 'Change Email' %} {% include('buttons.base.html.twig') %} @@ -139,7 +139,7 @@ {{ account_location }}
- + {{ csrf() }} {% set button_name = 'Change Info' %} {% include('buttons.base.html.twig') %} @@ -183,7 +183,7 @@
{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %} {% if player.isOnline() %}ONLINE{% else %}Offline{% endif %} {% if player.isHidden() %}Hidden{% else %}Visible{% endif %}{% if not player.isDeleted() %}[Edit]{% endif %}{% if not player.isDeleted() %}[Edit]{% endif %}
@@ -191,7 +191,7 @@ {% if setting('core.account_change_character_name') %} {% endif %}
- + {{ csrf() }} {% set button_name = 'Create Character' %} {% include('buttons.base.html.twig') %} @@ -199,7 +199,7 @@ - + {{ csrf() }} {% set button_name = 'Change Name' %} {% include('buttons.base.html.twig') %} @@ -208,7 +208,7 @@ {% endif %} {% if setting('core.account_change_character_sex') %} - + {{ csrf() }} {% set button_name = 'Change Sex' %} {% include('buttons.base.html.twig') %} @@ -216,7 +216,7 @@ - + {{ csrf() }} {% set button_name = 'Delete Character' %} {% include('buttons.base.html.twig') %} diff --git a/templates/tibiacom/account.management.html.twig b/templates/tibiacom/account.management.html.twig index 58f88e6533..773ce6c95b 100644 --- a/templates/tibiacom/account.management.html.twig +++ b/templates/tibiacom/account.management.html.twig @@ -94,7 +94,7 @@
- +
{{ include('buttons.edit.html.twig') }} @@ -176,7 +176,7 @@
- +
{{ include('buttons.change_password.html.twig') }} @@ -187,7 +187,7 @@ - +
@@ -256,7 +256,7 @@ - + {% endif %} - + {% endfor %}
{{ include('buttons.edit.html.twig') }} @@ -373,7 +373,7 @@ {% else %} Offline{% if not player.isDeleted() %}[Edit]{% endif %}{% if not player.isDeleted() %}[Edit]{% endif %}
@@ -395,7 +395,7 @@ @@ -407,7 +407,7 @@
- + {{ include('buttons.create_character.html.twig') }}
@@ -420,7 +420,7 @@
-
+ {{ include('buttons.change_name.html.twig') }}
@@ -433,7 +433,7 @@
-
+ {{ include('buttons.change_sex.html.twig') }}
-
+ {{ include('buttons.delete_character.html.twig') }}