Skip to content

Instantly share code, notes, and snippets.

View rebelga's full-sized avatar

George rebelga

View GitHub Profile
@lyquix-owner
lyquix-owner / ip-check-allowed.php
Last active March 11, 2023 07:17
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'
);