Example #1
0
   |          Gougou                                                     |
   +---------------------------------------------------------------------+
*/
function xhtml_highlight_string($chaine, $lignes = FALSE, $retour = FALSE)
{
    $source = str_replace("</font>", "</span>", str_replace("<font color=\"", "<span style=\"color:", highlight_string($chaine, TRUE)));
    if ($lignes) {
        $leslignes = explode("<br />", $source);
        $no = 1;
        $source = "";
        foreach ($leslignes as $laligne) {
            $source .= sprintf("<span style=\"color:#666666\">%04d </span>", $no++) . $laligne . "<br />\n";
        }
        $source = str_replace("<span style=\"color:#666666\">0001 </span><code>", "<code><span style=\"color:#666666\">0001 </span>", $source);
    }
    if ($retour) {
        return $source;
    }
    echo $source;
}
echo '<table border=0 >';
echo '<tr> ';
echo '<td bgcolor="#CCFFCC" class=text style="border: 3px dashed"><p>&nbsp;</p>';
if ($_POST['code'] != '') {
    echo xhtml_highlight_string($_POST['code'], true, false, false);
} else {
    echo xhtml_highlight_string($_GET['code'], true, false, false);
}
echo '</b></p><FORM><p align=center><INPUT TYPE="BUTTON" VALUE="Go back / Retour" ONCLICK="javascript:history.go(-1);" class="input"></p></td>';
echo '</tr>';
echo '</table>';
function parse_code_line($texte)
{
    global $strCode;
    preg_match_all("`\\[code=line\\](.*?)\\[/code\\]`si", $texte, $matches);
    $nb_matches = count($matches[1]);
    for ($i = 0; $i < $nb_matches; $i++) {
        $xyz = array('#\\[#', '#\\]#');
        $replace_xyz = array('&fs1;', '&fs2;');
        $origine = $matches[1][$i];
        $remplacement = $matches[1][$i];
        $remplacement = preg_replace($xyz, $replace_xyz, $remplacement);
        $remplacement = str_replace("  ", "&nbsp; ", $remplacement);
        $remplacement = str_replace("  ", " &nbsp;", $remplacement);
        $remplacement = xhtml_highlight_string($remplacement, false, true, false);
        $origine = '[code=line]' . $origine . '[/code]';
        $remplacement = '[code=line]' . $remplacement . '[/code]';
        $texte = str_replace($origine, $remplacement, $texte);
    }
    $texte = preg_replace("`\\[code=line\\](.*?)\\[/code\\]`si", sprintf('<br><br /><table class="table" style="width: %s;" align="center" cellspacing="0" cellpadding="3"><tr><td class="code_titre">%s</td></tr><tr><td class="code"><code>%s</code></td></tr></table><br>', '90%', $strCode, '\\1'), $texte);
    return $texte;
}