X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdfrn_confirm.php;h=98bdfbe1503991e69b4a92fc529d76b692d55764;hb=4ca68c7af05b7b41e1b04936b9080802ca2b7716;hp=001fa446891b28eaf205b763d8168dff26005a1f;hpb=9237b2611a1112072a5c5955999c557562a07153;p=friendica.git diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 001fa44689..98bdfbe150 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -18,9 +18,17 @@ * 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\Core\Config; +use Friendica\Core\PConfig; +use Friendica\Core\System; +use Friendica\Core\Worker; +use Friendica\Database\DBM; +use Friendica\Network\Probe; +use Friendica\Protocol\Diaspora; + +require_once 'include/enotify.php'; +require_once 'include/group.php'; function dfrn_confirm_post(App $a, $handsfree = null) { @@ -121,7 +129,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($uid) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { logger('Contact not found in DB.'); notice( t('Contact not found.') . EOL ); notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL ); @@ -152,7 +160,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); @@ -194,7 +202,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $params['public_key'] = $public_key; - $my_url = App::get_baseurl() . '/profile/' . $user[0]['nickname']; + $my_url = System::baseUrl() . '/profile/' . $user[0]['nickname']; openssl_public_encrypt($my_url, $params['source_url'], $site_pubkey); $params['source_url'] = bin2hex($params['source_url']); @@ -245,7 +253,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { return; } - if(strlen($leading_junk) && get_config('system','debugging')) { + if(strlen($leading_junk) && Config::get('system','debugging')) { // This might be more common. Mixed error text and some XML. // If we're configured for debugging, show the text. Proceed in either case. @@ -317,7 +325,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { * */ - require_once('include/Photo.php'); + require_once 'include/Photo.php'; update_contact_avatar($contact['photo'],$uid,$contact_id); @@ -349,8 +357,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { dbesc(NETWORK_DFRN), intval($contact_id) ); - } - else { + } else { // $network !== NETWORK_DFRN @@ -358,18 +365,16 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $notify = (($contact['notify']) ? $contact['notify'] : ''); $poll = (($contact['poll']) ? $contact['poll'] : ''); - if((! $contact['notify']) || (! $contact['poll'])) { - $arr = Probe::lrdd($contact['url']); - if(count($arr)) { - foreach($arr as $link) { - if($link['@attributes']['rel'] === 'salmon') - $notify = $link['@attributes']['href']; - if($link['@attributes']['rel'] === NAMESPACE_FEED) - $poll = $link['@attributes']['href']; - } - } + $arr = Probe::uri($contact['url']); + if (empty($contact['notify'])) { + $notify = $arr['notify']; + } + if (empty($contact['poll'])) { + $poll = $arr['poll']; } + $addr = $arr['addr']; + $new_relation = $contact['rel']; $writable = $contact['writable']; @@ -391,6 +396,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $r = q("UPDATE `contact` SET `name-date` = '%s', `uri-date` = '%s', + `addr` = '%s', `notify` = '%s', `poll` = '%s', `blocked` = 0, @@ -403,6 +409,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { ", dbesc(datetime_convert()), dbesc(datetime_convert()), + dbesc($addr), dbesc($notify), dbesc($poll), dbesc($network), @@ -413,7 +420,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { ); } - /// @TODO is dbm::is_result() working here? + /// @TODO is DBM::is_result() working here? if ($r === false) { notice( t('Unable to set contact photo.') . EOL); } @@ -423,7 +430,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($contact_id) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $contact = $r[0]; } else { $contact = null; @@ -433,7 +440,6 @@ function dfrn_confirm_post(App $a, $handsfree = null) { if ((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) { if (($contact) && ($contact['network'] === NETWORK_DIASPORA)) { - require_once('include/diaspora.php'); $ret = Diaspora::send_share($user[0],$r[0]); logger('share returns: ' . $ret); } @@ -444,9 +450,9 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($uid) ); - if((dbm::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) { + if((DBM::is_result($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) { - require_once('include/items.php'); + require_once 'include/items.php'; $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($uid) @@ -492,7 +498,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $i = item_store($arr); if($i) - proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + Worker::add(PRIORITY_HIGH, "notifier", "activity", $i); } } } @@ -505,7 +511,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // do anything special with this new friend. if ($handsfree === null) { - goaway(App::get_baseurl() . '/contacts/' . intval($contact_id)); + goaway(System::baseUrl() . '/contacts/' . intval($contact_id)); } else { return; } @@ -555,7 +561,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", dbesc($node)); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { $message = sprintf(t('No user record found for \'%s\' '), $node); xml_status(3,$message); // failure // NOTREACHED @@ -586,7 +592,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { dbesc($decrypted_source_url), intval($local_uid) ); - if (!dbm::is_result($ret)) { + if (!DBM::is_result($ret)) { if (strstr($decrypted_source_url,'http:')) { $newurl = str_replace('http:','https:',$decrypted_source_url); } else { @@ -597,7 +603,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { dbesc($newurl), intval($local_uid) ); - if (!dbm::is_result($ret)) { + if (!DBM::is_result($ret)) { // this is either a bogus confirmation (?) or we deleted the original introduction. $message = t('Contact record was not found for you on our site.'); xml_status(3,$message); @@ -632,7 +638,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $r = q("SELECT * FROM `contact` WHERE `dfrn-id` = '%s' LIMIT 1", dbesc($decrypted_dfrn_id) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $message = t('The ID provided by your system is a duplicate on our system. It should work if you try again.'); xml_status(1,$message); // Birthday paradox - duplicate dfrn-id // NOTREACHED @@ -643,7 +649,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { dbesc($dfrn_pubkey), intval($dfrn_record) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { $message = t('Unable to set your contact credentials on our system.'); xml_status(3,$message); } @@ -664,13 +670,13 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $r = q("SELECT `photo` FROM `contact` WHERE `id` = %d LIMIT 1", intval($dfrn_record)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $photo = $r[0]['photo']; } else { - $photo = App::get_baseurl() . '/images/person-175.jpg'; + $photo = System::baseUrl() . '/images/person-175.jpg'; } - require_once("include/Photo.php"); + require_once 'include/Photo.php'; update_contact_avatar($photo,$local_uid,$dfrn_record); @@ -720,10 +726,10 @@ function dfrn_confirm_post(App $a, $handsfree = null) { intval($dfrn_record) ); - if (dbm::is_result($r)) + if (DBM::is_result($r)) $combined = $r[0]; - if((dbm::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) { + if((DBM::is_result($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) { $mutual = ($new_relation == CONTACT_IS_FRIEND); notification(array( 'type' => NOTIFY_CONFIRM, @@ -732,7 +738,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { 'to_name' => $r[0]['username'], 'to_email' => $r[0]['email'], 'uid' => $r[0]['uid'], - 'link' => App::get_baseurl() . '/contacts/' . $dfrn_record, + 'link' => System::baseUrl() . '/contacts/' . $dfrn_record, 'source_name' => ((strlen(stripslashes($r[0]['name']))) ? stripslashes($r[0]['name']) : t('[Name Withheld]')), 'source_link' => $r[0]['url'], 'source_photo' => $r[0]['photo'], @@ -743,14 +749,14 @@ 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(PConfig::get($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) @@ -794,7 +800,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { $i = item_store($arr); if($i) - proc_run(PRIORITY_HIGH, "include/notifier.php", "activity", $i); + Worker::add(PRIORITY_HIGH, "notifier", "activity", $i); } } @@ -807,7 +813,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) { // somebody arrived here by mistake or they are fishing. Send them to the homepage. - goaway(z_root()); + goaway(System::baseUrl()); // NOTREACHED }