From 0fe997490df7fbd3d108c8da931e4823b0a4b2d9 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 15:04:18 -0700 Subject: dfrn remote profile protocol revision --- mod/dfrn_poll.php | 92 +++++++++++++++++++++++++++++++++++++++++++++++----- mod/dfrn_request.php | 2 +- 2 files changed, 84 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 686a42d08..fe9504deb 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -63,7 +63,7 @@ function dfrn_poll_init(&$a) { if(count($r)) { - $s = fetch_url($r[0]['poll'] . '?f=&dfrn_id=' . $my_id . '&type=profile-check'); + $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA); @@ -92,7 +92,7 @@ function dfrn_poll_init(&$a) { } - if($type === 'profile-check') { + if($type === 'profile-check' && $dfrn_version < 2.2 ) { if((strlen($challenge)) && (strlen($sec))) { @@ -182,8 +182,69 @@ function dfrn_poll_post(&$a) { $dfrn_id = ((x($_POST,'dfrn_id')) ? $_POST['dfrn_id'] : ''); $challenge = ((x($_POST,'challenge')) ? $_POST['challenge'] : ''); $url = ((x($_POST,'url')) ? $_POST['url'] : ''); + $sec = ((x($_POST,'sec')) ? $_POST['sec'] : ''); + $ptype = ((x($_POST,'type')) ? $_POST['type'] : ''); $dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0); + if($ptype === 'profile-check') { + + if((strlen($challenge)) && (strlen($sec))) { + + logger('dfrn_poll: POST: profile-check'); + + q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); + $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", + dbesc($sec) + ); + if(! count($r)) { + xml_status(3, 'No ticket'); + // NOTREACHED + } + $orig_id = $r[0]['dfrn_id']; + if(strpos($orig_id, ':')) + $orig_id = substr($orig_id,2); + + $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", + intval($r[0]['cid']) + ); + if(! count($c)) { + xml_status(3, 'No profile'); + } + $contact = $c[0]; + + $sent_dfrn_id = hex2bin($dfrn_id); + $challenge = hex2bin($challenge); + + $final_dfrn_id = ''; + + if(($contact['duplex']) && strlen($contact['prvkey'])) { + openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); + openssl_private_decrypt($challenge,$decoded_challenge,$contact['prvkey']); + } + else { + openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); + openssl_public_decrypt($challenge,$decoded_challenge,$contact['pubkey']); + } + + $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); + + if(strpos($final_dfrn_id,':') == 1) + $final_dfrn_id = substr($final_dfrn_id,2); + + if($final_dfrn_id != $orig_id) { + logger('profile_check: ' . $final_dfrn_id . ' != ' . $orig_id, LOGGER_DEBUG); + // did not decode properly - cannot trust this site + xml_status(3, 'Bad decryption'); + } + + header("Content-type: text/xml"); + echo "0$decoded_challenge$sec"; + killme(); + // NOTREACHED + } + + } + $direction = (-1); if(strpos($dfrn_id,':') == 1) { $direction = intval(substr($dfrn_id,0,1)); @@ -365,13 +426,26 @@ function dfrn_poll_content(&$a) { if(($type === 'profile') && (strlen($sec))) { // URL reply - $s = fetch_url($r[0]['poll'] - . '?f=&dfrn_id=' . $encrypted_id - . '&type=profile-check' - . '&dfrn_version=' . DFRN_PROTOCOL_VERSION - . '&challenge=' . $challenge - . '&sec=' . $sec - ); + + + if($dfrn_version < 2.2) { + $s = fetch_url($r[0]['poll'] + . '?dfrn_id=' . $encrypted_id + . '&type=profile-check' + . '&dfrn_version=' . DFRN_PROTOCOL_VERSION + . '&challenge=' . $challenge + . '&sec=' . $sec + ); + } + else { + $s = post_url($r[0]['poll'], array( + 'dfrn_id' => $encrypted_id, + 'type' => 'profile-check', + 'dfrn_version' => DFRN_PROTOCOL_VERSION, + 'challenge' => $challenge, + 'sec' => $sec + )); + } logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index cc6355078..3cd8473cf 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -172,7 +172,7 @@ function dfrn_request_post(&$a) { $dfrn_request = $contact_record['request']; if(strlen($dfrn_request) && strlen($confirm_key)) - $s = fetch_url($dfrn_request . '?f=&confirm_key=' . $confirm_key); + $s = fetch_url($dfrn_request . '?confirm_key=' . $confirm_key); // (ignore reply, nothing we can do it failed) -- cgit v1.2.3 From 75ad3219e67b803bebf028b69d59f26c44571b3d Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 17:50:18 -0700 Subject: remote deletion - check contact-id --- mod/dfrn_notify.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 2cc5a62f3..cd67df1d7 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -262,10 +262,13 @@ function dfrn_notify_post(&$a) { $when = datetime_convert('UTC','UTC','now','Y-m-d H:i:s'); } if($deleted) { - $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + + $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `contact-id` = %d LIMIT 1", dbesc($uri), - intval($importer['importer_uid']) + intval($importer['importer_uid']), + intval($importer['id']) ); + if(count($r)) { $item = $r[0]; -- cgit v1.2.3 From d728961cbf5ce3de7de65e37c900666e0f9f7358 Mon Sep 17 00:00:00 2001 From: Friendika Date: Thu, 31 Mar 2011 14:46:16 -0700 Subject: translateable time formats (PM & birthdays) --- mod/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/message.php b/mod/message.php index 9d30abd66..7978ecaf2 100644 --- a/mod/message.php +++ b/mod/message.php @@ -235,7 +235,7 @@ function message_content(&$a) { '$delete' => t('Delete conversation'), '$body' => $rr['body'], '$to_name' => $rr['name'], - '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'],'D, d M Y - g:i A') + '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')) )); } $o .= paginate($a); -- cgit v1.2.3 From e33b6e0b5a1f444786d00a2666be1b23dc659c8a Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Apr 2011 00:59:10 -0700 Subject: redirect to symbolic rather than absolute URL locations --- mod/dfrn_poll.php | 18 ++++++++++++++++-- mod/redir.php | 5 +++-- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index fe9504deb..82ad70907 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -447,6 +447,19 @@ function dfrn_poll_content(&$a) { )); } + switch($destination_url) { + case 'profile': + $dest = $a->get_baseurl() . '/profile/' . $profile . '?tab=profile'; + break; + case 'photos': + $dest = $a->get_baseurl() . '/photos/' . $profile; + break; + case 'status': + default: + $dest = $a->get_baseurl() . '/profile/' . $profile; + break; + } + logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); if(strlen($s) && strstr($s,'get_baseurl() . '/profile/' . $profile); + + goaway($dest); } - goaway($a->get_baseurl()); + goaway($dest); // NOTREACHED } diff --git a/mod/redir.php b/mod/redir.php index ac21aa17e..8d0c8f4b3 100644 --- a/mod/redir.php +++ b/mod/redir.php @@ -5,6 +5,7 @@ function redir_init(&$a) { if((! local_user()) || (! ($a->argc == 2)) || (! intval($a->argv[1]))) goaway($a->get_baseurl()); $cid = $a->argv[1]; + $url = ((x($_GET,'url')) ? $_GET['url'] : ''); $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($cid), @@ -37,8 +38,8 @@ function redir_init(&$a) { ); logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG); - + $dest = (($url) ? '&destination_url=' . $url : ''); goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id - . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec); + . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest ); } -- cgit v1.2.3 From 4b356e59ec36a2a2ef1a0224ecf86254090466e3 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 1 Apr 2011 14:39:09 -0700 Subject: allow other destinations according to protocol --- mod/dfrn_poll.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 82ad70907..25b28c63c 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -424,9 +424,8 @@ function dfrn_poll_content(&$a) { } if(($type === 'profile') && (strlen($sec))) { - // URL reply - + // URL reply if($dfrn_version < 2.2) { $s = fetch_url($r[0]['poll'] @@ -455,9 +454,12 @@ function dfrn_poll_content(&$a) { $dest = $a->get_baseurl() . '/photos/' . $profile; break; case 'status': - default: + case '': $dest = $a->get_baseurl() . '/profile/' . $profile; break; + default: + $dest = $destination_url; + break; } logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); -- cgit v1.2.3 From 9b50b0e16f2046b91cb4c734c56024524d8b178b Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 3 Apr 2011 20:41:40 -0700 Subject: Public exposure warning on affected network group pages. config-able so a plugin can shut it up. --- mod/network.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mod') diff --git a/mod/network.php b/mod/network.php index 39679b48a..a304c211f 100644 --- a/mod/network.php +++ b/mod/network.php @@ -54,6 +54,14 @@ function network_content(&$a, $update = 0) { } if(! $update) { + if(group) { + if(($t = group_public_members($group)) && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { + $plural_form = sprintf( tt('%d member', '%d members', $t), $t); + notice( sprintf( t('Warning: This group contains %s from an insecure network.'), $plural_form ) . EOL); + notice( t('Private messages to this group are at risk of public disclosure.') . EOL); + } + } + $o .= ''; $_SESSION['return_url'] = $a->cmd; -- cgit v1.2.3