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 `body`, `guid`, `contact-id`, `private`, `created`, `app` FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') 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"]);
42 $nodename = "status_message";
43 $post["raw_message"] = str_replace("&", "&", bb2diaspora($item[0]["body"]));
44 $post["guid"] = $item[0]["guid"];
45 $post["diaspora_handle"] = diaspora_handle_from_contact($item[0]["contact-id"]);
46 $post["public"] = (!$item[0]["private"] ? 'true':'false');
47 $post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
48 $post["provider_display_name"] = $item[0]["app"];
51 $dom = new DOMDocument("1.0");
52 $root = $dom->createElement("XML");
53 $dom->appendChild($root);
54 $postelement = $dom->createElement("post");
55 $root->appendChild($postelement);
56 $statuselement = $dom->createElement($nodename);
57 $postelement->appendChild($statuselement);
59 foreach($post AS $index => $value) {
60 $postnode = $dom->createElement($index, $value);
61 $statuselement->appendChild($postnode);
64 header("Content-Type: application/xml; charset=utf-8");
65 $xml = $dom->saveXML();
67 // Diaspora doesn't send the XML header, so we remove them as well.
68 // So we avoid possible compatibility problems.
69 if (substr($xml, 0, 21) == '<?xml version="1.0"?>')
70 $xml = trim(substr($xml, 21));