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
21 $baseurl = trim(hex2bin($argv[1]));
28 $item_id = intval($argv[3]);
37 $recipients = array();
39 // fetch requested item
41 $r = q("SELECT `item`.*, `contact`.*,`item`.`id` AS `item_id` FROM `item` LEFT JOIN `contact` ON `item`.`contact-id` = `contact`.`id`
42 WHERE `item`.`id` = %d LIMIT 1",
50 $recipients[] = $item['contact-id'];
52 if($item['parent'] == $item['id']) {
56 $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
57 intval($item['parent'])
64 $recipients[] = $parent['contact-id'];
66 $r = q("SELECT `contact-id` FROM `item` WHERE `hash` = '%s' AND `id` != %d AND `id` != %d",
69 intval($item['parent'])
73 if($rr['contact-id'] != $item['contact-id'])
74 $recipients[] = $rr['contact-id'];
78 $tpl = file_get_contents('view/atomic.tpl');
80 // FIXME should dump the entire conversation
82 $atom = replace_macros($tpl, array(
83 '$feed_id' => xmlify($baseurl),
84 '$feed_title' => xmlify('Wall Item'),
85 '$feed_updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')) ,
86 '$name' => xmlify($item['name']),
87 '$profile_page' => xmlify($item['url']),
88 '$thumb' => xmlify($item['thumb']),
89 '$item_id' => xmlify($item['hash'] . '-' . $item['id']),
90 '$title' => xmlify(''),
91 '$link' => xmlify($baseurl . '/item/' . $item['id']),
92 '$updated' => xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00' ,'Y-m-d\Th:i:s\Z')),
93 '$summary' => xmlify(''),
94 '$content' => xmlify($item['body'])
100 // expand list of recipients
105 $recipients = array_unique($recipients);
106 print_r($recipients);
107 $recip_str = implode(', ', $recipients);
109 $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ",
121 if(! strlen($rr['dfrn-id']))
123 $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id'];
125 $xml = fetch_url($url);
132 $res = simplexml_load_string($xml);
136 if((intval($res->status) != 0) || (! strlen($res->challenge)) || ($res->dfrn_id != $rr['dfrn-id']))
141 $postvars['dfrn_id'] = $rr['dfrn-id'];
142 $challenge = hex2bin($res->challenge);
143 echo "dfrn-id:" . $res->dfrn_id . "\r\n";
144 echo "challenge:" . $res->challenge . "\r\n";
145 echo "pubkey:" . $rr['pubkey'] . "\r\n";
147 openssl_public_decrypt($challenge,$postvars['challenge'],$rr['pubkey']);
149 $postvars['data'] = $atom;
152 $xml = fetch_url($url,$postvars);