Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify list of IPs in a body on maintenance.flag which will be granted access even if the flag is on #454

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,25 @@
}

if (!defined('BARE_BOOTSTRAP')) {
if (file_exists(BP . '/maintenance.flag')) {
if (PHP_SAPI == 'cli') {
echo 'Service temporarily unavailable due to maintenance downtime.';
} else {
include_once BP . '/pub/errors/503.php';
$maintenanceFile = BP . '/maintenance.flag';

if (file_exists($maintenanceFile)) {

$ips_file = BP . '/app/etc/allowed_ips.xml';
$allowedIps = array();
if (file_exists($ips_file)) {
$allowedIps = (array) simplexml_load_file($ips_file);
$allowedIps = array_map('trim', array_pop($allowedIps));
}

if (!in_array($_SERVER['REMOTE_ADDR'], $allowedIps)) {
if (PHP_SAPI == 'cli') {
echo 'Service temporarily unavailable due to maintenance downtime.';
} else {
include_once BP . '/pub/errors/503.php';
}
exit;
}
exit;
}

if (!empty($_SERVER['MAGE_PROFILER'])) {
Expand Down