Spam
De laatste tijd word mijn forum dagelijks volgespamt met cheap viagra en dat soort troep. Ik wil dit graag stoppen maar zou niet weten hoe, weet iemand mischien een link naar een tutorial ofzo waarmee ik dit kan oplossen?
Dan zo je in .htacces het IP kunnen blokkeren.
Zo ja, dan kan er niet gepost worden, zo nee, dan kan er wel gepost worden.
bedankt beide!
Mooi dit al opgelost
tom vd; krijg je spam met heel veel <A HREF="..">..</A> en [url=..]..[/url]?
Wat ik heb gedaan, in een website waar dit het geval was, was het volgende. Erg simpele oplossing, maar het werkt voor nu:
Code (php)
;)
Aangezien ip's meestal om de zoveel tijd worden veranderd en een filter voor woorden makkelijk kan worden doorbroken door gewoon een ander woord daar neer te zetten...
Zoek even in de scriptlib op captcha voor zo'n plaatje
Het captcha script zelf:
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
88
89
90
91
92
93
94
95
96
97
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
88
89
90
91
92
93
94
95
96
97
<?php
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
$chars = explode ( ' ', $chars );
for ( $i = 0; $i < $num_chars; $i++ )
{
if ( strlen ( $return ) < $num_chars )
{
$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
}
}
return $return;
}
if ( $_POST )
{
if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
{
die ( '<font color="#008000">Correcte Code!</font>' );
}
else
{
die ( '<font color="#800000">Foute Code!</font>' );
}
}
if ( isset ( $_GET['image'] ) )
{
// Alle instellingen:D
session_start ( );
$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
$lines = 10;
$dots = 100;
$width = strlen ( $code ) * 20;
$height = 30;
$im = imagecreate ( $width, $height );
// kleuren
$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
imagecolortransparent ( $im );
// lijnen
for ( $line = 0; $line < $lines; $line++ )
{
imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
}
// stippen
for ( $dot = 0; $dot < $dots; $dot++ )
{
imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
}
// en nu het ECHTE werk:D
// de tekst
$chars = preg_split ( '//', $code );
$x = -12;
for ( $i = 0; $i < count ( $chars ); $i++ )
{
imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
$x = $x + 20;
}
if ( function_exists ( 'imagegif' ) )
{
header ( 'Content-Type: image/gif' );
imagegif ( $im );
}
elseif ( function_exists ( 'imagejpeg' ) )
{
header ( 'Content-Type: image/jpeg' );
imagejpeg ( $im );
}
imagedestroy ( $im );
}
else
{
$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<html dir="ltr">
<head>
<title>Verificatie Test</title>
</head>
<body bgcolor="#333333">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6"> <img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>"><input type="submit">
</form>
</body>
</html>
<?php
}
?>
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
$chars = explode ( ' ', $chars );
for ( $i = 0; $i < $num_chars; $i++ )
{
if ( strlen ( $return ) < $num_chars )
{
$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
}
}
return $return;
}
if ( $_POST )
{
if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
{
die ( '<font color="#008000">Correcte Code!</font>' );
}
else
{
die ( '<font color="#800000">Foute Code!</font>' );
}
}
if ( isset ( $_GET['image'] ) )
{
// Alle instellingen:D
session_start ( );
$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
$lines = 10;
$dots = 100;
$width = strlen ( $code ) * 20;
$height = 30;
$im = imagecreate ( $width, $height );
// kleuren
$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
imagecolortransparent ( $im );
// lijnen
for ( $line = 0; $line < $lines; $line++ )
{
imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
}
// stippen
for ( $dot = 0; $dot < $dots; $dot++ )
{
imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
}
// en nu het ECHTE werk:D
// de tekst
$chars = preg_split ( '//', $code );
$x = -12;
for ( $i = 0; $i < count ( $chars ); $i++ )
{
imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
$x = $x + 20;
}
if ( function_exists ( 'imagegif' ) )
{
header ( 'Content-Type: image/gif' );
imagegif ( $im );
}
elseif ( function_exists ( 'imagejpeg' ) )
{
header ( 'Content-Type: image/jpeg' );
imagejpeg ( $im );
}
imagedestroy ( $im );
}
else
{
$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<html dir="ltr">
<head>
<title>Verificatie Test</title>
</head>
<body bgcolor="#333333">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6"> <img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>"><input type="submit">
</form>
</body>
</html>
<?php
}
?>
En het script waar ik het heb ingebouwd:
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<?php
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
$chars = explode ( ' ', $chars );
for ( $i = 0; $i < $num_chars; $i++ )
{
if ( strlen ( $return ) < $num_chars )
{
$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
}
}
return $return;
}
if ( $_POST )
{
if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
{
die ( '<font color="#008000">Correcte Code!</font>' );
}
else
{
die ( '<font color="#800000">Foute Code!</font>' );
}
}
if ( isset ( $_GET['image'] ) )
{
// Alle instellingen:D
session_start ( );
$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
$lines = 10;
$dots = 100;
$width = strlen ( $code ) * 20;
$height = 30;
$im = imagecreate ( $width, $height );
// kleuren
$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
imagecolortransparent ( $im );
// lijnen
for ( $line = 0; $line < $lines; $line++ )
{
imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
}
// stippen
for ( $dot = 0; $dot < $dots; $dot++ )
{
imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
}
// en nu het ECHTE werk:D
// de tekst
$chars = preg_split ( '//', $code );
$x = -12;
for ( $i = 0; $i < count ( $chars ); $i++ )
{
imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
$x = $x + 20;
}
if ( function_exists ( 'imagegif' ) )
{
header ( 'Content-Type: image/gif' );
imagegif ( $im );
}
elseif ( function_exists ( 'imagejpeg' ) )
{
header ( 'Content-Type: image/jpeg' );
imagejpeg ( $im );
}
imagedestroy ( $im );
}
else
{
$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<?php
error_reporting(E_ALL);
ob_start(); ?>
<?php include("functies.php"); ?>
<?php include("style1.inc.php"); ?>
<?php include("config.php"); ?>
<body bgcolor="#333333">
<style> BODY{scrollbar-3dlight-color:#333333;scrollbar-highlight-color:;scrollbar-face-color:#545454;scrollbar-shadow-color:;scrollbar-track-color:#333333;scrollbar-arrow-color:#333333;scrollbar-darkshadow-color:#FFFFFF;} </style>
<html>
<head>
<title>Schrijf een bericht in het gastenboek</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
//Deze functie hebben we later nodig voor de UBB code
function Invoegen(Smiley) {
var edit;
var HuidigeTekst = document.gastenboek.bericht.value;
edit = HuidigeTekst+Smiley+" ";
document.gastenboek.bericht.value=edit;
document.gastenboek.bericht.focus();
return;
}
function smiley() {
return;
}
</script>
</head>
<body>
<?php
if (isset($_POST['Submit'])) {
if (!trim($_POST['naam'])) {
$error="Je moet je naam invullen";
}
elseif(!check_email($_POST['emailadres'])) {
$error="Je moet een geldig e-mailadres invullen";
}
elseif (!trim($_POST['bericht'])) {
$error="Je moet een bericht invullen";
}
elseif ($_COOKIE['Gastenboek'] == "1") {
$error="Je kan geen bericht posten omdat je er al één hebt gepost";
}
//Als er een veld niet is ingevuld of wanneer het e-mailadres niet bestaat komt er een error
if ($error != "") {
?>
<center>
<table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>
<center>
<b><?=$error?></b><br>
<form method="post" action="javascript:history.go(-1)">
<input type="submit" name="Terug" value="Terug" />
</form>
</center>
</td>
</tr>
</table>
</center>
<?php
} else {
//Als alles correct is ingevuld gaan we over naar het posten van de gegevens naar de database
mysql_query ("INSERT INTO gastenboek (naam, emailadres, bericht, datum) VALUES ('".$_POST['naam']."', '".$_POST['emailadres']."', '".$_POST['bericht']."', NOW())") or die (mysql_error());
//Om SPAM te vermijden maken we een COOKIE (zie config)
setcookie (Gastenboek, 1, $tijd_cookie);
//Na het verzenden sturen we de gebruiker terug naar het gastenboek
header ("location: ".$pagina_lezen);
}
} else {
?>
<center>
<form name="gastenboek" action="" method="post">
<table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td height="20" colspan="2"><strong>Bericht posten in het gastenboek:</strong></td>
</tr>
<tr>
<td width="44%">Naam:</td>
<td width="56%">
<input name="naam" type="text" id="naam" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td>E-mail adres:</td>
<td>
<input name="emailadres" type="text" id="emailadres" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td>Verificatie:</td>
<td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6"> <img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>">
</form>
<?php
}
?>
</td>
</tr>
<tr>
<td align="center" colspan="2">Bericht:</td>
</tr>
<tr>
<td align="center" colspan="2">
<table width="27%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" height="21" colspan="4">
<small><i><b>Ubb-code:</b></i></small>
</td>
</tr>
<tr>
<td align="center" height="27" colspan="4">
<input type="button" name="b" value="B" style="font-weight: bold; width: 30px;" onClick="javascript:Invoegen('[B]...[/B]');" />
<input type="button" name="u" value="U" style="text-decoration: underline; width: 30px;" onClick="javascript:Invoegen('[U]...[/U]');" />
<input type="button" name="i" value="I" style="font-style: italic; width: 30px;" onClick="javascript:Invoegen('[I]...[/I]');" />
<input type="button" name="s" value="S" style="text-decoration: line-through; width: 30px;" onClick="javascript:Invoegen('[S]...[/S]');" />
<input type="button" name="url" value="http://" onClick="javascript:Invoegen('[URL=http://...]...[/URL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4">
<input type="button" name="align" value="Align" onClick="javascript:Invoegen('[ALIGN=...]...[/ALIGN]');" />
<input type="button" name="color" value="Kleur" onClick="javascript:Invoegen('[COLOR=...]...[/COLOR]');" />
<input type="button" name="size" value="Grootte" onClick="javascript:Invoegen('[SIZE=...]...[/SIZE]');" />
<input type="button" name="e-mail" value="E-mail" onClick="javascript:Invoegen('[EMAIL=...]...[/EMAIL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4"><small><i><b>Smileys:</b></i></small></td>
</tr>
<tr>
<td height="41" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':)');"><img src="smileys/blij.gif" width="20" border="0" /></a></td>
<td height="41" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':D');"><img src="smileys/tanden.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':P');"><img src="smileys/tong.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(';)');"><img src="smileys/knipoog.gif" width="20" height="20" border="0" /></a></td>
</tr>
<tr>
<td height="36" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':cool:');"><img src="smileys/cool.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':s');"><img src="smileys/verward.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':omg:');"><img src="smileys/omg.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':(');"><img src="smileys/droevig.gif" width="20" height="20" border="0" /></a></td>
</tr>
</table>
<br>
<textarea name="bericht" cols="50" rows="10" id="bericht"></textarea><br />
</td>
</tr>
<tr>
<td height="25" colspan="2" align="center">
<input type="submit" name="Submit" value="Verzenden" />
<input name="Reset" type="submit" id="Reset" value="Opnieuw" />
</td>
</tr>
</table>
</form>
</center>
<?php
}
?>
</body>
</html>
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
$chars = explode ( ' ', $chars );
for ( $i = 0; $i < $num_chars; $i++ )
{
if ( strlen ( $return ) < $num_chars )
{
$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
}
}
return $return;
}
if ( $_POST )
{
if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
{
die ( '<font color="#008000">Correcte Code!</font>' );
}
else
{
die ( '<font color="#800000">Foute Code!</font>' );
}
}
if ( isset ( $_GET['image'] ) )
{
// Alle instellingen:D
session_start ( );
$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
$lines = 10;
$dots = 100;
$width = strlen ( $code ) * 20;
$height = 30;
$im = imagecreate ( $width, $height );
// kleuren
$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
imagecolortransparent ( $im );
// lijnen
for ( $line = 0; $line < $lines; $line++ )
{
imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
}
// stippen
for ( $dot = 0; $dot < $dots; $dot++ )
{
imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
}
// en nu het ECHTE werk:D
// de tekst
$chars = preg_split ( '//', $code );
$x = -12;
for ( $i = 0; $i < count ( $chars ); $i++ )
{
imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
$x = $x + 20;
}
if ( function_exists ( 'imagegif' ) )
{
header ( 'Content-Type: image/gif' );
imagegif ( $im );
}
elseif ( function_exists ( 'imagejpeg' ) )
{
header ( 'Content-Type: image/jpeg' );
imagejpeg ( $im );
}
imagedestroy ( $im );
}
else
{
$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<?php
error_reporting(E_ALL);
ob_start(); ?>
<?php include("functies.php"); ?>
<?php include("style1.inc.php"); ?>
<?php include("config.php"); ?>
<body bgcolor="#333333">
<style> BODY{scrollbar-3dlight-color:#333333;scrollbar-highlight-color:;scrollbar-face-color:#545454;scrollbar-shadow-color:;scrollbar-track-color:#333333;scrollbar-arrow-color:#333333;scrollbar-darkshadow-color:#FFFFFF;} </style>
<html>
<head>
<title>Schrijf een bericht in het gastenboek</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
//Deze functie hebben we later nodig voor de UBB code
function Invoegen(Smiley) {
var edit;
var HuidigeTekst = document.gastenboek.bericht.value;
edit = HuidigeTekst+Smiley+" ";
document.gastenboek.bericht.value=edit;
document.gastenboek.bericht.focus();
return;
}
function smiley() {
return;
}
</script>
</head>
<body>
<?php
if (isset($_POST['Submit'])) {
if (!trim($_POST['naam'])) {
$error="Je moet je naam invullen";
}
elseif(!check_email($_POST['emailadres'])) {
$error="Je moet een geldig e-mailadres invullen";
}
elseif (!trim($_POST['bericht'])) {
$error="Je moet een bericht invullen";
}
elseif ($_COOKIE['Gastenboek'] == "1") {
$error="Je kan geen bericht posten omdat je er al één hebt gepost";
}
//Als er een veld niet is ingevuld of wanneer het e-mailadres niet bestaat komt er een error
if ($error != "") {
?>
<center>
<table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td>
<center>
<b><?=$error?></b><br>
<form method="post" action="javascript:history.go(-1)">
<input type="submit" name="Terug" value="Terug" />
</form>
</center>
</td>
</tr>
</table>
</center>
<?php
} else {
//Als alles correct is ingevuld gaan we over naar het posten van de gegevens naar de database
mysql_query ("INSERT INTO gastenboek (naam, emailadres, bericht, datum) VALUES ('".$_POST['naam']."', '".$_POST['emailadres']."', '".$_POST['bericht']."', NOW())") or die (mysql_error());
//Om SPAM te vermijden maken we een COOKIE (zie config)
setcookie (Gastenboek, 1, $tijd_cookie);
//Na het verzenden sturen we de gebruiker terug naar het gastenboek
header ("location: ".$pagina_lezen);
}
} else {
?>
<center>
<form name="gastenboek" action="" method="post">
<table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td height="20" colspan="2"><strong>Bericht posten in het gastenboek:</strong></td>
</tr>
<tr>
<td width="44%">Naam:</td>
<td width="56%">
<input name="naam" type="text" id="naam" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td>E-mail adres:</td>
<td>
<input name="emailadres" type="text" id="emailadres" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td>Verificatie:</td>
<td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6"> <img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>">
</form>
<?php
}
?>
</td>
</tr>
<tr>
<td align="center" colspan="2">Bericht:</td>
</tr>
<tr>
<td align="center" colspan="2">
<table width="27%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" height="21" colspan="4">
<small><i><b>Ubb-code:</b></i></small>
</td>
</tr>
<tr>
<td align="center" height="27" colspan="4">
<input type="button" name="b" value="B" style="font-weight: bold; width: 30px;" onClick="javascript:Invoegen('[B]...[/B]');" />
<input type="button" name="u" value="U" style="text-decoration: underline; width: 30px;" onClick="javascript:Invoegen('[U]...[/U]');" />
<input type="button" name="i" value="I" style="font-style: italic; width: 30px;" onClick="javascript:Invoegen('[I]...[/I]');" />
<input type="button" name="s" value="S" style="text-decoration: line-through; width: 30px;" onClick="javascript:Invoegen('[S]...[/S]');" />
<input type="button" name="url" value="http://" onClick="javascript:Invoegen('[URL=http://...]...[/URL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4">
<input type="button" name="align" value="Align" onClick="javascript:Invoegen('[ALIGN=...]...[/ALIGN]');" />
<input type="button" name="color" value="Kleur" onClick="javascript:Invoegen('[COLOR=...]...[/COLOR]');" />
<input type="button" name="size" value="Grootte" onClick="javascript:Invoegen('[SIZE=...]...[/SIZE]');" />
<input type="button" name="e-mail" value="E-mail" onClick="javascript:Invoegen('[EMAIL=...]...[/EMAIL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4"><small><i><b>Smileys:</b></i></small></td>
</tr>
<tr>
<td height="41" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':)');"><img src="smileys/blij.gif" width="20" border="0" /></a></td>
<td height="41" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':D');"><img src="smileys/tanden.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':P');"><img src="smileys/tong.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(';)');"><img src="smileys/knipoog.gif" width="20" height="20" border="0" /></a></td>
</tr>
<tr>
<td height="36" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':cool:');"><img src="smileys/cool.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':s');"><img src="smileys/verward.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':omg:');"><img src="smileys/omg.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':(');"><img src="smileys/droevig.gif" width="20" height="20" border="0" /></a></td>
</tr>
</table>
<br>
<textarea name="bericht" cols="50" rows="10" id="bericht"></textarea><br />
</td>
</tr>
<tr>
<td height="25" colspan="2" align="center">
<input type="submit" name="Submit" value="Verzenden" />
<input name="Reset" type="submit" id="Reset" value="Opnieuw" />
</td>
</tr>
</table>
</form>
</center>
<?php
}
?>
</body>
</html>
Op lijn 187 t/m 193 vind je het 'form' terug, en helemaal bovenaan staat de rest...
Gewijzigd op 01/01/1970 01:00:00 door tom vd