Voici la fonction exact:
<?php
function getGeshi($match) {
include_once('geshi/geshi.php'); // Inclure la librairie GeSHi
$geshi = new GeSHi($match[2], $match[1]); // Créer un objet "GeSHi"
$code = '<table width="1000" border="0" cellspacing="0" cellpadding="0"><tr><td height="20" background="images/quoteh.gif"> </td></tr><tr><td background="images/quotem.gif"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td>'.$geshi->parse_code().'</td></tr></table></td></tr><tr><td height="20" background="images/quoteb.gif"></td></tr></table>';
return $code; // Retourne le résultat
}
function ChangeBR($retour) {
$retour[1] = preg_replace("`\<br((\s*)\/?)\>`ims", '[[br]]', $retour[1]);
return $retour[1];
}
function nl2brCallback($retour) {
$retour[1] = preg_replace("`\<br((\s*)\/?)\>`ims", '', $retour[1]);
$retour[1] = preg_replace("`\[\[br\]\]+`ims", "\r", $retour[1]);
return $retour[1];
}
$text = code(nl2br($tuto['tuto_tuto']));
$text = preg_replace_callback("`(\[quote=(as|php|css)\]+(.*?)\[\/quote\])`isSm", 'ChangeBR', $text);
$text = preg_replace_callback("`(\[quote=(as|php|css)\]+(.*?)\[\/quote\])`isSm", 'nl2brCallback', $text);
$text = preg_replace_callback('/\[quote=(.*?)\](.*?)\[\/quote\]/is', 'getGeshi', $text);
echo $text;
?>
Dans le masque (as|php|css) de la regex il faudra que tu mette tout les language autorisé comme ceci:(as|php|css|js|html|sharp|java|sql|etc)