/** * simple Javascript Cloaking * email cloacking * by default replaces an email with a mailto link with email cloacked */ function emailCloaking($mail, $mailto = 1, $text = '', $email = 1) { // convert text $mail = mosHTML::encoding_converter($mail); // split email by @ symbol $mail = explode('@', $mail); $mail_parts = explode('.', $mail[1]); // random number $rand = rand(1, 100000); $replacement = "\n<script language='JavaScript' type='text/javascript'> \n"; $replacement .= "<!-- \n"; $replacement .= "var prefix = 'ma' + 'il' + 'to'; \n"; $replacement .= "var path = 'hr' + 'ef' + '='; \n"; $replacement .= "var addy" . $rand . " = '" . @$mail[0] . "' + '@' + '" . implode("' + '.' + '", $mail_parts) . "'; \n"; if ($mailto) { // special handling when mail text is different from mail addy if ($text) { if ($email) { // convert text $text = mosHTML::encoding_converter($text); // split email by @ symbol $text = explode('@', $text); $text_parts = explode('.', $text[1]); $replacement .= "var addy_text" . $rand . " = '" . @$text[0] . "' + '@' + '" . implode("' + '.' + '", @$text_parts) . "'; \n"; } else { $text = mosHTML::encoding_converter($text); $replacement .= "var addy_text" . $rand . " = '" . $text . "';\n"; } $replacement .= "document.write( '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>' ); \n"; $replacement .= "document.write( addy_text" . $rand . " ); \n"; $replacement .= "document.write( '<\\/a>' ); \n"; } else { $replacement .= "document.write( '<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>' ); \n"; $replacement .= "document.write( addy" . $rand . " ); \n"; $replacement .= "document.write( '<\\/a>' ); \n"; } } else { $replacement .= "document.write( addy" . $rand . " ); \n"; } $replacement .= "//--> \n"; $replacement .= "</script> \n"; $replacement .= "<noscript> \n"; $replacement .= T_('This email address is being protected from spam bots, you need Javascript enabled to view it'); $replacement .= "\n</noscript> \n"; return $replacement; }
/** * simple Javascript Cloaking * email cloacking * by default replaces an email with a mailto link with email cloacked */ function emailCloaking($mail, $mailto = 1, $text = '', $email = 1) { // convert text $mail = mosHTML::encoding_converter($mail); // split email by @ symbol $mail = explode('@', $mail); $mail_parts = explode('.', $mail[1]); // random number $rand = rand(1, 100000); $replacement = "\n <script language='JavaScript' 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) . "';"; if ($mailto) { // special handling when mail text is different from mail addy if ($text) { if ($email) { // convert text $text = mosHTML::encoding_converter($text); // split email by @ symbol $text = explode('@', $text); $text_parts = explode('.', $text[1]); $replacement .= "\n var addy_text" . $rand . " = '" . @$text[0] . "' + '@' + '" . implode("' + '.' + '", @$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>'; // XHTML compliance `No Javascript` text handling $replacement .= "<script language='JavaScript' type='text/javascript'>"; $replacement .= "\n <!--"; $replacement .= "\n document.write( '<span style=\\'display: none;\\'>' );"; $replacement .= "\n //-->"; $replacement .= "\n </script>"; $replacement .= _CLOAKING; $replacement .= "\n <script language='JavaScript' type='text/javascript'>"; $replacement .= "\n <!--"; $replacement .= "\n document.write( '</' );"; $replacement .= "\n document.write( 'span>' );"; $replacement .= "\n //-->"; $replacement .= "\n </script>"; return $replacement; }