Merge remote-tracking branch 'upstream/develop' into 1504-parse_url
This commit is contained in:
commit
e81f9c91fa
15 changed files with 22145 additions and 21802 deletions
75
mod/p.php
Normal file
75
mod/p.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
/*
|
||||
This file is part of the Diaspora protocol. It is used for fetching single public posts.
|
||||
*/
|
||||
require_once("include/diaspora.php");
|
||||
|
||||
function p_init($a){
|
||||
if ($a->argc != 2) {
|
||||
header($_SERVER["SERVER_PROTOCOL"].' 510 '.t('Not Extended'));
|
||||
killme();
|
||||
}
|
||||
|
||||
$guid = $a->argv[1];
|
||||
|
||||
if (strtolower(substr($guid, -4)) != ".xml") {
|
||||
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
|
||||
killme();
|
||||
}
|
||||
|
||||
$guid = strtolower(substr($guid, 0, -4));
|
||||
|
||||
$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",
|
||||
dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
|
||||
if (!$item) {
|
||||
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
|
||||
killme();
|
||||
}
|
||||
|
||||
$post = array();
|
||||
|
||||
$reshared = diaspora_is_reshare($item[0]["body"]);
|
||||
|
||||
if ($reshared) {
|
||||
$nodename = "reshare";
|
||||
$post["root_diaspora_id"] = $reshared["root_handle"];
|
||||
$post["root_guid"] = $reshared["root_guid"];
|
||||
$post["guid"] = $item[0]["guid"];
|
||||
$post["diaspora_handle"] = diaspora_handle_from_contact($item[0]["contact-id"]);
|
||||
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
||||
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
|
||||
} else {
|
||||
$nodename = "status_message";
|
||||
$post["raw_message"] = str_replace("&", "&", bb2diaspora($item[0]["body"]));
|
||||
$post["guid"] = $item[0]["guid"];
|
||||
$post["diaspora_handle"] = diaspora_handle_from_contact($item[0]["contact-id"]);
|
||||
$post["public"] = (!$item[0]["private"] ? 'true':'false');
|
||||
$post["created_at"] = datetime_convert('UTC','UTC',$item[0]["created"]);
|
||||
$post["provider_display_name"] = $item[0]["app"];
|
||||
}
|
||||
|
||||
$dom = new DOMDocument("1.0");
|
||||
$root = $dom->createElement("XML");
|
||||
$dom->appendChild($root);
|
||||
$postelement = $dom->createElement("post");
|
||||
$root->appendChild($postelement);
|
||||
$statuselement = $dom->createElement($nodename);
|
||||
$postelement->appendChild($statuselement);
|
||||
|
||||
foreach($post AS $index => $value) {
|
||||
$postnode = $dom->createElement($index, $value);
|
||||
$statuselement->appendChild($postnode);
|
||||
}
|
||||
|
||||
header("Content-Type: application/xml; charset=utf-8");
|
||||
$xml = $dom->saveXML();
|
||||
|
||||
// Diaspora doesn't send the XML header, so we remove them as well.
|
||||
// So we avoid possible compatibility problems.
|
||||
if (substr($xml, 0, 21) == '<?xml version="1.0"?>')
|
||||
$xml = trim(substr($xml, 21));
|
||||
|
||||
echo $xml;
|
||||
|
||||
killme();
|
||||
}
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
function share_init(&$a) {
|
||||
|
||||
$post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
|
||||
|
@ -23,11 +20,8 @@ function share_init(&$a) {
|
|||
$pos = strpos($r[0]['body'], "[share");
|
||||
$o = substr($r[0]['body'], $pos);
|
||||
} else {
|
||||
$o = "[share author='".str_replace("'", "'",$r[0]['author-name']).
|
||||
"' profile='".$r[0]['author-link'].
|
||||
"' avatar='".$r[0]['author-avatar'].
|
||||
"' link='".$r[0]['plink'].
|
||||
"' posted='".$r[0]['created']."']\n";
|
||||
$o = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
|
||||
|
||||
if($r[0]['title'])
|
||||
$o .= '[b]'.$r[0]['title'].'[/b]'."\n";
|
||||
$o .= $r[0]['body'];
|
||||
|
@ -46,3 +40,19 @@ function share_init(&$a) {
|
|||
echo $o;
|
||||
killme();
|
||||
}
|
||||
|
||||
function share_header($author, $profile, $avatar, $guid, $posted, $link) {
|
||||
$header = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$author).
|
||||
"' profile='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$profile).
|
||||
"' avatar='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$avatar);
|
||||
|
||||
if ($guid)
|
||||
$header .= "' guid='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$guid);
|
||||
|
||||
if ($posted)
|
||||
$header .= "' posted='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$posted);
|
||||
|
||||
$header .= "' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$link)."']";
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_once('include/Photo.php');
|
||||
|
||||
function wall_upload_post(&$a) {
|
||||
function wall_upload_post(&$a, $desktopmode = true) {
|
||||
|
||||
logger("wall upload: starting new upload", LOGGER_DEBUG);
|
||||
|
||||
|
@ -189,6 +189,25 @@ function wall_upload_post(&$a) {
|
|||
|
||||
$basename = basename($filename);
|
||||
|
||||
if (!$desktopmode) {
|
||||
|
||||
$r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
|
||||
if (!$r)
|
||||
return false;
|
||||
|
||||
$picture = array();
|
||||
|
||||
$picture["id"] = $r[0]["id"];
|
||||
$picture["size"] = $r[0]["datasize"];
|
||||
$picture["width"] = $r[0]["width"];
|
||||
$picture["height"] = $r[0]["height"];
|
||||
$picture["type"] = $r[0]["type"];
|
||||
$picture["albumpage"] = $a->get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
|
||||
$picture["picture"] = $a->get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
|
||||
$picture["preview"] = $a->get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
|
||||
|
||||
return $picture;
|
||||
}
|
||||
|
||||
/* mod Waitman Gobble NO WARRANTY */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue