registerFunction( 'onPrepareContent', 'botMosEmailCloak' ); /** * Mambot that Cloaks all emails in content from spambots via javascript */ function botMosEmailCloak( $published, &$row, &$params, $page=0 ) { global $database; // load mambot params info $query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'"; $database->setQuery( $query ); $id = $database->loadResult(); $mambot = new mosMambot( $database ); $mambot->load( $id ); $params =& new mosParameters( $mambot->params ); $mode = $params->def( 'mode', 1 ); $search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; // search for derivativs of link code email@amail.com // extra handling for inclusion of title and target attributes either side of href attribute $searchlink = "()". $search .""; while( eregi( $searchlink, $row->text, $regs ) ) { $mail = $regs[2] . $regs[3] . $regs[4]; $mail_text = $regs[5] . $regs[6] . $regs[7]; // check to see if mail text is different from mail addy if ( $mail_text ) { $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text ); } else { $replacement = mosHTML::emailCloaking( $mail, $mode ); } // replace the found address with the js cloacked email $row->text = str_replace( $regs[0], $replacement, $row->text ); } // search for derivativs of link code anytext // extra handling for inclusion of title and target attributes either side of href attribute $searchlink = "(". $search_text .""; while( eregi( $searchlink, $row->text, $regs ) ) { $mail = $regs[2] . $regs[3] . $regs[4]; $mail_text = $regs[5]; $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); // replace the found address with the js cloacked email $row->text = str_replace( $regs[0], $replacement, $row->text ); } // search for plain text email@amail.com while( eregi( $search, $row->text, $regs ) ) { $mail = $regs[0]; $replacement = mosHTML::emailCloaking( $mail, $mode ); // replace the found address with the js cloacked email $row->text = str_replace( $regs[0], $replacement, $row->text ); } } ?>