diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Scrape.php | 20 | ||||
-rw-r--r-- | include/html2bbcode.php | 4 | ||||
-rw-r--r-- | include/items.php | 36 | ||||
-rw-r--r-- | include/poller.php | 10 |
4 files changed, 52 insertions, 18 deletions
diff --git a/include/Scrape.php b/include/Scrape.php index bb42c3bdd..ff9899252 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -8,12 +8,18 @@ function scrape_dfrn($url) { $a = get_app(); $ret = array(); + + logger('scrape_dfrn: url=' . $url); + $s = fetch_url($url); if(! $s) return $ret; $headers = $a->get_curl_headers(); + logger('scrape_dfrn: headers=' . $headers, LOGGER_DEBUG); + + $lines = explode("\n",$headers); if(count($lines)) { foreach($lines as $line) { @@ -93,12 +99,17 @@ function scrape_meta($url) { $a = get_app(); $ret = array(); + + logger('scrape_meta: url=' . $url); + $s = fetch_url($url); if(! $s) return $ret; $headers = $a->get_curl_headers(); + logger('scrape_meta: headers=' . $headers, LOGGER_DEBUG); + $lines = explode("\n",$headers); if(count($lines)) { foreach($lines as $line) { @@ -135,6 +146,9 @@ function scrape_vcard($url) { $a = get_app(); $ret = array(); + + logger('scrape_vcard: url=' . $url); + $s = fetch_url($url); if(! $s) @@ -190,15 +204,17 @@ function scrape_feed($url) { return $ret; $headers = $a->get_curl_headers(); + logger('scrape_feed: headers=' . $headers, LOGGER_DEBUG); + $lines = explode("\n",$headers); if(count($lines)) { foreach($lines as $line) { if(stristr($line,'content-type:')) { - if(stristr($line,'application/atom+xml')) { + if(stristr($line,'application/atom+xml') || stristr($s,'<feed')) { $ret['feed_atom'] = $url; return $ret; } - if(stristr($line,'application/rss+xml')) { + if(stristr($line,'application/rss+xml') || stristr($s,'<rss')) { $ret['feed_rss'] = $url; return ret; } 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(.*?)\>(.*?)\<\/div\>/is', '/\<br(.*?)\>/is', '/\<strong\>(.*?)\<\/strong\>/is', - '/\<a href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is', + '/\<a (.*?)href=\"(.*?)\"(.*?)\>(.*?)\<\/a\>/is', '/\<code\>(.*?)\<\/code\>/is', '/\<span style=\"color:(.*?)\"\>(.*?)\<\/span\>/is', '/\<blockquote\>(.*?)\<\/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]', diff --git a/include/items.php b/include/items.php index c29ad9e44..a3078e39c 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']); @@ -800,6 +800,12 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $xml) return 3; + if(strpos($xml,'<?xml') === false) { + logger('dfrn_deliver: no valid XML returned'); + logger('dfrn_deliver: returned XML: ' . $xml, LOGGER_DATA); + return 3; + } + $res = simplexml_load_string($xml); if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) @@ -808,19 +814,20 @@ 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']); - } - else { + 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']); + } $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); @@ -854,11 +861,22 @@ 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($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_public_encrypt($key,$postvars['key'],$contact['pubkey']); + 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/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']) { |