Letzte Bearbeitung:
Function mailadress_hide
Useage : {{{mailaddress_hide($string)}}}
Example : {{{mailaddress_hide('yyy@xxxx.xxx')}}}
Der Funktion wird die E-Mail-Adresse als String übergeben (also 'empfängername@domin-name.tld') und gibt dafür HTML-Code mit einem E-Mail-Link aus. Der resultierende Quellcode enthält keinen Klartext, wird jedoch vom Browser wieder zusammengesetzt. Sie ist daher für moderne und aufwändig programmierte Spider auslesbar. Der Schutz der E-Mail-Adresse ist also nach meiner Meinung nicht absolut.
{{{mailaddress_hide("webma……ach-cmsimple.de");}}} ⇒ webmaster@lembach-cmsimple.de
Der zurückgegebene Quellcode für vorstehende E-Mail-Adresse sieht so aus:
<a href="mailto:webmaster@lembach-cmsimple.de">webmaster@lembach-cmsimple.de</a>
Dateiname: ./plugins/simpleplugins_xh/simpleplugins_library/mailaddress_hide/index.php
<?php
/*****************************************************
* Category : CMSimple_XH
* Typ : CMSimple Plugin
* Package : simpleplugins_xh Edition KRL
*****************************************************
* Function name : mailaddress_hide
* File name : index.php
* Version : 0.1
* Build : 20240206
* Autor : Takashi Uchiyama <http://cmsimple-jp.org>
* Lizenz : GPLv3 or CC-by-SA https://creativecommons.org/licenses/by-sa/4.0/deed.de
* Function : Konvertiert die Zeichen von E-Mail-Adressen in HTML-Entities, um Spam-Bots zu blockieren
* Converts email addresses characters to HTML entities to block spam bots
******************************************************
* Useage : {{{mailaddress_hide($mail_address);}}}
* Example : {{{mailaddress_hide('abc@domain.tld');}}}
******************************************************/
/*
* Prevent direct access.
*/
if (!defined('CMSIMPLE_XH_VERSION')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
function mailaddress_hide($mail) {
$func = new antispambot_mailhide();
$mailto_mail = 'mailto:'.$mail;
$mailto_mail = $func -> antispambot($mailto_mail);
$text = $func -> antispambot($mail);
return '<a href="' .$mailto_mail . '">' .$text .'</a>';
}
class antispambot_mailhide {
/*****Original : From Wordpress wp-includes\formatting.php ****/
/**
* Converts email addresses characters to HTML entities to block spam bots.
*
* @since 0.71
*
* @param string $email_address Email address.
* @param int $hex_encoding Optional. Set to 1 to enable hex encoding.
* @return string Converted email address.
*/
//function antispambot( $email_address, $hex_encoding = 0 ) {
function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0, $len = strlen( $email_address ); $i < $len; $i++ ) {
$j = rand( 0, 1 + $hex_encoding );
if ( $j == 0 ) {
$email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';';
} elseif ( $j == 1 ) {
$email_no_spam_address .= $email_address[$i];
} elseif ( $j == 2 ) {
// $email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[$i] ) ), 2 );
$email_no_spam_address .= '%' . $this -> zeroise( dechex( ord( $email_address[$i] ) ), 2 );
}
}
$email_no_spam_address = str_replace( '@', '@', $email_no_spam_address );
return $email_no_spam_address;
}
/**
* Add leading zeros when necessary.
*
* If you set the threshold to '4' and the number is '10', then you will get
* back '0010'. If you set the threshold to '4' and the number is '5000', then you
* will get back '5000'.
*
* Uses sprintf to append the amount of zeros based on the $threshold parameter
* and the size of the number. If the number is large enough, then no zeros will
* be appended.
*
* @since 0.71
*
* @param mixed $number Number to append zeros to if not greater than threshold.
* @param int $threshold Digit places number needs to be to not have zeros added.
* @return string Adds leading zeros to number if needed.
*/
//function zeroise($number, $threshold) {
function zeroise($number, $threshold) {
return sprintf('%0'.$threshold.'s', $number);
}
}
?>