Subversion Repositories ZenDark

Compare Revisions

Ignore whitespace Rev 23 → Rev 24

/functions.php
101,16 → 101,20
 
// This check if a gravatar exists for a user, and if not return false
function validate_gravatar($email) {
// Craft a potential url and test its headers
$hash = md5($email);
$uri = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
$headers = @get_headers($uri);
if (!preg_match("|200|", $headers[0])) {
$has_valid_avatar = false;
}
else {
$has_valid_avatar = true;
}
/* first of all, we want to do the check only if it's needed, so
* we check that gravatars are actually enabled in settings, and
* that you want to display a blank avatar (no avatar) as default.
*/
if (get_option('show_avatars') && get_option('avatar_default') == 'blank') {
// Craft a potential url and test its headers
$hash = md5($email);
$uri = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
$headers = @get_headers($uri);
if (!preg_match("|200|", $headers[0])) $has_valid_avatar = false;
else $has_valid_avatar = true;
}
elseif (!get_option('show_avatars')) $has_valid_avatar = false;
else $has_valid_avatar = true;
return $has_valid_avatar;
}