You are here

function spambot_check_whitelist in Spambot 8

Same name and namespace in other branches
  1. 7 spambot.module \spambot_check_whitelist()

Check if current data $type is whitelisted.

Parameters

string $type: Type can be one of these three values: 'ip', 'email' or 'username'.

object $config: Value for the configuration object.

string $value: Value to be checked.

Return value

bool TRUE if data is whitelisted, FALSE otherwise.

3 calls to spambot_check_whitelist()
SpambotUserspamForm::checkSubmit in src/Form/SpambotUserspamForm.php
Function provide functional for "Check" button.
spambot_account_is_spammer in ./spambot.module
Checks an account to see if it's a spammer.
spambot_user_register_form_validate in ./spambot.module
Validate callback for user_register form.

File

./spambot.module, line 387
Main module file.

Code

function spambot_check_whitelist($type, $config, $value) {
  switch ($type) {
    case 'ip':
      $whitelist_ips = $config
        ->get('spambot_whitelist_ip');
      $result = strpos($whitelist_ips, $value) !== FALSE;
      break;
    case 'email':
      $whitelist_usernames = $config
        ->get('spambot_whitelist_email');
      $result = strpos($whitelist_usernames, $value) !== FALSE;
      break;
    case 'username':
      $whitelist_emails = $config
        ->get('spambot_whitelist_username');
      $result = strpos($whitelist_emails, $value) !== FALSE;
      break;
    default:
      $result = FALSE;
      break;
  }
  return $result;
}