Changeset 3336909
- Timestamp:
- 07/31/2025 12:05:23 AM (8 months ago)
- Location:
- mirror-gravatar
- Files:
-
- 2 edited
- 5 copied
-
tags/1.5 (copied) (copied from mirror-gravatar/trunk)
-
tags/1.5/mirror-gravatar.js (copied) (copied from mirror-gravatar/trunk/mirror-gravatar.js)
-
tags/1.5/mirror-gravatar.php (copied) (copied from mirror-gravatar/trunk/mirror-gravatar.php) (8 diffs)
-
tags/1.5/mystery128.png (copied) (copied from mirror-gravatar/trunk/mystery128.png)
-
tags/1.5/readme.txt (copied) (copied from mirror-gravatar/trunk/readme.txt) (2 diffs)
-
trunk/mirror-gravatar.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mirror-gravatar/tags/1.5/mirror-gravatar.php
r3129055 r3336909 3 3 Plugin Name: Mirror Gravatar 4 4 Plugin URI: https://www.jwz.org/mirror-gravatar/ 5 Version: 1. 45 Version: 1.5 6 6 Description: Locally mirror commenters' Gravatar, Libravatar or Mastodon avatar images. 7 7 Author: Jamie Zawinski … … 9 9 */ 10 10 11 /* Copyright © 2022-202 4Jamie Zawinski <jwz@jwz.org>11 /* Copyright © 2022-2025 Jamie Zawinski <jwz@jwz.org> 12 12 13 13 Permission to use, copy, modify, distribute, and sell this software and its … … 28 28 */ 29 29 30 $mirror_gravatar_plugin_version = "1. 4";30 $mirror_gravatar_plugin_version = "1.5"; 31 31 $mirror_gravatar_plugin_name = 'mirror-gravatar'; 32 32 $mirror_gravatar_mystery_image = 'mystery128.png'; … … 37 37 function mirror_gravatar_load_url ($url, $desc, $json_p) { 38 38 39 if ($json_p)40 $response = wp_remote_get ($url);41 else42 $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)); 43 43 44 44 $code = wp_remote_retrieve_response_code ($response); 45 45 46 46 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) { 50 52 error_log ("mirror-gravatar: null response: $desc: $url"); 51 else53 } else { 52 54 error_log ("mirror-gravatar: error $code: $desc: $url"); 55 } 53 56 return null; 54 57 } … … 92 95 $dom = strtolower ($m[1]); 93 96 $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); 95 98 if ($srv && count ($srv)) { 96 99 // We're supposed to randomize by priority and weight, but screw it. … … 143 146 $hash = hash ('sha256', strtolower (trim ($email))); 144 147 $base = mirror_gravatar_libravatar_base_url ($email); 145 $url = "$base/avatar/$hash ";148 $url = "$base/avatar/$hash?d=404"; 146 149 $json = mirror_gravatar_load_url ($url, $desc, false); 147 150 if ($json) { … … 356 359 // To determine the saved avatar, look at the metadata that was stored 357 360 // 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. 359 363 // 360 364 $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 361 378 if (! $g) return $html; 362 379 … … 699 716 print htmlspecialchars($k); 700 717 if ($v) print '</A>'; 701 if ($f['verified_at'] ) print ' <I>(verified)</I>';718 if ($f['verified_at'] ?? null) print ' <I>(verified)</I>'; 702 719 print '<BR>'; 703 720 } -
mirror-gravatar/tags/1.5/readme.txt
r3336898 r3336909 5 5 Requires at least: 2.7 6 6 Tested up to: 6.8.2 7 Stable tag: 1. 47 Stable tag: 1.5 8 8 License: MIT 9 9 … … 63 63 * Prefer SHA256 to MD5, since Gravatar accepts that now. 64 64 * 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 3 3 Plugin Name: Mirror Gravatar 4 4 Plugin URI: https://www.jwz.org/mirror-gravatar/ 5 Version: 1. 45 Version: 1.5 6 6 Description: Locally mirror commenters' Gravatar, Libravatar or Mastodon avatar images. 7 7 Author: Jamie Zawinski … … 9 9 */ 10 10 11 /* Copyright © 2022-202 4Jamie Zawinski <jwz@jwz.org>11 /* Copyright © 2022-2025 Jamie Zawinski <jwz@jwz.org> 12 12 13 13 Permission to use, copy, modify, distribute, and sell this software and its … … 28 28 */ 29 29 30 $mirror_gravatar_plugin_version = "1. 4";30 $mirror_gravatar_plugin_version = "1.5"; 31 31 $mirror_gravatar_plugin_name = 'mirror-gravatar'; 32 32 $mirror_gravatar_mystery_image = 'mystery128.png'; … … 37 37 function mirror_gravatar_load_url ($url, $desc, $json_p) { 38 38 39 if ($json_p)40 $response = wp_remote_get ($url);41 else42 $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)); 43 43 44 44 $code = wp_remote_retrieve_response_code ($response); 45 45 46 46 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) { 50 52 error_log ("mirror-gravatar: null response: $desc: $url"); 51 else53 } else { 52 54 error_log ("mirror-gravatar: error $code: $desc: $url"); 55 } 53 56 return null; 54 57 } … … 92 95 $dom = strtolower ($m[1]); 93 96 $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); 95 98 if ($srv && count ($srv)) { 96 99 // We're supposed to randomize by priority and weight, but screw it. … … 143 146 $hash = hash ('sha256', strtolower (trim ($email))); 144 147 $base = mirror_gravatar_libravatar_base_url ($email); 145 $url = "$base/avatar/$hash ";148 $url = "$base/avatar/$hash?d=404"; 146 149 $json = mirror_gravatar_load_url ($url, $desc, false); 147 150 if ($json) { … … 356 359 // To determine the saved avatar, look at the metadata that was stored 357 360 // 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. 359 363 // 360 364 $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 361 378 if (! $g) return $html; 362 379 … … 699 716 print htmlspecialchars($k); 700 717 if ($v) print '</A>'; 701 if ($f['verified_at'] ) print ' <I>(verified)</I>';718 if ($f['verified_at'] ?? null) print ' <I>(verified)</I>'; 702 719 print '<BR>'; 703 720 } -
mirror-gravatar/trunk/readme.txt
r3336898 r3336909 5 5 Requires at least: 2.7 6 6 Tested up to: 6.8.2 7 Stable tag: 1. 47 Stable tag: 1.5 8 8 License: MIT 9 9 … … 63 63 * Prefer SHA256 to MD5, since Gravatar accepts that now. 64 64 * 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.