Restricting or allowing access by an IP address is an easy task. Here are a few examples. The code needs to be added to the beginning of the AfterAppInit event.
Note: This tutorial uses IPv4 addresses.
if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') exit();
Allow access from the list of approved IP addresses:
$array = array('127.0.0.1', '96.24.12.122', '96.24.12.123');
if (!in_array($_SERVER['REMOTE_ADDR'], $array)) exit();
Restrict access from a certain IP address:
if ($_SERVER['REMOTE_ADDR'] == '123.123.123.123') exit();
Restrict access from the list of addresses:
$array = array('127.0.0.1', '96.24.12.122', '96.24.12.123');
if (in_array($_SERVER['REMOTE_ADDR'], $array)) exit();
See also: