首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何获取magento开发者ip?

问如何获取magento开发者ip?
EN

Stack Overflow用户
提问于 2011-06-01 16:55:48
回答 3查看 3K关注 0票数 0

我使用这段代码在两边都有一个js弹出窗口,告诉访问者商店没有生产力:

代码语言:javascript
复制
<?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后端的developer Ip ->System -> Configuration -> Developer -> Developer客户端限制

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-06-01 18:23:37

您可以像获取任何其他配置值一样获取该值

代码语言:javascript
复制
Mage::getStoreConfig('dev/restrict/allow_ips', $storeId)
Mage::getStoreConfig('dev/restrict/allow_ips')

然后

或者只是

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

或者只是(正如MagePsycho在评论中指出的那样)

代码语言:javascript
复制
if(Mage::helper('core')->isDevAllowed()){ } 
票数 12
EN

Stack Overflow用户

发布于 2011-06-02 01:18:45

代码语言:javascript
复制
<?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 } ?>
票数 0
EN

Stack Overflow用户

发布于 2015-08-25 17:15:55

请尝试以下操作

代码语言:javascript
复制
Mage::getStoreConfig('dev/restrict/allow_ips');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6198589

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档