Skip to content

Instantly share code, notes, and snippets.

@lyquix-owner
lyquix-owner / ip-check-allowed.php
Last active September 19, 2024 01:20
PHP function to check if it matches allowed IP addresses and subnets
<?php
// IP to check
$ip_check = $_SERVER['REMOTE_ADDR'];
// Array of allowed IPs and subnets, both IPv4 and IPv6
$ips_allowed = array(
'192.30.252.0/22'
'2620:112:3000::/44'
'192.168.16.104'
);