This post has been archived
The content of this post has not been updated since 2015, and may be out of date. Extra care should be taken with any code provided.
The opposite requires a simple exclamation mark before in_array() to change the script so that only those listed in the array will be allowed to see the site. Anything below this code will only be accessible IPs is in the array.
$valid_ips = array('123.123.123.123','32.23.13.31','123.45.678.90'); if (in_array($_SERVER['REMOTE_ADDR'],$valid_ips)) { echo "You do have permission to see this text"; die(); }
This is a useful script to add at the start of any PHP file which you want hidden from a specific IP address or addresses. Anything below this first script will be hidden from anyone listed in the $valid_ips array.
$valid_ips = array('123.123.123.123','32.23.13.31','123.45.678.90'); if (!in_array($_SERVER['REMOTE_ADDR'],$valid_ips)) { echo "You do not have permission to see this text"; die(); }
June 2024
Here’s detailed look at some of the most popular PHP frameworks, each of which can help speed up development, improve code organisation, and enhance application...
March 2024
As PHP continues to evolve, so do the threats that target its vulnerabilities. Ensuring robust PHP security practices is paramount to safeguarding sensitive data and...
→ Continue reading"PHP Security in 2024: navigating the evolving landscape"
December 2022
Laravel is a powerful and popular PHP framework designed to make web development easier and more efficient. This quick start guide will help you set...
→ Continue reading"Quick start guide for Laravel on a PHP server"