hallo mensen.

ik heb een vraagje ik heb de volgende scripts + database gemaakt maar ik krijg de smiley's niet te zien in het forum.

wie kan mij helpen:

hier komen de scripts:

forum.php

<?php $title = "Forum";
include("config.php");
include_once("ubb.php");
?>

<?php

// The Topic List
if ($view == topics) {
print "<table><tr><td width=150><u><b>Topic</td><td width=100><u><b>Starter</td><td width=50><b><u>Replies</td></tr>";

$tsel = mysql_query("select * from topics");
while ($topic = mysql_fetch_array($tsel)) {
$replies = mysql_num_rows(mysql_query("select * from replies where topic_id=$topic[id]"));
print "<tr><td><a href=forum.php?topic=$topic[id]>$topic[topic]</a></td><td>$topic[starter]</td><td>$replies</td></tr>";
}

print "</table>";
print "</center><form method=post action=forum.php?action=addtopic>";
print "Add Topic:<br><input type=text name=title2 value=Title><br><textarea name=body cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Topic\"></form>";
}

// View Topic

if ($topic) {
$topicinfo = mysql_fetch_array(mysql_query("select * from topics where id=$topic"));
if (empty ($topicinfo[id])) {
print "No such topic.";
exit;
}
print "<center><br><table class=td width=98% cellpadding=0 cellspacing=0><tr><td style=\"border-bottom: solid black 1px;\"><b>$topicinfo[topic]</b> by $topicinfo[starter] (<a href=forum.php?view=topics>back</a>)</td></tr>";
print "<tr><td>$topicinfo[body]</td></tr></table><br>";

$rsel = mysql_query("select * from replies where topic_id=$topicinfo[id] order by id asc");
while ($reply = mysql_fetch_array($rsel)) {
print "<center><table class=td width=98% cellpadding=0 cellspacing=0><tr><td background=images/forum.PNG><b>$reply[starter]</b> says... (<a href=forum.php?view=topics>back</a>)</td></tr>";
print "<tr><td>$reply[body]</td></tr></table><br>";
}

print "</center><form method=post action=forum.php?reply=$topicinfo[id]>";
print "Add Reply:<br><textarea name=rep cols=30 rows=3>Body</textarea><br><input type=submit value=\"Add Reply\"></form>";
}

?>
<?php
// Add Topic
if ($action == addtopic) {
if (empty ($title) || empty ($body)) {
print "You must fill all fields.";

exit;
}
mysql_query("insert into topics (topic, body, starter) values('$title2', '$body', '$stat[user]')") or die("Could not add topic.");
print "Added topic. Click <a href=forum.php?view=topics>here</a> to go back to the topic list.";
}

?>

</td>
</tr>
</table>
<center>
<form method="topic_id" name="body">
<script language="javascript">
<!--
function add_smiley(smiley)
{
document.body.value += " " + smiley + " ";
}
//-->
</script>
<script language="javascript">
<!--

function add_ubb(ubb)
{
document.body.value += " " + ubb + " ";
}
//-->
</script>
<a href="javascript:add_smiley(':)')"><img src="smilies/smile.gif" border="0"></a>
<a href="javascript:add_smiley(':(')"><img src="smilies/mad.gif" border="0"></a>
<a href="javascript:add_smiley(':\'(')"><img src="smilies/cry.gif" border="0"></a>
<a href="javascript:add_smiley(';)')"><img src="smilies/knipoog.gif" border="0"></a>
<a href="javascript:add_smiley(':D')"><img src="smilies/biggrin.gif" border="0"></a>
<a href="javascript:add_smiley(':S')"><img src="smilies/verbaasd.gif" border="0"></a>
<a href="javascript:add_smiley(':P')"><img src="smilies/tongue.gif" border="0"></a>
<a href="javascript:add_smiley(':nerd:')"><img src="smilies/nerd.gif" border="0"></a>
<a href="javascript:add_smiley(':cool:')"><img src="smilies/cool.gif" border="0"></a>
<a href="javascript:add_smiley('9:6')"><img src="smilies/worshippy.gif" border="0"></a>
<a href="javascript:add_smiley(':evil:')"><img src="smilies/evil.gif" border="0"></a>
<a href="javascript:add_smiley(':vinger:')"><img src="smilies/vinger.gif" border="0"></a>
<a href="javascript:add_smiley(':lijst:')"><img src="smilies/lijstje.gif" border="0"></a>
<a href="javascript:add_smiley(':bier:')"><img src="smilies/bier.gif" border="0"></a>
<a href="javascript:add_smiley(':king:')"><img src="smilies/koning.gif" border="0"></a>
<a href="javascript:add_smiley(':koffie:')"><img src="smilies/koffie.gif" border="0"></a>
<a href="javascript:add_smiley('|:/')"><img src="smilies/professor.gif" border="0"></a>
<a href="javascript:add_smiley(':trek:')"><img src="smilies/naamloos.bmp" border="0"></a>
<a href="javascript:add_smiley(':gangsterstar:')"><img src="smilies/gun.gif" border="0"></a>
<a href="javascript:add_smiley(':shoot:')"><img src="smilies/schooting.gif" border="0"></a><br /><br />
<select name="ubb" onChange="add_ubb(this.value)" style="background-color: #A1B6C9; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 10px;"> <option>Ubb:</option>
<option value=" "> </option>
<option value=" "> </option>
<option value=" "> </option>
<option value="
 
