Hy.
Since now many internet providers work with dynamic IP's is very difficult for a developer to allow a client the changes that he made on his store and keep it in maintenance mode for visitor.
Trying to solve this I found this solution so you can allow access via token and ip in the same time.
This was tested on prestashop 1.6.1.11
Go to ./classes/controller/FrontController.php
Line: 751
Replace:
if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) {
header('HTTP/1.1 503 temporarily overloaded');
$this->context->smarty->assign($this->initLogoAndFavicon());
$this->context->smarty->assign(array(
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
));
// If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller
$front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this;
$this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl'));
exit;
}
with this:
(where "passman" is the parameter that will be passed in url
session_start();
if(isset($_GET['passman'])){$_SESSION['passman'] = $_GET['passman'];}
if (isset($_SESSION['passman'])){
if(!in_array($_SESSION['passman'], explode(',', Configuration::get('PS_MAINTENANCE_IP')))){
header('HTTP/1.1 503 temporarily overloaded');
$this->context->smarty->assign($this->initLogoAndFavicon());
$this->context->smarty->assign(array(
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
));
// If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller
$front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this;
$this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl'));
exit;
}
}else if (!in_array(Tools::getRemoteAddr(), explode(',', Configuration::get('PS_MAINTENANCE_IP')))) {
header('HTTP/1.1 503 temporarily overloaded');
$this->context->smarty->assign($this->initLogoAndFavicon());
$this->context->smarty->assign(array(
'HOOK_MAINTENANCE' => Hook::exec('displayMaintenance', array()),
));
// If the controller is a module, then getTemplatePath will try to find the template in the modules, so we need to instanciate a real frontcontroller
$front_controller = preg_match('/ModuleFrontController$/', get_class($this)) ? new FrontController() : $this;
$this->smartyOutputContent($front_controller->getTemplatePath($this->getThemeDir().'maintenance.tpl'));
exit;
}
At this point you can go to: Preferences>Maintenance and add to the list a token (string) that can be passed as a parameter and that allow you to pass the maintenance page. As showed int the picture below you can also add an IP to the list.
So now you can pass maintenance mode by accessing:
http://www.yoursorename.com/?passman=allowusertoken
You can send this link to anyone and that person can see the live store skipping the maintenance page.