aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Scrape.php11
-rw-r--r--include/api.php11
-rwxr-xr-xinclude/diaspora.php80
-rwxr-xr-xinclude/items.php8
-rw-r--r--include/plugin.php35
5 files changed, 73 insertions, 72 deletions
diff --git a/include/Scrape.php b/include/Scrape.php
index ca8f6e83a..4f53effe9 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -352,10 +352,11 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$email_conversant = false;
$twitter = ((strpos($url,'twitter.com') !== false) ? true : false);
+ $lastfm = ((strpos($url,'last.fm/user') !== false) ? true : false);
$at_addr = ((strpos($url,'@') !== false) ? true : false);
- if(! $twitter) {
+ if((! $twitter) && (! $lastfm)) {
if(strpos($url,'mailto:') !== false && $at_addr) {
$url = str_replace('mailto:','',$url);
@@ -564,6 +565,14 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard['fn'] = $tid . '@twitter';
}
+ if($lastfm) {
+ $profile = $url;
+ $poll = str_replace(array('www.','last.fm/'),array('','ws.audioscrobbler.com/1.0/'),$url) . '/recenttracks.rss';
+ $vcard['nick'] = basename($url);
+ $vcard['fn'] = $vcard['nick'] . t(' on Last.fm');
+ $network = NETWORK_FEED;
+ }
+
if(! x($vcard,'fn'))
if(x($vcard,'nick'))
$vcard['fn'] = $vcard['nick'];
diff --git a/include/api.php b/include/api.php
index 855e4efa3..691543907 100644
--- a/include/api.php
+++ b/include/api.php
@@ -719,14 +719,18 @@
if ($page<0) $page=0;
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
+ $exclude_replies = (x($_REQUEST,'exclude_replies')?1:0);
//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
$start = $page*$count;
//$include_entities = (x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:false);
+ $sql_extra = '';
if ($max_id > 0)
- $sql_extra = 'AND `item`.`id` <= '.intval($max_id);
+ $sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
+ if ($exclude_replies > 0)
+ $sql_extra .= ' AND `item`.`parent` = `item`.`id`';
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
@@ -1061,11 +1065,14 @@
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
if ($page<0) $page=0;
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
+ $exclude_replies = (x($_REQUEST,'exclude_replies')?1:0);
//$since_id = 0;//$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
$start = $page*$count;
- if ($user_info['self']==1) $sql_extra = "AND `item`.`wall` = 1 ";
+ $sql_extra = '';
+ if ($user_info['self']==1) $sql_extra .= " AND `item`.`wall` = 1 ";
+ if ($exclude_replies > 0) $sql_extra .= ' AND `item`.`parent` = `item`.`id`';
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
diff --git a/include/diaspora.php b/include/diaspora.php
index 2be266e8a..0ca9163a8 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -2150,7 +2150,7 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
- $theiraddr = $contact['addr'];
+// $theiraddr = $contact['addr'];
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
// return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
@@ -2213,7 +2213,10 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
- $theiraddr = $contact['addr'];
+// $theiraddr = $contact['addr'];
+
+ $body = $item['body'];
+ $text = html_entity_decode(bb2diaspora($body));
// The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
@@ -2232,26 +2235,30 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$relay_retract = false;
$sql_sign_id = 'iid';
if( $item['deleted']) {
- $tpl = get_markup_template('diaspora_relayable_retraction.tpl');
$relay_retract = true;
- $sql_sign_id = 'retract_iid';
+
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
+ $sender_signed_text = $item['guid'] . ';' . $target_type ;
+
+ $sql_sign_id = 'retract_iid';
+ $tpl = get_markup_template('diaspora_relayable_retraction.tpl');
}
elseif($item['verb'] === ACTIVITY_LIKE) {
- $tpl = get_markup_template('diaspora_like_relay.tpl');
$like = true;
+
$target_type = 'Post';
// $positive = (($item['deleted']) ? 'false' : 'true');
$positive = 'true';
+ $sender_signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
+
+ $tpl = get_markup_template('diaspora_like_relay.tpl');
}
- else {
+ else { // item is a comment
+ $sender_signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
+
$tpl = get_markup_template('diaspora_comment_relay.tpl');
}
- $body = $item['body'];
-
- $text = html_entity_decode(bb2diaspora($body));
-
// fetch the original signature if the relayable was created by a Diaspora
// or DFRN user. Relayables for other networks are not supported.
@@ -2272,51 +2279,20 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
// function is called
logger('diaspora_send_relay: original author signature not found, cannot send relayable');
return;
-/*
- $itemcontact = q("select * from contact where `id` = %d limit 1",
- intval($item['contact-id'])
- );
- if(count($itemcontact)) {
- if(! $itemcontact[0]['self']) {
- $prefix = sprintf( t('[Relayed] Comment authored by %s from network %s'),
- '['. $item['author-name'] . ']' . '(' . $item['author-link'] . ')',
- network_to_name($itemcontact['network'])) . "\n";
- // "$body" was assigned to "$text" above. It isn't used after that, so I don't think
- // the following change will do anything
- $body = $prefix . $body;
-
- // I think this comment will fail upon reaching Diaspora, because "$signed_text" is not defined
- }
- }
- else {
- // I'm confused about this "else." Since it sets "$handle = $myaddr," it seems like it should be for the case
- // where the top-level post owner commented on his own post, i.e. "$itemcontact[0]['self']" is true. But it's
- // positioned to be for the case where "count($itemcontact)" is 0.
-
- $handle = $myaddr;
-
- if($like)
- $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $handle;
- elseif($relay_retract)
- $signed_text = $item['guid'] . ';' . $target_type;
- else
- $signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $handle;
-
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
-
- q("insert into sign (`" . $sql_sign_id . "`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
- intval($item['id']),
- dbesc($signed_text),
- dbesc($authorsig),
- dbesc($handle)
- );
- }
-*/
}
- // sign it with the top-level owner's signature
+ // Sign the relayable with the top-level owner's signature
+ //
+ // We'll use the $sender_signed_text that we just created, instead of the $signed_text
+ // stored in the database, because that provides the best chance that Diaspora will
+ // be able to reconstruct the signed text the same way we did. This is particularly a
+ // concern for the comment, whose signed text includes the text of the comment. The
+ // smallest change in the text of the comment, including removing whitespace, will
+ // make the signature verification fail. Since we translate from BB code to Diaspora's
+ // markup at the top of this function, which is AFTER we placed the original $signed_text
+ // in the database, it's hazardous to trust the original $signed_text.
- $parentauthorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
+ $parentauthorsig = base64_encode(rsa_sign($sender_signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
diff --git a/include/items.php b/include/items.php
index 05134ef8f..a0dd1c815 100755
--- a/include/items.php
+++ b/include/items.php
@@ -446,6 +446,8 @@ function get_atom_elements($feed,$item) {
$res['body'] = $purifier->purify($res['body']);
$res['body'] = @html2bbcode($res['body']);
+
+
}
elseif(! $have_real_body) {
@@ -1264,6 +1266,12 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
return 3;
}
+ if($contact['term-date'] != '0000-00-00 00:00:00') {
+ logger("dfrn_deliver: $url back from the dead - removing mark for death");
+ require_once('include/Contact.php');
+ unmark_for_death($contact);
+ }
+
$res = parse_xml_string($xml);
return $res->status;
diff --git a/include/plugin.php b/include/plugin.php
index ae8eee78a..c6b61ae6e 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -148,7 +148,9 @@ function load_hooks() {
$r = q("SELECT * FROM `hook` WHERE 1");
if(count($r)) {
foreach($r as $rr) {
- $a->hooks[] = array($rr['hook'], $rr['file'], $rr['function']);
+ if(! array_key_exists($rr['hook'],$a->hooks))
+ $a->hooks[$rr['hook']] = array();
+ $a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
}
}
}}
@@ -158,25 +160,24 @@ if(! function_exists('call_hooks')) {
function call_hooks($name, &$data = null) {
$a = get_app();
- if(count($a->hooks)) {
- foreach($a->hooks as $hook) {
- if($hook[HOOK_HOOK] === $name) {
- @include_once($hook[HOOK_FILE]);
- if(function_exists($hook[HOOK_FUNCTION])) {
- $func = $hook[HOOK_FUNCTION];
- $func($a,$data);
- }
- else {
- // remove orphan hooks
- q("delete from hook where hook = '%s' and file = '$s' and function = '%s' limit 1",
- dbesc($hook[HOOK_HOOK]),
- dbesc($hook[HOOK_FILE]),
- dbesc($hook[HOOK_FUNCTION])
- );
- }
+ if((is_array($a->hooks)) && (array_key_exists($name,$a->hooks))) {
+ foreach($a->hooks[$name] as $hook) {
+ @include_once($hook[0]);
+ if(function_exists($hook[1])) {
+ $func = $hook[1];
+ $func($a,$data);
+ }
+ else {
+ // remove orphan hooks
+ q("delete from hook where hook = '%s' and file = '$s' and function = '%s' limit 1",
+ dbesc($name),
+ dbesc($hook[0]),
+ dbesc($hook[1])
+ );
}
}
}
+
}}