1
1
Fork 0

Merge remote-tracking branch 'upstream/develop' into 1504-parse_url

This commit is contained in:
Michael Vogel 2015-04-09 19:49:33 +02:00
commit e81f9c91fa
15 changed files with 22145 additions and 21802 deletions

View file

@ -7,6 +7,9 @@
require_once("include/conversation.php");
require_once("include/oauth.php");
require_once("include/html2plain.php");
require_once("mod/share.php");
require_once("include/Photo.php");
/*
* Twitter-Like API
*
@ -821,6 +824,18 @@
$_REQUEST['body'] .= "\n\n".$media;
}
// To-Do: Multiple IDs
if (requestdata('media_ids')) {
$r = q("SELECT `resource-id`, `scale`, `nickname`, `type` FROM `photo` INNER JOIN `user` ON `user`.`uid` = `photo`.`uid` WHERE `resource-id` IN (SELECT `resource-id` FROM `photo` WHERE `id` = %d) AND `scale` > 0 AND `photo`.`uid` = %d ORDER BY `photo`.`width` DESC LIMIT 1",
intval(requestdata('media_ids')), api_user());
if ($r) {
$phototypes = Photo::supportedTypes();
$ext = $phototypes[$r[0]['type']];
$_REQUEST['body'] .= "\n\n".'[url='.$a->get_baseurl().'/photos/'.$r[0]['nickname'].'/image/'.$r[0]['resource-id'].']';
$_REQUEST['body'] .= '[img]'.$a->get_baseurl()."/photo/".$r[0]['resource-id']."-".$r[0]['scale'].".".$ext."[/img][/url]";
}
}
// set this so that the item_post() function is quiet and doesn't redirect or emit json
$_REQUEST['api_source'] = true;
@ -840,6 +855,41 @@
api_register_func('api/statuses/update_with_media','api_statuses_update', true);
function api_media_upload(&$a, $type) {
if (api_user()===false) {
logger('no user');
return false;
}
$user_info = api_get_user($a);
if(!x($_FILES,'media')) {
// Output error
return false;
}
require_once('mod/wall_upload.php');
$media = wall_upload_post($a, false);
if(!$media) {
// Output error
return false;
}
$returndata = array();
$returndata["media_id"] = $media["id"];
$returndata["media_id_string"] = (string)$media["id"];
$returndata["size"] = $media["size"];
$returndata["image"] = array("w" => $media["width"],
"h" => $media["height"],
"image_type" => $media["type"]);
logger("Media uploaded: ".print_r($returndata, true), LOGGER_DEBUG);
return array("media" => $returndata);
}
api_register_func('api/media/upload','api_media_upload', true);
function api_status_show(&$a, $type){
$user_info = api_get_user($a);
@ -1136,7 +1186,8 @@
$idlist = implode(",", $idarray);
$r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
if ($idlist != "")
$r = q("UPDATE `item` SET `unseen` = 0 WHERE `unseen` AND `id` IN (%s)", $idlist);
$data = array('$statuses' => $ret);
@ -1389,10 +1440,8 @@
$pos = strpos($r[0]['body'], "[share");
$post = substr($r[0]['body'], $pos);
} else {
$post = "[share author='".str_replace("'", "'", $r[0]['author-name']).
"' profile='".$r[0]['author-link'].
"' avatar='".$r[0]['author-avatar'].
"' link='".$r[0]['plink']."']";
$post = share_header($r[0]['author-name'], $r[0]['author-link'], $r[0]['author-avatar'], $r[0]['guid'], $r[0]['created'], $r[0]['plink']);
$post .= $r[0]['body'];
$post .= "[/share]";
}
@ -1876,8 +1925,6 @@
if (!$ret)
return false;
require_once("include/Photo.php");
$attachments = array();
foreach ($images[1] AS $image) {
@ -2003,7 +2050,6 @@
$start = iconv_strpos($text, $url, $offset, "UTF-8");
if (!($start === false)) {
require_once("include/Photo.php");
$image = get_photo_info($url);
if ($image) {
// If image cache is activated, then use the following sizes:

View file

@ -7,6 +7,7 @@ require_once('include/contact_selectors.php');
require_once('include/queue_fn.php');
require_once('include/lock.php');
require_once('include/threads.php');
require_once('mod/share.php');
function diaspora_dispatch_public($msg) {
@ -778,6 +779,18 @@ function diaspora_post_allow($importer,$contact) {
return false;
}
function diaspora_plink($addr, $guid) {
$r = q("SELECT `url`, `nick` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", $addr);
// Fallback
if (!$r)
return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
if (strstr($r[0]["url"], "/channel/"))
return $r[0]["url"]."/?f=&mid=".$guid;
return 'https://'.substr($addr,strpos($addr,'@')+1).'/posts/'.$guid;
}
function diaspora_post($importer,$xml,$msg) {
@ -843,7 +856,7 @@ function diaspora_post($importer,$xml,$msg) {
}
}
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = diaspora_plink($diaspora_handle, $guid);
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
@ -936,7 +949,7 @@ function diaspora_store_by_guid($guid, $server) {
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['private'] = $private;
$datarray['parent'] = 0;
$datarray['plink'] = 'https://'.substr($author,strpos($author,'@')+1).'/posts/'.$guid;
$datarray['plink'] = diaspora_plink($author, $guid);
$datarray['author-name'] = $person['name'];
$datarray['author-link'] = $person['url'];
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
@ -1149,7 +1162,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray = array();
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = diaspora_plink($diaspora_handle, $guid);
$datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id'];
@ -1165,12 +1178,8 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['owner-link'] = $contact['url'];
$datarray['owner-avatar'] = ((x($contact,'thumb')) ? $contact['thumb'] : $contact['photo']);
if (!intval(get_config('system','wall-to-wall_share'))) {
$prefix = "[share author='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$person['name']).
"' profile='".$person['url'].
"' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).
"' guid='".$orig_guid.
"' posted='".$orig_created.
"' link='".str_replace(array("'", "[", "]"), array("'", "[", "]"),$orig_url)."']";
$prefix = share_header($person['name'], $person['url'], ((x($person,'thumb')) ? $person['thumb'] : $person['photo']), $orig_guid, $orig_created, $orig_url);
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = $contact['url'];
$datarray['author-avatar'] = $contact['thumb'];
@ -1199,8 +1208,8 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray2['contact-id'] = get_contact($person['url'], 0);
$datarray2['guid'] = $orig_guid;
$datarray2['uri'] = $datarray2['parent-uri'] = $orig_author.':'.$orig_guid;
$datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = datetime_convert('UTC','UTC',$orig_created);
$datarray2['plink'] = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
$datarray2['changed'] = $datarray2['created'] = $datarray2['edited'] = $datarray2['commented'] = $datarray2['received'] = datetime_convert('UTC','UTC',$orig_created);
$datarray2['plink'] = diaspora_plink($orig_author, $orig_guid);
$datarray2['author-name'] = $person['name'];
$datarray2['author-link'] = $person['url'];
@ -1284,7 +1293,7 @@ function diaspora_asphoto($importer,$xml,$msg) {
return;
}
$plink = 'https://'.substr($diaspora_handle,strpos($diaspora_handle,'@')+1).'/posts/'.$guid;
$plink = diaspora_plink($diaspora_handle, $guid);
$datarray = array();

View file

@ -12,6 +12,7 @@ require_once('include/email.php');
require_once('include/ostatus_conversation.php');
require_once('include/threads.php');
require_once('include/socgraph.php');
require_once('mod/share.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
@ -838,10 +839,7 @@ function get_atom_elements($feed, $item, $contact = array()) {
logger('get_atom_elements: fixing sender of repeated message.');
if (!intval(get_config('system','wall-to-wall_share'))) {
$prefix = "[share author='".str_replace("'", "'",$name).
"' profile='".$uri.
"' avatar='".$avatar.
"' link='".$orig_uri."']";
$prefix = share_header($name, $uri, $avatar, "", "", $orig_uri);
$res["body"] = $prefix.html2bbcode($message)."[/share]";
} else {
@ -1183,9 +1181,9 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa
$arr['owner-avatar'] = ((x($arr,'owner-avatar')) ? notags(trim($arr['owner-avatar'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
$arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert());
$arr['commented'] = datetime_convert();
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
$arr['commented'] = ((x($arr,'commented') !== false) ? datetime_convert('UTC','UTC',$arr['commented']) : datetime_convert());
$arr['received'] = ((x($arr,'received') !== false) ? datetime_convert('UTC','UTC',$arr['received']) : datetime_convert());
$arr['changed'] = ((x($arr,'changed') !== false) ? datetime_convert('UTC','UTC',$arr['changed']) : datetime_convert());
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');

View file

@ -192,7 +192,7 @@
// TODO (yet unsupported by most browsers):
// Implement notification.onclick()
notifyMarkAll();
// notifyMarkAll();
}
});

75
mod/p.php Normal file
View 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("&", "&amp;", 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();
}

View file

@ -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("'", "&#039;",$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("&#x27;", "&#x5B;", "&#x5D;"),$author).
"' profile='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$profile).
"' avatar='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$avatar);
if ($guid)
$header .= "' guid='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$guid);
if ($posted)
$header .= "' posted='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$posted);
$header .= "' link='".str_replace(array("'", "[", "]"), array("&#x27;", "&#x5B;", "&#x5D;"),$link)."']";
return $header;
}

View file

@ -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 */

