Esempio n. 1
0
function hocwp_get_safe_captcha_characters()
{
    $characters = hocwp_get_safe_characters();
    $excludes = array('b', 'd', 'e', 'i', 'j', 'l', 'o', 'w', 'B', 'D', 'E', 'I', 'J', 'L', 'O', 'W', '0', '1', '2', '8');
    $excludes = apply_filters('hocwp_exclude_captcha_characters', $excludes);
    $characters = str_replace($excludes, '', $characters);
    return $characters;
}
function hocwp_random_string($length = 10, $characters = '', $special_char = false)
{
    if (empty($characters)) {
        $characters = hocwp_get_safe_characters($special_char);
    }
    $len = strlen($characters);
    $result = '';
    for ($i = 0; $i < $length; $i++) {
        $random_char = $characters[rand(0, $len - 1)];
        $result .= $random_char;
    }
    return $result;
}