aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2017-01-29 19:53:41 -0500
committerAndrew Manning <tamanning@zoho.com>2017-01-29 19:53:41 -0500
commitf8918604087af97a9e416ba2a8503920f8b08186 (patch)
tree1332a4686c05f9a659f0b3aeb6acc51948921720 /include
parent3424c7dc878ecf5b1f1c021737e3d7eba2443299 (diff)
parentdbf7ff979122ea0f8877e9ae4b16590f280593ef (diff)
downloadvolse-hubzilla-f8918604087af97a9e416ba2a8503920f8b08186.tar.gz
volse-hubzilla-f8918604087af97a9e416ba2a8503920f8b08186.tar.bz2
volse-hubzilla-f8918604087af97a9e416ba2a8503920f8b08186.zip
Merge remote-tracking branch 'upstream/dev' into affinity-settings
Diffstat (limited to 'include')
-rw-r--r--include/channel.php36
-rw-r--r--include/hubloc.php104
-rwxr-xr-xinclude/items.php34
-rw-r--r--include/network.php41
-rw-r--r--include/queue_fn.php46
-rw-r--r--include/security.php23
-rw-r--r--include/xchan.php139
-rw-r--r--include/zot.php44
8 files changed, 274 insertions, 193 deletions
diff --git a/include/channel.php b/include/channel.php
index d66ed7abe..d2ef89cc8 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -311,23 +311,25 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id'];
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)",
- dbesc($hash),
- dbesc($guid),
- dbesc($sig),
- dbesc($key['pubkey']),
- dbesc(z_root() . "/photo/profile/l/{$newuid}"),
- dbesc(z_root() . "/photo/profile/m/{$newuid}"),
- dbesc(z_root() . "/photo/profile/s/{$newuid}"),
- dbesc(channel_reddress($ret['channel'])),
- dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']),
- dbesc(z_root() . '/follow?f=&url=%s'),
- dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']),
- dbesc($ret['channel']['channel_name']),
- dbesc('zot'),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($system)
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $hash,
+ 'xchan_guid' => $guid,
+ 'xchan_guid_sig' => $sig,
+ 'xchan_pubkey' => $key['pubkey'],
+ 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}",
+ 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}",
+ 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}",
+ 'xchan_addr' => channel_reddress($ret['channel']),
+ 'xchan_url' => z_root() . '/channel/' . $ret['channel']['channel_address'],
+ 'xchan_follow' => z_root() . '/follow?f=&url=%s',
+ 'xchan_connurl' => z_root() . '/poco/' . $ret['channel']['channel_address'],
+ 'xchan_name' => $ret['channel']['channel_name'],
+ 'xchan_network' => 'zot',
+ 'xchan_photo_date' => datetime_convert(),
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_system' => $system
+ ]
);
// Not checking return value.
diff --git a/include/hubloc.php b/include/hubloc.php
index 6f81ea31f..4da92ae72 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -176,110 +176,6 @@ function hubloc_mark_as_down($posturl) {
}
-function xchan_store($arr) {
-
- logger('xchan_store: ' . print_r($arr,true));
-
- if(! $arr['hash'])
- $arr['hash'] = $arr['guid'];
- if(! $arr['hash'])
- return false;
-
- $r = q("select * from xchan where xchan_hash = '%s' limit 1",
- dbesc($arr['hash'])
- );
- if($r)
- return true;
-
- if(! $arr['network'])
- $arr['network'] = 'unknown';
- if(! $arr['name'])
- $arr['name'] = 'unknown';
- if(! $arr['url'])
- $arr['url'] = z_root();
- if(! $arr['photo'])
- $arr['photo'] = z_root() . '/' . get_default_profile_photo();
-
-
- if($arr['network'] === 'zot') {
- if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) {
- logger('Unable to verify signature for ' . $arr['hash']);
- return false;
- }
- }
-
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d, %d, %d, %d, %d, %d, %d, '%s') ",
- dbesc($arr['hash']),
- dbesc($arr['guid']),
- dbesc($arr['guid_sig']),
- dbesc($arr['pubkey']),
- dbesc($arr['address']),
- dbesc($arr['url']),
- dbesc($arr['connurl']),
- dbesc($arr['follow']),
- dbesc($arr['connpage']),
- dbesc($arr['name']),
- dbesc($arr['network']),
- dbesc($arr['instance_url']),
- intval($arr['hidden']),
- intval($arr['orphan']),
- intval($arr['censored']),
- intval($arr['selfcensored']),
- intval($arr['system']),
- intval($arr['pubforum']),
- intval($arr['deleted']),
- dbesc(datetime_convert())
- );
- if(! $r)
- return $r;
-
- $photos = import_xchan_photo($arr['photo'],$arr['hash']);
- $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
- dbesc(datetime_convert()),
- dbesc($photos[0]),
- dbesc($photos[1]),
- dbesc($photos[2]),
- dbesc($photos[3]),
- dbesc($arr['hash'])
- );
- return $r;
-
-}
-
-
-function xchan_fetch($arr) {
-
- $key = '';
- if($arr['hash']) {
- $key = 'xchan_hash';
- $v = $arr['hash'];
- }
- elseif($arr['guid']) {
- $key = 'xchan_guid';
- $v = $arr['guid'];
- }
- elseif($arr['address']) {
- $key = 'xchan_addr';
- $v = $arr['address'];
- }
-
- if(! $key)
- return false;
-
- $r = q("select * from xchan where $key = '$v' limit 1");
- if(! $r)
- return false;
-
- $ret = array();
- foreach($r[0] as $k => $v) {
- if($k === 'xchan_addr')
- $ret['address'] = $v;
- else
- $ret[str_replace('xchan_','',$k)] = $v;
- }
- return $ret;
-}
-
function ping_site($url) {
diff --git a/include/items.php b/include/items.php
index 0d9fb02a4..559992b7f 100755
--- a/include/items.php
+++ b/include/items.php
@@ -833,13 +833,15 @@ function import_author_rss($x) {
}
$name = trim($x['name']);
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_url, xchan_name, xchan_network )
- values ( '%s', '%s', '%s', '%s', '%s' )",
- dbesc($x['guid']),
- dbesc($x['guid']),
- dbesc($x['url']),
- dbesc(($name) ? $name : t('(Unknown)')),
- dbesc('rss')
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $x['guid'],
+ 'xchan_guid' => $x['guid'],
+ 'xchan_url' => $x['url'],
+ 'xchan_name' => (($name) ? $name : t('(Unknown)')),
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_network' => 'rss'
+ ]
);
if($r && $x['photo']) {
@@ -878,14 +880,17 @@ function import_author_unknown($x) {
$name = trim($x['name']);
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_url, xchan_name, xchan_network )
- values ( '%s', '%s', '%s', '%s', '%s' )",
- dbesc($x['url']),
- dbesc($x['url']),
- dbesc($x['url']),
- dbesc(($name) ? $name : t('(Unknown)')),
- dbesc('unknown')
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $x['url'],
+ 'xchan_guid' => $x['url'],
+ 'xchan_url' => $x['url'],
+ 'xchan_name' => (($name) ? $name : t('(Unknown)')),
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_network' => 'unknown'
+ ]
);
+
if($r && $x['photo']) {
$photos = import_xchan_photo($x['photo']['src'],$x['url']);
@@ -1516,6 +1521,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
$arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
$arr['postopts'] = ((x($arr,'postopts')) ? trim($arr['postopts']) : '');
+ $arr['route'] = ((x($arr,'route')) ? trim($arr['route']) : '');
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
$arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
$arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
diff --git a/include/network.php b/include/network.php
index 4391f1bfe..9049d016b 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1121,16 +1121,17 @@ function discover_by_url($url,$arr = null) {
if(! $photo)
$photo = z_root() . '/images/rss_icon.png';
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
- dbesc($guid),
- dbesc($guid),
- dbesc($pubkey),
- dbesc($addr),
- dbesc($profile),
- dbesc($name),
- dbesc($network),
- dbesc(z_root()),
- dbesc(datetime_convert())
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $guid,
+ 'xchan_guid' => $guid,
+ 'xchan_pubkey' => $pubkey,
+ 'xchan_addr' => $addr,
+ 'xchan_url' => $profile,
+ 'xchan_name' => $name,
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_network' => $network
+ ]
);
$photos = import_xchan_photo($photo,$guid);
@@ -1449,15 +1450,17 @@ function discover_by_webbie($webbie) {
);
}
else {
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
- dbesc($address),
- dbesc(($diaspora_guid) ? $diaspora_guid : $location),
- dbesc($pubkey),
- dbesc($address),
- dbesc($location),
- dbesc($fullname),
- dbesc($network),
- dbescdate(datetime_convert())
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $address,
+ 'xchan_guid' => (($diaspora_guid) ? $diaspora_guid : $location),
+ 'xchan_pubkey' => $pubkey,
+ 'xchan_addr' => $address,
+ 'xchan_url' => $location,
+ 'xchan_name' => $fullname,
+ 'xchan_name_date' => datetime_convert(),
+ 'xchan_network' => $network
+ ]
);
}
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 0950faf85..74dde5de2 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -2,9 +2,42 @@
function update_queue_item($id, $add_priority = 0) {
logger('queue: requeue item ' . $id,LOGGER_DEBUG);
- q("UPDATE outq SET outq_updated = '%s', outq_priority = outq_priority + %d WHERE outq_hash = '%s'",
+ $x = q("select outq_created, outq_posturl from outq where outq_hash = '%s' limit 1",
+ dbesc($id)
+ );
+ if(! $x)
+ return;
+
+ // Set all other records for this destination way into the future.
+ // The queue delivers by destination. We'll keep one queue item for
+ // this destination (this one) with a shorter delivery. If we succeed
+ // once, we'll try to deliver everything for that destination.
+ // The delivery will be set to at most once per hour, and if the
+ // queue item is less than 12 hours old, we'll schedule for fifteen
+ // minutes.
+
+ $r = q("UPDATE outq SET outq_scheduled = '%s' WHERE outq_posturl = '%s'",
+ dbesc(datetime_convert('UTC','UTC','now + 5 days')),
+ dbesc($x[0]['outq_posturl'])
+ );
+
+ $since = datetime_convert('UTC','UTC',$x[0]['outq_created']);
+
+ if($since < datetime_convert('UTC','UTC','now - 12 hour')) {
+ $next = datetime_convert('UTC','UTC','now + 1 hour');
+ }
+ else {
+ $next = datetime_convert('UTC','UTC','now + 15 minutes');
+ }
+
+ q("UPDATE outq SET outq_updated = '%s',
+ outq_priority = outq_priority + %d,
+ outq_scheduled = '%s'
+ WHERE outq_hash = '%s'",
+
dbesc(datetime_convert()),
intval($add_priority),
+ dbesc($next),
dbesc($id)
);
}
@@ -33,8 +66,12 @@ function queue_set_delivered($id,$channel = 0) {
logger('queue: set delivered ' . $id,LOGGER_DEBUG);
$sql_extra = (($channel_id) ? " and outq_channel = " . intval($channel_id) . " " : '');
- q("update outq set outq_delivered = 1, outq_updated = '%s' where outq_hash = '%s' $sql_extra ",
+ // Set the next scheduled run date so far in the future that it will be expired
+ // long before it ever makes it back into the delivery chain.
+
+ q("update outq set outq_delivered = 1, outq_updated = '%s', outq_scheduled = '%s' where outq_hash = '%s' $sql_extra ",
dbesc(datetime_convert()),
+ dbesc(datetime_convert('UTC','UTC','now + 5 days')),
dbesc($id)
);
}
@@ -44,8 +81,8 @@ function queue_set_delivered($id,$channel = 0) {
function queue_insert($arr) {
$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority,
- outq_created, outq_updated, outq_notify, outq_msg )
- values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )",
+ outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )
+ values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )",
dbesc($arr['hash']),
intval($arr['account_id']),
intval($arr['channel_id']),
@@ -55,6 +92,7 @@ function queue_insert($arr) {
intval(($arr['priority']) ? $arr['priority'] : 0),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
dbesc($arr['notify']),
dbesc(($arr['msg']) ? $arr['msg'] : '')
);
diff --git a/include/security.php b/include/security.php
index 2f5de54c7..57b33251f 100644
--- a/include/security.php
+++ b/include/security.php
@@ -171,19 +171,16 @@ function atoken_create_xchan($xchan) {
if($r)
return;
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_mimetype, xchan_photo_l, xchan_photo_m, xchan_photo_s )
- values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ",
- dbesc($xchan['xchan_hash']),
- dbesc($xchan['xchan_hash']),
- dbesc($xchan['xchan_addr']),
- dbesc($xchan['xchan_url']),
- dbesc($xchan['xchan_name']),
- dbesc($xchan['xchan_network']),
- dbesc($xchan['xchan_photo_mimetype']),
- dbesc($xchan['xchan_photo_l']),
- dbesc($xchan['xchan_photo_m']),
- dbesc($xchan['xchan_photo_s'])
- );
+ $xchan['xchan_guid'] = $xchan['xchan_hash'];
+
+ $store = [];
+ foreach($xchan as $k => $v) {
+ if(strpos($k,'xchan_') === 0) {
+ $store[$k] = $v;
+ }
+ }
+
+ $r = xchan_store_lowlevel($store);
return true;
}
diff --git a/include/xchan.php b/include/xchan.php
new file mode 100644
index 000000000..12eb674fa
--- /dev/null
+++ b/include/xchan.php
@@ -0,0 +1,139 @@
+<?php
+
+
+function xchan_store_lowlevel($arr) {
+
+ $store = [
+ 'xchan_hash' => ((array_key_exists('xchan_hash',$arr)) ? $arr['xchan_hash'] : ''),
+ 'xchan_guid' => ((array_key_exists('xchan_guid',$arr)) ? $arr['xchan_guid'] : ''),
+ 'xchan_guid_sig' => ((array_key_exists('xchan_guid_sig',$arr)) ? $arr['xchan_guid_sig'] : ''),
+ 'xchan_pubkey' => ((array_key_exists('xchan_pubkey',$arr)) ? $arr['xchan_pubkey'] : ''),
+ 'xchan_photo_mimetype' => ((array_key_exists('xchan_photo_mimetype',$arr)) ? $arr['xchan_photo_mimetype'] : ''),
+ 'xchan_photo_l' => ((array_key_exists('xchan_photo_l',$arr)) ? $arr['xchan_photo_l'] : ''),
+ 'xchan_photo_m' => ((array_key_exists('xchan_photo_m',$arr)) ? $arr['xchan_photo_m'] : ''),
+ 'xchan_photo_s' => ((array_key_exists('xchan_photo_s',$arr)) ? $arr['xchan_photo_s'] : ''),
+ 'xchan_addr' => ((array_key_exists('xchan_addr',$arr)) ? $arr['xchan_addr'] : ''),
+ 'xchan_url' => ((array_key_exists('xchan_url',$arr)) ? $arr['xchan_url'] : ''),
+ 'xchan_connurl' => ((array_key_exists('xchan_connurl',$arr)) ? $arr['xchan_connurl'] : ''),
+ 'xchan_follow' => ((array_key_exists('xchan_follow',$arr)) ? $arr['xchan_follow'] : ''),
+ 'xchan_connpage' => ((array_key_exists('xchan_connpage',$arr)) ? $arr['xchan_connpage'] : ''),
+ 'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? $arr['xchan_name'] : ''),
+ 'xchan_network' => ((array_key_exists('xchan_network',$arr)) ? $arr['xchan_network'] : ''),
+ 'xchan_instance_url' => ((array_key_exists('xchan_instance_url',$arr)) ? $arr['xchan_instance_url'] : ''),
+ 'xchan_flags' => ((array_key_exists('xchan_flags',$arr)) ? intval($arr['xchan_flags']) : 0),
+ 'xchan_photo_date' => ((array_key_exists('xchan_photo_date',$arr)) ? datetime_convert('UTC','UTC',$arr['xchan_photo_date']) : NULL_DATE),
+ 'xchan_name_date' => ((array_key_exists('xchan_name_date',$arr)) ? datetime_convert('UTC','UTC',$arr['xchan_name_date']) : NULL_DATE),
+ 'xchan_hidden' => ((array_key_exists('xchan_hidden',$arr)) ? intval($arr['xchan_hidden']) : 0),
+ 'xchan_orphan' => ((array_key_exists('xchan_orphan',$arr)) ? intval($arr['xchan_orphan']) : 0),
+ 'xchan_censored' => ((array_key_exists('xchan_censored',$arr)) ? intval($arr['xchan_censored']) : 0),
+ 'xchan_selfcensored' => ((array_key_exists('xchan_selfcensored',$arr)) ? intval($arr['xchan_selfcensored']) : 0),
+ 'xchan_system' => ((array_key_exists('xchan_system',$arr)) ? intval($arr['xchan_system']) : 0),
+ 'xchan_pubforum' => ((array_key_exists('xchan_pubforum',$arr)) ? intval($arr['xchan_pubforum']) : 0),
+ 'xchan_deleted' => ((array_key_exists('xchan_deleted',$arr)) ? intval($arr['xchan_deleted']) : 0)
+ ];
+
+ return create_table_from_array('xchan',$store);
+}
+
+
+
+function xchan_store($arr) {
+
+ logger('xchan_store: ' . print_r($arr,true));
+
+ if(! $arr['hash'])
+ $arr['hash'] = $arr['guid'];
+ if(! $arr['hash'])
+ return false;
+
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($arr['hash'])
+ );
+ if($r)
+ return true;
+
+ if(! $arr['network'])
+ $arr['network'] = 'unknown';
+ if(! $arr['name'])
+ $arr['name'] = 'unknown';
+ if(! $arr['url'])
+ $arr['url'] = z_root();
+ if(! $arr['photo'])
+ $arr['photo'] = z_root() . '/' . get_default_profile_photo();
+
+
+ if($arr['network'] === 'zot') {
+ if((! $arr['key']) || (! rsa_verify($arr['guid'],base64url_decode($arr['guid_sig']),$arr['key']))) {
+ logger('Unable to verify signature for ' . $arr['hash']);
+ return false;
+ }
+ }
+
+ $x = [];
+ foreach($arr as $k => $v) {
+ if($k === 'key') {
+ $x['xchan_pubkey'] = $v;
+ continue;
+ }
+ if($k === 'photo') {
+ continue;
+ }
+
+ $x['xchan_' . $k] = $v;
+ }
+
+ $x['xchan_name_date'] = datetime_convert();
+
+ $r = xchan_store_lowlevel($x);
+
+ if(! $r)
+ return $r;
+
+ $photos = import_xchan_photo($arr['photo'],$arr['hash']);
+ $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'",
+ dbesc(datetime_convert()),
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc($photos[3]),
+ dbesc($arr['hash'])
+ );
+ return $r;
+
+}
+
+
+function xchan_fetch($arr) {
+
+ $key = '';
+ if($arr['hash']) {
+ $key = 'xchan_hash';
+ $v = $arr['hash'];
+ }
+ elseif($arr['guid']) {
+ $key = 'xchan_guid';
+ $v = $arr['guid'];
+ }
+ elseif($arr['address']) {
+ $key = 'xchan_addr';
+ $v = $arr['address'];
+ }
+
+ if(! $key)
+ return false;
+
+ $r = q("select * from xchan where $key = '$v' limit 1");
+ if(! $r)
+ return false;
+
+ $ret = array();
+ foreach($r[0] as $k => $v) {
+ if($k === 'xchan_addr')
+ $ret['address'] = $v;
+ else
+ $ret[str_replace('xchan_','',$k)] = $v;
+ }
+ return $ret;
+}
+
+
diff --git a/include/zot.php b/include/zot.php
index 24b50cc12..1538e956e 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -759,28 +759,28 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) {
&& ($arr['site']['url'] != z_root()))
$arr['searchable'] = false;
- $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,
- xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum )
- values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ",
- dbesc($xchan_hash),
- dbesc($arr['guid']),
- dbesc($arr['guid_sig']),
- dbesc($arr['key']),
- dbesc($arr['photo_mimetype']),
- dbesc($arr['photo']),
- dbesc($arr['address']),
- dbesc($arr['url']),
- dbesc($arr['connections_url']),
- dbesc($arr['follow_url']),
- dbesc($arr['connect_url']),
- dbesc(($arr['name']) ? $arr['name'] : '-'),
- dbesc('zot'),
- dbescdate($arr['photo_updated']),
- dbescdate($arr['name_updated']),
- intval(1 - intval($arr['searchable'])),
- intval($arr['adult_content']),
- intval($arr['deleted']),
- intval($arr['public_forum'])
+ $x = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $xchan_hash,
+ 'xchan_guid' => $arr['guid'],
+ 'xchan_guid_sig' => $arr['guid_sig'],
+ 'xchan_pubkey' => $arr['key'],
+ 'xchan_photo_mimetype' => $arr['photo_mimetype'],
+ 'xchan_photo_l' => $arr['photo'],
+ 'xchan_addr' => $arr['address'],
+ 'xchan_url' => $arr['url'],
+ 'xchan_connurl' => $arr['connections_url'],
+ 'xchan_follow' => $arr['follow_url'],
+ 'xchan_connpage' => $arr['connect_url'],
+ 'xchan_name' => (($arr['name']) ? $arr['name'] : '-'),
+ 'xchan_network' => 'zot',
+ 'xchan_photo_date' => $arr['photo_updated'],
+ 'xchan_name_date' => $arr['name_updated'],
+ 'xchan_hidden' => intval(1 - intval($arr['searchable'])),
+ 'xchan_selfcensored' => $arr['adult_content'],
+ 'xchan_deleted' => $arr['deleted'],
+ 'xchan_pubforum' => $arr['public_forum']
+ ]
);
$what .= 'new_xchan';