Skip to content

Commit

Permalink
Merge branch 'main' into fix-page-body-limited
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel authored May 28, 2024
2 parents cb3a838 + 3fa2c2d commit af291c9
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 22 deletions.
15 changes: 8 additions & 7 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@
'account_create_auto_login' => false, // auto login after creating account?
'account_create_character_create' => true, // allow directly to create character on create account page?
'account_mail_verify' => false, // force users to confirm their email addresses when registering account
'account_mail_confirmed_reward' => [ // reward users for confirming their E-Mails
// account_mail_verify needs to be enabled too
'premium_days' => 0,
'coins_transferable' => 0,
'coins' => 0,
'message' => 'You received %d %s for confirming your E-Mail address.' // example: You received 20 coins for confirming your E-Mail address.
],
'account_verified_only' => false, // force users to confirm their email to login in game
'account_mail_confirmed_reward' => [ // reward users for confirming their E-Mails
// account_mail_verify needs to be enabled too
'premium_days' => 0,
'coins_transferable' => 0,
'coins' => 0,
'message' => 'You received %d %s for confirming your E-Mail address.' // example: You received 20 coins for confirming your E-Mail address.
],
'account_mail_unique' => true, // email addresses cannot be duplicated? (one account = one email)
'account_premium_days' => 0, // default premium days on new account
'account_premium_coins' => 0, // default coins on new account
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_password'),
'/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register'),
'/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register_new'),
'/^account\/resend\/verify\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'resend_verify'),
'/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_email'),
'/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_info'),
'/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'create_character'),
Expand Down
4 changes: 4 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ function parseEvent($table1, $date, $table2)
sendError('Email or password is not correct.');
}

if ($config['account_verified_only'] && $config['mail_enabled'] && $config['account_mail_verify'] && $account->getCustomField('email_verified') != '1') {
sendError('You need to verify your account, enter in our site and resend verify e-mail!');
}

// common columns
$columns = 'name, level, sex, vocation, looktype, lookhead, lookbody, looklegs, lookfeet, lookaddons, lastlogin, isreward, istutorial, ismain, hidden';
$players = $db->query("SELECT {$columns} FROM players WHERE account_id = {$account->getId()} AND deletion = 0");
Expand Down
58 changes: 58 additions & 0 deletions system/pages/account/resend_verify.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
global $account_logged, $twig, $config;
/**
* Resend Verify Account Email
*
* @package MyAAC
* @author OpenTibiaBR
* @copyright 2024 MyAAC
* @link https://github.com/opentibiabr/myaac
*/
defined('MYAAC') or die('Direct access not allowed!');

