Annotation of /mambo/branches/4.6/mambots/content/mosemailcloak.php
Parent Directory
|
Revision Log
Revision 1219 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | elpie | 964 | * @package Mambo |
| 4 : | * @author Mambo Foundation Inc see README.php | ||
| 5 : | elpie | 1037 | * @copyright Mambo Foundation Inc. |
| 6 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 7 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see | ||
| 8 : | * LICENSE.php | ||
| 9 : | * Mambo is free software; you can redistribute it and/or | ||
| 10 : | * modify it under the terms of the GNU General Public License | ||
| 11 : | * as published by the Free Software Foundation; version 2 of the | ||
| 12 : | * License. | ||
| 13 : | neilt | 731 | */ |
| 14 : | root | 1 | |
| 15 : | /** ensure this file is being included by a parent file */ | ||
| 16 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 17 : | |||
| 18 : | $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosEmailCloak' ); | ||
| 19 : | |||
| 20 : | /** | ||
| 21 : | * Mambot that Cloaks all emails in content from spambots via javascript | ||
| 22 : | */ | ||
| 23 : | csouza | 129 | function botMosEmailCloak( $published, &$row, &$cparams, $page=0, $params ) { |
| 24 : | root | 1 | global $database; |
| 25 : | neilt | 731 | |
| 26 : | neilt | 776 | // load mambot params info |
| 27 : | andphe | 1074 | /*$query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'"; |
| 28 : | neilt | 776 | $database->setQuery( $query ); |
| 29 : | $id = $database->loadResult(); | ||
| 30 : | $mambot = new mosMambot( $database ); | ||
| 31 : | andphe | 1074 | $mambot->load( $id );*/ |
| 32 : | $mambots =& mosMambotHandler::getInstance(); | ||
| 33 : | andphe | 1219 | $mambot = $mambots->getBot('mosemailcloack','content'); |
| 34 : | andphe | 1075 | $params =& new mosParameters( (isset($mambot->params)?$mambot->params:'') ); |
| 35 : | neilt | 776 | |
| 36 : | root | 1 | $mode = $params->def( 'mode', 1 ); |
| 37 : | neilt | 731 | //$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; |
| 38 : | $search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-\?\=\%]+)"; | ||
| 39 : | root | 1 | $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; |
| 40 : | neilt | 731 | |
| 41 : | root | 1 | // search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a> |
| 42 : | // extra handling for inclusion of title and target attributes either side of href attribute | ||
| 43 : | $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>"; | ||
| 44 : | counterpoi | 213 | t if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); |
| 45 : | t else $localtext = $row->text; | ||
| 46 : | t while( eregi( $searchlink, $localtext, $regs ) ) { | ||
| 47 : | root | 1 | $mail = $regs[2] . $regs[3] . $regs[4]; |
| 48 : | $mail_text = $regs[5] . $regs[6] . $regs[7]; | ||
| 49 : | neilt | 731 | |
| 50 : | root | 1 | // check to see if mail text is different from mail addy |
| 51 : | neilt | 731 | if ( $mail_text ) { |
| 52 : | root | 1 | $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text ); |
| 53 : | } else { | ||
| 54 : | $replacement = mosHTML::emailCloaking( $mail, $mode ); | ||
| 55 : | neilt | 731 | } |
| 56 : | |||
| 57 : | root | 1 | // replace the found address with the js cloacked email |
| 58 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 59 : | root | 1 | } |
| 60 : | neilt | 731 | |
| 61 : | root | 1 | // search for derivativs of link code <a href="mailto:email@amail.com">anytext</a> |
| 62 : | // extra handling for inclusion of title and target attributes either side of href attribute | ||
| 63 : | $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>"; | ||
| 64 : | counterpoi | 213 | t while( eregi( $searchlink, $localtext, $regs ) ) { |
| 65 : | root | 1 | $mail = $regs[2] . $regs[3] . $regs[4]; |
| 66 : | $mail_text = $regs[5]; | ||
| 67 : | neilt | 731 | |
| 68 : | root | 1 | $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); |
| 69 : | neilt | 731 | |
| 70 : | root | 1 | // replace the found address with the js cloacked email |
| 71 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 72 : | root | 1 | } |
| 73 : | |||
| 74 : | // search for plain text email@amail.com | ||
| 75 : | counterpoi | 213 | t while( eregi( $search, $localtext, $regs ) ) { |
| 76 : | root | 1 | $mail = $regs[0]; |
| 77 : | |||
| 78 : | $replacement = mosHTML::emailCloaking( $mail, $mode ); | ||
| 79 : | neilt | 731 | |
| 80 : | root | 1 | // replace the found address with the js cloacked email |
| 81 : | counterpoi | 213 | t $localtext = str_replace( $regs[0], $replacement, $localtext ); |
| 82 : | root | 1 | } |
| 83 : | |||
| 84 : | counterpoi | 213 | t if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); |
| 85 : | t else $row->text = $localtext; | ||
| 86 : | t | ||
| 87 : | root | 1 | } |
| 88 : | mambo | 117 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

