aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarijus <mario@mariovavti.com>2014-08-22 09:17:17 +0200
committermarijus <mario@mariovavti.com>2014-08-22 09:17:17 +0200
commitb0d52943e85bf819d4ddf91127ca25ec7a32c289 (patch)
treefcb7c92735bbcbae9359d3fcf91a185226698426
parent1a3be504516db7106ea0ce385691e5a3eca4c084 (diff)
parentc5f4e5bac76de93b30c00fa9fb3dc8a559d7b070 (diff)
downloadvolse-hubzilla-b0d52943e85bf819d4ddf91127ca25ec7a32c289.tar.gz
volse-hubzilla-b0d52943e85bf819d4ddf91127ca25ec7a32c289.tar.bz2
volse-hubzilla-b0d52943e85bf819d4ddf91127ca25ec7a32c289.zip
Merge branch 'upstream'
-rw-r--r--include/crypto.php5
-rwxr-xr-xinclude/diaspora.php237
-rw-r--r--include/externals.php2
-rw-r--r--include/identity.php24
-rwxr-xr-xinclude/items.php8
-rwxr-xr-xinclude/text.php8
-rw-r--r--include/zot.php16
-rw-r--r--mod/item.php1
-rw-r--r--mod/receive.php9
-rw-r--r--mod/xrd.php21
-rw-r--r--view/tpl/diaspora_vcard.tpl57
-rwxr-xr-xview/tpl/profile_edit.tpl4
-rwxr-xr-xview/tpl/profile_vcard.tpl3
-rw-r--r--view/tpl/xrd_diaspora.tpl8
-rwxr-xr-xview/tpl/xrd_person.tpl10
15 files changed, 275 insertions, 138 deletions
diff --git a/include/crypto.php b/include/crypto.php
index c053dfae2..07655e24f 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -1,5 +1,8 @@
<?php /** @file */
+require_once('library/ASNValue.class.php');
+require_once('library/asn1.php');
+
function rsa_sign($data,$key,$alg = 'sha256') {
if(! $key)
return 'no key';
@@ -241,7 +244,6 @@ function metopem($m,$e) {
function pubrsatome($key,&$m,&$e) {
require_once('library/asn1.php');
- require_once('include/salmon.php');
$lines = explode("\n",$key);
unset($lines[0]);
@@ -266,7 +268,6 @@ function pemtorsa($key) {
}
function pemtome($key,&$m,&$e) {
- require_once('include/salmon.php');
$lines = explode("\n",$key);
unset($lines[0]);
unset($lines[count($lines)]);
diff --git a/include/diaspora.php b/include/diaspora.php
index dda552536..982e40f2f 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -106,29 +106,49 @@ function diaspora_dispatch($importer,$msg,$attempt=1) {
return $ret;
}
-function diaspora_handle_from_contact($contact_id) {
- $handle = false;
- logger("diaspora_handle_from_contact: contact id is " . $contact_id, LOGGER_DEBUG);
+function diaspora_is_blacklisted($s) {
- $r = q("SELECT * from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d",
- intval($contact_id)
+ $bl1 = get_config('system','blacklisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl && strpos($s,$bl) !== false) {
+ logger('diaspora_is_blacklisted: blacklisted ' . $s);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+
+
+
+
+function diaspora_handle_from_contact($contact_hash) {
+
+ logger("diaspora_handle_from_contact: contact id is " . $contact_hash, LOGGER_DEBUG);
+
+ $r = q("SELECT * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' limit 1",
+ intval($contact_hash)
);
if($r) {
- $contact = $r[0];
+ return $r[0]['xchan_addr'];
}
- $handle = $contact['xchan_addr'];
- return $handle;
+ return false;
}
function diaspora_get_contact_by_handle($uid,$handle) {
+
+ if(diaspora_is_blacklisted($handle))
+ return false;
+
$r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where xchan_addr = '%s' and abook_channel = %d limit 1",
dbesc($handle),
intval($uid)
);
- if($r)
- return $r[0];
- return false;
+ return (($r) ? $r[0] : false);
}
function find_diaspora_person_by_handle($handle) {
@@ -140,6 +160,8 @@ function find_diaspora_person_by_handle($handle) {
$endlessloop = 0;
$maxloops = 10;
+ if(diaspora_is_blacklisted($handle))
+ return false;
$r = q("select * from xchan where xchan_addr = '%s' limit 1",
dbesc($handle)
@@ -162,6 +184,7 @@ function find_diaspora_person_by_handle($handle) {
$result = discover_by_webbie($handle);
+
}
@@ -169,13 +192,10 @@ function find_diaspora_person_by_handle($handle) {
}
-function get_diaspora_key($uri) {
- logger('Fetching diaspora key for: ' . $uri);
-
- $r = find_diaspora_person_by_handle($uri);
- if($r)
- return $r['pubkey'];
- return '';
+function get_diaspora_key($handle) {
+ logger('Fetching diaspora key for: ' . $handle, LOGGER_DEBUG);
+ $r = find_diaspora_person_by_handle($handle);
+ return(($r) ? $r['xchan_pubkey'] : '');
}
@@ -350,7 +370,7 @@ function diaspora_decode($importer,$xml) {
$ciphertext = base64_decode($encrypted_header->ciphertext);
$outer_key_bundle = '';
- openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
+ openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['channel_prvkey']);
$j_outer_key_bundle = json_decode($outer_key_bundle);
@@ -428,7 +448,6 @@ function diaspora_decode($importer,$xml) {
$encoding = $base->encoding;
$alg = $base->alg;
-
$signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
@@ -580,15 +599,14 @@ function diaspora_request($importer,$xml) {
return;
}
-//FIXME
-// $g = q("select def_gid from user where uid = %d limit 1",
-// intval($importer['channel_id'])
-// );
-// if($g && intval($g[0]['def_gid'])) {
-// require_once('include/group.php');
-// group_add_member($importer['channel_id'],'',$contact_record['id'],$g[0]['def_gid']);
-// }
+ /** If there is a default group for this channel, add this member to it */
+ if($importer['channel_default_group']) {
+ require_once('include/group.php');
+ $g = group_rec_byhash($importer['channel_id'],$importer['channel_default_group']);
+ if($g)
+ group_add_member($importer['channel_id'],'',$contact_record['xchan_hash'],$g['id']);
+ }
return;
}
@@ -680,9 +698,6 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['uid'] = $importer['channel_id'];
// FIXME
- $datarray['contact-id'] = $contact['id'];
- $datarray['wall'] = 0;
- $datarray['network'] = NETWORK_DIASPORA;
$datarray['verb'] = ACTIVITY_POST;
@@ -691,7 +706,6 @@ function diaspora_post($importer,$xml,$msg) {
$datarray['changed'] = $datarray['created'] = $datarray['edited'] = datetime_convert('UTC','UTC',$created);
$datarray['item_private'] = $private;
-
$datarray['plink'] = $plink;
$datarray['author_xchan'] = $contact['xchan_hash'];
@@ -2029,8 +2043,8 @@ function diaspora_profile($importer,$xml,$msg) {
function diaspora_share($me,$contact) {
$a = get_app();
- $myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
- $theiraddr = $contact['addr'];
+ $myaddr = $me['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $theiraddr = $contact['xchan_addr'];
$tpl = get_markup_template('diaspora_share.tpl');
$msg = replace_macros($tpl, array(
@@ -2067,8 +2081,8 @@ function diaspora_unshare($me,$contact) {
function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
$a = get_app();
- $myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
- $theiraddr = $contact['addr'];
+ $myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $theiraddr = $contact['xchan_addr'];
$images = array();
@@ -2120,44 +2134,44 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
}
- $public = (($item['private']) ? 'false' : 'true');
+ $public = (($item['item_private']) ? 'false' : 'true');
require_once('include/datetime.php');
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
// Detect a share element and do a reshare
// see: https://github.com/Raven24/diaspora-federation/blob/master/lib/diaspora-federation/entities/reshare.rb
- if (!$item['private'] AND ($ret = diaspora_is_reshare($item["body"]))) {
+ if (!$item['item_private'] AND ($ret = diaspora_is_reshare($item["body"]))) {
$tpl = get_markup_template('diaspora_reshare.tpl');
$msg = replace_macros($tpl, array(
'$root_handle' => xmlify($ret['root_handle']),
'$root_guid' => $ret['root_guid'],
- '$guid' => $item['guid'],
+ '$guid' => $item['mid'],
'$handle' => xmlify($myaddr),
'$public' => $public,
'$created' => $created,
- '$provider' => $item["app"]
+ '$provider' => $item['app']
));
} else {
$tpl = get_markup_template('diaspora_post.tpl');
$msg = replace_macros($tpl, array(
'$body' => $body,
- '$guid' => $item['guid'],
+ '$guid' => $item['mid'],
'$handle' => xmlify($myaddr),
'$public' => $public,
'$created' => $created,
- '$provider' => $item["app"]
+ '$provider' => $item['app']
));
}
- logger('diaspora_send_status: '.$owner['username'].' -> '.$contact['name'].' base message: '.$msg, LOGGER_DATA);
+ logger('diaspora_send_status: '.$owner['channel_name'].' -> '.$contact['xchan_name'].' base message: '.$msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
$return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
- logger('diaspora_send_status: guid: '.$item['guid'].' result '.$return_code, LOGGER_DEBUG);
+ logger('diaspora_send_status: guid: '.$item['mid'].' result '.$return_code, LOGGER_DEBUG);
if(count($images)) {
diaspora_send_images($item,$owner,$contact,$images,$public_batch);
@@ -2167,51 +2181,52 @@ function diaspora_send_status($item,$owner,$contact,$public_batch = false) {
}
function diaspora_is_reshare($body) {
+
$body = trim($body);
- // Skip if it isn't a pure repeated messages
- // Does it start with a share?
- if (strpos($body, "[share") > 0)
- return(false);
+ // Skip if it isn't a pure repeated messages
+ // Does it start with a share?
+ if(strpos($body, "[share") > 0)
+ return(false);
- // Does it end with a share?
- if (strlen($body) > (strrpos($body, "[/share]") + 8))
- return(false);
+ // Does it end with a share?
+ if(strlen($body) > (strrpos($body, "[/share]") + 8))
+ return(false);
- $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
- // Skip if there is no shared message in there
- if ($body == $attributes)
- return(false);
+ $attributes = preg_replace("/\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","$1",$body);
+ // Skip if there is no shared message in there
+ if ($body == $attributes)
+ return(false);
- $profile = "";
- preg_match("/profile='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- preg_match('/profile="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $profile = $matches[1];
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
- $ret= array();
+ $ret= array();
- $ret["root_handle"] = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
- if (($ret["root_handle"] == $profile) OR ($ret["root_handle"] == ""))
- return(false);
+ $ret["root_handle"] = preg_replace("=https?://(.*)/u/(.*)=ism", "$2@$1", $profile);
+ if (($ret["root_handle"] == $profile) OR ($ret["root_handle"] == ""))
+ return(false);
- $link = "";
- preg_match("/link='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ $link = "";
+ preg_match("/link='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- preg_match('/link="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "")
- $link = $matches[1];
+ preg_match('/link="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $link = $matches[1];
- $ret["root_guid"] = preg_replace("=https?://(.*)/posts/(.*)=ism", "$2", $link);
- if (($ret["root_guid"] == $link) OR ($ret["root_guid"] == ""))
- return(false);
+ $ret["root_guid"] = preg_replace("=https?://(.*)/posts/(.*)=ism", "$2", $link);
+ if (($ret["root_guid"] == $link) OR ($ret["root_guid"] == ""))
+ return(false);
- return($ret);
+ return($ret);
}
function diaspora_send_images($item,$owner,$contact,$images,$public_batch = false) {
@@ -2227,18 +2242,18 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
$resource = str_replace('.jpg','',$image['file']);
$resource = substr($resource,0,strpos($resource,'-'));
- $r = q("select * from photo where `resource-id` = '%s' and `uid` = %d limit 1",
+ $r = q("select * from photo where `resource_id` = '%s' and `uid` = %d limit 1",
dbesc($resource),
intval($owner['uid'])
);
- if(! count($r))
+ if(! $r)
continue;
$public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
$msg = replace_macros($tpl,array(
'$path' => xmlify($image['path']),
'$filename' => xmlify($image['file']),
'$msg_guid' => xmlify($image['guid']),
- '$guid' => xmlify($r[0]['guid']),
+ '$guid' => xmlify($r[0]['resource_id']),
'$handle' => xmlify($image['handle']),
'$public' => xmlify($public),
'$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d H:i:s \U\T\C'))
@@ -2246,7 +2261,7 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
//$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
diaspora_transmit($owner,$contact,$slap,$public_batch);
@@ -2257,27 +2272,27 @@ function diaspora_send_images($item,$owner,$contact,$images,$public_batch = fals
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'];
+ $myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $theiraddr = $contact['xchan_addr'];
// Diaspora doesn't support threaded comments, but some
// versions of Diaspora (i.e. Diaspora-pistos) support
// likes on comments
- if($item['verb'] === ACTIVITY_LIKE && $item['thr-parent']) {
- $p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
- dbesc($item['thr-parent'])
- );
+ if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) {
+ $p = q("select mid, parent_mid from item where mid = '%s' limit 1",
+ dbesc($item['thr_parent'])
+ );
}
else {
// 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.
// The only item with `parent` and `id` as the parent id is the parent item.
- $p = q("select guid, type, uri, `parent-uri` from item where parent = %d and id = %d limit 1",
+ $p = q("select * from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
}
- if(count($p))
+ if($p)
$parent = $p[0];
else
return;
@@ -2285,12 +2300,10 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
if($item['verb'] === ACTIVITY_LIKE) {
$tpl = get_markup_template('diaspora_like.tpl');
$like = true;
- $target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
-// $target_type = (strpos($parent['type'], 'comment') ? 'Comment' : 'Post');
-// $positive = (($item['deleted']) ? 'false' : 'true');
+ $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment');
$positive = 'true';
- if(($item['deleted']))
+ if(($item_['item_restrict'] & ITEM_DELETED))
logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction');
}
else {
@@ -2303,15 +2316,15 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
// sign it
if($like)
- $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent['guid'] . ';' . $positive . ';' . $myaddr;
+ $signed_text = $item['mid'] . ';' . $target_type . ';' . $parent['mid'] . ';' . $positive . ';' . $myaddr;
else
- $signed_text = $item['guid'] . ';' . $parent['guid'] . ';' . $text . ';' . $myaddr;
+ $signed_text = $item['mid'] . ';' . $parent['mid'] . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['channel_prvkey'],'sha256'));
$msg = replace_macros($tpl,array(
- '$guid' => xmlify($item['guid']),
- '$parent_guid' => xmlify($parent['guid']),
+ '$guid' => xmlify($item['mid']),
+ '$parent_guid' => xmlify($parent['mid']),
'$target_type' =>xmlify($target_type),
'$authorsig' => xmlify($authorsig),
'$body' => xmlify($text),
@@ -2321,8 +2334,8 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) {
logger('diaspora_followup: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- //$slap = 'xml=' . urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['channel_prvkey'],$contact['xchan_pubkey'],$public_batch)));
+
return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
@@ -2332,7 +2345,7 @@ 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);
+ $myaddr = $owner['channel_address'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
// $theiraddr = $contact['addr'];
$body = $item['body'];
@@ -2341,21 +2354,21 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
// Diaspora doesn't support threaded comments, but some
// versions of Diaspora (i.e. Diaspora-pistos) support
// likes on comments
- if($item['verb'] === ACTIVITY_LIKE && $item['thr-parent']) {
- $p = q("select guid, type, uri, `parent-uri` from item where uri = '%s' limit 1",
- dbesc($item['thr-parent'])
- );
+ if($item['verb'] === ACTIVITY_LIKE && $item['thr_parent']) {
+ $p = q("select * from item where mid = '%s' limit 1",
+ dbesc($item['thr_parent'])
+ );
}
else {
// 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.
// The only item with `parent` and `id` as the parent id is the parent item.
- $p = q("select guid, type, uri, `parent-uri` from item where parent = %d and id = %d limit 1",
+ $p = q("select * from item where parent = %d and id = %d limit 1",
intval($item['parent']),
intval($item['parent'])
);
}
- if(count($p))
+ if($p)
$parent = $p[0];
else
return;
@@ -2363,7 +2376,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$like = false;
$relay_retract = false;
$sql_sign_id = 'iid';
- if( $item['deleted']) {
+ if( $item['item_restrict'] & ITEM_DELETED) {
$relay_retract = true;
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
@@ -2374,8 +2387,8 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
elseif($item['verb'] === ACTIVITY_LIKE) {
$like = true;
- $target_type = ( $parent['uri'] === $parent['parent-uri'] ? 'Post' : 'Comment');
-// $positive = (($item['deleted']) ? 'false' : 'true');
+ $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment');
+// $positive = (($item['item_restrict'] & ITEM_DELETED) ? 'false' : 'true');
$positive = 'true';
$tpl = get_markup_template('diaspora_like_relay.tpl');
@@ -2419,7 +2432,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
* been done yet
*/
- $handle = diaspora_handle_from_contact($item['contact-id']);
+ $handle = diaspora_handle_from_contact($item['author_xchan']);
if(! $handle)
return;
diff --git a/include/externals.php b/include/externals.php
index a96bf7c97..8944524b7 100644
--- a/include/externals.php
+++ b/include/externals.php
@@ -41,7 +41,7 @@ function externals_run($argv, $argc){
$bl1 = get_config('system','blacklisted_sites');
if(is_array($bl1) && $bl1) {
foreach($bl1 as $bl) {
- if(strpos($url,$bl) !== false) {
+ if($bl && strpos($url,$bl) !== false) {
$blacklisted = true;
break;
}
diff --git a/include/identity.php b/include/identity.php
index 9335673a0..8b742f53e 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -770,9 +770,26 @@ logger('online: ' . $profile['online']);
$location = $pdesc = $gender = $marital = $homepage = $online = False;
}
- $firstname = ((strpos($profile['name'],' '))
- ? trim(substr($profile['name'],0,strpos($profile['name'],' '))) : $profile['name']);
- $lastname = (($firstname === $profile['name']) ? '' : trim(substr($profile['name'],strlen($firstname))));
+ $firstname = ((strpos($profile['channel_name'],' '))
+ ? trim(substr($profile['channel_name'],0,strpos($profile['channel_name'],' '))) : $profile['channel_name']);
+ $lastname = (($firstname === $profile['channel_name']) ? '' : trim(substr($profile['channel_name'],strlen($firstname))));
+
+ if(get_config('system','diaspora_enabled')) {
+ $diaspora = array(
+ 'podloc' => z_root(),
+ 'searchable' => (($block) ? 'false' : 'true'),
+ 'nickname' => $profile['channel_address'],
+ 'fullname' => $profile['channel_name'],
+ 'firstname' => $firstname,
+ 'lastname' => $lastname,
+ 'photo300' => z_root() . '/photo/profile/300/' . $profile['uid'] . '.jpg',
+ 'photo100' => z_root() . '/photo/profile/100/' . $profile['uid'] . '.jpg',
+ 'photo50' => z_root() . '/photo/profile/50/' . $profile['uid'] . '.jpg',
+ );
+ }
+ else
+ $diaspora = null;
+
$contact_block = contact_block();
@@ -802,6 +819,7 @@ logger('online: ' . $profile['online']);
'$marital' => $marital,
'$homepage' => $homepage,
'$chanmenu' => $channel_menu,
+ '$diaspora' => $diaspora,
'$contact_block' => $contact_block,
));
diff --git a/include/items.php b/include/items.php
index fbe67817d..783c67752 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1664,8 +1664,8 @@ function item_store($arr,$allow_exec = false) {
}
- $arr['title'] = ((x($arr,'title')) ? trim($arr['title']) : '');
- $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
+ $arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : '');
+ $arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : '');
$arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : '');
$arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : '');
@@ -2136,7 +2136,6 @@ function item_store_update($arr,$allow_exec = false) {
$arr['commented'] = $orig[0]['commented'];
$arr['received'] = datetime_convert();
$arr['changed'] = datetime_convert();
- $arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']);
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']);
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']);
@@ -2152,7 +2151,8 @@ function item_store_update($arr,$allow_exec = false) {
$arr['deny_gid'] = ((array_key_exists('deny_gid',$arr)) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']);
$arr['item_private'] = ((array_key_exists('item_private',$arr)) ? intval($arr['item_private']) : $orig[0]['item_private']);
- $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
+ $arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : '');
+ $arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']);
// $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] );
diff --git a/include/text.php b/include/text.php
index 680e6fe95..d3d8b84a6 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1002,9 +1002,9 @@ function smilies($s, $sample = false) {
':facepalm',
':like',
':dislike',
+ 'red#matrix',
'red#',
- 'r#',
- 'red#matrix'
+ 'r#'
);
$icons = array(
@@ -1040,9 +1040,9 @@ function smilies($s, $sample = false) {
'<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
'<img class="smiley" src="' . $a->get_baseurl() . '/images/like.gif" alt=":like" />',
'<img class="smiley" src="' . $a->get_baseurl() . '/images/dislike.gif" alt=":dislike" />',
+ '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="red#matrix" />matrix</strong></a>',
'<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="red#" />matrix</strong></a>',
- '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong></a>',
- '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="red#matrix" />matrix</strong></a>'
+ '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong></a>'
);
diff --git a/include/zot.php b/include/zot.php
index 8b0efe09d..41d0bc1eb 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -507,6 +507,22 @@ function zot_refresh($them,$channel = null, $force = false) {
function zot_gethub($arr) {
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
+
+ $blacklisted = false;
+ $bl1 = get_config('system','blacklisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl && strpos($arr['url'],$bl) !== false) {
+ $blacklisted = true;
+ break;
+ }
+ }
+ }
+ if($blacklisted) {
+ logger('zot_gethub: blacklisted site: ' . $arr['url']);
+ return null;
+ }
+
$r = q("select * from hubloc
where hubloc_guid = '%s' and hubloc_guid_sig = '%s'
and hubloc_url = '%s' and hubloc_url_sig = '%s'
diff --git a/mod/item.php b/mod/item.php
index 92dc3e7c6..27691eb4f 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -790,7 +790,6 @@ function item_post(&$a) {
else
$post_id = 0;
-
$post = item_store($datarray,$execflag);
$post_id = $post['item_id'];
diff --git a/mod/receive.php b/mod/receive.php
index c5a2dc4e0..4071b169b 100644
--- a/mod/receive.php
+++ b/mod/receive.php
@@ -4,8 +4,6 @@
* Diaspora endpoint
*/
-
-//require_once('include/salmon.php');
require_once('include/crypto.php');
require_once('include/diaspora.php');
@@ -31,8 +29,11 @@ function receive_post(&$a) {
$guid = argv(2);
- $r = q("SELECT * FROM channel left join account on account_id = channel_account_id WHERE channel_guid = '%s' AND account_flags = 0 LIMIT 1",
- dbesc($guid)
+ // Diaspora sites *may* provide a truncated guid.
+
+ $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND NOT (channel_pageflags & %d ) LIMIT 1",
+ dbesc($guid . '%'),
+ intval(PAGE_REMOVED)
);
if(! $r)
http_status_exit(500);
diff --git a/mod/xrd.php b/mod/xrd.php
index 4d6a530e4..d059bec9b 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -22,7 +22,20 @@ function xrd_init(&$a) {
if(! $r)
killme();
-// $salmon_key = salmon_key($r[0]['pubkey']);
+ if(get_config('system','diaspora_enabled')) {
+ $tpl = get_markup_template('xrd_diaspora.tpl');
+ $dspr = replace_macros($tpl,array(
+ '$baseurl' => $a->get_baseurl(),
+ '$dspr_guid' => $r[0]['channel_guid'],
+ '$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))
+ ));
+ }
+ else
+ $dspr = '';
+
+
+
+ $salmon_key = salmon_key($r[0]['channel_pubkey']);
header('Access-Control-Allow-Origin: *');
header("Content-type: text/xml");
@@ -34,15 +47,15 @@ function xrd_init(&$a) {
'$nick' => $r[0]['channel_address'],
'$accturi' => $uri,
'$profile_url' => $a->get_baseurl() . '/channel/' . $r[0]['channel_address'],
-// '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['channel_address'],
+ '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['channel_address'],
'$atom' => $a->get_baseurl() . '/feed/' . $r[0]['channel_address'],
'$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['channel_address'],
'$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['channel_address'],
'$photo' => $a->get_baseurl() . '/photo/profile/l/' . $r[0]['channel_id'],
-// '$dspr' => $dspr,
+ '$dspr' => $dspr,
// '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'],
// '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['channel_address'] . '/mention',
-// '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
+ '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
// '$bigkey' => salmon_key($r[0]['pubkey'])
));
diff --git a/view/tpl/diaspora_vcard.tpl b/view/tpl/diaspora_vcard.tpl
new file mode 100644
index 000000000..9d234a398
--- /dev/null
+++ b/view/tpl/diaspora_vcard.tpl
@@ -0,0 +1,57 @@
+<div style="display:none;">
+ <dl class='entity_nickname'>
+ <dt>Nickname</dt>
+ <dd>
+ <a class="nickname url uid" href="{{$diaspora.podloc}}/" rel="me">{{$diaspora.nickname}}</a>
+ </dd>
+ </dl>
+ <dl class='entity_fn'>
+ <dt>Full name</dt>
+ <dd>
+ <span class='fn'>{{$diaspora.fullname}}</span>
+ </dd>
+ </dl>
+
+ <dl class='entity_given_name'>
+ <dt>First name</dt>
+ <dd>
+ <span class='given_name'>{{$diaspora.firstname}}</span>
+ </dd>
+ </dl>
+ <dl class='entity_family_name'>
+ <dt>Family name</dt>
+ <dd>
+ <span class='family_name'>{{$diaspora.lastname}}</span>
+ </dd>
+ </dl>
+ <dl class="entity_url">
+ <dt>URL</dt>
+ <dd>
+ <a class="url" href="{{$diaspora.podloc}}/" id="pod_location" rel="me">{{$diaspora.podloc}}/</a>
+ </dd>
+ </dl>
+ <dl class="entity_photo">
+ <dt>Photo</dt>
+ <dd>
+ <img class="photo avatar" height="300" width="300" src="{{$diaspora.photo300}}">
+ </dd>
+ </dl>
+ <dl class="entity_photo_medium">
+ <dt>Photo</dt>
+ <dd>
+ <img class="photo avatar" height="100" width="100" src="{{$diaspora.photo100}}">
+ </dd>
+ </dl>
+ <dl class="entity_photo_small">
+ <dt>Photo</dt>
+ <dd>
+ <img class="photo avatar" height="50" width="50" src="{{$diaspora.photo50}}">
+ </dd>
+ </dl>
+ <dl class="entity_searchable">
+ <dt>Searchable</dt>
+ <dd>
+ <span class="searchable">{{$diaspora.searchable}}</span>
+ </dd>
+ </dl>
+</div>
diff --git a/view/tpl/profile_edit.tpl b/view/tpl/profile_edit.tpl
index 87582da56..b453b1cfa 100755
--- a/view/tpl/profile_edit.tpl
+++ b/view/tpl/profile_edit.tpl
@@ -9,12 +9,12 @@
<div id="profile-edit-links">
<span class="btn btn-default"><a href="profile_photo" id="profile-photo_upload-link" title="{{$profpic}}">{{$profpic}}</a></span>
<span class="btn btn-default"><a href="profile/{{$profile_id}}/view" id="profile-edit-view-link" title="{{$viewprof}}">{{$viewprof}}</a></span>
-{{if ! $default}}<span class="btn btn-default"><a href="profperm/{{$profile_id}}" id="profile-edit-view-link" title="{{$editvis}}">{{$editvis}}</a></span>{{/if}}
+{{if ! $is_default}}<span class="btn btn-default"><a href="profperm/{{$profile_id}}" id="profile-edit-view-link" title="{{$editvis}}">{{$editvis}}</a></span>{{/if}}
{{if $profile_clone_link}}<span class="btn btn-default"><a href="{{$profile_clone_link}}" id="profile-edit-clone-link" title="{{$cr_prof}}">{{$cl_prof}}</a></span>{{/if}}
{{if $exportable}}<br /><span class="btn btn-default"><a href="profiles/export/{{$profile_id}}" target="_blank">{{$lbl_export}}</a></span>
<span class="btn btn-default profile-import"><b>{{$lbl_import}}</b> <input type="file" name="userfile" class="profile-import" ></span>
{{/if}}
-{{if ! $default}}<span class="btn btn-danger"><a href="{{$profile_drop_link}}" id="profile-edit-drop-link" title="{{$del_prof}}" onclick="return confirmDelete();" {{$disabled}} >{{$del_prof}}</a></span>{{/if}}
+{{if ! $is_default}}<span class="btn btn-danger"><a href="{{$profile_drop_link}}" id="profile-edit-drop-link" title="{{$del_prof}}" onclick="return confirmDelete();" {{$disabled}} >{{$del_prof}}</a></span>{{/if}}
</div>
diff --git a/view/tpl/profile_vcard.tpl b/view/tpl/profile_vcard.tpl
index a653dca7d..7dff8fdeb 100755
--- a/view/tpl/profile_vcard.tpl
+++ b/view/tpl/profile_vcard.tpl
@@ -43,6 +43,9 @@
{{if $homepage}}<dl class="homepage"><dt class="homepage-label">{{$homepage}}</dt><dd class="homepage-url"><a href="{{$profile.homepage}}" >{{$profile.homepage}}</a></dd></dl>{{/if}}
+ {{if $diaspora}}
+ {{include file="diaspora_vcard.tpl"}}
+ {{/if}}
{{if $connect}}
<a href="{{$connect_url}}" class="rconnect"><i class="icon-plus connect-icon"></i> {{$connect}}</a>
diff --git a/view/tpl/xrd_diaspora.tpl b/view/tpl/xrd_diaspora.tpl
new file mode 100644
index 000000000..143980bcc
--- /dev/null
+++ b/view/tpl/xrd_diaspora.tpl
@@ -0,0 +1,8 @@
+{{*
+ * AUTOMATICALLY GENERATED TEMPLATE
+ * DO NOT EDIT THIS FILE, CHANGES WILL BE OVERWRITTEN
+ *
+ *}}
+ <Link rel="http://joindiaspora.com/seed_location" type="text/html" href="{{$baseurl}}/" />
+ <Link rel="http://joindiaspora.com/guid" type="text/html" href="{{$dspr_guid}}" />
+ <Link rel="diaspora-public-key" type="RSA" href="{{$dspr_key}}" />
diff --git a/view/tpl/xrd_person.tpl b/view/tpl/xrd_person.tpl
index 20d438dd5..631ed3f18 100755
--- a/view/tpl/xrd_person.tpl
+++ b/view/tpl/xrd_person.tpl
@@ -14,5 +14,13 @@
<Link rel="http://webfinger.net/rel/avatar"
type="image/jpeg"
href="{{$photo}}" />
-
+ <Link rel="http://microformats.org/profile/hcard"
+ type="text/html"
+ href="{{$hcard_url}}" />
+
+ <Link rel="magic-public-key"
+ href="{{$modexp}}" />
+
+ {{$dspr}}
+
</XRD>