public static function parseQuote($message) { $i = 0; $pattern = '#\\[quote=([0-9]+)\\|p\\]#i'; while (preg_match($pattern, $message) && ++$i < 11) { $message = preg_replace_callback($pattern, function ($m) { $username = comments::getUsernameFromCid($m[1], true); return $username ? '[commentquote=[user]' . $username . '[/user] [small][url="' . comments::getURLFromCid($m[1], true) . '"]→ c' . $m[1] . '[/url][/small]]' . comments::getMessage($m[1], true) . '[/commentquote]' : ''; }, $message, 1); } if ($i == 11) { $message = preg_replace('#\\[quote=([0-9]+)\\|p\\]#i', '', $message); } $i = 0; $pattern = '#\\[quote=([0-9]+)\\|u\\]#i'; while (preg_match($pattern, $message) && ++$i < 11) { $message = preg_replace_callback($pattern, function ($m) { $username = comments::getUsernameFromCid($m[1]); return $username ? '[commentquote=[user]' . $username . '[/user] [small][url="' . comments::getURLFromCid($m[1]) . '"]→ c' . $m[1] . '[/url][/small]]' . comments::getMessage($m[1]) . '[/commentquote]' : ''; }, $message, 1); } if ($i == 11) { $message = preg_replace('#\\[quote=([0-9]+)\\|u\\]#i', '', $message); } //Brought back quotes return trim($message); }