时间:2021-07-01 10:21:17 帮助过:8人阅读
输出页面,反之拒绝访问。
$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 地址是否符合访问条件。符合则正常
if (!($from >= 0 && $to <= 0))
echo "Access Denied";
else
include('homepage.html')";
?>
当然,也可以按判断结果跳转至不同页面。跳转代码如下:
代码如下:
if (!($from >= 0 && $to <= 0))
header('Location: http://www.gxlcms.com/404.html');
else
header('Location: http://www.gxlcms.com/index.html');
?>