Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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("!&lt;(\/*[a-z].*?)&gt;!i", "<$1>", $body);
18
 
19
            // restore escaped &
20
            $body = str_replace("&amp;", "&", $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
?>