<?php
$ip_addresses = explode("\n", file_get_contents(dirname(__FILE__) . '/ips.txt'); // Read the file and split it up by a new line making it an array.
$curIP = $_SERVER['REMOTE_ADDR']; // We get the visitor's IP
if (!in_array($curIP, $ip_addresses)) // Checks if the visitor's IP is white listed.
{
header('location: /'; // We redirect him to the home page of the site.
die ('You are not allowed to visit this part of the site.'; // We make the script die so other php code does not get executed.
}
<?php
$ip_addresses = explode("\n", file_get_contents(dirname(__FILE__) . '/ips.txt'); // Read the file and split it up by a new line making it an array.
$curIP = $_SERVER['REMOTE_ADDR']; // We get the visitor's IP
if (!in_array($curIP, $ip_addresses)) // Checks if the visitor's IP is white listed.
{
header('location: /'; // We redirect him to the home page of the site.
die ('You are not allowed to visit this part of the site.'; // We make the script die so other php code does not get executed.
}
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.