The localhost webpage should not display the HTML because in killed the page using die().
I can continue w/o sorting this but I am really curious. Lots of very good info came up as I searched this forum.
According to the tutorial that I am following, The page should die() and not display the words Welcome But it does display welcome at localhost/my website/
Index.php
<?php
require 'conf.inc.php';
foreach($ip_blocked as $ip){
if ($ip==$ip_address){
die();
}
}
?>
<h1> welcome</h1>
conf.inc.php
<?php
$ip_address = $_SERVER['REMOTE_ADDR'];
$ip_blocked = array('127,0,0,1', '100,100,100,100');
?>
Change
$ip_blocked = array('127,0,0,1', '100,100,100,100');
to
$ip_blocked = array('127.0.0.1', '100.100.100.100');
. instead of ,
$ip_blocked = array('127,0,0,1', '100,100,100,100');
should be
$ip_blocked = array('127.0.0.1', '100.100.100.100');
Notice the DOTs!
Plus you should not compare strings with IPs. Think IPs in terms of ranges, check against private IP addresses if you're on a network with a 192.168.*.*
IP address.
ip2long()
should be taken into consideration. Numbers compare faster than strings plus friendlier with range comparison (in between) .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.