问题描述
|
我使用此代码在每侧都有一个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
->系统->配置->开发人员->开发人员客户端限制
解决方法
您可以像获取其他任何配置值一样获得此信息
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()){ }
, <?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 } ?>
, 尝试跟随
Mage::getStoreConfig(\'dev/restrict/allow_ips\');