X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fdfrn_request.php;h=4efb4119e1c7df065ec6c29fd0091f00b1533149;hb=47bd3243cdb4a4840ca4d40452402a86b792ce1b;hp=b9c1b674464b1890f2b29b9f8e460cdd91225b89;hpb=20e71d21a6206c03f2137eb82edf8f8b3bc644f2;p=friendica.git diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index b9c1b67446..4efb4119e1 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -12,12 +12,14 @@ * https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png */ -require_once('include/enotify.php'); -require_once('include/Scrape.php'); -require_once('include/Probe.php'); -require_once('include/group.php'); +use Friendica\App; +use Friendica\Network\Probe; -function dfrn_request_init(App &$a) { +require_once 'include/enotify.php'; +require_once 'include/probe.php'; +require_once 'include/group.php'; + +function dfrn_request_init(App $a) { if($a->argc > 1) $which = $a->argv[1]; @@ -42,7 +44,7 @@ function dfrn_request_init(App &$a) { * After logging in, we click 'submit' to approve the linkage. * */ -function dfrn_request_post(App &$a) { +function dfrn_request_post(App $a) { if(($a->argc != 2) || (! count($a->profile))) { logger('Wrong count of argc or profiles: argc=' . $a->argc . ',profile()=' . count($a->profile)); @@ -131,7 +133,7 @@ function dfrn_request_post(App &$a) { if (! x($parms,'photo')) { notice( t('Warning: profile location has no profile photo.') . EOL ); } - $invalid = Probe::valid_dfrn($parms); + $invalid = Probe::validDfrn($parms); if ($invalid) { notice( sprintf( tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", @@ -145,9 +147,7 @@ function dfrn_request_post(App &$a) { $photo = $parms["photo"]; // Escape the entire array - - dbesc_array($parms); - + dbm::esc_array($parms); /* * Create a contact record on our site for the other person @@ -303,7 +303,7 @@ function dfrn_request_post(App &$a) { if (dbm::is_result($r)) { foreach ($r as $rr) { if(! $rr['rel']) { - q("DELETE FROM `contact` WHERE `id` = %d", + q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`", intval($rr['cid']) ); } @@ -328,7 +328,7 @@ function dfrn_request_post(App &$a) { if (dbm::is_result($r)) { foreach ($r as $rr) { if(! $rr['rel']) { - q("DELETE FROM `contact` WHERE `id` = %d", + q("DELETE FROM `contact` WHERE `id` = %d AND NOT `self`", intval($rr['cid']) ); } @@ -455,7 +455,7 @@ function dfrn_request_post(App &$a) { $network = $data["network"]; // Canonicalise email-style profile locator - $url = Probe::webfinger_dfrn($url,$hcard); + $url = Probe::webfingerDfrn($url,$hcard); if (substr($url,0,5) === 'stat:') { @@ -516,8 +516,11 @@ function dfrn_request_post(App &$a) { return; // NOTREACHED } - - require_once('include/Scrape.php'); + if (blocked_url($url)) { + notice( t('Blocked domain') . EOL); + goaway(App::get_baseurl() . '/' . $a->cmd); + return; // NOTREACHED + } $parms = Probe::profile(($hcard) ? $hcard : $url); @@ -532,7 +535,7 @@ function dfrn_request_post(App &$a) { if (! x($parms,'photo')) { notice( t('Warning: profile location has no profile photo.') . EOL ); } - $invalid = Probe::valid_dfrn($parms); + $invalid = Probe::validDfrn($parms); if ($invalid) { notice( sprintf( tt("%d required parameter was not found at the given location", "%d required parameters were not found at the given location", @@ -547,7 +550,7 @@ function dfrn_request_post(App &$a) { $parms['issued-id'] = $issued_id; $photo = $parms["photo"]; - dbesc_array($parms); + dbm::esc_array($parms); $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `name`, `nick`, `issued-id`, `photo`, `site-pubkey`, `request`, `confirm`, `notify`, `poll`, `poco`, `network`, `blocked`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", @@ -658,7 +661,7 @@ function dfrn_request_post(App &$a) { } -function dfrn_request_content(App &$a) { +function dfrn_request_content(App $a) { if (($a->argc != 2) || (! count($a->profile))) { return ""; @@ -762,7 +765,7 @@ function dfrn_request_content(App &$a) { } if($auto_confirm) { - require_once('mod/dfrn_confirm.php'); + require_once 'mod/dfrn_confirm.php'; $handsfree = array( 'uid' => $r[0]['uid'], 'node' => $r[0]['nickname'], @@ -810,19 +813,17 @@ function dfrn_request_content(App &$a) { // At first look if an address was provided // Otherwise take the local address - if (x($_GET,'addr') AND ($_GET['addr'] != "")) + if (x($_GET,'addr') AND ($_GET['addr'] != "")) { $myaddr = hex2bin($_GET['addr']); - elseif (x($_GET,'address') AND ($_GET['address'] != "")) + } elseif (x($_GET,'address') AND ($_GET['address'] != "")) { $myaddr = $_GET['address']; - elseif (local_user()) { + } elseif (local_user()) { if (strlen($a->path)) { $myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname']; - } - else { + } else { $myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); } - } - else { + } else { // last, try a zrl $myaddr = get_my_url(); } @@ -840,8 +841,7 @@ function dfrn_request_content(App &$a) { if ($a->profile['page-flags'] == PAGE_NORMAL) { $tpl = get_markup_template('dfrn_request.tpl'); - } - else { + } else { $tpl = get_markup_template('auto_request.tpl'); } @@ -850,10 +850,12 @@ function dfrn_request_content(App &$a) { // see if we are allowed to have NETWORK_MAIL2 contacts $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); - if(get_config('system','dfrn_only')) + + if (get_config('system','dfrn_only')) { $mail_disabled = 1; + } - if(! $mail_disabled) { + if (! $mail_disabled) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($a->profile['uid']) ); @@ -875,7 +877,7 @@ function dfrn_request_content(App &$a) { '$header' => t('Friend/Connection Request'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@identi.ca'), '$pls_answer' => t('Please answer the following:'), - '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$a->profile['name']), false, '', array(t('No'),t('Yes'))), + '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$a->profile['name']), false, '', array(t('No'), t('Yes'))), /*'$does_know' => sprintf( t('Does %s know you?'),$a->profile['name']), '$yes' => t('Yes'), '$no' => t('No'), */