View file

@ -287,22 +287,24 @@ class Item extends BaseObject {
}
// Disable features that aren't available in several networks
if (($item["item_network"] != "dfrn") AND isset($buttons["dislike"])) {
if (($item["item_network"] != NETWORK_DFRN) AND isset($buttons["dislike"])) {
unset($buttons["dislike"]);
$tagger = '';
}
if (($item["item_network"] == "feed") AND isset($buttons["like"]))
if (($item["item_network"] == NETWORK_FEED) AND isset($buttons["like"]))
unset($buttons["like"]);
if (($item["item_network"] == "mail") AND isset($buttons["like"]))
if (($item["item_network"] == NETWORK_MAIL) AND isset($buttons["like"]))
unset($buttons["like"]);
if (($item["item_network"] == "dspr") AND ($indent == 'comment') AND isset($buttons["like"]))
// Diaspora isn't able to do likes on comments - but red does
if (($item["item_network"] == NETWORK_DIASPORA) AND ($indent == 'comment') AND
!strstr($item["owner-link"], "/channel/") AND isset($buttons["like"]))
unset($buttons["like"]);
// Facebook can like comments - but it isn't programmed in the connector yet.
if (($item["item_network"] == "face") AND ($indent == 'comment') AND isset($buttons["like"]))
if (($item["item_network"] == NETWORK_FACEBOOK) AND ($indent == 'comment') AND isset($buttons["like"]))
unset($buttons["like"]);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
<base href="{{$baseurl}}/" />
<meta name="generator" content="{{$generator}}" />
<link rel="stylesheet" href="{{$baseurl}}/library/jgrowl/jquery.jgrowl.css" type="text/css" media="screen" />
<script type="text/javascript" src="{{$baseurl}}/js/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="{{$stylesheet}}" media="all" />