if (!$config['mail_enabled'])
echo "You can't resend email to verify your account";
else {
$accName = $account_logged->getName();
$accEmail = $account_logged->getEMail();

if ($account_logged->getCustomField('email_verified') == '1') {
echo "You account is already verified!";
return;
}

if (isset($_POST['confirmresend']) && $_POST['confirmresend'] == '1') {
$hash = md5(generateRandomString(16, true, true) . $accEmail);
$account_logged->setCustomField('email_hash', $hash);

$verify_url = getLink('account/confirm_email/' . $hash);
$body_html = $twig->render('mail.account.verify.html.twig', array(
'account' => $accName,
'verify_url' => generateLink($verify_url, $verify_url, true)
));

if (_mail($accEmail, configLua('serverName') . ' - Verify Account', $body_html)) {
$message = "<br />Your request was sent on email address <b>{$accEmail}</b>";
$show_form = false;
} else {
$message = "<br /><p class='error'>An error occurred while sending email ( <b>{$accEmail}</b> )! Try again later. For Admin: More info can be found in system/logs/mailer-error.log</p>";
}

$twig->display('success.html.twig', array(
'title' => 'Verify Email Sent',
'description' => "<ul>{$message}</ul>"
));
}

//show errors if not empty
if (!empty($errors)) {
$twig->display('error_box.html.twig', array('errors' => $errors));
}

if ($show_form) {
$twig->display('account.resend_verify_email.html.twig', array(
'name' => $accName,
'email' => $accEmail,
));
}
}
9 changes: 9 additions & 0 deletions system/pages/accountmanagement.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
global $config, $db, $account_logged, $logged, $action, $template_path, $twig;
/**
* Account management
*
Expand Down Expand Up @@ -100,6 +101,13 @@
else
$welcome_message = 'Welcome to your ' . configLua('serverName') . ' account!';

$verify_message = "";
if ($config['mail_enabled'] && $config['account_mail_verify'] && $account_logged->getCustomField('email_verified') != '1') {
$verifyLink = getLink('account/resend/verify');
$type = ($config['account_verified_only'] ?? false) ? 'required' : 'optional';
$verify_message = "<span style='color: red'>Verification is {$type}! Please <b><a href='{$verifyLink}'>Verify</a></b> your Account!</span>";
}

$email_change = '';
$email_request = false;
if ($email_new_time > 1) {
Expand Down Expand Up @@ -128,6 +136,7 @@

$twig->display('account.management.html.twig', array(
'welcome_message' => $welcome_message,
'verify_message' => $verify_message,
'recovery_key' => $recovery_key,
'email_change' => $email_change,
'email_request' => $email_request,
Expand Down
17 changes: 16 additions & 1 deletion system/templates/account.generate_new_recovery_key.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
To generate new recovery key for your account please enter your password.<br/>
<span style="color: {{ color }}"><b>New recovery key cost {{ config.generate_new_reckey_price }} {{ coin_type }}.</b> You have {{ coins }} {{ coin_type }}. You will receive e-mail with this recovery key.</span>
<span>New recovery key cost: <b>{{ config.generate_new_reckey_price }} {{ coin_name }}</b>. You will receive e-mail with this recovery key.</span><br/>
<span>
Coins Balance:
{% if coins > 0 %}
<span style="color: green; font-weight: bold">{{ coins }} {{ coin_name }}
{% if coins < config.account_change_character_name_coins %}
<span style="color: red; font-weight: normal"> (you do not have {{ coin_name }} enough,
<a href="?donate" target="_blank">donate</a> now)</span>
{% endif %}
</span>
{% else %}
<span style="color: red; font-weight: bold">You do not have {{ coin_name }},
<a href="?donate" target="_blank">donate</a> now</span>
{% endif %}
</span>
<br/><br/>

<form action="{{ getLink('account/register/new') }}" method="post">
<input type="hidden" name="registeraccountsave" value="1">
<div class="TableContainer">
Expand Down
71 changes: 71 additions & 0 deletions system/templates/account.resend_verify_email.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Check your information and confirm to send verify e-mail.
<br/><br/>
<form action="{{ getLink('account/resend/verify') }}" method="post">
<input type="hidden" name="confirmresend" value="1">
<div class="TableContainer">
<table class="Table1" cellpadding="0" cellspacing="0">
<div class="CaptionContainer">
<div class="CaptionInnerContainer">
<span class="CaptionEdgeLeftTop"
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightTop"
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionBorderTop"
style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionVerticalLeft"
style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<div class="Text">Confirm Send Verify Email</div>
<span class="CaptionVerticalRight"
style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
<span class="CaptionBorderBottom"
style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
<span class="CaptionEdgeLeftBottom"
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
<span class="CaptionEdgeRightBottom"
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
</div>
</div>
<tr>
<td>
<div class="InnerTableContainer">
<table style="width:100%;">
<tr>
<td class="LabelV" style="width: 50px"><span>Account name:</span></td>
<td>{{ name }}</td>
</tr>
<tr>
<td class="LabelV"><span>E-mail:</span></td>
<td>{{ email }}</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
<br/>
<table style="width:100%">
<tr align="center">
<td>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="border:0px;">
{{ include('buttons.submit.html.twig') }}
</td>
</tr>
</form>
</table>
</td>
<td>
<table border="0" cellspacing="0" cellpadding="0">
<form action="{{ getLink('account/manage') }}" method="post">
<tr>
<td style="border:0px;">
{{ include('buttons.back.html.twig') }}
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
38 changes: 24 additions & 14 deletions templates/tibiacom/account.management.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
<table style="margin-left: auto; margin-right: auto;">
<tr>
<td>
<img src="{{ template_path }}/images/content/headline-bracer-left.gif"/>
<img src="{{ template_path }}/images/content/headline-bracer-left.gif" />
</td>
<td
style="text-align:center;vertical-align:middle;horizontal-align:center;font-size:17px;font-weight:bold;">{{ welcome_message|raw }}
</td>
<td><img src="{{ template_path }}/images/content/headline-bracer-right.gif"/></td>
<td><img src="{{ template_path }}/images/content/headline-bracer-right.gif" /></td>
</tr>
</table>
<br/>
{% if verify_message is not empty %}
<table style="margin: 7px auto 1px auto">
<tr>
<td
style="text-align:center;vertical-align:middle;horizontal-align:center;font-size:20px;font-weight:bold;">{{ verify_message|raw }}
</td>
</tr>
</table>
{% endif %}
<br />
</div>
<div class="TableContainer">
<div class="CaptionContainer">
Expand Down Expand Up @@ -72,7 +81,8 @@
<a href="?donate" target="blank">
<div class="BigButton"
style="background-image:url({{ template_path }}/images/global/buttons/sbutton_green.gif)">
<div onmouseover="MouseOverBigButton('GetCoinsButton');" onmouseout="MouseOutBigButton('GetCoinsButton');">
<div onmouseover="MouseOverBigButton('GetCoinsButton');"
onmouseout="MouseOutBigButton('GetCoinsButton');">
<div id="GetCoinsButton" class="BigButtonOver"
style="background-image:url({{ template_path }}/images/global/buttons/sbutton_green_over.gif); visibility: hidden;"></div>
<input class="BigButtonText" type="submit" value="Get Coins"></div>
Expand Down Expand Up @@ -251,13 +261,13 @@
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></div>
</div>
</div>
<br/>
<br />
{% endif %}

<div class="TopButtonContainer">
<div class="TopButton">
<a href="#top">
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif"/>
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif" />
</a>
</div>
</div>
Expand Down Expand Up @@ -474,13 +484,13 @@
style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></div>
</div>
</div>
<br/>
<br />
{% endif %}
<a name="General+Information"></a>
<div class="TopButtonContainer">
<div class="TopButton">
<a href="#top">
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif"/>
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif" />
</a>
</div>
</div>
Expand Down Expand Up @@ -542,7 +552,7 @@
<tr style="background-color: {{ config.darkborder }};">
<td class="LabelV">Tibia Coins:</td>
<td>{{ account_coins }} <img src="{{ template_path }}/images/account/icon-tibiacoin.png"
class="VSCCoinImages"/>
class="VSCCoinImages" />
(Including: {{ account_coins_transferable }} <img
src="{{ template_path }}/images/account/icon-tibiacointrusted.png"
class="VSCCoinImages">)
Expand Down Expand Up @@ -584,7 +594,7 @@
<form action="{{ getLink('account/email') }}" method="post">
<tr>
<td style="border:0px;">
<input type="hidden" name="newemail" value=""/>
<input type="hidden" name="newemail" value="" />
<input type="hidden" name="newemaildate" value="0">
{{ include('buttons.change_email.html.twig') }}
</td>
Expand Down Expand Up @@ -618,13 +628,13 @@
</table>
</div>

<br/>
<br />

<a name="Public+Information"></a>
<div class="TopButtonContainer">
<div class="TopButton">
<a href="#top">
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif"/>
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif" />
</a>
</div>
</div>
Expand Down Expand Up @@ -708,13 +718,13 @@
</tr>
</table>
</div>
<br/>
<br />

<a name="Account+Logs"></a>
<div class="TopButtonContainer">
<div class="TopButton">
<a href="#top">
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif"/>
<img style="border:0px;" src="{{ template_path }}/images/content/back-to-top.gif" />
</a>
</div>
</div>
Expand Down

0 comments on commit af291c9

Please sign in to comment.