Subversion Repositories oidplus

Rev

Rev 368 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 368 Rev 386
Line 43... Line 43...
43
                $file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
43
                $file2 = preg_replace('/\.([^.]+)$/', '$'.OIDplus::getCurrentLang().'.\1', $file);
44
                if (file_exists($file2)) $file = $file2;
44
                if (file_exists($file2)) $file = $file2;
45
 
45
 
46
                $cont = file_get_contents($file);
46
                $cont = file_get_contents($file);
47
 
47
               
48
                // make sure the program works even if the user provided HTML is not UTF-8
48
                list($html, $js, $css) = extractHtmlContents($cont);
49
                $cont = iconv(mb_detect_encoding($cont, mb_detect_order(), true), 'UTF-8//IGNORE', $cont);
-
 
50
                $bom = pack('H*','EFBBBF');
49
                $cont = '';
51
                $cont = preg_replace("/^$bom/", '', $cont);
-
 
52
 
-
 
53
                $cont = preg_replace('@^(.+)<body[^>]*>@isU', '', $cont);
50
                if (!empty($js))  $cont .= "<script>\n$js\n</script>";
54
                $cont = preg_replace('@</body>.+$@isU', '', $cont);
-
 
55
                $cont = preg_replace('@<title>.+</title>@isU', '', $cont);
51
                if (!empty($css)) $cont .= "<style>\n$css\n</style>";
56
                $cont = preg_replace('@<h1>.+</h1>@isU', '', $cont, 1);
52
                $cont .= $html;
57
 
53
               
58
                return $cont;
54
                return $cont;
59
        }
55
        }
60
 
56
 
61
        private static function getDocumentTitle($file) {
57
        private static function getDocumentTitle($file) {
Line 68... Line 64...
68
                // make sure the program works even if the user provided HTML is not UTF-8
64
                // make sure the program works even if the user provided HTML is not UTF-8
69
                $cont = iconv(mb_detect_encoding($cont, mb_detect_order(), true), 'UTF-8//IGNORE', $cont);
65
                $cont = iconv(mb_detect_encoding($cont, mb_detect_order(), true), 'UTF-8//IGNORE', $cont);
70
                $bom = pack('H*','EFBBBF');
66
                $bom = pack('H*','EFBBBF');
71
                $cont = preg_replace("/^$bom/", '', $cont);
67
                $cont = preg_replace("/^$bom/", '', $cont);
72
 
68
 
-
 
69
                $m = array();
73
                if (preg_match('@<title>(.+)</title>@ismU', $cont, $m)) return $m[1];
70
                if (preg_match('@<title>(.+)</title>@ismU', $cont, $m)) return $m[1];
74
                if (preg_match('@<h1>(.+)</h1>@ismU', $cont, $m)) return $m[1];
71
                if (preg_match('@<h1>(.+)</h1>@ismU', $cont, $m)) return $m[1];
75
                if (preg_match('@<h2>(.+)</h2>@ismU', $cont, $m)) return $m[1];
72
                if (preg_match('@<h2>(.+)</h2>@ismU', $cont, $m)) return $m[1];
76
                if (preg_match('@<h3>(.+)</h3>@ismU', $cont, $m)) return $m[1];
73
                if (preg_match('@<h3>(.+)</h3>@ismU', $cont, $m)) return $m[1];
77
                if (preg_match('@<h4>(.+)</h4>@ismU', $cont, $m)) return $m[1];
74
                if (preg_match('@<h4>(.+)</h4>@ismU', $cont, $m)) return $m[1];