diff --git a/lib/util.php b/lib/util.php --- a/lib/util.php +++ b/lib/util.php @@ -248,6 +248,37 @@ function error_msg($message) // |||:sec:||| vaccation(1) message // -------------------------------------------------- +if (!function_exists("quoted_printable_encode")) { + // only available with PHP >= 5.3.0 + if (function_exists("imap_8bit")) { + function quoted_printable_encode($string) { + return imap_8bit($string); + } + } else { + /** + * Process a string to fit the requirements of RFC2045 section 6.7. Note that + * this works, but replaces more characters than the minimum set. For readability + * the spaces and CRLF pairs aren't encoded though. + */ + function quoted_printable_encode($string) { + $string = str_replace(array('%20', '%0D%0A', '%'), array(' ', "\r\n", '='), rawurlencode($string)); + $string = preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n", $string); + return $string; + } + } +} + +// there should be no need ... quoted_printable_decode is around since PHP4 +if (!function_exists("quoted_printable_decode")) { + if (function_exists("imap_qprint")) { + echo "imap_qprint"; + function quoted_printable_decode($string) { + return imap_qprint($string); + } + } else { + } +} + function vacation_split($message, $decode) { $lines = explode("\n", $message);