login  Naam:   Wachtwoord: 
Registreer je!
 Forum

[PHP][UBB] Code-tag wordt niet geparsed

Offline DeviLGuY - 12/12/2005 21:28
Avatar van DeviLGuYNieuw lid Hoi,

Ik ben nu bezig een niet UBB-systeem te maken, nu heb ik alleen het probleem dat ie de code's niet weergeeft.
Dit is de code:
  1. <?php
  2. class ubb {
  3. function code($code) {
  4. $iscode = explode("[code]", $code);
  5. $iscode2 = explode("
", $code);
if (count($iscode) > "0" && count($iscode2) > "1") {
$showcode = $iscode[1].$iscode2[1];
$showcode = str_replace("
  1. ", "", $showcode);
  2. $showcode = str_replace("
", "", $showcode);
return highlight_string($showcode);
}
}
function parseubb($code) {
$code = htmlspecialchars($code);
$code = nl2br($code);
$tags = Array (
"(.*?)" => "<b>\\1</b>",
"(.*?)" => "<u>\\1</u>",
"(.*?)" => "<i>\\1</i>",
"(.*?)" => "<s>\\1</s>",
"[small](.*?)[/small]" => "<small>\\1</small>",
"[url]http://(.*?)[/url]" => "<A href=\"http://\\1\">http://\\1</A>",
"[url=http://(.*?)](.*?)[/url]" => "<A href=\"http://\\1\">\\2</A>",
"[quote=(.*?)](.*?)[/quote]" => "<DIV class='quotehead'>Quote door \\1:</DIV><DIV class='quote' style='width: 100%; overflow: auto;'>\\2</DIV>",
"
Citaat:
(.*?)
" => "<DIV class='quotehead'>Quote:</DIV><DIV class='quote' style='width: 100%; overflow: auto;'>\\1</DIV>",
"[img](.*?)[/img]" => "<IMG src=\"\\1\" border=\"0\">",
"[img width=(.*?) height=(.*?)](.*?)[/img]" => "<IMG src=\"\\3\" width=\"\\1\" height=\"\\2\" border=\"0\">",
"[img height=(.*?) width=(.*?)](.*?)[/img]" => "<IMG src=\"\\3\" height=\"\\1\" width=\"\\2\" border=\"0\">",
"[img width=(.*?)](.*?)[/img]" => "<IMG src=\"\\2\" width=\"\\1\" border=\"0\">",
"[img height=(.*?)](.*?)[/img]" => "<IMG src=\"\\2\" height=\"\\1\" border=\"0\">"
);
$code = preg_replace("_\[code\](.*?)\[\/code\]_is", "$this->code(".$code.")", $code);
$code = preg_replace("_\[php\](.*?)\[\/php\]_is", "$this->code(".$code.")", $code);
foreach ($tags as $tag => $html) {
$tag = str_replace("[", "\[", $tag);
$tag = str_replace("]", "\]", $tag);
$tag = str_replace("/", "\/", $tag);
if (eregi("highlight\_string\('", $tag)) {
$tag = preg_replace("_highlight_string('(.*?)')_is", highlight_string('\\1'), $tag);
}
$code = preg_replace("_".$tag."_is", $html, $code);
}
#if (eregi("\[code\]", $code) && eregi("\[\/code\]", $code)) {
# $code = code(preg_replace("\[code\](.*?)\[\/code\]_is", ".", $code));
#}
return $code;
}
}
$ubb = new ubb;
echo $ubb->parseubb($_POST['ubb'])."<br /><br />";
?>[/code]

Dit is de input:
Citaat:
[..]
[code*]<?php
/* UBB Systeem - Door Q-DeviL */
echo "<A href="http://www.webcentra.nl">Webcentra.nl</A>";
?>[/code]


En dit is de output:
Citaat:
[..]
[..code..])


Wat doe ik fout?

Let op! Dit is een crosspost met WMCity.nl

0 antwoorden

Gesponsorde links
Er zijn nog geen reacties op dit bericht.
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.303s