wpseek.com
WordPress开发者和主题制作者的搜索引擎



antispambot › WordPress Function

Since0.71
已弃用n/a
antispambot ( $email_address, $hex_encoding = 0 )
参数: (2)
  • (string) $email_address Email address.
    Required: Yes
  • (int) $hex_encoding Optional. Set to 1 to enable hex encoding.
    Required: No
    默认:
返回:
  • (string) Converted email address.
定义在:
文档:

Converts email addresses characters to HTML entities to block spam bots.



源码

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 ( 0 === $j ) {
			$email_no_spam_address .= '&#' . ord( $email_address[ $i ] ) . ';';
		} elseif ( 1 === $j ) {
			$email_no_spam_address .= $email_address[ $i ];
		} elseif ( 2 === $j ) {
			$email_no_spam_address .= '%' . zeroise( dechex( ord( $email_address[ $i ] ) ), 2 );
		}
	}

	return str_replace( '@', '&#64;', $email_no_spam_address );
}