applications/dashboard/models/class.banmodel.php
public static function CheckUser($User, $Validation = NULL, $UpdateBlocks = FALSE, &$BansFound = NULL) {
      $Bans = self::AllBans();
      $Fields = array('Name' => 'Name', 'Email' => 'Email', 'IPAddress' => 'LastIPAddress');
      $Banned = array();
      
      if (!$BansFound)
         $BansFound = array();

      foreach ($Bans as $Ban) {
         // Convert ban to regex.
         $Parts = explode('*', str_replace('%', '*', $Ban['BanValue']));
         $Parts = array_map('preg_quote', $Parts);
         $Regex = '`^'.implode('.*', $Parts).'$`i';

         if (preg_match($Regex, GetValue($Fields[$Ban['BanType']], $User))) {
            $Banned[$Ban['BanType']] = TRUE;
            $BansFound[] = $Ban;

            if ($UpdateBlocks) {
               Gdn::SQL()
                  ->Update('Ban')
                  ->Set('CountBlockedRegistrations', 'CountBlockedRegistrations + 1', FALSE, FALSE)
                  ->Where('BanID', $Ban['BanID'])
                  ->Put();
            }
         }
      }

      // Add the validation results.
      if ($Validation) {
         foreach ($Banned as $BanType => $Value) {
            $Validation->AddValidationResult(Gdn_Form::LabelCode($BanType), 'ValidateBanned');
         }
      }
      return count($Banned) == 0;
   }
public static function CheckUser($User, $Validation = NULL, $UpdateBlocks = FALSE, &$BansFound = NULL) {
      $Bans = self::AllBans();
      $Fields = array('Name' => 'Name', 'Email' => 'Email', 'IPAddress' => 'LastIPAddress');
      $Banned = array();
      
      if (!$BansFound)
         $BansFound = array();

      foreach ($Bans as $Ban) {
         // Convert ban to regex.
         $Parts = explode('*', str_replace('%', '*', $Ban['BanValue']));
         $Parts = array_map('preg_quote', $Parts);
         $Regex = '`^'.implode('.*', $Parts).'$`i';

         if (preg_match($Regex, GetValue($Fields[$Ban['BanType']], $User))) {
            $Banned[$Ban['BanType']] = TRUE;
            $BansFound[] = $Ban;

            if ($UpdateBlocks) {
               Gdn::SQL()
                  ->Update('Ban')
                  ->Set('CountBlockedRegistrations', 'CountBlockedRegistrations + 1', FALSE, FALSE)
                  ->Where('BanID', $Ban['BanID'])
                  ->Put();
            }
         }
      }

      // Add the validation results.
      if ($Validation) {
         foreach ($Banned as $BanType => $Value) {
            $Validation->AddValidationResult(Gdn_Form::LabelCode($BanType), 'ValidateBanned');
         }
      }
      return count($Banned) == 0;
   }
public static function CheckUser ( $ User , $ Validation = NULL , $ UpdateBlocks = FALSE , & $ BansFound = NULL ) { $ Bans = self :: AllBans ( ) ; $ Fields = array ( 'Name' => 'Name' , 'Email' => 'Email' , 'IPAddress' => 'LastIPAddress' ) ; $ Banned = array ( ) ; if ( ! $ BansFound ) $ BansFound = array ( ) ; foreach ( $ Bans as $ Ban ) { // Convert ban to regex. $ Parts = explode ( '*' , str_replace ( '%' , '*' , $ Ban [ 'BanValue' ] ) ) ; $ Parts = array_map ( 'preg_quote' , $ Parts ) ; $ Regex = '`^' . implode ( '.*' , $ Parts ) . '$`i' ; if ( preg_match ( $ Regex , GetValue ( $ Fields [ $ Ban [ 'BanType' ] ] , $ User ) ) ) { $ Banned [ $ Ban [ 'BanType' ] ] = TRUE ; $ BansFound [ ] = $ Ban ; if ( $ UpdateBlocks ) { Gdn :: SQL ( ) -> Update ( 'Ban' ) -> Set ( 'CountBlockedRegistrations' , 'CountBlockedRegistrations + 1' , FALSE , FALSE ) -> Where ( 'BanID' , $ Ban [ 'BanID' ] ) -> Put ( ) ; } } } // Add the validation results. if ( $ Validation ) { foreach ( $ Banned as $ BanType => $ Value ) { $ Validation -> AddValidationResult ( Gdn_Form :: LabelCode ( $ BanType ) , 'ValidateBanned' ) ; } } return count ( $ Banned ) == 0 ; }
Add ban data to all Get requests.

@since 2.0.18
@access public

@param mixed User data (array or object).
@param Gdn_Validation $Validation
@param bool $UpdateBlocks
@return bool Whether user is banned.
Add ban data to all Get requests .