Merge pull request #136 from annando/master
Mail improvements, item caching and so on
This commit is contained in:
commit
5d2c590fa9
12 changed files with 330 additions and 72 deletions
|
@ -636,6 +636,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` (
|
||||||
`mailbox` CHAR( 255 ) NOT NULL,
|
`mailbox` CHAR( 255 ) NOT NULL,
|
||||||
`user` CHAR( 255 ) NOT NULL ,
|
`user` CHAR( 255 ) NOT NULL ,
|
||||||
`pass` TEXT NOT NULL ,
|
`pass` TEXT NOT NULL ,
|
||||||
|
`reply_to` CHAR( 255 ) NOT NULL ,
|
||||||
`action` INT NOT NULL ,
|
`action` INT NOT NULL ,
|
||||||
`movetofolder` CHAR(255) NOT NULL ,
|
`movetofolder` CHAR(255) NOT NULL ,
|
||||||
`pubmail` TINYINT(1) NOT NULL DEFAULT '0',
|
`pubmail` TINYINT(1) NOT NULL DEFAULT '0',
|
||||||
|
|
|
@ -79,3 +79,9 @@ $a->config['system']['theme'] = 'duepuntozero';
|
||||||
// By default allow pseudonyms
|
// By default allow pseudonyms
|
||||||
|
|
||||||
$a->config['system']['no_regfullname'] = true;
|
$a->config['system']['no_regfullname'] = true;
|
||||||
|
|
||||||
|
// If set to true the priority settings of ostatus contacts are used
|
||||||
|
$a->config['system']['ostatus_use_priority'] = false;
|
||||||
|
|
||||||
|
// If enabled all items are cached in the given directory
|
||||||
|
$a->config['system']['itemcache'] = "";
|
||||||
|
|
|
@ -435,8 +435,8 @@ function delivery_run($argv, $argc){
|
||||||
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
||||||
|
|
||||||
// for testing purposes: Collect exported mails
|
// for testing purposes: Collect exported mails
|
||||||
$file = tempnam("/tmp/friendica/", "mail-out-");
|
// $file = tempnam("/tmp/friendica/", "mail-out-");
|
||||||
file_put_contents($file, json_encode($it));
|
// file_put_contents($file, json_encode($it));
|
||||||
|
|
||||||
$headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n";
|
$headers .= 'Message-Id: <' . iri2msgid($it['uri']). '>' . "\n";
|
||||||
|
|
||||||
|
@ -446,30 +446,16 @@ function delivery_run($argv, $argc){
|
||||||
|
|
||||||
if($it['uri'] !== $it['parent-uri']) {
|
if($it['uri'] !== $it['parent-uri']) {
|
||||||
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
||||||
if(! strlen($it['title'])) {
|
if(!strlen($it['title'])) {
|
||||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||||
dbesc($it['parent-uri'])
|
dbesc($it['parent-uri']));
|
||||||
);
|
|
||||||
if(count($r)) {
|
if(count($r) AND ($r[0]['title'] != ''))
|
||||||
$subtitle = $r[0]['title'];
|
$subject = $r[0]['title'];
|
||||||
if($subtitle) {
|
|
||||||
if(strncasecmp($subtitle,'RE:',3))
|
|
||||||
$subject = $subtitle;
|
|
||||||
else
|
|
||||||
$subject = 'Re: ' . $subtitle;
|
|
||||||
}
|
}
|
||||||
|
if(strncasecmp($subject,'RE:',3))
|
||||||
|
$subject = 'Re: '.$subject;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
/*$headers .= 'MIME-Version: 1.0' . "\n";
|
|
||||||
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
|
||||||
$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
|
|
||||||
$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
|
|
||||||
$html = prepare_body($it);
|
|
||||||
//$message = '<html><body>' . $html . '</body></html>';
|
|
||||||
$message = html2plain($html);
|
|
||||||
logger('notifier: email delivery to ' . $addr);
|
|
||||||
mail($addr, $subject, $message, $headers);*/
|
|
||||||
email_send($addr, $subject, $headers, $it);
|
email_send($addr, $subject, $headers, $it);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
|
require_once('include/msgclean.php');
|
||||||
|
require_once('include/quoteconvert.php');
|
||||||
|
|
||||||
function email_connect($mailbox,$username,$password) {
|
function email_connect($mailbox,$username,$password) {
|
||||||
if(! function_exists('imap_open'))
|
if(! function_exists('imap_open'))
|
||||||
|
@ -86,6 +88,7 @@ function email_get_msg($mbox,$uid) {
|
||||||
|
|
||||||
if(! $struc->parts) {
|
if(! $struc->parts) {
|
||||||
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'html');
|
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'html');
|
||||||
|
$html = $ret['body'];
|
||||||
|
|
||||||
if (trim($ret['body']) == '')
|
if (trim($ret['body']) == '')
|
||||||
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'plain');
|
$ret['body'] = email_get_part($mbox,$uid,$struc,0, 'plain');
|
||||||
|
@ -107,6 +110,17 @@ function email_get_msg($mbox,$uid) {
|
||||||
else
|
else
|
||||||
$ret['body'] = $text;
|
$ret['body'] = $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ret['body'] = removegpg($ret['body']);
|
||||||
|
$msg = removesig($ret['body']);
|
||||||
|
$ret['body'] = $msg['body'];
|
||||||
|
$ret['body'] = convertquote($ret['body'], false);
|
||||||
|
|
||||||
|
if (trim($html) != '')
|
||||||
|
$ret['body'] = removelinebreak($ret['body']);
|
||||||
|
|
||||||
|
$ret['body'] = unifyattributionline($ret['body']);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,18 +142,22 @@ function html2bbcode($message)
|
||||||
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '[i]', '[/i]');
|
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '[i]', '[/i]');
|
||||||
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '[b]', '[/b]');
|
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '[b]', '[/b]');
|
||||||
|
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
|
/*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
|
||||||
node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
|
node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(.+)/'), '[font=$1][size=$2]', '[/size][/font]');
|
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(.+)/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'color'=>'/(.+)/'), '[font=$1][color=$3]', '[/color][/font]');
|
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'color'=>'/(.+)/'), '[font=$1][color=$3]', '[/color][/font]');
|
||||||
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/'), '[font=$1]', '[/font]');
|
node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/'), '[font=$1]', '[/font]');
|
||||||
node2bbcode($doc, 'font', array('size'=>'/(\d+)/'), '[size=$1]', '[/size]');
|
node2bbcode($doc, 'font', array('size'=>'/(\d+)/'), '[size=$1]', '[/size]');
|
||||||
node2bbcode($doc, 'font', array('color'=>'/(.+)/'), '[color=$1]', '[/color]');
|
node2bbcode($doc, 'font', array('color'=>'/(.+)/'), '[color=$1]', '[/color]');
|
||||||
|
*/
|
||||||
|
// Untested
|
||||||
|
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*font-family:\s*(.+?)[,;].*color:\s*(.+?)[,;].*/'), '[size=$1][font=$2][color=$3]', '[/color][/font][/size]');
|
||||||
|
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]');
|
||||||
|
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]');
|
||||||
|
|
||||||
node2bbcode($doc, 'span', array('style'=>'/.*color:\s*(.+?)[,;].*/'), '[color="$1"]', '[/color]');
|
node2bbcode($doc, 'span', array('style'=>'/.*color:\s*(.+?)[,;].*/'), '[color="$1"]', '[/color]');
|
||||||
node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)/'), '[size=$1]', '[/size]');
|
|
||||||
|
|
||||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
//node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
||||||
|
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)pt.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)pt.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)px.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*font-size:\s*(\d+?)px.*/'), '[font=$1][size=$2]', '[/size][/font]');
|
||||||
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
//node2bbcode($doc, 'div', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
||||||
|
@ -187,13 +191,13 @@ function html2bbcode($message)
|
||||||
|
|
||||||
node2bbcode($doc, 'hr', array(), "[hr]", "");
|
node2bbcode($doc, 'hr', array(), "[hr]", "");
|
||||||
|
|
||||||
//node2bbcode($doc, 'table', array(), "", "");
|
node2bbcode($doc, 'table', array(), "", "");
|
||||||
//node2bbcode($doc, 'tr', array(), "\n", "");
|
node2bbcode($doc, 'tr', array(), "\n", "");
|
||||||
//node2bbcode($doc, 'td', array(), "\t", "");
|
node2bbcode($doc, 'td', array(), "\t", "");
|
||||||
node2bbcode($doc, 'table', array(), "[table]", "[/table]");
|
//node2bbcode($doc, 'table', array(), "[table]", "[/table]");
|
||||||
node2bbcode($doc, 'th', array(), "[th]", "[/th]");
|
//node2bbcode($doc, 'th', array(), "[th]", "[/th]");
|
||||||
node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
|
//node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
|
||||||
node2bbcode($doc, 'td', array(), "[td]", "[/td]");
|
//node2bbcode($doc, 'td', array(), "[td]", "[/td]");
|
||||||
|
|
||||||
node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
|
node2bbcode($doc, 'h1', array(), "\n\n[size=xx-large][b]", "[/b][/size]\n");
|
||||||
node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
|
node2bbcode($doc, 'h2', array(), "\n\n[size=x-large][b]", "[/b][/size]\n");
|
||||||
|
|
225
include/msgclean.php
Normal file
225
include/msgclean.php
Normal file
|
@ -0,0 +1,225 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function savereplace($pattern, $replace, $text)
|
||||||
|
{
|
||||||
|
$save = $text;
|
||||||
|
|
||||||
|
$text = preg_replace($pattern, $replace, $text);
|
||||||
|
|
||||||
|
if ($text == '')
|
||||||
|
$text = $save;
|
||||||
|
return($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unifyattributionline($message)
|
||||||
|
{
|
||||||
|
$quotestr = array('quote', 'collapsed');
|
||||||
|
foreach ($quotestr as $quote) {
|
||||||
|
|
||||||
|
$message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?) <(.*?)>\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\sDatum: (.*?)\s.*Von: "([^<"].*?)" <(.*?)>\s.*An: (.*?)\n.*/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?)\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?).*:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Am (.*?), schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Am .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\sschrieb\s(.*?)\s<(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Am (.*?) schrieb (.*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/Am (.*?) schrieb <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/Am (.*?) schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/Am (.*?) schrieb (.*?)\n(.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/On .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\s(.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/On (.*?) at (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message);
|
||||||
|
$message = savereplace('/On (.*?)\n([^<].*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/On (.*?), (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message);
|
||||||
|
$message = savereplace('/On ([^,].*?), (.*?)\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/On (.*?), (.*?)\swrote\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
|
||||||
|
// Der loescht manchmal den Body - was eigentlich unmoeglich ist
|
||||||
|
$message = savereplace('/On (.*?),(.*?),(.*?),(.*?), (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$5']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Zitat von ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Quoting ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/From: "([^<"].*?)" <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/From: <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/Du \(([^)].*?)\) schreibst:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/--- (.*?) <.*?> schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/--- (.*?) schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/\* (.*?) <(.*?)> hat geschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/(.*?) <(.*?)> schrieb (.*?)\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) <(.*?)> schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) \((.*?)\) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/(.*?) <(.*?)> writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) \((.*?)\) writes:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/\* (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) wrote \(.*?\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/([^<].*?) <.*?> hat am (.*?)\sum\s(.*)\sgeschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
|
||||||
|
$message = savereplace('/(\d+)\/(\d+)\/(\d+) (.*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
|
||||||
|
$message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
|
||||||
|
$message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
|
||||||
|
|
||||||
|
$message = savereplace('/(.*?) <(.*?)> schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
|
||||||
|
$message = savereplace('/(.*?) \((.*?)\) schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
|
||||||
|
|
||||||
|
}
|
||||||
|
return($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removegpg($message)
|
||||||
|
{
|
||||||
|
|
||||||
|
$pattern = '/(.*)\s*-----BEGIN PGP SIGNED MESSAGE-----\s*[\r\n].*Hash:.*?[\r\n](.*)'.
|
||||||
|
'[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'.
|
||||||
|
'[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is';
|
||||||
|
|
||||||
|
preg_match($pattern, $message, $result);
|
||||||
|
|
||||||
|
$cleaned = trim($result[1].$result[2].$result[3]);
|
||||||
|
|
||||||
|
$cleaned = str_replace(array("\n- --\n", "\n- -"), array("\n-- \n", "\n-"), $cleaned);
|
||||||
|
|
||||||
|
|
||||||
|
if ($cleaned == '')
|
||||||
|
$cleaned = $message;
|
||||||
|
|
||||||
|
return($cleaned);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removesig($message)
|
||||||
|
{
|
||||||
|
$sigpos = strrpos($message, "\n-- \n");
|
||||||
|
$quotepos = strrpos($message, "[/quote]");
|
||||||
|
|
||||||
|
if ($sigpos == 0) {
|
||||||
|
// Speziell fuer web.de, die das als Trenner verwenden
|
||||||
|
$message = str_replace("\n___________________________________________________________\n", "\n-- \n", $message);
|
||||||
|
$sigpos = strrpos($message, "\n-- \n");
|
||||||
|
$quotepos = strrpos($message, "[/quote]");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sollte sich der Signaturtrenner innerhalb eines Quotes befinden
|
||||||
|
// wird keine Signaturtrennung ausgefuehrt
|
||||||
|
if (($sigpos < $quotepos) and ($sigpos != 0))
|
||||||
|
return(array('body' => $message, 'sig' => ''));
|
||||||
|
|
||||||
|
// To-Do: Regexp umstellen, so dass auf 1 oder kein Leerzeichen
|
||||||
|
// geprueft wird
|
||||||
|
//$message = str_replace("\n--\n", "\n-- \n", $message);
|
||||||
|
|
||||||
|
$pattern = '/(.*)[\r\n]-- [\r\n](.*)/is';
|
||||||
|
|
||||||
|
preg_match($pattern, $message, $result);
|
||||||
|
|
||||||
|
if (($result[1] != '') and ($result[2] != '')) {
|
||||||
|
$cleaned = trim($result[1])."\n";
|
||||||
|
$sig = trim($result[2]);
|
||||||
|
// '[hr][size=x-small][color=darkblue]'.trim($result[2]).'[/color][/size]';
|
||||||
|
} else {
|
||||||
|
$cleaned = $message;
|
||||||
|
$sig = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return(array('body' => $cleaned, 'sig' => $sig));
|
||||||
|
}
|
||||||
|
|
||||||
|
function removelinebreak($message)
|
||||||
|
{
|
||||||
|
$arrbody = explode("\n", trim($message));
|
||||||
|
|
||||||
|
$lines = array();
|
||||||
|
$lineno = 0;
|
||||||
|
|
||||||
|
foreach($arrbody as $i => $line) {
|
||||||
|
$currquotelevel = 0;
|
||||||
|
$currline = $line;
|
||||||
|
while ((strlen($currline)>0) and ((substr($currline, 0, 1) == '>')
|
||||||
|
or (substr($currline, 0, 1) == ' '))) {
|
||||||
|
if (substr($currline, 0, 1) == '>')
|
||||||
|
$currquotelevel++;
|
||||||
|
|
||||||
|
$currline = ltrim(substr($currline, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$quotelevel = 0;
|
||||||
|
$nextline = trim($arrbody[$i+1]);
|
||||||
|
while ((strlen($nextline)>0) and ((substr($nextline, 0, 1) == '>')
|
||||||
|
or (substr($nextline, 0, 1) == ' '))) {
|
||||||
|
if (substr($nextline, 0, 1) == '>')
|
||||||
|
$quotelevel++;
|
||||||
|
|
||||||
|
$nextline = ltrim(substr($nextline, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$len = strlen($line);
|
||||||
|
$firstword = strpos($nextline.' ', ' ');
|
||||||
|
|
||||||
|
$specialchars = ((substr(trim($nextline), 0, 1) == '-') or
|
||||||
|
(substr(trim($nextline), 0, 1) == '=') or
|
||||||
|
(substr(trim($nextline), 0, 1) == '*') or
|
||||||
|
(substr(trim($nextline), 0, 1) == '·') or
|
||||||
|
(substr(trim($nextline), 0, 4) == '[url') or
|
||||||
|
(substr(trim($nextline), 0, 5) == '[size') or
|
||||||
|
(substr(trim($nextline), 0, 7) == 'http://') or
|
||||||
|
(substr(trim($nextline), 0, 8) == 'https://'));
|
||||||
|
|
||||||
|
if (!$specialchars)
|
||||||
|
$specialchars = ((substr(rtrim($line), -1) == '-') or
|
||||||
|
(substr(rtrim($line), -1) == '=') or
|
||||||
|
(substr(rtrim($line), -1) == '*') or
|
||||||
|
(substr(rtrim($line), -1) == '·') or
|
||||||
|
(substr(rtrim($line), -6) == '[/url]') or
|
||||||
|
(substr(rtrim($line), -7) == '[/size]'));
|
||||||
|
|
||||||
|
//if ($specialchars)
|
||||||
|
// echo ("Special\n");
|
||||||
|
|
||||||
|
if ($lines[$lineno] != '') {
|
||||||
|
if (substr($lines[$lineno], -1) != ' ')
|
||||||
|
$lines[$lineno] .= ' ';
|
||||||
|
|
||||||
|
while ((strlen($line)>0) and ((substr($line, 0, 1) == '>')
|
||||||
|
or (substr($line, 0, 1) == ' '))) {
|
||||||
|
|
||||||
|
$line = ltrim(substr($line, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
// $lines[$lineno] = $quotelevel.'-'.$len.'-'.$firstword.'-';
|
||||||
|
|
||||||
|
$lines[$lineno] .= $line;
|
||||||
|
//if ((($len + $firstword < 68) and (substr($line, -1, 1) != ' '))
|
||||||
|
// or ($quotelevel != $currquotelevel) or $specialchars)
|
||||||
|
if (((substr($line, -1, 1) != ' '))
|
||||||
|
or ($quotelevel != $currquotelevel))
|
||||||
|
$lineno++;
|
||||||
|
}
|
||||||
|
return(implode("\n", $lines));
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
|
@ -648,38 +648,23 @@ function notifier_run($argv, $argc){
|
||||||
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
$headers .= 'Reply-to: ' . $reply_to . "\n";
|
||||||
|
|
||||||
// for testing purposes: Collect exported mails
|
// for testing purposes: Collect exported mails
|
||||||
$file = tempnam("/tmp/friendica/", "mail-out2-");
|
//$file = tempnam("/tmp/friendica/", "mail-out2-");
|
||||||
file_put_contents($file, json_encode($it));
|
//file_put_contents($file, json_encode($it));
|
||||||
|
|
||||||
$headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
|
$headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
|
||||||
|
|
||||||
if($it['uri'] !== $it['parent-uri']) {
|
if($it['uri'] !== $it['parent-uri']) {
|
||||||
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
|
||||||
if(! strlen($it['title'])) {
|
if(!strlen($it['title'])) {
|
||||||
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
|
||||||
dbesc($it['parent-uri'])
|
dbesc($it['parent-uri']));
|
||||||
);
|
|
||||||
if(count($r)) {
|
|
||||||
$subtitle = $r[0]['title'];
|
|
||||||
if($subtitle) {
|
|
||||||
if(strncasecmp($subtitle,'RE:',3))
|
|
||||||
$subject = $subtitle;
|
|
||||||
else
|
|
||||||
$subject = 'Re: ' . $subtitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*$headers .= 'MIME-Version: 1.0' . "\n";
|
if(count($r) AND ($r[0]['title'] != ''))
|
||||||
//$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
|
$subject = $r[0]['title'];
|
||||||
$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
|
}
|
||||||
$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
|
if(strncasecmp($subject,'RE:',3))
|
||||||
$html = prepare_body($it);
|
$subject = 'Re: '.$subject;
|
||||||
//$message = '<html><body>' . $html . '</body></html>';
|
}
|
||||||
$message = html2plain($html);
|
|
||||||
logger('notifier: email delivery to ' . $addr);
|
|
||||||
mail($addr, $subject, $message, $headers);*/
|
|
||||||
email_send($addr, $subject, $headers, $it);
|
email_send($addr, $subject, $headers, $it);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once("include/quoteconvert.php");
|
|
||||||
|
|
||||||
|
|
||||||
function poller_run($argv, $argc){
|
function poller_run($argv, $argc){
|
||||||
|
@ -70,6 +69,19 @@ function poller_run($argv, $argc){
|
||||||
// clear old cache
|
// clear old cache
|
||||||
Cache::clear();
|
Cache::clear();
|
||||||
|
|
||||||
|
// clear item cache files if they are older than one day
|
||||||
|
$cache = get_config('system','itemcache');
|
||||||
|
if (($cache != '') and is_dir($cache)) {
|
||||||
|
if ($dh = opendir($cache)) {
|
||||||
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
$fullpath = $cache."/".$file;
|
||||||
|
if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 86400))
|
||||||
|
unlink($fullpath);
|
||||||
|
}
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$manual_id = 0;
|
$manual_id = 0;
|
||||||
$generation = 0;
|
$generation = 0;
|
||||||
$hub_update = false;
|
$hub_update = false;
|
||||||
|
@ -141,7 +153,10 @@ function poller_run($argv, $argc){
|
||||||
if($manual_id)
|
if($manual_id)
|
||||||
$contact['last-update'] = '0000-00-00 00:00:00';
|
$contact['last-update'] = '0000-00-00 00:00:00';
|
||||||
|
|
||||||
if($contact['network'] === NETWORK_DFRN || $contact['network'] === NETWORK_OSTATUS)
|
if($contact['network'] === NETWORK_DFRN)
|
||||||
|
$contact['priority'] = 2;
|
||||||
|
|
||||||
|
if(!get_config('system','ostatus_use_priority') and ($contact['network'] === NETWORK_OSTATUS))
|
||||||
$contact['priority'] = 2;
|
$contact['priority'] = 2;
|
||||||
|
|
||||||
if($contact['priority'] || $contact['subhub']) {
|
if($contact['priority'] || $contact['subhub']) {
|
||||||
|
@ -494,7 +509,7 @@ function poller_run($argv, $argc){
|
||||||
logger("Mail: can't fetch msg ".$msg_uid);
|
logger("Mail: can't fetch msg ".$msg_uid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$datarray['body'] = escape_tags(convertquote($r['body'], false));
|
$datarray['body'] = escape_tags($r['body']);
|
||||||
|
|
||||||
logger("Mail: Importing ".$msg_uid);
|
logger("Mail: Importing ".$msg_uid);
|
||||||
|
|
||||||
|
|
|
@ -877,14 +877,27 @@ function prepare_body($item,$attach = false) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
call_hooks('prepare_body_init', $item);
|
call_hooks('prepare_body_init', $item);
|
||||||
|
|
||||||
|
$cache = get_config('system','itemcache');
|
||||||
|
|
||||||
|
if (($cache != '')) {
|
||||||
|
$cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']);
|
||||||
|
|
||||||
|
if (file_exists($cachefile))
|
||||||
|
$s = file_get_contents($cachefile);
|
||||||
|
else {
|
||||||
|
$s = prepare_text($item['body']);
|
||||||
|
file_put_contents($cachefile, $s);
|
||||||
|
}
|
||||||
|
} else
|
||||||
$s = prepare_text($item['body']);
|
$s = prepare_text($item['body']);
|
||||||
|
|
||||||
$prep_arr = array('item' => $item, 'html' => $s);
|
$prep_arr = array('item' => $item, 'html' => $s);
|
||||||
call_hooks('prepare_body', $prep_arr);
|
call_hooks('prepare_body', $prep_arr);
|
||||||
$s = $prep_arr['html'];
|
$s = $prep_arr['html'];
|
||||||
|
|
||||||
if(! $attach)
|
if(! $attach) {
|
||||||
return $s;
|
return $s;
|
||||||
|
}
|
||||||
|
|
||||||
$arr = explode(',',$item['attach']);
|
$arr = explode(',',$item['attach']);
|
||||||
if(count($arr)) {
|
if(count($arr)) {
|
||||||
|
@ -942,9 +955,9 @@ function prepare_body($item,$attach = false) {
|
||||||
$s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
|
$s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$prep_arr = array('item' => $item, 'html' => $s);
|
$prep_arr = array('item' => $item, 'html' => $s);
|
||||||
call_hooks('prepare_body_final', $prep_arr);
|
call_hooks('prepare_body_final', $prep_arr);
|
||||||
|
|
||||||
return $prep_arr['html'];
|
return $prep_arr['html'];
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -485,6 +485,9 @@ code {
|
||||||
#sidebar-group-list .tool:hover {
|
#sidebar-group-list .tool:hover {
|
||||||
background: #EEE;
|
background: #EEE;
|
||||||
}
|
}
|
||||||
|
#sidebar-pages-list .tool:hover {
|
||||||
|
background: #EEE;
|
||||||
|
}
|
||||||
.tool .label {
|
.tool .label {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
@ -1334,14 +1337,14 @@ body .pageheader{
|
||||||
}
|
}
|
||||||
.tag {
|
.tag {
|
||||||
/*background: url("../../../images/tag_b.png") repeat-x center left;*/
|
/*background: url("../../../images/tag_b.png") repeat-x center left;*/
|
||||||
color: #3465A4;
|
color: #999;
|
||||||
padding-left: 3px;
|
padding-left: 3px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
.tag a {
|
.tag a {
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
/*background: url("../../../images/tag.png") no-repeat center right;*/
|
/*background: url("../../../images/tag.png") no-repeat center right;*/
|
||||||
color: #3465A4;
|
color: #999;
|
||||||
}
|
}
|
||||||
.wwto {
|
.wwto {
|
||||||
position: absolute !important;
|
position: absolute !important;
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="contact-photo-link" id="wall-item-photo-link-$item.id">
|
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="contact-photo-link" id="wall-item-photo-link-$item.id">
|
||||||
<img src="$item.thumb" class="contact-photo$item.sparkle" id="wall-item-photo-$item.id" alt="$item.name" />
|
<img src="$item.thumb" class="contact-photo$item.sparkle" id="wall-item-photo-$item.id" alt="$item.name" />
|
||||||
</a>
|
</a>
|
||||||
<a href="#" rel="#wall-item-photo-menu-$item.id" class="contact-photo-menu-button icon s16 menu" id="wall-item-photo-menu-button-$item.id">menu</a>
|
<a href="#" rel="#wall-item-photo-menu-$item.id" class="contact-photo-menu-button icon s16 menu"
|
||||||
|
id="wall-item-photo-menu-button-$item.id">menu</a>
|
||||||
<ul class="contact-menu menu-popup" id="wall-item-photo-menu-$item.id">
|
<ul class="contact-menu menu-popup" id="wall-item-photo-menu-$item.id">
|
||||||
$item.item_photo_menu
|
$item.item_photo_menu
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -21,7 +22,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wall-item-actions-author">
|
<div class="wall-item-actions-author">
|
||||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle">$item.name</span></a>
|
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span
|
||||||
|
class="wall-item-name$item.sparkle">$item.name</span></a>
|
||||||
<span class="wall-item-ago">-
|
<span class="wall-item-ago">-
|
||||||
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||||
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
||||||
|
@ -95,3 +97,4 @@
|
||||||
<div class="wall-item-comment-wrapper" >
|
<div class="wall-item-comment-wrapper" >
|
||||||
$item.comment
|
$item.comment
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="contact-photo-link" id="wall-item-photo-link-$item.id">
|
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="contact-photo-link" id="wall-item-photo-link-$item.id">
|
||||||
<img src="$item.thumb" class="contact-photo$item.sparkle" id="wall-item-photo-$item.id" alt="$item.name" />
|
<img src="$item.thumb" class="contact-photo$item.sparkle" id="wall-item-photo-$item.id" alt="$item.name" />
|
||||||
</a>
|
</a>
|
||||||
<a href="#" rel="#wall-item-photo-menu-$item.id" class="contact-photo-menu-button icon s16 menu" id="wall-item-photo-menu-button-$item.id">menu</a>
|
<a href="#" rel="#wall-item-photo-menu-$item.id" class="contact-photo-menu-button icon s16 menu"
|
||||||
|
id="wall-item-photo-menu-button-$item.id">menu</a>
|
||||||
<ul class="contact-menu menu-popup" id="wall-item-photo-menu-$item.id">
|
<ul class="contact-menu menu-popup" id="wall-item-photo-menu-$item.id">
|
||||||
$item.item_photo_menu
|
$item.item_photo_menu
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -26,8 +27,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wall-item-actions-author">
|
<div class="wall-item-actions-author">
|
||||||
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span class="wall-item-name$item.sparkle">$item.name</span></a>
|
<a href="$item.profile_url" target="redir" title="$item.linktitle" class="wall-item-name-link"><span
|
||||||
$item.to <a href="$item.owner_url" target="redir" title="$item.olinktitle" class="wall-item-name-link"><span class="wall-item-name$item.osparkle" id="wall-item-ownername-$item.id">$item.owner_name</span></a>
|
class="wall-item-name$item.sparkle">$item.name</span></a>
|
||||||
|
$item.to <a href="$item.owner_url" target="redir" title="$item.olinktitle" class="wall-item-name-link"><span class="wall-item-name$item.osparkle"
|
||||||
|
id="wall-item-ownername-$item.id">$item.owner_name</span></a>
|
||||||
$item.vwall <span class="wall-item-ago">-
|
$item.vwall <span class="wall-item-ago">-
|
||||||
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
{{ if $item.plink }}<a class="link" title="$item.plink.title" href="$item.plink.href" style="color: #999">$item.ago</a>{{ else }} $item.ago {{ endif }}
|
||||||
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
{{ if $item.lock }} - <span class="fakelink" style="color: #999" onclick="lockview(event,$item.id);">$item.lock</span> {{ endif }}
|
||||||
|
|
Loading…
Reference in a new issue