3 require_once('simplepie/simplepie.inc');
7 function dfrn_notify_post(&$a) {
9 $dfrn_id = notags(trim($_POST['dfrn_id']));
10 $challenge = notags(trim($_POST['challenge']));
11 $data = $_POST['data'];
13 $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
20 $r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
25 $feed = new SimplePie();
26 $feed->set_raw_data($data);
29 echo "Feed title:" . $feed->get_title();
31 foreach ($feed->get_items() as $item) {
33 echo $item->get_permalink();
34 echo $item->get_content();
54 function dfrn_notify_content(&$a) {
56 if(x($_GET,'dfrn_id')) {
57 // initial communication from external contact
58 $hash = random_string();
62 $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time()));
64 $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` )
65 VALUES( '%s', '%s', '%s') ",
67 dbesc(notags(trim($_GET['dfrn_id']))),
71 $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1",
72 dbesc($_GET['dfrn_id']));
73 if((! count($r)) || (! strlen($r[0]['prvkey'])))
78 openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']);
79 $challenge = bin2hex($challenge);
80 echo '<?xml version="1.0" encoding="UTF-8"?><dfrn_notify><status>' .$status . '</status><dfrn_id>' . $_GET['dfrn_id'] . '</dfrn_id>'
81 . '<challenge>' . $challenge . '</challenge></dfrn_notify>' . "\r\n" ;
82 session_write_close();