UBB op op site
ik wil graag Ubb gebruiken op mijn site, nu heb ik deze code al gevonden op PHPHulp.ml maar ik snap niet precies hoe ik hem in mijn site moet verwerken.
kan iemand mijn helpen?
het script staat hier:
http://www.phphulp.nl/php/scripts/6/108/
Alvast bedankt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
function ubb($bericht)
{
// Enters V
$bericht = str_replace ("[br]","\n",$bericht);
$bericht = str_replace ("\n","<br>",$bericht);
// Code V
$bericht = str_replace ("","<b>Code:</b><br /><table bgcolor=\"#000000\" cellspacing=\"1\" width=\"90%\"><tr><td><table cellpadding=2 cellspacing=\"0\" bgcolor=\"#FFFFFF\" width=\"100%\"><tr><td><font face=Courier size=\"1\" color=\"#000000\">", $bericht);
$bericht = str_replace ("", "</font></td></tr></table></td></tr></table>", $bericht);
// Vet, schuin, etc V
$bericht = preg_replace("/\[b\](.+?)\[\/b\]/is",'<strong>\1</strong>', $bericht);
$bericht = preg_replace("/\[i\](.+?)\[\/i\]/is",'<em>\1</em>', $bericht);
$bericht = preg_replace("/\[u\](.+?)\[\/u\]/is",'<u>\1</u>', $bericht);
$bericht = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $bericht);
// Marquee
$bericht = str_replace ("[move]", "<div align=\"center\"><marquee width=\"90%\">", $bericht);
$bericht = str_replace ("[/move]", "</marquee></div>", $bericht);
// Color, font & size V
$bericht = preg_replace ("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "<font color=\"\\1\">\\2</font>", $bericht);
$bericht = preg_replace ("/\[font=(.*)\](.*)\[\/font\]/", "<font face=\"$1\">$2</font>", $bericht);
$bericht = preg_replace ("/\[size=(.*)\](.*)\[\/size\]/", "<font size=\"$1\">$2</font>", $bericht);
// Plaatje toevoegen V
$bericht = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">",$bericht);
// Diversen V
$bericht = str_replace ("[tt]", "<tt>", $bericht);
$bericht = str_replace ("[/tt]", "</tt>", $bericht);
$bericht = str_replace ("[left]", "<div align=left>", $bericht);
$bericht = str_replace ("[/left]", "</div>", $bericht);
$bericht = str_replace ("[center]", "<div align=\"center\">", $bericht);
$bericht = str_replace ("[/center]", "</div>", $bericht);
$bericht = str_replace ("[right]", "<div align=\"right\">", $bericht);
$bericht = str_replace ("[/right]", "</div>", $bericht);
$bericht = str_replace ("[sub]", "<sub>", $bericht);
$bericht = str_replace ("[/sub]", "</sub>", $bericht);
$bericht = str_replace ("[sup]", "<sup>", $bericht);
$bericht = str_replace ("[/sup]", "</sup>", $bericht);
$bericht = str_replace ("[fixed]", "<font face=\"Courier New\">", $bericht);
$bericht = str_replace ("[/fixed]", "</font>", $bericht);
$bericht = str_replace ("[[","{{",$bericht);
$bericht = str_replace ("]]","}}",$bericht);
$bericht = str_replace ("|","|",$bericht);
$bericht = str_replace ("[pre]","<pre>",$bericht);
$bericht = str_replace ("[/pre]","</pre>",$bericht);
$bericht = str_replace ("{{","[",$bericht);
$bericht = str_replace ("}}","]",$bericht);
// Horizontale lijn V
$bericht = str_replace ("[hr]","<hr color=\"#000000\" noshade />",$bericht);
// Lijst V
$bericht = str_replace ("[list]","<ul>",$bericht);
$bericht = str_replace ("[*]","<li>",$bericht);
$bericht = str_replace ("[/list]","</li></ul>",$bericht);
// Tabel V
$bericht = str_replace ("[table]","<table class=\"main\">",$bericht);
$bericht = str_replace ("[/table]","</table>",$bericht);
$bericht = str_replace ("[tr]","<tr>",$bericht);
$bericht = str_replace ("[/tr]","</tr>",$bericht);
$bericht = str_replace ("[td]","<td>",$bericht);
$bericht = str_replace ("[/td]","</td>",$bericht);
// Smiley's V
// Roll Eyes
$bericht = str_replace ("::)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[rolleyes]","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("::-)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Smile
$bericht = str_replace (":)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[smile]","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (":-)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Wink
$bericht = str_replace (";)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[wink]","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (";-)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
}
?>
function ubb($bericht)
{
// Enters V
$bericht = str_replace ("[br]","\n",$bericht);
$bericht = str_replace ("\n","<br>",$bericht);
// Code V
$bericht = str_replace ("","<b>Code:</b><br /><table bgcolor=\"#000000\" cellspacing=\"1\" width=\"90%\"><tr><td><table cellpadding=2 cellspacing=\"0\" bgcolor=\"#FFFFFF\" width=\"100%\"><tr><td><font face=Courier size=\"1\" color=\"#000000\">", $bericht);
$bericht = str_replace ("", "</font></td></tr></table></td></tr></table>", $bericht);
// Vet, schuin, etc V
$bericht = preg_replace("/\[b\](.+?)\[\/b\]/is",'<strong>\1</strong>', $bericht);
$bericht = preg_replace("/\[i\](.+?)\[\/i\]/is",'<em>\1</em>', $bericht);
$bericht = preg_replace("/\[u\](.+?)\[\/u\]/is",'<u>\1</u>', $bericht);
$bericht = preg_replace("/\[s\](.+?)\[\/s\]/is",'<s>\1</s>', $bericht);
// Marquee
$bericht = str_replace ("[move]", "<div align=\"center\"><marquee width=\"90%\">", $bericht);
$bericht = str_replace ("[/move]", "</marquee></div>", $bericht);
// Color, font & size V
$bericht = preg_replace ("#\[color=(\#[0-9A-F]{6}|[a-z\-]+)\](.*?)\[/color\]#si", "<font color=\"\\1\">\\2</font>", $bericht);
$bericht = preg_replace ("/\[font=(.*)\](.*)\[\/font\]/", "<font face=\"$1\">$2</font>", $bericht);
$bericht = preg_replace ("/\[size=(.*)\](.*)\[\/size\]/", "<font size=\"$1\">$2</font>", $bericht);
// Plaatje toevoegen V
$bericht = preg_replace("/\[img\](.*?)\[\/img\]/si", "<img src=\"\\1\" border=\"0\">",$bericht);
// Diversen V
$bericht = str_replace ("[tt]", "<tt>", $bericht);
$bericht = str_replace ("[/tt]", "</tt>", $bericht);
$bericht = str_replace ("[left]", "<div align=left>", $bericht);
$bericht = str_replace ("[/left]", "</div>", $bericht);
$bericht = str_replace ("[center]", "<div align=\"center\">", $bericht);
$bericht = str_replace ("[/center]", "</div>", $bericht);
$bericht = str_replace ("[right]", "<div align=\"right\">", $bericht);
$bericht = str_replace ("[/right]", "</div>", $bericht);
$bericht = str_replace ("[sub]", "<sub>", $bericht);
$bericht = str_replace ("[/sub]", "</sub>", $bericht);
$bericht = str_replace ("[sup]", "<sup>", $bericht);
$bericht = str_replace ("[/sup]", "</sup>", $bericht);
$bericht = str_replace ("[fixed]", "<font face=\"Courier New\">", $bericht);
$bericht = str_replace ("[/fixed]", "</font>", $bericht);
$bericht = str_replace ("[[","{{",$bericht);
$bericht = str_replace ("]]","}}",$bericht);
$bericht = str_replace ("|","|",$bericht);
$bericht = str_replace ("[pre]","<pre>",$bericht);
$bericht = str_replace ("[/pre]","</pre>",$bericht);
$bericht = str_replace ("{{","[",$bericht);
$bericht = str_replace ("}}","]",$bericht);
// Horizontale lijn V
$bericht = str_replace ("[hr]","<hr color=\"#000000\" noshade />",$bericht);
// Lijst V
$bericht = str_replace ("[list]","<ul>",$bericht);
$bericht = str_replace ("[*]","<li>",$bericht);
$bericht = str_replace ("[/list]","</li></ul>",$bericht);
// Tabel V
$bericht = str_replace ("[table]","<table class=\"main\">",$bericht);
$bericht = str_replace ("[/table]","</table>",$bericht);
$bericht = str_replace ("[tr]","<tr>",$bericht);
$bericht = str_replace ("[/tr]","</tr>",$bericht);
$bericht = str_replace ("[td]","<td>",$bericht);
$bericht = str_replace ("[/td]","</td>",$bericht);
// Smiley's V
// Roll Eyes
$bericht = str_replace ("::)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[rolleyes]","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("::-)","<img src=\"img/ubbc/rolleyes.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Smile
$bericht = str_replace (":)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[smile]","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (":-)","<img src=\"img/ubbc/smiley.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
// Wink
$bericht = str_replace (";)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace ("[wink]","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
$bericht = str_replace (";-)","<img src=\"img/ubbc/wink.gif\" width=\"15\" height=\"15\" border=\"0\">",$bericht);
}
?>
en dan gebruik je m zo:
Code (php)
1
2
3
4
2
3
4
<?php
$ubb = 'Een hele leuke teskst met [b]ubb[/b][i]co[/i][u]des[/u].'
$html = ubb($ubb);
?>
$ubb = 'Een hele leuke teskst met [b]ubb[/b][i]co[/i][u]des[/u].'
$html = ubb($ubb);
?>
Gewijzigd op 01/01/1970 01:00:00 door - -
De eerste en tweede parameters van de functies preg_replace en str_replace kan een array zijn. Misschien is dit wat overzichtelijker en sneller.
Volgens mij gaat het op regel 26 en 27 van je code verkeerd als je twee van dezelfde tags op een regel hebt staan.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
// Verwerk.php
// Variabelen
$bericht = $_POST['bericht'];
?>
<html>
<head>
<title>Voorbeeld Formulier UBBC code</title>
</head>
<body>
<?php
echo "<p>Dit is de output zonder UBBC</p>\n\n";
echo "<p>$bericht</p>\n\n";
echo "<p>Hier is dezelfde output met UBBC</p>\n\n";
// UBBC toepassen
require("ubbc.php");
echo "<p>$bericht</p>\n\n";
?>
</body>
</html>
// Verwerk.php
// Variabelen
$bericht = $_POST['bericht'];
?>
<html>
<head>
<title>Voorbeeld Formulier UBBC code</title>
</head>
<body>
<?php
echo "<p>Dit is de output zonder UBBC</p>\n\n";
echo "<p>$bericht</p>\n\n";
echo "<p>Hier is dezelfde output met UBBC</p>\n\n";
// UBBC toepassen
require("ubbc.php");
echo "<p>$bericht</p>\n\n";
?>
</body>
</html>
hjet is dit niet alleen die code die er al voorbeeld staat :S, ik ben niet erg bekend met dit soort dingen.
ik wil hem verwerken in dit, niet dat jullie mijn website moeten gaan maken ofzo mar ik weet effe niet hoe ik dit moet gaan verwerken in de add.php pagina:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html>
<head>
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<img src="images/header.gif">
<?php
require('config.php');
if (isset($_POST['title']))
{
$toevoegen = '
INSERT INTO news
SET
gb_name = "' . $_POST['gb_name'] . '",
title = "' . $_POST['title'] . '",
message = "' . $_POST['message'] . '"';
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
echo '<br />';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Name:<input type="text" value="' . $row['$name'] . '" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" value="' . $row['title'] . '" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">' . $row['message'] . '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
</body>
</html>
<head>
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<img src="images/header.gif">
<?php
require('config.php');
if (isset($_POST['title']))
{
$toevoegen = '
INSERT INTO news
SET
gb_name = "' . $_POST['gb_name'] . '",
title = "' . $_POST['title'] . '",
message = "' . $_POST['message'] . '"';
mysql_query($toevoegen) or die (mysql_error());
echo 'Message introduced';
echo '<br />';
}
echo '<a href="index.php">Index</a>';
echo '<form action="" method="post">';
echo 'Name:<input type="text" value="' . $row['$name'] . '" name="gb_name">';
echo '<br />';
echo 'Title:<input type="text" value="' . $row['title'] . '" name="title">';
echo '<br />';
echo 'Message:<textarea name="message" rows="10" cols="30">' . $row['message'] . '</textarea>';
echo '<br />';
echo '<br />';
echo '<input type="submit" value="Submit">';
echo '<br />';
?>
</body>
</html>
Moet ik dan van if (isset($_POST['title'])) dit if (isset($_POST['bericht'])) maken?
Gewijzigd op 01/01/1970 01:00:00 door mich