function searchHighlight(&$content) { $pattern = '/[?&](q|as_q|as_epq|as_oq|query|search)=/'; if (!isset($_SERVER['HTTP_REFERER']) && isset($_SERVER['QUERY_STRING'])) { $_SERVER['HTTP_REFERER'] = $_SERVER['REQUEST_URI']; } if (isset($_SERVER['HTTP_REFERER']) && preg_match($pattern, $_SERVER['HTTP_REFERER'])) { // add JS to the header register_filter_js(CAT_URL . '/modules/blackcatFilter/js/highlight.js'); // add onload register_filter_onload('highlighter.highlight()'); } }
/** * obfuscates eMail addresses (links with 'href="mailto:..."') by using * Base64 Encoding and ROT13 in combination; this will need JavaScript for * de-obfuscation on the client side! * * @access public * @param string &$content - page content to parse * @return void edits $content **/ function obfuscateEmail(&$content) { $dom = new DOMDocument(); libxml_use_internal_errors(true); @$dom->loadHTML($content); $x = new DOMXPath($dom); foreach ($x->query("//a") as $node) { if (preg_match('~^mailto:(.*)~i', $node->getAttribute("href"), $match)) { $obfuscated = obfuscate($match[1]); $content = str_replace($match[0], 'javascript:' . $obfuscated, $content); // replace any other occurance $content = str_replace($match[1], '<script type="text/javascript">document.write(' . $obfuscated . ');</script>', $content); } } // match any other occurances of email addresses preg_match_all('/\\b([A-Za-z0-9._%-]+@(?:[A-Za-z0-9-]+\\.)+[A-Za-z]{2,4})\\b/D', $content, $matches, PREG_SET_ORDER); if (count($matches)) { foreach ($matches as $match) { $content = str_replace($match[1], '<script type="text/javascript">document.write(' . obfuscate($match[1]) . ');</script>', $content); } } // add JS to the header register_filter_js(CAT_URL . '/modules/blackcatFilter/js/obfuscateEmail.js'); }