/** * 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. */ 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; }
function pluralCount($Count, $Type) { $PluralCodes = array('Activity' => '%s Activities'); $SingleCode = '%s ' . Gdn_Form::LabelCode($Type); return plural($Count, $SingleCode, val($Type, $PluralCodes, $SingleCode . 's')); }
?> </th> <th class="DateCell"><?php echo T('Applied On', 'Date'); ?> </th> </tr> </thead> <tbody> <?php foreach ($this->Data('Log') as $Row) { $RecordLabel = GetValueR('Data.Type', $Row); if (!$RecordLabel) { $RecordLabel = $Row['RecordType']; } $RecordLabel = Gdn_Form::LabelCode($RecordLabel); ?> <tr id="<?php echo "LogID_{$Row['LogID']}"; ?> "> <td class="CheckboxCell"><input type="checkbox" name="LogID[]" value="<?php echo $Row['LogID']; ?> " /></td> <td class="UsernameCell"><?php echo UserAnchor($Row, '', 'Insert'); if (!empty($Row['OtherUserIDs'])) { $OtherUserIDs = explode(',', $Row['OtherUserIDs']); echo ' ' . Plural(count($OtherUserIDs), 'and %s other', 'and %s others') . ' '; }
/** * 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. */ 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'; $value = val($Fields[$Ban['BanType']], $User); if ($Ban['BanType'] === 'IPAddress') { $value = ipDecode($value); } if (preg_match($Regex, $value)) { $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; }