diff options
-rwxr-xr-x | include/items.php | 42 | ||||
-rw-r--r-- | include/zot.php | 23 | ||||
-rw-r--r-- | mod/channel.php | 31 | ||||
-rw-r--r-- | mod/post.php | 4 | ||||
-rw-r--r-- | mod/profile.php | 17 | ||||
-rw-r--r-- | util/wp/post_to_red/post_to_red.php | 2 | ||||
-rw-r--r-- | version.inc | 2 |
7 files changed, 62 insertions, 59 deletions
diff --git a/include/items.php b/include/items.php index fa46b62a1..b6a196f4a 100755 --- a/include/items.php +++ b/include/items.php @@ -609,8 +609,8 @@ function get_item_elements($x) { // once, and after that your hub knows them. Sure some info is in the post, but it's only a transit identifier // and not enough info to be able to look you up from your hash - which is the only thing stored with the post. - if(import_author_xchan($x['author'])) - $arr['author_xchan'] = base64url_encode(hash('whirlpool',$x['author']['guid'] . $x['author']['guid_sig'], true)); + if(($xchan_hash = import_author_xchan($x['author'])) !== false) + $arr['author_xchan'] = $xchan_hash; else return array(); @@ -618,8 +618,8 @@ function get_item_elements($x) { if($arr['author_xchan'] === base64url_encode(hash('whirlpool',$x['owner']['guid'] . $x['owner']['guid_sig'], true))) $arr['owner_xchan'] = $arr['author_xchan']; else { - if(import_author_xchan($x['owner'])) - $arr['owner_xchan'] = base64url_encode(hash('whirlpool',$x['owner']['guid'] . $x['owner']['guid_sig'], true)); + if(($xchan_hash = import_author_xchan($x['owner'])) !== false) + $arr['owner_xchan'] = $xchan_hash; else return array(); } @@ -657,21 +657,18 @@ function get_item_elements($x) { function import_author_xchan($x) { - $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d) limit 1", - dbesc($x['guid']), - dbesc($x['guid_sig']), - intval(HUBLOC_FLAGS_PRIMARY) - ); + $arr = array('xchan' => $x, 'xchan_hash' => ''); + call_hooks('import_author_xchan',$arr); + if($arr['xchan_hash']) + return $arr['xchan_hash']; - if($r) { - logger('import_author_xchan: in cache', LOGGER_DEBUG); - return true; + if((! array_key_exists('network', $x)) || ($x['network'] === 'zot')) { + return import_author_zot($x); } - logger('import_author_xchan: entry not in cache - probing: ' . print_r($x,true), LOGGER_DEBUG); + // TODO: create xchans for other common and/or aligned networks - $them = array('hubloc_url' => $x['url'],'xchan_guid' => $x['guid'], 'xchan_guid_sig' => $x['guid_sig']); - return zot_refresh($them); + return false; } function encode_item($item) { @@ -785,6 +782,7 @@ function encode_item_xchan($xchan) { $ret['name'] = $xchan['xchan_name']; $ret['address'] = $xchan['xchan_addr']; $ret['url'] = $xchan['hubloc_url']; + $ret['network'] = $xchan['xchan_network']; $ret['photo'] = array('mimetype' => $xchan['xchan_photo_mimetype'], 'src' => $xchan['xchan_photo_m']); $ret['guid'] = $xchan['xchan_guid']; $ret['guid_sig'] = $xchan['xchan_guid_sig']; @@ -977,18 +975,16 @@ function get_mail_elements($x) { if($x['attach']) $arr['attach'] = activity_sanitise($x['attach']); - - if(import_author_xchan($x['from'])) - $arr['from_xchan'] = base64url_encode(hash('whirlpool',$x['from']['guid'] . $x['from']['guid_sig'], true)); + if(($xchan_hash = import_author_xchan($x['from'])) !== false) + $arr['from_xchan'] = $xchan_hash; else return array(); - if(import_author_xchan($x['to'])) - $arr['to_xchan'] = base64url_encode(hash('whirlpool',$x['to']['guid'] . $x['to']['guid_sig'], true)); + if(($xchan_hash = import_author_xchan($x['to'])) !== false) + $arr['to_xchan'] = $xchan_hash; else return array(); - return $arr; } @@ -998,8 +994,8 @@ function get_profile_elements($x) { $arr = array(); - if(import_author_xchan($x['from'])) - $arr['xprof_hash'] = base64url_encode(hash('whirlpool',$x['from']['guid'] . $x['from']['guid_sig'], true)); + if(($xchan_hash = import_author_xchan($x['from'])) !== false) + $arr['xprof_hash'] = $xchan_hash; else return array(); diff --git a/include/zot.php b/include/zot.php index e365435e9..37373e7ad 100644 --- a/include/zot.php +++ b/include/zot.php @@ -863,8 +863,6 @@ function import_xchan($arr,$ud_flags = 1) { } } - - if($changed) { $guid = random_string() . '@' . get_app()->get_hostname(); update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags); @@ -2103,3 +2101,24 @@ function get_rpost_path($observer) { } +function import_author_zot($x) { + $hash = base64url_encode(hash('whirlpool',$x['guid'] . $x['guid_sig'], true)); + $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d) limit 1", + dbesc($x['guid']), + dbesc($x['guid_sig']), + intval(HUBLOC_FLAGS_PRIMARY) + ); + + if($r) { + logger('import_author_zot: in cache', LOGGER_DEBUG); + return $hash; + } + + logger('import_author_zot: entry not in cache - probing: ' . print_r($x,true), LOGGER_DEBUG); + + $them = array('hubloc_url' => $x['url'],'xchan_guid' => $x['guid'], 'xchan_guid_sig' => $x['guid_sig']); + if(zot_refresh($them)) + return $hash; + return false; +} + diff --git a/mod/channel.php b/mod/channel.php index f36636023..2014cd08b 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -1,5 +1,14 @@ <?php +require_once('include/contact_widgets.php'); +require_once('include/items.php'); +require_once("include/bbcode.php"); +require_once('include/security.php'); +require_once('include/conversation.php'); +require_once('include/acl_selectors.php'); +require_once('include/permissions.php'); + + function channel_init(&$a) { $which = null; @@ -37,8 +46,6 @@ function channel_init(&$a) { function channel_aside(&$a) { - require_once('include/contact_widgets.php'); - require_once('include/items.php'); if(! $a->profile['profile_uid']) return; @@ -64,16 +71,6 @@ function channel_content(&$a, $update = 0, $load = false) { $category = $datequery = $datequery2 = ''; - // if(argc() > 2) { - // for($x = 2; $x < argc(); $x ++) { - // if(is_a_date_arg(argv($x))) { - // if($datequery) - // $datequery2 = escape_tags(argv($x)); - // else - // $datequery = escape_tags(argv($x)); - // } - // } - // } $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); @@ -81,16 +78,6 @@ function channel_content(&$a, $update = 0, $load = false) { return login(); } - - - require_once("include/bbcode.php"); - require_once('include/security.php'); - require_once('include/conversation.php'); - require_once('include/acl_selectors.php'); - require_once('include/items.php'); - require_once('include/permissions.php'); - - $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $groups = array(); diff --git a/mod/post.php b/mod/post.php index e65cb0968..627e13fa0 100644 --- a/mod/post.php +++ b/mod/post.php @@ -196,9 +196,9 @@ function post_init(&$a) { } else { logger('mod_zot: magic-auth failure - not authenticated: ' . $x[0]['xchan_addr']); - q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_addr = '%s'", + q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ", intval(HUBLOC_RECEIVE_ERROR), - dbesc($x[0]['xchan_addr']) + intval($x[0]['hubloc_id']) ); } diff --git a/mod/profile.php b/mod/profile.php index cd5c3eeef..a307905e6 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -1,4 +1,12 @@ -<?php +<?php /** @file */ + +require_once('include/contact_widgets.php'); +require_once('include/items.php'); +require_once("include/bbcode.php"); +require_once('include/security.php'); +require_once('include/conversation.php'); +require_once('include/acl_selectors.php'); + function profile_init(&$a) { @@ -45,8 +53,6 @@ function profile_init(&$a) { function profile_aside(&$a) { - require_once('include/contact_widgets.php'); - require_once('include/items.php'); profile_create_sidebar($a); @@ -60,11 +66,6 @@ function profile_content(&$a, $update = 0) { } - require_once("include/bbcode.php"); - require_once('include/security.php'); - require_once('include/conversation.php'); - require_once('include/acl_selectors.php'); - require_once('include/items.php'); $groups = array(); diff --git a/util/wp/post_to_red/post_to_red.php b/util/wp/post_to_red/post_to_red.php index 11b1b48f7..e7f18985e 100644 --- a/util/wp/post_to_red/post_to_red.php +++ b/util/wp/post_to_red/post_to_red.php @@ -96,7 +96,7 @@ function post_to_red_post($post_id) { foreach($terms as $term) { if(strlen($cats)) $cats .= ','; - $cats .= $term->name; + $cats .= htmlspecialchars_decode($term->name, ENT_COMPAT); } } diff --git a/version.inc b/version.inc index ccc8f4186..8e4f4a4dc 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-12-03.516 +2013-12-04.517 |