diff options
author | Mike Macgirvin <mike@macgirvin.com> | 2010-07-04 20:45:56 -0700 |
---|---|---|
committer | Mike Macgirvin <mike@macgirvin.com> | 2010-07-04 20:45:56 -0700 |
commit | 766b31707037a82ffd9140bfe599c27f4ef01495 (patch) | |
tree | f51c239c5161c20b39a09551db81dfbb9b3608fa /mod/dfrn_notify.php | |
parent | 7c890c286012a1f125e76ca8603df6bea0b0cc80 (diff) | |
download | volse-hubzilla-766b31707037a82ffd9140bfe599c27f4ef01495.tar.gz volse-hubzilla-766b31707037a82ffd9140bfe599c27f4ef01495.tar.bz2 volse-hubzilla-766b31707037a82ffd9140bfe599c27f4ef01495.zip |
some changes
Diffstat (limited to 'mod/dfrn_notify.php')
-rw-r--r-- | mod/dfrn_notify.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php new file mode 100644 index 000000000..c078afe38 --- /dev/null +++ b/mod/dfrn_notify.php @@ -0,0 +1,77 @@ +<?php + + + + + +function dfrn_notify_post(&$a) { + + $dfrn_id = notags(trim($_POST['dfrn_id'])); + $challenge = notags(trim($_POST['challenge'])); + $data = $_POST['data']; + + $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", + dbesc($dfrn_id), + dbesc($challenge) + ); + if(! count($r)) + xml_status(3); + + $r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", + dbesc($dfrn_id), + dbesc($challenge) + ); + + + + + + + +} + + + + + + + + + + + + +function dfrn_notify_content(&$a) { + + if(x($_GET,'dfrn_id')) { + // initial communication from external contact + $hash = random_string(); + + $status = 0; + + $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); + + $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` ) + VALUES( '%s', '%s', '%s') ", + dbesc($hash), + dbesc(notags(trim($_GET['dfrn_id']))), + intval(time() + 60 ) + ); + + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1", + dbesc($_GET['dfrn_id'])); + if((! count($r)) || (! strlen($r[0]['prvkey']))) + $status = 1; + + $challenge = ''; + + openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']); + + echo '<?xml version=1.0" encoding="UTF-8"?><dfrn_notify><status>' .$status . '</status><dfrn_id>' . $_GET['dfrn_id'] . '</dfrn_id>' + . '<challenge>' . $challenge . '</challenge></dfrn_notify>' . "\r\n" ; + session_write_close(); + exit; + + } + +}
\ No newline at end of file |