Avatar as Gravatar shows up but wont stick.

Akimotos

New member
hello, ive seen several messages about garvatar usage. So maybe i'm doing something wrong or it's something weird.
i have checked several things and what i see is not giving me a conclusion:

in the attached image you see the gravatar picture that is conencted to my account.
the errorlog says
Code:
Zend_Http_Client_Adapter_Exception: Unable to Connect to tcp://www.gravatar.com:80. Error #110: Connection timed out - library/Zend/Http/Client/Adapter/Socket.php:235
Generated By: Akimotos, 1 minute ago
Stack Trace
#0 /home/pfijma/public_html/library/Zend/Http/Client.php(973): Zend_Http_Client_Adapter_Socket->connect('www.gravatar.co...', 80, false)
#1 /home/pfijma/public_html/library/XenForo/Model/Avatar.php(457): Zend_Http_Client->request('HEAD')
#2 /home/pfijma/public_html/library/XenForo/ControllerPublic/Account.php(573): XenForo_Model_Avatar::gravatarExists('p.fijma@rpgweb....', NULL)
#3 /home/pfijma/public_html/library/XenForo/FrontController.php(347): XenForo_ControllerPublic_Account->actionAvatarUpload()
#4 /home/pfijma/public_html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
#5 /home/pfijma/public_html/index.php(13): XenForo_FrontController->run()
#6 {main}
Request State
array(3) {
  ["url"] => string(55) "http://www.pbpgames.com/index.php?account/avatar-upload"
  ["_GET"] => array(1) {
    ["account/avatar-upload"] => string(0) ""
  }
  ["_POST"] => array(9) {
    ["use_gravatar"] => string(1) "1"
    ["gravatar"] => string(17) "p.fijma@rpgweb.eu"
    ["avatar_date"] => string(1) "0"
    ["avatar_crop_x"] => string(1) "0"
    ["avatar_crop_y"] => string(1) "0"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(30) "/index.php?members/akimotos.2/"
    ["_xfNoRedirect"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}

if DNS would be the problem as suggested by several other posts, it would not show up in the first place.
however, selecting it and pressing TEST or pressing OKAY result in a mini-progressbar in topright corner, followed by a error that states that there is a time out.
so... (why) is it showing the image that it is supposed not to find due to a time out ? (my admin account didn't show the gravatar and suddenly it shows...

maybe related:
to use the file upload function i press file and select the picture i like. the window vanishes and the upload box randimly shows the image link (like d:\pic\...png) or not. nothing shows. (no progress bar no link, no image) close the window. refresh the page and... suddenly it shows the previous uploaded image. (i tried several times. including clearing cache. )
i am just runnig my forum for two days so this forum is all fairly new to me.
i will test more and post here. i have a dotnetnuke solution at the same provider that haven't shown similar problems)
if there is anything i can test let me know.

i wasn't allowed to add another post, so i edit this one:
additional: when i change email on the contacts details page it changes the gravatar picture. (i can change all i want in the avatar editor it doesn't change image et al.)
when i want to use it it tells me that it times out. (and it doesn't show.)
 

Attachments

  • 2015-05-28 00_48_05-Akimotos _ PbPgames.webp
    2015-05-28 00_48_05-Akimotos _ PbPgames.webp
    109.1 KB · Views: 4
Last edited:
I have just looked up your account based on the email address you have used to register so I can see you are licensed.
I have therefore moved the thread but you won't be able to post in the customer forums until you associate your account.

The error which is being logged is an issue with your server connecting to the Gravatar service.

It could be due to a temporary issue such as Gravatar being down, a routing issue, or it could be due to the server configuration - e.g. the firewall blocking the connection.
 
if it cannot reach the site (due to one of teh mentioned reasons... why is it showing the picture? it obviously did get that image from the same gravatar site. I am a windows man and don't use linux, so i have no clue what and how to test. Is there a php thingy that i can use to test what is missing/not working?
i am hosting everything at arvixe and for the forum i rented a server(shared) and the install is done by the ISP manually. I only run my own DotNetNuke on windows at their servers.
http://www.arvixe.com/xenforo_hosting

i have been trying the imagery for two hours and other sites that i host have no connection issues.
So it isn't down or not working. I cant exclude a port failure, but logically hat would be for every request in a similar fashion, and my admin account shows the correct image, with gravatar: this would be impossible with a port blocking mechanism. so it has to be something else. (can it be that the image is too small on gravatar? need to test that.
i will do some investigation tomorrow (its here 02:00 AM and i am... bleh.) and ask if the provider can check some (as soon as i know what to check for.)

Thanks Brogan, for correcting me in the forum registration. I would not expect a username connection in a world where everything is validated with email :)
i read it and it didn't register in my brain.
 
If the errors are intermittent then that would explain why the Gravatar image has been successfully retrieved.

Ultimately you need to determine whether the connection issue is related to your server, a routing issue, or at Gravatar's end.
 
took me some time to get it working (lack of knowldge linux and php), but i have found a test thingy.
http://www.pbpgames.com/gtest/test.php?email=p.fijma@rpgweb.eu
it shows the gravatar. (i noticed that this link has become an email to link... :-/)

it's based on
Code:
<?php
error_reporting(E_ALL | E_NOTICE);
require('../src/Gravatar.php');

// Get an email address from the test.php?email= URL parameter
$email = $_GET['email'];
$grav1 = new Gravatar($email);

?>
<html>
<head>
<title>Gravatar for <?php echo $grav1->get_email(); ?></title>
</head>
<body>

<h1>Gravatar for <?php echo $grav1->get_email(); ?></h1>

<h2>Basic usage</h2>

<?php
echo $grav1;
?>

<h2>Testing all the options</h2>

<?php
$grav2 = new Gravatar(
    array(
        'default' => 'identicon',
        'size'    => 128,
        'rating'  => 'X',
        'border'  => 'F00',
        'file_extension' => 'png',
        'extra'   => 'class="test"'
    )
);
$grav2->set_email($email);

// Testing __get() and isset
assert($grav2->rating == 'X');
assert(isset($grav2->border));

if ($grav2->avatar_exists()) {
    echo 'Image link is <a href="' . $grav2->get_src() . '">' . $grav2->get_src() . '</a><br/>';
    echo $grav2;
} else {
    echo 'No Gravatar exists for this email address<br/>';
    echo $grav2; // Showing the identicon
}
?>
</body>
</html>
[code]

it shows (like the avatar editor) the image. (the gravatar editor does show i, even changes it when you change your details; email address)  but when you press test or OKAY... it searches again and  then .. error. it doesn't save the link/image.

if i upload a normal file it doesn't work in one go. i need to select the file a second time. the local filename won't show up in the upload box the first time.
after selecting and OKAYing it doesn't show up (in the avatar editor). i press okay. it lingers some time 4-5 sec. (way to long for a 100x100 static gif). the box dissapears and i need to do page refresh.   i guess that these two problems are related and that there is some part not saving the URI?

I hope this helps to solve a problem. 

The code i used to test is from this github https://github.com/philix/php-gravatar
 
i have asked my provider to investigate if they can see what is going on.
it's difficult to explain that it isn't working when a php page gets the results on the same machine.
Code:
 http://www.pbpgames.com/gtest/test.php?email=p.fijma@autotrader.nl
testcode:
Code:
<?php
error_reporting(E_ALL | E_NOTICE);
require('../src/Gravatar.php');

// Get an email address from the test.php?email= URL parameter
$email = $_GET['email'];
$grav1 = new Gravatar($email);

?>
<html>
<head>
<title>Gravatar for <?php echo $grav1->get_email(); ?></title>
</head>
<body>

<h1>Gravatar for <?php echo $grav1->get_email(); ?></h1>

<h2>Basic usage</h2>

<?php
echo $grav1;
?>

<h2>Testing all the options</h2>

<?php
$grav2 = new Gravatar(
 array(
 'default' => 'identicon',
 'size'  => 128,
 'rating'  => 'X',
 'border'  => 'F00',
 'file_extension' => 'png',
 'extra'  => 'class="test"'
 )
);
$grav2->set_email($email);

// Testing __get() and isset
assert($grav2->rating == 'X');
assert(isset($grav2->border));

if ($grav2->avatar_exists()) {
 echo 'Image link is <a href="' . $grav2->get_src() . '">' . $grav2->get_src() . '</a><br/>';
 echo $grav2;
} else {
 echo 'No Gravatar exists for this email address<br/>';
 echo $grav2; // Showing the identicon
}
?>
</body>
</html>

and the gravatar code
Code:
<?php

/**
 * Gravatar class
 *
 * {@link http://site.gravatar.com/site/implement}
 *
 * Very basic usage:
 * <code>
 *  $gravatar = new Gravatar("user@gmail.com");
 *  echo $gravatar; // <img src="http://gravatar.com/...
 * </code>
 *
 * @package Gravatar
 * @version 1.0
 * @copyright 2008-2010 Felipe Oliveira Caravalho
 * @author Felipe Oliveira Carvalho <felipekde@gmail.com>
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt LGPL
 */
class Gravatar
{
 /**
  * Gravatar's base url 
  */
 const GRAVATAR_URL = 'http://gravatar.com/avatar/';

 /**
  * Available ratings
  *
  * @var string
  * @access private
  */
 private $GRAVATAR_RATING = array('G', 'PG', 'R', 'X');

 /**
  * Gravatar URL properties:
  * - gravatar_id
  * - default, d (identicon, monsterid, wavatar, <url>)
  * - size, s
  * - rating, r
  * - border, b
  *
  * @link http://en.gravatar.com/site/implement/url More information
  *
  * @var array
  * @access protected
  */
 protected $properties = array(
 'default' => NULL,
 'size' => 80,
 'rating' => NULL,
 'border' => NULL,
 );

 /**
  * Email
  * 
  * @var string
  * @access protected
  */
 protected $email = '';


 /**
  * Optional file extension (png, gif, jpg...)
  * 
  * @var string
  * @access protected
  */
 protected $file_extension = '';

 /**
  * Extra attributes to the IMG tag like ALT, CLASS, STYLE...
  * 
  * @var string
  * @access protected
  */
 protected $extra = '';

 /**
  * Gravatar constructor
  * 
  * @param array|string $props may be an email or a configuration array
  * @access public
  * @return void
  */
 function Gravatar($props = array())
 {
 if (is_array($props))
 return $this->initialize($props);
 // In case it's an email
 $this->set_email($props);
 }

 /**
  * This method allows CodeIgniter integration.
  * The options you can set are the following:
  *  - default
  *  - size
  *  - rating
  *  - email (you won't use this in a configuration file)
  *  - file_extension
  *  - extra
  * 
  * @param array $config 
  * @access public
  * @return void
  */
 function initialize($config = array())
 {
 foreach($config as $key => $val) {
 $method = 'set_'.$key;
 $this->$method($val);
 }
 
 $this->properties['gravatar_id'] = NULL;
 }

 /**
  * Set email
  * 
  * @param string $email 
  * @access public
  * @return boolean indicates if the email is valid
  */
 function set_email($email)
 {
 if ($this->is_valid_email($email)) {
 $this->email = $email;
 $this->properties['gravatar_id'] = md5(strtolower($this->email));
 return true;
 }
 return false;
 }

 /**
  * Set the value of the 'default' parameter
  * 
  * @param string $default 
  * @access public
  * @return void
  */
 function set_default($default)
 {
 $this->properties['default'] = $default;
 }

 /**
  * Set rating 
  * 
  * @param string $rating 
  * @access public
  * @return boolean indicates if the rating is valid
  */
 function set_rating($rating)
 {
 if (in_array($rating, $this->GRAVATAR_RATING)) {
 $this->properties['rating'] = $rating;
 return true;
 }
 return false;
 }

 /**
  * Set the avatar size
  * 
  * @param integer $size 
  * @access public
  * @return void
  */
 function set_size($size)
 {
 $size = (int) $size;
 if ($size <= 0)
 $size = NULL;  // Use the default size
 $this->properties['size'] = $size;
 }
 
 /**
  * Set extra html data that will be inserted inside the <img> tag
  * 
  * @param string $extra 
  * @access public
  * @return void
  */
 function set_extra($extra)
 {
 if ($this->extra == '')
 $this->extra = $extra;
 else
 $this->extra .= ' '.$extra;
 }

 /**
  * Set the optional file extension ('jpg', 'png', 'gif'...)
  * 
  * @param string $ext 
  * @access public
  * @return void
  */
 function set_file_extension($ext)
 {
 $this->file_extension = $ext;
 }

 /**
  * Set the optional avatar 1px border color (e.g. FF0000, F00)
  *
  * @param string border
  * @return void
  */
 function set_border($border)
 {
 $this->properties['border'] = $border;
 }

 /**
  * Tests whether a email is valid 
  * 
  * @param string $email 
  * @access public
  * @return void
  */
 function is_valid_email($email)
 {
 return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5})$/i", $email);
 }

 /**
  * Tests whether a gravatar exists
  * {@link http://codex.wordpress.org/Using_Gravatars}
  *
  * @return boolean
  */
 function avatar_exists()
 {
 // Craft a potential url and test its headers
 $hash = $this->properties['gravatar_id'];
 if (is_null($hash))
 return false;
 $uri = self::GRAVATAR_URL . $hash . '?d=404';
 $headers = @get_headers($uri);
 if (!preg_match('|200|', $headers[0]))
 return false;
 return true;
 }

 /**
  * Returns the email
  *
  * @return string
  */
 function get_email()
 {
 return $this->email;
 }

 /**
  * __get 
  * 
  * @param mixed $var 
  * @access protected
  * @return mixed
  */
 function __get($var)
 {
 return $this->properties[$var];
 }

 /**
  * __isset 
  * 
  * @param string $var 
  * @access protected
  * @return boolean
  */
 function __isset($var)
 {
 return isset($this->properties[$var]);
 }

 /**
  * __unset 
  * 
  * @param string $var 
  * @access protected
  * @return boolean
  */
 function __unset($var)
 {
 return @$this->properties[$var] == NULL;
 }


 /**
  * Returns the url of the avatar
  * 
  * @access public
  * @return string
  */
 function get_src()
 {
 $gravatar_id = $this->properties['gravatar_id'];
 $ext = (empty($this->file_extension)) ? '' : '.'.$this->file_extension;
 $url = self::GRAVATAR_URL.$gravatar_id.$ext.'?';
 $first = true;
 foreach($this->properties as $key => $value) {
 if (!is_null($value) && $key != 'gravatar_id') {
 if (!$first)
 $url .= '&';
 $url .= $key[0].'='.urlencode($value);
 $first = false;
 }
 }
 return $url; 
 }

 /**
  * Return the HTML <img> that represents the avatar 
  * 
  * @access public
  * @return string
  */
 function to_HTML()
 {
 return  '<img src="'.$this->get_src().'"'
 .(!isset($this->size) ? '' : " width=\"{$this->size}\" height=\"{$this->size}\"")
 ." {$this->extra}/>"; 
 }

 /**
  * __toString 
  * 
  * @access protected
  * @return string
  */
 function __toString()
 {
 return $this->to_HTML();
 }
}

if my provider finds a blocked something i will add it here.
 
At the least, there's a difference in URL from that library to ours (with vs with out the "www"), so that may be relevant. But if you submit a ticket with FTP details, I'll attempt to create a minimal script to test the issue.
 
Back
Top Bottom