3 function savereplace($pattern, $replace, $text)
7 $text = preg_replace($pattern, $replace, $text);
14 function unifyattributionline($message)
16 $quotestr = array('quote', 'spoiler');
17 foreach ($quotestr as $quote) {
19 $message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
20 $message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
22 $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?) <(.*?)>\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message);
23 $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\sDatum: (.*?)\s.*Von: "([^<"].*?)" <(.*?)>\s.*An: (.*?)\n.*/i', "[".$quote."='$2']\n", $message);
24 $message = savereplace('/-------- Original-Nachricht --------\s*\['.$quote.'\]\nDatum: (.*?)\nVon: (.*?)\nAn: (.*?)\nBetreff: (.*?)\n/i', "[".$quote."='$2']\n", $message);
26 $message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?).*:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
27 $message = savereplace('/-----Urspr.*?ngliche Nachricht-----\sVon: "([^<"].*?)" <(.*?)>\s.*Gesendet: (.*?)\s.*An: (.*?)\s.*Betreff: ([^\n].*?)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
29 $message = savereplace('/Am (.*?), schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
31 $message = savereplace('/Am .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\sschrieb\s(.*?)\s<(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
33 $message = savereplace('/Am (.*?) schrieb (.*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
34 $message = savereplace('/Am (.*?) schrieb <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
35 $message = savereplace('/Am (.*?) schrieb (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
36 $message = savereplace('/Am (.*?) schrieb (.*?)\n(.*?):\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
38 $message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
40 $message = savereplace('/On .*?, \d+ .*? \d+ \d+:\d+:\d+ \+\d+\s(.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
42 $message = savereplace('/On (.*?) at (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message);
43 $message = savereplace('/On (.*?)\n([^<].*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
44 $message = savereplace('/On (.*?), (.*?), (.*?)\s<(.*?)>\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$3']\n", $message);
45 $message = savereplace('/On ([^,].*?), (.*?)\swrote:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
46 $message = savereplace('/On (.*?), (.*?)\swrote\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
48 // Der loescht manchmal den Body - was eigentlich unmoeglich ist
49 $message = savereplace('/On (.*?),(.*?),(.*?),(.*?), (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$5']\n", $message);
51 $message = savereplace('/Zitat von ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
53 $message = savereplace('/Quoting ([^<].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
55 $message = savereplace('/From: "([^<"].*?)" <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
56 $message = savereplace('/From: <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
58 $message = savereplace('/Du \(([^)].*?)\) schreibst:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
60 $message = savereplace('/--- (.*?) <.*?> schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
61 $message = savereplace('/--- (.*?) schrieb am (.*?):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
63 $message = savereplace('/\* (.*?) <(.*?)> hat geschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
65 $message = savereplace('/(.*?) <(.*?)> schrieb (.*?)\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
66 $message = savereplace('/(.*?) <(.*?)> schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
67 $message = savereplace('/(.*?) schrieb am (.*?) um (.*):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
68 $message = savereplace('/(.*?) \((.*?)\) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
69 $message = savereplace('/(.*?) schrieb:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
71 $message = savereplace('/(.*?) <(.*?)> writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
72 $message = savereplace('/(.*?) \((.*?)\) writes:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
73 $message = savereplace('/(.*?) writes:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
75 $message = savereplace('/\* (.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
76 $message = savereplace('/(.*?) wrote \(.*?\):\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
77 $message = savereplace('/(.*?) wrote:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
79 $message = savereplace('/([^<].*?) <.*?> hat am (.*?)\sum\s(.*)\sgeschrieben:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
81 $message = savereplace('/(\d+)\/(\d+)\/(\d+) ([^<"].*?) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
82 $message = savereplace('/(\d+)\/(\d+)\/(\d+) (.*?) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
83 $message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>:\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
84 $message = savereplace('/(\d+)\/(\d+)\/(\d+) <(.*?)>\s*\['.$quote.'\]/i', "[".$quote."='$4']\n", $message);
86 $message = savereplace('/(.*?) <(.*?)> schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
87 $message = savereplace('/(.*?) \((.*?)\) schrubselte:\s*\['.$quote.'\]/i', "[".$quote."='$2']\n", $message);
93 function removegpg($message)
96 $pattern = '/(.*)\s*-----BEGIN PGP SIGNED MESSAGE-----\s*[\r\n].*Hash:.*?[\r\n](.*)'.
97 '[\r\n]\s*-----BEGIN PGP SIGNATURE-----\s*[\r\n].*'.
98 '[\r\n]\s*-----END PGP SIGNATURE-----(.*)/is';
100 preg_match($pattern, $message, $result);
102 $cleaned = trim($result[1].$result[2].$result[3]);
104 $cleaned = str_replace(array("\n- --\n", "\n- -"), array("\n-- \n", "\n-"), $cleaned);
113 function removesig($message)
115 $sigpos = strrpos($message, "\n-- \n");
116 $quotepos = strrpos($message, "[/quote]");
119 // Speziell fuer web.de, die das als Trenner verwenden
120 $message = str_replace("\n___________________________________________________________\n", "\n-- \n", $message);
121 $sigpos = strrpos($message, "\n-- \n");
122 $quotepos = strrpos($message, "[/quote]");
125 // Sollte sich der Signaturtrenner innerhalb eines Quotes befinden
126 // wird keine Signaturtrennung ausgefuehrt
127 if (($sigpos < $quotepos) and ($sigpos != 0))
128 return(array('body' => $message, 'sig' => ''));
130 /// @TODO Regexp umstellen, so dass auf 1 oder kein Leerzeichen
132 /// $message = str_replace("\n--\n", "\n-- \n", $message);
134 $pattern = '/(.*)[\r\n]-- [\r\n](.*)/is';
136 preg_match($pattern, $message, $result);
138 if (($result[1] != '') and ($result[2] != '')) {
139 $cleaned = trim($result[1])."\n";
140 $sig = trim($result[2]);
141 // '[hr][size=x-small][color=darkblue]'.trim($result[2]).'[/color][/size]';
147 return(array('body' => $cleaned, 'sig' => $sig));
150 function removelinebreak($message)
152 $arrbody = explode("\n", trim($message));
157 foreach($arrbody as $i => $line) {
160 while ((strlen($currline)>0) and ((substr($currline, 0, 1) == '>')
161 or (substr($currline, 0, 1) == ' '))) {
162 if (substr($currline, 0, 1) == '>')
165 $currline = ltrim(substr($currline, 1));
169 $nextline = trim($arrbody[$i+1]);
170 while ((strlen($nextline)>0) and ((substr($nextline, 0, 1) == '>')
171 or (substr($nextline, 0, 1) == ' '))) {
172 if (substr($nextline, 0, 1) == '>')
175 $nextline = ltrim(substr($nextline, 1));
178 $len = strlen($line);
179 $firstword = strpos($nextline.' ', ' ');
181 $specialchars = ((substr(trim($nextline), 0, 1) == '-') or
182 (substr(trim($nextline), 0, 1) == '=') or
183 (substr(trim($nextline), 0, 1) == '*') or
184 (substr(trim($nextline), 0, 1) == '·') or
185 (substr(trim($nextline), 0, 4) == '[url') or
186 (substr(trim($nextline), 0, 5) == '[size') or
187 (substr(trim($nextline), 0, 7) == 'http://') or
188 (substr(trim($nextline), 0, 8) == 'https://'));
191 $specialchars = ((substr(rtrim($line), -1) == '-') or
192 (substr(rtrim($line), -1) == '=') or
193 (substr(rtrim($line), -1) == '*') or
194 (substr(rtrim($line), -1) == '·') or
195 (substr(rtrim($line), -6) == '[/url]') or
196 (substr(rtrim($line), -7) == '[/size]'));
199 // echo ("Special\n");
201 if ($lines[$lineno] != '') {
202 if (substr($lines[$lineno], -1) != ' ')
203 $lines[$lineno] .= ' ';
205 while ((strlen($line)>0) and ((substr($line, 0, 1) == '>')
206 or (substr($line, 0, 1) == ' '))) {
208 $line = ltrim(substr($line, 1));
213 // $lines[$lineno] = $quotelevel.'-'.$len.'-'.$firstword.'-';
215 $lines[$lineno] .= $line;
216 //if ((($len + $firstword < 68) and (substr($line, -1, 1) != ' '))
217 // or ($quotelevel != $currquotelevel) or $specialchars)
218 if (((substr($line, -1, 1) != ' '))
219 or ($quotelevel != $currquotelevel))
222 return(implode("\n", $lines));