网站开发 · 2025年4月26日

限制zencart网站后台只有在特定的IP才能访问

为了zencart网站的数据安全,想要限制zen cart网站的后台只有特定IP才能登陆访问。我写了一个简单的代码,可以将这个代码添加到login.php的头部,当然也可以放在application_top.php的前几行。

/**
* limit zen cart admin backend only available to specified ips
*
* @author george zheng 
* @date 09/05/2012
*/

$ip=’192.168.0.11′;
if ($_SERVER[‘REMOTE_ADDR’] != $ip) {
die(‘You are not permitted to admin backend’);
}

$ips=array(
‘192.168.0.11’,
‘192.168.0.12’
);
if (count($ips) && !in_array($_SERVER[‘REMOTE_ADDR’],$ips)) {
die(‘You are not permitted to admin backend’);
}
?>

注:使用这个代码,如果没有设定任何IP,则默认所有的IP都可以访问登陆zen cart网站后台。