Annotation of /mambo/branches/4.6/mambots/content/mosemailcloak.php
Parent Directory
|
Revision Log
Revision 213 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: mosemailcloak.php,v 1.2 2005/07/22 03:30:14 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosEmailCloak' ); | ||
| 14 : | |||
| 15 : | /** | ||
| 16 : | * Mambot that Cloaks all emails in content from spambots via javascript | ||
| 17 : | */ | ||
| 18 : | csouza | 129 | function botMosEmailCloak( $published, &$row, &$cparams, $page=0, $params ) { |
| 19 : | root | 1 | global $database; |
| 20 : | |||
| 21 : | $mode = $params->def( 'mode', 1 ); | ||
| 22 : | $search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; | ||
| 23 : | $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; | ||
| 24 : | |||
| 25 : | // 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 | ||
| 27 : | $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>"; | ||
| 28 : | counterpoi | 213 | t if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); |
| 29 : | t else $localtext = $row->text; | ||
| 30 : | t while( eregi( $searchlink, $localtext, $regs ) ) { | ||
| 31 : | root | 1 | $mail = $regs[2] . $regs[3] . $regs[4]; |
| 32 : | $mail_text = $regs[5] . $regs[6] . $regs[7]; | ||
| 33 : | |||
| 34 : | // check to see if mail text is different from mail addy | ||
| 35 : | if ( $mail_text ) { | ||
| 36 : | $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text ); | ||
| 37 : | } else { | ||
| 38 : | $replacement = mosHTML::emailCloaking( $mail, $mode ); | ||
| 39 : | } | ||
| 40 : | |||
| 41 : | // replace the found address with the js cloacked email | ||
| 42 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 43 : | root | 1 | } |
| 44 : | |||
| 45 : | // 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 | ||
| 47 : | $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>"; | ||
| 48 : | counterpoi | 213 | t while( eregi( $searchlink, $localtext, $regs ) ) { |
| 49 : | root | 1 | $mail = $regs[2] . $regs[3] . $regs[4]; |
| 50 : | $mail_text = $regs[5]; | ||
| 51 : | |||
| 52 : | $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); | ||
| 53 : | |||
| 54 : | // replace the found address with the js cloacked email | ||
| 55 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 56 : | root | 1 | } |
| 57 : | |||
| 58 : | // search for plain text email@amail.com | ||
| 59 : | counterpoi | 213 | t while( eregi( $search, $localtext, $regs ) ) { |
| 60 : | root | 1 | $mail = $regs[0]; |
| 61 : | |||
| 62 : | $replacement = mosHTML::emailCloaking( $mail, $mode ); | ||
| 63 : | |||
| 64 : | // replace the found address with the js cloacked email | ||
| 65 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 66 : | root | 1 | } |
| 67 : | |||
| 68 : | counterpoi | 213 | t if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); |
| 69 : | t else $row->text = $localtext; | ||
| 70 : | t | ||
| 71 : | root | 1 | } |
| 72 : | mambo | 117 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

