diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Scrape.php | 48 | ||||
-rw-r--r-- | include/auth.php | 3 | ||||
-rw-r--r-- | include/salmon.php | 13 |
3 files changed, 50 insertions, 14 deletions
diff --git a/include/Scrape.php b/include/Scrape.php index 0272dde12..10ec54d13 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -2,15 +2,6 @@ require_once('library/HTML5/Parser.php'); -if(! function_exists('attribute_contains')) { -function attribute_contains($attr,$s) { - $a = explode(' ', $attr); - if(count($a) && in_array($s,$a)) - return true; - return false; -}} - - if(! function_exists('scrape_dfrn')) { function scrape_dfrn($url) { @@ -53,7 +44,7 @@ function scrape_dfrn($url) { $ret['photo'] = $x->getAttribute('src'); if(attribute_contains($x->getAttribute('class'),'key')) $ret['key'] = $x->textContent; - } + } } } @@ -107,3 +98,40 @@ function scrape_meta($url) { return $ret; }} + + +if(! function_exists('scrape_vcard')) { +function scrape_vcard($url) { + + $ret = array(); + $s = fetch_url($url); + + if(! $s) + return $ret; + + $dom = HTML5_Parser::parse($s); + + if(! $dom) + return $ret; + + // Pull out hCard profile elements + + $items = $dom->getElementsByTagName('*'); + foreach($items as $item) { + if(attribute_contains($item->getAttribute('class'), 'vcard')) { + $level2 = $item->getElementsByTagName('*'); + foreach($level2 as $x) { + if(attribute_contains($x->getAttribute('class'),'fn')) + $ret['fn'] = $x->textContent; + if((attribute_contains($x->getAttribute('class'),'photo')) + || (attribute_contains($x->getAttribute('class'),'avatar'))) + $ret['photo'] = $x->getAttribute('src'); + if((attribute_contains($x->getAttribute('class'),'nickname')) + || (attribute_contains($x->getAttribute('class'),'uid'))) + $ret['nick'] = $x->textContent; + } + } + } + + return $ret; +}} diff --git a/include/auth.php b/include/auth.php index 7e04cb2e7..a54b24f08 100644 --- a/include/auth.php +++ b/include/auth.php @@ -41,7 +41,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] === 'login'))) { $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $a->user['nickname']; - $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { $a->contact = $r[0]; @@ -91,6 +91,7 @@ else { $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { + $a->contact = $r[0]; $a->cid = $r[0]['id']; $_SESSION['cid'] = $a->cid; } diff --git a/include/salmon.php b/include/salmon.php index c5ad3e825..7f4c32265 100644 --- a/include/salmon.php +++ b/include/salmon.php @@ -105,7 +105,8 @@ $namespaces = <<< EOT xmlns:media="http://purl.org/syndication/atommedia" xmlns:dfrn="http://purl.org/macgirvin/dfrn/1.0" xmlns:as="http://activitystrea.ms/spec/1.0/" - xmlns:georss="http://www.georss.org/georss" > + xmlns:georss="http://www.georss.org/georss" + xmlns:poco="http://portablecontacts.net/spec/1.0" > EOT; $slap = str_replace('<entry>',$namespaces,$slap); @@ -129,7 +130,7 @@ EOT; $rsa->setHash('sha256'); $rsa->loadKey($owner['sprvkey']); - $signature = $rsa->sign($data); + $signature = base64url_encode($rsa->sign($data)); $salmon_tpl = load_view_file('view/magicsig.tpl'); $salmon = replace_macros($salmon_tpl,array( @@ -141,7 +142,13 @@ EOT; )); // slap them - post_url($contact['notify'],$salmon); + post_url($contact['notify'],$salmon, array( + 'Content-type: application/magic-envelope+xml', + 'Content-length: ' . strlen($salmon) + )); + $a = get_app(); + echo "CURL returned: " . $a->get_curl_code() . "\n"; + return; }
\ No newline at end of file |