aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/dfrn_notify.php7
-rw-r--r--mod/dfrn_poll.php112
-rw-r--r--mod/dfrn_request.php2
-rw-r--r--mod/message.php2
-rw-r--r--mod/network.php8
-rw-r--r--mod/redir.php5
6 files changed, 119 insertions, 17 deletions
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];
diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php
index 686a42d08..25b28c63c 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 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><dfrn_poll><status>0</status><challenge>$decoded_challenge</challenge><sec>$sec</sec></dfrn_poll>";
+ killme();
+ // NOTREACHED
+ }
+
+ }
+
$direction = (-1);
if(strpos($dfrn_id,':') == 1) {
$direction = intval(substr($dfrn_id,0,1));
@@ -363,15 +424,43 @@ 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
+ ));
+ }
+
+ 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':
+ case '':
+ $dest = $a->get_baseurl() . '/profile/' . $profile;
+ break;
+ default:
+ $dest = $destination_url;
+ break;
+ }
logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA);
@@ -399,9 +488,10 @@ function dfrn_poll_content(&$a) {
);
}
$profile = $r[0]['nickname'];
- goaway((strlen($destination_url)) ? $destination_url : $a->get_baseurl() . '/profile/' . $profile);
+
+ goaway($dest);
}
- goaway($a->get_baseurl());
+ goaway($dest);
// NOTREACHED
}
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)
diff --git a/mod/message.php b/mod/message.php
index da35e1896..7f17a362b 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -237,7 +237,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);
diff --git a/mod/network.php b/mod/network.php
index 13ce81abc..42c6c0c29 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 .= '<script> $(document).ready(function() { $(\'#nav-network-link\').addClass(\'nav-selected\'); });</script>';
$_SESSION['return_url'] = $a->cmd;
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 );
}