3 This file is part of the Diaspora protocol. It is used for fetching single public posts.
5 require_once("include/diaspora.php");
9 header($_SERVER["SERVER_PROTOCOL"].' 510 '.t('Not Extended'));
15 if (strtolower(substr($guid, -4)) != ".xml") {
16 header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
20 $guid = strtolower(substr($guid, 0, -4));
22 $item = q("SELECT `title`, `body`, `guid`, `contact-id`, `private`, `created`, `app` FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
23 dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
25 header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
31 $reshared = diaspora::is_reshare($item[0]["body"]);
34 $nodename = "reshare";
35 $post["root_diaspora_id"] = $reshared["root_handle"];
36 $post["root_guid"] = $reshared["root_guid"];
37 $post["guid"] = $item[0]["guid"];
38 $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
39 $post["public"] = (!$item[0]["private"] ? 'true':'false');
40 $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
43 $body = bb2diaspora($item[0]["body"]);
45 if(strlen($item[0]["title"]))
46 $body = "## ".html_entity_decode($item[0]["title"])."\n\n".$body;
48 $nodename = "status_message";
49 $post["raw_message"] = str_replace("&", "&", $body);
50 $post["guid"] = $item[0]["guid"];
51 $post["diaspora_handle"] = diaspora::handle_from_contact($item[0]["contact-id"]);
52 $post["public"] = (!$item[0]["private"] ? 'true':'false');
53 $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
54 $post["provider_display_name"] = $item[0]["app"];
57 $dom = new DOMDocument("1.0");
58 $root = $dom->createElement("XML");
59 $dom->appendChild($root);
60 $postelement = $dom->createElement("post");
61 $root->appendChild($postelement);
62 $statuselement = $dom->createElement($nodename);
63 $postelement->appendChild($statuselement);
65 foreach($post AS $index => $value) {
66 $postnode = $dom->createElement($index, $value);
67 $statuselement->appendChild($postnode);
70 header("Content-Type: application/xml; charset=utf-8");
71 $xml = $dom->saveXML();
73 // Diaspora doesn't send the XML header, so we remove them as well.
74 // So we avoid possible compatibility problems.
75 if (substr($xml, 0, 21) == '<?xml version="1.0"?>')
76 $xml = trim(substr($xml, 21));