Source for file email.php
Documentation is available at email.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Utility class for cloaking email addresses
* @package Joomla.Libraries
* Simple JavaScript email cloaker
* By default replaces an email with a mailto link with email cloaked
* @param string $mail The -mail address to cloak.
* @param boolean $mailto True if text and mailing address differ
* @param string $text Text for the link
* @param boolean $email True if text is an e-mail address
* @return string The cloaked email.
public static function cloak($mail, $mailto =
true, $text =
'', $email =
true)
$mail =
static::convertEncoding($mail);
// Split email by @ symbol
$mail_parts =
explode('.', $mail[1]);
$replacement =
"<script type='text/javascript'>";
$replacement .=
"\n <!--";
$replacement .=
"\n var prefix = 'ma' + 'il' + 'to';";
$replacement .=
"\n var path = 'hr' + 'ef' + '=';";
$replacement .=
"\n var addy" .
$rand .
" = '" .
@$mail[0] .
"' + '@';";
$replacement .=
"\n addy" .
$rand .
" = addy" .
$rand .
" + '" .
implode("' + '.' + '", $mail_parts) .
"';";
// Special handling when mail text is different from mail address
$text =
static::convertEncoding($text);
// Split email by @ symbol
$text_parts =
explode('.', $text[1]);
$replacement .=
"\n var addy_text" .
$rand .
" = '" .
@$text[0] .
"' + '@' + '" .
implode("' + '.' + '", @$text_parts)
$replacement .=
"\n var addy_text" .
$rand .
" = '" .
$text .
"';";
$replacement .=
"\n document.write('<a ' + path + '\'' + prefix + ':' + addy" .
$rand .
" + '\'>');";
$replacement .=
"\n document.write(addy_text" .
$rand .
");";
$replacement .=
"\n document.write('<\/a>');";
$replacement .=
"\n document.write('<a ' + path + '\'' + prefix + ':' + addy" .
$rand .
" + '\'>');";
$replacement .=
"\n document.write(addy" .
$rand .
");";
$replacement .=
"\n document.write('<\/a>');";
$replacement .=
"\n document.write(addy" .
$rand .
");";
$replacement .=
"\n //-->";
$replacement .=
'\n </script>';
// XHTML compliance no Javascript text handling
$replacement .=
"<script type='text/javascript'>";
$replacement .=
"\n <!--";
$replacement .=
"\n document.write('<span style=\'display: none;\'>');";
$replacement .=
"\n //-->";
$replacement .=
"\n </script>";
$replacement .=
JText::_('JLIB_HTML_CLOAKING');
$replacement .=
"\n <script type='text/javascript'>";
$replacement .=
"\n <!--";
$replacement .=
"\n document.write('</');";
$replacement .=
"\n document.write('span>');";
$replacement .=
"\n //-->";
$replacement .=
"\n </script>";
* @param string $text Text to convert
* @return string The converted text.
// Replace vowels with character encoding
Documentation generated on Tue, 19 Nov 2013 15:02:25 +0100 by phpDocumentor 1.4.3