You are here

function invisimail_encode_html in Invisimail 7

Translates a string into its HTML entity version.

Unlike PHP's htmlentities() and htmlspecialchars() functions, this function will convert all characters in the string unequivocably. That makes it useful for obfuscation, since browsers will treat the string exactly the same but most humans and spambots won't have a clue how to read it.

Parameters

string $string: An arbitrary string to encode as HTML entities.

Return value

string The same string encoded in raw, obfuscated HTML entities.

2 calls to invisimail_encode_html()
invisimail_encoder_html_entities_encode in ./invisimail.module
Encoding callback for the html_entities encoder.
invisimail_encoder_js_entities_encode in ./invisimail.module
Encoding callback for the js_entities encoder.

File

./invisimail.module, line 365
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_html($string) {
  $encode = '';
  for ($i = 0; $i < strlen($string); $i++) {
    $char = substr($string, $i, 1);
    $encode .= '&#' . ord($char) . ';';
  }
  return $encode;
}