831 |
florian |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
if(!defined("PHORUM")) return;
|
|
|
4 |
|
|
|
5 |
// HTML Phorum Mod
|
|
|
6 |
function phorum_html($data)
|
|
|
7 |
{
|
|
|
8 |
$PHORUM = $GLOBALS["PHORUM"];
|
|
|
9 |
|
|
|
10 |
foreach($data as $message_id => $message){
|
|
|
11 |
|
|
|
12 |
if(isset($message["body"])){
|
|
|
13 |
|
|
|
14 |
$body = $message["body"];
|
|
|
15 |
|
|
|
16 |
// restore tags where Phorum has killed them
|
|
|
17 |
$body = preg_replace("!<(\/*[a-z].*?)>!i", "<$1>", $body);
|
|
|
18 |
|
|
|
19 |
// restore escaped &
|
|
|
20 |
$body = str_replace("&", "&", $body);
|
|
|
21 |
|
|
|
22 |
// strip out javascript events
|
|
|
23 |
if(preg_match_all("/<[a-z][^>]+>/i", $body, $matches)){
|
|
|
24 |
$tags=array_unique($matches[0]);
|
|
|
25 |
foreach($tags as $tag){
|
|
|
26 |
$newtag=preg_replace("/\son.+?=[^>]+/i", "$1", $tag);
|
|
|
27 |
$body=str_replace($tag, $newtag, $body);
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
// turn script and meta tags into comments
|
|
|
32 |
$body=preg_replace("/<(\/*(script|meta).*?)>/i", "<!--$1-->", $body);
|
|
|
33 |
|
|
|
34 |
// strip any <br phorum=\"true\" /> that got inside certain blocks like tables and pre.
|
|
|
35 |
$block_tags="table|pre|xmp";
|
|
|
36 |
|
|
|
37 |
preg_match_all("!(<($block_tags).*?>).+?(</($block_tags).*?>)!ms", $body, $matches);
|
|
|
38 |
|
|
|
39 |
foreach($matches[0] as $block){
|
|
|
40 |
$newblock=str_replace("<br phorum=\"true\" />", "", $block);
|
|
|
41 |
$body=str_replace($block, $newblock, $body);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$data[$message_id]["body"] = $body;
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
return $data;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
?>
|