- md5
- 085348fe485382306166eed34e5c7941
- sha1
- 0037c34217d7a31ae681460f3fd96c135b98d932
- sha256
- 6095667952f176128451b5c256ac79bc77fa73e62bd936c58747e2ef07bfc78d
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
<?php
/**
* @version $Id: mosemailcloak.php 4564 2006-08-18 23:26:32Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );
$_MAMBOTS->registerFunction( 'onPrepareContent', 'botMosEmailCloak' );
/**
* Mambot that Cloaks all emails in content from spambots via javascript
*/
function botMosEmailCloak( $published, &$row, &$params, $page=0 ) {
global $database, $_MAMBOTS;
// check whether mambot has been unpublished
if ( !$published ) {
return true;
}
// simple performance check to determine whether bot should process further
if ( strpos( $row->text, '@' ) === false ) {
return true;
}
// simple check to allow disabling of bot
$regex = '{emailcloak=off}';
if ( strpos( $row->text, $regex ) !== false ) {
$row->text = str_replace( $regex, '', $row->text );
return true;
}
// check if param query has previously been processed
if ( !isset($_MAMBOTS->_content_mambot_params['mosemailcloak']) ) {
// load mambot params info
$query = "SELECT params"
. "\n FROM #__mambots"
. "\n WHERE element = 'mosemailcloak'"
. "\n AND folder = 'content'"
;
$database->setQuery( $query );
$database->loadObject($mambot);
// save query to class variable
$_MAMBOTS->_content_mambot_params['mosemailcloak'] = $mambot;
}
// pull query data from class variable
$mambot = $_MAMBOTS->_content_mambot_params['mosemailcloak'];
$botParams = new mosParameters( $mambot->params );
$mode = $botParams->def( 'mode', 1 );
// [email protected]
$search_email = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)";
// [email protected]?subject=anyText
$search_email_msg = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)([[:alnum:][:space:][:punct:]][^\"<>]+)";
// anyText
$search_text = "([[:alnum:][:space:][:punct:]][^<>]+)";
// search for derivativs of link code <a href="mailto:[email protected]">[email protected]</a>
$pattern = botMosEmailCloak_searchPattern( $search_email, $search_email );
while( eregi( $pattern, $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 <a href="mailto:[email protected]">anytext</a>
$pattern = botMosEmailCloak_searchPattern( $search_email, $search_text );
while( eregi( $pattern, $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 derivativs of link code <a href="mailto:[email protected]?subject=Text&body=Text">[email protected]</a>
$pattern = botMosEmailCloak_searchPattern( $search_email_msg, $search_email );
while( eregi( $pattern, $row->text, $regs ) ) {
$mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
$mail_text = $regs[6] . $regs[7]. $regs[8];
//needed for handling of Body parameter
$mail = str_replace( '&', '&', $mail );
// 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 <a href="mailto:[email protected]?subject=Text&body=Text">anytext</a>
$pattern = botMosEmailCloak_searchPattern( $search_email_msg, $search_text );
while( eregi( $pattern, $row->text, $regs ) ) {
$mail = $regs[2] . $regs[3] . $regs[4] . $regs[5];
$mail_text = $regs[6];
//needed for handling of Body parameter
$mail = str_replace( '&', '&', $mail );
$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 protected]
while( eregi( $search_email, $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 );
}
}
function botMosEmailCloak_searchPattern ( $link, $text ) {
// <a href="mailto:anyLink">anyText</a>
$pattern = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $link ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $text ."</a>";
return $pattern;
}
?>
The same content is in 3 releases, Joomla 1.0.13 to 1.0.15. See them all, or every version of this file.