Difference between revisions of "How to restrict access to admin interface by certain IP address"

From aMember Pro Documentation
Jump to: navigation, search
(Created page with "Create /amember/application/configs/site.php with this code: <source> <?php class Am_Controller_CheckIp extends Zend_Controller_Plugin_Abstract { public function preDispatc...")
 
Line 1: Line 1:
Create /amember/application/configs/site.php with this code:  
+
Add this code to [[site.php file]]:
 
+
 
<source>
 
<source>
 
<?php
 
<?php

Revision as of 03:41, 9 August 2013

Add this code to site.php file:

<?php
class Am_Controller_CheckIp extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        if (stripos($this->getRequest()->getControllerName(), 'admin')===0)
        {
            if ($_SERVER['REMOTE_ADDR']!='127.0.0.1') die('Access Denied');
        }
    }
}
 
Zend_Controller_Front::getInstance()->registerPlugin(new Am_Controller_CheckIp, 500);