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

@ -471,9 +471,28 @@ class adminAdminView extends admin
Context::set('sitelock_title', escape(Rhymix\Framework\Config::get('lock.title')));
Context::set('sitelock_message', escape(Rhymix\Framework\Config::get('lock.message')));
$allowed_ip = Rhymix\Framework\Config::get('lock.allow');
if (!in_array('127.0.0.1', $allowed_ip)) $allowed_ip[] = '127.0.0.1';
if (!in_array(RX_CLIENT_IP, $allowed_ip)) $allowed_ip[] = RX_CLIENT_IP;
$allowed_ip = Rhymix\Framework\Config::get('lock.allow') ?: array();
$allowed_localhost = false;
$allowed_current = false;
foreach ($allowed_ip as $range)
{
if (Rhymix\Framework\IpFilter::inRange('127.0.0.1', $range))
{
$allowed_localhost = true;
}
if (Rhymix\Framework\IpFilter::inRange(RX_CLIENT_IP, $range))
{
$allowed_current = true;
}
}
if (!$allowed_localhost)
{
array_unshift($allowed_ip, '127.0.0.1');
}
if (!$allowed_current)
{
array_unshift($allowed_ip, RX_CLIENT_IP);
}
Context::set('sitelock_allowed_ip', implode(PHP_EOL, $allowed_ip));
Context::set('remote_addr', RX_CLIENT_IP);

View file

@ -12,7 +12,7 @@
<label class="x_control-label">{$lang->use_sitelock} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_config_general_sitelock" target="_blank">{$lang->help}</a></label>
<div class="x_controls">
<label for="sitelock_locked_y" class="x_inline"><input type="radio" name="sitelock_locked" id="sitelock_locked_y" value="Y" checked="checked"|cond="$sitelock_locked" /> {$lang->cmd_yes}</label>
<label for="sitelock_locked_y" class="x_inline"><input type="radio" name="sitelock_locked" id="sitelock_locked_n" value="N" checked="checked"|cond="!$sitelock_locked" /> {$lang->cmd_no}</label>
<label for="sitelock_locked_n" class="x_inline"><input type="radio" name="sitelock_locked" id="sitelock_locked_n" value="N" checked="checked"|cond="!$sitelock_locked" /> {$lang->cmd_no}</label>
</div>
</div>