aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-08-13 16:39:59 -0700
committerFriendika <info@friendika.com>2011-08-13 16:39:59 -0700
commit4b4ff75b7273194d2bea2b39ff878835738cd2b1 (patch)
tree1894a570e48a8ca1850c0843ae28c81b4510fa5d /include
parentc9225a691b8e54c85f2f12f1d37ff4c2aa12e139 (diff)
downloadvolse-hubzilla-4b4ff75b7273194d2bea2b39ff878835738cd2b1.tar.gz
volse-hubzilla-4b4ff75b7273194d2bea2b39ff878835738cd2b1.tar.bz2
volse-hubzilla-4b4ff75b7273194d2bea2b39ff878835738cd2b1.zip
basic post message from diaspora (untested)
Diffstat (limited to 'include')
-rw-r--r--include/diaspora.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 90fa09b25..847bec73d 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -319,6 +319,79 @@ function diaspora_request($importer,$contact,$xml) {
function diaspora_post($importer,$contact,$xml) {
+ $guid = notags(unxmlify($xml->guid));
+ $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+ $message_id = $diaspora_handle . ':' . $guid;
+ $r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `guid` = '%s' LIMIT 1",
+ intval($importer['uid']),
+ dbesc($message_id),
+ dbesc($guid)
+ );
+ if(count($r))
+ return;
+
+ $owner = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+ intval($importer['uid'])
+ );
+ if(! count($owner))
+ return;
+
+ $created = unxmlify($xml->created_at);
+ $private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
+
+ $body = unxmlify($xml->raw_message);
+
+ require_once('library/HTMLPurifier.auto.php');
+ require_once('include/html2bbcode.php');
+
+ $maxlen = get_max_import_size();
+ if($maxlen && (strlen($body) > $maxlen))
+ $body = substr($body,0, $maxlen);
+
+ if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
+
+ $body = preg_replace('#<object[^>]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?</object>#s',
+ '[youtube]$1[/youtube]', $body);
+
+ $body = preg_replace('#<iframe[^>].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?</iframe>#s',
+ '[youtube]$1[/youtube]', $body);
+
+ $body = oembed_html2bbcode($body);
+
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('Cache.DefinitionImpl', null);
+
+ // we shouldn't need a whitelist, because the bbcode converter
+ // will strip out any unsupported tags.
+ // $config->set('HTML.Allowed', 'p,b,a[href],i');
+
+ $purifier = new HTMLPurifier($config);
+ $body = $purifier->purify($body);
+
+ $body = html2bbcode($body);
+ }
+
+ $datarray = array();
+ $datarray['uid'] = $importer['uid'];
+ $datarray['contact-id'] = $contact['id'];
+ $datarray['wall'] = 0;
+ $datarray['guid'] = $guid;
+ $datarray['uri'] = $message_id;
+ $dattarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
+ $dattarray['private'] = $private;
+ $dattarray['parent'] = 0;
+ $datarray['owner-name'] = $owner[0]['name'];
+ $datarray['owner-link'] = $owner[0]['url'];
+ $datarray['owner-avatar'] = $owner[0]['thumb'];
+ $datarray['author-name'] = $contact['name'];
+ $datarray['author-link'] = $contact['url'];
+ $datarray['author-avatar'] = $contact['thumb'];
+
+ item_store($datarray);
+
+ return;
+
+
}
function diaspora_comment($importer,$contact,$xml) {