Removed some refs to IPAddress class.
This commit is contained in:
parent
cbda92f72e
commit
b0f6db2450
6 changed files with 16 additions and 12 deletions
|
@ -169,7 +169,7 @@ switch ($authMode) {
|
|||
break;
|
||||
}
|
||||
|
||||
$ipAddress = IPAddress::remote()->getString();
|
||||
$ipAddress = remote_address();
|
||||
$emailSent = Database::prepare('
|
||||
SELECT COUNT(`verification_code`) > 0
|
||||
FROM `msz_users_password_resets`
|
||||
|
@ -235,7 +235,7 @@ MSG;
|
|||
$authLoginError = '';
|
||||
|
||||
while ($isSubmission) {
|
||||
$ipAddress = IPAddress::remote()->getString();
|
||||
$ipAddress = remote_address();
|
||||
|
||||
if (!isset($authUsername, $authPassword)) {
|
||||
$authLoginError = "You didn't fill all the forms!";
|
||||
|
@ -343,7 +343,7 @@ MSG;
|
|||
$authUsername,
|
||||
$authPassword,
|
||||
$authEmail,
|
||||
IPAddress::remote()->getString()
|
||||
remote_address()
|
||||
);
|
||||
|
||||
if ($createUser < 1) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
use Misuzu\Database;
|
||||
use Misuzu\Net\IPAddress;
|
||||
|
||||
require_once __DIR__ . '/../../misuzu.php';
|
||||
|
||||
|
@ -124,7 +123,7 @@ if ($postRequest) {
|
|||
$topicId,
|
||||
$forum['forum_id'],
|
||||
$app->getUserId(),
|
||||
IPAddress::remote()->getString(),
|
||||
remote_address(),
|
||||
$postText,
|
||||
MSZ_PARSER_BBCODE
|
||||
);
|
||||
|
|
|
@ -141,7 +141,7 @@ final class IPAddress
|
|||
public static function remote(string $fallbackAddress = self::FALLBACK_ADDRESS): IPAddress
|
||||
{
|
||||
try {
|
||||
return self::fromString($_SERVER['REMOTE_ADDR'] ?? $fallbackAddress);
|
||||
return self::fromString(remote_address($fallbackAddress));
|
||||
} catch (InvalidArgumentException $ex) {
|
||||
return self::fromString($fallbackAddress);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ function user_bump_last_active(int $userId, string $ipAddress = null): void
|
|||
`last_ip` = INET6_ATON(:last_ip)
|
||||
WHERE `user_id` = :user_id
|
||||
');
|
||||
$bumpUserLast->bindValue('last_ip', $ipAddress ?? $_SERVER['REMOTE_ADDR'] ?? '::1');
|
||||
$bumpUserLast->bindValue('last_ip', $ipAddress ?? remote_address());
|
||||
$bumpUserLast->bindValue('user_id', $userId);
|
||||
$bumpUserLast->execute();
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ function audit_log(
|
|||
string $action,
|
||||
int $userId = 0,
|
||||
array $params = [],
|
||||
IPAddress $ipAddress = null
|
||||
?string $ipAddress = null
|
||||
): void {
|
||||
$ipAddress = $ipAddress ?? IPAddress::remote();
|
||||
$ipAddress = $ipAddress ?? remote_address();
|
||||
|
||||
for ($i = 0; $i < count($params); $i++) {
|
||||
if (preg_match('#^(-?[0-9]+)$#', $params[$i])) {
|
||||
|
@ -20,13 +20,13 @@ function audit_log(
|
|||
INSERT INTO `msz_audit_log`
|
||||
(`log_action`, `user_id`, `log_params`, `log_ip`, `log_country`)
|
||||
VALUES
|
||||
(:action, :user, :params, :ip, :country)
|
||||
(:action, :user, :params, INET6_ATON(:ip), :country)
|
||||
');
|
||||
$addLog->bindValue('action', $action);
|
||||
$addLog->bindValue('user', $userId < 1 ? null : $userId);
|
||||
$addLog->bindValue('params', json_encode($params));
|
||||
$addLog->bindValue('ip', $ipAddress->getRaw());
|
||||
$addLog->bindValue('country', $ipAddress->getCountryCode());
|
||||
$addLog->bindValue('ip', $ipAddress);
|
||||
$addLog->bindValue('country', get_country_code($ipAddress));
|
||||
$addLog->execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,11 @@ function array_apply(array $array, callable $func): array
|
|||
return $array;
|
||||
}
|
||||
|
||||
function remote_address(string $fallback = '::1'): string
|
||||
{
|
||||
return $_SERVER['REMOTE_ADDR'] ?? $fallback;
|
||||
}
|
||||
|
||||
function set_cookie_m(string $name, string $value, int $expires): void
|
||||
{
|
||||
setcookie(
|
||||
|
|
Loading…
Add table
Reference in a new issue