aboutsummaryrefslogtreecommitdiffstats
path: root/mod/receive.php
diff options
context:
space:
mode:
authorPaolo T <tuscanhobbit@users.noreply.github.com>2014-08-18 18:55:18 +0200
committerPaolo T <tuscanhobbit@users.noreply.github.com>2014-08-18 18:55:18 +0200
commitb5d1c7865b14fa60c35618b4179eb3c91949a441 (patch)
tree38ddb2fcab0f4c2c3baf6917e3544148cbe1eb9e /mod/receive.php
parent3b979dd2a9f8bb8f569c234408d02dfd1e7039d7 (diff)
parentd9ff121930554aa9bcad4f4ceffeb9b5e3b83d17 (diff)
downloadvolse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.tar.gz
volse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.tar.bz2
volse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.zip
Merge pull request #1 from friendica/master
Red master has been merged
Diffstat (limited to 'mod/receive.php')
-rw-r--r--mod/receive.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/mod/receive.php b/mod/receive.php
new file mode 100644
index 000000000..c5a2dc4e0
--- /dev/null
+++ b/mod/receive.php
@@ -0,0 +1,76 @@
+<?php
+
+/**
+ * Diaspora endpoint
+ */
+
+
+//require_once('include/salmon.php');
+require_once('include/crypto.php');
+require_once('include/diaspora.php');
+
+
+function receive_post(&$a) {
+
+
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ logger('mod-diaspora: disabled');
+ http_status_exit(500);
+ }
+
+ $public = false;
+
+ if((argc() == 2) && (argv(1) === 'public')) {
+ $public = true;
+ }
+ else {
+
+ if(argc() != 3 || argv(1) !== 'users')
+ http_status_exit(500);
+
+ $guid = argv(2);
+
+ $r = q("SELECT * FROM channel left join account on account_id = channel_account_id WHERE channel_guid = '%s' AND account_flags = 0 LIMIT 1",
+ dbesc($guid)
+ );
+ if(! $r)
+ http_status_exit(500);
+
+ $importer = $r[0];
+ }
+
+ // It is an application/x-www-form-urlencoded that has been urlencoded twice.
+
+ logger('mod-diaspora: receiving post', LOGGER_DEBUG);
+
+ $xml = urldecode($_POST['xml']);
+
+ logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
+
+ if(! $xml)
+ http_status_exit(500);
+
+ logger('mod-diaspora: message is okay', LOGGER_DEBUG);
+
+ $msg = diaspora_decode($importer,$xml);
+
+ logger('mod-diaspora: decoded', LOGGER_DEBUG);
+
+ logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
+
+ if(! is_array($msg))
+ http_status_exit(500);
+
+ logger('mod-diaspora: dispatching', LOGGER_DEBUG);
+
+ $ret = 0;
+ if($public)
+ diaspora_dispatch_public($msg);
+ else
+ $ret = diaspora_dispatch($importer,$msg);
+
+ http_status_exit(($ret) ? $ret : 200);
+ // NOTREACHED
+}
+