Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Created December 7, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molotovbliss/16a36c803f3f01cf22359d0d58b80c44 to your computer and use it in GitHub Desktop.
Save molotovbliss/16a36c803f3f01cf22359d0d58b80c44 to your computer and use it in GitHub Desktop.
Maintenance flag bypass via IP whitelist file var/maintenance-whitelist.txt for Magento v1.x
if (file_exists($maintenanceFile)) {
$whitelistIps = [];
if (file_exists('var/maintenance-whitelist.txt')) {
$whitelistIps = explode("\n", trim(file_get_contents('var/maintenance-whitelist.txt')));
$whitelistIps = array_map(function($value) {
return preg_replace('%^\s*([0-9\.]+).*$%', '$1', $value);
}, $whitelistIps);
}
if (!in_array($_SERVER['REMOTE_ADDR'], $whitelistIps)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment