diff --git a/boot.php b/boot.php
index 4fc35be9bb..7fbd2a6fbd 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'BUILD_ID', 1035 );
+define ( 'BUILD_ID', 1037 );
define ( 'FRIENDIKA_VERSION', '2.10.0905' );
define ( 'DFRN_PROTOCOL_VERSION', '2.1' );
@@ -215,9 +215,19 @@ class App {
$this->scheme = ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'])) ? 'https' : 'http' );
- if(x($_SERVER,'SERVER_NAME'))
+ if(x($_SERVER,'SERVER_NAME')) {
$this->hostname = $_SERVER['SERVER_NAME'];
+ /**
+ * Figure out if we are running at the top of a domain
+ * or in a sub-directory and adjust accordingly
+ */
+
+ $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
+ if(isset($path) && strlen($path) && ($path != $this->path))
+ $this->path = $path;
+ }
+
set_include_path("include/$this->hostname" . PATH_SEPARATOR . 'include' . PATH_SEPARATOR . '.' );
if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'],0,2) === "q=")
@@ -225,14 +235,6 @@ class App {
if(x($_GET,'q'))
$this->cmd = trim($_GET['q'],'/\\');
- /**
- * Figure out if we are running at the top of a domain
- * or in a sub-directory and adjust accordingly
- */
-
- $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
- if(isset($path) && strlen($path) && ($path != $this->path))
- $this->path = $path;
/**
@@ -295,8 +297,20 @@ class App {
}
function set_baseurl($url) {
+ $parsed = parse_url($url);
+
$this->baseurl = $url;
- $this->hostname = basename($url);
+
+ if($parsed) {
+ $this->scheme = $parsed['scheme'];
+
+ $this->hostname = $parsed['host'];
+ if($parsed['port'])
+ $this->hostname .= ':' . $parsed['port'];
+ if($parsed['path'])
+ $this->path = trim($parsed['path'],'\\/');
+ }
+
}
function get_hostname() {
@@ -406,8 +420,12 @@ function system_unavailable() {
if(! function_exists('check_config')) {
function check_config(&$a) {
+
load_config('system');
+ if(! x($_SERVER,'SERVER_NAME'))
+ return;
+
$build = get_config('system','build');
if(! x($build))
$build = set_config('system','build',BUILD_ID);
@@ -608,7 +626,16 @@ function fetch_url($url,$binary = false, &$redirects = 0) {
}
}
$a->set_curl_code($http_code);
+
$body = substr($s,strlen($header)+4);
+
+ /* one more try to make sure there are no more headers */
+
+ if(strpos($body,'HTTP/') === 0) {
+ $header = substr($body,0,strpos($body,"\r\n\r\n"));
+ $body = substr($body,strlen($header)+4);
+ }
+
$a->set_curl_headers($header);
curl_close($ch);
@@ -672,6 +699,14 @@ function post_url($url,$params, $headers = null, &$redirects = 0) {
}
$a->set_curl_code($http_code);
$body = substr($s,strlen($header)+4);
+
+ /* one more try to make sure there are no more headers */
+
+ if(strpos($body,'HTTP/') === 0) {
+ $header = substr($body,0,strpos($body,"\r\n\r\n"));
+ $body = substr($body,strlen($header)+4);
+ }
+
$a->set_curl_headers($header);
curl_close($ch);
@@ -744,7 +779,7 @@ function login($register = false) {
$lostpass = t('Forgot your password?');
$lostlink = t('Password Reset');
- if(x($_SESSION,'authenticated')) {
+ if(local_user()) {
$tpl = load_view_file("view/logout.tpl");
}
else {
@@ -754,12 +789,12 @@ function login($register = false) {
$o = replace_macros($tpl,array(
'$register_html' => $register_html,
- '$classname' => $classname,
- '$namelabel' => $namelabel,
- '$passlabel' => $passlabel,
- '$login' => $login,
- '$lostpass' => $lostpass,
- '$lostlink' => $lostlink
+ '$classname' => $classname,
+ '$namelabel' => $namelabel,
+ '$passlabel' => $passlabel,
+ '$login' => $login,
+ '$lostpass' => $lostpass,
+ '$lostlink' => $lostlink
));
return $o;
@@ -1248,7 +1283,7 @@ function del_pconfig($uid,$family,$key) {
unset($a->config[$uid][$family][$key]);
$ret = q("DELETE FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
intval($uid),
- dbesc($cat),
+ dbesc($family),
dbesc($key)
);
return $ret;
@@ -2275,3 +2310,117 @@ function proc_run($cmd){
proc_close(proc_open($cmdline." &",array(),$foo));
}}
+/*
+ * Return full URL to theme which is currently in effect.
+ * Provide a sane default if nothing is chosen or the specified theme does not exist.
+ */
+
+if(! function_exists('current_theme_url')) {
+function current_theme_url() {
+
+ $app_base_themes = array('duepuntozero', 'loozah');
+
+ $a = get_app();
+
+ $system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
+ $theme_name = ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $system_theme);
+
+ if($theme_name && file_exists('view/theme/' . $theme_name . '/style.css'))
+ return($a->get_baseurl() . '/view/theme/' . $theme_name . '/style.css');
+
+ foreach($app_base_themes as $t) {
+ if(file_exists('view/theme/' . $t . '/style.css'))
+ return($a->get_baseurl() . '/view/theme/' . $t . '/style.css');
+ }
+
+ $fallback = glob('view/theme/*/style.css');
+ if(count($fallback))
+ return($a->get_baseurl() . $fallback[0]);
+
+
+}}
+
+if(! function_exists('feed_birthday')) {
+function feed_birthday($uid,$tz) {
+
+ /**
+ *
+ * Determine the next birthday, but only if the birthday is published
+ * in the default profile. We _could_ also look for a private profile that the
+ * recipient can see, but somebody could get mad at us if they start getting
+ * public birthday greetings when they haven't made this info public.
+ *
+ * Assuming we are able to publish this info, we are then going to convert
+ * the start time from the owner's timezone to UTC.
+ *
+ * This will potentially solve the problem found with some social networks
+ * where birthdays are converted to the viewer's timezone and salutations from
+ * elsewhere in the world show up on the wrong day. We will convert it to the
+ * viewer's timezone also, but first we are going to convert it from the birthday
+ * person's timezone to GMT - so the viewer may find the birthday starting at
+ * 6:00PM the day before, but that will correspond to midnight to the birthday person.
+ *
+ */
+
+ $birthday = '';
+
+ $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
+ intval($uid)
+ );
+
+ if($p && count($p)) {
+ $tmp_dob = substr($p[0]['dob'],5);
+ if(intval($tmp_dob)) {
+ $y = datetime_convert($tz,$tz,'now','Y');
+ $bd = $y . '-' . $tmp_dob . ' 00:00';
+ $t_dob = strtotime($bd);
+ $now = strtotime(datetime_convert($tz,$tz,'now'));
+ if($t_dob < $now)
+ $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
+ $birthday = datetime_convert($tz,'UTC',$bd,ATOM_TIME);
+ }
+ }
+
+ return $birthday;
+}}
+
+/**
+ * return atom link elements for all of our hubs
+ */
+
+if(! function_exists('feed_hublinks')) {
+function feed_hublinks() {
+
+ $hub = get_config('system','huburl');
+
+ $hubxml = '';
+ if(strlen($hub)) {
+ $hubs = explode(',', $hub);
+ if(count($hubs)) {
+ foreach($hubs as $h) {
+ $h = trim($h);
+ if(! strlen($h))
+ continue;
+ $hubxml .= '' . "\n" ;
+ }
+ }
+ }
+ return $hubxml;
+}}
+
+/* return atom link elements for salmon endpoints */
+
+if(! function_exists('feed_salmonlinks')) {
+function feed_salmonlinks($nick) {
+
+ $a = get_app();
+
+ $salmon = '' . "\n" ;
+
+ // old style links that status.net still needed as of 12/2010
+
+ $salmon .= ' ' . "\n" ;
+ $salmon .= ' ' . "\n" ;
+ return $salmon;
+}}
+
diff --git a/database.sql b/database.sql
index 817fd09226..83e0e4b6f4 100644
--- a/database.sql
+++ b/database.sql
@@ -77,6 +77,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
`subhub` tinyint(1) NOT NULL DEFAULT '0',
`hub-verify` char(255) NOT NULL,
`last-update` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `success_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',
diff --git a/htconfig.php b/htconfig.php
index 5f5c76cbd7..fb62245d21 100644
--- a/htconfig.php
+++ b/htconfig.php
@@ -64,6 +64,10 @@ $a->config['system']['huburl'] = 'http://pubsubhubbub.appspot.com';
$a->config['system']['rino_encrypt'] = true;
+// default system theme
+
+$a->config['system']['theme'] = 'duepuntozero';
+
// Addons or plugins are configured here.
// This is a comma seperated list of addons to enable. Example:
diff --git a/include/items.php b/include/items.php
index 15fd262f4c..cffd13a01e 100644
--- a/include/items.php
+++ b/include/items.php
@@ -9,74 +9,27 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
// default permissions - anonymous user
- $sql_extra = "
- AND `allow_cid` = ''
- AND `allow_gid` = ''
- AND `deny_cid` = ''
- AND `deny_gid` = ''
- ";
-
- if(strlen($owner_nick) && ! intval($owner_nick)) {
- $r = q("SELECT `uid`, `nickname`, `timezone` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
- dbesc($owner_nick)
- );
- if(count($r)) {
- $owner_id = $r[0]['uid'];
- $owner_nick = $r[0]['nickname'];
- $owner_tz = $r[0]['timezone'];
- }
- }
-
- $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
- intval($owner_id)
- );
- if(count($r)) {
- $owner = $r[0];
- $owner['nickname'] = $owner_nick;
- }
- else
+ if(! strlen($owner_nick))
killme();
+ $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
- /**
- *
- * Determine the next birthday, but only if the birthday is published
- * in the default profile. We _could_ also look for a private profile that the
- * recipient can see, but somebody could get mad at us if they start getting
- * public birthday greetings when they haven't made this info public.
- *
- * Assuming we are able to publish this info, we are then going to convert
- * the start time from the owner's timezone to UTC.
- *
- * This will potentially solve the problem found with some social networks
- * where birthdays are converted to the viewer's timezone and salutations from
- * elsewhere in the world show up on the wrong day. We will convert it to the
- * viewer's timezone also, but first we are going to convert it from the birthday
- * person's timezone to GMT - so the viewer may find the birthday starting at
- * 6:00PM the day before, but that will correspond to midnight to the birthday person.
- *
- */
-
- $birthday = '';
-
- $p = q("SELECT `dob` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
- intval($owner_id)
+ $r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`
+ FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
+ WHERE `contact`.`self` = 1 AND `user`.`nickname` = '%s' LIMIT 1",
+ dbesc($owner_nick)
);
- if($p && count($p)) {
- $tmp_dob = substr($p[0]['dob'],5);
- if(intval($tmp_dob)) {
- $y = datetime_convert($owner_tz,$owner_tz,'now','Y');
- $bd = $y . '-' . $tmp_dob . ' 00:00';
- $t_dob = strtotime($bd);
- $now = strtotime(datetime_convert($owner_tz,$owner_tz,'now'));
- if($t_dob < $now)
- $bd = $y + 1 . '-' . $tmp_dob . ' 00:00';
- $birthday = datetime_convert($owner_tz,'UTC',$bd,ATOM_TIME);
- }
- }
+ if(! count($r))
+ killme();
- if($dfrn_id && $dfrn_id != '*') {
+ $owner = $r[0];
+ $owner_id = $owner['user_uid'];
+ $owner_nick = $owner['nickname'];
+
+ $birthday = feed_birthday($owner_id,$owner['timezone']);
+
+ if(strlen($dfrn_id)) {
$sql_extra = '';
switch($direction) {
@@ -102,7 +55,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
);
if(! count($r))
- return false;
+ killme();
$contact = $r[0];
$groups = init_groups_visitor($contact['id']);
@@ -156,7 +109,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
);
// Will check further below if this actually returned results.
- // We will provide an empty feed in any case.
+ // We will provide an empty feed if that is the case.
$items = $r;
@@ -164,25 +117,9 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$atom = '';
- $hub = get_config('system','huburl');
-
- $hubxml = '';
- if(strlen($hub)) {
- $hubs = explode(',', $hub);
- if(count($hubs)) {
- foreach($hubs as $h) {
- $h = trim($h);
- if(! strlen($h))
- continue;
- $hubxml .= '' . "\n" ;
- }
- }
- }
-
- $salmon = '' . "\n" ;
- $salmon .= '' . "\n" ;
- $salmon .= '' . "\n" ;
+ $hubxml = feed_hublinks();
+ $salmon = feed_salmonlinks($owner_nick);
$atom .= replace_macros($feed_template, array(
'$version' => xmlify(FRIENDIKA_VERSION),
@@ -215,7 +152,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
// public feeds get html, our own nodes use bbcode
- if($dfrn_id === '*') {
+ if($dfrn_id === '') {
$type = 'html';
}
else {
@@ -922,12 +859,12 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
}
-/*
+/**
*
* consume_feed - process atom feed and update anything/everything we might need to update
*
- * $xml = the (atom) feed to consume - no RSS spoken here, it might partially work since simplepie
- * handles both, but we don't claim it will work well, and are reasonably certain it won't.
+ * $xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
+ *
* $importer = the contact_record (joined to user_record) of the local user who owns this relationship.
* It is this person's stuff that is going to be updated.
* $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity
@@ -1094,25 +1031,18 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
}
- // Now process the feed
- if($feed->get_item_quantity()) {
- // in inverse date order
- if ($datedir)
- $items = array_reverse($feed->get_items());
- else
- $items = $feed->get_items();
-
- foreach($items as $item) {
+ // process any deleted entries
+ $del_entries = $feed->get_feed_tags(NAMESPACE_TOMB, 'deleted-entry');
+ if(is_array($del_entries) && count($del_entries)) {
+ foreach($del_entries as $dentry) {
$deleted = false;
-
- $rawdelete = $item->get_item_tags( NAMESPACE_TOMB, 'deleted-entry');
- if(isset($rawdelete[0]['attribs']['']['ref'])) {
- $uri = $rawthread[0]['attribs']['']['ref'];
+ if(isset($dentry['attribs']['']['ref'])) {
+ $uri = $dentry['attribs']['']['ref'];
$deleted = true;
- if(isset($rawdelete[0]['attribs']['']['when'])) {
- $when = $rawthread[0]['attribs']['']['when'];
+ if(isset($dentry['attribs']['']['when'])) {
+ $when = $dentry['attribs']['']['when'];
$when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s');
}
else
@@ -1126,6 +1056,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
);
if(count($r)) {
$item = $r[0];
+
+ if(! $item['deleted'])
+ logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
+
if($item['uri'] == $item['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = ''
@@ -1147,7 +1081,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
);
if($item['last-child']) {
// ensure that last-child is set in case the comment that had it just got wiped.
- $q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
+ q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc(datetime_convert()),
dbesc($item['parent-uri']),
intval($item['uid'])
@@ -1166,9 +1100,24 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
}
}
}
- continue;
}
+ }
+ }
+ // Now process the feed
+
+ if($feed->get_item_quantity()) {
+
+ logger('consume_feed: feed item count = ' . $feed->get_item_quantity());
+
+ // in inverse date order
+ if ($datedir)
+ $items = array_reverse($feed->get_items());
+ else
+ $items = $feed->get_items();
+
+
+ foreach($items as $item) {
$is_reply = false;
$item_id = $item->get_id();
@@ -1178,7 +1127,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
$parent_uri = $rawthread[0]['attribs']['']['ref'];
}
-
if(($is_reply) && is_array($contact)) {
// Have we seen it? If not, import it.
diff --git a/include/notifier.php b/include/notifier.php
index 07bde7c4d6..b6c4ca5712 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -87,7 +87,7 @@ function notifier_run($argv, $argc){
}
}
- $r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags`
+ $r = q("SELECT `contact`.*, `user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, `user`.`page-flags`
FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
intval($uid)
@@ -179,20 +179,14 @@ function notifier_run($argv, $argc){
$mail_template = load_view_file('view/atom_mail.tpl');
$atom = '';
- $hubxml = '';
$slaps = array();
- if(strlen($hub)) {
- $hubs = explode(',', $hub);
- if(count($hubs)) {
- foreach($hubs as $h) {
- $h = trim($h);
- if(! strlen($h))
- continue;
- $hubxml .= '' . "\n" ;
- }
- }
- }
+ $hubxml = feed_hublinks();
+
+ $birthday = feed_birthday($owner['uid'],$owner['timezone']);
+
+ if(strlen($birthday))
+ $birthday = '' . xmlify($birthday) . '';
$atom .= replace_macros($feed_template, array(
'$version' => xmlify(FRIENDIKA_VERSION),
@@ -208,7 +202,7 @@ function notifier_run($argv, $argc){
'$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
'$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) ,
'$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) ,
- '$birthday' => ''
+ '$birthday' => $birthday
));
if($cmd === 'mail') {
@@ -394,7 +388,7 @@ function notifier_run($argv, $argc){
*
*/
- $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 150 : intval(get_config('system','maxdeliver')));
+ $max_allowed = ((get_config('system','maxpubdeliver') === false) ? 150 : intval(get_config('system','maxpubdeliver')));
/**
*
diff --git a/include/poller.php b/include/poller.php
index 20c84990e0..66df080a9d 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -28,7 +28,6 @@ function poller_run($argv, $argc){
// run queue delivery process in the background
$php_path = ((x($a->config,'php_path') && strlen($a->config['php_path'])) ? $a->config['php_path'] : 'php');
- //proc_close(proc_open("\"$php_path\" \"include/queue.php\" &", array(), $foo));
proc_run($php_path,"include/queue.php");
// clear old cache
@@ -239,6 +238,7 @@ function poller_run($argv, $argc){
$xml = post_url($contact['poll'],$postvars);
}
else {
+
// $contact['network'] !== 'dfrn'
$xml = fetch_url($contact['poll']);
@@ -246,8 +246,14 @@ function poller_run($argv, $argc){
logger('poller: received xml : ' . $xml, LOGGER_DATA);
- if(! strlen($xml))
+ if(! strstr($xml,'module != 'install')
require_once('nav.php');
/**
- *
* Build the page - now that we have all the components
- * Make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
- *
*/
-$default_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : 'default');
-if((x($_SESSION,'theme')) && (! file_exists('view/theme/' . $_SESSION['theme'] . '/style.css')))
- unset($_SESSION['theme']);
-
-$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
- '$stylesheet' => $a->get_baseurl() . '/view/theme/'
- . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : $default_theme)
- . '/style.css'
- ));
+$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => current_theme_url()));
$page = $a->page;
$profile = $a->profile;
diff --git a/mod/contacts.php b/mod/contacts.php
index 61d9ce3986..36f42f8e59 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -245,6 +245,13 @@ function contacts_content(&$a) {
$sparkle = '';
}
+ $last_update = (($r[0]['last-update'] == '0000-00-00 00:00:00')
+ ? t('Never')
+ : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A'));
+
+ if($r[0]['last-update'] !== '0000-00-00 00:00:00')
+ $last_update .= ' ' . (($r[0]['last-update'] == $r[0]['success_update']) ? t("\x28Update was successful\x29") : t("\x28Update was not successful\x29"));
+
$o .= replace_macros($tpl,array(
'$header' => t('Contact Editor'),
'$visit' => t('Visit $name\'s profile'),
@@ -254,9 +261,7 @@ function contacts_content(&$a) {
'$poll_interval' => contact_poll_interval($r[0]['priority']),
'$lastupdtext' => t('Last updated: '),
'$updpub' => t('Update public posts: '),
- '$last_update' => (($r[0]['last-update'] == '0000-00-00 00:00:00')
- ? t('Never')
- : datetime_convert('UTC',date_default_timezone_get(),$r[0]['last-update'],'D, j M Y, g:i A')),
+ '$last_update' => $last_update,
'$udnow' => t('Update now'),
'$profile_select' => contact_profile_assign($r[0]['profile-id'],(($r[0]['network'] !== 'dfrn') ? true : false)),
'$contact_id' => $r[0]['id'],
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php
index 142d132845..dffbb59740 100644
--- a/mod/dfrn_notify.php
+++ b/mod/dfrn_notify.php
@@ -200,68 +200,77 @@ function dfrn_notify_post(&$a) {
logger('dfrn_notify: feed item count = ' . $feed->get_item_quantity());
- foreach($feed->get_items() as $item) {
+ // process any deleted entries
- $deleted = false;
-
- $rawdelete = $item->get_item_tags( NAMESPACE_TOMB , 'deleted-entry');
- if(isset($rawdelete[0]['attribs']['']['ref'])) {
- $uri = $rawthread[0]['attribs']['']['ref'];
- $deleted = true;
- if(isset($rawdelete[0]['attribs']['']['when'])) {
- $when = $rawthread[0]['attribs']['']['when'];
- $when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s');
+ $del_entries = $feed->get_feed_tags(NAMESPACE_TOMB, 'deleted-entry');
+ if(is_array($del_entries) && count($del_entries)) {
+ foreach($del_entries as $dentry) {
+ $deleted = false;
+ if(isset($dentry['attribs']['']['ref'])) {
+ $uri = $dentry['attribs']['']['ref'];
+ $deleted = true;
+ if(isset($dentry['attribs']['']['when'])) {
+ $when = $dentry['attribs']['']['when'];
+ $when = datetime_convert('UTC','UTC', $when, 'Y-m-d H:i:s');
+ }
+ else
+ $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
}
- else
- $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s');
- }
- if($deleted) {
- $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($uri),
- intval($importer['importer_uid'])
- );
- if(count($r)) {
- $item = $r[0];
- if($item['uri'] == $item['parent-uri']) {
- $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
- WHERE `parent-uri` = '%s' AND `uid` = %d",
- dbesc($when),
- dbesc(datetime_convert()),
- dbesc($item['uri']),
- intval($importer['importer_uid'])
- );
- }
- else {
- $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
- WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($when),
- dbesc(datetime_convert()),
- dbesc($uri),
- intval($importer['importer_uid'])
- );
- if($item['last-child']) {
- // ensure that last-child is set in case the comment that had it just got wiped.
- $q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
+ if($deleted) {
+ $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($uri),
+ intval($importer['importer_uid'])
+ );
+ if(count($r)) {
+ $item = $r[0];
+
+ if(! $item['deleted'])
+ logger('dfrn_notify: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
+
+ if($item['uri'] == $item['parent-uri']) {
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
+ WHERE `parent-uri` = '%s' AND `uid` = %d",
+ dbesc($when),
dbesc(datetime_convert()),
- dbesc($item['parent-uri']),
- intval($item['uid'])
+ dbesc($item['uri']),
+ intval($importer['importer_uid'])
);
- // who is the last child now?
- $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d
- ORDER BY `created` DESC LIMIT 1",
- dbesc($item['parent-uri']),
- intval($importer['importer_uid'])
- );
- if(count($r)) {
- q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
- intval($r[0]['id'])
- );
- }
}
+ else {
+ $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s'
+ WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($when),
+ dbesc(datetime_convert()),
+ dbesc($uri),
+ intval($importer['importer_uid'])
+ );
+ if($item['last-child']) {
+ // ensure that last-child is set in case the comment that had it just got wiped.
+ q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
+ dbesc(datetime_convert()),
+ dbesc($item['parent-uri']),
+ intval($item['uid'])
+ );
+ // who is the last child now?
+ $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d
+ ORDER BY `created` DESC LIMIT 1",
+ dbesc($item['parent-uri']),
+ intval($importer['importer_uid'])
+ );
+ if(count($r)) {
+ q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
+ intval($r[0]['id'])
+ );
+ }
+ }
+ }
}
- }
- continue;
+ }
}
+ }
+
+
+ foreach($feed->get_items() as $item) {
$is_reply = false;
$item_id = $item->get_id();
@@ -298,7 +307,7 @@ function dfrn_notify_post(&$a) {
);
if(count($r))
$parent = $r[0]['parent'];
-
+
if(! $is_like) {
$r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d",
dbesc(datetime_convert()),
@@ -332,12 +341,11 @@ function dfrn_notify_post(&$a) {
'$from' => $from,
'$body' => strip_tags(bbcode(stripslashes($datarray['body'])))
));
-
+
$res = mail($importer['email'], $from . t(' commented on an item at ') . $a->config['sitename'],
$email_tpl, "From: " . t('Administrator') . '@' . $a->get_hostname() );
}
}
-
xml_status(0);
// NOTREACHED
}
@@ -372,7 +380,6 @@ function dfrn_notify_post(&$a) {
$datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE;
}
-
$r = item_store($datarray);
// find out if our user is involved in this conversation and wants to be notified.
@@ -389,7 +396,7 @@ function dfrn_notify_post(&$a) {
continue;
require_once('bbcode.php');
$from = stripslashes($datarray['author-name']);
- $tpl = load_view_file('view/cmnt_received_eml.tpl');
+ $tpl = load_view_file('view/cmnt_received_eml.tpl');
$email_tpl = replace_macros($tpl, array(
'$sitename' => $a->config['sitename'],
'$siteurl' => $a->get_baseurl(),
diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
index 85e7fc0afd..334e103079 100644
--- a/mod/dfrn_poll.php
+++ b/mod/dfrn_poll.php
@@ -28,7 +28,7 @@ function dfrn_poll_init(&$a) {
if(($dfrn_id === '') && (! x($_POST,'dfrn_id')) && ($a->argc > 1)) {
logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] );
header("Content-type: application/atom+xml");
- $o = get_feed_for($a, '*', $a->argv[1],$last_update);
+ $o = get_feed_for($a, '', $a->argv[1],$last_update);
echo $o;
killme();
}
diff --git a/mod/photos.php b/mod/photos.php
index 1a1ebaac19..9acde458df 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -268,6 +268,13 @@ foreach($_FILES AS $key => $val) {
intval($page_owner_uid)
);
}
+
+ /* Don't make the item visible if the only change was the album name */
+
+ $visibility = 0;
+ if($p[0]['desc'] !== $desc || strlen($rawtags))
+ $visibility = 1;
+
if(! $item_id) {
// Create item container
@@ -297,6 +304,7 @@ foreach($_FILES AS $key => $val) {
$arr['deny_cid'] = $p[0]['deny_cid'];
$arr['deny_gid'] = $p[0]['deny_gid'];
$arr['last-child'] = 1;
+ $arr['visible'] = $visibility;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
. '[/url]';
diff --git a/update.php b/update.php
index f909837470..e51e8ac33e 100644
--- a/update.php
+++ b/update.php
@@ -342,3 +342,24 @@ function update_1034() {
q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE");
}
+
+
+function update_1035() {
+
+ q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` ");
+
+}
+
+function update_1036() {
+
+ $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' && `photo` LIKE '%include/photo%' ");
+ if(count($r)) {
+ foreach($r as $rr) {
+ q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(str_replace('include/photo','photo',$rr['photo'])),
+ dbesc(str_replace('include/photo','photo',$rr['thumb'])),
+ dbesc(str_replace('include/photo','photo',$rr['micro'])),
+ intval($rr['id']));
+ }
+ }
+}
diff --git a/view/de/head.tpl b/view/de/head.tpl
index 50dd9cab6b..c3ec3d2c9e 100644
--- a/view/de/head.tpl
+++ b/view/de/head.tpl
@@ -1,7 +1,7 @@
-
+