From 2afe0c1185cba2a0f273a49b3a1ba19987686db1 Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 28 Mar 2024 21:25:43 +0100 Subject: [PATCH 01/96] Fill up the equipment variable no matter of config --- system/pages/characters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/pages/characters.php b/system/pages/characters.php index b2286db6..c38a289c 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -199,7 +199,7 @@ if($player->isLoaded() && !$player->isDeleted()) unset($storage); } - if($config['characters']['equipment'] && $db->hasTable('player_items') && $db->hasColumn('player_items', 'pid') && $db->hasColumn('player_items', 'sid') && $db->hasColumn('player_items', 'itemtype')) { + if($db->hasTable('player_items') && $db->hasColumn('player_items', 'pid') && $db->hasColumn('player_items', 'sid') && $db->hasColumn('player_items', 'itemtype')) { $eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)'); $equipment = array(); foreach($eq_sql as $eq) From 6d4724f4f4ccb595a88829c3412df058e739aefd Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 1 Apr 2024 21:54:53 +0200 Subject: [PATCH 02/96] Squashed commit of the following: commit da18629d1652c304a75b684939255a1838989279 Author: slawkens Date: Mon Apr 1 21:53:53 2024 +0200 Fixes to tables headline commit 41c3d9ad21304e99330ea42841b5932af792db92 Author: slawkens Date: Sun Mar 31 13:59:25 2024 +0200 [WIP] Tables headline --- .../templates/account.change_info.html.twig | 180 +++-- .../templates/account.change_mail.html.twig | 64 +- .../templates/account.change_name.html.twig | 133 ++-- .../account.change_password.html.twig | 136 ++-- system/templates/account.change_sex.html.twig | 135 ++-- .../account.create_character.html.twig | 266 ++++---- .../account.delete_character.html.twig | 110 ++- ...ccount.generate_new_recovery_key.html.twig | 101 ++- .../account.generate_recovery_key.html.twig | 57 +- system/templates/account.logout.html.twig | 38 +- .../guilds.change_description.html.twig | 38 +- system/templates/guilds.change_logo.html.twig | 34 +- system/templates/guilds.change_motd.html.twig | 27 +- .../templates/guilds.delete_guild.html.twig | 50 +- system/templates/guilds.list.html.twig | 198 +++--- system/templates/guilds.manager.html.twig | 71 +- .../guilds.pass_leadership.html.twig | 52 +- system/templates/guilds.view.html.twig | 397 +++++------ system/templates/houses.html.twig | 300 ++++----- system/templates/houses.view.html.twig | 73 +- system/templates/lastkills.html.twig | 119 ++-- system/templates/tables.headline.html.twig | 38 +- system/templates/team.html.twig | 348 +++++----- .../tibiacom/account.management.html.twig | 627 ++++++++---------- templates/tibiacom/tables.headline.html.twig | 24 + 25 files changed, 1606 insertions(+), 2010 deletions(-) create mode 100644 templates/tibiacom/tables.headline.html.twig diff --git a/system/templates/account.change_info.html.twig b/system/templates/account.change_info.html.twig index 067eabc5..aa097988 100644 --- a/system/templates/account.change_info.html.twig +++ b/system/templates/account.change_info.html.twig @@ -1,102 +1,84 @@ Here you can tell other players about yourself. This information will be displayed alongside the data of your characters. If you do not want to fill in a certain field, just leave it blank.

-
- {{ csrf() }} -
- -
-
- - - - -
Change Public Information
- - - - -
-
- - - -
-
- - - - - - - - - - {% if setting('core.account_country') %} - - - - - {% endif %} -
Real Name: - -
Location: - -
Country: - - - -
-
-
-
-
- - - + +
- - - + + {% endif %} +
+ $(function() { + updateFlag(); + $('#account_country').change(function() { + updateFlag(); + }); + }); + +
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+ + + - - -
+ + + - -
+ + {{ csrf() }} - {{ include('buttons.submit.html.twig') }} -
-
- - - - {{ csrf() }} - - - - -
- {{ include('buttons.back.html.twig') }} -
-
+ {{ include('buttons.submit.html.twig') }} + +
+ + + + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+ + + diff --git a/system/templates/account.change_mail.html.twig b/system/templates/account.change_mail.html.twig index f093fbff..83fe9ce3 100644 --- a/system/templates/account.change_mail.html.twig +++ b/system/templates/account.change_mail.html.twig @@ -1,47 +1,27 @@ Please enter your password and the new email address. Make sure that you enter a valid email address which you have access to.
For security reasons, the actual change will be finalised after a waiting period of {{ setting('core.account_mail_change') }} days.

-
- {{ csrf() }} -
- -
-
- - - - -
Change Email Address
- - - - -
-
+{% set title = 'Change Email Address' %} +{% set background = config('darkborder') %} +{% set content %} +
+ + + + +
+ New Email Address: + + +
+ Password: + -
- - - - - - - - - -
- New Email Address: - - -
- Password: - - -
-
+
-
+{% endset %} +{% include 'tables.headline.html.twig' %}
@@ -49,13 +29,15 @@ Please enter your password and the new email address. Make sure that you enter a
- - {{ include('buttons.submit.html.twig') }} + + {{ csrf() }} + + {{ include('buttons.submit.html.twig') }} +
- diff --git a/system/templates/account.change_name.html.twig b/system/templates/account.change_name.html.twig index 1fd10609..e40ea6ed 100644 --- a/system/templates/account.change_name.html.twig +++ b/system/templates/account.change_name.html.twig @@ -1,79 +1,62 @@ To change a name of character select player and choose a new name.
Change name cost {{ setting('core.account_change_character_name_price') }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}. You have {{ points }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}.

- - {{ csrf() }} - -
-
-
-
- - - - -
Change Name
- - - - -
-
- - - -
-
- - - - - - - - - -
Character: - -
New Name: - - -
- -
Please enter your character name.
-
-
-
-
- -
- - - + + +
- - - + +
+ +{% set title = 'Change Name' %} +{% set background = config('darkborder') %} +{% set content %} + + + + + + + + + +
Character: + +
New Name: + + +
+ +
Please enter your character name.
+
+
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+ + + - - -
+ + + - - -
+ + {{ csrf() }} + {{ include('buttons.submit.html.twig') }} -
-
- - - {{ csrf() }} - - - - -
- {{ include('buttons.back.html.twig') }} -
-
+ +
+
+ + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
diff --git a/system/templates/account.change_password.html.twig b/system/templates/account.change_password.html.twig index 89ccf592..bfece757 100644 --- a/system/templates/account.change_password.html.twig +++ b/system/templates/account.change_password.html.twig @@ -1,80 +1,62 @@ Please enter your current password and a new password. For your security, please enter the new password twice.

-
- {{ csrf() }} -
- -
-
- - - - -
Change Password
- - - - -
-
- - - -
-
- - - - - - - - - - - - - -
- New Password: - - -
- New Password Again: - - -
- Current Password: - - -
-
-
-
-
- - - + + +
- - - + +
+{% set title = 'Change Password' %} +{% set background = config('darkborder') %} +{% set content %} + + + + + + + + + + + + + +
+ New Password: + + +
+ New Password Again: + + +
+ Current Password: + + +
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+ + + - - - -
+ + + - -
+ + {{ csrf() }} {{ include('buttons.submit.html.twig') }} -
-
- - - {{ csrf() }} - - - - -
- {{ include('buttons.back.html.twig') }} -
-
+ +
+
+ + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
diff --git a/system/templates/account.change_sex.html.twig b/system/templates/account.change_sex.html.twig index fe0ef6e7..244418cf 100644 --- a/system/templates/account.change_sex.html.twig +++ b/system/templates/account.change_sex.html.twig @@ -1,78 +1,61 @@ To change a sex of character select player and choose a new sex.
-Change sex cost {{ setting('core.account_change_character_sex_price') }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}. You have {{ points }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}.

-
- {{ csrf() }} - -
- -
-
- - - - -
Change sex
- - - - -
-
- - - -
-
- - - - - - - - - -
Character: - -
New Sex: - -
-
-
-
-
- - - + + +
- - - + +
+Change sex cost {{ setting('core.account_change_character_sex_price') }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}. You have {{ points }} {{ setting('core.donate_column') == 'coins' ? 'coins' : 'premium points' }}. +

+{% set title = 'Change sex' %} +{% set background = config('darkborder') %} +{% set content %} + + + + + + + + + +
Character: + +
New Sex: + +
+{% endset %} +{% include 'tables.headline.html.twig' %} + +
+ + + - - -
+ + + - - - -
+ + {{ csrf() }} + {{ include('buttons.submit.html.twig') }} -
-
- - - {{ csrf() }} - - - - -
- {{ include('buttons.back.html.twig') }} -
-
+ +
+
+ + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
diff --git a/system/templates/account.create_character.html.twig b/system/templates/account.create_character.html.twig index a860a8b1..280e71c3 100644 --- a/system/templates/account.create_character.html.twig +++ b/system/templates/account.create_character.html.twig @@ -6,145 +6,145 @@ In any case the name must not violate the naming conventions stated in the You have maximum number of characters per account on your account. Delete one before you make new. {% endif %}

-
- {{ csrf() }} - -
- -
-
- - - - -
Create Character
- - - - -
+
+
+
+
+ + + + +
Create Character
+ + + +
-
- - -
-
- - -
-
-
-
-
-
- - - - - - - - - -
- Name - - Sex -
- - -
- -
{% if not save or errors.name is defined %}Please enter your character name.{% endif %}
-
-
- {% set i = 0 %} - {% for id, gender in config.genders|reverse(true) %} - {% set i = i + 1 %} -
- {% endfor %} -
-
-
-
-
-
- - - {% if config.character_samples|length > 1 %} - - {% endif %} - -
- - - - - -

Select your vocation:
- - {% for key, sample_char in config.character_samples %} - - - - {% endfor %} -
- - -
-
- {% endif %} - {% if config.character_towns|length > 1 %} -
- - - - - -

Select your city:
- - {% for town_id in config.character_towns %} - - - - {% endfor %} -
- - -
-
-
-
-
-
-
- - + + -
- - - - - -
- {{ include('buttons.submit.html.twig') }} -
-
- - - {{ csrf() }} +
+
-
- {{ include('buttons.back.html.twig') }} + +
+
+
+
+
+ + + + + + + + + +
+ Name + + Sex +
+ + +
+ +
{% if not save or errors.name is defined %}Please enter your character name.{% endif %}
+
+
+ {% set i = 0 %} + {% for id, gender in config.genders|reverse(true) %} + {% set i = i + 1 %} +
+ {% endfor %} +
+
+
+
+ +
+ + + {% if config.character_samples|length > 1 %} + + {% endif %} - -
+ + + + + +

Select your vocation:
+ + {% for key, sample_char in config.character_samples %} + + + + {% endfor %} +
+ + +
+
+ {% endif %} + {% if config.character_towns|length > 1 %} +
+ + + + + +

Select your city:
+ + {% for town_id in config.character_towns %} + + + + {% endfor %} +
+ + +
+
+
+ + +
+ + + + + +
+ + + + +
+
+ {{ csrf() }} + + {{ include('buttons.submit.html.twig') }} +
+
+
+ + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
diff --git a/system/templates/account.delete_character.html.twig b/system/templates/account.delete_character.html.twig index c5953cc7..cc0ca0f5 100644 --- a/system/templates/account.delete_character.html.twig +++ b/system/templates/account.delete_character.html.twig @@ -1,68 +1,50 @@ To delete a character enter the name of the character and your password.

-
- {{ csrf() }} - -
- -
-
- - - - -
Delete Character
- - - - -
-
- - - -
-
- - - - - - - - - -
Character Name: - -
Password: - -
-
-
-
-
- - - + +
- +{% set title = 'Delete Character' %} +{% set background = config('darkborder') %} +{% set content %} +
+ + + + + + + + +
Character Name: + +
Password: + +
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+ + + + - - -
+ + + + +
+ + {{ csrf() }} + + {{ include('buttons.submit.html.twig') }} + +
+
+ + + {{ csrf() }} - - -
- {{ include('buttons.submit.html.twig') }} + {{ include('buttons.back.html.twig') }}
-
- - - {{ csrf() }} - - - - -
- {{ include('buttons.back.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 9b28cebc..fc378d54 100644 --- a/system/templates/account.generate_new_recovery_key.html.twig +++ b/system/templates/account.generate_new_recovery_key.html.twig @@ -1,61 +1,44 @@ To generate new recovery key for your account please enter your password.
-New recovery key cost {{ setting('core.account_generate_new_reckey_price') }} Premium Points. You have {{ points }} premium points. You will receive e-mail with this recovery key.
-
- {{ csrf() }} - -
- -
-
- - - - -
Generate recovery key
- - - - -
-
- - - -
-
- - - - - -
Password:
-
-
-
-
- - - + + +
- - - + +
+New recovery key cost {{ setting('core.account_generate_new_reckey_price') }} Premium Points. You have {{ points }} premium points. You will receive e-mail with this recovery key. +
+{% set title = 'Generate recovery key' %} +{% set background = config('darkborder') %} +{% set content %} + + + + + +
Password:
+{% endset %} +{% include 'tables.headline.html.twig' %} +
+ + + - - -
+ + + - - -
+ + {{ csrf() }} + {{ include('buttons.submit.html.twig') }} -
-
- - - {{ csrf() }} - - - - -
- {{ include('buttons.back.html.twig') }} -
-
+ +
+
+ + + + +
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
diff --git a/system/templates/account.generate_recovery_key.html.twig b/system/templates/account.generate_recovery_key.html.twig index cb69476c..de6292ac 100644 --- a/system/templates/account.generate_recovery_key.html.twig +++ b/system/templates/account.generate_recovery_key.html.twig @@ -1,40 +1,18 @@ To generate recovery key for your account please enter your password.

-
- {{ csrf() }} - -
- -
-
- - - - -
Generate recovery key
- - - - -
-
- - - -
-
- - - - - -
- Password: - - -
-
-
-
+{% set title = 'Generate recovery key' %} +{% set content %} + + + + + +
+ Password: + + +
+{% endset %} +{% include 'tables.headline.html.twig' %}
@@ -42,12 +20,15 @@ To generate recovery key for your account please enter your password.

- {{ include('buttons.submit.html.twig') }} + + {{ csrf() }} + + {{ include('buttons.submit.html.twig') }} +
- diff --git a/system/templates/account.logout.html.twig b/system/templates/account.logout.html.twig index f74c9ffd..d71c4130 100644 --- a/system/templates/account.logout.html.twig +++ b/system/templates/account.logout.html.twig @@ -1,28 +1,10 @@ -
-
-
-
- - - - -
Logout Successful
- - - - -
-
- - - -
-
- - - - -
You have logged out of your {{ config.serverName }} account. In order to view your account you need to log in again.
-
-
- \ No newline at end of file +{% set title = 'Logout Successful' %} +{% set background = config('darkborder') %} +{% set content %} + + + + +
You have logged out of your {{ config.serverName }} account. In order to view your account you need to log in again.
+{% endset %} +{% include 'tables.headline.html.twig' %} diff --git a/system/templates/guilds.change_description.html.twig b/system/templates/guilds.change_description.html.twig index 4576ae0a..9c656920 100644 --- a/system/templates/guilds.change_description.html.twig +++ b/system/templates/guilds.change_description.html.twig @@ -1,14 +1,24 @@ -

Change guild description

-Here you can change description of your guild.
- - {{ csrf() }} - -
- (max. {{ setting('core.guild_description_lines_limit') }} lines, max. {{ setting('core.guild_description_chars_limit') }} chars)
-
-
-
- {{ csrf() }} - {{ include('buttons.back.html.twig') }} -
-
+{% set title = 'Change guild description' %} +{% set background = config('darkborder') %} +{% set content %} + + + + +
+ Here you can change description of your guild.
+
+ {{ csrf() }} + +
+ (max. {{ setting('core.guild_description_lines_limit') }} lines, max. {{ setting('core.guild_description_chars_limit') }} chars)

+
+
+
+ {{ csrf() }} + {{ include('buttons.back.html.twig') }} +
+
+
+{% endset %} +{% include 'tables.headline.html.twig' %} diff --git a/system/templates/guilds.change_logo.html.twig b/system/templates/guilds.change_logo.html.twig index 016c13c9..13813e9b 100644 --- a/system/templates/guilds.change_logo.html.twig +++ b/system/templates/guilds.change_logo.html.twig @@ -1,20 +1,32 @@ -

Change guild logo

-Here you can change logo of your guild.
Actuall logo:

-
- {{ csrf() }} - - - Select new logo: - -
-Only jpg, gif, png, bmp pictures. Max. size: {{ setting('core.guild_image_size_kb') }} KB
-
+{% set title = 'Change guild logo' %} +{% set background = config('darkborder') %} +{% set content %} + + + + +
+ Here you can change logo of your guild.
Actuall logo:

+
+ {{ csrf() }} + + + Select new logo: + +
+ Only jpg, gif, png, bmp pictures. Max. size: {{ setting('core.guild_image_size_kb') }} KB
+
+
+{% endset %} +{% include 'tables.headline.html.twig' %} +
{{ csrf() }} {{ include('buttons.back.html.twig') }}
+ {% 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 %} {% endfor %} @@ -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 58f88e65..773ce6c9 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') }}
From 0db0ec1aa47e044c26bc403ff5078a2115d086f8 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 14 Jun 2024 06:42:42 +0200 Subject: [PATCH 77/96] Fix useGuildNick displaying --- system/pages/guilds/show.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/system/pages/guilds/show.php b/system/pages/guilds/show.php index 58a4b45f..33039ad3 100644 --- a/system/pages/guilds/show.php +++ b/system/pages/guilds/show.php @@ -142,9 +142,7 @@ if($logged && count($invited_list) > 0) } } -$useGuildNick = false; -if($db->hasColumn('players', 'guildnick')) - $useGuildNick = true; +$useGuildNick = $db->hasTable('guild_members') || $db->hasTable('guild_membership') || $db->hasColumn('players', 'guildnick'); $twig->display('guilds.view.html.twig', array( 'logo' => $guild_logo, @@ -160,7 +158,6 @@ $twig->display('guilds.view.html.twig', array( 'level_in_guild' => $level_in_guild, 'isLeader' => $guild_leader, 'isVice' => $guild_vice, - 'logged' => $logged, 'invited_list' => $invited_list, 'show_accept_invite' => $show_accept_invite, 'useGuildNick' => $useGuildNick From 813786c7688f6c04f73bca14ec8e51d14da6ea3c Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 14 Jun 2024 06:42:45 +0200 Subject: [PATCH 78/96] Update cleanup_players.php --- system/pages/guilds/cleanup_players.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/pages/guilds/cleanup_players.php b/system/pages/guilds/cleanup_players.php index 61b1ce49..7e02fbeb 100644 --- a/system/pages/guilds/cleanup_players.php +++ b/system/pages/guilds/cleanup_players.php @@ -40,7 +40,7 @@ if(count($players_list) > 0) if(!$rank_guild->isLoaded()) { $player->setRank(); - $player->setGuildNick(); + $player->setGuildNick(''); $changed_ranks_of[] = $player->getName(); $deleted_ranks[] = 'ID: '.$player_rank->getId().' - '.$player_rank->getName(); $player_rank->delete(); From a8d255c04baa154cb1d680525dd8a7f2bb0138de Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 14 Jun 2024 08:07:52 +0200 Subject: [PATCH 79/96] feat: Plugins pages: subSubFolders --- system/src/Plugins.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/system/src/Plugins.php b/system/src/Plugins.php index 08f7be50..b0d58afe 100644 --- a/system/src/Plugins.php +++ b/system/src/Plugins.php @@ -21,7 +21,6 @@ class Plugins { } } - $duplicates = []; $routes = []; foreach(self::getAllPluginsJson() as $plugin) { $routesDefaultPriority = 1000; @@ -86,10 +85,7 @@ class Plugins { $file = str_replace(PLUGINS, 'plugins/', $file); $name = pathinfo($file, PATHINFO_FILENAME); - if (!isset($duplicates[$name])) { - $routes[] = [['get', 'post'], $name, $file, $pagesDefaultPriority]; - $duplicates[$name] = true; - } + $routes[] = [['get', 'post'], $name, $file, $pagesDefaultPriority]; } } @@ -106,9 +102,19 @@ class Plugins { $file = str_replace(PLUGINS, 'plugins/', $file); $name = $folderName . '/' . pathinfo($file, PATHINFO_FILENAME); - if (!isset($duplicates[$name])) { - $routes[] = [['get', 'post'], $name, $file, $pagesDefaultPriority]; - $duplicates[$name] = true; + $routes[] = [['get', 'post'], $name, $file, $pagesDefaultPriority]; + } + + $subFolders = glob(PLUGINS . $plugin['filename'] . '/pages/' . $folderName . '/*', GLOB_ONLYDIR); + foreach ($subFolders as $subFolder) { + $subFolderName = pathinfo($subFolder, PATHINFO_FILENAME); + $subSubFiles = glob(PLUGINS . $plugin['filename'] . '/pages/' . $folderName . '/' . $subFolderName . '/*.php'); + + foreach ($subSubFiles as $subSubFile) { + $subSubFile = str_replace(PLUGINS, 'plugins/', $subSubFile); + $name = $folderName . '/' . $subFolderName . '/' . pathinfo($subSubFile, PATHINFO_FILENAME); + + $routes[] = [['get', 'post'], $name, $subSubFile, $pagesDefaultPriority]; } } } From bc3dcab462a8ad0bbc55cafd87fba0c55af3126f Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 23 Jun 2024 09:55:15 +0200 Subject: [PATCH 80/96] deny all is enough --- nginx-sample.conf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nginx-sample.conf b/nginx-sample.conf index fb3967b5..40d85fb4 100644 --- a/nginx-sample.conf +++ b/nginx-sample.conf @@ -10,24 +10,20 @@ server { # this is very important, be sure its in your nginx conf - it prevents access to logs etc. location ~ /system { deny all; - return 404; } location /vendor { deny all; - return 404; } # block .htaccess, CHANGELOG.md, composer.json etc. # this is to prevent finding software versions location ~\.(ht|md|json|dist)$ { deny all; - return 404; } # block git files and folders location ~ /\.git { - return 404; deny all; } From a631760dbf9293df744b2228b2aa6c8968a1559d Mon Sep 17 00:00:00 2001 From: slawkens Date: Sun, 23 Jun 2024 16:10:50 +0200 Subject: [PATCH 81/96] Order fraggers by time --- system/pages/characters.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/pages/characters.php b/system/pages/characters.php index 3128daa3..89f98cf0 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -346,6 +346,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil ->join('players', 'players.id', '=', 'player_deaths.player_id') ->limit($frags_limit) ->selectRaw('players.name, player_deaths.*') + ->orderBy('player_deaths.time', 'DESC') ->get(); if ($player_frags->count()) { From d30811404b59d092bca4757874faae9bf8b08624 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 28 Jun 2024 19:03:06 +0200 Subject: [PATCH 82/96] Update players.php --- admin/pages/players.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/pages/players.php b/admin/pages/players.php index 863c098c..e8084afd 100644 --- a/admin/pages/players.php +++ b/admin/pages/players.php @@ -274,7 +274,7 @@ else if (isset($_REQUEST['search'])) { $player->setLossContainers($loss_containers); $player->setLossItems($loss_items); } - if ($db->hasColumn('players', 'blessings')) + if ($hasBlessingsColumn) $player->setBlessings($blessings); if ($hasBlessingColumn) { From dc17b701da053e04bfa64e21be9247a4f07505e1 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 29 Jun 2024 14:05:06 +0200 Subject: [PATCH 83/96] feat: Hooks priority --- plugins/example.json | 5 +++-- system/src/Plugins.php | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/plugins/example.json b/plugins/example.json index 24c608c9..68805cb9 100644 --- a/plugins/example.json +++ b/plugins/example.json @@ -25,7 +25,8 @@ "hooks": { "Example Hook": { "type": "BEFORE_PAGE", - "file": "plugins/example/before.php" + "file": "plugins/example/before.php", + "priority": 1000 } }, "routes": { @@ -33,7 +34,7 @@ "pattern": "/YourAwesomePage/{name:string}/{page:int}", "file": "plugins/your-plugin/your-awesome-page.php", "method": "GET", - "priority": "130" + "priority": 130 }, "Redirect Example": { "redirect_from": "/redirectExample", diff --git a/system/src/Plugins.php b/system/src/Plugins.php index b0d58afe..97604af4 100644 --- a/system/src/Plugins.php +++ b/system/src/Plugins.php @@ -218,14 +218,20 @@ class Plugins { $hooks = []; foreach(self::getAllPluginsJson() as $plugin) { if (isset($plugin['hooks'])) { + $priority = 1000; + foreach ($plugin['hooks'] as $_name => $info) { if (str_contains($info['type'], 'HOOK_')) { $info['type'] = str_replace('HOOK_', '', $info['type']); } + if (isset($info['priority'])) { + $priority = (int)$info['priority']; + } + if (defined('HOOK_'. $info['type'])) { $hook = constant('HOOK_'. $info['type']); - $hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']]; + $hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file'], 'priority' => $priority]; } else { self::$warnings[] = 'Plugin: ' . $plugin['name'] . '. Unknown event type: ' . $info['type']; } @@ -233,6 +239,15 @@ class Plugins { } } + usort($hooks, function ($a, $b) + { + if ($a['priority'] == $b['priority']) { + return 0; + } + + return ($a['priority'] < $b['priority']) ? -1 : 1; + }); + if ($cache->enabled()) { $cache->set('plugins_hooks', serialize($hooks), 600); } From 33a47137c9fb2ff9d8971158e693c92b0ee85d57 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 29 Jun 2024 15:09:44 +0200 Subject: [PATCH 84/96] Fix hooks priority default --- system/src/Plugins.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Plugins.php b/system/src/Plugins.php index 97604af4..fbaa5e40 100644 --- a/system/src/Plugins.php +++ b/system/src/Plugins.php @@ -218,9 +218,9 @@ class Plugins { $hooks = []; foreach(self::getAllPluginsJson() as $plugin) { if (isset($plugin['hooks'])) { - $priority = 1000; - foreach ($plugin['hooks'] as $_name => $info) { + $priority = 1000; + if (str_contains($info['type'], 'HOOK_')) { $info['type'] = str_replace('HOOK_', '', $info['type']); } From 83b3dc803a7181a2753099004abc97c92293dfe3 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 8 Jul 2024 19:50:05 +0200 Subject: [PATCH 85/96] Fix 5th step of installer --- install/steps/5-database.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install/steps/5-database.php b/install/steps/5-database.php index 6ee7d031..d0db8cfc 100644 --- a/install/steps/5-database.php +++ b/install/steps/5-database.php @@ -72,16 +72,16 @@ if(!$error) { } if(!$error) { - $twig->display('install.installer.html.twig', array( - 'url' => 'tools/5-database.php', - 'message' => $locale['loading_spinner'] - )); - $content = ''; $saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content); if($saved) { success($locale['step_database_config_saved']); $_SESSION['saved'] = true; + + $twig->display('install.installer.html.twig', array( + 'url' => 'tools/5-database.php', + 'message' => $locale['loading_spinner'] + )); } else { $_SESSION['config_content'] = $content; From 10a739773c4f2911876bc802a0ee0537c3e00a92 Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 21:29:42 +0200 Subject: [PATCH 86/96] Detect tools/ext exists on install to prevent broken installs --- install/steps/3-requirements.php | 17 ++++++++++++++--- system/locale/de/install.php | 4 ++++ system/locale/en/install.php | 4 ++++ system/locale/pl/install.php | 4 ++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/install/steps/3-requirements.php b/install/steps/3-requirements.php index 659e3036..65281248 100644 --- a/install/steps/3-requirements.php +++ b/install/steps/3-requirements.php @@ -2,10 +2,15 @@ defined('MYAAC') or die('Direct access not allowed!'); // configuration -$dirs_required = [ +$dirs_required_writable = [ 'system/logs', 'system/cache', ]; + +$dirs_required = [ + 'tools/ext' => $locale['step_requirements_folder_not_exists_tools_ext'], +]; + $dirs_optional = [ GUILD_IMAGES_DIR => $locale['step_requirements_warning_images_guilds'], GALLERY_DIR => $locale['step_requirements_warning_images_gallery'], @@ -18,6 +23,7 @@ $extensions_optional = [ 'gd' => $locale['step_requirements_warning_player_signatures'], 'zip' => $locale['step_requirements_warning_install_plugins'], ]; + /* * * @param string $name @@ -41,7 +47,7 @@ $failed = false; // start validating version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50500), PHP_VERSION); -foreach ($dirs_required as $value) +foreach ($dirs_required_writable as $value) { $is_writable = is_writable(BASE . $value) && (MYAAC_OS != 'WINDOWS' || win_is_writable(BASE . $value)); version_check($locale['step_requirements_write_perms'] . ': ' . $value, $is_writable); @@ -52,6 +58,12 @@ foreach ($dirs_optional as $dir => $errorMsg) { version_check($locale['step_requirements_write_perms'] . ': ' . $dir, $is_writable, $is_writable ? '' : $errorMsg, true); } +foreach ($dirs_required as $dir => $errorMsg) +{ + $exists = is_dir(BASE . $dir); + version_check($locale['step_requirements_folder_exists'] . ': ' . $dir, $exists, $exists ? '' : $errorMsg); +} + $ini_register_globals = ini_get_bool('register_globals'); version_check('register_long_arrays', !$ini_register_globals, $ini_register_globals ? $locale['on'] : $locale['off']); @@ -78,4 +90,3 @@ if($failed) { } echo ''; -?> diff --git a/system/locale/de/install.php b/system/locale/de/install.php index 85be3b16..ad354609 100644 --- a/system/locale/de/install.php +++ b/system/locale/de/install.php @@ -36,6 +36,10 @@ $locale['step_requirements'] = 'Anforderungen'; $locale['step_requirements_title'] = 'Anforderungen überprüfen'; $locale['step_requirements_php_version'] = 'PHP Version'; $locale['step_requirements_write_perms'] = 'Schreibberechtigungen'; +$locale['step_requirements_folder_exists'] = 'Ordner ist vorhanden'; +$locale['step_requirements_folder_not_exists_tools_ext'] = 'NPM Package Manager wird verwendet für externe JavaScript/CSS Bibliotheken.' + . ' Es sollte via Command Line installiert werden: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm' + . ' Nachdem das Tool installiert wurde, folgende Befehl sollte ausgeführt in dem Hauptordner des MyAACs: "npm install".'; $locale['step_requirements_failed'] = 'Die Installation wird deaktiviert, bis diese Anforderungen erfüllt sind.
Für weitere Informationen siehe README Datei.'; $locale['step_requirements_extension'] = '$EXTENSION$ PHP Erweiterung'; diff --git a/system/locale/en/install.php b/system/locale/en/install.php index 3de85896..e25537c9 100644 --- a/system/locale/en/install.php +++ b/system/locale/en/install.php @@ -36,6 +36,10 @@ $locale['step_requirements'] = 'Requirements'; $locale['step_requirements_title'] = 'Requirements check'; $locale['step_requirements_php_version'] = 'PHP Version'; $locale['step_requirements_write_perms'] = 'Write permissions'; +$locale['step_requirements_folder_exists'] = 'Directory exists'; +$locale['step_requirements_folder_not_exists_tools_ext'] = 'NPM Package Manager is used for external JavaScript/CSS libraries.' + . ' You need to install it through Command Line: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm' + . ' When you done with installing that tool, execute: "npm install" in the main MyAAC folder.'; $locale['step_requirements_failed'] = 'Installation will be disabled until these requirements will be passed.
For more informations see README file.'; $locale['step_requirements_extension'] = '$EXTENSION$ PHP extension'; $locale['step_requirements_warning_images_guilds'] = 'Guild logo upload will not work'; diff --git a/system/locale/pl/install.php b/system/locale/pl/install.php index 1afb2ddd..22204adf 100644 --- a/system/locale/pl/install.php +++ b/system/locale/pl/install.php @@ -36,6 +36,10 @@ $locale['step_requirements'] = 'Wymagania'; $locale['step_requirements_title'] = 'Sprawdzanie wymagań'; $locale['step_requirements_php_version'] = 'Wersja PHP'; $locale['step_requirements_write_perms'] = 'Uprawnienia do zapisu'; +$locale['step_requirements_folder_exists'] = 'Folder istnieje'; +$locale['step_requirements_folder_not_exists_tools_ext'] = 'Manadżer Pakietów NPM jest używany do zewnętrznych bibliotek JavaScript/CSS.' + . ' Trzeba go zainstalować poprzez wiersz poleceń: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm' + . ' Po instalacji narzędzia, wywołaj następujące polecenie w głownym katalogu MyAAC: "npm install".'; $locale['step_requirements_failed'] = 'Instalacja zostanie zablokowana dopóki te wymagania nie zostaną spełnione.
Po więcej informacji zasięgnij do pliku README.'; $locale['step_requirements_extension'] = 'Rozszerzenie PHP - $EXTENSION$'; $locale['step_requirements_warning_images_guilds'] = 'Nie będzie możliwości uploadu obrazków gildii'; From d94828772c3bebd845ede6aa1d8c3bb9452fadda Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 22:04:47 +0200 Subject: [PATCH 87/96] Rework 5th step of installation, to fix some pointless message about Cache --- install/steps/5-database.php | 83 ++++++++++++++++++------------------ install/tools/5-database.php | 3 ++ system/database.php | 1 + 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/install/steps/5-database.php b/install/steps/5-database.php index d0db8cfc..ed8f82a1 100644 --- a/install/steps/5-database.php +++ b/install/steps/5-database.php @@ -41,57 +41,56 @@ if(!$error) { $configToSave['cache_engine'] = 'auto'; $configToSave['cache_prefix'] = 'myaac_' . generateRandomString(8, true, false, true); - require BASE . 'install/includes/config.php'; - if(!$error) { - require BASE . 'install/includes/database.php'; + $content = ''; + $saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content); + if ($saved) { + success($locale['step_database_config_saved']); + $_SESSION['saved'] = true; - $locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']); - success($locale['step_database_importing']); + require BASE . 'config.local.php'; + require BASE . 'install/includes/config.php'; - if(isset($database_error)) { // we failed connect to the database - error($database_error); - } - else { - if(!$db->hasTable('accounts')) { - $tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']); - error($tmp); - $error = true; - } + if (!$error) { + require BASE . 'install/includes/database.php'; - if(!$db->hasTable('players')) { - $tmp = str_replace('$TABLE$', 'players', $locale['step_database_error_table']); - error($tmp); - $error = true; - } - - if(!$db->hasTable('guilds')) { - $tmp = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']); - error($tmp); - $error = true; - } - - if(!$error) { - $content = ''; - $saved = Settings::saveConfig($configToSave, BASE . 'config.local.php', $content); - if($saved) { - success($locale['step_database_config_saved']); - $_SESSION['saved'] = true; - - $twig->display('install.installer.html.twig', array( - 'url' => 'tools/5-database.php', - 'message' => $locale['loading_spinner'] - )); + if (isset($database_error)) { // we failed connect to the database + error($database_error); } else { - $_SESSION['config_content'] = $content; - unset($_SESSION['saved']); + if (!$db->hasTable('accounts')) { + $tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']); + error($tmp); + $error = true; + } - $locale['step_database_error_file'] = str_replace('$FILE$', '' . BASE . 'config.php', $locale['step_database_error_file']); - error($locale['step_database_error_file'] . '
- '); + if (!$db->hasTable('players')) { + $tmp = str_replace('$TABLE$', 'players', $locale['step_database_error_table']); + error($tmp); + $error = true; + } + + if (!$db->hasTable('guilds')) { + $tmp = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']); + error($tmp); + $error = true; + } + + if (!$error) { + $twig->display('install.installer.html.twig', array( + 'url' => 'tools/5-database.php', + 'message' => $locale['loading_spinner'] + )); + } } } + } else { + $_SESSION['config_content'] = $content; + unset($_SESSION['saved']); + + $locale['step_database_error_file'] = str_replace('$FILE$', '' . BASE . 'config.php', $locale['step_database_error_file']); + error($locale['step_database_error_file'] . '
+ '); } } } diff --git a/install/tools/5-database.php b/install/tools/5-database.php index 3ad4348a..ff0bcbbb 100644 --- a/install/tools/5-database.php +++ b/install/tools/5-database.php @@ -32,6 +32,9 @@ if($db->hasTable(TABLE_PREFIX . 'account_actions')) { else { // import schema try { + $locale['step_database_importing'] = str_replace('$DATABASE_NAME$', config('database_name'), $locale['step_database_importing']); + success($locale['step_database_importing']); + $db->query(file_get_contents(BASE . 'install/includes/schema.sql')); $locale['step_database_success_schema'] = str_replace('$PREFIX$', TABLE_PREFIX, $locale['step_database_success_schema']); diff --git a/system/database.php b/system/database.php index f20ca720..34b4574a 100644 --- a/system/database.php +++ b/system/database.php @@ -127,6 +127,7 @@ try { } if(defined('MYAAC_INSTALL')) { + $error = $e->getMessage(); return; // installer will take care of this } From fcb13f3c0fb8ceafda0bd614a229a26a269432bd Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 23:05:36 +0200 Subject: [PATCH 88/96] Fixes to account verify - do not allow login without verified email (Thanks @anyeor) --- plugins/email-confirmed-reward/reward.php | 2 -- system/pages/account/confirm-email.php | 18 ++++++---- system/pages/account/create.php | 3 ++ system/pages/account/login.php | 43 +++++++++++++---------- 4 files changed, 38 insertions(+), 28 deletions(-) diff --git a/plugins/email-confirmed-reward/reward.php b/plugins/email-confirmed-reward/reward.php index 11af5b34..e485dcf0 100644 --- a/plugins/email-confirmed-reward/reward.php +++ b/plugins/email-confirmed-reward/reward.php @@ -1,8 +1,6 @@ hasColumn('accounts', 'coins'); $rewardCoins = setting('core.account_mail_confirmed_reward_coins'); if ($rewardCoins > 0 && !$hasCoinsColumn) { diff --git a/system/pages/account/confirm-email.php b/system/pages/account/confirm-email.php index 925aef5e..615dd942 100644 --- a/system/pages/account/confirm-email.php +++ b/system/pages/account/confirm-email.php @@ -25,16 +25,20 @@ if(!Account::where('email_hash', $hash)->exists()) { } else { - if (Account::where('email_hash', $hash)->where('email_verified', 0)->exists()) { - $query = $query->fetch(PDO::FETCH_ASSOC); + $accountModel = Account::where('email_hash', $hash)->where('email_verified', 0)->first(); + if ($accountModel) { + $accountModel->email_verified = 1; + $accountModel->save(); + + success('You have now verified your e-mail, this will increase the security of your account. Thank you for doing this. You can now log in.'); + $account = new OTS_Account(); - $account->load($query['id']); + $account->load($accountModel->id); if ($account->isLoaded()) { $hooks->trigger(HOOK_EMAIL_CONFIRMED, ['account' => $account]); } } - - Account::where('email_hash', $hash)->update('email_verified', 1); - success('You have now verified your e-mail, this will increase the security of your account. Thank you for doing this.'); + else { + error('Link has expired.'); + } } -?> diff --git a/system/pages/account/create.php b/system/pages/account/create.php index 34e4689d..6895bba9 100644 --- a/system/pages/account/create.php +++ b/system/pages/account/create.php @@ -236,6 +236,9 @@ if($save) if(_mail($email, 'New account on ' . $config['lua']['serverName'], $body_html)) { echo 'Your account has been created.

'; + + warning("Before you can login - you need to verify your E-Mail. The verification link has been sent to $email. If the message is not coming - remember to check the SPAM folder."); + $twig->display('success.html.twig', array( 'title' => 'Account Created', 'description' => 'Your account ' . $account_type . ' is ' . $tmp_account . '
You will need the account ' . $account_type . ' and your password to play on ' . configLua('serverName') . '. diff --git a/system/pages/account/login.php b/system/pages/account/login.php index e68bfd2e..0fce795d 100644 --- a/system/pages/account/login.php +++ b/system/pages/account/login.php @@ -60,28 +60,33 @@ if(!empty($login_account) && !empty($login_password)) && (!isset($t) || $t['attempts'] < 5) ) { - session_regenerate_id(); - setSession('account', $account_logged->getId()); - setSession('password', encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $login_password)); - if($remember_me) { - setSession('remember_me', true); - } - - $logged = true; - $logged_flags = $account_logged->getWebFlags(); - - if(isset($_POST['admin']) && !admin()) { - $errors[] = 'This account has no admin privileges.'; - unsetSession('account'); - unsetSession('password'); - unsetSession('remember_me'); - $logged = false; + if (setting('core.account_mail_verify') && (int)$account_logged->getCustomField('email_verified') !== 1) { + $errors[] = 'Your account is not verified. Please verify your email address. If the message is not coming check the SPAM folder in your E-Mail client.'; } else { - $account_logged->setCustomField('web_lastlogin', time()); - } + session_regenerate_id(); + setSession('account', $account_logged->getId()); + setSession('password', encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $login_password)); + if($remember_me) { + setSession('remember_me', true); + } - $hooks->trigger(HOOK_LOGIN, array('account' => $account_logged, 'password' => $login_password, 'remember_me' => $remember_me)); + $logged = true; + $logged_flags = $account_logged->getWebFlags(); + + if(isset($_POST['admin']) && !admin()) { + $errors[] = 'This account has no admin privileges.'; + unsetSession('account'); + unsetSession('password'); + unsetSession('remember_me'); + $logged = false; + } + else { + $account_logged->setCustomField('web_lastlogin', time()); + } + + $hooks->trigger(HOOK_LOGIN, array('account' => $account_logged, 'password' => $login_password, 'remember_me' => $remember_me)); + } } else { From 203e411b626fe62401a4b74a48420769e512aa39 Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 23:06:12 +0200 Subject: [PATCH 89/96] Allow account_create_character_create even if account_mail_verify is activated --- system/init.php | 7 ------- system/pages/account/create.php | 18 +++++++++--------- system/templates/account.create.html.twig | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/system/init.php b/system/init.php index ec61b459..8e087139 100644 --- a/system/init.php +++ b/system/init.php @@ -157,13 +157,6 @@ require_once SYSTEM . 'compat/config.php'; date_default_timezone_set(setting('core.date_timezone')); -setting( - [ - 'core.account_create_character_create', - setting('core.account_create_character_create') && (!setting('core.mail_enabled') || !setting('core.account_mail_verify')) - ] -); - $settingsItemImagesURL = setting('core.item_images_url'); if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') { setting(['core.item_images_url', $settingsItemImagesURL . '/']); diff --git a/system/pages/account/create.php b/system/pages/account/create.php index 6895bba9..0074f9e3 100644 --- a/system/pages/account/create.php +++ b/system/pages/account/create.php @@ -255,15 +255,6 @@ if($save) } else { - if(setting('core.account_create_character_create')) { - // character creation - $character_created = $createCharacter->doCreate($character_name, $character_sex, $character_vocation, $character_town, $new_account, $errors); - if (!$character_created) { - error('There was an error creating your character. Please create your character later in account management page.'); - error(implode(' ', $errors)); - } - } - if(setting('core.account_create_auto_login')) { if ($hasBeenCreatedByEMail) { $_POST['account_login'] = $email; @@ -314,6 +305,15 @@ if($save) } } + if(setting('core.account_create_character_create')) { + // character creation + $character_created = $createCharacter->doCreate($character_name, $character_sex, $character_vocation, $character_town, $new_account, $errors); + if (!$character_created) { + error('There was an error creating your character. Please create your character later in account management page.'); + error(implode(' ', $errors)); + } + } + return; } } diff --git a/system/templates/account.create.html.twig b/system/templates/account.create.html.twig index 300b700a..2e5267e2 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -110,7 +110,7 @@ {{ hook('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1') }} - {% if (not setting('core.mail_enabled') or not setting('core.account_mail_verify')) and setting('core.account_create_character_create') %} + {% if setting('core.account_create_character_create') %}
@@ -105,7 +105,7 @@ From 28f98db9deaa9a6ea120d793b271dc751cfdbda7 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 12 Jul 2024 20:48:27 +0200 Subject: [PATCH 95/96] Fix PHPStan errors in monsters.php --- phpstan.neon | 1 + system/pages/monsters.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/phpstan.neon b/phpstan.neon index b77bc1d2..fda6a07c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -29,6 +29,7 @@ parameters: - '#Variable \$[a-zA-Z0-9\\_]+ might not be defined#' # Eloquent models - '#Call to an undefined static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+()#' + - '#Call to an undefined method object::toArray\(\)#' # system/pages/highscores.php - '#Call to an undefined method Illuminate\\Database\\Query\\Builder::withOnlineStatus\(\)#' - '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$online_status#' diff --git a/system/pages/monsters.php b/system/pages/monsters.php index f8a8a66a..e254fb6f 100644 --- a/system/pages/monsters.php +++ b/system/pages/monsters.php @@ -44,6 +44,8 @@ $monster = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first( if ($monster && isset($monster->name)) { $monster = $monster->toArray(); + /** @var array $monster */ + function sort_by_chance($a, $b) { if ($a['chance'] == $b['chance']) { From cff62ccba4f3ea2358e66e60a3ccd51fe4fa01ee Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 12 Jul 2024 20:54:12 +0200 Subject: [PATCH 96/96] Another try --- system/pages/monsters.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system/pages/monsters.php b/system/pages/monsters.php index e254fb6f..988d15b5 100644 --- a/system/pages/monsters.php +++ b/system/pages/monsters.php @@ -39,12 +39,11 @@ if (empty($_REQUEST['name'])) { // display monster $monster_name = urldecode(stripslashes(ucwords(strtolower($_REQUEST['name'])))); -$monster = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first(); - -if ($monster && isset($monster->name)) { - $monster = $monster->toArray(); +$monsterModel = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first(); +if ($monsterModel && isset($monsterModel->name)) { /** @var array $monster */ + $monster = $monsterModel->toArray(); function sort_by_chance($a, $b) {
-
+ {{ include('buttons.delete_character.html.twig') }}
From 5f63c3b227d1d39aea58afcf82dc299cde31a492 Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 23:33:00 +0200 Subject: [PATCH 90/96] Invalidate cached setting --- system/src/Settings.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/src/Settings.php b/system/src/Settings.php index 6c122237..0749396a 100644 --- a/system/src/Settings.php +++ b/system/src/Settings.php @@ -382,6 +382,8 @@ class Settings implements \ArrayAccess } $this->settingsDatabase[$pluginKeyName][$key] = $value; + // invalidate cache + unset($this->cache[$offset]); } #[\ReturnTypeWillChange] From 9a27403e7dc610fcb82649d1b673084db35ff60d Mon Sep 17 00:00:00 2001 From: slawkens Date: Tue, 9 Jul 2024 23:35:39 +0200 Subject: [PATCH 91/96] Fixes to account_mail_verify --- system/init.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system/init.php b/system/init.php index 8e087139..9bc14514 100644 --- a/system/init.php +++ b/system/init.php @@ -157,6 +157,13 @@ require_once SYSTEM . 'compat/config.php'; date_default_timezone_set(setting('core.date_timezone')); +setting( + [ + 'core.account_mail_verify', + setting('core.account_mail_verify') && setting('core.mail_enabled') + ] +); + $settingsItemImagesURL = setting('core.item_images_url'); if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') { setting(['core.item_images_url', $settingsItemImagesURL . '/']); From ef79b99b8acc179f14b8475547347d9daca27512 Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 10 Jul 2024 09:54:54 +0200 Subject: [PATCH 92/96] Fix monster not found exception --- system/pages/monsters.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/pages/monsters.php b/system/pages/monsters.php index 8ba07acc..f8a8a66a 100644 --- a/system/pages/monsters.php +++ b/system/pages/monsters.php @@ -39,9 +39,11 @@ if (empty($_REQUEST['name'])) { // display monster $monster_name = urldecode(stripslashes(ucwords(strtolower($_REQUEST['name'])))); -$monster = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first()->toArray(); +$monster = Monster::where('hide', '!=', 1)->where('name', $monster_name)->first(); + +if ($monster && isset($monster->name)) { + $monster = $monster->toArray(); -if (isset($monster['name'])) { function sort_by_chance($a, $b) { if ($a['chance'] == $b['chance']) { From cd49dfc79942f3301ce9c0b8d899b9f39bda9a41 Mon Sep 17 00:00:00 2001 From: slawkens Date: Wed, 10 Jul 2024 18:12:05 +0200 Subject: [PATCH 93/96] Set Admin Account verified by default --- install/steps/7-finish.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/steps/7-finish.php b/install/steps/7-finish.php index 0d95863a..84c2cce4 100644 --- a/install/steps/7-finish.php +++ b/install/steps/7-finish.php @@ -93,6 +93,8 @@ if(USE_ACCOUNT_SALT) $account_used->setCustomField('web_flags', FLAG_ADMIN + FLAG_SUPER_ADMIN); $account_used->setCustomField('country', 'us'); +$account_used->setCustomField('email_verified', 1); + if($db->hasColumn('accounts', 'group_id')) $account_used->setCustomField('group_id', $groups->getHighestId()); if($db->hasColumn('accounts', 'type')) From da14e125e97d117947365668ee87c380ae9c15d9 Mon Sep 17 00:00:00 2001 From: slawkens Date: Fri, 12 Jul 2024 20:01:12 +0200 Subject: [PATCH 94/96] Fix highscores skill links (Thanks @vyroq) --- system/templates/highscores.html.twig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/templates/highscores.html.twig b/system/templates/highscores.html.twig index 90a833c6..8a2c78a6 100644 --- a/system/templates/highscores.html.twig +++ b/system/templates/highscores.html.twig @@ -11,7 +11,7 @@
{% for link, name in types %} - {{ name }}
+ {{ name }}
{% endfor %}