Exemple #1
0
 public function validate($ip_list = array())
 {
     return Rhymix\Framework\Filters\IpFilter::validateRanges($ip_list);
 }
 /**
  * Update sitelock configuration.
  */
 function procAdminUpdateSitelock()
 {
     $vars = Context::gets('sitelock_locked', 'sitelock_allowed_ip', 'sitelock_title', 'sitelock_message');
     $allowed_ip = array_map('trim', preg_split('/[\\r\\n]/', $vars->sitelock_allowed_ip));
     $allowed_ip = array_unique(array_filter($allowed_ip, function ($item) {
         return $item !== '';
     }));
     if ($vars->sitelock_locked === 'Y') {
         if (!Rhymix\Framework\Filters\IpFilter::inRanges('127.0.0.1', $allowed_ip)) {
             array_unshift($allowed_ip, '127.0.0.1');
         }
         if (!Rhymix\Framework\Filters\IpFilter::inRanges(RX_CLIENT_IP, $allowed_ip)) {
             array_unshift($allowed_ip, RX_CLIENT_IP);
         }
     }
     if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) {
         return new Object(-1, 'msg_invalid_ip');
     }
     Rhymix\Framework\Config::set('lock.locked', $vars->sitelock_locked === 'Y');
     Rhymix\Framework\Config::set('lock.title', trim($vars->sitelock_title));
     Rhymix\Framework\Config::set('lock.message', trim($vars->sitelock_message));
     Rhymix\Framework\Config::set('lock.allow', array_values($allowed_ip));
     Rhymix\Framework\Config::save();
     $this->setMessage('success_updated');
     $this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSitelock'));
 }