Onbekend |
|
Ik heb mijn ubb.class veranderd naar dit:
includes/ubb.class.php
<?php
error_reporting(E_ALL);
class UbbCodes
{
#variabelen
var $text;
#constructie
function UbbCodes ($text)
{
$this->text = $text;
}
#woorden
function woorden ()
{
$this->text = htmlentities($this->text, ENT_QUOTES);
$artikel_query = mysql_query("SELECT `id`, `letter`, `woord`, `omschrijving` FROM `woordenboek`") or die (mysql_error());
while($artikel = mysql_fetch_assoc($artikel_query))
{
$this->text = str_replace ( "[?]".$artikel['woord']."[/?]", "<a href=\"../woordenboek/index.php?zoekwoord=".$artikel['woord']."\" style=\"cursor: help;\" title=\"Zoek in het woordenboek naar ".$artikel['woord']."\"><i>".$artikel['woord']."</i></a>", $this->text );
}
}
#tekstopmaak
function tekstopmaak ()
{
$this->text = preg_replace ( "_\[b\](.*?)\[/b\]_ise", "<b>\\1</b>", $this->text );
$this->text = preg_replace ( "_\[u\](.*?)\[/u\]_ise", "<u>\\1</u>", $this->text );
$this->text = preg_replace ( "_\[i\](.*?)\[/i\]_ise", "<i>\\1</i>", $this->text );
$this->text = preg_replace ( "_\[s\](.*?)\[/s\]_ise", "<s>\\1</s>", $this->text );
$this->text = preg_replace ( "_\[h1\](.*?)\[/h1\]_ise", "<h1>\\1</h1>", $this->text );
$this->text = preg_replace ( "_\[h2\](.*?)\[/h2\]_ise", "<h2>\\1</h2>", $this->text );
$this->text = preg_replace ( "_\[h3\](.*?)\[/h3\]_ise", "<h3>\\1</h3>", $this->text );
$this->text = preg_replace ( "_\[h4\](.*?)\[/h4\]_ise", "<h4>\\1</h4>", $this->text );
}
#link
function link ()
{
$this->text = eregi_replace ( "\[url\]www.([^\[]*)","<a href=\"http://www.\\1\" target=_blank>\\1", $this->text );
$this->text = eregi_replace ( "\[url\]([^\[]*)","<a href=\"\\1\" target=_blank>\\1", $this->text );
$this->text = eregi_replace ( "(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"http://\\2\" target=_blank>", $this->text );
$this->text = eregi_replace ( "\[url](http://(.*))", "<a href=\"\\1\" target=\"_blank\">\\1", $this->text );
$this->text = eregi_replace ( "(\[/url\])", "</a>", $this->text );
$this->text = eregi_replace ( "http://http://", "http://", $this->text );
}
#smilies
function smilies ()
{
$this->text = str_replace ( ":)", "<img src=\"../../afbeeldingen/lach.gif\">", $this->text );
$this->text = str_replace ( ":-)", "<img src=\"../../afbeeldingen/lach.gif\">", $this->text );
$this->text = str_replace ( ":P", "<img src=\"../../afbeeldingen/tong.gif\">", $this->text );
$this->text = str_replace ( ":-P", "<img src=\"../../afbeeldingen/tong.gif\">", $this->text );
$this->text = str_replace ( ":(", "<img src=\"../../afbeeldingen/droevig.gif\">", $this->text );
$this->text = str_replace ( ":-(", "<img src=\"../../afbeeldingen/droevig.gif\">", $this->text );
$this->text = str_replace ( ":D", "<img src=\"../../afbeeldingen/blij.gif\">", $this->text );
$this->text = str_replace ( ":-D", "<img src=\"../../afbeeldingen/blij.gif\">", $this->text );
}
#quote
function quote ()
{
$this->text = preg_replace ( "_\[quote\](.*?)\[/quote\]_ise", "<table width=\"80%\"><tr><td>QUOTE:</td><td>\\1</td></tr></table>", $this->text );
}
#code
function code ()
{
$this->text = preg_replace ( "_\[code\](.*?)\[/code\]_ise", "<table width=\"80%\"><tr><td>CODE:</td><td>\\1</td></tr></table>", $this->text );
}
#plaatjes
function plaatjes ()
{
$this->text = preg_replace ( "_\[img\](.*?)\[/img\]_ise", "<img src=\"\\1\" />", $this->text );
}
#laten zien
function show ()
{
UbbCodes::woorden();
UbbCodes::tekstopmaak();
UbbCodes::link();
UbbCodes::smilies();
UbbCodes::quote();
UbbCodes::code();
UbbCodes::plaatjes();
return $this->text;
}
}
?>
<?php class UbbCodes { #variabelen var $text; #constructie function UbbCodes ($text) { $this->text = $text; } #woorden function woorden () { { $this->text = str_replace ( "[?]".$artikel['woord']."[/?]", "<a href=\"../woordenboek/index.php?zoekwoord=".$artikel['woord']."\" style=\"cursor: help;\" title=\"Zoek in het woordenboek naar ".$artikel['woord']."\"><i>".$artikel['woord']."</i></a>", $this->text ); } } #tekstopmaak function tekstopmaak () { $this->text = preg_replace ( "_\[b\](.*?)\[/b\]_ise", "<b>\\1</b>", $this->text ); $this->text = preg_replace ( "_\[u\](.*?)\[/u\]_ise", "<u>\\1</u>", $this->text ); $this->text = preg_replace ( "_\[i\](.*?)\[/i\]_ise", "<i>\\1</i>", $this->text ); $this->text = preg_replace ( "_\[s\](.*?)\[/s\]_ise", "<s>\\1</s>", $this->text ); $this->text = preg_replace ( "_\[h1\](.*?)\[/h1\]_ise", "<h1>\\1</h1>", $this->text ); $this->text = preg_replace ( "_\[h2\](.*?)\[/h2\]_ise", "<h2>\\1</h2>", $this->text ); $this->text = preg_replace ( "_\[h3\](.*?)\[/h3\]_ise", "<h3>\\1</h3>", $this->text ); $this->text = preg_replace ( "_\[h4\](.*?)\[/h4\]_ise", "<h4>\\1</h4>", $this->text ); } #link { $this->text = eregi_replace ( "\[url\]www.([^\[]*)","<a href=\"http://www.\\1\" target=_blank>\\1", $this->text ); $this->text = eregi_replace ( "\[url\]([^\[]*)","<a href=\"\\1\" target=_blank>\\1", $this->text ); $this->text = eregi_replace ( "(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"http://\\2\" target=_blank>", $this->text ); $this->text = eregi_replace ( "\[url](http://(.*))", "<a href=\"\\1\" target=\"_blank\">\\1", $this->text ); $this->text = eregi_replace ( "(\[/url\])", "</a>", $this->text ); $this->text = eregi_replace ( "http://http://", "http://", $this->text ); } #smilies function smilies () { $this->text = str_replace ( ":)", "<img src=\"../../afbeeldingen/lach.gif\">", $this->text ); $this->text = str_replace ( ":-)", "<img src=\"../../afbeeldingen/lach.gif\">", $this->text ); $this->text = str_replace ( ":P", "<img src=\"../../afbeeldingen/tong.gif\">", $this->text ); $this->text = str_replace ( ":-P", "<img src=\"../../afbeeldingen/tong.gif\">", $this->text ); $this->text = str_replace ( ":(", "<img src=\"../../afbeeldingen/droevig.gif\">", $this->text ); $this->text = str_replace ( ":-(", "<img src=\"../../afbeeldingen/droevig.gif\">", $this->text ); $this->text = str_replace ( ":D", "<img src=\"../../afbeeldingen/blij.gif\">", $this->text ); $this->text = str_replace ( ":-D", "<img src=\"../../afbeeldingen/blij.gif\">", $this->text ); } #quote function quote () { $this->text = preg_replace ( "_\[quote\](.*?)\[/quote\]_ise", "<table width=\"80%\"><tr><td>QUOTE:</td><td>\\1</td></tr></table>", $this->text ); } #code function code () { $this->text = preg_replace ( "_\[code\](.*?)\[/code\]_ise", "<table width=\"80%\"><tr><td>CODE:</td><td>\\1</td></tr></table>", $this->text ); } #plaatjes function plaatjes () { $this->text = preg_replace ( "_\[img\](.*?)\[/img\]_ise", "<img src=\"\\1\" />", $this->text ); } #laten zien function show () { UbbCodes::woorden(); UbbCodes::tekstopmaak(); UbbCodes::smilies(); UbbCodes::quote(); UbbCodes::code(); UbbCodes::plaatjes(); return $this->text; } } ?>
En ik roep hem zo aan:
<?php
include ("includes/ubb.class.php");
include ("includes/config.inc.php");
error_reporting(E_ALL);
$text = "Dit wordt de quote [quote]Hallo dit is een quote van mij[/quote] Dit is een code [";
$procesText = new UbbCodes($text);
$newText = $procesText->show();
echo $newText;
include ("includes/footer.inc.php");
?>
<?php include ("includes/ubb.class.php"); include ("includes/config.inc.php"); $text = "Dit wordt de quote [quote]Hallo dit is een quote van mij[/quote] Dit is een code ["; $procesText = new UbbCodes($text); $newText = $procesText->show(); include ("includes/footer.inc.php"); ?>
Maar hij geeft dan alleen een leeg scherm.
(Sorry voor de code maar er is iets mis met plaatscode.be |