From d11c1c63c02e88b3c73336741a2240ccc18d3b02 Mon Sep 17 00:00:00 2001
From: Mike Macgirvin <mike@macgirvin.com>
Date: Sun, 8 Aug 2010 21:03:08 -0700
Subject: [PATCH] lots of fixes - most recent photo updates for contacts

---
 boot.php                  |  23 +++++----
 database.sql              |   3 ++
 include/items.php         |   8 ++-
 include/poller.php        |  51 +++++++++++++++++-
 index.php                 |   6 +++
 mod/dfrn_confirm.php      |  10 +++-
 mod/dfrn_notify.php       |   5 +-
 mod/photos.php            |   2 +-
 mod/profile_photo.php     |   5 ++
 mod/profiles.php          |  20 ++++++--
 mod/register.php          |  10 ++--
 simplepie/simplepie.inc   | 105 +++++++++++++++++++++++++++++++++++---
 view/atom_feed.tpl        |   8 +--
 view/profile_advanced.php |  20 ++++----
 view/style.css            |   2 +-
 15 files changed, 231 insertions(+), 47 deletions(-)

diff --git a/boot.php b/boot.php
index c1fbf2985..e70e2bf6b 100644
--- a/boot.php
+++ b/boot.php
@@ -177,19 +177,20 @@ function replace_macros($s,$r) {
 }}
 
 
+if(! function_exists('load_translation_table')) {
 function load_translation_table($lang) {
 	global $a;
 
-}
-
+}}
 
+if(! function_exists('t')) {
 function t($s) {
 	global $a;
 
 	if($a->strings[$s])
 		return $a->strings[$s];
 	return $s;
-}
+}}
 
 if(! function_exists('fetch_url')) {
 function fetch_url($url,$binary = false) {
@@ -423,17 +424,20 @@ function xmlify($str) {
 	return($buffer);
 }}
 
+if(! function_exists('unxmlify')) {
 function unxmlify($s) {
 	$ret = str_replace('&amp;','&', $s);
 	$ret = str_replace(array('&lt;','&gt;','&quot;','&apos;'),array('<','>','"',"'"),$ret);
 	return $ret;	
-}
+}}
 
+if(! function_exists('hex2bin')) {
 function hex2bin($s) {
 	return(pack("H*",$s));
-}
+}}
 
 
+if(! function_exists('paginate')) {
 function paginate(&$a) {
 	$o = '';
 	$stripped = ereg_replace("(&page=[0-9]*)","",$_SERVER['QUERY_STRING']);
@@ -483,8 +487,9 @@ function paginate(&$a) {
 		$o .= '</div>'."\r\n";
 	}
 	return $o;
-}
+}}
 
+if(! function_exists('expand_acl')) {
 function expand_acl($s) {
 
 	if(strlen($s)) {
@@ -495,9 +500,9 @@ function expand_acl($s) {
 		return $a;
 	}
 	return array();
-}		
-
+}}		
 
+if(! function_exists('sanitise_acl')) {
 function sanitise_acl(&$item) {
 	$item = '<' . intval(notags(trim($item))) . '>';
-}
+}}
diff --git a/database.sql b/database.sql
index 1411ec6da..eeba76f7e 100644
--- a/database.sql
+++ b/database.sql
@@ -60,6 +60,9 @@ CREATE TABLE IF NOT EXISTS `contact` (
   `ret-id` char(255) NOT NULL,
   `ret-pubkey` text NOT NULL,
   `last-update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `name-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `uri-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `avatar-date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
   `priority` tinyint(3) NOT NULL,
   `blocked` tinyint(1) NOT NULL DEFAULT '1',
   `readonly` tinyint(1) NOT NULL DEFAULT '0',
diff --git a/include/items.php b/include/items.php
index e74132c6a..876f92330 100644
--- a/include/items.php
+++ b/include/items.php
@@ -61,6 +61,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
 
 	$r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
 		`contact`.`name`, `contact`.`photo`, `contact`.`url`, 
+		`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
 		`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, 
 		`contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid`
 		FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@@ -91,7 +92,12 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) {
 			'$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
 			'$name' => xmlify($owner['name']),
 			'$profile_page' => xmlify($owner['url']),
-			'$photo' => xmlify($owner['photo'])
+			'$photo' => xmlify($owner['photo']),
+			'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+			'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+			'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
+
+
 	));
 
 	foreach($items as $item) {
diff --git a/include/poller.php b/include/poller.php
index be073b93b..0ef4d126a 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -123,6 +123,51 @@ echo "Length:" . strlen($xml) . "\r\n";
 		$feed->enable_order_by_date(false);
 		$feed->init();
 
+		$photo_rawupdate = $feed->get_feed_tags(NAMESPACE_DFRN,'icon-updated');
+		if($photo_rawupdate) {
+			$photo_timestamp = datetime_convert('UTC','UTC',$photo_rawupdate[0]['data']);
+			$photo_url = $feed->get_image_url();
+			if(strlen($photo_url) && $photo_timestamp > $contact['avatar-date']) {
+
+				require_once("Photo.php");
+
+				$photo_failure = false;
+
+				$r = q("SELECT `resource-id` FROM `photo` WHERE `contact-id` = %d AND `uid` = %d LIMIT 1",
+					intval($contact['id']),
+					intval($contact['uid'])
+				);
+				if(count($r)) {
+					$resource_id = $r[0]['resource-id'];
+					$img_str = fetch_url($photo_url,true);
+					$img = new Photo($img_str);
+					if($img) {
+						q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND contact-id` = %d AND `uid` = %d",
+							dbesc($resource_id),
+							intval($contact['id']),
+							intval($contact['uid'])
+						);
+
+						$img->scaleImageSquare(175);
+					
+						$hash = $resource_id;
+
+						$r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 4);
+					
+						$img->scaleImage(80);
+						$r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), t('Contact Photos') , 5);
+						if($r)
+							q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
+								dbesc(datetime_convert()),
+								intval($contact['uid']),
+								intval($contact['id'])
+							);
+					}
+				}
+			}
+		}
+
+		
 		foreach($feed->get_items() as $item) {
 
 			$deleted = false;
@@ -145,14 +190,16 @@ echo "Length:" . strlen($xml) . "\r\n";
 				);
 				if(count($r)) {
 					if($r[0]['uri'] == $r[0]['parent-uri']) {
-						$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s'
+						$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s',
+							`body` = '', `title` = ''
 							WHERE `parent-uri` = '%s'",
 							dbesc($when),
 							dbesc($r[0]['uri'])
 						);
 					}
 					else {
-						$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s' 
+						$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s',
+							`body` = '', `title` = '' 
 							WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
 							dbesc($when),
 							dbesc($uri),
diff --git a/index.php b/index.php
index e27d6f04f..2353355f0 100644
--- a/index.php
+++ b/index.php
@@ -36,6 +36,7 @@ if(strlen($a->module)) {
 		$a->module_loaded = true;
 	}
 	else {
+		header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
 		notice( t('Page not found' ) . EOL);
 	}
 }
@@ -88,6 +89,11 @@ if(x($_SESSION,'sysmsg')) {
 	unset($_SESSION['sysmsg']);
 }
 
+if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
+	header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
+}
+
+
 // Feel free to comment out this line on production sites.
 $a->page['content'] .= $debug_text;
 
diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php
index a8a4b3b99..359ddef17 100644
--- a/mod/dfrn_confirm.php
+++ b/mod/dfrn_confirm.php
@@ -116,9 +116,12 @@ function dfrn_confirm_post(&$a) {
 				$thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
 			}
 
-			$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1",
+			$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1",
 				dbesc($photo),
 				dbesc($thumb),
+				dbesc(datetime_convert()),
+				dbesc(datetime_convert()),
+				dbesc(datetime_convert()),
 				intval($dfrn_record)
 			);
 			if($r === false)
@@ -322,9 +325,12 @@ function dfrn_confirm_post(&$a) {
 			$thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg';
 		}
 
-		$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1",
+		$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `name-date` = '%s', `uri-date` = '%s', `avatar-date` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1",
 			dbesc($photo),
 			dbesc($thumb),
+			dbesc(datetime_convert()),
+			dbesc(datetime_convert()),
+			dbesc(datetime_convert()),
 			intval($contact_id)
 		);
 		if($r === false)
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 5655977e5..6aed53a77 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -47,6 +47,9 @@ function dfrn_notify_post(&$a) {
 	$feed->init();
 
 	$ismail = false;
+	$photo_time = $feed->get_feed_tags( NAMESPACE_DFRN, 'icon-updated');
+	if($photo_time)
+		$avatar_update = $photo_time[0]['data'];
 
 	$rawmail = $feed->get_feed_tags( NAMESPACE_DFRN, 'mail' );
 	if(isset($rawmail[0]['child'][NAMESPACE_DFRN])) {
@@ -57,7 +60,7 @@ function dfrn_notify_post(&$a) {
 		$msg['uid'] = $importer['uid'];
 		$msg['from-name'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['name'][0]['data']));
 		$msg['from-photo'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']));
-		$msg['from-url'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['avatar'][0]['data']));
+		$msg['from-url'] = notags(unxmlify($base['sender'][0]['child'][NAMESPACE_DFRN]['uri'][0]['data']));
 		$msg['contact-id'] = $importer['id'];
 		$msg['title'] = notags(unxmlify($base['subject'][0]['data']));
 		$msg['body'] = escape_tags(unxmlify($base['content'][0]['data']));
diff --git a/mod/photos.php b/mod/photos.php
index 81d071829..7b07f6729 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -375,7 +375,7 @@ function photos_post(&$a) {
 		$dups = false;
 		$item_hash = random_string();
 
-		$uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $profile_uid . ':' . $item_hash;
+		$uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $_SESSION['uid'] . ':' . $item_hash;
 
 		$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1",
 		dbesc($uri));
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index 151277249..ebd9f1b48 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -74,6 +74,11 @@ function profile_photo_post(&$a) {
 				intval($_SESSION['uid'])
 			);
 
+			$r = q("UPDATE `contact` SET `avatar-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
+				dbesc(datetime_convert()),
+				intval($_SESSION['uid'])
+			);
+
 		}
 		goaway($a->get_baseurl() . '/profiles');
 		return; // NOTREACHED
diff --git a/mod/profiles.php b/mod/profiles.php
index db4426474..bfdff5f6b 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -7,16 +7,19 @@ function profiles_post(&$a) {
 		notice( "Permission denied." . EOL);
 		return;
 	}
+
+	$namechanged = false;
+
 	if(($a->argc > 1) && ($a->argv[1] != "new") && intval($a->argv[1])) {
-		$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+		$orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
 			intval($a->argv[1]),
 			intval($_SESSION['uid'])
 		);
-		if(! count($r)) {
+		if(! count($orig)) {
 			$_SESSION['sysmsg'] .= "Profile not found." . EOL;
 			return;
 		}
-		$is_default = (($r[0]['is-default']) ? 1 : 0);
+		$is_default = (($orig[0]['is-default']) ? 1 : 0);
 
 		$profile_name = notags(trim($_POST['profile_name']));
 		if(! strlen($profile_name)) {
@@ -39,6 +42,10 @@ function profiles_post(&$a) {
 
 			
 		$name = notags(trim($_POST['name']));
+
+		if($orig[0]['name'] != $name)
+			$namechanged = true;
+
 		$gender = notags(trim($_POST['gender']));
 		$address = notags(trim($_POST['address']));
 		$locality = notags(trim($_POST['locality']));
@@ -132,7 +139,12 @@ function profiles_post(&$a) {
 
 			);
 		}
-
+		if($namechanged && $is_default) {
+			$r = q("UPDATE `contact` SET `name-date` = '%s' WHERE `self` = 1 AND `uid` = %d LIMIT 1",
+				dbesc(datetime_convert()),
+				intval($_SESSION['uid'])
+			);
+		}
 
 	}
 
diff --git a/mod/register.php b/mod/register.php
index 62f4e60dc..65b7fa6be 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -138,8 +138,8 @@ function register_post(&$a) {
 			return;
 		}
 		$r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `photo`, `thumb`, `blocked`, `pending`, `url`,
-			`request`, `notify`, `poll`, `confirm` )
-			VALUES ( %d, '%s', 1, '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s' ) ",
+			`request`, `notify`, `poll`, `confirm`, `name-date`, `uri-date`, `avatar-date` )
+			VALUES ( %d, '%s', 1, '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
 			intval($newuid),
 			datetime_convert(),
 			dbesc($username),
@@ -149,8 +149,10 @@ function register_post(&$a) {
 			dbesc($a->get_baseurl() . "/dfrn_request/$nickname"),
 			dbesc($a->get_baseurl() . "/dfrn_notify/$nickname"),
 			dbesc($a->get_baseurl() . "/dfrn_poll/$nickname"),
-			dbesc($a->get_baseurl() . "/dfrn_confirm/$nickname")
-
+			dbesc($a->get_baseurl() . "/dfrn_confirm/$nickname"),
+			dbesc(datetime_convert()),
+			dbesc(datetime_convert()),
+			dbesc(datetime_convert())
 		);
 
 
diff --git a/simplepie/simplepie.inc b/simplepie/simplepie.inc
index cd5f46944..185e17bcc 100644
--- a/simplepie/simplepie.inc
+++ b/simplepie/simplepie.inc
@@ -2432,6 +2432,10 @@ class SimplePie
 			$uri = null;
 			$email = null;
 			$avatar = null;
+			$name_date = null;
+			$uri_date = null;
+			$avatar_date = null;
+
 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
 			{
 				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
@@ -2446,11 +2450,24 @@ class SimplePie
 			}
 			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']))
 			{
-				$avatar = $this->sanitize($$author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]));
+				$avatar = $this->sanitize($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]));
 			}
