How to check other IP addresses?

Hello. There is a code. I would like to implement here, check also other IP addresses except mine. How do I implement it?
<?

if ($_POST['login_f']) {

captcha_valid();

if ( $_POST['password'] != '12345' or $_SERVER['REMOTE_ADDR'] != 'ip admin')
 message('Access denied');

$_SESSION['admin'] = 1;
go('a_home');
}
?>
April 7th 20 at 10:43
1 answer
April 7th 20 at 10:45
Solution
$restrictedIps = ['192.168.0.1', '192.168.0.2'];
if ( $_POST['password'] != '12345' or in_array($_SERVER['REMOTE_ADDR'], $restrictedIps, true))
 message('Access denied');
Did not help, with one IP writes that all is well and the other not. - korey.Gulgows commented on April 7th 20 at 10:48
@korey.Gulgows, the code is correct, so give the IP, we think. - lee.McLaughlin commented on April 7th 20 at 10:51
@lee.McLaughlin, the First IP is venovski, and the second is mine. The first IP everything works fine, but the second does not.
<?

if ($_POST['login_f']) {

captcha_valid();

$restrictedIps = ['77.111.245.13', '176.52.33.20'];
if ( $_POST['password'] != '12345' or in_array($_SERVER['REMOTE_ADDR'], $restrictedIps, true))
 message('Access denied');

$_SESSION['admin'] = 1;
go('a_home');

}

?>
- korey.Gulgows commented on April 7th 20 at 10:54
@korey.Gulgows, IP-shnik the outside, it's like...
Oh, I thought you found a mistake. put a "not" before "in_array":
if ( $_POST['password'] != '12345' or !in_array($_SERVER['REMOTE_ADDR'], $restrictedIps, true))

of course, if PHP allows you to do that, I don't know... - lee.McLaughlin commented on April 7th 20 at 10:57
@lee.McLaughlin, yeah, got it right. You need to put !in_array and then it is desirable to rename $restrictedIps for $allowedIps. - dawn.Schmidt commented on April 7th 20 at 11:00
@dawn.Schmidt, fix Everything, but it gives the same error.
<?

if ($_POST['login_f']) {

captcha_valid();

$allowedIps = ['77.111.245.74', '176.52.33.20'];
if ( $_POST['password'] != '12345' or !in_array($_SERVER['REMOTE_ADDR'], $allowedIps, true))
 message('Access denied');

$_SESSION['admin'] = 1;

go('a_home');

}

?>
- korey.Gulgows commented on April 7th 20 at 11:03
@dawn.Schmidt, Everything works. It turns out that I have just changed IP address. And that was the whole problem. - korey.Gulgows commented on April 7th 20 at 11:06

Find more questions by tags PHP