Skip to content
Permalink
Browse files

[TASK] Improves compatibility of popfetcher with Serendipity 2.3

- Proper boolean toggles for allow/moderate comments
- Multiple author ids allowed
- PHP 7.2 fixes
  • Loading branch information...
fe-hicking committed Sep 9, 2019
1 parent d0ee81f commit 4c00a2bf4bb83225355fbd96572e5a4879e4b63b
@@ -1,3 +1,13 @@
1.48
----
* Serendipity 2.3 compatibility:
* Remove function call to serendipity_purgeEntry
* Proper evaluation of allow_comments/moderate_comments booleans
* Adds ability to specify multiple valid e-mail addresses
* PHP7 compatibility:
* use quoted_printable_decode instead of a preg-e rule
* Use foreach instead of while(list(...) = each())

1.47
----
* Fix PHP7 incompatibility
@@ -88,7 +88,7 @@
@define('PLUGIN_MF_STRIPTEXT', 'Text nach speziellen Buchstaben abschneiden');
@define('PLUGIN_MF_STRIPTEXT_DESC', 'Wenn Sie Werbung oder andere Textpassagen abschneiden wollen, können Sie hier einen "magischen Text" angeben. Sobald dieser im Inhalt ihrer Mail vorkommt, wird aller Text danach aus dem Eintrag gelöscht.');
@define('PLUGIN_MF_ONLYFROM', 'E-Mail Absender');
@define('PLUGIN_MF_ONLYFROM_DESC', 'Wenn nur ein spezieller Absender anerkannt werden soll, tragen Sie hier diese E-Mail Addresse ein. Bei einem leeren Feld werden alle E-Mails im Blog angenommen');
@define('PLUGIN_MF_ONLYFROM_DESC', 'Wenn nur ein spezieller Absender anerkannt werden soll, tragen Sie hier diese E-Mail Addresse ein. Bei einem leeren Feld werden alle E-Mails im Blog angenommen. Mehrere Mail-Adressen mit Semikolon trennen.');
@define('MF_ERROR_ONLYFROM', 'E-Mail Absender %s entspricht nicht dem zugelassenen Absender %s. Ignoriere E-Mail.');
@define('PLUGIN_MF_SPLITTEXT', 'Spezieller Text, der Text und erweiterten Eintrag einer E-Mail aufteilt');
@@ -89,7 +89,7 @@
@define('PLUGIN_MF_STRIPTEXT_DESC', 'If you want to cut advertisement or other texts, you can specify a "magic string" sequence here. All text after this special string is removed from your posting.');
@define('PLUGIN_MF_ONLYFROM', 'Restrict e-mail sender');
@define('PLUGIN_MF_ONLYFROM_DESC', 'If you only want to allow a certain e-mail address to send mails, you can enter it here. If you leave this field empty, all mails received for your configured account are stored in the blog.');
@define('PLUGIN_MF_ONLYFROM_DESC', 'If you only want to allow a certain e-mail address to send mails, you can enter it here. If you leave this field empty, all mails received for your configured account are stored in the blog. Separate multiple mail adresses with a semicolon.');
@define('MF_ERROR_ONLYFROM', 'E-mail address %s is not the same as configured restriction to %s. Ignoring mail.');
@define('PLUGIN_MF_SPLITTEXT', 'Define a string which separates body/extended parts');
@define('PLUGIN_MF_SPLITTEXT_DESC', 'If you want to use a special string which separates the body and the extended body text in your emails, enter that string here. Serendipity will look for the occurence of that string, and put everything before that string in the body part, and everything after the string in the extended section. Be sure to use a unique string that does not occur as usual text, like "xxx-SPLIT-xxx". If you leave this option empty, the email will be computed as usual - but if you configure a magic string here, some of the other options will be overridden!');
@@ -211,8 +211,7 @@ function _decode($headers, $body, $default_ctype = 'text/plain')
}
}
reset($headers);
while (list($key, $value) = each($headers)) {
foreach($headers AS $key => $value) {
$headers[$key]['name'] = strtolower($headers[$key]['name']);
switch ($headers[$key]['name']) {
@@ -225,7 +224,7 @@ function _decode($headers, $body, $default_ctype = 'text/plain')
}
if (isset($content_type['other'])) {
while (list($p_name, $p_value) = each($content_type['other'])) {
foreach($content_type['other'] AS $p_name => $p_value) {
$return->ctype_parameters[$p_name] = $p_value;
}
}
@@ -235,7 +234,7 @@ function _decode($headers, $body, $default_ctype = 'text/plain')
$content_disposition = $this->_parseHeaderValue($headers[$key]['value']);
$return->disposition = $content_disposition['value'];
if (isset($content_disposition['other'])) {
while (list($p_name, $p_value) = each($content_disposition['other'])) {
foreach($content_disposition['other'] AS $p_name => $p_value) {
$return->d_parameters[$p_name] = $p_value;
}
}
@@ -555,7 +554,9 @@ function _quotedPrintableDecode($input)
$input = preg_replace("/=\r?\n/", '', $input);
// Replace encoded characters
$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input);
$input = quoted_printable_decode($input);
#OLD, no longer working with preg_replace 'e' modifier
#$input = preg_replace('/=([a-f0-9]{2})/ie', "chr(hexdec('\\1'))", $input);
return $input;
}
@@ -88,7 +88,7 @@
@define('PLUGIN_MF_STRIPTEXT', 'Text nach speziellen Buchstaben abschneiden');
@define('PLUGIN_MF_STRIPTEXT_DESC', 'Wenn Sie Werbung oder andere Textpassagen abschneiden wollen, können Sie hier einen "magischen Text" angeben. Sobald dieser im Inhalt ihrer Mail vorkommt, wird aller Text danach aus dem Eintrag gelöscht.');
@define('PLUGIN_MF_ONLYFROM', 'E-Mail Absender');
@define('PLUGIN_MF_ONLYFROM_DESC', 'Wenn nur ein spezieller Absender anerkannt werden soll, tragen Sie hier diese E-Mail Addresse ein. Bei einem leeren Feld werden alle E-Mails im Blog angenommen');
@define('PLUGIN_MF_ONLYFROM_DESC', 'Wenn nur ein spezieller Absender anerkannt werden soll, tragen Sie hier diese E-Mail Addresse ein. Bei einem leeren Feld werden alle E-Mails im Blog angenommen. Mehrere Mail-Adressen mit Semikolon trennen.');
@define('MF_ERROR_ONLYFROM', 'E-Mail Absender %s entspricht nicht dem zugelassenen Absender %s. Ignoriere E-Mail.');
@define('PLUGIN_MF_SPLITTEXT', 'Spezieller Text, der Text und erweiterten Eintrag einer E-Mail aufteilt');
@@ -95,7 +95,7 @@
@define('PLUGIN_MF_STRIPTEXT_DESC', 'If you want to cut advertisement or other texts, you can specify a "magic string" sequence here. All text after this special string is removed from your posting.');
@define('PLUGIN_MF_ONLYFROM', 'Restrict e-mail sender');
@define('PLUGIN_MF_ONLYFROM_DESC', 'If you only want to allow a certain e-mail address to send mails, you can enter it here. If you leave this field empty, all mails received for your configured account are stored in the blog.');
@define('PLUGIN_MF_ONLYFROM_DESC', 'If you only want to allow a certain e-mail address to send mails, you can enter it here. If you leave this field empty, all mails received for your configured account are stored in the blog. Separate multiple mail adresses with a semicolon.');
@define('MF_ERROR_ONLYFROM', 'E-mail address %s is not the same as configured restriction to %s. Ignoring mail.');
@define('MF_ERROR_NOAUTHOR', 'No author with email address %s. Skipping email.');
@@ -12,7 +12,7 @@
require_once('o2.php');
// Default values
define('POPFETCHER_VERSION', '1.47'); // This version of Popfetcher
define('POPFETCHER_VERSION', '1.48'); // This version of Popfetcher
define('DEFAULT_ADMINMENU', 'true'); // True if run as sidebar plugin. False if external plugin.
define('DEFAULT_HIDENAME', 'popfetcher'); // User should set this to something unguessable
define('DEFAULT_MAILSERVER', '');
@@ -405,7 +405,6 @@ function workComment($id, $commentInfo, $type = 'NORMAL', $source = 'internal')
serendipity_approveComment($cid, $id, true);
serendipity_purgeEntry($id, $t);
return $cid;
} else {
return false;
@@ -477,6 +476,19 @@ function workEntry($subject, &$msgbody, $authorid, &$postex, &$cid, &$s) {
$entry['allow_comments'] = serendipity_db_bool($this->get_config('default_comments', true));
$entry['moderate_comments'] = serendipity_db_bool($this->get_config('default_moderate', false));;
// s9y internally works with false/true strings.
if (serendipity_db_bool($entry['allow_comments'])) {
$entry['allow_comments'] = 'true';
} else {
$entry['allow_comments'] = 'false';
}
if (serendipity_db_bool($entry['moderate_comments'])) {
$entry['moderate_comments'] = 'true';
} else {
$entry['moderate_comments'] = 'false';
}
if (!empty($usetext)) {
// Only match the text we specified.
$this->captureText($usetext, $entry['body']);
@@ -1063,7 +1075,7 @@ function workPopfetcher(&$eventData) {
// Extract the msg from MessArray and store it in Message
$Message[$i-1]='';
while (list($lineNum, $line) = each ($MessArray)) {
foreach($MessArray AS $lineNum => $line) {
$Message[$i-1] .= $line;
}
@@ -1118,11 +1130,26 @@ function workPopfetcher(&$eventData) {
$date = (isset($s->headers['date'])) ? $s->headers['date'] : MF_MSG3;
$from = (isset($s->headers['from'])) ? $s->headers['from'] : MF_MSG4;
if (!empty($onlyfrom) && trim($from) != trim($onlyfrom)) {
$this->out('<br />'.sprintf(MF_ERROR_ONLYFROM, '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($from) : htmlspecialchars($from, ENT_COMPAT, LANG_CHARSET)) . '"', '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($onlyfrom) : htmlspecialchars($onlyfrom, ENT_COMPAT, LANG_CHARSET)) . '"'));
continue;
if (strlen($onlyfrom) > 0) {
$onlyfrom_parts = explode(',', $onlyfrom);
$validSender = false;
foreach($onlyfrom_parts AS $onlyfrom_part) {
if (trim($from) == trim($onlyfrom_part)) {
$validSender = true;
}
if (preg_match('@^[^<]*<([^>]+)>$@imsU', trim($from), $rfc_from)) {
if (trim($rfc_from[1]) == trim($onlyfrom_part)) {
$validSender = true;
}
}
}
if (!$validSender) {
$this->out('<br />'.sprintf(MF_ERROR_ONLYFROM, '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($from) : htmlspecialchars($from, ENT_COMPAT, LANG_CHARSET)) . '"', '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($onlyfrom) : htmlspecialchars($onlyfrom, ENT_COMPAT, LANG_CHARSET)) . '"'));
continue;
}
}
if (empty($s->ctype_parameters['charset'])) {
$s->ctype_parameters['charset'] = 'UTF-8';
}

0 comments on commit 4c00a2b

Please sign in to comment.
You can’t perform that action at this time.