From a347d040f0307650a01c71c06b5f490179421ba1 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 1 Feb 2011 21:21:47 -0800 Subject: [PATCH 1/8] protocol reversal, roll dfrn_version to 2.1 --- boot.php | 4 ++-- include/items.php | 35 +++++++++++++++++++++++++---------- mod/dfrn_notify.php | 28 ++++++++++++++++++---------- 3 files changed, 45 insertions(+), 22 deletions(-) diff --git a/boot.php b/boot.php index 6bd82bb08..e47f1834d 100644 --- a/boot.php +++ b/boot.php @@ -3,8 +3,8 @@ set_time_limit(0); define ( 'BUILD_ID', 1034 ); -define ( 'FRIENDIKA_VERSION', '2.10.0902' ); -define ( 'DFRN_PROTOCOL_VERSION', '2.0' ); +define ( 'FRIENDIKA_VERSION', '2.10.0903' ); +define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/items.php b/include/items.php index c29ad9e44..f909fde6a 100644 --- a/include/items.php +++ b/include/items.php @@ -768,7 +768,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $a = get_app(); - if((! strlen($contact['dfrn-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY))) + if((! strlen($contact['issued-id'])) && (! $contact['duplex']) && (! ($owner['page-flags'] == PAGE_COMMUNITY))) return 3; $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']); @@ -808,20 +808,33 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $postvars = array(); $sent_dfrn_id = hex2bin((string) $res->dfrn_id); $challenge = hex2bin((string) $res->challenge); + $dfrn_version = (float) (($res->dfrn_version) ? $res->dfrn_version : 2.0); $rino_allowed = ((intval($res->rino) === 1) ? 1 : 0); $final_dfrn_id = ''; - - if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { - openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); - openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); + if($dfrn_version > 2.1) { + if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); + openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); + } + else { + openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); + openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); + } } else { - openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); - openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); + if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); + openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); + } + else { + openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); + openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); + } } + $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); if(strpos($final_dfrn_id,':') == 1) @@ -854,11 +867,13 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $postvars['data'] = $data; logger('rino: sent key = ' . $key); - if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { - openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); + + + if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); } else { - openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); + openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); } logger('md5 rawkey ' . md5($postvars['key'])); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index f904b06bc..1eb2ff725 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -52,8 +52,6 @@ function dfrn_notify_post(&$a) { } - - $r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`, `contact`.`pubkey` AS `cpubkey`, `contact`.`prvkey` AS `cprvkey`, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` @@ -93,11 +91,21 @@ function dfrn_notify_post(&$a) { logger('rino: md5 raw key: ' . md5($rawkey)); $final_key = ''; - if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) { - openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']); + if($dfrn_version > 2.1) { + if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { + openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); + } + else { + openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']); + } } else { - openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); + if((($importer['duplex']) && strlen($importer['cpubkey'])) || (! strlen($importer['cprvkey']))) { + openssl_public_decrypt($rawkey,$final_key,$importer['cpubkey']); + } + else { + openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); + } } logger('rino: received key : ' . $final_key); @@ -498,14 +506,14 @@ function dfrn_notify_content(&$a) { $encrypted_id = ''; $id_str = $my_id . '.' . mt_rand(1000,9999); - if((($r[0]['duplex']) && strlen($r[0]['pubkey'])) || (! strlen($r[0]['prvkey']))) { - openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']); - openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']); - } - else { + if((($r[0]['duplex']) && strlen($r[0]['prvkey'])) || (! strlen($r[0]['pubkey']))) { openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']); openssl_private_encrypt($id_str,$encrypted_id,$r[0]['prvkey']); } + else { + openssl_public_encrypt($hash,$challenge,$r[0]['pubkey']); + openssl_public_encrypt($id_str,$encrypted_id,$r[0]['pubkey']); + } $challenge = bin2hex($challenge); $encrypted_id = bin2hex($encrypted_id); From fce9988f73ee8ad3624586e6866a68a2ae952ef8 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 1 Feb 2011 22:45:46 -0800 Subject: [PATCH 2/8] backward compatibility --- include/items.php | 41 +++++++++++++++++++---------------------- mod/dfrn_notify.php | 2 +- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/include/items.php b/include/items.php index f909fde6a..0c9d54a33 100644 --- a/include/items.php +++ b/include/items.php @@ -813,28 +813,16 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $final_dfrn_id = ''; - if($dfrn_version > 2.1) { - if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { - openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); - openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); - } - else { - openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); - openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); - } + + if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); + openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); } else { - if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { - openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); - openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); - } - else { - openssl_public_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['pubkey']); - openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); - } + openssl_private_decrypt($sent_dfrn_id,$final_dfrn_id,$contact['prvkey']); + openssl_private_decrypt($challenge,$postvars['challenge'],$contact['prvkey']); } - $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); if(strpos($final_dfrn_id,':') == 1) @@ -868,12 +856,21 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { logger('rino: sent key = ' . $key); - - if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { - openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); + if($dfrn_version >= 2.1) { + if(($contact['duplex'] && strlen($contact['pubkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); + } + else { + openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); + } } else { - openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); + if(($contact['duplex'] && strlen($contact['prvkey'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { + openssl_private_encrypt($key,$postvars['key'],$contact['prvkey']); + } + else { + openssl_public_encrypt($key,$postvars['key'],$contact['pubkey']); + } } logger('md5 rawkey ' . md5($postvars['key'])); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 1eb2ff725..cad7f9563 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -91,7 +91,7 @@ function dfrn_notify_post(&$a) { logger('rino: md5 raw key: ' . md5($rawkey)); $final_key = ''; - if($dfrn_version > 2.1) { + if($dfrn_version >= 2.1) { if((($importer['duplex']) && strlen($importer['cprvkey'])) || (! strlen($importer['cpubkey']))) { openssl_private_decrypt($rawkey,$final_key,$importer['cprvkey']); } From ee45dee9324be48cd87a883405bdd9e11e3f39f5 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 2 Feb 2011 14:48:27 -0800 Subject: [PATCH 3/8] suppress some scraping errors when confronted with hybrid/strange feeds that provide insufficient content-type and choke the html parser. --- boot.php | 3 +++ include/Scrape.php | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index e47f1834d..0dd507168 100644 --- a/boot.php +++ b/boot.php @@ -1366,6 +1366,7 @@ function lrdd($uri) { else { $html = fetch_url($uri); $headers = $a->get_curl_headers(); + logger('lrdd: headers=' . $headers, LOGGER_DEBUG); $lines = explode("\n",$headers); if(count($lines)) { foreach($lines as $line) { @@ -1377,6 +1378,8 @@ function lrdd($uri) { // don't try and run feeds through the html5 parser if(stristr($line,'content-type:') && ((stristr($line,'application/atom+xml')) || (stristr($line,'application/rss+xml')))) return array(); + if(stristr($html,' Date: Wed, 2 Feb 2011 16:51:55 -0800 Subject: [PATCH 4/8] string update, allow js_upload file selection text to be localised --- addon/js_upload/js_upload.php | 21 +++++++++++++++++++++ util/strings.php | 12 ++++++++++++ 2 files changed, 33 insertions(+) diff --git a/addon/js_upload/js_upload.php b/addon/js_upload/js_upload.php index dc2dc37dc..9f3fa9600 100644 --- a/addon/js_upload/js_upload.php +++ b/addon/js_upload/js_upload.php @@ -36,6 +36,11 @@ function js_upload_form(&$a,&$b) { $b['addon_text'] .= ''; $b['addon_text'] .= ''; + $upload_msg = t('Upload a file'); + $drop_msg = t('Drop files here to upload'); + $cancel = t('Cancel'); + $failed = t('Failed'); + $b['addon_text'] .= <<< EOT
@@ -65,6 +70,22 @@ function createUploader() { uploader = new qq.FileUploader({ element: document.getElementById('file-uploader-demo1'), action: '{$b['post_url']}', + + template: '
' + + '
$drop_msg
' + + '
$upload_msg
' + + '
    ' + + '
    ', + + // template for one item in file list + fileTemplate: '
  • ' + + '' + + '' + + '' + + '$cancel' + + '$failed' + + '
  • ', + debug: true, onSubmit: function(id,filename) { diff --git a/util/strings.php b/util/strings.php index 5233c5619..3b12c0e54 100644 --- a/util/strings.php +++ b/util/strings.php @@ -84,6 +84,7 @@ $a->strings['Delete contact'] = 'Delete contact'; $a->strings['Last updated: '] = 'Last updated: '; $a->strings['Update public posts: '] = 'Update public posts: '; $a->strings['Never'] = 'Never'; +$a->strings['Update now'] = 'Update now'; $a->strings['Unblock this contact'] = 'Unblock this contact'; $a->strings['Block this contact'] = 'Block this contact'; $a->strings['Unignore this contact'] = 'Unignore this contact'; @@ -219,6 +220,11 @@ $a->strings['Empty post discarded.'] = 'Empty post discarded.'; $a->strings['Wall Photos'] = 'Wall Photos'; $a->strings[" commented on your item at "] = " commented on your item at "; $a->strings[" posted on your profile wall at "] = " posted on your profile wall at "; +$a->strings['This message was sent to you by '] = 'This message was sent to you by '; +$a->strings[', a member of the Friendika social network.'] = ', a member of the Friendika social network.'; +$a->strings['You may visit them online at'] = 'You may visit them online at'; +$a->strings['Please contact the sender by replying to this post if you do not wish to receive these messages.'] = 'Please contact the sender by replying to this post if you do not wish to receive these messages.'; +$a->strings['posted an update.'] = 'posted an update.'; $a->strings['photo'] = 'photo'; $a->strings['status'] = 'status'; $a->strings['likes'] = 'likes'; @@ -251,6 +257,8 @@ $a->strings['Delete message'] = 'Delete message'; $a->strings['Send Reply'] = 'Send Reply'; $a->strings['Normal View'] = 'Normal View'; $a->strings['New Item View'] = 'New Item View'; +$a->strings['CC: email addresses'] = 'CC: email addresses'; +$a->strings['Example: bob@example.com, mary@example.com'] = 'Example: bob@example.com, mary@example.com'; $a->strings['No such group'] = 'No such group'; $a->strings['Group is empty'] = 'Group is empty'; $a->strings['Group: '] = 'Group: '; @@ -411,6 +419,7 @@ $a->strings['Network'] = 'Network'; $a->strings['Notifications'] = 'Notifications'; $a->strings['Settings'] = 'Settings'; $a->strings['Profiles'] = 'Profiles'; +$a->strings['Embedding disabled'] = 'Embedding disabled'; $a->strings['Male'] = 'Male'; $a->strings['Female'] = 'Female'; $a->strings['Currently Male'] = 'Currently Male'; @@ -467,6 +476,9 @@ $a->strings['Ask me'] = 'Ask me'; $a->strings['Facebook status update failed.'] = 'Facebook status update failed.'; $a->strings['Select files to upload: '] = 'Select files to upload: '; $a->strings['Use the following controls only if the Java uploader [above] fails to launch.'] = 'Use the following controls only if the Java uploader [above] fails to launch.'; +$a->strings['Upload a file'] = 'Upload a file'; +$a->strings['Drop files here to upload'] = 'Drop files here to upload'; +$a->strings['Failed'] = 'Failed'; $a->strings['No files were uploaded.'] = 'No files were uploaded.'; $a->strings['Uploaded file is empty'] = 'Uploaded file is empty'; $a->strings['Uploaded file is too large'] = 'Uploaded file is too large'; From 1a18f4bcdee4084ef132b652188ae283cc187535 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 2 Feb 2011 17:32:25 -0800 Subject: [PATCH 5/8] get media-rss thumbnail if available and nothing else was found (e.g. github). --- mod/follow.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mod/follow.php b/mod/follow.php index c5f6d9e3f..8c1dc348f 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -113,10 +113,16 @@ function follow_post(&$a) { $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); $email = $author->get_email(); } + if(! $vcard['photo']) { + $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/','thumbnail'); + if($rawmedia && $rawmedia[0]['attribs']['']['url']) + $vcard['photo'] = $rawmedia[0]['attribs']['']['url']; + } } } if((! $vcard['photo']) && strlen($email)) $vcard['photo'] = gravatar_img($email); + $network = 'feed'; $priority = 2; } From 25c2640c17244aeb53020df83455a14ae245e831 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 2 Feb 2011 18:09:27 -0800 Subject: [PATCH 6/8] be more forgiving about the order of link parameters in html->bb --- include/html2bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 65cbcec41..6af8df824 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -23,7 +23,7 @@ function html2bbcode($s) { '/\(.*?)\<\/div\>/is', '/\/is', '/\(.*?)\<\/strong\>/is', - '/\(.*?)\<\/a\>/is', + '/\(.*?)\<\/a\>/is', '/\(.*?)\<\/code\>/is', '/\(.*?)\<\/span\>/is', '/\(.*?)\<\/blockquote\>/is', @@ -48,7 +48,7 @@ function html2bbcode($s) { '$2', "\n", '[b]$1[/b]', - '[url=$1]$3[/url]', + '[url=$2]$4[/url]', '[code]$1[/code]', '[color="$1"]$2[/color]', '[quote]$1[/quote]', From a8cea3f30cce072e6fc3607e5cfc180b69c07387 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 2 Feb 2011 19:28:40 -0800 Subject: [PATCH 7/8] don't try to parse non-xml in dfrn_deliver --- include/items.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/items.php b/include/items.php index 0c9d54a33..a3078e39c 100644 --- a/include/items.php +++ b/include/items.php @@ -800,6 +800,12 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $xml) return 3; + if(strpos($xml,'status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) From 0a32370e32b068073010d1d6b33241867c3be4d7 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 2 Feb 2011 19:56:27 -0800 Subject: [PATCH 8/8] silence php notices about $manual_id not being defined --- include/poller.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/poller.php b/include/poller.php index 2ba285b7b..20c84990e 100644 --- a/include/poller.php +++ b/include/poller.php @@ -35,16 +35,16 @@ function poller_run($argv, $argc){ q("DELETE FROM `cache` WHERE `updated`<'%s'", dbesc(datetime_convert('UTC','UTC',"now - 30 days"))); - + $manual_id = 0; $hub_update = false; - $force = false; + $force = false; if(($argc > 1) && ($argv[1] == 'force')) $force = true; if(($argc > 1) && intval($argv[1])) { $manual_id = intval($argv[1]); - $force = true; + $force = true; } $sql_extra = (($manual_id) ? " AND `id` = $manual_id " : ""); @@ -62,8 +62,8 @@ function poller_run($argv, $argc){ foreach($contacts as $contact) { - if($manual_id) - $contact['last-update'] = '0000-00-00 00:00:00'; + if($manual_id) + $contact['last-update'] = '0000-00-00 00:00:00'; if($contact['priority'] || $contact['subhub']) {