- md5
- af8e8aede1de21c9013ff8ca8324310f
- sha1
- ef0ad02edd1ce106ca057db66f9cce2a85014858
- sha256
- 1038b5124451541ccb1817a5c2590b9e84b31b62430e27b52ebba80b2acc8c0e
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<?php
/**
* @version $Id: mosemailcloak.php 427 2005-10-09 18:59:01Z 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;
// check whether mambot has been unpublished
if ( !$published ) {
return true;
}
// load mambot params info
$query = "SELECT id"
. "\n FROM #__mambots"
. "\n WHERE element = 'mosemailcloak'"
. "\n AND folder = 'content'"
;
$database->setQuery( $query );
$id = $database->loadResult();
$mambot = new mosMambot( $database );
$mambot->load( $id );
$botParams = new mosParameters( $mambot->params );
$mode = $botParams->def( 'mode', 1 );
$search = "([[:alnum:]_\.\-]+)(\@[[:alnum:]\.\-]+\.+)([[:alnum:]\.\-]+)";
$search_text = "([[:alnum:][:space:][:punct:]][^<>]+)";
// search for derivativs of link code <a href="mailto:[email protected]">[email protected]</a>
// extra handling for inclusion of title and target attributes either side of href attribute
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*>)". $search ."</a>";
while( eregi( $searchlink, $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>
// extra handling for inclusion of title and target attributes either side of href attribute
$searchlink = "(<a [[:alnum:] _\"\'=\@\.\-]*href=[\"\']mailto:". $search ."[\"\'][[:alnum:] _\"\'=\@\.\-]*)>". $search_text ."</a>";
while( eregi( $searchlink, $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 plain text [email protected]
while( eregi( $search, $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 );
}
}
?>
The same content is in 3 releases, Joomla 1.0.3 to 1.0.7. See them all, or every version of this file.