mirror of
https://github.com/slawkens/myaac.git
synced 2025-12-10 02:50:46 +01:00
Remove duplicated code - extract lostAccountCooldown function
This commit is contained in:
14
system/pages/account/lost/base.php
Normal file
14
system/pages/account/lost/base.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
|
function lostAccountCooldown(string $nick, int $time): string
|
||||||
|
{
|
||||||
|
$inSec = $time - time();
|
||||||
|
$minutesLeft = floor($inSec / 60);
|
||||||
|
$secondsLeft = $inSec - ($minutesLeft * 60);
|
||||||
|
$timeLeft = $minutesLeft.' minutes '.$secondsLeft.' seconds';
|
||||||
|
|
||||||
|
$timeRounded = ceil(setting('core.mail_lost_account_interval') / 60);
|
||||||
|
|
||||||
|
return "Account of selected character (<b>" . escapeHtml($nick) . "</b>) received e-mail in last $timeRounded minutes. You must wait $timeLeft before you can use Lost Account Interface again.";
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
|
require __DIR__ . '/../base.php';
|
||||||
|
|
||||||
$title = 'Lost Account';
|
$title = 'Lost Account';
|
||||||
|
|
||||||
$email = $_REQUEST['email'];
|
$email = $_REQUEST['email'];
|
||||||
@@ -40,14 +42,7 @@ if($account->isLoaded()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$inSec = (int)$account->getCustomField('email_next') - time();
|
echo lostAccountCooldown($nick, (int)$account->getCustomField('email_next'));
|
||||||
$minutesLeft = floor($inSec / 60);
|
|
||||||
$secondsLeft = $inSec - ($minutesLeft * 60);
|
|
||||||
$timeLeft = $minutesLeft.' minutes '.$secondsLeft.' seconds';
|
|
||||||
|
|
||||||
$timeRounded = ceil(setting('core.mail_lost_account_interval') / 60);
|
|
||||||
|
|
||||||
echo "Account of selected character (<b>" . escapeHtml($nick) . "</b>) received e-mail in last $timeRounded minutes. You must wait $timeLeft before you can use Lost Account Interface again.";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
|
require __DIR__ . '/../base.php';
|
||||||
|
|
||||||
$title = 'Lost Account';
|
$title = 'Lost Account';
|
||||||
|
|
||||||
@@ -9,14 +12,7 @@ if($account->isLoaded()) {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$inSec = (int)$account->getCustomField('email_next') - time();
|
echo lostAccountCooldown($nick, (int)$account->getCustomField('email_next'));
|
||||||
$minutesLeft = floor($inSec / 60);
|
|
||||||
$secondsLeft = $inSec - ($minutesLeft * 60);
|
|
||||||
$timeLeft = $minutesLeft.' minutes '.$secondsLeft.' seconds';
|
|
||||||
|
|
||||||
$timeRounded = ceil(setting('core.mail_lost_account_interval') / 60);
|
|
||||||
|
|
||||||
echo "Account of selected character (<b>" . escapeHtml($nick) . "</b>) received e-mail in last $timeRounded minutes. You must wait $timeLeft before you can use Lost Account Interface again.";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user