时间:2021-07-01 10:21:17 帮助过:10人阅读
输出页面,反之拒绝访问。
<?php
$IP = $_SERVER['REMOTE_ADDR'];
$from = strcmp($IP,'192.168.0.0');
$to = strcmp($IP,'192.168.0.255');
if (!($from >= 0 && $to <= 0))
echo "Access Denied";
else
echo "Homepage";
?>
从流程上讲,这段代码首先捕获访客 IP 地址,然后判断该 IP 地址是否符合访问条件。符合则正常
<?php
if (!($from >= 0 && $to <= 0))
echo "Access Denied";
else
include('homepage.html')";
?>
当然,也可以按判断结果跳转至不同页面。跳转代码如下:
代码如下:
<?php
if (!($from >= 0 && $to <= 0))
header('Location: //www.gxlcms.com/404.html');
else
header('Location: //www.gxlcms.com/index.html');
?>