aller c'est cadeau je te file mon parser... par contre je l'ai fais il y a pas mal de temps y'a surement moyen de l'améliorer ^^
<?
Function CallBack_Interpreter_IMG($img)
{
if($tabSize = @GetImageSize($img[1]))
{
if($tabSize[0] > 450) $width = 450; else $width = $tabSize[0];
Return "<a href='".$img[1]."' target='_blank'><img src='".$img[1]."' class='post-img' width=".$width." alt='".$img[1]."' align='absmiddle' border=0></a>";
}
else
{
Return "<span class="texteBleu">image non valide ou déplacée : [".$img[1]."]</span>";
}
}
Function CallBack_LienMembre($pseudo)
{
if(!empty($pseudo[1]))
{
$conn = ConnectDB();
$Req = "SELECT ME_id FROM membre WHERE ME_pseudo='".$pseudo[1]."'";
$Res = MySQL_Query($Req,$conn) Or die(MySQL_Error());
$Nb = MySQL_NumRows($Res);
if($Nb==1) Return "<a href="http://".$pseudo[1].".benzor.com" target="_self">".$pseudo[1]."</a>"; else Return "<span class="texteBleu">Membre inexistant : [".$pseudo[1]."]</span>";
ConnexionFerme($conn);
}
}
Function CallBack_LienNom($lien)
{
if(Substr($lien[1],0,7) !="http://")
{
$lien[1] = "http://".$lien[1];
$lien[3] = MyTruncate($lien[3],25);
Return "<a href="".$lien[1]."" target="_blank" title="".$lien[1]."">".$lien[3]."</a>";
}
else
{
$lien[2] = MyTruncate($lien[2],25);
Return "<a href="".$lien[1]."" target="_blank" title="".$lien[1]."">".$lien[2]."</a>";
}
}
Function CallBack_Lien($lien)
{
if(Substr($lien[1],0,7) !="http://")
{
$lien[1] = "http://".$lien[1];
}
Return "<a href="".$lien[1]."" target="_blank" title="".$lien[1]."">".TronquerLien($lien[1],25)."</a>";
}
Function CallBack_Email($email)
{
$tabEmail = CrypterEmail($email[1]);
Return "<a href="javascript:MailBz('".$tabEmail[0]."','".$tabEmail[1]."');">".$tabEmail[5]."@NoSpam</a>";
}
Function ColorPhpCode($Code) {
$Color['html'] = '#339933';
$Color['comment'] = '#cc66cc';
$Color['default'] = '#336699';
$Color['keyword'] = '#ff8000';
$Color['string'] = '#999999';
$ret = highlight_string($Code, true);
$in = array(
'`</?code>`i',
'`<(?:font color="|span style="color: )' . ini_get('highlight.html') . '">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )' . ini_get('highlight.comment') . '">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )' . ini_get('highlight.default') . '">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )' . ini_get('highlight.keyword') . '">(.+?)</(?:font|span)>`si',
'`<(?:font color="|span style="color: )' . ini_get('highlight.string') . '">(.+?)</(?:font|span)>`si',
'` `si'
);
$out = array(
'',
'<span style="color:' . $Color['html'] . '">$1</span>',
'<span style="color:' . $Color['comment'] . '">$1</span>',
'<span style="color:' . $Color['default'] . '">$1</span>',
'<span style="color:' . $Color['keyword'] . '">$1</span>',
'<span style="color:' . $Color['string' ] . '">$1</span>',
' '
);
Return "<div class='layerCode'>".preg_replace($in, $out, $ret)."</div>";
}
Function InterpreterCouleur($couleur)
{
Return "<font color='#".$couleur."'>";
}
Function Interpreter_Styles($chaine)
{
$chaine = preg_replace("([#([0-9a-fA-F]{6})](.+?)[/#])",'<font color="#$1">$2</font>',$chaine); // Font color
$chaine = preg_replace("([b](.+?)[/b])",'<b>$1</b>',$chaine); // Bold
$chaine = preg_replace("([i](.+?)[/i])",'<i>$1</i>',$chaine); // Italique
$chaine = preg_replace("([u](.+?)[/u])",'<u>$1</u>',$chaine); // Underline
$chaine = preg_replace("([s](.+?)[/s])",'<s>$1</s>',$chaine); // Barré
$chaine = preg_replace("([texteGris](.+?)[/texteGris])",'<span class="texteGris">$1</span>',$chaine); // Footer Notifs internes
$chaine = preg_replace("([center](.+?)[/center])",'<center>$1</center>',$chaine); // Centré
$chaine = preg_replace("([li](.+?)[/li])","<img src="http://www.benzor.com/images/puce.gif" Style="margin-right:2px;">$1",$chaine); // Puce
$chaine = preg_replace_callback("([M=(.+?)])","CallBack_LienMembre",$chaine); // Liens membre
/* Gestion des URLS */
$chaine = preg_replace_callback("#[url=([w]+?://[w#$%&~/.-;:=,?@[]+]*?)]([^?nrt].*?)[/url]#is","CallBack_LienNom",$chaine);
$chaine = preg_replace_callback("#[url=((www|ftp).[w#$%&~/.-;:=,?@[]+]*?)]([^?nrt].*?)[/url]#is","CallBack_LienNom",$chaine);
$chaine = preg_replace_callback("#[url]([w]+?://([w#$%&~/.-;:=,?@]+]+|[(?!url=))*?)[/url]#is","CallBack_Lien",$chaine);
$chaine = preg_replace_callback("#[url]((www|ftp).([w#$%&~/.-;:=,?@]+]+|[(?!url=))*?)[/url]#is","CallBack_Lien",$chaine);
/* Gestion des emails */
$chaine = preg_replace_callback("#[email]([a-z0-9&-_.]+?@[w-]+.([w-.]+.)?[w]+)[/email]#si","CallBack_Email",$chaine);
/* Gestion des images */
$chaine = preg_replace_callback("#[img]([^?](?:[^[]+|[(?!url))*?)[/img]#i","CallBack_Interpreter_IMG",$chaine);
Return $chaine;
}
Function VerifStyle($chaine)
{
if(preg_match("#([img](.+?))#is",$chaine)) Return true;
else if(preg_match("#([M=(.+?))#is",$chaine)) Return true;
else if(preg_match("#([url=(.+?))#is",$chaine)) Return true;
else if(preg_match("#([url](.+?))#is",$chaine)) Return true;
else if(preg_match("#([email](.+?))#is",$chaine)) Return true;
else Return false;
}
?>