Subversion Repositories ZenDark

Rev

Rev 3 | Rev 25 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 24
Line 99... Line 99...
99
  return $classes;
99
  return $classes;
100
}
100
}
101
101
102
// This check if a gravatar exists for a user, and if not return false
102
// This check if a gravatar exists for a user, and if not return false
103
function validate_gravatar($email) {
103
function validate_gravatar($email) {
104
        // Craft a potential url and test its headers
-
 
105
        $hash = md5($email);
-
 
106
        $uri = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
-
 
107
        $headers = @get_headers($uri);
-
 
108
        if (!preg_match("|200|", $headers[0])) {
-
 
109
                $has_valid_avatar = false;
-
 
110
        }
-
 
111
  else {
-
 
112
                $has_valid_avatar = true;
-
 
113
        }
-
 
-
 
104
  /* first of all, we want to do the check only if it's needed, so
-
 
105
   * we check that gravatars are actually enabled in settings, and
-
 
106
   * that you want to display a blank avatar (no avatar) as default.
-
 
107
   */
-
 
108
  if (get_option('show_avatars') && get_option('avatar_default') == 'blank') {
-
 
109
    // Craft a potential url and test its headers
-
 
110
    $hash = md5($email);
-
 
111
    $uri = 'http://www.gravatar.com/avatar/'.$hash.'?d=404';
-
 
112
    $headers = @get_headers($uri);
-
 
113
    if (!preg_match("|200|", $headers[0])) $has_valid_avatar = false;
-
 
114
    else $has_valid_avatar = true;
-
 
115
  }
-
 
116
  elseif (!get_option('show_avatars')) $has_valid_avatar = false;
-
 
117
  else $has_valid_avatar = true;
114
        return $has_valid_avatar;
118
        return $has_valid_avatar;
115
}
119
}
116
120
117
/* Function to generate comments, I believe it's
121
/* Function to generate comments, I believe it's
118
 * necessary if you want paged comments.
122
 * necessary if you want paged comments.