All pastes #91597 Raw Edit

Unnamed

public php v1 · immutable
#91597 ·published 2006-07-18 19:17 UTC
rendered paste body
$g_gravatar_folder = $g_image_path.'gravatars/';$g_gravatar_cache = $g_gravatar_folder.'cache/';$g_gravatar_default = 'default.gif';function gravatar($email,$size=40) {	global $g_gravatar_folder;	global $g_gravatar_cache;	global $g_gravatar_default;		$gravatar_id = md5($email);	if(is_file($_SERVER['DOCUMENT_ROOT'].$g_gravatar_cache.$gravatar_id)) {		// ace, it's cached, serve it from here then		$gravatar_path = $g_gravatar_cache;	}	else {		// grab it from the site		$fetch_gravatar_url = 'http://www.gravatar.com/avatar.php?gravatar_id='.$gravatar_id; //'&size='.$size;		if(is_file($fetch_gravatar_url)) { // is_file is not true with URLS...			// the file exists, so we cache it			$fetch_gravatar_url_text = file_get_contents($fetch_gravatar_url);			$file_open = fopen($_SERVER['DOCUMENT_ROOT'].$g_gravatar_cache.$gravatar_id, 'x');			fwrite($file_open, $fetch_gravatar_url_text);			fclose($file_open);			$gravatar_path = $gravatar_path_cache;		}		else {			// no file, show the default one.			$gravatar_path = $g_gravatar_folder;			$gravatar_id = $g_gravatar_default;		}	}	return imageDetails($gravatar_id,'gravatar','normal',$gravatar_path);}RETURNS...Array(    [width] => 80    [height] => 80    [name] => a489725ad8451b6e87fcb9ed4f189cf9    [path] => /images/gravatars/cache/    [alt] => )Array(    [width] => 44    [height] => 43    [name] => default.gif    [path] => /images/gravatars/    [alt] => )Array(    [width] => 44    [height] => 43    [name] => default.gif    [path] => /images/gravatars/    [alt] => )