Skip to content

Commit 77a459e

Browse files
committed
Bug-fix.
Looking for IPAddr in the wrong object; Fixed.
1 parent a510cdf commit 77a459e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/FrontEnd.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2022.02.01).
11+
* This file: Front-end handler (last modified: 2022.02.13).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -222,10 +222,10 @@ public function view(string $Page = ''): void
222222
{
223223
/** Brute-force protection. */
224224
if ((
225-
($LoginAttempts = (int)$this->Loader->Cache->getEntry('LoginAttempts' . $this->IPAddr)) &&
225+
($LoginAttempts = (int)$this->Loader->Cache->getEntry('LoginAttempts' . $this->Loader->IPAddr)) &&
226226
($LoginAttempts >= $this->Loader->Configuration['frontend']['max_login_attempts'])
227227
) || (
228-
($Failed2FA = (int)$this->Loader->Cache->getEntry('Failed2FA' . $this->IPAddr)) &&
228+
($Failed2FA = (int)$this->Loader->Cache->getEntry('Failed2FA' . $this->Loader->IPAddr)) &&
229229
($Failed2FA >= $this->Loader->Configuration['frontend']['max_login_attempts'])
230230
)) {
231231
header('Content-Type: text/plain');
@@ -297,7 +297,7 @@ public function view(string $Page = ''): void
297297
'UA' => $_SERVER['HTTP_USER_AGENT'] ?? '',
298298

299299
/** The IP address of the current request. */
300-
'YourIP' => $this->IPAddr,
300+
'YourIP' => $this->Loader->IPAddr,
301301

302302
/** Asynchronous mode. */
303303
'ASYNC' => !empty($_POST['ASYNC']),
@@ -455,7 +455,7 @@ public function view(string $Page = ''): void
455455
!empty($this->Loader->Configuration[$ConfigUserPath]['permissions'])
456456
) {
457457
if (password_verify($_POST['password'], $this->Loader->Configuration[$ConfigUserPath]['password'])) {
458-
$this->Loader->Cache->deleteEntry('LoginAttempts' . $this->IPAddr);
458+
$this->Loader->Cache->deleteEntry('LoginAttempts' . $this->Loader->IPAddr);
459459
$Permissions = (int)$this->Loader->Configuration[$ConfigUserPath]['permissions'];
460460
if ($Permissions !== 1 && $Permissions !== 2) {
461461
$FE['state_msg'] = $this->Loader->L10N->getString('response_login_wrong_endpoint');
@@ -512,7 +512,7 @@ public function view(string $Page = ''): void
512512
if ($FE['state_msg']) {
513513
$LoginAttempts++;
514514
$TimeToAdd = ($LoginAttempts > 4) ? ($LoginAttempts - 4) * 86400 : 86400;
515-
$this->Loader->Cache->setEntry('LoginAttempts' . $this->IPAddr, $LoginAttempts, $TimeToAdd ?: 86400);
515+
$this->Loader->Cache->setEntry('LoginAttempts' . $this->Loader->IPAddr, $LoginAttempts, $TimeToAdd ?: 86400);
516516
$LoggerMessage = $FE['state_msg'];
517517
}
518518
} elseif ($this->Permissions === 3) {
@@ -526,7 +526,7 @@ public function view(string $Page = ''): void
526526
$TryUser = preg_replace('~[\x00-\x1F]~', '', $TryUser ?? $this->User);
527527

528528
/** Handle front-end logging. */
529-
$this->frontendLogger($this->IPAddr, $TryUser, $LoggerMessage ?? '');
529+
$this->frontendLogger($this->Loader->IPAddr, $TryUser, $LoggerMessage ?? '');
530530
}
531531

532532
/** Determine whether the user has logged in. */
@@ -561,16 +561,16 @@ public function view(string $Page = ''): void
561561
if (password_verify($_POST['2fa'], substr($TwoFactorState, 1))) {
562562
$this->Loader->Cache->setEntry('TwoFactorState:' . $_COOKIE['PHPMUSSEL-ADMIN'], '1', $this->SessionTTL);
563563
$Try = 1;
564-
$this->Loader->Cache->deleteEntry('Failed2FA' . $this->IPAddr);
564+
$this->Loader->Cache->deleteEntry('Failed2FA' . $this->Loader->IPAddr);
565565
if ($this->Loader->Configuration['frontend']['frontend_log']) {
566-
$this->frontendLogger($this->IPAddr, $SessionUser, $this->Loader->L10N->getString('response_2fa_valid'));
566+
$this->frontendLogger($this->Loader->IPAddr, $SessionUser, $this->Loader->L10N->getString('response_2fa_valid'));
567567
}
568568
} else {
569569
$Failed2FA++;
570570
$TimeToAdd = ($Failed2FA > 4) ? ($Failed2FA - 4) * 86400 : 86400;
571-
$this->Loader->Cache->setEntry('Failed2FA' . $this->IPAddr, $Failed2FA, $TimeToAdd ?: 86400);
571+
$this->Loader->Cache->setEntry('Failed2FA' . $this->Loader->IPAddr, $Failed2FA, $TimeToAdd ?: 86400);
572572
if ($this->Loader->Configuration['frontend']['frontend_log']) {
573-
$this->frontendLogger($this->IPAddr, $SessionUser, $this->Loader->L10N->getString('response_2fa_invalid'));
573+
$this->frontendLogger($this->Loader->IPAddr, $SessionUser, $this->Loader->L10N->getString('response_2fa_invalid'));
574574
}
575575
$FE['state_msg'] = $this->Loader->L10N->getString('response_2fa_invalid');
576576
}
@@ -605,7 +605,7 @@ public function view(string $Page = ''): void
605605
$this->User = '';
606606
$this->Permissions = 0;
607607
setcookie('PHPMUSSEL-ADMIN', '', -1, '/', $this->HostnameOverride ?: $this->Host, false, true);
608-
$this->frontendLogger($this->IPAddr, $SessionUser, $this->Loader->L10N->getString('state_logged_out'));
608+
$this->frontendLogger($this->Loader->IPAddr, $SessionUser, $this->Loader->L10N->getString('state_logged_out'));
609609
}
610610

611611
if ($this->Permissions === 1) {

0 commit comments

Comments
 (0)