Changeset 219395
- Timestamp:
- 03/19/2010 03:25:24 AM (16 years ago)
- Location:
- chatroll-live-chat
- Files:
-
- 4 edited
-
tags/1.2.5/readme.txt (modified) (2 diffs)
-
tags/1.2.5/wp-chatroll.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-chatroll.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chatroll-live-chat/tags/1.2.5/readme.txt
r214725 r219395 5 5 Requires at least: 2.8 6 6 Tested up to: 2.9 7 Stable tag: 1.2. 47 Stable tag: 1.2.5 8 8 9 9 Chatroll is a simple and flexible chat plugin for WordPress. Use Chatroll as a live chat or shoutbox on your sidebar, posts and pages. … … 108 108 == Changelog == 109 109 110 = 1.2.5 = 111 * Improved Gravatar support. Removed Curl dependency. 112 110 113 = 1.2.4 = 111 114 * Add support for Gravatars and local avatars. -
chatroll-live-chat/tags/1.2.5/wp-chatroll.php
r214725 r219395 237 237 238 238 /** 239 * We need special handling for Gravatar image URLs because:240 * 1) Chatroll requires image URLs to have valid filename extensions (.png, .jpg, etc.)241 * 2) Chatroll does not support image URLs that redirect or have GET parameters242 * Both these issues should be fixed in a future Chatroll service update.243 * Please contact support@chatroll.com for more information.244 */245 public function getGravatarUrl($url)246 {247 // Gravatar URL pattern248 $gpattern = "http:\/\/www\.gravatar\.com\/avatar\/[a-z0-9]+";249 250 // Decode URL-encoded characters in the Gravatar URL for processing251 $url = urldecode($url);252 253 // Extract the user image URL and default image URL from the combined Gravatar URL254 $userUrl = "";255 $defaultUrl = "";256 if (preg_match("/(" . $gpattern . ").*d=(" . $gpattern . ").*/", $url, $matches)) {257 $userUrl = $matches[1];258 $defaultUrl = $matches[2];259 }260 261 // Use CURL to check if the Gravatar exists, otherwise use the default image URL262 $ch = curl_init($userUrl . "?d=404");263 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);264 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);265 curl_setopt($ch, CURLOPT_FAILONERROR, true);266 curl_setopt($ch, CURLOPT_NOBODY, true);267 curl_setopt($ch, CURLOPT_TIMEOUT, 5);268 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);269 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6");270 $html = curl_exec($ch);271 if(!curl_errno($ch)) {272 return $userUrl . ".jpg";273 } else {274 return $defaultUrl . ".jpg";275 }276 }277 278 /**279 239 * OVERRIDE Chatroll::appendPlatformDefaultAttr() 280 240 * Set user parameters for SSO integration … … 304 264 // This ONLY takes effect when the Single Sign-On (SSO) check box is turned on via the Chatroll's Settings page! 305 265 if (function_exists('get_avatar')) { 266 // 38px image size 306 267 $avtr = get_avatar($current_user->ID, 38); 307 268 $avtr_src = preg_replace("/.*src='([^']*)'.*/", "$1", $avtr); … … 312 273 $domain = preg_replace("/^(http[s]?:\/\/[^\/]+).*/", "$1", $url); 313 274 $avtr_src = $domain . $avtr_src; 314 } else if (preg_match("/gravatar\.com/", $avtr_src)) {315 // Get full Gravatar image URL (with extension) 316 $avtr_src = $this->getGravatarUrl($avtr_src); 317 } 318 $attr['upic'] = $avtr_src;275 } 276 // The gravatar image URL is extracted from an image tag and ampersands (&) are escaped to & 277 // Chatroll uses the URL to download the image, as opposed to using it directly for an html img tag. 278 // Thus we need to un-escape the specialchars. (e.g. & -> &) 279 $attr['upic'] = htmlspecialchars_decode($avtr_src); 319 280 } 320 281 } -
chatroll-live-chat/trunk/readme.txt
r214725 r219395 5 5 Requires at least: 2.8 6 6 Tested up to: 2.9 7 Stable tag: 1.2. 47 Stable tag: 1.2.5 8 8 9 9 Chatroll is a simple and flexible chat plugin for WordPress. Use Chatroll as a live chat or shoutbox on your sidebar, posts and pages. … … 108 108 == Changelog == 109 109 110 = 1.2.5 = 111 * Improved Gravatar support. Removed Curl dependency. 112 110 113 = 1.2.4 = 111 114 * Add support for Gravatars and local avatars. -
chatroll-live-chat/trunk/wp-chatroll.php
r214725 r219395 237 237 238 238 /** 239 * We need special handling for Gravatar image URLs because:240 * 1) Chatroll requires image URLs to have valid filename extensions (.png, .jpg, etc.)241 * 2) Chatroll does not support image URLs that redirect or have GET parameters242 * Both these issues should be fixed in a future Chatroll service update.243 * Please contact support@chatroll.com for more information.244 */245 public function getGravatarUrl($url)246 {247 // Gravatar URL pattern248 $gpattern = "http:\/\/www\.gravatar\.com\/avatar\/[a-z0-9]+";249 250 // Decode URL-encoded characters in the Gravatar URL for processing251 $url = urldecode($url);252 253 // Extract the user image URL and default image URL from the combined Gravatar URL254 $userUrl = "";255 $defaultUrl = "";256 if (preg_match("/(" . $gpattern . ").*d=(" . $gpattern . ").*/", $url, $matches)) {257 $userUrl = $matches[1];258 $defaultUrl = $matches[2];259 }260 261 // Use CURL to check if the Gravatar exists, otherwise use the default image URL262 $ch = curl_init($userUrl . "?d=404");263 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);264 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);265 curl_setopt($ch, CURLOPT_FAILONERROR, true);266 curl_setopt($ch, CURLOPT_NOBODY, true);267 curl_setopt($ch, CURLOPT_TIMEOUT, 5);268 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);269 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; it; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6");270 $html = curl_exec($ch);271 if(!curl_errno($ch)) {272 return $userUrl . ".jpg";273 } else {274 return $defaultUrl . ".jpg";275 }276 }277 278 /**279 239 * OVERRIDE Chatroll::appendPlatformDefaultAttr() 280 240 * Set user parameters for SSO integration … … 304 264 // This ONLY takes effect when the Single Sign-On (SSO) check box is turned on via the Chatroll's Settings page! 305 265 if (function_exists('get_avatar')) { 266 // 38px image size 306 267 $avtr = get_avatar($current_user->ID, 38); 307 268 $avtr_src = preg_replace("/.*src='([^']*)'.*/", "$1", $avtr); … … 312 273 $domain = preg_replace("/^(http[s]?:\/\/[^\/]+).*/", "$1", $url); 313 274 $avtr_src = $domain . $avtr_src; 314 } else if (preg_match("/gravatar\.com/", $avtr_src)) {315 // Get full Gravatar image URL (with extension) 316 $avtr_src = $this->getGravatarUrl($avtr_src); 317 } 318 $attr['upic'] = $avtr_src;275 } 276 // The gravatar image URL is extracted from an image tag and ampersands (&) are escaped to & 277 // Chatroll uses the URL to download the image, as opposed to using it directly for an html img tag. 278 // Thus we need to un-escape the specialchars. (e.g. & -> &) 279 $attr['upic'] = htmlspecialchars_decode($avtr_src); 319 280 } 320 281 }
Note: See TracChangeset
for help on using the changeset viewer.