/** * simple Javascript Cloaking * email cloacking * by default replaces an email with a mailto link with email cloacked */ static function emailCloaking($mail, $mailto = 1, $text = '', $email = 1, $cloaktext = true) { global $_CB_framework; static $spanId = null; if ($spanId == null) { $spanId = rand(1, 100000); } else { $spanId += 1; } // convert text $mail = moscomprofilerHTML::encoding_converter($mail); // split email by @ symbol $mail = explode('@', $mail); if (count($mail) > 1) { $mail_parts = explode('.', $mail[1]); } else { $mail_parts = array(''); } // random number $rand = rand(1, 100000); $replacement = '<span id="cbMa' . $spanId . '" class="cbMailRepl">...</span>'; $js = ' {' . "\n\t\tvar prefix='ma'+'il'+'to';" . "\n\t\tvar path = 'hr'+ 'ef'+'=';" . "\n\t\tvar addy" . $rand . "= '" . @$mail[0] . "'+ '@' +'" . implode("' + '.' + '", $mail_parts) . "';"; if ($mailto) { // special handling when mail text is different from mail addy if ($text) { if ($cloaktext) { if ($email) { // convert text $text = moscomprofilerHTML::encoding_converter($text); // split email by @ symbol $text = explode('@', $text); $text_parts = explode('.', $text[1]); $js .= "\n\t\tvar addy_text" . $rand . " = '" . @$text[0] . "' + '@' + '" . implode("' + '.' + '", @$text_parts) . "';"; } else { $text = moscomprofilerHTML::encoding_converter($text); $js .= "\n\t\tvar addy_text" . $rand . " = '" . $text . "';"; } } else { $js .= "\n\t\tvar addy_text" . $rand . " = '" . $text . "';"; } $js .= "\n\t\t\$('#cbMa" . $spanId . "').html(" . "'<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>'" . " + addy_text" . $rand . " + '</a>'" . ");"; } else { $js .= "\n\t\t\$('#cbMa" . $spanId . "').html(" . "'<a ' + path + '\\'' + prefix + ':' + addy" . $rand . " + '\\'>'" . " + addy" . $rand . " + '</a>'" . ");"; } } else { $js .= "\n\t\t\$('#cbMa" . $spanId . "').html(addy" . $rand . ");"; } $js .= "\n\t}"; $replacement .= "<noscript> \n"; $replacement .= _UE_CLOAKED; $replacement .= "\n</noscript> \n"; $_CB_framework->outputCbJQuery($js); return $replacement; }