| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @author Mambo Foundation Inc see README.php 5 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 6 * See COPYRIGHT.php for copyright notices and details. 7 * @license GNU/GPL Version 2, see LICENSE.php 8 * 9 * Redistributions of files must retain the above copyright notice. 10 * 11 * Mambo is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; version 2 of the License. 14 */ 15 16 /** ensure this file is being included by a parent file */ 17 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 18 19 $_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosEmailCloak' ); 20 21 /** 22 * Mambot that Cloaks all emails in content from spambots via javascript 23 */ 24 function botMosEmailCloak( $published, &$row, &$cparams, $page=0, $params ) { 25 global $database; 26 27 // load mambot params info 28 /*$query = "SELECT id FROM #__mambots WHERE element = 'mosemailcloak' AND folder = 'content'"; 29 $database->setQuery( $query ); 30 $id = $database->loadResult(); 31 $mambot = new mosMambot( $database ); 32 $mambot->load( $id );*/ 33 $mambots =& mosMambotHandler::getInstance(); 34 $mambot = $mambots->getBot('mosemailcloack','content'); 35 $params =& new mosParameters( (isset($mambot->params)?$mambot->params:'') ); 36 37 $mode = $params->def( 'mode', 1 ); 38 //$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)"; 39 $search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-\?\=\%]+)"; 40 $search_text = "([[:alnum:][:space:][:punct:]][^<>]+)"; 41 42 // search for derivativs of link code <a href="mailto:email@amail.com">email@amail.com</a> 43 // extra handling for inclusion of title and target attributes either side of href attribute 44 $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>"; 45 if (is_callable(array($row, 'getText'))) $localtext = $row->getText(); 46 else $localtext = $row->text; 47 while( eregi( $searchlink, $localtext, $regs ) ) { 48 $mail = $regs[2] . $regs[3] . $regs[4]; 49 $mail_text = $regs[5] . $regs[6] . $regs[7]; 50 51 // check to see if mail text is different from mail addy 52 if ( $mail_text ) { 53 $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text ); 54 } else { 55 $replacement = mosHTML::emailCloaking( $mail, $mode ); 56 } 57 58 // replace the found address with the js cloacked email 59 $localtext = str_replace( $regs[0], $replacement, $localtext ); 60 } 61 62 // search for derivativs of link code <a href="mailto:email@amail.com">anytext</a> 63 // extra handling for inclusion of title and target attributes either side of href attribute 64 $searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>"; 65 while( eregi( $searchlink, $localtext, $regs ) ) { 66 $mail = $regs[2] . $regs[3] . $regs[4]; 67 $mail_text = $regs[5]; 68 69 $replacement = mosHTML::emailCloaking( $mail, $mode, $mail_text, 0 ); 70 71 // replace the found address with the js cloacked email 72 $localtext = str_replace( $regs[0], $replacement, $localtext ); 73 } 74 75 // search for plain text email@amail.com 76 while( eregi( $search, $localtext, $regs ) ) { 77 $mail = $regs[0]; 78 79 $replacement = mosHTML::emailCloaking( $mail, $mode ); 80 81 // replace the found address with the js cloacked email 82 $localtext = str_replace( $regs[0], $replacement, $localtext ); 83 } 84 85 if (is_callable(array($row, 'saveText'))) $row->saveText($localtext); 86 else $row->text = $localtext; 87 88 } 89 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |