aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php5
-rw-r--r--include/contact_widgets.php19
-rw-r--r--include/feedutils.php7
-rw-r--r--include/network.php31
-rw-r--r--include/perm_upgrade.php3
-rw-r--r--include/photo/photo_driver.php1
-rw-r--r--include/text.php16
-rw-r--r--include/zot.php23
8 files changed, 83 insertions, 22 deletions
diff --git a/include/channel.php b/include/channel.php
index 7072bb4ce..fef933ba7 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -278,11 +278,13 @@ function create_identity($arr) {
intval($arr['account_id'])
);
+ $photo_type = null;
+
$z = [ 'account' => $a[0], 'channel' => $r[0], 'photo_url' => '' ];
call_hooks('create_channel_photo',$z);
if($z['photo_url']) {
- import_channel_photo_from_url($z['photo_url'],$arr['account_id'],$r[0]['channel_id']);
+ $photo_type = import_channel_photo_from_url($z['photo_url'],$arr['account_id'],$r[0]['channel_id']);
}
if($role_permissions && array_key_exists('limits',$role_permissions))
@@ -330,6 +332,7 @@ function create_identity($arr) {
'xchan_guid' => $guid,
'xchan_guid_sig' => $sig,
'xchan_pubkey' => $key['pubkey'],
+ 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'),
'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}",
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index aac756a46..e5bb696f8 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -143,7 +143,7 @@ function cardcategories_widget($baseurl,$selected = '') {
-function common_friends_visitor_widget($profile_uid) {
+function common_friends_visitor_widget($profile_uid,$cnt = 10) {
if(local_channel() == $profile_uid)
return;
@@ -156,19 +156,20 @@ function common_friends_visitor_widget($profile_uid) {
require_once('include/socgraph.php');
$t = count_common_friends($profile_uid,$observer_hash);
+
if(! $t)
return;
- $r = common_friends($profile_uid,$observer_hash,0,5,true);
+ $r = common_friends($profile_uid,$observer_hash,0,$cnt,true);
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
- '$desc' => sprintf( tt("%d connection in common", "%d connections in common", $t), $t),
- '$base' => z_root(),
- '$uid' => $profile_uid,
- '$cid' => $observer,
- '$linkmore' => (($t > 5) ? 'true' : ''),
- '$more' => t('show more'),
- '$items' => $r
+ '$desc' => sprintf( t('Common connections: %d'), $t),
+ '$base' => z_root(),
+ '$uid' => $profile_uid,
+ '$cid' => $observer,
+ '$linkmore' => (($t > $cnt) ? 'true' : ''),
+ '$more' => t('show more'),
+ '$items' => $r
));
};
diff --git a/include/feedutils.php b/include/feedutils.php
index 145d4361c..112e10155 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -811,6 +811,7 @@ function feed_get_reshare(&$res,$item) {
}
$attach = $share['links'];
+
if($attach) {
foreach($attach as $att) {
if($att['rel'] === 'alternate') {
@@ -845,6 +846,10 @@ function feed_get_reshare(&$res,$item) {
}
}
+ if((! $body) && ($share['alternate'])) {
+ $body = $share['alternate'];
+ }
+
$res['body'] = "[share author='" . urlencode($share['author']) .
"' profile='" . $share['profile'] .
"' avatar='" . $share['avatar'] .
@@ -1706,7 +1711,7 @@ function compat_photos_list($s) {
$found = preg_match_all('/\[[zi]mg(.*?)\](.*?)\[/ism',$s,$matches,PREG_SET_ORDER);
if($found) {
- foreach($matches as $match) {
+ foreach($matches as $match) {
$ret[] = [
'href' => $match[2],
'length' => 0,
diff --git a/include/network.php b/include/network.php
index da1afc3ac..7e2dbf4cf 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1943,4 +1943,35 @@ function getBestSupportedMimeType($mimeTypes = null, $acceptedTypes = false) {
}
// no mime-type found
return null;
+}
+
+
+function jsonld_document_loader($url) {
+
+ // perform caching for jsonld normaliser
+
+ require_once('library/jsonld/jsonld.php');
+
+ $cachepath = 'store/[data]/ldcache';
+ if(! is_dir($cachepath))
+ os_mkdir($cachepath,STORAGE_DEFAULT_PERMISSIONS,true);
+
+ $filename = $cachepath . '/' . urlencode($url);
+ if(file_exists($filename) && filemtime($filename) > time() - (12 * 60 * 60)) {
+ return json_decode(file_get_contents($filename));
+ }
+
+ $r = jsonld_default_document_loader($url);
+ if($r) {
+ file_put_contents($filename,json_encode($r));
+ return $r;
+ }
+
+ logger('not found');
+ if(file_exists($filename)) {
+ return json_decode(file_get_contents($filename));
+ }
+
+ return [];
+
} \ No newline at end of file
diff --git a/include/perm_upgrade.php b/include/perm_upgrade.php
index 5be1ffbb2..9eb1efba2 100644
--- a/include/perm_upgrade.php
+++ b/include/perm_upgrade.php
@@ -135,6 +135,9 @@ function translate_abook_perms_outbound(&$abook) {
$my_perms = 0;
$their_perms = 0;
+ if(! $abook)
+ return;
+
if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && $abook['abconfig']) {
foreach($abook['abconfig'] as $p) {
if($p['cat'] === 'their_perms') {
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index c6c023147..17ca81419 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -666,6 +666,7 @@ function import_channel_photo_from_url($photo,$aid,$uid) {
import_channel_photo($img_str,$type,$aid,$uid);
+ return $type;
}
diff --git a/include/text.php b/include/text.php
index dafb6f131..16391bbc9 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1789,21 +1789,21 @@ function layout_select($channel_id, $current = '') {
function mimetype_select($channel_id, $current = 'text/bbcode', $choices = null, $element = 'mimetype') {
$x = (($choices) ? $choices : [
- 'text/bbcode',
- 'text/html',
- 'text/markdown',
- 'text/plain',
- 'application/x-pdl'
+ 'text/bbcode' => t('BBcode'),
+ 'text/html' => t('HTML'),
+ 'text/markdown' => t('Markdown'),
+ 'text/plain' => t('Text'),
+ 'application/x-pdl' => t('Comanche Layout')
]);
if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){
- $x[] = 'application/x-php';
+ $x['application/x-php'] = t('PHP');
}
- foreach($x as $y) {
+ foreach($x as $y => $z) {
$selected = (($y == $current) ? ' selected="selected" ' : '');
- $options .= '<option name="' . $y . '"' . $selected . '>' . $y . '</option>';
+ $options .= '<option value="' . $y . '"' . $selected . '>' . $z . '</option>';
}
$o = replace_macros(get_markup_template('field_select_raw.tpl'), array(
diff --git a/include/zot.php b/include/zot.php
index c8321c2ae..f03445781 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -977,6 +977,18 @@ function zot_process_response($hub, $arr, $outq) {
}
if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) {
+
+ if(array_key_exists('iv',$x['delivery_report'])) {
+ $j = crypto_unencapsulate($x['delivery_report'],get_config('system','prvkey'));
+ if($j) {
+ $x['delivery_report'] = json_decode($j,true);
+ }
+ if(! (is_array($x['delivery_report']) && count($x['delivery_report']))) {
+ logger('encrypted delivery report could not be decrypted');
+ return;
+ }
+ }
+
foreach($x['delivery_report'] as $xx) {
if(is_array($xx) && array_key_exists('message_id',$xx) && delivery_report_is_storable($xx)) {
q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ",
@@ -1048,13 +1060,15 @@ function zot_fetch($arr) {
foreach($ret_hubs as $ret_hub) {
+ $secret = substr(preg_replace('/[^0-9a-fA-F]/','',$arr['secret']),0,64);
+
$data = [
'type' => 'pickup',
'url' => z_root(),
'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post', get_config('system','prvkey'))),
'callback' => z_root() . '/post',
- 'secret' => $arr['secret'],
- 'secret_sig' => base64url_encode(rsa_sign($arr['secret'], get_config('system','prvkey')))
+ 'secret' => $secret,
+ 'secret_sig' => base64url_encode(rsa_sign($secret, get_config('system','prvkey')))
];
$algorithm = zot_best_algorithm($ret_hub['site_crypto']);
@@ -1064,8 +1078,11 @@ function zot_fetch($arr) {
$result = zot_import($fetch, $arr['sender']['url']);
- if($result)
+ if($result) {
+ $result = crypto_encapsulate(json_encode($result),$ret_hub['hubloc_sitekey'], $algorithm);
return $result;
+ }
+
}
return;