aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristian Vogeley <christian.vogeley@hotmail.de>2013-09-15 03:21:19 +0200
committerChristian Vogeley <christian.vogeley@hotmail.de>2013-09-15 03:21:19 +0200
commit4132d1cd8e59d2cf84d7578ac700c65d7954edd6 (patch)
tree5586bb1bf97ad9e457de2eacb298d28e22c854ee /include
parent496f869157ab76139d14a3c67fd8276ee6557517 (diff)
parentaefb0f823353d15a281d3c94ec6fc044e1b62580 (diff)
downloadvolse-hubzilla-4132d1cd8e59d2cf84d7578ac700c65d7954edd6.tar.gz
volse-hubzilla-4132d1cd8e59d2cf84d7578ac700c65d7954edd6.tar.bz2
volse-hubzilla-4132d1cd8e59d2cf84d7578ac700c65d7954edd6.zip
Upstream merge
Diffstat (limited to 'include')
-rw-r--r--include/activities.php3
-rw-r--r--include/contact_widgets.php11
-rw-r--r--include/event.php3
-rwxr-xr-xinclude/items.php80
-rw-r--r--include/menu.php11
-rw-r--r--include/network.php10
-rw-r--r--include/notifier.php9
-rw-r--r--include/photos.php6
-rw-r--r--include/poller.php9
-rw-r--r--include/zot.php110
10 files changed, 168 insertions, 84 deletions
diff --git a/include/activities.php b/include/activities.php
index 7ef26abeb..73180eae0 100644
--- a/include/activities.php
+++ b/include/activities.php
@@ -75,7 +75,8 @@ function profile_activity($changed, $value) {
$arr['deny_cid'] = $self['channel_deny_cid'];
$arr['deny_gid'] = $self['channel_deny_gid'];
- $i = item_store($arr);
+ $res = item_store($arr);
+ $i = $res['item_id'];
if($i) {
// FIXME - limit delivery in notifier.php to those specificed in the perms argument
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index cc7d92508..bc7faebc3 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -91,9 +91,16 @@ function categories_widget($baseurl,$selected = '') {
return '';
$terms = array();
- $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc",
+ $r = q("select distinct(term.term)
+ from term join item on term.oid = item.id
+ where item.uid = %d
+ and term.uid = item.uid
+ and term.type = %d
+ and item.author_xchan = '%s'
+ order by term.term asc",
intval($a->profile['profile_uid']),
- intval(TERM_CATEGORY)
+ intval(TERM_CATEGORY),
+ dbesc($a->profile['channel_hash'])
);
if($r && count($r)) {
foreach($r as $rr)
diff --git a/include/event.php b/include/event.php
index 29ada2e96..7873de1ef 100644
--- a/include/event.php
+++ b/include/event.php
@@ -360,7 +360,8 @@ function event_store($arr) {
}
- $item_id = item_store($item_arr);
+ $res = item_store($item_arr);
+ $item_id = $res['item_id'];
call_hooks("event_created", $event['id']);
diff --git a/include/items.php b/include/items.php
index cd3ef7f68..c83eceabe 100755
--- a/include/items.php
+++ b/include/items.php
@@ -18,6 +18,9 @@ function collect_recipients($item,&$private) {
require_once('include/group.php');
+ if($item['item_private'])
+ $private = true;
+
if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) {
$allow_people = expand_acl($item['allow_cid']);
$allow_groups = expand_groups(expand_acl($item['allow_gid']));
@@ -193,7 +196,9 @@ function post_activity_item($arr) {
}
- $post_id = item_store($arr);
+ $post = item_store($arr);
+ if($post['result'])
+ $post_id = $post['item_id'];
if($post_id) {
$arr['id'] = $post_id;
@@ -1365,9 +1370,12 @@ function encode_rel_links($links) {
function item_store($arr,$allow_exec = false) {
+ $ret = array('result' => false, 'item_id' => 0);
+
if(! $arr['uid']) {
logger('item_store: no uid');
- return 0;
+ $ret['message'] = 'No uid.';
+ return ret;
}
// If a page layout is provided, ensure it exists and belongs to us.
@@ -1392,7 +1400,8 @@ function item_store($arr,$allow_exec = false) {
if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) {
logger('item_store: php mimetype but allow_exec is denied.');
- return 0;
+ $ret['message'] = 'exec denied.';
+ return $ret;
}
@@ -1424,7 +1433,8 @@ function item_store($arr,$allow_exec = false) {
call_hooks('item_translate', $translate);
if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) {
logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']);
- return;
+ $ret['message'] = 'language not accepted';
+ return $ret;
}
$arr = $translate['item'];
}
@@ -1439,15 +1449,10 @@ function item_store($arr,$allow_exec = false) {
}
- if($arr['object'])
- logger('item_store: input object: ' . print_r($arr['object'],true), LOGGER_DATA);
-
if((x($arr,'object')) && is_array($arr['object'])) {
activity_sanitise($arr['object']);
- logger('item_store: sanitised object: ' . print_r($arr['object'],true), LOGGER_DATA);
$arr['object'] = json_encode($arr['object']);
- logger('item_store: encoded object: ' . print_r($arr['object'],true), LOGGER_DATA);
}
if((x($arr,'target')) && is_array($arr['target'])) {
@@ -1570,7 +1575,8 @@ function item_store($arr,$allow_exec = false) {
}
else {
logger('item_store: item parent was not found - ignoring item');
- return 0;
+ $ret['message'] = 'parent not found.';
+ return $ret;
}
}
@@ -1583,15 +1589,17 @@ function item_store($arr,$allow_exec = false) {
intval($arr['uid'])
);
if($r) {
- logger('item-store: duplicate item ignored. ' . print_r($arr,true));
- return 0;
+ logger('item_store: duplicate item ignored. ' . print_r($arr,true));
+ $ret['message'] = 'duplicate post.';
+ return $ret;
}
call_hooks('post_remote',$arr);
if(x($arr,'cancel')) {
logger('item_store: post cancelled by plugin.');
- return 0;
+ $ret['message'] = 'cancelled.';
+ return $ret;
}
// pull out all the taxonomy stuff for separate storage
@@ -1614,18 +1622,21 @@ function item_store($arr,$allow_exec = false) {
// find the item we just created
- $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
+ $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
$arr['mid'], // already dbesc'd
intval($arr['uid'])
);
+
if($r && count($r)) {
$current_post = $r[0]['id'];
+ $arr = $r[0]; // This will gives us a fresh copy of what's now in the DB and undo the db escaping, which really messes up the notifications
logger('item_store: created item ' . $current_post, LOGGER_DEBUG);
}
else {
- logger('item_store: could not locate created item');
- return 0;
+ logger('item_store: could not locate stored item');
+ $ret['message'] = 'unable to retrieve.';
+ return $ret;
}
if(count($r) > 1) {
logger('item_store: duplicated post occurred. Removing duplicates.');
@@ -1657,6 +1668,7 @@ function item_store($arr,$allow_exec = false) {
intval($current_post)
);
+ // These are probably redundant now that we've queried the just stored post
$arr['id'] = $current_post;
$arr['parent'] = $parent_id;
$arr['allow_cid'] = $allow_cid;
@@ -1697,21 +1709,26 @@ function item_store($arr,$allow_exec = false) {
send_status_notifications($current_post,$arr);
tag_deliver($arr['uid'],$current_post);
+ $ret['success'] = true;
+ $ret['item_id'] = $current_post;
- return $current_post;
+ return $ret;
}
function item_store_update($arr,$allow_exec = false) {
+ $ret = array('result' => false, 'item_id' => 0);
if(! intval($arr['uid'])) {
logger('item_store_update: no uid');
- return 0;
+ $ret['message'] = 'no uid.';
+ return $ret;
}
if(! intval($arr['id'])) {
logger('item_store_update: no id');
- return 0;
+ $ret['message'] = 'no id.';
+ return $ret;
}
$orig_post_id = $arr['id'];
@@ -1729,7 +1746,8 @@ function item_store_update($arr,$allow_exec = false) {
call_hooks('item_translate', $translate);
if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) {
logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']);
- return;
+ $ret['message'] = 'language not accepted';
+ return $ret;
}
$arr = $translate['item'];
}
@@ -1738,7 +1756,8 @@ function item_store_update($arr,$allow_exec = false) {
if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) {
logger('item_store: php mimetype but allow_exec is denied.');
- return 0;
+ $ret['message'] = 'exec denied.';
+ return $ret;
}
@@ -1771,7 +1790,8 @@ function item_store_update($arr,$allow_exec = false) {
);
if(! $orig) {
logger('item_store_update: original post not found: ' . $orig_post_id);
- return 0;
+ $ret['message'] = 'no original';
+ return $ret;
}
unset($arr['aid']);
@@ -1814,7 +1834,8 @@ function item_store_update($arr,$allow_exec = false) {
if(x($arr,'cancel')) {
logger('item_store_update: post cancelled by plugin.');
- return 0;
+ $ret['message'] = 'cancelled.';
+ return $ret;
}
// pull out all the taxonomy stuff for separate storage
@@ -1842,7 +1863,8 @@ function item_store_update($arr,$allow_exec = false) {
logger('item_store_update: updated item ' . $orig_post_id, LOGGER_DEBUG);
else {
logger('item_store_update: could not update item');
- return 0;
+ $ret['message'] = 'DB update failed.';
+ return $ret;
}
$r = q("delete from term where oid = %d and otype = %d",
@@ -1871,8 +1893,10 @@ function item_store_update($arr,$allow_exec = false) {
send_status_notifications($orig_post_id,$arr);
tag_deliver($uid,$orig_post_id);
+ $ret['success'] = true;
+ $ret['item_id'] = $orig_post_id;
- return $orig_post_id;
+ return $ret;
}
@@ -2749,7 +2773,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
}
}
- $r = item_store($datarray);
+ $xx = item_store($datarray);
+ $r = $xx['item_id'];
continue;
}
@@ -2879,7 +2904,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
continue;
- $r = item_store($datarray);
+ $xx = item_store($datarray);
+ $r = $xx['item_id'];
continue;
}
diff --git a/include/menu.php b/include/menu.php
index 6d614055a..900b48e65 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -118,6 +118,8 @@ function menu_edit($arr) {
return false;
+ $menu_channel_id = intval($arr['menu_channel_id']);
+
$r = q("select menu_id from menu where menu_name = '%s' and menu_channel_id = %d limit 1",
dbesc($menu_name),
intval($menu_channel_id)
@@ -128,9 +130,6 @@ function menu_edit($arr) {
}
-
- $menu_channel_id = intval($arr['menu_channel_id']);
-
$r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1",
intval($menu_id),
intval($menu_channel_id)
@@ -141,14 +140,16 @@ function menu_edit($arr) {
}
- $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1",
+ $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d and menu_desc = '%s' limit 1",
dbesc($menu_name),
- intval($menu_channel_id)
+ intval($menu_channel_id),
+ dbesc($menu_desc)
);
if($r)
return false;
+
return q("update menu set menu_name = '%s', menu_desc = '%s'
where menu_id = %d and menu_channel_id = %d limit 1",
dbesc($menu_name),
diff --git a/include/network.php b/include/network.php
index 8b9a8a6a6..00d931f19 100644
--- a/include/network.php
+++ b/include/network.php
@@ -312,8 +312,13 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
$rc = intval($http_code);
$ret['return_code'] = $rc;
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
+ if(! $ret['success']) {
+ $ret['debug'] = $curl_info;
+ logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA);
+ }
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
+
@curl_close($ch);
return($ret);
}
@@ -407,6 +412,11 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) {
$rc = intval($http_code);
$ret['return_code'] = $rc;
$ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false);
+ if(! $ret['success']) {
+ $ret['debug'] = $curl_info;
+ logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA);
+ }
+
$ret['body'] = substr($s,strlen($header));
$ret['header'] = $header;
curl_close($ch);
diff --git a/include/notifier.php b/include/notifier.php
index 5dcd7b58c..e1f150bf2 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -208,9 +208,8 @@ function notifier_run($argv, $argc){
$channel = $s[0];
$uid = $item_id;
$recipients = array();
- $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d)",
- intval($item_id),
- intval(ABOOK_FLAG_SELF)
+ $r = q("select abook_xchan from abook where abook_channel = %d",
+ intval($item_id)
);
if($r) {
foreach($r as $rr) {
@@ -373,6 +372,10 @@ function notifier_run($argv, $argc){
}
}
+ if(($private) && (! $env_recips)) {
+ // shouldn't happen
+ logger('notifier: private message with no envelope recipients.' . print_r($argv,true));
+ }
logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list,true), LOGGER_DEBUG);
diff --git a/include/photos.php b/include/photos.php
index c670bd90c..517212e57 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -222,7 +222,8 @@ function photo_upload($channel, $observer, $args) {
. '[zmg]' . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]'
. '[/zrl]';
- $item_id = item_store($arr);
+ $result = item_store($arr);
+ $item_id = $result['item_id'];
if($visible)
proc_run('php', "include/notifier.php", 'wall-new', $item_id);
@@ -402,7 +403,8 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]'
. '[/zrl]';
- $item_id = item_store($arr);
+ $result = item_store($arr);
+ $item_id = $result['item_id'];
return $item_id;
} \ No newline at end of file
diff --git a/include/poller.php b/include/poller.php
index bdb0388ac..f084005c7 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -158,7 +158,7 @@ function poller_run($argv, $argc){
);
- $contacts = q("SELECT abook_id, abook_updated, abook_connected, abook_closeness, abook_channel
+ $contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_channel
FROM abook LEFT JOIN account on abook_account = account_id where 1
$sql_extra
AND (( abook_flags = %d ) OR ( abook_flags = %d ))
@@ -210,6 +210,11 @@ function poller_run($argv, $argc){
continue;
}
+ if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) {
+ $update = false;
+ continue;
+ }
+
// might be dead, so maybe don't poll quite so often
// recently deceased, so keep up the regular schedule for 3 days
@@ -223,6 +228,8 @@ function poller_run($argv, $argc){
if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) {
$update = true;
}
+
+
}
if((! $update) && (! $force))
diff --git a/include/zot.php b/include/zot.php
index 33522b485..53031a6c5 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -493,7 +493,6 @@ function import_xchan($arr) {
logger('import_xchan: existing: ' . print_r($r[0],true), LOGGER_DATA);
logger('import_xchan: new: ' . print_r($arr,true), LOGGER_DATA);
- update_modtime($xchan_hash);
$changed = true;
}
}
@@ -532,7 +531,7 @@ function import_xchan($arr) {
dbesc($arr['name_updated']),
intval($new_flags)
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -553,7 +552,7 @@ function import_xchan($arr) {
dbesc($xchan_hash)
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -579,13 +578,18 @@ function import_xchan($arr) {
}
}
- $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s'
- and hubloc_url = '%s' and hubloc_url_sig = '%s' limit 1",
+ // match as many fields as possible in case anything at all changed.
+
+ $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_host = '%s' and hubloc_addr = '%s' and hubloc_callback = '%s' and hubloc_sitekey = '%s' limit 1",
dbesc($xchan_hash),
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
dbesc($location['url']),
- dbesc($location['url_sig'])
+ dbesc($location['url_sig']),
+ dbesc($location['host']),
+ dbesc($location['address']),
+ dbesc($location['callback']),
+ dbesc($location['sitekey'])
);
if($r) {
logger('import_xchan: hub exists: ' . $location['url']);
@@ -601,7 +605,6 @@ function import_xchan($arr) {
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
- update_modtime($xchan_hash);
$changed = true;
}
continue;
@@ -641,7 +644,7 @@ function import_xchan($arr) {
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
- update_modtime($xchan_hash);
+
$changed = true;
}
@@ -653,7 +656,7 @@ function import_xchan($arr) {
$r = q("delete from hubloc where hubloc_id = %d limit 1",
intval($x['hubloc_id'])
);
- update_modtime($xchan_hash);
+
$changed = true;
}
}
@@ -667,7 +670,7 @@ function import_xchan($arr) {
if(array_key_exists('profile',$arr) && is_array($arr['profile'])) {
$profile_changed = import_directory_profile($xchan_hash,$arr['profile']);
if($profile_changed) {
- update_modtime($xchan_hash);
+
$changed = true;
}
}
@@ -686,7 +689,6 @@ function import_xchan($arr) {
if(array_key_exists('site',$arr) && is_array($arr['site'])) {
$profile_changed = import_site($arr['site'],$arr['key']);
if($profile_changed) {
- update_modtime($xchan_hash);
$changed = true;
}
}
@@ -694,9 +696,8 @@ function import_xchan($arr) {
if($changed) {
- // send out a directory mirror update packet if we're a directory server or some kind
-
-
+ $guid = random_string() . '@' . get_app()->get_hostname();
+ update_modtime($xchan_hash,$guid);
}
if(! x($ret,'message')) {
@@ -847,6 +848,12 @@ function zot_import($arr) {
}
else {
+ if((array_key_exists('flags',$i['message'])) && (in_array('private',$i['message']['flags']))) {
+ // This should not happen but until we can stop it...
+ logger('private message was delivered with no recipients.');
+ continue;
+ }
+
logger('public post');
// Public post. look for any site members who are or may be accepting posts from this sender
@@ -906,8 +913,9 @@ function zot_import($arr) {
$result = process_channel_sync_delivery($i['notify']['sender'],$arr,$deliveries);
}
}
- if($result)
+ if($result){
$return = array_merge($return,$result);
+ }
}
}
@@ -928,14 +936,22 @@ function public_recips($msg) {
$check_mentions = false;
if($msg['message']['type'] === 'activity') {
+ $col = 'channel_w_stream';
+ $field = PERMS_W_STREAM;
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
- $col = 'channel_w_stream';
- $field = PERMS_W_STREAM;
+ // check mention recipient permissions on top level posts only
$check_mentions = true;
}
else {
- $col = 'channel_w_comment';
- $field = PERMS_W_COMMENT;
+ // if this is a comment and it wasn't sent by the post owner, check to see who is allowing them to comment.
+ // We should have one specific recipient and this step shouldn't be needed unless somebody stuffed up their software.
+ // We may need this step to protect us from bad guys intentionally stuffing up their software.
+ // If it is sent by the post owner, we don't need to do this. We only need to see who is receiving the
+ // owner's stream (which was already set above) - as they control the comment permissions
+ if($msg['notify']['sender']['guid_sig'] != $msg['message']['owner']['guid_sig']) {
+ $col = 'channel_w_comment';
+ $field = PERMS_W_COMMENT;
+ }
}
}
elseif($msg['message']['type'] === 'mail') {
@@ -948,9 +964,9 @@ function public_recips($msg) {
if($msg['notify']['sender']['url'] === z_root())
- $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) ";
+ $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " ) or ( " . $col . " & " . PERMS_PUBLIC . ")) ";
else
- $sql = " where ( " . $col . " & " . PERMS_NETWORK . " ) " ;
+ $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_PUBLIC . ")) ";
$r = q("select channel_hash as hash from channel " . $sql );
@@ -958,7 +974,7 @@ function public_recips($msg) {
$r = array();
$x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id where abook_xchan = '%s'
- and (( " . $col . " & " . PERMS_SPECIFIC . " ) OR ( " . $col . " & " . PERMS_CONTACTS . " )) and ( abook_my_perms & " . $field . " ) ",
+ and (( " . $col . " & " . PERMS_SPECIFIC . " ) and ( abook_my_perms & " . $field . " )) OR ( " . $col . " & " . PERMS_CONTACTS . " ) ",
dbesc($msg['notify']['sender']['hash'])
);
@@ -1157,8 +1173,9 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
else {
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
- $item_id = item_store($arr);
- $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed'),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
+ $item_result = item_store($arr);
+ $item_id = $item_result['item_id'];
+ $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>');
}
if($relay && $item_id) {
@@ -1241,8 +1258,11 @@ function remove_community_tag($sender,$arr,$uid) {
function update_imported_item($sender,$item,$uid) {
- item_store_update($item);
- logger('update_imported_item');
+ $x = item_store_update($item);
+ if(! $x['item_id'])
+ logger('update_imported_item: failed: ' . $x['message']);
+ else
+ logger('update_imported_item');
}
@@ -1363,8 +1383,8 @@ function import_directory_profile($hash,$profile) {
foreach($profile['keywords'] as $kw) {
$kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8',false));
$kw = trim($kw,',');
+ $clean[] = $kw;
}
- $clean[] = $kw;
}
$arr['xprof_keywords'] = implode(' ',$clean);
@@ -1431,7 +1451,7 @@ function import_directory_profile($hash,$profile) {
call_hooks('import_directory_profile', $d);
if($d['update'])
- update_modtime($arr['xprof_hash']);
+ update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname());
return $d['update'];
}
@@ -1470,20 +1490,12 @@ function import_directory_keywords($hash,$keywords) {
}
-function update_modtime($hash) {
- $r = q("select * from updates where ud_hash = '%s' limit 1",
- dbesc($hash)
+function update_modtime($hash,$guid) {
+ q("insert into updates (ud_hash, ud_guid, ud_date) values ( '%s', '%s', '%s' )",
+ dbesc($hash),
+ dbesc($guid),
+ dbesc(datetime_convert())
);
- if($r)
- q("update updates set ud_date = '%s' where ud_hash = '%s' limit 1",
- dbesc(datetime_convert()),
- dbesc($hash)
- );
- else
- q("insert into updates (ud_hash, ud_date) values ( '%s', '%s' )",
- dbesc($hash),
- dbesc(datetime_convert())
- );
}
@@ -1549,7 +1561,7 @@ function import_site($arr,$pubkey) {
}
}
else {
- $r = q("insert into site ( site_url, site_acccess, site_flags, site_update, site_directory, site_register )
+ $r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register )
values ( '%s', %d, %d, '%s', '%s', %d )",
dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)),
intval($site_directory),
@@ -1745,6 +1757,20 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
if(! array_key_exists('abook_xchan',$clean))
continue;
+ $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
+ dbesc($clean['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+
+ // make sure we have an abook entry for this xchan on this system
+
+ if(! $r) {
+ q("insert into abook ( abook_xchan, abook_channel ) values ('%s', %d ) ",
+ dbesc($clean['abook_xchan']),
+ intval($channel['channel_id'])
+ );
+ }
+
if(count($clean)) {
foreach($clean as $k => $v) {
$r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v)