| 15 |
/** |
/** |
| 16 |
* Mambot that Cloaks all emails in content from spambots via javascript |
* Mambot that Cloaks all emails in content from spambots via javascript |
| 17 |
*/ |
*/ |
| 18 |
function botMosEmailCloak( $published, &$row, &$params, $page=0 ) { |
function botMosEmailCloak( $published, &$row, &$cparams, $page=0, $params ) { |
| 19 |
global $database; |
global $database; |
| 20 |
|
|
|
// 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 ); |
|
| 21 |
$mode = $params->def( 'mode', 1 ); |
$mode = $params->def( 'mode', 1 ); |
|
|
|
| 22 |
$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; |
$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; |
| 23 |
$search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; |
$search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; |
| 24 |
|
|
| 25 |
// search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a> |
// search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a> |
| 26 |
// extra handling for inclusion of title and target attributes either side of href attribute |
// extra handling for inclusion of title and target attributes either side of href attribute |
| 27 |
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>"; |
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>"; |
| 28 |
while( eregi( $searchlink, $row->text, $regs ) ) { |
if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); |
| 29 |
|
else $localtext = $row->text; |
| 30 |
|
while( eregi( $searchlink, $localtext, $regs ) ) { |
| 31 |
$mail = $regs[2] . $regs[3] . $regs[4]; |
$mail = $regs[2] . $regs[3] . $regs[4]; |
| 32 |
$mail_text = $regs[5] . $regs[6] . $regs[7]; |
$mail_text = $regs[5] . $regs[6] . $regs[7]; |
| 33 |
|
|
| 39 |
} |
} |
| 40 |
|
|
| 41 |
// replace the found address with the js cloacked email |
// replace the found address with the js cloacked email |
| 42 |
$row->text = str_replace( $regs[0], $replacement, $row->text ); |
$localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 43 |
} |
} |
| 44 |
|
|
| 45 |
// search for derivativs of link code <a href="mailto:email@amail.com">anytext</a> |
// search for derivativs of link code <a href="mailto:email@amail.com">anytext</a> |
| 46 |
// extra handling for inclusion of title and target attributes either side of href attribute |
// extra handling for inclusion of title and target attributes either side of href attribute |
| 47 |
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>"; |
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>"; |
| 48 |
while( eregi( $searchlink, $row->text, $regs ) ) { |
while( eregi( $searchlink, $localtext, $regs ) ) { |
| 49 |
$mail = $regs[2] . $regs[3] . $regs[4]; |
$mail = $regs[2] . $regs[3] . $regs[4]; |
| 50 |
$mail_text = $regs[5]; |
$mail_text = $regs[5]; |
| 51 |
|
|
| 52 |
$replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); |
$replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); |
| 53 |
|
|
| 54 |
// replace the found address with the js cloacked email |
// replace the found address with the js cloacked email |
| 55 |
$row->text = str_replace( $regs[0], $replacement, $row->text ); |
$localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 56 |
} |
} |
| 57 |
|
|
| 58 |
// search for plain text email@amail.com |
// search for plain text email@amail.com |
| 59 |
while( eregi( $search, $row->text, $regs ) ) { |
while( eregi( $search, $localtext, $regs ) ) { |
| 60 |
$mail = $regs[0]; |
$mail = $regs[0]; |
| 61 |
|
|
| 62 |
$replacement = mosHTML::emailCloaking( $mail, $mode ); |
$replacement = mosHTML::emailCloaking( $mail, $mode ); |
| 63 |
|
|
| 64 |
// replace the found address with the js cloacked email |
// replace the found address with the js cloacked email |
| 65 |
$row->text = str_replace( $regs[0], $replacement, $row->text ); |
$localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 66 |
} |
} |
| 67 |
|
|
| 68 |
|
if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); |
| 69 |
|
else $row->text = $localtext; |
| 70 |
|
|
| 71 |
} |
} |
| 72 |
?> |
?> |