diff options
author | zotlabs <mike@macgirvin.com> | 2016-10-13 21:06:26 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-10-13 21:06:26 -0700 |
commit | 40e03a05be8273a0c5fcebeeab127009976d6086 (patch) | |
tree | 2f987765fa51f208fe69f5de988c98b5c1c10fa4 /include/zot.php | |
parent | bd70e6ae6d5baa5f75e3c704ae25ff41a6a90047 (diff) | |
parent | b9eb74a705823ddc0fafe81e460442b525d0e7ed (diff) | |
download | volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.tar.gz volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.tar.bz2 volse-hubzilla-40e03a05be8273a0c5fcebeeab127009976d6086.zip |
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
Diffstat (limited to 'include/zot.php')
-rw-r--r-- | include/zot.php | 183 |
1 files changed, 93 insertions, 90 deletions
diff --git a/include/zot.php b/include/zot.php index f6d6fe362..838ac44c6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -176,7 +176,7 @@ function zot_zot($url, $data) { * @param boolean $autofallback * fallback/failover to http if https connection cannot be established. Default is true. * - * @return array see z_post_url() and \ref mod/zfinger.php + * @return array see z_post_url() and \ref Zotlabs::Zot::Finger "\\Zotlabs\\Zot\\Finger" */ function zot_finger($webbie, $channel = null, $autofallback = true) { @@ -303,7 +303,7 @@ function zot_refresh($them, $channel = null, $force = false) { // if they re-installed the server we could end up with the wrong record - pointing to the old install. // We'll order by reverse id to try and pick off the newest one first and hopefully end up with the - // correct hubloc. If this doesn't work we may have to re-write this section to try them all. + // correct hubloc. If this doesn't work we may have to re-write this section to try them all. if(array_key_exists('xchan_addr',$them) && $them['xchan_addr']) { $r = q("select hubloc_url, hubloc_primary from hubloc where hubloc_addr = '%s' order by hubloc_id desc", @@ -526,7 +526,7 @@ function zot_refresh($them, $channel = null, $force = false) { 'to_xchan' => $channel['channel_hash'], 'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'], )); - + if(intval($permissions['view_stream'])) { if(intval(get_pconfig($channel['channel_id'],'perm_limits','send_stream') & PERMS_PENDING) || (! intval($new_connection[0]['abook_pending']))) @@ -539,7 +539,7 @@ function zot_refresh($them, $channel = null, $force = false) { if($default_group) { require_once('include/group.php'); $g = group_rec_byhash($channel['channel_id'],$default_group); - if($g) + if($g) group_add_member($channel['channel_id'],'',$x['hash'],$g['id']); } @@ -575,11 +575,12 @@ function zot_refresh($them, $channel = null, $force = false) { * * \e string \b guid_sig => guid signed with conversant's private key * * \e string \b url => URL of the origination hub of this communication * * \e string \b url_sig => URL signed with conversant's private key + * @param boolean $multiple (optional) default false * * @returns array|null null if site is blacklisted or not found, otherwise an * array with an hubloc record */ -function zot_gethub($arr,$multiple = false) { +function zot_gethub($arr, $multiple = false) { if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) { @@ -590,7 +591,7 @@ function zot_gethub($arr,$multiple = false) { $limit = (($multiple) ? '' : ' limit 1 '); $sitekey = ((array_key_exists('sitekey',$arr) && $arr['sitekey']) ? " and hubloc_sitekey = '" . protect_sprintf($arr['sitekey']) . "' " : ''); - + $r = q("select * from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' @@ -758,15 +759,15 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { if(intval($r[0]['xchan_pubforum']) != intval($arr['public_forum'])) $pubforum_changed = 1; - if(($r[0]['xchan_name_date'] != $arr['name_updated']) - || ($r[0]['xchan_connurl'] != $arr['connections_url']) + if(($r[0]['xchan_name_date'] != $arr['name_updated']) + || ($r[0]['xchan_connurl'] != $arr['connections_url']) || ($r[0]['xchan_addr'] != $arr['address']) || ($r[0]['xchan_follow'] != $arr['follow_url']) - || ($r[0]['xchan_connpage'] != $arr['connect_url']) + || ($r[0]['xchan_connpage'] != $arr['connect_url']) || ($r[0]['xchan_url'] != $arr['url']) || $hidden_changed || $adult_changed || $deleted_changed || $pubforum_changed ) { - $rup = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', - xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d, + $rup = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', + xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d, xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s'", dbesc(($arr['name']) ? $arr['name'] : '-'), dbesc($arr['name_updated']), @@ -1026,12 +1027,12 @@ function zot_process_response($hub, $arr, $outq) { } } - // we have a more descriptive delivery report, so discard the per hub 'queued' report. + // we have a more descriptive delivery report, so discard the per hub 'queued' report. q("delete from dreport where dreport_queue = '%s' ", dbesc($outq['outq_hash']) ); - + // update the timestamp for this site q("update site set site_dead = 0, site_update = '%s' where site_url = '%s'", @@ -1072,7 +1073,7 @@ function zot_fetch($arr) { // set $multiple param on zot_gethub() to return all matching hubs // This allows us to recover from re-installs when a redundant (but invalid) hubloc for - // this identity is widely dispersed throughout the network. + // this identity is widely dispersed throughout the network. $ret_hubs = zot_gethub($arr['sender'],true); if(! $ret_hubs) { @@ -1084,7 +1085,7 @@ function zot_fetch($arr) { $data = array( 'type' => 'pickup', 'url' => z_root(), - 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post',get_config('system','prvkey'))), + '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'))) @@ -1095,7 +1096,7 @@ function zot_fetch($arr) { $fetch = zot_zot($url,$datatosend); $result = zot_import($fetch, $arr['sender']['url']); - + if($result) return $result; } @@ -1199,7 +1200,7 @@ function zot_import($arr, $sender_url) { if($recip_arr) { stringify_array_elms($recip_arr); $recips = implode(',',$recip_arr); - $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) + $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) and channel_removed = 0 "); } @@ -1407,7 +1408,7 @@ function public_recips($msg) { $perm = 'post_mail'; $r = array(); - + $c = q("select channel_id, channel_hash from channel where channel_removed = 0"); if($c) { foreach($c as $cc) { @@ -1436,7 +1437,7 @@ function public_recips($msg) { if(($tag['type'] === 'mention') && (strpos($tag['url'],z_root()) !== false)) { $address = basename($tag['url']); if($address) { - $z = q("select channel_hash as hash from channel where channel_address = '%s' + $z = q("select channel_hash as hash from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc($address) ); @@ -1609,12 +1610,12 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ /** * @FIXME: Somehow we need to block normal message delivery from our clones, as the delivered - * message doesn't have ACL information in it as the cloned copy does. That copy - * will normally arrive first via sync delivery, but this isn't guaranteed. + * message doesn't have ACL information in it as the cloned copy does. That copy + * will normally arrive first via sync delivery, but this isn't guaranteed. * There's a chance the current delivery could take place before the cloned copy arrives * hence the item could have the wrong ACL and *could* be used in subsequent deliveries or * access checks. So far all attempts at identifying this situation precisely - * have caused issues with delivery of relayed comments. + * have caused issues with delivery of relayed comments. */ // if(($d['hash'] === $sender['hash']) && ($sender['url'] !== z_root()) && (! $relay)) { @@ -1747,7 +1748,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ intval($channel['channel_id']), dbesc($arr['owner_xchan']) ); - $abook = (($ab) ? $ab[0] : null); + $abook = (($ab) ? $ab[0] : null); if(intval($arr['item_deleted'])) { @@ -1761,7 +1762,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $arr['uid'] = $channel['channel_id']; $item_id = delete_imported_item($sender,$arr,$channel['channel_id'],$relay); - $DR->update(($item_id) ? 'deleted' : 'delete_failed'); + $DR->update(($item_id) ? 'deleted' : 'delete_failed'); $result[] = $DR->get(); if($relay && $item_id) { @@ -1783,7 +1784,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $item_id = $r[0]['id']; if(intval($r[0]['item_deleted'])) { - // It was deleted locally. + // It was deleted locally. $DR->update('update ignored'); $result[] = $DR->get(); @@ -1810,8 +1811,8 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $result[] = $DR->get(); - // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit), - // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful. + // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit), + // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful. if(! intval($r[0]['item_origin'])) continue; } @@ -1825,7 +1826,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ if(check_item_source($arr['uid'], $arr)) call_hooks('post_local', $arr); - + $item_id = 0; if(($arr['mid'] == $arr['parent_mid']) && (! post_is_importable($arr,$abook))) { @@ -1938,9 +1939,11 @@ function remove_community_tag($sender, $arr, $uid) { * @brief Just calls item_store_update() and logs result. * * @see item_store_update() + * * @param array $sender (unused) * @param array $item - * @param int $uid (unused) + * @param array $orig + * @param int $uid */ function update_imported_item($sender, $item, $orig, $uid) { @@ -1961,7 +1964,7 @@ function update_imported_item($sender, $item, $orig, $uid) { // because event_addtocal will parse the body to get the 'new' event details if($orig['resource_type'] === 'event') { - $res = event_addtocal($orig['id'],$uid); + $res = event_addtocal($orig['id'], $uid); if(! $res) logger('update event: failed'); } @@ -2236,15 +2239,15 @@ function process_location_delivery($sender,$arr,$deliveries) { /** * @brief checks for a moved UNO channel and sets the channel_moved flag - * + * * Currently the effect of this flag is to turn the channel into 'read-only' mode. - * New content will not be processed (there was still an issue with blocking the + * New content will not be processed (there was still an issue with blocking the * ability to post comments as of 10-Mar-2016). - * We do not physically remove the channel at this time. The hub admin may choose + * We do not physically remove the channel at this time. The hub admin may choose * to do so, but is encouraged to allow a grace period of several days in case there * are any issues migrating content. This packet will generally be received by the * original site when the basic channel import has been processed. - * + * * This will only be executed on the UNO system which is the old location * if a new location is reported and there is only one location record. * The rest of the hubloc syncronisation will be handled within @@ -2256,7 +2259,7 @@ function process_location_delivery($sender,$arr,$deliveries) { function check_location_move($sender_hash,$locations) { if(! $locations) - return; + return; if(get_config('system','server_role') !== 'basic') return; @@ -2279,13 +2282,13 @@ function check_location_move($sender_hash,$locations) { dbesc($sender_hash) ); - // federation plugins may wish to notify connections + // federation plugins may wish to notify connections // of the move on singleton networks $arr = array('channel' => $r[0],'locations' => $locations); call_hooks('location_move',$arr); - } + } } @@ -2540,7 +2543,7 @@ function zot_encode_locations($channel) { foreach($x as $hub) { // if this is a local channel that has been deleted, the hubloc is no good - make sure it is marked deleted - // so that nobody tries to use it. + // so that nobody tries to use it. if(intval($channel['channel_removed']) && $hub['hubloc_url'] === z_root()) $hub['hubloc_deleted'] = 1; @@ -3094,7 +3097,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { require_once('include/import.php'); - /** @FIXME this will sync red structures (channel, pconfig and abook). + /** @FIXME this will sync red structures (channel, pconfig and abook). Eventually we need to make this application agnostic. */ $result = array(); @@ -3185,15 +3188,15 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] - 0x1000; } - - $disallowed = [ - 'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey', - 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted', - 'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook', - 'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall', - 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall', - 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish', - 'channel_a_delegate' + + $disallowed = [ + 'channel_id', 'channel_account_id', 'channel_primary', 'channel_prvkey', + 'channel_address', 'channel_notifyflags', 'channel_removed', 'channel_deleted', + 'channel_system', 'channel_r_stream', 'channel_r_profile', 'channel_r_abook', + 'channel_r_storage', 'channel_r_pages', 'channel_w_stream', 'channel_w_wall', + 'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall', + 'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish', + 'channel_a_delegate' ]; $clean = array(); @@ -3230,7 +3233,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($arr['abook'] as $abook) { - + $abconfig = null; @@ -3507,7 +3510,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { foreach($profile as $k => $v) { if(in_array($k,$disallowed)) continue; - + if($k === 'name') $clean['fullname'] = $v; elseif($k === 'with') @@ -3518,7 +3521,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $clean[$k] = $v; /** - * @TODO + * @TODO * We also need to import local photos if a custom photo is selected */ } @@ -3720,18 +3723,18 @@ function zotinfo($arr) { } } - $ztarget_hash = (($ztarget && $zsig) ? make_xchan_hash($ztarget,$zsig) : '' ); + $ztarget_hash = (($ztarget && $zsig) ? make_xchan_hash($ztarget,$zsig) : '' ); $r = null; if(strlen($zhash)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1", dbesc($zhash) ); } elseif(strlen($zguid) && strlen($zguid_sig)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($zguid), dbesc($zguid_sig) @@ -3750,7 +3753,7 @@ function zotinfo($arr) { /** * The special address '[system]' will return a system channel if one has been defined, - * Or the first valid channel we find if there are no system channels. + * Or the first valid channel we find if there are no system channels. * * This is used by magic-auth if we have no prior communications with this site - and * returns an identity on this site which we can use to create a valid hub record so that @@ -3765,7 +3768,7 @@ function zotinfo($arr) { $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_removed = 0 order by channel_id limit 1"); } - } + } } else { $ret['message'] = 'Invalid request'; @@ -3790,7 +3793,7 @@ function zotinfo($arr) { if($deleted || $censored || $sys_channel) $searchable = false; - + $public_forum = false; $role = get_pconfig($e['channel_id'],'system','permissions_role'); @@ -3823,14 +3826,14 @@ function zotinfo($arr) { if($p) { if(! intval($p[0]['publish'])) - $searchable = false; + $searchable = false; $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== '')) $profile['next_birthday'] = $bd; - if($age = age($p[0]['dob'],$e['channel_timezone'],'')) + if($age = age($p[0]['dob'],$e['channel_timezone'],'')) $profile['age'] = $age; $profile['gender'] = $p[0]['gender']; $profile['marital'] = $p[0]['marital']; @@ -3883,14 +3886,14 @@ function zotinfo($arr) { $ret['adult_content'] = $adult_channel; $ret['public_forum'] = $public_forum; if($deleted) - $ret['deleted'] = $deleted; + $ret['deleted'] = $deleted; if(intval($e['channel_removed'])) $ret['deleted_locally'] = true; // premium or other channel desiring some contact with potential followers before connecting. // This is a template - %s will be replaced with the follow_url we discover for the return channel. - if($special_channel) + if($special_channel) $ret['connect_url'] = z_root() . '/connect/' . $e['channel_address']; // This is a template for our follow url, %s will be replaced with a webbie @@ -3966,7 +3969,7 @@ function zotinfo($arr) { $ret['site']['access_policy'] = 'tiered'; $ret['site']['accounts'] = account_total(); - + require_once('include/channel.php'); $ret['site']['channels'] = channel_total(); @@ -4007,7 +4010,7 @@ function check_zotinfo($channel,$locations,&$ret) { // This function will likely expand as we find more things to detect and fix. // 1. Because magic-auth is reliant on it, ensure that the system channel has a valid hubloc - // Force this to be the case if anything is found to be wrong with it. + // Force this to be the case if anything is found to be wrong with it. // @FIXME ensure that the system channel exists in the first place and has an xchan @@ -4027,9 +4030,9 @@ function check_zotinfo($channel,$locations,&$ret) { logger('System channel locations are not valid. Attempting repair.'); - // Don't trust any existing records. Just get rid of them, but only do this + // Don't trust any existing records. Just get rid of them, but only do this // for the sys channel as normal channels will be trickier. - + q("delete from hubloc where hubloc_hash = '%s'", dbesc($channel['channel_hash']) ); @@ -4086,7 +4089,7 @@ function delivery_report_is_storable($dr) { return false; - // is the recipient one of our connections, or do we want to store every report? + // is the recipient one of our connections, or do we want to store every report? $r = explode(' ', $dr['recipient']); $rxchan = $r[0]; @@ -4097,15 +4100,15 @@ function delivery_report_is_storable($dr) { // We always add ourself as a recipient to private and relayed posts // So if a remote site says they can't find us, that's no big surprise // and just creates a lot of extra report noise - + if(($dr['location'] !== z_root()) && ($dr['sender'] === $rxchan) && ($dr['status'] === 'recipient_not_found')) return false; // If you have a private post with a recipient list, every single site is going to report - // back a failed delivery for anybody on that list that isn't local to them. We're only + // back a failed delivery for anybody on that list that isn't local to them. We're only // concerned about this if we have a local hubloc record which says we expected them to // have a channel on that site. - + $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_url = '%s'", dbesc($rxchan), dbesc($dr['location']) @@ -4135,7 +4138,7 @@ function update_hub_connected($hub,$sitekey = '') { * Any hub with the same URL and a different sitekey cannot be valid. * Get rid of them (mark them deleted). There's a good chance they were re-installs. */ - + q("update hubloc set hubloc_deleted = 1, hubloc_error = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ", dbesc($hub['hubloc_url']), dbesc($sitekey) @@ -4146,7 +4149,7 @@ function update_hub_connected($hub,$sitekey = '') { $sitekey = $hub['sitekey']; } - // $sender['sitekey'] is a new addition to the protocol to distinguish + // $sender['sitekey'] is a new addition to the protocol to distinguish // hublocs coming from re-installed sites. Older sites will not provide // this field and we have to still mark them valid, since we can't tell // if this hubloc has the same sitekey as the packet we received. @@ -4169,7 +4172,7 @@ function update_hub_connected($hub,$sitekey = '') { if(intval($hub['hubloc_error'])) { q("update hubloc set hubloc_error = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ", intval($hub['hubloc_id']), - dbesc($sitekey) + dbesc($sitekey) ); if(intval($r[0]['hubloc_orphancheck'])) { q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ", @@ -4181,7 +4184,7 @@ function update_hub_connected($hub,$sitekey = '') { dbesc($hub['hubloc_hash']) ); } - + return $hub['hubloc_url']; } @@ -4194,7 +4197,7 @@ function zot_reply_ping() { // This will let us know if any important communication details // that we may have stored are no longer valid, regardless of xchan details. logger('POST: got ping send pong now back: ' . z_root() , LOGGER_DEBUG ); - + $ret['success'] = true; $ret['site'] = array(); $ret['site']['url'] = z_root(); @@ -4268,7 +4271,7 @@ function zot_reply_pickup($data) { /* * If we made it to here, the signatures verify, but we still don't know if the tracking ID is valid. * It wouldn't be an error if the tracking ID isn't found, because we may have sent this particular - * queue item with another pickup (after the tracking ID for the other pickup was verified). + * queue item with another pickup (after the tracking ID for the other pickup was verified). */ $r = q("select outq_posturl from outq where outq_hash = '%s' and outq_posturl = '%s' limit 1", @@ -4308,7 +4311,7 @@ function zot_reply_pickup($data) { } else $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $x); - + remove_queue_item($rr['outq_hash']); } } @@ -4330,7 +4333,7 @@ function zot_reply_auth_check($data,$encrypted_packet) { * Requestor visits /magic/?dest=somewhere on their own site with a browser * magic redirects them to $destsite/post [with auth args....] * $destsite sends an auth_check packet to originator site - * The auth_check packet is handled here by the originator's site + * The auth_check packet is handled here by the originator's site * - the browser session is still waiting * inside $destsite/post for everything to verify * If everything checks out we'll return a token to $destsite @@ -4352,9 +4355,9 @@ function zot_reply_auth_check($data,$encrypted_packet) { // garbage collect any old unused notifications - // This was and should be 10 minutes but my hosting provider has time lag between the DB and - // the web server. We should probably convert this to webserver time rather than DB time so - // that the different clocks won't affect it and allow us to keep the time short. + // This was and should be 10 minutes but my hosting provider has time lag between the DB and + // the web server. We should probably convert this to webserver time rather than DB time so + // that the different clocks won't affect it and allow us to keep the time short. Zotlabs\Zot\Verify::purge('auth','30 MINUTE'); @@ -4365,7 +4368,7 @@ function zot_reply_auth_check($data,$encrypted_packet) { // We created a unique hash in mod/magic.php when we invoked remote auth, and stored it in // the verify table. It is now coming back to us as 'secret' and is signed by a channel at the other end. // First verify their signature. We will have obtained a zot-info packet from them as part of the sender - // verification. + // verification. if ((! $y) || (! rsa_verify($data['secret'], base64url_decode($data['secret_sig']),$y[0]['xchan_pubkey']))) { logger('mod_zot: auth_check: sender not found or secret_sig invalid.'); @@ -4438,7 +4441,7 @@ function zot_reply_purge($sender,$recipients) { if ($recipients) { // basically this means "unfriend" foreach ($recipients as $recip) { - $r = q("select channel.*,xchan.* from channel + $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), @@ -4455,13 +4458,13 @@ function zot_reply_purge($sender,$recipients) { } } $ret['success'] = true; - } + } else { // Unfriend everybody - basically this means the channel has committed suicide $arr = $sender; $sender_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); - remove_all_xchan_resources($sender_hash); + remove_all_xchan_resources($sender_hash); $ret['success'] = true; } @@ -4476,7 +4479,7 @@ function zot_reply_refresh($sender,$recipients) { // remote channel info (such as permissions or photo or something) // has been updated. Grab a fresh copy and sync it. - // The difference between refresh and force_refresh is that + // The difference between refresh and force_refresh is that // force_refresh unconditionally creates a directory update record, // even if no changes were detected upon processing. @@ -4485,7 +4488,7 @@ function zot_reply_refresh($sender,$recipients) { // This would be a permissions update, typically for one connection foreach ($recipients as $recip) { - $r = q("select channel.*,xchan.* from channel + $r = q("select channel.*,xchan.* from channel left join xchan on channel_hash = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), @@ -4493,17 +4496,17 @@ function zot_reply_refresh($sender,$recipients) { ); $x = zot_refresh(array( - 'xchan_guid' => $sender['guid'], + 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] ), $r[0], (($msgtype === 'force_refresh') ? true : false)); } - } + } else { // system wide refresh $x = zot_refresh(array( - 'xchan_guid' => $sender['guid'], + 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], 'hubloc_url' => $sender['url'] ), null, (($msgtype === 'force_refresh') ? true : false)); @@ -4526,7 +4529,7 @@ function zot_reply_notify($data) { if($async) { // add to receive queue // qreceive_add($data); - } + } else { $x = zot_fetch($data); $ret['delivery_report'] = $x; |