diff --git a/boot.php b/boot.php
index e69b59d70..023c5807c 100644
--- a/boot.php
+++ b/boot.php
@@ -520,6 +520,19 @@ if(! class_exists('App')) {
$this->is_tablet = $mobile_detect->isTablet();
}
+ function get_basepath() {
+
+ $basepath = get_config("system", "basepath");
+
+ if ($basepath == "")
+ $basepath = $_SERVER["DOCUMENT_ROOT"];
+
+ if ($basepath == "")
+ $basepath = $_SERVER["PWD"];
+
+ return($basepath);
+ }
+
function get_baseurl($ssl = false) {
$scheme = $this->scheme;
@@ -1895,7 +1908,7 @@ function clear_cache($basepath = "", $path = "") {
$fullpath = $path."/".$file;
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != ".."))
clear_cache($basepath, $fullpath);
- if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - $cachetime))
+ if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime)))
unlink($fullpath);
}
closedir($dh);
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 75fe1ef35..ffe6b3b97 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -155,6 +155,9 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) {
// $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism",
// "[url]$1[/url]\n[img]$2[/img]", $Text);
+ // Remove the avatar picture since that isn't looking good on the other side
+ //$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
+
// Convert it to HTML - don't try oembed
$Text = bbcode($Text, $preserve_nl, false);
diff --git a/include/bbcode.php b/include/bbcode.php
index d83fe6c12..b3f6aa826 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -206,7 +206,59 @@ function bb_replace_images($body, $images) {
return $newbody;
}}
+function bb_ShareAttributes($match) {
+ $attributes = $match[1];
+
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
+
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $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];
+
+ $avatar = "";
+ preg_match("/avatar='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $matches[1];
+
+ preg_match('/avatar="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $avatar = $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];
+
+ $headline = '
";
+
+ $text = "
".$headline.''.trim($match[2])."
";
+
+ return($text);
+}
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica - Mike Macgirvin
@@ -248,6 +300,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace("<", "<", $Text);
$Text = str_replace(">", ">", $Text);
+ // remove some newlines before the general conversion
+ $Text = preg_replace("/\s?\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","[share$1]$2[/share]",$Text);
+
+ // when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
+ if (!$tryoembed)
+ $Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);
+
// Convert new line chars to html
tags
// nlbr seems to be hopelessly messed up
@@ -271,7 +330,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text);
+ $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text);
if ($tryoembed)
$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);
@@ -422,7 +481,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// [img]pathtoimage[/img]
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '', $Text);
-
+ // Shared content
+ $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
', $Text);
$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'
', $Text);
diff --git a/include/delivery.php b/include/delivery.php
index 428035973..c56d7d288 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -458,13 +458,17 @@ function delivery_run(&$argv, &$argc){
// only expose our real email address to true friends
- if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
- $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
- else
+ if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked'])) {
+ if($reply_to) {
+ $headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$reply_to.'>'."\n";
+ $headers .= 'Sender: '.$local_user[0]['email']."\n";
+ } else
+ $headers = 'From: '.email_header_encode($local_user[0]['username'],'UTF-8').' <'.$local_user[0]['email'].'>'."\n";
+ } else
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
- if($reply_to)
- $headers .= 'Reply-to: ' . $reply_to . "\n";
+ //if($reply_to)
+ // $headers .= 'Reply-to: ' . $reply_to . "\n";
// for testing purposes: Collect exported mails
// $file = tempnam("/tmp/friendica/", "mail-out-");
diff --git a/include/nav.php b/include/nav.php
index 3c058e04f..d94bf03be 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -44,14 +44,14 @@ function nav(&$a) {
if(local_user()) {
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
-
+
// user menu
$nav['usermenu'][] = Array('profile/' . $a->user['nickname'], t('Status'), "", t('Your posts and conversations'));
$nav['usermenu'][] = Array('profile/' . $a->user['nickname']. '?tab=profile', t('Profile'), "", t('Your profile page'));
$nav['usermenu'][] = Array('photos/' . $a->user['nickname'], t('Photos'), "", t('Your photos'));
$nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
$nav['usermenu'][] = Array('notes/', t('Personal notes'), "", t('Your personal photos'));
-
+
// user info
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->user['uid']));
$userinfo = array(
@@ -130,11 +130,13 @@ function nav(&$a) {
$nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox'));
$nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox'));
$nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message'));
-
+
if(is_array($a->identities) && count($a->identities) > 1) {
$nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages'));
}
+ $nav['delegations'] = Array('delegate', t('Delegations'), "", t('Delegate Page Management'));
+
$nav['settings'] = array('settings', t('Settings'),"", t('Account settings'));
if(feature_enabled(local_user(),'multi_profiles'))
$nav['profiles'] = array('profiles', t('Profiles'),"", t('Manage/Edit Profiles'));
diff --git a/include/network.php b/include/network.php
index 599088a2d..5877dda41 100644
--- a/include/network.php
+++ b/include/network.php
@@ -854,8 +854,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
}
// replace the special char encoding
-
- $s = htmlspecialchars($s,ENT_QUOTES,'UTF-8');
+ $s = htmlspecialchars($s,ENT_NOQUOTES,'UTF-8');
return $s;
}
diff --git a/include/notifier.php b/include/notifier.php
index 3398254b6..b685e1b99 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -771,14 +771,17 @@ function notifier_run(&$argv, &$argc){
$subject = (($it['title']) ? email_header_encode($it['title'],'UTF-8') : t("\x28no subject\x29")) ;
// only expose our real email address to true friends
-
if(($contact['rel'] == CONTACT_IS_FRIEND) && (! $contact['blocked']))
- $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
+ if($reply_to) {
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $reply_to . '>' . "\n";
+ $headers .= 'Sender: '.$local_user[0]['email']."\n";
+ } else
+ $headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . $local_user[0]['email'] . '>' . "\n";
else
$headers = 'From: ' . email_header_encode($local_user[0]['username'],'UTF-8') . ' <' . t('noreply') . '@' . $a->get_hostname() . '>' . "\n";
- if($reply_to)
- $headers .= 'Reply-to: ' . $reply_to . "\n";
+ //if($reply_to)
+ // $headers .= 'Reply-to: ' . $reply_to . "\n";
// for testing purposes: Collect exported mails
//$file = tempnam("/tmp/friendica/", "mail-out2-");
diff --git a/include/onepoll.php b/include/onepoll.php
index 8fabede11..1e11f2ca1 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -2,6 +2,13 @@
require_once("boot.php");
+function RemoveReply($subject) {
+ while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
+ $subject = trim(substr($subject, 4));
+
+ return($subject);
+}
+
function onepoll_run(&$argv, &$argc){
global $a, $db;
@@ -374,10 +381,6 @@ function onepoll_run(&$argv, &$argc){
// $datarray['parent-uri'] = $r[0]['uri'];
}
-
- if(! x($datarray,'parent-uri'))
- $datarray['parent-uri'] = $datarray['uri'];
-
// Decoding the header
$subject = imap_mime_header_decode($meta->subject);
$datarray['title'] = "";
@@ -392,11 +395,26 @@ function onepoll_run(&$argv, &$argc){
//$datarray['title'] = notags(trim($meta->subject));
$datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
- // Is it reply?
+ // Is it a reply?
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
(substr(strtolower($datarray['title']), 0, 3) == "re-") or
(raw_refs != ""));
+ // Remove Reply-signs in the subject
+ $datarray['title'] = RemoveReply($datarray['title']);
+
+ // If it seems to be a reply but a header couldn't be found take the last message with matching subject
+ if(!x($datarray,'parent-uri') and $reply) {
+ $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) ORDER BY `created` DESC LIMIT 1",
+ dbesc(protect_sprintf($datarray['title'])));
+ if(count($r))
+ $datarray['parent-uri'] = $r[0]['parent-uri'];
+ }
+
+ if(! x($datarray,'parent-uri'))
+ $datarray['parent-uri'] = $datarray['uri'];
+
+
$r = email_get_msg($mbox,$msg_uid, $reply);
if(! $r) {
logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf[0]['user']);
diff --git a/include/poller.php b/include/poller.php
index 6f2eeed82..4eb5e8a2b 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -105,6 +105,9 @@ function poller_run(&$argv, &$argc){
// clear old item cache files
clear_cache();
+ // clear cache for photos
+ clear_cache($a->get_basepath(), $a->get_basepath()."/photo");
+
$manual_id = 0;
$generation = 0;
$hub_update = false;
diff --git a/include/text.php b/include/text.php
index a32641241..7d26d3550 100644
--- a/include/text.php
+++ b/include/text.php
@@ -292,11 +292,11 @@ function alt_pager(&$a, $i) {
$o .= '