eKiwi

BB-Codes, Smileys in HTML konvertieren

Diese Funktion setzt BB-Codes (rechtsbündig, linksbündig, zentriert, URL, Marquee, fett, kursiv, unterstrichen), Smileys und E-Mail-Adressen nach HTML um. Die entsprechenden Grafiken für die Smileys müssen in der eingetragenen URL verfügbar sein um angezeigt zu werden.

<?php
/**
* Message formatieren, Smiley und UBB-Code setzen
*
* @param string $message
* @return string
*/
function MessageFormat($message)
{
    
$message = preg_replace( "/<\/?[^\\<>|\/]*>/", "", $message );
    
    
//Zeilenumbrüche
    
    //Smileys
    
$message = str_replace(":)","<img src=\"pics/smiley/s1.gif\">",$message);
    
$message = str_replace(";)","<img src=\"pics/smiley/s2.gif\">",$message);
    
$message = str_replace(":D","<img src=\"pics/smiley/s3.gif\">",$message);
    
$message = str_replace("]:(","<img src=\"pics/smiley/s4.gif\">",$message);
    
$message = str_replace(":(","<img src=\"pics/smiley/s6.gif\">",$message);
    
$message = str_replace(":-((","<img src=\"pics/smiley/s15.gif\">",$message);
    
$message = str_replace("8)","<img src=\"pics/smiley/s8.gif\">",$message);
    
$message = str_replace("::)","<img src=\"pics/smiley/s9.gif\">",$message);
    
$message = str_replace(":P","<img src=\"pics/smiley/s10.gif\">",$message);
    
$message = str_replace(":-[","<img src=\"pics/smiley/s11.gif\">",$message);
    
$message = str_replace(":-X","<img src=\"pics/smiley/s12.gif\">",$message);
    
$message = str_replace(":-\\","<img src=\"pics/smiley/s13.gif\">",$message);
    
$message = str_replace(":-*","<img src=\"pics/smiley/s14.gif\">",$message);
    
$message = str_replace(";D","<img src=\"pics/smiley/s16.gif\">",$message);
    
      
// Bold, Italic, Underlined, PRE, Left, Right, Mid ,marquee
    
$message = preg_replace( "/\[b\](.+?)\[\/b\]/is", "<b>\\1</b>", $message);
      
$message = preg_replace( "/\[u\](.+?)\[\/u\]/is", "<u>\\1</u>", $message);
      
$message = preg_replace( "/\[i\](.+?)\[\/i\]/is", "<i>\\1</i>", $message);
      
      
$message = preg_replace( "/\[pre\](.+?)\[\/pre\]/is", "<pre>\\1</pre>", $message);
      
$message = preg_replace( "/\[left\](.+?)\[\/left\]/is", "<div align=\"left\">\\1</div>", $message);
      
$message = preg_replace( "/\[center\](.+?)\[\/center\]/is", "<div align=\"center\">\\1</div>", $message);
      
$message = preg_replace( "/\[right\](.+?)\[\/right\]/is", "<div align=\"right\">\\1</div>", $message);
      
$message = preg_replace( "/\[move\](.+?)\[\/move\]/is", "<marquee>\\1</marquee>", $message);
      

      
// URL-Tags
      
$message = preg_replace( "/\[url=(.+)\](.+)\[\/url\]/is", "<a href=\"\\1\">\\2</a>", $message);

      
// E-Mail
      
$message = preg_replace( "/(([\.a-zA-Z0-9_-]+)@([.a-zA-Z0-9_-]+)([\.a-zA-Z0-9_-]+))/", "<a href=\"mailto:\\2@\\3\\4\">\\1</a>", $message);
    
      
$message = nl2br($message);
      
    return
$message;
}
?>




comments powered by Disqus

Copyright Dunkel & Iwer GbR - Alle Rechte vorbehalten