-			if ($name !== null || $email !== null || $uri !== null || $avatar !== null)
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data']))
 			{
-				$authors[] = new $this->author_class($name, $uri, $email, $avatar);
+				$name_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data']))
+			{
+				$uri_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data']))
+			{
+				$avatar_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data'];
+			}
+
+			if ($name !== null || $email !== null || $uri !== null || $avatar !== null || $name_date !== null || $uri_date !== null || $avatar_date !== null )
+			{
+				$authors[] = new $this->author_class($name, $uri, $email, $avatar, $name_date, $uri_date, $avatar_date);
 			}
 		}
 		if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
@@ -3481,6 +3498,9 @@ class SimplePie_Item
 			$uri = null;
 			$email = null;
 			$avatar = null;
+			$name_date = null;
+			$uri_date = null;
+			$avatar_date = null;
 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
 			{
 				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
@@ -3497,10 +3517,22 @@ class SimplePie_Item
 			{
 				$avatar = $this->sanitize($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]));
 			}
-			if ($name !== null || $email !== null || $uri !== null || $avatar !== null)
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data']))
 			{
-				$authors[] = new $this->feed->author_class($name, $uri, $email, $avatar);
+				$name_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data']))
+			{
+				$uri_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data']))
+			{
+				$avatar_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data'];
+			}
 
+			if ($name !== null || $email !== null || $uri !== null || $avatar !== null || $name_date !== null || $uri_date !== null || $avatar_date !== null )
+			{
+				$authors[] = new $this->feed->author_class($name, $uri, $email, $avatar, $name_date, $uri_date, $avatar_date);
 			}
 		}
 		if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
@@ -5909,6 +5941,10 @@ class SimplePie_Source
 			$uri = null;
 			$email = null;
 			$avatar = null;
+			$name_date = null;
+			$uri_date = null;
+			$avatar_date = null;
+
 			if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']))
 			{
 				$name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
@@ -5921,13 +5957,26 @@ class SimplePie_Source
 			{
 				$email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT);
 			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']))
 			{
 				$avatar = $this->sanitize($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]));
 			}
-			if ($name !== null || $email !== null || $uri !== null || $avatar !== null)
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data']))
 			{
-				$authors[] = new $this->item->feed->author_class($name, $uri, $email, $avatar);
+				$name_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['name-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data']))
+			{
+				$uri_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['uri-updated'][0]['data'];
+			}
+			if (isset($author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data']))
+			{
+				$avatar_date = $author['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar-updated'][0]['data'];
+			}
 
+			if ($name !== null || $email !== null || $uri !== null || $avatar !== null || $name_date !== null || $uri_date !== null || $avatar_date !== null )
+			{
+				$authors[] = new $this->item->feed->author_class($name, $uri, $email, $avatar, $name_date, $uri_date, $avatar_date);
 			}
 		}
 		if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author'))
@@ -6300,14 +6349,20 @@ class SimplePie_Author
 	var $link;
 	var $email;
 	var $avatar;
+	var $name_date;
+	var $uri_date;
+	var $avatar_date;
 
 	// Constructor, used to input the data
-	function SimplePie_Author($name = null, $link = null, $email = null, $avatar = null)
+	function SimplePie_Author($name = null, $link = null, $email = null, $avatar = null, $name_date = null, $uri_date = null, $avatar_date = null)
 	{
 		$this->name = $name;
 		$this->link = $link;
 		$this->email = $email;
 		$this->avatar = $avatar;
+		$this->name_date = $name_date;
+		$this->uri_date = $uri_date;
+		$this->avatar_date = $avatar_date;
 	}
 
 	function __toString()
@@ -6364,6 +6419,40 @@ class SimplePie_Author
 		}
 	}
 
+	function get_name_date()
+	{
+		if ($this->name_date !== null)
+		{
+			return $this->name_date;
+		}
+		else
+		{
+			return null;
+		}
+	}
+	function get_uri_date()
+	{
+		if ($this->uri_date !== null)
+		{
+			return $this->uri_date;
+		}
+		else
+		{
+			return null;
+		}
+	}
+	function get_avatar_date()
+	{
+		if ($this->avatar_date !== null)
+		{
+			return $this->avatar_date;
+		}
+		else
+		{
+			return null;
+		}
+	}
+
 
 }
 
diff --git a/view/atom_feed.tpl b/view/atom_feed.tpl
index a620a2578..fc2816ef9 100644
--- a/view/atom_feed.tpl
+++ b/view/atom_feed.tpl
@@ -7,14 +7,14 @@
   <id>$feed_id</id>
   <title>$feed_title</title>
   <icon>$photo</icon>
-  <dfrn:icon-updated>0000-00-00T00:00:00Z</dfrn:icon-updated>
+  <dfrn:icon-updated>$picdate</dfrn:icon-updated>
   <updated>$feed_updated</updated>
 
   <author>
     <name>$name</name>
-    <dfrn:name-updated>0000-00-00T00:00:00Z</dfrn:name-updated>
+    <dfrn:name-updated>$namdate</dfrn:name-updated>
     <uri>$profile_page</uri>
-    <dfrn:uri-updated>0000-00-00T00:00:00Z</dfrn:uri-updated>
+    <dfrn:uri-updated>$uridate</dfrn:uri-updated>
     <dfrn:avatar>$thumb</dfrn:avatar>
-    <dfrn:avatar-updated>0000-00-00T00:00:00Z</dfrn:avatar-updated>
+    <dfrn:avatar-updated>$picdate</dfrn:avatar-updated>
  </author>
diff --git a/view/profile_advanced.php b/view/profile_advanced.php
index 78053fe0b..73a155409 100644
--- a/view/profile_advanced.php
+++ b/view/profile_advanced.php
@@ -60,7 +60,7 @@ EOT;
 if($a->profile['marital']) {
 $o .= <<< EOT
 <div id="advanced-profile-marital-wrapper" >
-<div id="advanced-profile-marital-text">Status:</div>
+<div id="advanced-profile-marital-text"><span class="heart">&hearts;</span> Status:</div>
 <div id="advanced-profile-marital">{$a->profile['marital']}</div>
 </div>
 <div id="advanced-profile-marital-end"></div>
@@ -90,7 +90,7 @@ EOT;
 if($a->profile['politic']) {
 $o .= <<< EOT
 <div id="advanced-profile-politic-wrapper" >
-<div id="advanced-profile-politic-text">Political Leaning:</div>
+<div id="advanced-profile-politic-text">Political Views:</div>
 <div id="advanced-profile-politic">{$a->profile['politic']}</div>
 </div>
 <div id="advanced-profile-politic-end"></div>
@@ -121,7 +121,7 @@ EOT;
 if($txt = bbcode($a->profile['interest'])) {
 $o .= <<< EOT
 <div id="advanced-profile-interest-wrapper" >
-<div id="advanced-profile-interest-text">Interests/Hobbies:</div>
+<div id="advanced-profile-interest-text">Hobbies/Interests:</div>
 <br />
 <div id="advanced-profile-interest">$txt</div>
 </div>
@@ -132,7 +132,7 @@ EOT;
 if($txt = bbcode($a->profile['contact'])) {
 $o .= <<< EOT
 <div id="advanced-profile-contact-wrapper" >
-<div id="advanced-profile-contact-text">Contact:</div>
+<div id="advanced-profile-contact-text">Contact information and Social Networks:</div>
 <br />
 <div id="advanced-profile-contact">$txt</div>
 </div>
@@ -143,7 +143,7 @@ EOT;
 if($txt = bbcode($a->profile['music'])) {
 $o .= <<< EOT
 <div id="advanced-profile-music-wrapper" >
-<div id="advanced-profile-music-text">Music:</div>
+<div id="advanced-profile-music-text">Musical interests:</div>
 <br />
 <div id="advanced-profile-music">$txt</div>
 </div>
@@ -154,7 +154,7 @@ EOT;
 if($txt = bbcode($a->profile['book'])) {
 $o .= <<< EOT
 <div id="advanced-profile-book-wrapper" >
-<div id="advanced-profile-book-text">Books:</div>
+<div id="advanced-profile-book-text">Books, literature:</div>
 <br />
 <div id="advanced-profile-book">$txt</div>
 </div>
@@ -176,7 +176,7 @@ EOT;
 if($txt = bbcode($a->profile['film'])) {
 $o .= <<< EOT
 <div id="advanced-profile-film-wrapper" >
-<div id="advanced-profile-film-text">Film:</div>
+<div id="advanced-profile-film-text">Film/dance/culture/entertainment:</div>
 <br />
 <div id="advanced-profile-film">$txt</div>
 </div>
@@ -187,7 +187,7 @@ EOT;
 if($txt = bbcode($a->profile['romance'])) {
 $o .= <<< EOT
 <div id="advanced-profile-romance-wrapper" >
-<div id="advanced-profile-romance-text">Romance:</div>
+<div id="advanced-profile-romance-text">Love/romance:</div>
 <br />
 <div id="advanced-profile-romance">$txt</div>
 </div>
@@ -198,7 +198,7 @@ EOT;
 if($txt = bbcode($a->profile['work'])) {
 $o .= <<< EOT
 <div id="advanced-profile-work-wrapper" >
-<div id="advanced-profile-work-text">work:</div>
+<div id="advanced-profile-work-text">Work/employment:</div>
 <br />
 <div id="advanced-profile-work">$txt</div>
 </div>
@@ -209,7 +209,7 @@ EOT;
 if($txt = bbcode($a->profile['education'])) {
 $o .= <<< EOT
 <div id="advanced-profile-education-wrapper" >
-<div id="advanced-profile-education-text">Education:</div>
+<div id="advanced-profile-education-text">School/education:</div>
 <br />
 <div id="advanced-profile-education">$txt</div>
 </div>
diff --git a/view/style.css b/view/style.css
index 777f938b8..c3dee16c3 100644
--- a/view/style.css
+++ b/view/style.css
@@ -832,7 +832,7 @@ input#dfrn-url {
 #advanced-profile-romance-text,
 #advanced-profile-work-text,
 #advanced-profile-education-text {
-	width: 250px;
+	width: 300px;
 	float: left;
 }