Allow sitelock immediately after install (#160)

This commit is contained in:
Kijin Sung 2016-02-08 22:00:17 +09:00
parent 9e9b09464f
commit 605fdec1a2
10 changed files with 84 additions and 10 deletions

View file

@ -153,9 +153,31 @@ class installView extends install
// Always use SSL if installing via SSL.
Context::set('use_ssl', RX_SSL ? 'always' : 'none');
Context::set('sitelock_ip_range', $this->detectUserIPRange());
$this->setTemplateFile('other_config');
}
/**
* Detect the IP range of the user.
*/
function detectUserIPRange()
{
if (RX_CLIENT_IP_VERSION === 4)
{
return preg_replace('/\.\d+$/', '.*', RX_CLIENT_IP);
}
elseif (function_exists('inet_pton'))
{
$binary = inet_pton(RX_CLIENT_IP);
$binary = substr($binary, 0, 8) . str_repeat(chr(0), 8);
return inet_ntop($binary) . '/64';
}
else
{
return RX_CLIENT_IP;
}
}
/**
* Detect best time zone for the user.
*/