aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-09-26 11:42:48 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2011-09-26 11:42:48 +0200
commit5792b3d3580b9f09460305858293398d8d8a9abf (patch)
tree90d60e9db4ed733a60c2890c7305d45ddd48be42 /include
parent991656a3ef396d9a6bd43ddb752627c2880b17ba (diff)
parent428e6766411d2c6708ad25f726c4bcf1d64af1cc (diff)
downloadvolse-hubzilla-5792b3d3580b9f09460305858293398d8d8a9abf.tar.gz
volse-hubzilla-5792b3d3580b9f09460305858293398d8d8a9abf.tar.bz2
volse-hubzilla-5792b3d3580b9f09460305858293398d8d8a9abf.zip
Merge branch 'master' into newui
Diffstat (limited to 'include')
-rw-r--r--include/EmailNotification.php7
-rw-r--r--include/Scrape.php22
-rw-r--r--include/api.php2
-rw-r--r--include/auth.php4
-rw-r--r--include/bb2diaspora.php27
-rw-r--r--include/bbcode.php15
-rw-r--r--include/conversation.php29
-rw-r--r--include/delivery.php147
-rw-r--r--include/diaspora.php311
-rw-r--r--include/email.php15
-rw-r--r--include/group.php30
-rw-r--r--include/items.php18
-rw-r--r--include/network.php73
-rw-r--r--include/notifier.php33
-rw-r--r--include/pgettext.php23
-rw-r--r--include/poller.php17
-rw-r--r--include/profile_advanced.php76
-rw-r--r--include/queue.php3
-rw-r--r--include/template_processor.php20
-rw-r--r--include/text.php66
20 files changed, 610 insertions, 328 deletions
diff --git a/include/EmailNotification.php b/include/EmailNotification.php
index 78912c0b9..8861e8f5d 100644
--- a/include/EmailNotification.php
+++ b/include/EmailNotification.php
@@ -1,4 +1,7 @@
<?php
+
+require_once('include/email.php');
+
class EmailNotification {
/**
* Send a multipart/alternative message with Text and HTML versions
@@ -12,6 +15,10 @@ class EmailNotification {
* @param textVersion text only version of the message
*/
static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
+
+ $fromName = email_header_encode($fromName,'UTF-8');
+ $messageSubject = email_header_encode($messageSubject,'UTF-8');
+
// generate a mime boundary
$mimeBoundary =rand(0,9)."-"
diff --git a/include/Scrape.php b/include/Scrape.php
index 58468a40d..2af02fff5 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -249,20 +249,6 @@ function scrape_feed($url) {
return $ret;
- $items = $dom->getElementsByTagName('img');
-
- // get img elements (twitter)
-
- if($items) {
- foreach($items as $item) {
- $x = $item->getAttribute('id');
- if($x === 'profile-image') {
- $ret['photo'] = $item->getAttribute('src');
- }
- }
- }
-
-
$head = $dom->getElementsByTagName('base');
if($head) {
foreach($head as $head0) {
@@ -496,8 +482,10 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if($diaspora && $diaspora_base && $diaspora_guid) {
- if($mode == PROBE_DIASPORA || ! $notify)
+ if($mode == PROBE_DIASPORA || ! $notify) {
$notify = $diaspora_base . 'receive/users/' . $diaspora_guid;
+ $batch = $diaspora_base . 'receive/public' ;
+ }
if(strpos($url,'@'))
$addr = str_replace('acct:', '', $url);
}
@@ -532,6 +520,9 @@ function probe_url($url, $mode = PROBE_NORMAL) {
else
$poll = $tapi . '?screen_name=' . $tid;
$profile = 'http://twitter.com/#!/' . $tid;
+ $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid;
+ $vcard['nick'] = $tid;
+ $vcard['fn'] = $tid . '@twitter';
}
if(! x($vcard,'fn'))
@@ -675,6 +666,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$result['nick'] = $vcard['nick'];
$result['url'] = $profile;
$result['addr'] = $addr;
+ $result['batch'] = $batch;
$result['notify'] = $notify;
$result['poll'] = $poll;
$result['request'] = $request;
diff --git a/include/api.php b/include/api.php
index 5d008c290..74b4aaf6e 100644
--- a/include/api.php
+++ b/include/api.php
@@ -55,7 +55,7 @@
// process normal login request
$r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
dbesc(trim($user)),
dbesc(trim($user)),
dbesc($encrypted)
diff --git a/include/auth.php b/include/auth.php
index b7b96bdc0..1f16b3504 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -49,7 +49,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
}
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
- FROM `user` WHERE `uid` = %d LIMIT 1",
+ FROM `user` WHERE `uid` = %d AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
intval($_SESSION['uid'])
);
@@ -186,7 +186,7 @@ else {
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
dbesc(trim($_POST['openid_url'])),
dbesc(trim($_POST['openid_url'])),
dbesc($encrypted)
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 5b240bdd2..c72c78445 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -3,30 +3,18 @@
require_once("include/oembed.php");
require_once('include/event.php');
-
-
+require_once('library/markdown.php');
+require_once('include/html2bbcode.php');
function diaspora2bb($s) {
- // bug #127
- $s = preg_replace('/\[(.+?)\]\((.+?)[^\\\]_(.+?)\)/','[$1]($2\\_$3)',$s);
-
-
- $s = str_replace(array('\\**','\\__','\\*','\\_'), array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'),$s);
- $s = preg_replace("/\*\*\*(.+?)\*\*\*/", '[b][i]$1[/i][/b]', $s);
- $s = preg_replace("/\_\_\_(.+?)\_\_\_/", '[b][i]$1[/i][/b]', $s);
- $s = preg_replace("/\*\*(.+?)\*\*/", '[b]$1[/b]', $s);
- $s = preg_replace("/\_\_(.+?)\_\_/", '[b]$1[/b]', $s);
- $s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s);
- $s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s);
-
- $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s);
- $s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s);
- $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s);
$s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s);
+ $s = Markdown($s);
+ $s = html2bbcode($s);
+// $s = preg_replace('/\[url=(.+?)\<em\>(.+?)\]/ism','[url=$1_$2]',$s);
+// $s = preg_replace('/\[url=(.+?)\<\/em\>(.+?)\]/ism','[url=$1_$2]',$s);
- $s = escape_tags($s);
return $s;
}
@@ -188,8 +176,7 @@ function bb2diaspora($Text,$preserve_nl = false) {
$Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
- $Text = preg_replace('/\[(.*?)\\\\_(.*?)\]\((.*?)\)/ism','[$1_$2]($3)',$Text);
- $Text = preg_replace('/\[(.*?)\\\\\*(.*?)\]\((.*?)\)/ism','[$1*$2]($3)',$Text);
+ $Text = preg_replace('/\[(.*?)\]\((.*?)\\\\_(.*?)\)/ism','[$1]($2_$3)',$Text);
call_hooks('bb2diaspora',$Text);
diff --git a/include/bbcode.php b/include/bbcode.php
index 3886af37d..9abc7c439 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -43,11 +43,11 @@ function bbcode($Text,$preserve_nl = false) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/", '$1<a href="$2" target="external-link">$2</a>', $Text);
+ $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1<a href="$2" target="external-link">$2</a>', $Text);
- $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/m", '<a href="$1" target="external-link">$1</a>', $Text);
- $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/m", '<a href="$1" target="external-link">$2</a>', $Text);
- //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/m", '<a href="$1" target="_blank">$2</a>', $Text);
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="external-link">$1</a>', $Text);
+ $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="external-link">$2</a>', $Text);
+ //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
// Perform MAIL Search
@@ -95,7 +95,7 @@ function bbcode($Text,$preserve_nl = false) {
// $Text = str_replace("[*]", "<li>", $Text);
// Check for font change text
- $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/m","<span style=\"font-family: $1;\">$2</span>",$Text);
+ $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/sm","<span style=\"font-family: $1;\">$2</span>",$Text);
// Declare the format for [code] layout
@@ -113,6 +113,9 @@ function bbcode($Text,$preserve_nl = false) {
// Check for [quote] text
$Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism","$QuoteLayout", $Text);
+ // [img=widthxheight]image source[/img]
+ $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height: $2px; width: $1px;" >', $Text);
+
// Images
// [img]pathtoimage[/img]
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
@@ -125,8 +128,6 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text);
- // [img=widthxheight]image source[/img]
- $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text);
if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
// use oembed for youtube links
diff --git a/include/conversation.php b/include/conversation.php
index aeb30177f..10d9bad2c 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -211,21 +211,21 @@ function conversation(&$a, $items, $mode, $update) {
$o .= replace_macros($tpl,array(
'$id' => $item['item_id'],
- '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
+ '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
- '$name' => $profile_name,
+ '$name' => template_escape($profile_name),
'$sparkle' => $sparkle,
'$lock' => $lock,
'$thumb' => $profile_avatar,
- '$title' => $item['title'],
- '$body' => $body,
+ '$title' => template_escape($item['title']),
+ '$body' => template_escape($body),
'$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
- '$location' => $location,
+ '$location' => template_escape($location),
'$indent' => '',
'$owner_url' => $owner_url,
'$owner_photo' => $owner_photo,
- '$owner_name' => $owner_name,
+ '$owner_name' => template_escape($owner_name),
'$star' => $star,
'$drop' => $drop,
'$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'] . '">' . t('View in context') . '</a>'
@@ -505,27 +505,27 @@ function conversation(&$a, $items, $mode, $update) {
$tmp_item = replace_macros($template,array(
+ '$body' => template_escape($body),
'$id' => $item['item_id'],
- '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
- '$olinktitle' => sprintf( t('View %s\'s profile'), $owner_name),
+ '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
+ '$olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])),
'$to' => t('to'),
'$wall' => t('Wall-to-Wall'),
'$vwall' => t('via Wall-To-Wall:'),
'$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item),
- '$name' => $profile_name,
+ '$name' => template_escape($profile_name),
'$thumb' => $profile_avatar,
'$osparkle' => $osparkle,
'$sparkle' => $sparkle,
- '$title' => $item['title'],
- '$body' => $body,
+ '$title' => template_escape($item['title']),
'$ago' => ((($item['app']) && ($item['id'] == $item['parent'])) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])),
'$lock' => $lock,
- '$location' => $location,
+ '$location' => template_escape($location),
'$indent' => $indent,
'$owner_url' => $owner_url,
'$owner_photo' => $owner_photo,
- '$owner_name' => $owner_name,
+ '$owner_name' => template_escape($owner_name),
'$plink' => get_plink($item),
'$edpost' => $edpost,
'$isstarred' => $isstarred,
@@ -535,6 +535,7 @@ function conversation(&$a, $items, $mode, $update) {
'$like' => $like,
'$dislike' => $dislike,
'$comment' => $comment
+
));
@@ -755,7 +756,7 @@ function status_editor($a,$x, $notes_cid = 0) {
if($mail_enabled) {
$selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
- $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . 'value="1" /> '
+ $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
. t("Post to Email") . '</div>';
}
diff --git a/include/delivery.php b/include/delivery.php
index 18ef09a31..706c07b3b 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -31,7 +31,7 @@ function delivery_run($argv, $argc){
$a->set_baseurl(get_config('system','url'));
- logger('delivery: invoked: ' . print_r($argv,true));
+ logger('delivery: invoked: ' . print_r($argv,true), LOGGER_DEBUG);
$cmd = $argv[1];
$item_id = intval($argv[2]);
@@ -145,6 +145,7 @@ function delivery_run($argv, $argc){
$public_message = true;
// fill this in with a single salmon slap if applicable
+
$slap = '';
require_once('include/group.php');
@@ -195,8 +196,6 @@ function delivery_run($argv, $argc){
$public_message = false; // private recipients, not public
}
- $conversant_str = intval($contact_id);
-
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `blocked` = 0 AND `pending` = 0",
intval($contact_id)
);
@@ -204,62 +203,10 @@ function delivery_run($argv, $argc){
if(count($r))
$contact = $r[0];
-
- $feed_template = get_markup_template('atom_feed.tpl');
- $mail_template = get_markup_template('atom_mail.tpl');
-
- $atom = '';
- $slaps = array();
-
$hubxml = feed_hublinks();
- $birthday = feed_birthday($owner['uid'],$owner['timezone']);
-
- if(strlen($birthday))
- $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
-
- $atom .= replace_macros($feed_template, array(
- '$version' => xmlify(FRIENDIKA_VERSION),
- '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
- '$feed_title' => xmlify($owner['name']),
- '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
- '$hub' => $hubxml,
- '$salmon' => '', // private feed, we don't use salmon here
- '$name' => xmlify($owner['name']),
- '$profile_page' => xmlify($owner['url']),
- '$photo' => xmlify($owner['photo']),
- '$thumb' => xmlify($owner['thumb']),
- '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
- '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) ,
- '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) ,
- '$birthday' => $birthday
- ));
-
- foreach($items as $item) {
- if(! $item['parent'])
- continue;
-
- // private emails may be in included in public conversations. Filter them.
- if(($public_message) && $item['private'])
- continue;
-
- $item_contact = get_item_contact($item,$icontacts);
- if(! $item_contact)
- continue;
-
- $atom .= atom_entry($item,'text',$item_contact,$owner,true);
-
- if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
- $slaps[] = atom_entry($item,'html',$item_contact,$owner,true);
- }
-
- $atom .= '</feed>' . "\r\n";
-
- logger('notifier: ' . $atom, LOGGER_DATA);
-
logger('notifier: slaps: ' . print_r($slaps,true), LOGGER_DATA);
-
require_once('include/salmon.php');
if($contact['self'])
@@ -271,6 +218,55 @@ function delivery_run($argv, $argc){
case NETWORK_DFRN :
logger('notifier: dfrndelivery: ' . $contact['name']);
+
+ $feed_template = get_markup_template('atom_feed.tpl');
+ $mail_template = get_markup_template('atom_mail.tpl');
+
+ $atom = '';
+
+
+ $birthday = feed_birthday($owner['uid'],$owner['timezone']);
+
+ if(strlen($birthday))
+ $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>';
+
+ $atom .= replace_macros($feed_template, array(
+ '$version' => xmlify(FRIENDIKA_VERSION),
+ '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
+ '$feed_title' => xmlify($owner['name']),
+ '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
+ '$hub' => $hubxml,
+ '$salmon' => '', // private feed, we don't use salmon here
+ '$name' => xmlify($owner['name']),
+ '$profile_page' => xmlify($owner['url']),
+ '$photo' => xmlify($owner['photo']),
+ '$thumb' => xmlify($owner['thumb']),
+ '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
+ '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , ATOM_TIME)) ,
+ '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , ATOM_TIME)) ,
+ '$birthday' => $birthday
+ ));
+
+ foreach($items as $item) {
+ if(! $item['parent'])
+ continue;
+
+ // private emails may be in included in public conversations. Filter them.
+ if(($public_message) && $item['private'])
+ continue;
+
+ $item_contact = get_item_contact($item,$icontacts);
+ if(! $item_contact)
+ continue;
+
+ $atom .= atom_entry($item,'text',$item_contact,$owner,true);
+
+ }
+
+ $atom .= '</feed>' . "\r\n";
+
+ logger('notifier: ' . $atom, LOGGER_DATA);
+
$deliver_status = dfrn_deliver($owner,$contact,$atom);
logger('notifier: dfrn_delivery returns ' . $deliver_status);
@@ -299,7 +295,25 @@ function delivery_run($argv, $argc){
// only send salmon if public - e.g. if it's ok to notify
// a public hub, it's ok to send a salmon
- if((count($slaps)) && ($public_message) && (! $expire)) {
+ if(($public_message) && (! $expire)) {
+ $slaps = array();
+
+ foreach($items as $item) {
+ if(! $item['parent'])
+ continue;
+
+ // private emails may be in included in public conversations. Filter them.
+ if(($public_message) && $item['private'])
+ continue;
+
+ $item_contact = get_item_contact($item,$icontacts);
+ if(! $item_contact)
+ continue;
+
+ if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
+ $slaps[] = atom_entry($item,'html',$item_contact,$owner,true);
+ }
+
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
@@ -393,12 +407,17 @@ function delivery_run($argv, $argc){
break;
case NETWORK_DIASPORA :
- logger('delivery: diaspora deliver: ' . $contact['name']);
+ if($public_message)
+ $loc = 'public batch ' . $contact['batch'];
+ else
+ $loc = $contact['name'];
+
+ logger('delivery: diaspora batch deliver: ' . $loc);
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
- if(! $contact['pubkey'])
+ if((! $contact['pubkey']) && (! $public_message))
break;
if($target_item['verb'] === ACTIVITY_DISLIKE) {
@@ -406,23 +425,23 @@ function delivery_run($argv, $argc){
break;
}
elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
- logger('delivery: diaspora retract: ' . $contact['name']);
+ logger('delivery: diaspora retract: ' . $loc);
// diaspora delete,
- diaspora_send_retraction($target_item,$owner,$contact);
+ diaspora_send_retraction($target_item,$owner,$contact,$public_message);
break;
}
elseif($target_item['parent'] != $target_item['id']) {
- logger('delivery: diaspora relay: ' . $contact['name']);
+ logger('delivery: diaspora relay: ' . $loc);
// we are the relay - send comments, likes and unlikes to our conversants
- diaspora_send_relay($target_item,$owner,$contact);
+ diaspora_send_relay($target_item,$owner,$contact,$public_message);
break;
}
elseif(($top_level) && (! $walltowall)) {
// currently no workable solution for sending walltowall
- logger('delivery: diaspora status: ' . $contact['name']);
- diaspora_send_status($target_item,$owner,$contact);
+ logger('delivery: diaspora status: ' . $loc);
+ diaspora_send_status($target_item,$owner,$contact,$public_message);
break;
}
diff --git a/include/diaspora.php b/include/diaspora.php
index 6d070ecba..80fbff8d6 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -5,34 +5,55 @@ require_once('include/items.php');
require_once('include/bb2diaspora.php');
require_once('include/contact_selectors.php');
+
+function diaspora_dispatch_public($msg) {
+
+ $r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ",
+ dbesc(NETWORK_DIASPORA),
+ dbesc($msg['author'])
+ );
+ if(count($r)) {
+ foreach($r as $rr) {
+ logger('diaspora_public: delivering to: ' . $rr['username']);
+ diaspora_dispatch($rr,$msg);
+ }
+ }
+ else
+ logger('diaspora_public: no subscribers');
+}
+
+
+
function diaspora_dispatch($importer,$msg) {
+ $ret = 0;
+
$parsed_xml = parse_xml_string($msg['message'],false);
$xmlbase = $parsed_xml->post;
if($xmlbase->request) {
- diaspora_request($importer,$xmlbase->request);
+ $ret = diaspora_request($importer,$xmlbase->request);
}
elseif($xmlbase->status_message) {
- diaspora_post($importer,$xmlbase->status_message);
+ $ret = diaspora_post($importer,$xmlbase->status_message);
}
elseif($xmlbase->comment) {
- diaspora_comment($importer,$xmlbase->comment,$msg);
+ $ret = diaspora_comment($importer,$xmlbase->comment,$msg);
}
elseif($xmlbase->like) {
- diaspora_like($importer,$xmlbase->like,$msg);
+ $ret = diaspora_like($importer,$xmlbase->like,$msg);
}
elseif($xmlbase->retraction) {
- diaspora_retraction($importer,$xmlbase->retraction,$msg);
+ $ret = diaspora_retraction($importer,$xmlbase->retraction,$msg);
}
elseif($xmlbase->photo) {
- diaspora_photo($importer,$xmlbase->photo,$msg);
+ $ret = diaspora_photo($importer,$xmlbase->photo,$msg);
}
else {
logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase,true));
}
- return;
+ return $ret;
}
function diaspora_get_contact_by_handle($uid,$handle) {
@@ -47,6 +68,7 @@ function diaspora_get_contact_by_handle($uid,$handle) {
}
function find_diaspora_person_by_handle($handle) {
+ $update = false;
$r = q("select * from fcontact where network = '%s' and addr = '%s' limit 1",
dbesc(NETWORK_DIASPORA),
dbesc($handle)
@@ -54,18 +76,14 @@ function find_diaspora_person_by_handle($handle) {
if(count($r)) {
// update record occasionally so it doesn't get stale
$d = strtotime($r[0]['updated'] . ' +00:00');
- if($d < strtotime('now - 14 days')) {
- q("delete from fcontact where id = %d limit 1",
- intval($r[0]['id'])
- );
- }
- else
+ if($d > strtotime('now - 14 days'))
return $r[0];
+ $update = true;
}
require_once('include/Scrape.php');
$r = probe_url($handle, PROBE_DIASPORA);
if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) {
- add_fcontact($r);
+ add_fcontact($r,$update);
return ($r);
}
return false;
@@ -82,9 +100,60 @@ function get_diaspora_key($uri) {
}
-function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
+function diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey) {
$a = get_app();
+ logger('diaspora_pubmsg_build: ' . $msg, LOGGER_DATA);
+
+
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+// $b64_data = base64_encode($msg);
+// $b64url_data = base64url_encode($b64_data);
+
+ $b64url_data = base64url_encode($msg);
+
+ $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
+
+ $type = 'application/xml';
+ $encoding = 'base64url';
+ $alg = 'RSA-SHA256';
+
+ $signable_data = $data . '.' . base64url_encode($type) . '.'
+ . base64url_encode($encoding) . '.' . base64url_encode($alg) ;
+
+ $signature = rsa_sign($signable_data,$prvkey);
+ $sig = base64url_encode($signature);
+
+$magic_env = <<< EOT
+<?xml version='1.0' encoding='UTF-8'?>
+<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
+ <header>
+ <author_id>$handle</author_id>
+ </header>
+ <me:env>
+ <me:encoding>base64url</me:encoding>
+ <me:alg>RSA-SHA256</me:alg>
+ <me:data type="application/xml">$data</me:data>
+ <me:sig>$sig</me:sig>
+ </me:env>
+</diaspora>
+EOT;
+
+ logger('diaspora_pubmsg_build: magic_env: ' . $magic_env, LOGGER_DATA);
+ return $magic_env;
+
+}
+
+
+
+
+function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey,$public = false) {
+ $a = get_app();
+
+ if($public)
+ return diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey);
+
logger('diaspora_msg_build: ' . $msg, LOGGER_DATA);
$inner_aes_key = random_string(32);
@@ -97,7 +166,7 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$outer_iv = random_string(16);
$b_outer_iv = base64_encode($outer_iv);
- $handle = 'acct:' . $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
$padded_data = pkcs5_pad($msg,16);
$inner_encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $padded_data, MCRYPT_MODE_CBC, $inner_iv);
@@ -106,16 +175,14 @@ function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$b64url_data = base64url_encode($b64_data);
- $b64url_stripped = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
- $lines = str_split($b64url_stripped,60);
- $data = implode("\n",$lines);
- $data = $data . (($data[-1] != "\n") ? "\n" : '') ;
- $type = 'application/atom+xml';
+ $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
+
+ $type = 'application/xml';
$encoding = 'base64url';
$alg = 'RSA-SHA256';
- $signable_data = $data . '.' . base64url_encode($type) . "\n" . '.'
- . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
+ $signable_data = $data . '.' . base64url_encode($type) . '.'
+ . base64url_encode($encoding) . '.' . base64url_encode($alg) ;
$signature = rsa_sign($signable_data,$prvkey);
$sig = base64url_encode($signature);
@@ -124,10 +191,7 @@ $decrypted_header = <<< EOT
<decrypted_header>
<iv>$b_inner_iv</iv>
<aes_key>$b_inner_aes_key</aes_key>
- <author>
- <name>{$user['username']}</name>
- <uri>$handle</uri>
- </author>
+ <author_id>$handle</author_id>
</decrypted_header>
EOT;
@@ -152,15 +216,15 @@ EOT;
$magic_env = <<< EOT
<?xml version='1.0' encoding='UTF-8'?>
-<entry xmlns='http://www.w3.org/2005/Atom'>
+<diaspora xmlns="https://joindiaspora.com/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
$encrypted_header
- <me:env xmlns:me="http://salmon-protocol.org/ns/magic-env">
+ <me:env>
<me:encoding>base64url</me:encoding>
<me:alg>RSA-SHA256</me:alg>
- <me:data type="application/atom+xml">$data</me:data>
+ <me:data type="application/xml">$data</me:data>
<me:sig>$sig</me:sig>
</me:env>
-</entry>
+</diaspora>
EOT;
logger('diaspora_msg_build: magic_env: ' . $magic_env, LOGGER_DATA);
@@ -185,50 +249,67 @@ EOT;
function diaspora_decode($importer,$xml) {
+ $public = false;
$basedom = parse_xml_string($xml);
- $atom = $basedom->children(NAMESPACE_ATOM1);
+ $children = $basedom->children('https://joindiaspora.com/protocol');
- // Diaspora devs: This is kind of sucky - 'encrypted_header' does not belong in the atom namespace
+ if($children->header) {
+ $public = true;
+ $author_link = str_replace('acct:','',$children->header->author_id);
+ }
+ else {
- $encrypted_header = json_decode(base64_decode($atom->encrypted_header));
+ $encrypted_header = json_decode(base64_decode($children->encrypted_header));
- $encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
- $ciphertext = base64_decode($encrypted_header->ciphertext);
+ $encrypted_aes_key_bundle = base64_decode($encrypted_header->aes_key);
+ $ciphertext = base64_decode($encrypted_header->ciphertext);
+
+ $outer_key_bundle = '';
+ openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
+
+ $j_outer_key_bundle = json_decode($outer_key_bundle);
+
+ $outer_iv = base64_decode($j_outer_key_bundle->iv);
+ $outer_key = base64_decode($j_outer_key_bundle->key);
+
+ $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv);
- $outer_key_bundle = '';
- openssl_private_decrypt($encrypted_aes_key_bundle,$outer_key_bundle,$importer['prvkey']);
- $j_outer_key_bundle = json_decode($outer_key_bundle);
+ $decrypted = pkcs5_unpad($decrypted);
- $outer_iv = base64_decode($j_outer_key_bundle->iv);
- $outer_key = base64_decode($j_outer_key_bundle->key);
+ /**
+ * $decrypted now contains something like
+ *
+ * <decrypted_header>
+ * <iv>8e+G2+ET8l5BPuW0sVTnQw==</iv>
+ * <aes_key>UvSMb4puPeB14STkcDWq+4QE302Edu15oaprAQSkLKU=</aes_key>
- $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $outer_key, $ciphertext, MCRYPT_MODE_CBC, $outer_iv);
+***** OBSOLETE
+ * <author>
+ * <name>Ryan Hughes</name>
+ * <uri>acct:galaxor@diaspora.pirateship.org</uri>
+ * </author>
- $decrypted = pkcs5_unpad($decrypted);
+***** CURRENT
- /**
- * $decrypted now contains something like
- *
- * <decrypted_header>
- * <iv>8e+G2+ET8l5BPuW0sVTnQw==</iv>
- * <aes_key>UvSMb4puPeB14STkcDWq+4QE302Edu15oaprAQSkLKU=</aes_key>
- * <author>
- * <name>Ryan Hughes</name>
- * <uri>acct:galaxor@diaspora.pirateship.org</uri>
- * </author>
- * </decrypted_header>
- */
+ * <author_id>galaxor@diaspora.priateship.org</author_id>
- logger('decrypted: ' . $decrypted, LOGGER_DEBUG);
- $idom = parse_xml_string($decrypted,false);
+***** END DIFFS
- $inner_iv = base64_decode($idom->iv);
- $inner_aes_key = base64_decode($idom->aes_key);
+ * </decrypted_header>
+ */
- $author_link = str_replace('acct:','',$idom->author->uri);
+ logger('decrypted: ' . $decrypted, LOGGER_DEBUG);
+ $idom = parse_xml_string($decrypted,false);
+
+ $inner_iv = base64_decode($idom->iv);
+ $inner_aes_key = base64_decode($idom->aes_key);
+
+ $author_link = str_replace('acct:','',$idom->author_id);
+
+ }
$dom = $basedom->children(NAMESPACE_SALMON_ME);
@@ -255,16 +336,6 @@ function diaspora_decode($importer,$xml) {
// strip whitespace so our data element will return to one big base64 blob
$data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data);
- // Add back the 60 char linefeeds
-
- // This completely violates the entire principle of salmon magic signatures,
- // which was to have a message signing format that was completely ambivalent to linefeeds
- // and transport whitespace mangling, and base64 wrapping rules. Guess what? PHP and Ruby
- // use different linelengths for base64 output.
-
- $lines = str_split($data,60);
- $data = implode("\n",$lines);
-
// stash away some other stuff for later
@@ -273,22 +344,25 @@ function diaspora_decode($importer,$xml) {
$encoding = $base->encoding;
$alg = $base->alg;
- // I can't even begin to tell you how sucky this is. Please read the spec.
- $signed_data = $data . (($data[-1] != "\n") ? "\n" : '') . '.' . base64url_encode($type) . "\n" . '.' . base64url_encode($encoding) . "\n" . '.' . base64url_encode($alg) . "\n";
+ $signed_data = $data . '.' . base64url_encode($type) . '.' . base64url_encode($encoding) . '.' . base64url_encode($alg);
// decode the data
$data = base64url_decode($data);
- // Now pull out the inner encrypted blob
- $inner_encrypted = base64_decode($data);
+ if($public) {
+ $inner_decrypted = $data;
+ }
+ else {
- $inner_decrypted =
- $inner_decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $inner_encrypted, MCRYPT_MODE_CBC, $inner_iv);
+ // Decode the encrypted blob
- $inner_decrypted = pkcs5_unpad($inner_decrypted);
+ $inner_encrypted = base64_decode($data);
+ $inner_decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $inner_aes_key, $inner_encrypted, MCRYPT_MODE_CBC, $inner_iv);
+ $inner_decrypted = pkcs5_unpad($inner_decrypted);
+ }
if(! $author_link) {
logger('mod-diaspora: Could not retrieve author URI.');
@@ -321,7 +395,6 @@ function diaspora_decode($importer,$xml) {
}
-
function diaspora_request($importer,$xml) {
$sender_handle = unxmlify($xml->sender_handle);
@@ -332,7 +405,6 @@ function diaspora_request($importer,$xml) {
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
-
if($contact) {
// perhaps we were already sharing with this person. Now they're sharing with us.
@@ -357,13 +429,16 @@ function diaspora_request($importer,$xml) {
return;
}
- $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
- VALUES ( %d, '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
+ $batch = (($ret['batch']) ? $ret['batch'] : implode('/', array_slice(explode('/',$ret['url']),0,3)) . '/receive/public');
+
+ $r = q("INSERT INTO `contact` (`uid`, `network`,`addr`,`created`,`url`,`batch`,`name`,`nick`,`photo`,`pubkey`,`notify`,`poll`,`blocked`,`priority`)
+ VALUES ( %d, '%s', '%s', '%s','%s','%s','%s','%s','%s','%s','%s','%s',%d,%d) ",
intval($importer['uid']),
dbesc($ret['network']),
dbesc($ret['addr']),
datetime_convert(),
dbesc($ret['url']),
+ dbesc($batch),
dbesc($ret['name']),
dbesc($ret['nick']),
dbesc($ret['photo']),
@@ -408,8 +483,7 @@ function diaspora_post($importer,$xml) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_post: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$message_id = $diaspora_handle . ':' . $guid;
@@ -493,8 +567,7 @@ function diaspora_comment($importer,$xml,$msg) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_comment: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -535,7 +608,7 @@ function diaspora_comment($importer,$xml,$msg) {
}
}
- if(! rsa_verify($author_signed_data,$author_signature,$key,'sha')) {
+ if(! rsa_verify($author_signed_data,$author_signature,$key,'sha256')) {
logger('diaspora_comment: verification failed.');
return;
}
@@ -548,7 +621,7 @@ function diaspora_comment($importer,$xml,$msg) {
$key = $msg['key'];
- if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha')) {
+ if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha256')) {
logger('diaspora_comment: owner verification failed.');
return;
}
@@ -633,8 +706,7 @@ function diaspora_photo($importer,$xml,$msg) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_photo: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -686,8 +758,7 @@ function diaspora_like($importer,$xml,$msg) {
if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
logger('diaspora_like: Ignoring this author.');
- http_status_exit(202);
- // NOTREACHED
+ return 202;
}
$r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
@@ -743,7 +814,7 @@ function diaspora_like($importer,$xml,$msg) {
}
}
- if(! rsa_verify($author_signed_data,$author_signature,$key,'sha')) {
+ if(! rsa_verify($author_signed_data,$author_signature,$key,'sha256')) {
logger('diaspora_like: verification failed.');
return;
}
@@ -756,7 +827,7 @@ function diaspora_like($importer,$xml,$msg) {
$key = $msg['key'];
- if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha')) {
+ if(! rsa_verify($owner_signed_data,$parent_author_signature,$key,'sha256')) {
logger('diaspora_like: owner verification failed.');
return;
}
@@ -877,7 +948,7 @@ function diaspora_retraction($importer,$xml) {
}
}
- http_exit_status(202);
+ return 202;
// NOTREACHED
}
@@ -917,7 +988,7 @@ function diaspora_unshare($me,$contact) {
-function diaspora_send_status($item,$owner,$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);
@@ -959,19 +1030,19 @@ function diaspora_send_status($item,$owner,$contact) {
logger('diaspora_send_status: ' . $owner['username'] . ' -> ' . $contact['name'] . ' base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- $return_code = diaspora_transmit($owner,$contact,$slap);
+ $return_code = diaspora_transmit($owner,$contact,$slap,$public_batch);
if(count($images)) {
- diaspora_send_images($item,$owner,$contact,$images);
+ diaspora_send_images($item,$owner,$contact,$images,$public_batch);
}
return $return_code;
}
-function diaspora_send_images($item,$owner,$contact,$images) {
+function diaspora_send_images($item,$owner,$contact,$images,$public_batch = false) {
$a = get_app();
if(! count($images))
return;
@@ -1003,14 +1074,14 @@ function diaspora_send_images($item,$owner,$contact,$images) {
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- diaspora_transmit($owner,$contact,$slap);
+ diaspora_transmit($owner,$contact,$slap,$public_batch);
}
}
-function diaspora_send_followup($item,$owner,$contact) {
+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);
@@ -1044,7 +1115,7 @@ function diaspora_send_followup($item,$owner,$contact) {
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -1058,13 +1129,13 @@ function diaspora_send_followup($item,$owner,$contact) {
logger('diaspora_followup: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_send_relay($item,$owner,$contact) {
+function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$a = get_app();
@@ -1131,7 +1202,7 @@ function diaspora_send_relay($item,$owner,$contact) {
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($item['id']),
@@ -1145,7 +1216,7 @@ function diaspora_send_relay($item,$owner,$contact) {
// sign it
- $parentauthorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
+ $parentauthorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha256'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -1160,15 +1231,15 @@ function diaspora_send_relay($item,$owner,$contact) {
logger('diaspora_relay_comment: base message: ' . $msg, LOGGER_DATA);
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_send_retraction($item,$owner,$contact) {
+function diaspora_send_retraction($item,$owner,$contact,$public_batch = false) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
@@ -1180,30 +1251,32 @@ function diaspora_send_retraction($item,$owner,$contact) {
'$handle' => $myaddr
));
- $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'],$public_batch)));
- return(diaspora_transmit($owner,$contact,$slap));
+ return(diaspora_transmit($owner,$contact,$slap,$public_batch));
}
-function diaspora_transmit($owner,$contact,$slap) {
+function diaspora_transmit($owner,$contact,$slap,$public_batch) {
$a = get_app();
-
- post_url($contact['notify'] . '/',$slap);
+ $logid = random_string(4);
+ logger('diaspora_transmit: ' . $logid . ' ' . (($public_batch) ? $contact['batch'] : $contact['notify']));
+ post_url((($public_batch) ? $contact['batch'] : $contact['notify']) . '/',$slap);
$return_code = $a->get_curl_code();
- logger('diaspora_transmit: returns: ' . $return_code);
+ logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code);
if(! $return_code) {
logger('diaspora_transmit: queue message');
// queue message for redelivery
- q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
+ q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`,`batch`)
VALUES ( %d, '%s', '%s', '%s') ",
intval($contact['id']),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
- dbesc($slap)
+ dbesc($slap),
+ intval($public_batch)
);
}
diff --git a/include/email.php b/include/email.php
index a36d9adab..3e6a8186d 100644
--- a/include/email.php
+++ b/include/email.php
@@ -169,6 +169,17 @@ function email_get_part($mbox,$uid,$p,$partno) {
function email_header_encode($in_str, $charset) {
$out_str = $in_str;
+ $need_to_convert = false;
+
+ for($x = 0; $x < strlen($in_str); $x ++) {
+ if((ord($in_str[$x]) == 0) || ((ord($in_str[$x]) > 128))) {
+ $need_to_convert = true;
+ }
+ }
+
+ if(! $need_to_convert)
+ return $in_str;
+
if ($out_str && $charset) {
// define start delimimter, end delimiter and spacer
@@ -205,4 +216,6 @@ function email_header_encode($in_str, $charset) {
$out_str = $start . $out_str . $end;
}
return $out_str;
-} \ No newline at end of file
+}
+
+
diff --git a/include/group.php b/include/group.php
index d92e24e20..e3c7d33d4 100644
--- a/include/group.php
+++ b/include/group.php
@@ -6,8 +6,26 @@ function group_add($uid,$name) {
$ret = false;
if(x($uid) && x($name)) {
$r = group_byname($uid,$name); // check for dups
- if($r !== false)
+ if($r !== false) {
+
+ // This could be a problem.
+ // Let's assume we've just created a group which we once deleted
+ // all the old members are gone, but the group remains so we don't break any security
+ // access lists. What we're doing here is reviving the dead group, but old content which
+ // was restricted to this group may now be seen by the new group members.
+
+ $z = q("SELECT * FROM `group` WHERE `id` = %d LIMIT 1",
+ intval($r)
+ );
+ if(count($z) && $z[0]['deleted']) {
+ $r = q("UPDATE `group` SET `deleted` = 0 WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($name)
+ );
+ notice( t('A deleted group with this name was revived. Existing item permissions <strong>may</strong> apply to this group and any future members. If this is not what you intended, please create another group with a different name.') . EOL);
+ }
return true;
+ }
$r = q("INSERT INTO `group` ( `uid`, `name` )
VALUES( %d, '%s' ) ",
intval($uid),
@@ -146,15 +164,15 @@ function group_side($every="contacts",$each="group",$edit = false, $group_id = 0
$createtext = t('Create a new group');
$linktext= t('Everybody');
- $selected = (($group_id == 0) ? ' class="group-selected" ' : '');
+ $selected = (($group_id == 0) ? ' group-selected' : '');
$o .= <<< EOT
-<div id="group-sidebar">
+<div id="group-sidebar" class="widget">
<h3>Groups</h3>
<div id="sidebar-group-list">
<ul id="sidebar-group-ul">
- <li class="sidebar-group-li" ><a href="$every" class="sidebar-group-element" $selected >$linktext</a></li>
+ <li class="sidebar-group-li" ><a href="$every" class="sidebar-group-element$selected" >$linktext</a></li>
EOT;
@@ -167,13 +185,13 @@ EOT;
if(count($r)) {
foreach($r as $rr) {
- $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : '');
+ $selected = (($group_id == $rr['id']) ? ' group-selected' : '');
$o .= ' <li class="sidebar-group-li">'
. (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit')
. "\" class=\"groupsideedit\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "")
. (($cid) ? '<input type="checkbox" class="' . (($selected) ? 'ticked' : 'unticked') . '" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" '
. ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '')
- . "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element\" $selected >{$rr['name']}</a></li>\r\n";
+ . "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element" . $selected ."\" >{$rr['name']}</a></li>\r\n";
}
}
$o .= " </ul>\r\n </div>";
diff --git a/include/items.php b/include/items.php
index facd8b2d4..da5a18cad 100644
--- a/include/items.php
+++ b/include/items.php
@@ -717,6 +717,7 @@ function item_store($arr,$force_parent = false) {
$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['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
@@ -865,6 +866,14 @@ function item_store($arr,$force_parent = false) {
intval($current_post)
);
+ // update the commented timestamp on the parent
+
+ q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($parent_id)
+ );
+
if($dsprsig) {
q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ",
intval($current_post),
@@ -1606,13 +1615,18 @@ function lose_follower($importer,$contact,$datarray,$item) {
}
-function subscribe_to_hub($url,$importer,$contact) {
+function subscribe_to_hub($url,$importer,$contact,$submode = 'subscribe') {
if(is_array($importer)) {
$r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid'])
);
}
+
+ // Diaspora has different message-ids in feeds than they do
+ // through the direct Diaspora protocol. If we try and use
+ // the feed, we'll get duplicates. So don't.
+
if((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
return;
@@ -1622,7 +1636,7 @@ function subscribe_to_hub($url,$importer,$contact) {
$verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string());
- $params= 'hub.mode=subscribe&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token;
+ $params= 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token;
logger('subscribe_to_hub: subscribing ' . $contact['name'] . ' to hub ' . $url . ' with verifier ' . $verify_token);
diff --git a/include/network.php b/include/network.php
index deb257ff3..ec99d1e0d 100644
--- a/include/network.php
+++ b/include/network.php
@@ -701,24 +701,59 @@ function parse_xml_string($s,$strict = true) {
return $x;
}}
-function add_fcontact($arr) {
-
- $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
- `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
- values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
- dbesc($arr['url']),
- dbesc($arr['name']),
- dbesc($arr['photo']),
- dbesc($arr['request']),
- dbesc($arr['nick']),
- dbesc($arr['addr']),
- dbesc($arr['notify']),
- dbesc($arr['poll']),
- dbesc($arr['confirm']),
- dbesc($arr['network']),
- dbesc($arr['alias']),
- dbesc($arr['pubkey']),
- dbesc(datetime_convert())
- );
+function add_fcontact($arr,$update = false) {
+
+ if($update) {
+ $r = q("UPDATE `fcontact` SET
+ `name` = '%s',
+ `photo` = '%s',
+ `request` = '%s',
+ `nick` = '%s',
+ `addr` = '%s',
+ `batch` = '%s',
+ `notify` = '%s',
+ `poll` = '%s',
+ `confirm` = '%s',
+ `alias` = '%s',
+ `pubkey` = '%s',
+ `updated` = '%s'
+ WHERE `url` = '%s' AND `network` = '%s' LIMIT 1",
+ dbesc($arr['name']),
+ dbesc($arr['photo']),
+ dbesc($arr['request']),
+ dbesc($arr['nick']),
+ dbesc($arr['addr']),
+ dbesc($arr['batch']),
+ dbesc($arr['notify']),
+ dbesc($arr['poll']),
+ dbesc($arr['confirm']),
+ dbesc($arr['network']),
+ dbesc($arr['alias']),
+ dbesc($arr['pubkey']),
+ dbesc(datetime_convert()),
+ dbesc($arr['url']),
+ dbesc($arr['network'])
+ );
+ }
+ else {
+ $r = q("insert into fcontact ( `url`,`name`,`photo`,`request`,`nick`,`addr`,
+ `batch`, `notify`,`poll`,`confirm`,`network`,`alias`,`pubkey`,`updated` )
+ values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
+ dbesc($arr['url']),
+ dbesc($arr['name']),
+ dbesc($arr['photo']),
+ dbesc($arr['request']),
+ dbesc($arr['nick']),
+ dbesc($arr['addr']),
+ dbesc($arr['batch']),
+ dbesc($arr['notify']),
+ dbesc($arr['poll']),
+ dbesc($arr['confirm']),
+ dbesc($arr['network']),
+ dbesc($arr['alias']),
+ dbesc($arr['pubkey']),
+ dbesc(datetime_convert())
+ );
+ }
return $r;
}
diff --git a/include/notifier.php b/include/notifier.php
index 6ac882c19..748d15743 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -409,6 +409,8 @@ function notifier_run($argv, $argc){
foreach($r as $contact) {
if((! $mail) && (! $fsuggest) && (! $followup) && (! $contact['self'])) {
+ if(($contact['network'] === NETWORK_DIASPORA) && ($public_message))
+ continue;
q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )",
dbesc($cmd),
intval($item_id),
@@ -583,9 +585,19 @@ function notifier_run($argv, $argc){
break;
case NETWORK_DIASPORA:
require_once('include/diaspora.php');
+
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
+ // special handling for followup to public post
+ // all other public posts processed as public batches further below
+
+ if($public_message) {
+ if($followup)
+ diaspora_send_followup($target_item,$owner,$contact, true);
+ break;
+ }
+
if(! $contact['pubkey'])
break;
@@ -643,17 +655,25 @@ function notifier_run($argv, $argc){
if($public_message) {
- $r = q("SELECT `id`, `name` FROM `contact`
- WHERE `network` in ('%s','%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
+ $r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s'
+ AND `uid` = %d AND `rel` != %d ORDER BY rand() ",
+ dbesc(NETWORK_DIASPORA),
+ intval($owner['uid']),
+ intval(CONTACT_IS_SHARING)
+ );
+
+ $r2 = q("SELECT `id`, `name`,`network` FROM `contact`
+ WHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
AND `rel` != %d order by rand() ",
dbesc(NETWORK_DFRN),
- dbesc(NETWORK_DIASPORA),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)
);
+ $r = array_merge($r2,$r1);
+
if(count($r)) {
- logger('pubdeliver: ' . print_r($r,true));
+ logger('pubdeliver: ' . print_r($r,true), LOGGER_DEBUG);
// throw everything into the queue in case we get killed
@@ -669,9 +689,10 @@ function notifier_run($argv, $argc){
foreach($r as $rr) {
- /* Don't deliver to folks who have already been delivered to */
+ // except for Diaspora batch jobs
+ // Don't deliver to folks who have already been delivered to
- if(in_array($rr['id'],$conversants)) {
+ if(($rr['network'] !== NETWORK_DIASPORA) && (in_array($rr['id'],$conversants))) {
logger('notifier: already delivered id=' . $rr['id']);
continue;
}
diff --git a/include/pgettext.php b/include/pgettext.php
index 49f100737..83e76ba9d 100644
--- a/include/pgettext.php
+++ b/include/pgettext.php
@@ -90,8 +90,11 @@ if(! function_exists('load_translation_table')) {
function load_translation_table($lang) {
global $a;
- if(file_exists("view/$lang/strings.php"))
+ if(file_exists("view/$lang/strings.php")) {
include("view/$lang/strings.php");
+ }
+ else
+ $a->strings = array();
}}
// translate string if translation exists
@@ -110,12 +113,15 @@ function t($s) {
if(! function_exists('tt')){
function tt($singular, $plural, $count){
-
+ global $lang;
$a = get_app();
if(x($a->strings,$singular)) {
$t = $a->strings[$singular];
- $k = string_plural_select($count);
+ $f = 'string_plural_select_' . str_replace('-','_',$lang);
+ if(! function_exists($f))
+ $f = 'string_plural_select_default';
+ $k = $f($count);
return is_array($t)?$t[$k]:$t;
}
@@ -124,4 +130,13 @@ function tt($singular, $plural, $count){
} else {
return $singular;
}
-}} \ No newline at end of file
+}}
+
+// provide a fallback which will not collide with
+// a function defined in any language file
+
+if(! function_exists('string_plural_select_default')) {
+function string_plural_select_default($n) {
+ return ($n != 1);
+}}
+
diff --git a/include/poller.php b/include/poller.php
index e80b696bf..fd2a0af8f 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -86,11 +86,12 @@ function poller_run($argv, $argc){
// and which have a polling address and ignore Diaspora since
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
- $contacts = q("SELECT `id` FROM `contact`
+ $contacts = q("SELECT `contact`.`id` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
AND `network` != '%s'
$sql_extra
- AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()",
+ AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
+ AND `user`.`account_expired` = 0 ORDER BY RAND()",
intval(CONTACT_IS_SHARING),
intval(CONTACT_IS_FRIEND),
dbesc(NETWORK_DIASPORA)
@@ -137,6 +138,8 @@ function poller_run($argv, $argc){
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
$hub_update = true;
}
+ else
+ $hub_update = false;
/**
* Based on $contact['priority'], should we poll this site now? Or later?
@@ -472,21 +475,25 @@ function poller_run($argv, $argc){
consume_feed($xml,$importer,$contact,$hub,1);
+ $hubmode = 'subscribe';
+ if($contact['network'] === NETWORK_DFRN || $contact['blocked'] || $contact['readonly'])
+ $hubmode = 'unsubscribe';
- if((strlen($hub)) && ($hub_update) && (($contact['rel'] == CONTACT_IS_FRIEND) || (($contact['network'] === NETWORK_OSTATUS) && (! $contact['readonly'])))) {
- logger('poller: subscribing to hub(s) : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
+ if((strlen($hub)) && ($hub_update) && ($contact['rel'] != CONTACT_IS_FOLLOWER)) {
+ logger('poller: hub ' . $hubmode . ' : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
$h = trim($h);
if(! strlen($h))
continue;
- subscribe_to_hub($h,$importer,$contact);
+ subscribe_to_hub($h,$importer,$contact,$hubmode);
}
}
}
}
+
$updated = datetime_convert();
$r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1",
diff --git a/include/profile_advanced.php b/include/profile_advanced.php
index c1dfad66f..22e035fe6 100644
--- a/include/profile_advanced.php
+++ b/include/profile_advanced.php
@@ -12,8 +12,8 @@ if($a->profile['name']) {
$o .= <<< EOT
<div id="advanced-profile-name-wrapper" >
-<div id="advanced-profile-name-text">$lbl_fullname</div>
-<div id="advanced-profile-name">$fullname</div>
+<div id="advanced-profile-name-text" class="advanced-profile-label">$lbl_fullname</div>
+<div id="advanced-profile-name" class="advanced-profile-content">$fullname</div>
</div>
<div id="advanced-profile-name-end"></div>
EOT;
@@ -25,8 +25,8 @@ if($a->profile['gender']) {
$o .= <<< EOT
<div id="advanced-profile-gender-wrapper" >
-<div id="advanced-profile-gender-text">$lbl_gender</div>
-<div id="advanced-profile-gender">$gender</div>
+<div id="advanced-profile-gender-text" class="advanced-profile-label">$lbl_gender</div>
+<div id="advanced-profile-gender" class="advanced-profile-content">$gender</div>
</div>
<div id="advanced-profile-gender-end"></div>
EOT;
@@ -37,7 +37,7 @@ if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
$o .= <<< EOT
<div id="advanced-profile-dob-wrapper" >
-<div id="advanced-profile-dob-text">$lbl_birthday</div>
+<div id="advanced-profile-dob-text" class="advanced-profile-label">$lbl_birthday</div>
EOT;
// If no year, add an arbitrary one so just we can parse the month and day.
@@ -45,7 +45,7 @@ EOT;
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
-$o .= '<div id="advanced-profile-dob">'
+$o .= '<div id="advanced-profile-dob" class="advanced-profile-content">'
. ((intval($a->profile['dob']))
? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
: day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],6) . ' 00:00 +00:00',$short_bd_format)))
@@ -59,8 +59,8 @@ if($age = age($a->profile['dob'],$a->profile['timezone'],'')) {
$lbl_age = t('Age:');
$o .= <<< EOT
<div id="advanced-profile-age-wrapper" >
-<div id="advanced-profile-age-text">$lbl_age</div>
-<div id="advanced-profile-age">$age</div>
+<div id="advanced-profile-age-text" class="advanced-profile-label">$lbl_age</div>
+<div id="advanced-profile-age" class="advanced-profile-content">$age</div>
</div>
<div id="advanced-profile-age-end"></div>
EOT;
@@ -72,8 +72,8 @@ if($a->profile['marital']) {
$o .= <<< EOT
<div id="advanced-profile-marital-wrapper" >
-<div id="advanced-profile-marital-text">$lbl_marital</div>
-<div id="advanced-profile-marital">$marital</div>
+<div id="advanced-profile-marital-text" class="advanced-profile-label">$lbl_marital</div>
+<div id="advanced-profile-marital" class="advanced-profile-content">$marital</div>
EOT;
if($a->profile['with']) {
@@ -92,8 +92,8 @@ if($a->profile['sexual']) {
$o .= <<< EOT
<div id="advanced-profile-sexual-wrapper" >
-<div id="advanced-profile-sexual-text">$lbl_sexual</div>
-<div id="advanced-profile-sexual">$sexual</div>
+<div id="advanced-profile-sexual-text" class="advanced-profile-label">$lbl_sexual</div>
+<div id="advanced-profile-sexual" class="advanced-profile-content">$sexual</div>
</div>
<div id="advanced-profile-sexual-end"></div>
EOT;
@@ -104,8 +104,8 @@ if($a->profile['homepage']) {
$homepage = linkify($a->profile['homepage']);
$o .= <<< EOT
<div id="advanced-profile-homepage-wrapper" >
-<div id="advanced-profile-homepage-text">$lbl_homepage</div>
-<div id="advanced-profile-homepage">$homepage</div>
+<div id="advanced-profile-homepage-text" class="advanced-profile-label">$lbl_homepage</div>
+<div id="advanced-profile-homepage" class="advanced-profile-content">$homepage</div>
</div>
<div id="advanced-profile-homepage-end"></div>
EOT;
@@ -116,8 +116,8 @@ if($a->profile['politic']) {
$politic = $a->profile['politic'];
$o .= <<< EOT
<div id="advanced-profile-politic-wrapper" >
-<div id="advanced-profile-politic-text">$lbl_politic</div>
-<div id="advanced-profile-politic">$politic</div>
+<div id="advanced-profile-politic-text" class="advanced-profile-label">$lbl_politic</div>
+<div id="advanced-profile-politic" class="advanced-profile-content">$politic</div>
</div>
<div id="advanced-profile-politic-end"></div>
EOT;
@@ -128,8 +128,8 @@ if($a->profile['religion']) {
$religion = $a->profile['religion'];
$o .= <<< EOT
<div id="advanced-profile-religion-wrapper" >
-<div id="advanced-profile-religion-text">$lbl_religion</div>
-<div id="advanced-profile-religion">$religion</div>
+<div id="advanced-profile-religion-text" class="advanced-profile-label">$lbl_religion</div>
+<div id="advanced-profile-religion" class="advanced-profile-content">$religion</div>
</div>
<div id="advanced-profile-religion-end"></div>
EOT;
@@ -138,9 +138,9 @@ if($txt = prepare_text($a->profile['about'])) {
$lbl_about = t('About:');
$o .= <<< EOT
<div id="advanced-profile-about-wrapper" >
-<div id="advanced-profile-about-text">$lbl_about</div>
+<div id="advanced-profile-about-text" class="advanced-profile-label">$lbl_about</div>
<br />
-<div id="advanced-profile-about">$txt</div>
+<div id="advanced-profile-about" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-about-end"></div>
EOT;
@@ -150,9 +150,9 @@ if($txt = prepare_text($a->profile['interest'])) {
$lbl_interests = t('Hobbies/Interests:');
$o .= <<< EOT
<div id="advanced-profile-interest-wrapper" >
-<div id="advanced-profile-interest-text">$lbl_interests</div>
+<div id="advanced-profile-interest-text" class="advanced-profile-label">$lbl_interests</div>
<br />
-<div id="advanced-profile-interest">$txt</div>
+<div id="advanced-profile-interest" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-interest-end"></div>
EOT;
@@ -162,9 +162,9 @@ if($txt = prepare_text($a->profile['contact'])) {
$lbl_contact = t('Contact information and Social Networks:');
$o .= <<< EOT
<div id="advanced-profile-contact-wrapper" >
-<div id="advanced-profile-contact-text">$lbl_contact</div>
+<div id="advanced-profile-contact-text" class="advanced-profile-label">$lbl_contact</div>
<br />
-<div id="advanced-profile-contact">$txt</div>
+<div id="advanced-profile-contact" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-contact-end"></div>
EOT;
@@ -174,9 +174,9 @@ if($txt = prepare_text($a->profile['music'])) {
$lbl_music = t('Musical interests:');
$o .= <<< EOT
<div id="advanced-profile-music-wrapper" >
-<div id="advanced-profile-music-text">$lbl_music</div>
+<div id="advanced-profile-music-text" class="advanced-profile-label">$lbl_music</div>
<br />
-<div id="advanced-profile-music">$txt</div>
+<div id="advanced-profile-music" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-music-end"></div>
EOT;
@@ -186,9 +186,9 @@ if($txt = prepare_text($a->profile['book'])) {
$lbl_book = t('Books, literature:');
$o .= <<< EOT
<div id="advanced-profile-book-wrapper" >
-<div id="advanced-profile-book-text">$lbl_book</div>
+<div id="advanced-profile-book-text" class="advanced-profile-label">$lbl_book</div>
<br />
-<div id="advanced-profile-book">$txt</div>
+<div id="advanced-profile-book" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-book-end"></div>
EOT;
@@ -198,9 +198,9 @@ if($txt = prepare_text($a->profile['tv'])) {
$lbl_tv = t('Television:');
$o .= <<< EOT
<div id="advanced-profile-tv-wrapper" >
-<div id="advanced-profile-tv-text">$lbl_tv</div>
+<div id="advanced-profile-tv-text" class="advanced-profile-label">$lbl_tv</div>
<br />
-<div id="advanced-profile-tv">$txt</div>
+<div id="advanced-profile-tv" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-tv-end"></div>
EOT;
@@ -210,9 +210,9 @@ if($txt = prepare_text($a->profile['film'])) {
$lbl_film = t('Film/dance/culture/entertainment:');
$o .= <<< EOT
<div id="advanced-profile-film-wrapper" >
-<div id="advanced-profile-film-text">$lbl_film</div>
+<div id="advanced-profile-film-text" class="advanced-profile-label">$lbl_film</div>
<br />
-<div id="advanced-profile-film">$txt</div>
+<div id="advanced-profile-film" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-film-end"></div>
EOT;
@@ -222,9 +222,9 @@ if($txt = prepare_text($a->profile['romance'])) {
$lbl_romance = t('Love/Romance:');
$o .= <<< EOT
<div id="advanced-profile-romance-wrapper" >
-<div id="advanced-profile-romance-text">$lbl_romance</div>
+<div id="advanced-profile-romance-text" class="advanced-profile-label">$lbl_romance</div>
<br />
-<div id="advanced-profile-romance">$txt</div>
+<div id="advanced-profile-romance" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-romance-end"></div>
EOT;
@@ -234,9 +234,9 @@ if($txt = prepare_text($a->profile['work'])) {
$lbl_work = t('Work/employment:');
$o .= <<< EOT
<div id="advanced-profile-work-wrapper" >
-<div id="advanced-profile-work-text">$lbl_work</div>
+<div id="advanced-profile-work-text" class="advanced-profile-label">$lbl_work</div>
<br />
-<div id="advanced-profile-work">$txt</div>
+<div id="advanced-profile-work" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-work-end"></div>
EOT;
@@ -246,9 +246,9 @@ if($txt = prepare_text($a->profile['education'])) {
$lbl_education = t('School/education:');
$o .= <<< EOT
<div id="advanced-profile-education-wrapper" >
-<div id="advanced-profile-education-text">$lbl_education</div>
+<div id="advanced-profile-education-text" class="advanced-profile-label">$lbl_education</div>
<br />
-<div id="advanced-profile-education">$txt</div>
+<div id="advanced-profile-education" class="advanced-profile-content">$txt</div>
</div>
<div id="advanced-profile-education-end"></div>
EOT;
diff --git a/include/queue.php b/include/queue.php
index 5119a65d8..d312b50f5 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -123,6 +123,7 @@ function queue_run($argv, $argc){
}
$data = $qi[0]['content'];
+ $public = $qi[0]['batch'];
$contact = $c[0];
$owner = $u[0];
@@ -155,7 +156,7 @@ function queue_run($argv, $argc){
case NETWORK_DIASPORA:
if($contact['notify']) {
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
- $deliver_status = diaspora_transmit($owner,$contact,$data);
+ $deliver_status = diaspora_transmit($owner,$contact,$data,$public);
if($deliver_status == (-1))
update_queue_time($q_item['id']);
diff --git a/include/template_processor.php b/include/template_processor.php
index f64fe4c0f..d04da8c61 100644
--- a/include/template_processor.php
+++ b/include/template_processor.php
@@ -199,8 +199,26 @@
$os=$s; $count++;
$s = str_replace($this->search,$this->replace, $s);
}
- return $s;
+ return template_unescape($s);
}
}
$t = new Template;
+
+
+
+
+function template_escape($s) {
+
+ return str_replace(array('$','{{'),array('!_Doll^Ars1Az_!','!_DoubLe^BraceS4Rw_!'),$s);
+
+
+}
+
+function template_unescape($s) {
+
+ return str_replace(array('!_Doll^Ars1Az_!','!_DoubLe^BraceS4Rw_!'),array('$','{{'),$s);
+
+
+
+}
diff --git a/include/text.php b/include/text.php
index a22faa1a5..ea64a3d28 100644
--- a/include/text.php
+++ b/include/text.php
@@ -860,10 +860,16 @@ function lang_selector() {
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
$langs = glob('view/*/strings.php');
if(is_array($langs) && count($langs)) {
+ $langs[] = '';
if(! in_array('view/en/strings.php',$langs))
$langs[] = 'view/en/';
asort($langs);
foreach($langs as $l) {
+ if($l == '') {
+ $default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
+ $o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
+ continue;
+ }
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
$selected = (($ll === $lang) ? ' selected="selected" ' : '');
@@ -932,6 +938,60 @@ function base64url_decode($s) {
return base64_decode(strtr($s,'-_','+/'));
}
-function cc_license() {
-return '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
-}
+
+if (!function_exists('str_getcsv')) {
+ function str_getcsv($input, $delimiter = ',', $enclosure = '"', $escape = '\\', $eol = '\n') {
+ if (is_string($input) && !empty($input)) {
+ $output = array();
+ $tmp = preg_split("/".$eol."/",$input);
+ if (is_array($tmp) && !empty($tmp)) {
+ while (list($line_num, $line) = each($tmp)) {
+ if (preg_match("/".$escape.$enclosure."/",$line)) {
+ while ($strlen = strlen($line)) {
+ $pos_delimiter = strpos($line,$delimiter);
+ $pos_enclosure_start = strpos($line,$enclosure);
+ if (
+ is_int($pos_delimiter) && is_int($pos_enclosure_start)
+ && ($pos_enclosure_start < $pos_delimiter)
+ ) {
+ $enclosed_str = substr($line,1);
+ $pos_enclosure_end = strpos($enclosed_str,$enclosure);
+ $enclosed_str = substr($enclosed_str,0,$pos_enclosure_end);
+ $output[$line_num][] = $enclosed_str;
+ $offset = $pos_enclosure_end+3;
+ } else {
+ if (empty($pos_delimiter) && empty($pos_enclosure_start)) {
+ $output[$line_num][] = substr($line,0);
+ $offset = strlen($line);
+ } else {
+ $output[$line_num][] = substr($line,0,$pos_delimiter);
+ $offset = (
+ !empty($pos_enclosure_start)
+ && ($pos_enclosure_start < $pos_delimiter)
+ )
+ ?$pos_enclosure_start
+ :$pos_delimiter+1;
+ }
+ }
+ $line = substr($line,$offset);
+ }
+ } else {
+ $line = preg_split("/".$delimiter."/",$line);
+
+ /*
+ * Validating against pesky extra line breaks creating false rows.
+ */
+ if (is_array($line) && !empty($line[0])) {
+ $output[$line_num] = $line;
+ }
+ }
+ }
+ return $output;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+}