X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fdiogenes.compose.inc.php;fp=include%2Fdiogenes.compose.inc.php;h=1d5bef0b04c9a2ede9aa86486d3bc4fa79ef148e;hb=6855525e48fad5de270500a5445c4f4ff85d8bda;hp=0000000000000000000000000000000000000000;hpb=e69709aa8ee6108a1197e46b45367ba8dab55a52;p=diogenes.git diff --git a/include/diogenes.compose.inc.php b/include/diogenes.compose.inc.php new file mode 100644 index 0000000..1d5bef0 --- /dev/null +++ b/include/diogenes.compose.inc.php @@ -0,0 +1,81 @@ +)/",$input,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $output = ""; + + while ($block = array_shift($splits)) { + if ($block == "") + die("phpProtect : parse error"); + $output .= "{PHP:".base64_encode($code).":PHP}"; + } else { + $output .= $block; + } + } + + return $output; +} + + +/** Unprotect PHP code. + */ +function phpUnprotect($input) +{ + $splits = preg_split("/({PHP:.+:PHP})/",$input,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + $output = ""; + + foreach ($splits as $block) { + if (preg_match("/{PHP:(.+):PHP}/",$block,$match)) { + $output .= ""; + } else { + $output .= $block; + } + } + + return $output; +} + + +/** Convert XHTML-compliant tags to plain HTML. + */ +function xhtmlToHtml($input) +{ + return html_accent(preg_replace("/<(br|img|input|p)( [^\/]*)?\/>/","<\$1\$2>",$input)); +} + + +/** Restore XHTML-compliant tags. + */ +function htmlToXhtml($input) +{ + return preg_replace("/<(br|img|input)( [^>]+)?>/","<\$1\$2/>",$input); +} + +?>