Ok I’ve fixed the code, the mistake was I appended the gravatar id onto the address of the image, and I dont think the cache worked anyway so you were right to take it out
if you replace all the functions that were added to display the gravatar with the ones bellow then it’ll all start working how its supposed to
it checks the cache for an existing gravatar, if its not found or has expired the it is requested from gravatar.com, if its not found at gravatar.com or the site cant be reached the none image is used unless theres a cached copy.
function wp_gravatar_info($md5 = ‘’) {
if (’’ == $md5) { return false; }
$r = array();
$foo = @file("http://www.gravatar.com/info/md5/$md5");
if (! $foo) return false;
array_shift($foo); // strip leading <xml ...> declaration
array_shift($foo); // strip opening <gravatar>
array_pop($foo); // strip closing <gravatar>
foreach ($foo as $bar) {
$matched = array();
preg_match_all("/([^<>])+/", $bar, $matched);
$r[$matched[0][1]] = $matched[0][2];
}
return $r;
}
function Download_Gravatar($id, $local, $remote)
{
// we don’t know about this gravatar yet, let’s look for it
$response = wp_gravatar_info($id);
if (’200’ == $response)
{
// it’s not an error, so let’s make a local copy
if ( (is_writeable($local)) && (ini_get(’allow_url_fopen’)) )
{
$cached = copy ($remote.$id, $local.$id.".TMP");
if (! $cached)
{
// looks like the copy failed, delete the TMP
unlink($local.$id.".TMP");
return 0;
} else
{
// we copied successfully
rename($local.$id.".TMP", $local.$id);
return 1;
}
}
} else {
return 0;
}
}
function Gravitar_Cached($id, $local, $remote)
{
$cachetime="34200";
if(file_exists($local.$id))
//if the file exists on the server
{
//check its date
$now=time();
$ftime=filemtime($local.$id);
//echo “boo”.filectime($remote.$id);
if($now-$ftime>$cachetime)
//if the time difference is more then the cache time then get a newer copy
{
//download it
Download_Gravatar($id, $local, $remote);
}
return 1;
}else
{
//download it its new
return Download_Gravatar($id, $local, $remote);
}
}
function GetGravatar($email)
//function to return the gravitar requiered
{
$gravatar_url="http://www.gravatar.com/avatar.php?gravatar_id=";
$gravatar_id=md5($email);
$gravatar_local=$_SERVER[’DOCUMENT_ROOT’] . “/pMachine/gravatarcache/”;
$gravatar_local_url=$_SERVER[’SERVER_ROOT’] . “/pMachine/gravatarcache/”;
$gravatar_none=$_SERVER[’SERVER_ROOT’] . “/pMachine/gravatarcache/none.gif”;
if(Gravitar_Cached($gravatar_id, $gravatar_local, $gravatar_url))
{
$gravatar_path=$gravatar_local_url.$gravatar_id;
$gravatar = “$gravatar_path”;
}else
{
$gravatar_path=$gravatar_none;
$gravatar = “<a href=’http://www.gravatar.com’ target=’_blank’ title=’Get your own gravatar from www.gravatar.com’>$gravatar_path</a>”;
}
return $gravatar;
}
hopefully that’ll do the trick, its all working on my site now so it should be fine for anyone else
good luck