">
 
</option>
<option value=""></option>
<option value="
">
</option>
</select><br />
</form>
<?
?>
</td>
</tr>
</table>
</body>
</html>
<?php

// Add Reply
if ($reply) {
$exists = mysql_num_rows(mysql_query("select * from topics where id=$reply"));
if ($exists <= 0) {
print "No such topic.";

exit;
}
if (empty ($rep)) {
print "You must fill out all fields.";

exit;
}
mysql_query("insert into replies (starter, topic_id, body) values('$stat[user]', $reply, '$rep')") or die("Could not add reply.");
print "Reply added. Click <a href=forum.php?topic=$reply>here</a>.";
}

{


$inputtext = nl2br($inputtext);
return $inputtext;
}

?>

ubb.php

<?php

include("head2.php");
include("left.php");
include("config.php");


function italic($code) {
$code = "<i>".$code."</i>";
return $code;
}

function bold($code) {
$code = "<b>".$code."</b>";
return $code;
}

function underlined($code) {
$code = "<u>".$code."</u>";
return $code;
}


function ubb($body)
{


$kleur1 = "#EAF0FA";
$kleur2 = "#F7F7F7";
$borderkleur = "#D3D3D3";



$body = htmlspecialchars("$body");
$body = stripslashes($body);
$body = nl2br("$body");

// Hier begint het code systeem


$body = str_replace("[center]", "<center>", $body);
$body = str_replace("[/center]", "</center>", $body);
$body = str_replace("", "<small>", $body);
$body = str_replace("
", "</small>", $body);
$body = str_replace("
", "<small>Quote:</small><br><table width=\"100%\" bgcolor=\"$kleur1\" style=\"BORDER-RIGHT: $borderkleur 2px solid; BORDER-TOP: $borderkleur 1px solid; BORDER-BOTTOM: $borderkleur 2px solid; BORDER-LEFT: $borderkleur 1px solid\" cellspacing=\"0\" cellpadding=\"1\"><tr><td><font color=\"#000000\">", $body);
$body = str_replace("
", "</font></td></tr></table>", $body);
$body = str_replace("[ul]", "<ul>", $body);
$body = str_replace("[/ul]", "</ul>", $body);
$body = str_replace("[li]", "<li>", $body);
$body = str_replace("[/li]", "</li>", $body);
$body = eregi_replace("http://[^[:space:]]+","<a href=\"\\0\" target=\"_blank\">\\0</a>",$body);
$body = eregi_replace("([a-zA-Z0-9_-]+)@([a-zA-Z0-9\._-]+)(\.[a-zA-Z]+)", "<a href=\"mailto:\\1@\\2\\3\">\\1@\\2\\3</a>", $body);
$body = preg_replace('_\[i\](.*?)\[/i\]_ise', "italic(' \\1 ')", $body);
$body = preg_replace('_\[b\](.*?)\[/b\]_ise', "bold(' \\1 ')", $body);
$body = preg_replace('_\[u\](.*?)\[/u\]_ise', "underlined(' \\1 ')", $body);
$body = str_replace("","<img src=\"http://",$body); $body = str_replace("","\">",$body);
$body = eregi_replace("\[url\]www.([^\[]*)","<a href=\"http://www.\\1\"; target=_blank>\\1", $body);
$body = eregi_replace("\[url\]([^\[]*)","<a href=\"\\1\" target=_blank>\\1", $body);
$body = eregi_replace("(\[url=)([A-Za-z0-9_~&=;\?:%@#./\-]+[A-Za-z0-9/])(\])", "<a href=\"http://\\2\" target=_blank>", $body);
$body = eregi_replace("\[url](http://(.*))";, "<a href=\"\\1\" target=\"_blank\">\\1", $body);
$body = eregi_replace("(\[/url\])", "</a>", $body);
$body = str_replace("http://http://";, "http://", $body);

//ubb codes
$body = eregi_replace("\\[color=([^\\[]*)\\]([^\\[]*)\\[/color\\]","<font color=\"\\1\">\\2</font>",$body);
$body = eregi_replace("\\[size=([^\\[]*)\\]([^\\[]*)\\[/size\\]","<font size=\"\\1\">\\2</font>",$body);
$body = eregi_replace("\\[font=([^\\[]*)\\]([^\\[]*)\\[/font\\]","<font face=\"\\1\">\\2</font>",$body);
$body = eregi_replace("\\[img height=([^\\[]*)\\ width=([^\\[]*)\\]([^\\[]*)\\[/img\\]","<img src=\"\\3\" height=\"\\1\" width=\"\\2\">",$body);
$body = eregi_replace("\\[img]([^\\[]*)\\[/img\\]","<img src=\"\\1\">",$bericht);
$body = eregi_replace("\\[flash=([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/flash\\]","<object classid=\"clsid: D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\\1 height=\\2><param name=movie value=\\3><param name=play value=true><param name=loop value=true><param name=quality value=high><embed src=\\3 width=\\1 height=\\2 play=true loop=true quality=high></embed></object>",$body);
$body = eregi_replace("\\[align=([^\\[]*)\\]([^\\[]*)\\[/align\\]","<p align=\"\\1\">\\2</p>",$body);
$body = eregi_replace("\\[shadow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/shadow\\]","<font style=\"Filter: Shadow(color=\\1, Direction=\\2); Width=\\3px;\">\\4</font>",$body);
$body = eregi_replace("\\[glow=([^\\[]*)\\,([^\\[]*)\\,([^\\[]*)\\]([^\\[]*)\\[/glow\\]","<font style=\"Filter: Glow(color=\\1, Strength=\\2); Width=\\3px;\">\\4</font>",$body);
$body = eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]";, "<a href=\"http://www.\\1\"; target=_blank>\\1</a>",$body);
$body = eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$body);
$body = eregi_replace("\\[url=([^\\[]*)\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$body);
$body = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)","\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5",$body);

