我使用此代码在每一方都有一个js弹出窗口,告诉访问者该商店效率不高:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip == 'xxx.xxx.xxx.xxx' OR $ip == 'xxx.xxx.xxx.xx') { ?>
You are a developer
<?php } else { ?>
You are a visitor
<?php } ?>
我的问题是,如何在此代码中使用magento后端的开发人员Ip - &gt;系统 - &gt;配置 - &gt;开发者 - &gt;开发人员客户端限制
答案 0 :(得分:12)
你可以像任何其他配置值一样得到它
Mage::getStoreConfig('dev/restrict/allow_ips', $storeId)
Mage::getStoreConfig('dev/restrict/allow_ips')
然后
或只是
<?php $isDeveloper = (strstr(Mage::getStoreConfig('dev/restrict/allow_ips', $storeId), Mage::helper('core/http')->getRemoteAddr())) ? true : false; ?>
或者只是(正如MagePsycho在评论中指出的那样)
if(Mage::helper('core')->isDevAllowed()){ }
答案 1 :(得分:0)
<?php
$allowedIps = Mage::getStoreConfig('dev/restrict/allow_ips', $storeId);
$remoteAddr = Mage::helper('core/http')->getRemoteAddr();
if (!empty($allowedIps) && !empty($remoteAddr)) {
$allowedIps = preg_split('#\s*,\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY);
if (array_search($remoteAddr, $allowedIps) === false
&& array_search(Mage::helper('core/http')->getHttpHost(), !$allowedIps) === false) {
?>
You are a visitor
<?php } else { ?>
You are a developer
<?php } ?>
<?php } ?>