From 9a6a60a9c1c7f781790849173e309ac0664d7b35 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Thu, 8 Jul 2010 07:03:25 -0700 Subject: mucho progress on notifier, email style dfrn url's --- include/Scrape.php | 24 ++++++++++++ include/main.js | 12 ++++++ include/notifier.php | 105 ++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 include/main.js (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index cc5015165..b4a5dd849 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -76,5 +76,29 @@ function validate_dfrn($a) { return $errors; }} +if(! function_exists('scrape_meta')) { +function scrape_meta($url) { + $ret = array(); + $s = fetch_url($url); + + if(! $s) + return $ret; + + $dom = HTML5_Parser::parse($s); + + if(! $dom) + return $ret; + $items = $dom->getElementsByTagName('meta'); + + // get DFRN link elements + + foreach($items as $item) { + $x = $item->getAttribute('name'); + if(substr($x,0,5) == "dfrn-") + $ret[$x] = $item->getAttribute('content'); + } + + return $ret; +}} diff --git a/include/main.js b/include/main.js new file mode 100644 index 000000000..4fb92c774 --- /dev/null +++ b/include/main.js @@ -0,0 +1,12 @@ + + function openClose(theID) { + if(document.getElementById(theID).style.display == "block") { + document.getElementById(theID).style.display = "none" + } + else { + document.getElementById(theID).style.display = "block" + } + } + function openMenu(theID) { + document.getElementById(theID).style.display = "block" + } diff --git a/include/notifier.php b/include/notifier.php index d1f26cdc2..e67ef06e3 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -1,6 +1,5 @@ $a->get_baseurl(), - '$feed_title' => 'Wall Item', - '$feed_updated' => datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z') , - '$name' => $item['name'], - '$profile_page' => $item['url'], - '$thumb' => $item['thumb'], - '$item_id' => $item['hash'] . '-' . $item['id'], - '$title' => '', - '$link' => $a->get_baseurl() . '/item/' . $item['id'], - '$updated' => datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z'), - '$summary' => '', - '$content' => $item['body'] + '$feed_id' => xmlify($baseurl), + '$feed_title' => xmlify('Wall Item'), + '$feed_updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')) , + '$name' => xmlify($item['name']), + '$profile_page' => xmlify($item['url']), + '$thumb' => xmlify($item['thumb']), + '$item_id' => xmlify($item['hash'] . '-' . $item['id']), + '$title' => xmlify(''), + '$link' => xmlify($baseurl . '/item/' . $item['id']), + '$updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')), + '$summary' => xmlify(''), + '$content' => xmlify($item['body']) )); print_r($atom); @@ -75,19 +87,60 @@ print_r($atom); // expand list of recipients - // grab the contact records +dbg(3); - // foreach recipient - // if no dfrn-id continue + $recipients = array_unique($recipients); +print_r($recipients); + $recip_str = implode(', ', $recipients); - // fetch_url dfrn-notify + $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ", + dbesc($recip_str) + ); + if(! count($r)) + killme(); - // decrypt challenge + // delivery loop - // post result + foreach($r as $rr) { + if($rr['self']) + continue; - // continue + if(! strlen($rr['dfrn-id'])) + continue; + $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id']; +print_r($url); + $xml = fetch_url($url); +echo $xml; - killme(); +print_r($xml); + if(! $xml) + continue; + + $res = simplexml_load_string($xml); +print_r($res); +var_dump($res); + + if((intval($res->status) != 0) || (! strlen($res->challenge)) || ($res->dfrn_id != $rr['dfrn-id'])) + continue; + + $postvars = array(); + + $postvars['dfrn_id'] = $rr['dfrn-id']; + $challenge = hex2bin($res->challenge); +echo "dfrn-id:" . $res->dfrn_id . "\r\n"; +echo "challenge:" . $res->challenge . "\r\n"; +echo "pubkey:" . $rr['pubkey'] . "\r\n"; + + openssl_public_decrypt($challenge,$postvars['challenge'],$rr['pubkey']); + + $postvars['data'] = $atom; + +print_r($postvars); + $xml = fetch_url($url,$postvars); + + + } + + killme(); -- cgit v1.2.3