guestbook-spam-protected-mysql-db
Gesponsorde koppelingen
PHP script bestanden
SQL CODE:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
CREATE TABLE IF NOT EXISTS `guestbook` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(128) NOT NULL,
`email` varchar(512) NOT NULL,
`showEmail` tinyint(1) NOT NULL,
`enableEmoticons` tinyint(1) NOT NULL,
`message` text NOT NULL,
`time` datetime NOT NULL,
`ip` varchar(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
`id` int(11) NOT NULL auto_increment,
`name` varchar(128) NOT NULL,
`email` varchar(512) NOT NULL,
`showEmail` tinyint(1) NOT NULL,
`enableEmoticons` tinyint(1) NOT NULL,
`message` text NOT NULL,
`time` datetime NOT NULL,
`ip` varchar(15) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
PHP CODE:
captcha.php
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
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
<?php
#######################################
## © 2008 Wouter De Schuyter (Paradox)
## <[email protected]>
## http://paradox-productions.net/
## CAPTCHA V1.0 (SPAM PROTECTION)
#######################################
session_start(); // START SESSION
// FUNCTION TO SELECT A RANDOM CHARACTER OUT OF A STRING
function random_char($string) {
$length = strlen($string);
$position = mt_rand(0, $length - 1);
return $string[$position];
}
$width = 75; // IMG WIDTH (PX)
$height = 25; // IMG HEIGHT (PX)
$characters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"; // CHARACTERS FOR CAPTCHA STRING
$font = "fonts/font.ttf"; // FONT LOCATION
$fontS = 12; // FONT SIZE (PX)
$min = 50; // MIN NUMBER FOR THE RANDOM RGB TEXT COLOR
$max = 200; // MAX NUMBER FOR THE RANDOM RGB TEXT COLOR
// ADVANCED
////////////
$positionCharacterX = 3; // POSITION CHARACTER 1 ON THE X-AXIS (PX)
$characterSpace = 20; // SPACE FOR 1 CHARACTER (PX)
$positionCharactersY = 17; // SPACE ON THE Y-AXIS (PX)
$img = imagecreate($width, $height);
imagecolorallocate($img, 255, 255, 255); // BACKGROUND COLOR IN RGB
$randNr1 = rand($min, $max); // RANDOM NUMBER 1 BETWEEN $min & $max
$randNr2 = rand($min, $max); // RANDOM NUMBER 2 BETWEEN $min & $max
$randNr3 = rand($min, $max); // RANDOM NUMBER 3 BETWEEN $min & $max
$randomChar1 = random_char($characters); // RANDOM CHARACTER 1
$randomChar2 = random_char($characters); // RANDOM CHARACTER 2
$randomChar3 = random_char($characters); // RANDOM CHARACTER 3
$randomChar4 = random_char($characters); // RANDOM CHARACTER 4
$textcolor1 = imagecolorallocate($img, $randNr1, $randNr2, $randNr3); // TEXT COLOR 1
$textcolor2 = imagecolorallocate($img, $randNr2, $randNr3, $randNr1); // TEXT COLOR 2
$textcolor3 = imagecolorallocate($img, $randNr3, $randNr1, $randNr2); // TEXT COLOR 3
$textcolor4 = imagecolorallocate($img, $randNr3, $randNr2, $randNr1); // TEXT COLOR 4
imagettftext($img, $fontS, 0, $positionCharacterX + 0 * $characterSpace, $positionCharactersY, $textcolor1, $font, $randomChar1); // CHARACTER 1
imagettftext($img, $fontS, 0, $positionCharacterX + 1 * $characterSpace, $positionCharactersY, $textcolor2, $font, $randomChar2); // CHARACTER 2
imagettftext($img, $fontS, 0, $positionCharacterX + 2 * $characterSpace, $positionCharactersY, $textcolor3, $font, $randomChar3); // CHARACTER 3
imagettftext($img, $fontS, 0, $positionCharacterX + 3 * $characterSpace, $positionCharactersY, $textcolor4, $font, $randomChar4); // CHARACTER 4
$_SESSION['captcha'] = $randomChar1 . $randomChar2 . $randomChar3 . $randomChar4; // CAPTCHA STRING FOR SESSION
header("content-type: image/png"); // CONTENT TYPE
imagepng($img); // CREATE IMAGE
imagedestroy($img); // DESTROY IMAGE
?>
#######################################
## © 2008 Wouter De Schuyter (Paradox)
## <[email protected]>
## http://paradox-productions.net/
## CAPTCHA V1.0 (SPAM PROTECTION)
#######################################
session_start(); // START SESSION
// FUNCTION TO SELECT A RANDOM CHARACTER OUT OF A STRING
function random_char($string) {
$length = strlen($string);
$position = mt_rand(0, $length - 1);
return $string[$position];
}
$width = 75; // IMG WIDTH (PX)
$height = 25; // IMG HEIGHT (PX)
$characters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"; // CHARACTERS FOR CAPTCHA STRING
$font = "fonts/font.ttf"; // FONT LOCATION
$fontS = 12; // FONT SIZE (PX)
$min = 50; // MIN NUMBER FOR THE RANDOM RGB TEXT COLOR
$max = 200; // MAX NUMBER FOR THE RANDOM RGB TEXT COLOR
// ADVANCED
////////////
$positionCharacterX = 3; // POSITION CHARACTER 1 ON THE X-AXIS (PX)
$characterSpace = 20; // SPACE FOR 1 CHARACTER (PX)
$positionCharactersY = 17; // SPACE ON THE Y-AXIS (PX)
$img = imagecreate($width, $height);
imagecolorallocate($img, 255, 255, 255); // BACKGROUND COLOR IN RGB
$randNr1 = rand($min, $max); // RANDOM NUMBER 1 BETWEEN $min & $max
$randNr2 = rand($min, $max); // RANDOM NUMBER 2 BETWEEN $min & $max
$randNr3 = rand($min, $max); // RANDOM NUMBER 3 BETWEEN $min & $max
$randomChar1 = random_char($characters); // RANDOM CHARACTER 1
$randomChar2 = random_char($characters); // RANDOM CHARACTER 2
$randomChar3 = random_char($characters); // RANDOM CHARACTER 3
$randomChar4 = random_char($characters); // RANDOM CHARACTER 4
$textcolor1 = imagecolorallocate($img, $randNr1, $randNr2, $randNr3); // TEXT COLOR 1
$textcolor2 = imagecolorallocate($img, $randNr2, $randNr3, $randNr1); // TEXT COLOR 2
$textcolor3 = imagecolorallocate($img, $randNr3, $randNr1, $randNr2); // TEXT COLOR 3
$textcolor4 = imagecolorallocate($img, $randNr3, $randNr2, $randNr1); // TEXT COLOR 4
imagettftext($img, $fontS, 0, $positionCharacterX + 0 * $characterSpace, $positionCharactersY, $textcolor1, $font, $randomChar1); // CHARACTER 1
imagettftext($img, $fontS, 0, $positionCharacterX + 1 * $characterSpace, $positionCharactersY, $textcolor2, $font, $randomChar2); // CHARACTER 2
imagettftext($img, $fontS, 0, $positionCharacterX + 2 * $characterSpace, $positionCharactersY, $textcolor3, $font, $randomChar3); // CHARACTER 3
imagettftext($img, $fontS, 0, $positionCharacterX + 3 * $characterSpace, $positionCharactersY, $textcolor4, $font, $randomChar4); // CHARACTER 4
$_SESSION['captcha'] = $randomChar1 . $randomChar2 . $randomChar3 . $randomChar4; // CAPTCHA STRING FOR SESSION
header("content-type: image/png"); // CONTENT TYPE
imagepng($img); // CREATE IMAGE
imagedestroy($img); // DESTROY IMAGE
?>
font: http://downloads.paradox-productions.net/?f=fonts.rar
connection.inc.php
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
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
<?php
#######################################
## © 2008 Wouter De Schuyter (Paradox)
## <[email protected]>
## http://paradox-productions.net/
## CONNECTION
#######################################
// CONFIG
////////////
$hostname = "localhost"; // HOST (99% of the time localhost)
$username = ""; // USER
$password = ""; // PASS
$database = ""; // DATABASE
/////////////////////////////////////////////////
if($_SERVER['REMOTE_ADDR'] == "127.0.0.1") {
$host = "localhost";
$user = "root";
$pass = "usbw";
$db_name = "guestbook";
}
else {
$host = $hostname;
$user = $username;
$pass = $password;
$db_name = $database;
}
mysql_connect($host, $user, $pass) or die("<b>Could not connect to MySQL..</b><br />" . mysql_error());
mysql_select_db($db_name) or die("<b>Could not connect to Database..</b><br />" . mysql_error());
?>
#######################################
## © 2008 Wouter De Schuyter (Paradox)
## <[email protected]>
## http://paradox-productions.net/
## CONNECTION
#######################################
// CONFIG
////////////
$hostname = "localhost"; // HOST (99% of the time localhost)
$username = ""; // USER
$password = ""; // PASS
$database = ""; // DATABASE
/////////////////////////////////////////////////
if($_SERVER['REMOTE_ADDR'] == "127.0.0.1") {
$host = "localhost";
$user = "root";
$pass = "usbw";
$db_name = "guestbook";
}
else {
$host = $hostname;
$user = $username;
$pass = $password;
$db_name = $database;
}
mysql_connect($host, $user, $pass) or die("<b>Could not connect to MySQL..</b><br />" . mysql_error());
mysql_select_db($db_name) or die("<b>Could not connect to Database..</b><br />" . mysql_error());
?>
guestbook.php
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<?php
session_start();
require('connection.inc.php');
#####################################
## © 2008 Wouter De Schuyter
## <[email protected]>
## Guestbook V1.0
#####################################
// SET VARIABLES
//////////////////
$minName = 2; // minimum lenght name
$maxName = 32; // maximum lenght name
$minEmail = 8; // minimum lenght email
$maxEmail = 256; // maximum lenght email
$minMessage = 8; // minimum lenght message
$maxMessage = 2560; // maximum lenght message
///////////////////
$act = $_GET['action'];
// FUNCTIONS
//////////////
// REPLACE TEXT BY EMOTICONS
function emoticons($string) {
$emoticonsDirectory = "img/emoticons"; // directory from emoticons | example: "img/emoticons"
$array1 = array(
'^^',
'(!)',
'(?)',
'(A)',
'(a)',
':)',
'=)',
'(:',
'(=',
'):',
')=',
':(',
'=(',
';)',
':d',
':D',
'=d',
'=D',
':p',
':P',
'=p',
'=P',
'(8)',
':s',
':S',
'=s',
'=S',
's:',
'S:',
's=',
'S=',
':o',
':O',
'=o',
'=O',
'o:',
'O:',
'o=',
'O=',
'(l)',
'(L)',
':$',
'=$',
'$:',
'$=',
':\'(',
'=\'(',
')\'=',
')\':',
':@',
'=@',
' >< ',
'-_-',
'-.-',
'f5'
);
$array2 = array(
'<img src="' . $emoticonsDirectory . '/happy.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/exclamationmark.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/questionmark.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angel.png" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angel.png" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/wink.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/bandit.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/heart.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/heart.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angry.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angry.gif" alt="Emoticon" />',
' <img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" /> ',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
// UBB CODE
function ubb($string) {
$array1 = array(
'[b]',
'[/b]',
'[u]',
'[/u]',
'[center]',
'[/center]',
'[i]',
'[/i]'
);
$array2 = array(
'<b>',
'</b>',
'<u>',
'</u>',
'<center>',
'</center>',
'<i>',
'</i>'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
// VALID
function valid($string) {
$array1 = array(
'<br>',
'<noscript>'
);
$array2 = array(
'<br />',
'*noscript*'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
echo '
<a href="?action=homepage">Homepage</a>
|
<a href="?action=addComment">Add Comment</a>
|
<a href="?action=viewComments">View Comment(s)</a>';
// WHEN ACTION IS "Add Comment"
if($act == "addComment") {
echo "<h3>Add Comment</h3>\n";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$name = addslashes(ucfirst(trim($_POST['name']))); // NAME
$email = addslashes($_POST['email']); // EMAIL
$showEmail = $_POST['showEmail']; // SHOW/HIDE EMAIL
$emoticons = $_POST['emoticons']; // ENABLE/DISABLE EMOTICONS
$message = addslashes(ucfirst(trim($_POST['message']))); // MESSAGE
$captcha = $_POST['captcha']; // CAPTCHA
$captchaVer = $_SESSION['captcha']; // CAPTCHA CHECK
$time = date("Y/m/d H:i:s"); // TIME
$ip = $_SERVER['REMOTE_ADDR']; // IP
$regexp = "/^[a-z0-9_]+([_\\.-][a-z0-9_]+)*@([a-z0-9_]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; // EMAIL CHECK
// GENERAL FIELD CHECK
if(strlen($name) < 1 or strlen($email) < 1 or strlen($message) < 1 or strlen($captcha) < 1) {
echo "<p>Make sure all the required fields are correctly filled in!</p>\n";
$generalError = true;
}
elseif($generalError !== true) {
// CHECK NAME LENGHT
if(strlen($name) < $minName) {
echo "<p>Your name must contain at least " . $minName . " characters! Please enter a longer name.</p>\n";
$lenghtError = true;
}
elseif(strlen($name) > $maxName) {
echo "<p>Your name can not contain more than " . $maxName . " characters! Please enter a shorter name.</p>\n";
$lenghtError = true;
}
// CHECK EMAIL LENGHT
if(strlen($email) < $minEmail) {
echo "<p>Your email must contain at least " . $minEmail . " characters! Please enter a longer email.</p>\n";
$lenghtError = true;
}
elseif(strlen($email) > $maxEmail) {
echo "<p>Your email can not contain more than " . $maxEmail . " characters! Please enter a shorter email.</p>\n";
$lenghtError = true;
}
// CHECK MESSAGE LENGHT
if(strlen($message) < $minMessage) {
echo "<p>Your message must contain at least " . $minMessage . " characters! Please enter a longer message.</p>\n";
$lenghtError = true;
}
elseif(strlen($message) > $maxMessage) {
echo "<p>Your message can not contain more than " . $maxMessage . " characters! Please enter a shorter message.</p>\n";
$lenghtError = true;
}
// CHECK CAPTCHA LENGHT
if(strlen($captcha) !== 4) {
echo "<p>Your captcha verefication can not contain more or less than 4 characters!</p>\n";
$lenghtError = true;
}
if($lenghtError !== true) {
// VALID EMAIL ?
if(!preg_match($regexp, $email)) {
echo "<p>Your email is not valid! Please try again.</p>\n";
$error = true;
}
// CAPTCHA CORRECT?
if($captcha !== $captchaVer) {
echo "<p>Your captcha verefication code was inccorect! Please try again.</p>\n";
$error = true;
}
if($error !== true) {
$insertQuery = "INSERT INTO `guestbook` (`name`, `email`, `showEmail`, `enableEmoticons`, `message`, `time`, `ip`) VALUES ('" . $name . "', '" . $email . "', '" . $showEmail . "', '" . $emoticons . "', '" . $message . "', '" . $time . "', '" . $ip . "')";
$insert = mysql_query($insertQuery);
if($insert) {
echo "<p>Your message was successfully loaded into the guestbook database!<br /><a href=\"?action=viewComments\">Click Here</a> to view the guestbook entries.</p>\n";
$success = true;
}
else {
echo "<p>Error<br />" . mysql_error() . "</p>\n";
}
}
}
}
}
if($success !== true) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $act; ?>" method="post">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" maxlength="<?php echo $maxName; ?>" value="<?php echo stripslashes($name); ?>" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" maxlength="<?php echo $maxEmail; ?>" value="<?php echo stripslashes($email); ?>" /></td>
</tr>
<tr>
<td>Show Email</td>
<td>
Yes <input type="radio" name="showEmail" value="1"<?php if($showEmail == 1) { echo " checked=\"checked\""; } ?> />
No <input type="radio" name="showEmail" value="0"<?php if($showEmail == 0) { echo " checked=\"checked\""; } ?> />
</td>
</tr>
<tr>
<td>Enable Emoticons</td>
<td>
Yes <input type="radio" name="emoticons" value="1"<?php if($emoticons == 1) { echo " checked=\"checked\""; } ?> />
No <input type="radio" name="emoticons" value="0"<?php if($emoticons == 0) { echo " checked=\"checked\""; } ?> />
</td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message" rows="4" cols="30"><?php echo stripslashes($message); ?></textarea></td>
</tr>
<tr>
<td><img src="captcha/captcha.php" alt="Are You Human?" /></td>
<td><input type="text" name="captcha" maxlength="4" size="6" /> <span class="note">(Vereficate You Are Human)</span></td>
</tr>
<tr>
<td><input type="reset" value="Reset Form" /></td>
<td><input type="submit" value="Save Message" /></td>
</tr>
</table>
</form>
<?php
}
}
// WHEN ACTION IS "View Comment(s)"
elseif($act == "viewComments") {
$sql = "SELECT `name`, `email`, `showEmail`, `enableEmoticons`, `message`, `time` FROM guestbook ORDER BY `id` DESC";
$dataQuery = mysql_query($sql);
echo "<h3>View Comments (" . mysql_num_rows($dataQuery) . ")</h3>\n";
if(mysql_num_rows($dataQuery) == 0) {
echo "<p>There are currently no guestbook entries. <a href=\"?action=addComment\">Be first to make one!</a></p>\n";
}
else {
while($data = mysql_fetch_assoc($dataQuery)) {
?>
<table border="1px" width="400px">
<tr>
<td><?php if($data['showEmail'] == 1) { ?><a href="mailto:<?php echo $data['email']; ?>"><?php } echo stripslashes($data['name']); if($data['showEmail'] == 1) { ?></a><?php } ?> wrote on <?php $date = new DateTime($data['time']); echo $date->format('d/m/Y, H:i:s'); ?></td>
</tr>
<tr>
<td>
<?php
$message = ubb(nl2br(stripslashes(htmlentities(valid($data['message'])))));
if($data['enableEmoticons'] == 1) {
echo emoticons($message);
}
if($data['enableEmoticons'] == 0) {
echo $message;
}
?>
</td>
</tr>
</table>
<?php
}
}
}
else {
echo "<h3>Guestbook V1.0 - Provided by www.paradox-productions.net</h3>\n";
?>
<ul>
<li>Add Comment</li>
<li>Read Comments</li>
<li>Secured against
<ul>
<li>Spam(bots)</li>
<li>SQL Injection</li>
<li>Javascript Injection</li>
<li>Form Injection</li>
<li>(x)html/php filter</li>
</ul>
</li>
<li>Option to hide your email</li>
<li>Option to enable emoticons</li>
<li>Config</li>
</ul>
<?php } echo "<center><p>© 2008 All Rights Reserved To Paradox-Productions.Net | Designed & Coded by Paradox</p></center>"; ?>
session_start();
require('connection.inc.php');
#####################################
## © 2008 Wouter De Schuyter
## <[email protected]>
## Guestbook V1.0
#####################################
// SET VARIABLES
//////////////////
$minName = 2; // minimum lenght name
$maxName = 32; // maximum lenght name
$minEmail = 8; // minimum lenght email
$maxEmail = 256; // maximum lenght email
$minMessage = 8; // minimum lenght message
$maxMessage = 2560; // maximum lenght message
///////////////////
$act = $_GET['action'];
// FUNCTIONS
//////////////
// REPLACE TEXT BY EMOTICONS
function emoticons($string) {
$emoticonsDirectory = "img/emoticons"; // directory from emoticons | example: "img/emoticons"
$array1 = array(
'^^',
'(!)',
'(?)',
'(A)',
'(a)',
':)',
'=)',
'(:',
'(=',
'):',
')=',
':(',
'=(',
';)',
':d',
':D',
'=d',
'=D',
':p',
':P',
'=p',
'=P',
'(8)',
':s',
':S',
'=s',
'=S',
's:',
'S:',
's=',
'S=',
':o',
':O',
'=o',
'=O',
'o:',
'O:',
'o=',
'O=',
'(l)',
'(L)',
':$',
'=$',
'$:',
'$=',
':\'(',
'=\'(',
')\'=',
')\':',
':@',
'=@',
' >< ',
'-_-',
'-.-',
'f5'
);
$array2 = array(
'<img src="' . $emoticonsDirectory . '/happy.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/exclamationmark.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/questionmark.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angel.png" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angel.png" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/smile.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/sad.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/wink.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/biggrin.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/tongue.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/bandit.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/confused.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/ooo.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/heart.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/heart.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/blush.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/crying.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angry.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/angry.gif" alt="Emoticon" />',
' <img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" /> ',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />',
'<img src="' . $emoticonsDirectory . '/hmmpff.gif" alt="Emoticon" />'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
// UBB CODE
function ubb($string) {
$array1 = array(
'[b]',
'[/b]',
'[u]',
'[/u]',
'[center]',
'[/center]',
'[i]',
'[/i]'
);
$array2 = array(
'<b>',
'</b>',
'<u>',
'</u>',
'<center>',
'</center>',
'<i>',
'</i>'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
// VALID
function valid($string) {
$array1 = array(
'<br>',
'<noscript>'
);
$array2 = array(
'<br />',
'*noscript*'
);
$output = str_replace($array1, $array2, $string);
return $output;
}
echo '
<a href="?action=homepage">Homepage</a>
|
<a href="?action=addComment">Add Comment</a>
|
<a href="?action=viewComments">View Comment(s)</a>';
// WHEN ACTION IS "Add Comment"
if($act == "addComment") {
echo "<h3>Add Comment</h3>\n";
if($_SERVER['REQUEST_METHOD'] == "POST") {
$name = addslashes(ucfirst(trim($_POST['name']))); // NAME
$email = addslashes($_POST['email']); // EMAIL
$showEmail = $_POST['showEmail']; // SHOW/HIDE EMAIL
$emoticons = $_POST['emoticons']; // ENABLE/DISABLE EMOTICONS
$message = addslashes(ucfirst(trim($_POST['message']))); // MESSAGE
$captcha = $_POST['captcha']; // CAPTCHA
$captchaVer = $_SESSION['captcha']; // CAPTCHA CHECK
$time = date("Y/m/d H:i:s"); // TIME
$ip = $_SERVER['REMOTE_ADDR']; // IP
$regexp = "/^[a-z0-9_]+([_\\.-][a-z0-9_]+)*@([a-z0-9_]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; // EMAIL CHECK
// GENERAL FIELD CHECK
if(strlen($name) < 1 or strlen($email) < 1 or strlen($message) < 1 or strlen($captcha) < 1) {
echo "<p>Make sure all the required fields are correctly filled in!</p>\n";
$generalError = true;
}
elseif($generalError !== true) {
// CHECK NAME LENGHT
if(strlen($name) < $minName) {
echo "<p>Your name must contain at least " . $minName . " characters! Please enter a longer name.</p>\n";
$lenghtError = true;
}
elseif(strlen($name) > $maxName) {
echo "<p>Your name can not contain more than " . $maxName . " characters! Please enter a shorter name.</p>\n";
$lenghtError = true;
}
// CHECK EMAIL LENGHT
if(strlen($email) < $minEmail) {
echo "<p>Your email must contain at least " . $minEmail . " characters! Please enter a longer email.</p>\n";
$lenghtError = true;
}
elseif(strlen($email) > $maxEmail) {
echo "<p>Your email can not contain more than " . $maxEmail . " characters! Please enter a shorter email.</p>\n";
$lenghtError = true;
}
// CHECK MESSAGE LENGHT
if(strlen($message) < $minMessage) {
echo "<p>Your message must contain at least " . $minMessage . " characters! Please enter a longer message.</p>\n";
$lenghtError = true;
}
elseif(strlen($message) > $maxMessage) {
echo "<p>Your message can not contain more than " . $maxMessage . " characters! Please enter a shorter message.</p>\n";
$lenghtError = true;
}
// CHECK CAPTCHA LENGHT
if(strlen($captcha) !== 4) {
echo "<p>Your captcha verefication can not contain more or less than 4 characters!</p>\n";
$lenghtError = true;
}
if($lenghtError !== true) {
// VALID EMAIL ?
if(!preg_match($regexp, $email)) {
echo "<p>Your email is not valid! Please try again.</p>\n";
$error = true;
}
// CAPTCHA CORRECT?
if($captcha !== $captchaVer) {
echo "<p>Your captcha verefication code was inccorect! Please try again.</p>\n";
$error = true;
}
if($error !== true) {
$insertQuery = "INSERT INTO `guestbook` (`name`, `email`, `showEmail`, `enableEmoticons`, `message`, `time`, `ip`) VALUES ('" . $name . "', '" . $email . "', '" . $showEmail . "', '" . $emoticons . "', '" . $message . "', '" . $time . "', '" . $ip . "')";
$insert = mysql_query($insertQuery);
if($insert) {
echo "<p>Your message was successfully loaded into the guestbook database!<br /><a href=\"?action=viewComments\">Click Here</a> to view the guestbook entries.</p>\n";
$success = true;
}
else {
echo "<p>Error<br />" . mysql_error() . "</p>\n";
}
}
}
}
}
if($success !== true) {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $act; ?>" method="post">
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" maxlength="<?php echo $maxName; ?>" value="<?php echo stripslashes($name); ?>" /></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" maxlength="<?php echo $maxEmail; ?>" value="<?php echo stripslashes($email); ?>" /></td>
</tr>
<tr>
<td>Show Email</td>
<td>
Yes <input type="radio" name="showEmail" value="1"<?php if($showEmail == 1) { echo " checked=\"checked\""; } ?> />
No <input type="radio" name="showEmail" value="0"<?php if($showEmail == 0) { echo " checked=\"checked\""; } ?> />
</td>
</tr>
<tr>
<td>Enable Emoticons</td>
<td>
Yes <input type="radio" name="emoticons" value="1"<?php if($emoticons == 1) { echo " checked=\"checked\""; } ?> />
No <input type="radio" name="emoticons" value="0"<?php if($emoticons == 0) { echo " checked=\"checked\""; } ?> />
</td>
</tr>
<tr>
<td>Message</td>
<td><textarea name="message" rows="4" cols="30"><?php echo stripslashes($message); ?></textarea></td>
</tr>
<tr>
<td><img src="captcha/captcha.php" alt="Are You Human?" /></td>
<td><input type="text" name="captcha" maxlength="4" size="6" /> <span class="note">(Vereficate You Are Human)</span></td>
</tr>
<tr>
<td><input type="reset" value="Reset Form" /></td>
<td><input type="submit" value="Save Message" /></td>
</tr>
</table>
</form>
<?php
}
}
// WHEN ACTION IS "View Comment(s)"
elseif($act == "viewComments") {
$sql = "SELECT `name`, `email`, `showEmail`, `enableEmoticons`, `message`, `time` FROM guestbook ORDER BY `id` DESC";
$dataQuery = mysql_query($sql);
echo "<h3>View Comments (" . mysql_num_rows($dataQuery) . ")</h3>\n";
if(mysql_num_rows($dataQuery) == 0) {
echo "<p>There are currently no guestbook entries. <a href=\"?action=addComment\">Be first to make one!</a></p>\n";
}
else {
while($data = mysql_fetch_assoc($dataQuery)) {
?>
<table border="1px" width="400px">
<tr>
<td><?php if($data['showEmail'] == 1) { ?><a href="mailto:<?php echo $data['email']; ?>"><?php } echo stripslashes($data['name']); if($data['showEmail'] == 1) { ?></a><?php } ?> wrote on <?php $date = new DateTime($data['time']); echo $date->format('d/m/Y, H:i:s'); ?></td>
</tr>
<tr>
<td>
<?php
$message = ubb(nl2br(stripslashes(htmlentities(valid($data['message'])))));
if($data['enableEmoticons'] == 1) {
echo emoticons($message);
}
if($data['enableEmoticons'] == 0) {
echo $message;
}
?>
</td>
</tr>
</table>
<?php
}
}
}
else {
echo "<h3>Guestbook V1.0 - Provided by www.paradox-productions.net</h3>\n";
?>
<ul>
<li>Add Comment</li>
<li>Read Comments</li>
<li>Secured against
<ul>
<li>Spam(bots)</li>
<li>SQL Injection</li>
<li>Javascript Injection</li>
<li>Form Injection</li>
<li>(x)html/php filter</li>
</ul>
</li>
<li>Option to hide your email</li>
<li>Option to enable emoticons</li>
<li>Config</li>
</ul>
<?php } echo "<center><p>© 2008 All Rights Reserved To Paradox-Productions.Net | Designed & Coded by Paradox</p></center>"; ?>
Hoe installeren?
Maak een map aan "captcha" maak daarin het bestand captcha.php aan. plaats in de captcha map een andere map "fonts" en plaats daarin het font (font.ttf).
Maak in de hoofdmap waar de captcha map in staat connection.inc.php aan en guestbook.php
Maak een dir aan in diezelfde hoofdmap met de emoticons en pas vervolgens guestbook.php aan naar de naam van de dir met de emoticons. Voor het standaard maak je een map "img" aan en daarin een map "emoticons" en daar zet je de emoticons in.
Maar het gemakkelijkste is dat je gewoon dit http://downloads.paradox-productions.net/?f=GUESTBOOK.rar download extract en dan de non styled version gebruikt om in je website te integreren.