english/libraries/joomla/html/html/email.php
/**
	* Simple Javascript email Cloaker
	*
	* By default replaces an email with a mailto link with email cloacked
	*/
Simple Javascript email Cloaker
By default replaces an email with a mailto link with email cloacked
Simple Javascript email Cloaker By default replaces an email with a mailto link with email cloacked
public static function cloak($mail, $mailto=1, $text='', $email=1)
	{
		$mail			= JHtmlEmail::_convertEncoding($mail);
		$mail			= explode('@', $mail);
		$mail_parts		= explode('.', $mail[1]);
		$rand			= rand(1, 100000);
		$replacement	= "\n <script type='text/javascript'>";
		$replacement	.= "\n <!--";
		$replacement	.= "\n var prefix = '&#109;a' + 'i&#108;' + '&#116;o';";
		$replacement	.= "\n var path = 'hr' + 'ef' + '=';";
		$replacement	.= "\n var addy". $rand ." = '". @$mail[0] ."' + '&#64;';";
		$replacement	.= "\n addy". $rand ." = addy". $rand ." + '". implode("' + '&#46;' + '", $mail_parts) ."';";
		if ($mailto) {
			if ($text) {
				if ($email) {
					$text			= JHtmlEmail::_convertEncoding($text);
					$text			= explode('@', $text);
					$text_parts		= explode('.', $text[1]);
					$replacement	.= "\n var addy_text". $rand ." = '". @$text[0] ."' + '&#64;' + '". implode("' + '&#46;' + '", @$text_parts) ."';";
				} else {
					$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>');";
			} else {
				$replacement	.= "\n document.write('<a ' + path + '\'' + prefix + ':' + addy". $rand ." + '\'>');";
				$replacement	.= "\n document.write(addy". $rand .");";
				$replacement	.= "\n document.write('<\/a>');";
			}
		} else {
			$replacement	.= "\n document.write(addy". $rand .");";
		}
		$replacement	.= "\n //-->";
		$replacement	.= '\n </script>';
		$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>";
		return $replacement;
	}
public static function cloak ( $ mail , $ mailto = 1 , $ text = '' , $ email = 1 ) { $ mail = JHtmlEmail :: _convertEncoding ( $ mail ) ; $ mail = explode ( '@' , $ mail ) ; $ mail_parts = explode ( '.' , $ mail [ 1 ] ) ; $ rand = rand ( 1 , 100000 ) ; $ replacement = " \n  <script type='text/javascript'> " ; $ replacement .= " \n  <!-- " ; $ replacement .= " \n  var prefix = '&#109;a' + 'i&#108;' + '&#116;o'; " ; $ replacement .= " \n  var path = 'hr' + 'ef' + '='; " ; $ replacement .= " \n  var addy " . $ rand . "  = ' " . @ $ mail [ 0 ] . " ' + '&#64;'; " ; $ replacement .= " \n  addy " . $ rand . "  = addy " . $ rand . "  + ' " . implode ( " ' + '&#46;' + ' " , $ mail_parts ) . " '; " ; if ( $ mailto ) { if ( $ text ) { if ( $ email ) { $ text = JHtmlEmail :: _convertEncoding ( $ text ) ; $ text = explode ( '@' , $ text ) ; $ text_parts = explode ( '.' , $ text [ 1 ] ) ; $ replacement .= " \n  var addy_text " . $ rand . "  = ' " . @ $ text [ 0 ] . " ' + '&#64;' + ' " . implode ( " ' + '&#46;' + ' " , @ $ text_parts ) . " '; " ; } else { $ 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>'); " ; } else { $ replacement .= " \n  document.write('<a ' + path + '\'' + prefix + ':' + addy " . $ rand . "  + '\'>'); " ; $ replacement .= " \n  document.write(addy " . $ rand . " ); " ; $ replacement .= " \n  document.write('<\/a>'); " ; } } else { $ replacement .= " \n  document.write(addy " . $ rand . " ); " ; } $ replacement .= " \n  //--> " ; $ replacement .= '\n </script>' ; $ 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> " ; return $ replacement ; }
Simple Javascript email Cloaker
 By default replaces an email with a mailto link with email cloacked
Simple Javascript email Cloaker By default replaces an email with a mailto link with email cloacked
// Convert text // Split email by @ symbol // Random number // Special handling when mail text is different from mail addy // Convert text // Split email by @ symbol // XHTML compliance no Javascript text handling