Plugin Directory

Changeset 3336909


Ignore:
Timestamp:
07/31/2025 12:05:23 AM (8 months ago)
Author:
jwz
Message:

Version 1.5

Location:
mirror-gravatar
Files:
2 edited
5 copied

Legend:

Unmodified
Added
Removed
  • mirror-gravatar/tags/1.5/mirror-gravatar.php

    r3129055 r3336909  
    33Plugin Name: Mirror Gravatar
    44Plugin URI: https://www.jwz.org/mirror-gravatar/
    5 Version: 1.4
     5Version: 1.5
    66Description: Locally mirror commenters' Gravatar, Libravatar or Mastodon avatar images.
    77Author: Jamie Zawinski
     
    99*/
    1010
    11 /* Copyright © 2022-2024 Jamie Zawinski <jwz@jwz.org>
     11/* Copyright © 2022-2025 Jamie Zawinski <jwz@jwz.org>
    1212
    1313   Permission to use, copy, modify, distribute, and sell this software and its
     
    2828 */
    2929
    30 $mirror_gravatar_plugin_version = "1.4";
     30$mirror_gravatar_plugin_version = "1.5";
    3131$mirror_gravatar_plugin_name    = 'mirror-gravatar';
    3232$mirror_gravatar_mystery_image  = 'mystery128.png';
     
    3737function mirror_gravatar_load_url ($url, $desc, $json_p) {
    3838
    39   if ($json_p)
    40     $response = wp_remote_get ($url);
    41   else
    42     $response = wp_remote_head ($url);
     39  $args = [ 'redirection' => 10 ];  // Default 5; libravatar might need more?
     40  $response = ($json_p
     41               ? wp_remote_get  ($url, $args)
     42               : wp_remote_head ($url, $args));
    4343
    4444  $code = wp_remote_retrieve_response_code ($response);
    4545
    4646  if (! preg_match ('/^2\d\d/', $code)) {
    47     if ($code == '404')
    48       ; // error_log ("mirror-gravatar: no avatar: $desc");
    49     else if (!$code)
     47    if ($code == '404') {
     48      // error_log ("mirror-gravatar: no avatar: $desc");
     49    } else if (preg_match ('/^3\d\d/', $code)) {
     50      error_log ("mirror-gravatar: too many redirects: $desc: $url");
     51    } else if (!$code) {
    5052      error_log ("mirror-gravatar: null response: $desc: $url");
    51     else
     53    } else {
    5254      error_log ("mirror-gravatar: error $code: $desc: $url");
     55    }
    5356    return null;
    5457  }
     
    9295    $dom = strtolower ($m[1]);
    9396    $sub = '_avatars-sec._tcp.';    // dig +short SRV _avatars-sec._tcp.$dom
    94     $srv = dns_get_record ("$sub$dom", DNS_SRV);
     97    $srv = @dns_get_record ("$sub$dom", DNS_SRV);
    9598    if ($srv && count ($srv)) {
    9699      // We're supposed to randomize by priority and weight, but screw it.
     
    143146    $hash = hash ('sha256', strtolower (trim ($email)));
    144147    $base = mirror_gravatar_libravatar_base_url ($email);
    145     $url = "$base/avatar/$hash";
     148    $url = "$base/avatar/$hash?d=404";
    146149    $json = mirror_gravatar_load_url ($url, $desc, false);
    147150    if ($json) {
     
    356359  // To determine the saved avatar, look at the metadata that was stored
    357360  // on this comment by mirror_gravatar_download_metadata() at the time
    358   // that the comment was posted.
     361  // that the comment was posted.  It will have a 'hash' value that
     362  // identifies the avatar image file that we downloaded.
    359363  //
    360364  $g = get_comment_meta ($id->comment_ID, 'gravatar', true);
     365
     366  // An early version of this plugin (prior to 1.2) might have downloaded an
     367  // avatar image file without also storing the 'gravatar' metadata in the
     368  // comment.  To handle those old comments, we fake up metadata with a hash.
     369  //
     370  if (! $g) {
     371    $email = $id->comment_author_email ?? null;
     372    if ($email) {
     373      $hash = hash ('md5', strtolower (trim ($email))); // Old hashes were MD5
     374      $g = [[ 'hash' => $hash ]];
     375    }
     376  }
     377
    361378  if (! $g) return $html;
    362379
     
    699716      print htmlspecialchars($k);
    700717      if ($v) print '</A>';
    701       if ($f['verified_at']) print ' <I>(verified)</I>';
     718      if ($f['verified_at'] ?? null) print ' <I>(verified)</I>';
    702719      print '<BR>';
    703720    }
  • mirror-gravatar/tags/1.5/readme.txt

    r3336898 r3336909  
    55Requires at least: 2.7
    66Tested up to: 6.8.2
    7 Stable tag: 1.4
     7Stable tag: 1.5
    88License: MIT
    99
     
    6363* Prefer SHA256 to MD5, since Gravatar accepts that now.
    6464* Added support for Libravatar.
     65
     66= 1.4 =
     67* Oops, I forgot to include the CSS file in the distribution.
  • mirror-gravatar/trunk/mirror-gravatar.php

    r3129055 r3336909  
    33Plugin Name: Mirror Gravatar
    44Plugin URI: https://www.jwz.org/mirror-gravatar/
    5 Version: 1.4
     5Version: 1.5
    66Description: Locally mirror commenters' Gravatar, Libravatar or Mastodon avatar images.
    77Author: Jamie Zawinski
     
    99*/
    1010
    11 /* Copyright © 2022-2024 Jamie Zawinski <jwz@jwz.org>
     11/* Copyright © 2022-2025 Jamie Zawinski <jwz@jwz.org>
    1212
    1313   Permission to use, copy, modify, distribute, and sell this software and its
     
    2828 */
    2929
    30 $mirror_gravatar_plugin_version = "1.4";
     30$mirror_gravatar_plugin_version = "1.5";
    3131$mirror_gravatar_plugin_name    = 'mirror-gravatar';
    3232$mirror_gravatar_mystery_image  = 'mystery128.png';
     
    3737function mirror_gravatar_load_url ($url, $desc, $json_p) {
    3838
    39   if ($json_p)
    40     $response = wp_remote_get ($url);
    41   else
    42     $response = wp_remote_head ($url);
     39  $args = [ 'redirection' => 10 ];  // Default 5; libravatar might need more?
     40  $response = ($json_p
     41               ? wp_remote_get  ($url, $args)
     42               : wp_remote_head ($url, $args));
    4343
    4444  $code = wp_remote_retrieve_response_code ($response);
    4545
    4646  if (! preg_match ('/^2\d\d/', $code)) {
    47     if ($code == '404')
    48       ; // error_log ("mirror-gravatar: no avatar: $desc");
    49     else if (!$code)
     47    if ($code == '404') {
     48      // error_log ("mirror-gravatar: no avatar: $desc");
     49    } else if (preg_match ('/^3\d\d/', $code)) {
     50      error_log ("mirror-gravatar: too many redirects: $desc: $url");
     51    } else if (!$code) {
    5052      error_log ("mirror-gravatar: null response: $desc: $url");
    51     else
     53    } else {
    5254      error_log ("mirror-gravatar: error $code: $desc: $url");
     55    }
    5356    return null;
    5457  }
     
    9295    $dom = strtolower ($m[1]);
    9396    $sub = '_avatars-sec._tcp.';    // dig +short SRV _avatars-sec._tcp.$dom
    94     $srv = dns_get_record ("$sub$dom", DNS_SRV);
     97    $srv = @dns_get_record ("$sub$dom", DNS_SRV);
    9598    if ($srv && count ($srv)) {
    9699      // We're supposed to randomize by priority and weight, but screw it.
     
    143146    $hash = hash ('sha256', strtolower (trim ($email)));
    144147    $base = mirror_gravatar_libravatar_base_url ($email);
    145     $url = "$base/avatar/$hash";
     148    $url = "$base/avatar/$hash?d=404";
    146149    $json = mirror_gravatar_load_url ($url, $desc, false);
    147150    if ($json) {
     
    356359  // To determine the saved avatar, look at the metadata that was stored
    357360  // on this comment by mirror_gravatar_download_metadata() at the time
    358   // that the comment was posted.
     361  // that the comment was posted.  It will have a 'hash' value that
     362  // identifies the avatar image file that we downloaded.
    359363  //
    360364  $g = get_comment_meta ($id->comment_ID, 'gravatar', true);
     365
     366  // An early version of this plugin (prior to 1.2) might have downloaded an
     367  // avatar image file without also storing the 'gravatar' metadata in the
     368  // comment.  To handle those old comments, we fake up metadata with a hash.
     369  //
     370  if (! $g) {
     371    $email = $id->comment_author_email ?? null;
     372    if ($email) {
     373      $hash = hash ('md5', strtolower (trim ($email))); // Old hashes were MD5
     374      $g = [[ 'hash' => $hash ]];
     375    }
     376  }
     377
    361378  if (! $g) return $html;
    362379
     
    699716      print htmlspecialchars($k);
    700717      if ($v) print '</A>';
    701       if ($f['verified_at']) print ' <I>(verified)</I>';
     718      if ($f['verified_at'] ?? null) print ' <I>(verified)</I>';
    702719      print '<BR>';
    703720    }
  • mirror-gravatar/trunk/readme.txt

    r3336898 r3336909  
    55Requires at least: 2.7
    66Tested up to: 6.8.2
    7 Stable tag: 1.4
     7Stable tag: 1.5
    88License: MIT
    99
     
    6363* Prefer SHA256 to MD5, since Gravatar accepts that now.
    6464* Added support for Libravatar.
     65
     66= 1.4 =
     67* Oops, I forgot to include the CSS file in the distribution.
Note: See TracChangeset for help on using the changeset viewer.