Esempio n. 1
0
 protected function set_permissions($saved = false)
 {
     //IP Address Blacklist
     Loader::model('user_banned_ip');
     $ip_ban_enable_lock_ip_after = Config::get('IP_BAN_LOCK_IP_ENABLE');
     $ip_ban_enable_lock_ip_after = $ip_ban_enable_lock_ip_after == 1 ? 1 : 0;
     $ip_ban_lock_ip_after_attempts = Config::get('IP_BAN_LOCK_IP_ATTEMPTS');
     $ip_ban_lock_ip_after_time = Config::get('IP_BAN_LOCK_IP_TIME');
     $ip_ban_lock_ip_how_long_min = Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') ? Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') : '';
     if (!$ip_ban_lock_ip_how_long_min) {
         $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER;
     } else {
         $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED;
     }
     $user_banned_ip = new UserBannedIP();
     //pull all once filter various lists using code
     $user_banned_ips = $user_banned_ip->Find('1=1');
     $user_banned_manual_ips = array();
     $user_banned_limited_ips = array();
     foreach ($user_banned_ips as $user_banned_ip) {
         if ($user_banned_ip->isManual == 1) {
             $user_banned_manual_ips[] = $user_banned_ip->getIPRangeForDisplay();
         } else {
             if ($user_banned_ip->expires - time() > 0 || $user_banned_ip->expires == 0) {
                 $user_banned_limited_ips[] = $user_banned_ip;
             }
         }
     }
     $user_banned_manual_ips = join($user_banned_manual_ips, "\n");
     $this->set('user_banned_manual_ips', $user_banned_manual_ips);
     $this->set('user_banned_limited_ips', $user_banned_limited_ips);
     $this->set('ip_ban_enable_lock_ip_after', $ip_ban_enable_lock_ip_after);
     $this->set('ip_ban_lock_ip_after_attempts', $ip_ban_lock_ip_after_attempts);
     $this->set('ip_ban_lock_ip_after_time', $ip_ban_lock_ip_after_time);
     $this->set('ip_ban_change_makeperm', self::IP_BLACKLIST_CHANGE_MAKEPERM);
     $this->set('ip_ban_change_remove', self::IP_BLACKLIST_CHANGE_REMOVE);
     $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type);
     $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type);
     $this->set('ip_ban_lock_ip_how_long_type_forever', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER);
     $this->set('ip_ban_lock_ip_how_long_type_timed', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED);
     $this->set('ip_ban_lock_ip_how_long_min', $ip_ban_lock_ip_how_long_min);
     //maintanence mode
     $site_maintenance_mode = Config::get('SITE_MAINTENANCE_MODE');
     if ($site_maintenance_mode < 1) {
         $site_maintenance_mode = 0;
     }
     $this->set('site_maintenance_mode', $site_maintenance_mode);
     $this->set('user_banned_ips', $user_banned_ips);
     if ($saved) {
         switch ($saved) {
             case "maintenance_enabled":
                 $this->set('message', t('Maintenance Mode turned on. Your site is now private.'));
                 break;
             case "maintenance_disabled":
                 $this->set('message', t('Maintenance Mode turned off. Your site is public.'));
                 break;
             case "saved_ipblacklist":
                 $this->set('message', t('IP Blacklist Settings Updated'));
                 break;
                 //permissions saved
             //permissions saved
             default:
                 $this->set('message', t('Permissions saved.'));
         }
     }
     if (PERMISSIONS_MODEL != 'simple') {
         return;
     }
     $home = Page::getByID(1, "RECENT");
     $gl = new GroupList($home, false, true);
     $gArrayTmp = $gl->getGroupList();
     $gArray = array();
     foreach ($gArrayTmp as $gi) {
         if ($gi->getGroupID() == GUEST_GROUP_ID) {
             $ggu = $gi;
             if ($ggu->canRead()) {
                 $this->set('guestCanRead', true);
             }
         } else {
             if ($gi->getGroupID() == REGISTERED_GROUP_ID) {
                 $gru = $gi;
                 if ($gru->canRead()) {
                     $this->set('registeredCanRead', true);
                 }
             } else {
                 $gArray[] = $gi;
             }
         }
     }
     $this->set('ggu', $ggu);
     $this->set('gru', $gru);
     $this->set('gArray', $gArray);
     $this->set('home', $home);
 }
Esempio n. 2
0
 public function view()
 {
     //IP Address Blacklist
     Loader::model('user_banned_ip');
     $ip_ban_enable_lock_ip_after = Config::get('IP_BAN_LOCK_IP_ENABLE');
     $ip_ban_enable_lock_ip_after = $ip_ban_enable_lock_ip_after == 1 ? 1 : 0;
     $ip_ban_lock_ip_after_attempts = Config::get('IP_BAN_LOCK_IP_ATTEMPTS');
     $ip_ban_lock_ip_after_time = Config::get('IP_BAN_LOCK_IP_TIME');
     $ip_ban_lock_ip_how_long_min = Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') ? Config::get('IP_BAN_LOCK_IP_HOW_LONG_MIN') : '';
     if (!$ip_ban_lock_ip_how_long_min) {
         $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER;
     } else {
         $ip_ban_lock_ip_how_long_type = self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED;
     }
     $user_banned_ip = new UserBannedIP();
     //pull all once filter various lists using code
     $user_banned_ips = $user_banned_ip->Find('1=1');
     $user_banned_manual_ips = array();
     $user_banned_limited_ips = array();
     foreach ($user_banned_ips as $user_banned_ip) {
         if ($user_banned_ip->isManual == 1) {
             $user_banned_manual_ips[] = $user_banned_ip->getIPRangeForDisplay();
         } else {
             if ($user_banned_ip->expires - time() > 0 || $user_banned_ip->expires == 0) {
                 $user_banned_limited_ips[] = $user_banned_ip;
             }
         }
     }
     $user_banned_manual_ips = join($user_banned_manual_ips, "\n");
     $this->set('user_banned_manual_ips', $user_banned_manual_ips);
     $this->set('user_banned_limited_ips', $user_banned_limited_ips);
     $this->set('ip_ban_enable_lock_ip_after', $ip_ban_enable_lock_ip_after);
     $this->set('ip_ban_lock_ip_after_attempts', $ip_ban_lock_ip_after_attempts);
     $this->set('ip_ban_lock_ip_after_time', $ip_ban_lock_ip_after_time);
     $this->set('ip_ban_change_makeperm', self::IP_BLACKLIST_CHANGE_MAKEPERM);
     $this->set('ip_ban_change_remove', self::IP_BLACKLIST_CHANGE_REMOVE);
     $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type);
     $this->set('ip_ban_lock_ip_how_long_type', $ip_ban_lock_ip_how_long_type);
     $this->set('ip_ban_lock_ip_how_long_type_forever', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_FOREVER);
     $this->set('ip_ban_lock_ip_how_long_type_timed', self::IP_BAN_LOCK_IP_HOW_LONG_TYPE_TIMED);
     $this->set('ip_ban_lock_ip_how_long_min', $ip_ban_lock_ip_how_long_min);
     $this->set('user_banned_ips', $user_banned_ips);
 }