示例#1
0
function parse_content(&$toparse)
{
    $toparse = htmlspecialchars_decode($toparse);
    $explo = explode('|', $toparse);
    foreach ($explo as $index => $part) {
        $part = trim($part);
        if ($part[0] == '+') {
            $func = explode(',', $part, 4);
            switch ($func[0]) {
                case "+img":
                    $explo[$index] = imgtag($func[1], $func[2]);
                    break;
                case "+spacer":
                    $explo[$index] = spacertag($func[1]);
                    break;
                case "+atvgall":
                    $explo[$index] = build_atv_gallery();
                    break;
                case "+imagegall":
                    $explo[$index] = '<h1>Image Gallery</h1>' . imageupload() . '<p><br><br></p>' . delimage() . '<p><br><br></p>' . buildgallery();
                    break;
                case "+csv":
                    $explo[$index] = csvfileupload();
                    break;
                case "+viparea":
                    $explo[$index] = viparea();
                    break;
                case "+dbviewer":
                    $explo[$index] = dbcontrol() . printusers() . printfiles() . printnotes() . printcms();
                    break;
                case "+filedeposit":
                    $explo[$index] = filedeposit();
                    break;
                case "+newsfeed":
                    $explo[$index] = build_newsfeed();
                    break;
                case "+projfeed":
                    $explo[$index] = build_projectfeed($func[1]);
                    break;
                case "+login":
                    $explo[$index] = login_page();
                    break;
                case "+contactprofile":
                    $explo[$index] = profilepage();
                    break;
            }
        }
    }
    $toparse = implode($explo);
}
function html2bbcode($text)
{
    $text = strip_tags($text, '<table><tr><td><b><strong><i><em><u><a><div><span><p><strike><blockquote><ol><ul><li><font><img><br><br/><h1><h2><h3><h4><h5><h6><script>');
    if (ismozilla()) {
        $text = preg_replace("/(?<!<br>|<br \\/>|\r)(\r\n|\n|\r)/", ' ', $text);
    }
    $pregfind = array("/<table([^>]*(width|background|background-color|bgcolor)[^>]*)>/siU", "/<td(.+)>/siU", '/<h([0-9]+)[^>]*>/siU');
    $pregreplace = array(function ($matches) {
        return tabletag($matches[1]);
    }, function ($matches) {
        return tdtag($matches[1]);
    }, function ($matches) {
        return '[size="' . (7 - $matches[1]) . '"]';
    });
    foreach ($pregfind as $key => $p) {
        $text = preg_replace_callback($p, $pregreplace[$key], $text);
    }
    $pregfind = array("/<script.*>.*<\\/script>/siU", '/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', "/(\r\n|\n|\r)/", "/<table.*>/siU", "/<tr.*>/siU", "/<td>/i", "/<\\/td>/i", "/<\\/tr>/i", "/<\\/table>/i", '/<\\/h([0-9]+)>/siU', "/<a\\s+?name=.+?\".\">(.+?)<\\/a>/is", "/<br.*>/siU", "/<span\\s+?style=\"float:\\s+(left|right);\">(.+?)<\\/span>/is");
    $pregreplace = array('', '', '', '[table]', '[tr]', '[td]', '[/td]', '[/tr]', '[/table]', "[/size]\n\n", '\\1', "\n", "[float=\\1]\\2[/float]");
    $text = preg_replace($pregfind, $pregreplace, $text);
    $pregfind = array("/<img[^>]+smilieid=\"(\\d+)\".*>/siU", "/<img([^>]*src[^>]*)>/iU");
    $pregreplace = array(function ($matches) {
        return smileycode($matches[1]);
    }, function ($matches) {
        return imgtag($matches[1]);
    });
    foreach ($pregfind as $key => $p) {
        $text = preg_replace_callback($p, $pregreplace[$key], $text);
    }
    $text = recursion('b', $text, 'simpletag', 'b');
    $text = recursion('strong', $text, 'simpletag', 'b');
    $text = recursion('i', $text, 'simpletag', 'i');
    $text = recursion('em', $text, 'simpletag', 'i');
    $text = recursion('u', $text, 'simpletag', 'u');
    $text = recursion('a', $text, 'atag');
    $text = recursion('font', $text, 'fonttag');
    $text = recursion('blockquote', $text, 'simpletag', 'indent');
    $text = recursion('ol', $text, 'listtag');
    $text = recursion('ul', $text, 'listtag');
    $text = recursion('div', $text, 'divtag');
    $text = recursion('span', $text, 'spantag');
    $text = recursion('p', $text, 'ptag');
    $pregfind = array("/(?<!\r|\n|^)\\[(\\/list|list|\\*)\\]/", "/<li>(.*)((?=<li>)|<\\/li>)/iU", "/<p.*>/iU", "/<p><\\/p>/i", "/(<a>|<\\/a>|<\\/li>)/is", "/<\\/?(A|LI|FONT|DIV|SPAN)>/siU", "/\\[url[^\\]]*\\]\\[\\/url\\]/i", "/\\[url=javascript:[^\\]]*\\](.+?)\\[\\/url\\]/is");
    $pregreplace = array("\n[\\1]", "\\1\n", "\n", '', '', '', '', "\\1");
    $text = preg_replace($pregfind, $pregreplace, $text);
    $strfind = array('&nbsp;', '&lt;', '&gt;', '&amp;');
    $strreplace = array(' ', '<', '>', '&');
    $text = str_replace($strfind, $strreplace, $text);
    return dhtmlspecialchars(trim($text));
}