X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdfrn_confirm.php;h=897e85ecb60af2198db78cb6e66c271bbcc95536;hb=47bd3243cdb4a4840ca4d40452402a86b792ce1b;hp=9dd38df34bc327fc42c841777556296dd92baae7;hpb=9c2c4839968169a191084d6d2b0d629d82430e67;p=friendica.git diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 9dd38df34b..897e85ecb6 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -18,13 +18,15 @@ * https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_confirmation.png */ -require_once('include/enotify.php'); -require_once('include/group.php'); -require_once('include/Probe.php'); +use Friendica\App; +use Friendica\Network\Probe; + +require_once 'include/enotify.php'; +require_once 'include/group.php'; function dfrn_confirm_post(App $a, $handsfree = null) { - if (is_array($handsfree)) { + if(is_array($handsfree)) { /* * We were called directly from dfrn_request due to automatic friend acceptance. @@ -37,7 +39,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { } else { - if ($a->argc > 1) + if($a->argc > 1) $node = $a->argv[1]; } @@ -53,11 +55,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - if (! x($_POST,'source_url')) { + if(! x($_POST,'source_url')) { $uid = ((is_array($handsfree)) ? $handsfree['uid'] : local_user()); - if (! $uid) { + if(! $uid) { notice( t('Permission denied.') . EOL ); return; } @@ -66,7 +68,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($uid) ); - if (! $user) { + if(! $user) { notice( t('Profile not found.') . EOL ); return; } @@ -74,7 +76,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // These data elements may come from either the friend request notification form or $handsfree array. - if (is_array($handsfree)) { + if(is_array($handsfree)) { logger('Confirm in handsfree mode'); $dfrn_id = $handsfree['dfrn_id']; $intro_id = $handsfree['intro_id']; @@ -99,11 +101,11 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - if (strlen($dfrn_id)) + if(strlen($dfrn_id)) $cid = 0; logger('Confirming request for dfrn_id (issued) ' . $dfrn_id); - if ($cid) + if($cid) logger('Confirming follower with contact_id: ' . $cid); @@ -138,10 +140,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $network = ((strlen($contact['issued-id'])) ? NETWORK_DFRN : NETWORK_OSTATUS); - if ($contact['network']) + if($contact['network']) $network = $contact['network']; - if ($network === NETWORK_DFRN) { + if($network === NETWORK_DFRN) { /* * @@ -152,7 +154,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * worried about key leakage than anybody cracking it. * */ - require_once('include/crypto.php'); + require_once 'include/crypto.php'; $res = new_keypair(4096); @@ -185,10 +187,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - $src_aes_key = random_string(); + $src_aes_key = openssl_random_pseudo_bytes(64); $result = ''; - openssl_private_encrypt($dfrn_id,$result,$user[0]['prvkey']); + openssl_private_encrypt($dfrn_id, $result, $user[0]['prvkey']); $params['dfrn_id'] = bin2hex($result); $params['public_key'] = $public_key; @@ -199,19 +201,19 @@ function dfrn_confirm_post(App $a, $handsfree = null) { openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); $params['source_url'] = bin2hex($params['source_url']); - if ($aes_allow && function_exists('openssl_encrypt')) { + if($aes_allow && function_exists('openssl_encrypt')) { openssl_public_encrypt($src_aes_key, $params['aes_key'], $site_pubkey); $params['aes_key'] = bin2hex($params['aes_key']); $params['public_key'] = bin2hex(openssl_encrypt($public_key,'AES-256-CBC',$src_aes_key)); } $params['dfrn_version'] = DFRN_PROTOCOL_VERSION ; - if ($duplex == 1) + if($duplex == 1) $params['duplex'] = 1; - if ($user[0]['page-flags'] == PAGE_COMMUNITY) + if($user[0]['page-flags'] == PAGE_COMMUNITY) $params['page'] = 1; - if ($user[0]['page-flags'] == PAGE_PRVGROUP) + if($user[0]['page-flags'] == PAGE_PRVGROUP) $params['page'] = 2; logger('Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); @@ -234,7 +236,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $leading_junk = substr($res,0,strpos($res,' NOTIFY_CONFIRM, @@ -742,20 +745,20 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // Send a new friend post if we are allowed to... - if ($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { + if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($local_uid) ); - if ((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) { + if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0)) { - require_once('include/items.php'); + require_once 'include/items.php'; $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($local_uid) ); - if (dbm::is_result($self)) { + if(count($self)) { $arr = array(); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid); @@ -792,9 +795,8 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $arr['deny_gid'] = $user[0]['deny_gid']; $i = item_store($arr); - if ($i) { + if($i) proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); - } } }