2 function convertquote($body, $reply)
5 $arrbody = explode("\n", trim($body));
8 for ($i = 0; $i < count($arrbody); $i++) {
10 $quoteline = $arrbody[$i];
12 while ((strlen($quoteline)>0) and ((substr($quoteline, 0, 1) == '>')
13 or (substr($quoteline, 0, 1) == ' '))) {
14 if (substr($quoteline, 0, 1) == '>')
17 $quoteline = ltrim(substr($quoteline, 1));
20 //echo $quotelevel.'*'.$quoteline."\r\n";
22 $arrlevel[$i] = $quotelevel;
23 $arrbody[$i] = $quoteline;
28 $arrbodyquoted = array();
30 for ($i = 0; $i < count($arrbody); $i++) {
32 $previousquote = $quotelevel;
33 $quotelevel = $arrlevel[$i];
34 $currline = $arrbody[$i];
36 while ($previousquote < $quotelevel) {
38 $quote = "[quote title=$sender]";
43 $arrbody[$i] = $quote.$arrbody[$i];
47 while ($previousquote > $quotelevel) {
48 $arrbody[$i] = '[/quote]'.$arrbody[$i];
52 $arrbodyquoted[] = $arrbody[$i];
54 while ($quotelevel > 0) {
55 $arrbodyquoted[] = '[/quote]';
59 $body = implode("\n", $arrbodyquoted);
61 if (strlen($body) > 0)
65 $body = removetofu($body);
70 function removetofu($message)
72 $message = trim($message);
75 $oldmessage = $message;
76 $message = preg_replace('=\[/quote\][\s](.*?)\[quote\]=i', '$1', $message);
77 $message = str_replace("[/quote][quote]", "", $message);
78 } while ($message != $oldmessage);
86 while(($pos = strpos($message, '[quote', $start)) > 0) {
95 while(($pos = strpos($message, '[/quote]', $start)) > 0) {
100 while ($endquotes < $startquotes) {
101 $message .= '[/quote]';
107 while(($pos = strpos($message, '[/quote]', $start)) > 0) {
112 if (strtolower(substr($message, -8)) != '[/quote]')
119 foreach ($quotes as $index => $quote) {
120 $quotelevel += $quote;
122 if (($quotelevel == 0) and ($quotestart == 0))
123 $quotestart = $index;
126 if ($quotestart != 0) {
127 $message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart+7, -8).'[/spoiler]';