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

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.

4 calls to spambot_check_whitelist()
SpambotUserspamForm::checkSubmit in src/Form/SpambotUserspamForm.php
Function provide functional for "Check" button.
SpamBotWebformHandler::validateForm in src/Plugin/WebformHandler/SpamBotWebformHandler.php
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 385

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;
}