3 require_once("boot.php");
7 @include(".htconfig.php");
8 require_once("dba.php");
9 $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
10 unset($db_host, $db_user, $db_pass, $db_data);
12 require_once("session.php");
13 require_once("datetime.php");
15 // FIXME - generalise for other content, probably create a notify queue in
16 // the db with type and recipient list
18 if(($argc != 3) || (! intval($argv[2])))
21 $baseurl = trim(pack("H*" , $argv[1]));
27 $recipients = array();
29 $r = q("SELECT `item`.*, `contact`.*,`item`.`id` AS `item_id` FROM `item` LEFT JOIN `contact` ON `item`.`contact-id` = `contact`.`id`
30 WHERE `item`.`id` = %d LIMIT 1",
38 $recipients[] = $item['contact-id'];
40 if($item['parent'] == $item['id']) {
44 $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
45 intval($item['parent'])
52 $recipients[] = $parent['contact-id'];
54 $r = q("SELECT `contact-id` FROM `item` WHERE `hash` = '%s' AND `id` != %d AND `id` != %d",
57 intval($item['parent'])
61 if($rr['contact-id'] != $item['contact-id'])
62 $recipients[] = $rr['contact-id'];
66 $tpl = file_get_contents('view/atomic.tpl');
68 // FIXME should dump the entire conversation
70 $atom = replace_macros($tpl, array(
71 '$feed_id' => xmlify($baseurl),
72 '$feed_title' => xmlify('Wall Item'),
73 '$feed_updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')) ,
74 '$name' => xmlify($item['name']),
75 '$profile_page' => xmlify($item['url']),
76 '$thumb' => xmlify($item['thumb']),
77 '$item_id' => xmlify($item['hash'] . '-' . $item['id']),
78 '$title' => xmlify(''),
79 '$link' => xmlify($baseurl . '/item/' . $item['id']),
80 '$updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')),
81 '$summary' => xmlify(''),
82 '$content' => xmlify($item['body'])
88 // expand list of recipients
93 $recipients = array_unique($recipients);
95 $recip_str = implode(', ', $recipients);
97 $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ",
109 if(! strlen($rr['dfrn-id']))
111 $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id'];
113 $xml = fetch_url($url);
120 $res = simplexml_load_string($xml);
124 if((intval($res->status) != 0) || (! strlen($res->challenge)) || ($res->dfrn_id != $rr['dfrn-id']))
129 $postvars['dfrn_id'] = $rr['dfrn-id'];
130 $challenge = hex2bin($res->challenge);
131 echo "dfrn-id:" . $res->dfrn_id . "\r\n";
132 echo "challenge:" . $res->challenge . "\r\n";
133 echo "pubkey:" . $rr['pubkey'] . "\r\n";
135 openssl_public_decrypt($challenge,$postvars['challenge'],$rr['pubkey']);
137 $postvars['data'] = $atom;
140 $xml = fetch_url($url,$postvars);