$body = str_replace("", "<b>",$body);
$body = str_replace("
","</b>",$body);
$body = str_replace("","<i>",$body);
$body = str_replace("
","</i>",$body);
$body = str_replace("","<u>",$body);
$body = str_replace("
","</u>",$body);

$body = str_replace(":)","<img src=\"smilies/smile.gif\">",$body);
$body = str_replace(":(","<img src=\"smilies/mad.gif\">",$body);
$body = str_replace(":'(","<img src=\"smilies/cry.gif\">",$body);
$body = str_replace(";)","<img src=\"smilies/knipoog.gif\">",$body);
$body = str_replace(":D","<img src=\"smilies/biggrin.gif\">",$body);
$body = str_replace(":S","<img src=\"smilies/verbaasd.gif\">",$body);
$body = str_replace(":P","<img src=\"smilies/tongue.gif\">",$body);
$body = str_replace(":nerd:","<img src=\"smilies/nerd.gif\">",$body);
$body = str_replace(":cool:","<img src=\"smilies/cool.gif\">",$body);
$body = str_replace("9:6","<img src=\"smilies/worshippy.gif\">",$body);
$body = str_replace(":evil:","<img src=\"smilies/evil.gif\">",$body);
$body = str_replace(":vinger:","<img src=\"smilies/vinger.gif\">",$body);
$body = str_replace(":lijst:","<img src=\"smilies/lijstje.gif\">",$body);
$body = str_replace(":bier:","<img src=\"smilies/bier.gif\">",$body);
$body = str_replace(":king:","<img src=\"smilies/koning.gif\">",$body);
$body = str_replace(":koffie:","<img src=\"smilies/koffie.gif\">",$body);
$body = str_replace("|:/","<img src=\"smilies/professor.gif\">",$body);
$body = str_replace(":trek:","<img src=\"smilies/naamloos.bmp\">",$body);
$body = str_replace(":gangerstar:","<img src=\"smilies/gun.gif\">",$body);
$body = str_replace(":shoot:","<img src=\"smilies/schooting.gif\">",$body);

return $body;
}

?>

database:

#
# Tabel structuur voor tabel `replies`
#

CREATE TABLE `replies` (
`id` int(11) NOT NULL auto_increment,
`starter` varchar(30) NOT NULL default '',
`topic_id` text NOT NULL,
`body` text NOT NULL,
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;

# --------------------------------------------------------

#
# Tabel structuur voor tabel `topics`
#

CREATE TABLE `topics` (
`id` int(11) NOT NULL auto_increment,
`topic` text NOT NULL,
`body` text NOT NULL,
`starter` varchar(30) NOT NULL default '',
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
Je hoeft niet die hele code te posten...

Je moet de functie van de ubb nog aanroepen...
<?
ubb($topicinfo[body])
?>

Denk tenminste dat dat het bericht is, maar dat weet je zelf wel...

Reageren