开发者

How to get the magento developer ip?

I use this code to have a js popup on each side telling visitors that the shop is not productive:

<?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 vis开发者_StackOverflow社区itor
<?php } ?>

My question is, how can I use the developer Ip from the magento backend in this code ->System -> Configuration -> Developer -> Developer Client Restrictions


you can get this like any other config value

Mage::getStoreConfig('dev/restrict/allow_ips', $storeId)
Mage::getStoreConfig('dev/restrict/allow_ips')

and then

or just

<?php $isDeveloper = (strstr(Mage::getStoreConfig('dev/restrict/allow_ips', $storeId), Mage::helper('core/http')->getRemoteAddr())) ? true : false; ?>

or just (as pointed by MagePsycho in comments)

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 } ?>


Try following

Mage::getStoreConfig('dev/restrict/allow_ips');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