Remove some PHP4-ness from the antispambot() function, and update it to match some modern coding standards. Props hakre and crrobi01 for initial patches. Fixes #16754
Built from https://develop.svn.wordpress.org/trunk@25055 git-svn-id: http://core.svn.wordpress.org/trunk@25041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2da772855e
commit
47c82e1c83
|
@ -1483,25 +1483,26 @@ function rawurlencode_deep( $value ) {
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
*
|
*
|
||||||
* @param string $emailaddy Email address.
|
* @param string $email_address Email address.
|
||||||
* @param int $mailto Optional. Range from 0 to 1. Used for encoding.
|
* @param int $extra_entrpoy Optional. Range from 0 to 1. Used for encoding.
|
||||||
* @return string Converted email address.
|
* @return string Converted email address.
|
||||||
*/
|
*/
|
||||||
function antispambot($emailaddy, $mailto=0) {
|
function antispambot( $email_address, $extra_entropy = 0 ) {
|
||||||
$emailNOSPAMaddy = '';
|
$email_no_spam_address = '';
|
||||||
srand ((float) microtime() * 1000000);
|
for ( $i = 0; $i < strlen( $email_address ); $i++ ) {
|
||||||
for ($i = 0; $i < strlen($emailaddy); $i = $i + 1) {
|
$j = rand( 0, 1 + $extra_entropy );
|
||||||
$j = floor(rand(0, 1+$mailto));
|
if ( $j == 0 ) {
|
||||||
if ($j==0) {
|
$email_no_spam_address .= '&#' . ord( substr( $email_address, $i, 1 ) ) . ';';
|
||||||
$emailNOSPAMaddy .= '&#'.ord(substr($emailaddy,$i,1)).';';
|
} elseif ( $j == 1 ) {
|
||||||
} elseif ($j==1) {
|
$email_no_spam_address .= substr( $email_address, $i, 1 );
|
||||||
$emailNOSPAMaddy .= substr($emailaddy,$i,1);
|
} elseif ( $j == 2 ) {
|
||||||
} elseif ($j==2) {
|
$email_no_spam_address .= '%' . zeroise( dechex( ord( substr( $email_address, $i, 1 ) ) ), 2 );
|
||||||
$emailNOSPAMaddy .= '%'.zeroise(dechex(ord(substr($emailaddy, $i, 1))), 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$emailNOSPAMaddy = str_replace('@','@',$emailNOSPAMaddy);
|
|
||||||
return $emailNOSPAMaddy;
|
$email_no_spam_address = str_replace( '@', '@', $email_no_spam_address );
|
||||||
|
|
||||||
|
return $email_no_spam_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue