- 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'])
- );
- }
+
+ mark_for_death($contact);
+ }
+ else {
+ if($contact['term-date'] != '0000-00-00 00:00:00') {
+ logger("poller: $url back from the dead - removing mark for death");
+ unmark_for_death($contact);