You are here

function _invisimail_encode_string in Invisimail 6

Performs ASCII encoding on the provided string.

Parameters

string $string:

bool $js:

Return value

string

3 calls to _invisimail_encode_string()
invisimail_ascii_encode in ./invisimail.module
ASCII-encode an email address.
invisimail_callback in ./invisimail.module
Callback function used by preg_replace_callback.
invisimail_encode_add_link in ./invisimail.module

File

./invisimail.module, line 291
This module provides a filter that will search content for email addresses and replace them with their ascii equivalents before display. This is not a complete protection from spam harvesters, but it is some help.

Code

function _invisimail_encode_string($string, $js, $link = FALSE) {
  $encode = '';
  for ($i = 0; $i < strlen($string); $i++) {
    $char = substr($string, $i, 1);
    $encode .= '&#' . ord($char) . ';';
    if ($js && $link) {
      if (in_array($char, array(
        '.',
        '@',
      ))) {

        // break strings after ats and dots.
        $encode .= "'+'";
      }
    }
  }
  return $encode;
}