Kiezen in PHP gaat fout! A.u.b. hulp!
Ik ben momenteel bezig met een script voor een mobiele chat.
Ik ben nu alleen het volgende probleem tegen gekomen:
Als ik naar de chat ga (www.schoolfeest.djmisha.nl, alleen te bezoeken via mobiel/PDA) dan moet ik het geslacht & of ik smilies wil of niet invullen. Dit gaat d.m.v. een lijst. Alleen nu kan ik deze lijst niet openen op mijn mobiele telefoon. Dus hoe kan ik het maken dat je d.m.v. een rondje kan kiezen?
Hier is het script:
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
<?php
/////////////////////////////////////////////////////////////////////////////////////////////////
// //
// GumChat //
// Current Version : 1.19 //
// Author : GUMSLONE //
// You are not allowed to redistribute or modify this script //
// Copyright (c) 2008 GumSlone. All rights reserved. //
// Additional scripts can be found at http://www.coding-talk.com //
// Released on 08 April 2009 //
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////
//0 means server time
$TimeZone = "0";
// hours* 60 mins* 60secs DONT TOUCH!
$New_Time = time() + ($TimeZone * 60 * 60);
//DONT TOUCH!
$_time = date("H:i", $New_Time);
//chatroom refreshtime
$_refresh = 200;
//means chatroom size of 15 messages
$_room_size = 20;
$home_page_url = "http://2wap.org";
$home_page_title = "2WAP.ORG";
//up to which text message should be smilies visible, from this text messages the smilies will be shown as a text not as an image
$smilies_decode = 5;
$waittime_sec = 5;
/* Set this to a minimum wait time between posts (in sec) */
//DONT TOUCH!
$encoding = "ISO-8859-1";
/////////////[Change language or menu]////////////////////////////////
$lang_user_in_chat = "users in chat";
$lang_enter = "- Enter -";
$lang_nickname = "Your Nickname:";
$lang_gender = "Gender:";
$lang_male = "Male";
$lang_female = "Female";
$lang_age = "Age: ";
$lang_show_smilies = "Show smilies? ";
$lang_yes = "YES";
$lang_no = "NO";
$lang_select_chatroom = "Select Chatroom";
$lang_users = "Users in";
$lang_chatrooms = "Chatrooms";
$lang_smilies = "Smilies";
$lang_next = "Next »";
$lang_prev = "« Prev";
$lang_chat = "Back to Chatroom";
$lang_say = "Say";
$lang_refresh = "Refresh";
$lang_message = "Message:";
$lang_ok = "OK";
$lang_change_chatroom = "Change Chatroom";
$lang_who_is_online = "Who's Inside";
$lang_loading = "Loading...<br/>please wait";
$lang_exit = "Logout";
///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////
/////////////[DO NOT EDIT AFTER THIS LINE]////////////////////////////////
foreach ($_POST as $key => $value) {
${$key} = $value;
}
foreach ($_GET as $key => $value) {
${$key} = $value;
}
$nick = nick_replace($nick);
$nick = substr(trim($nick), 0, 15);
global $nick;
///////////IF Nickname is shorter than 3 chars retur an error message and let the user relogin//////////
if ($nick != '' && strlen($nick) < 3) {
$gum = "";
$login_error_message .= '<i>Nickname is to short, it has to be longer than 3 chars, also avoid special chars in nickname. Allowed chars: A-Z, a-z, 0-9, - _ @</i><br/>';
}
$G = nick_replace(substr(trim($G), 0, 1));
$A = nick_replace(substr(trim($A), 0, 2));
$room = replace($room);
header("Content-type: text/vnd.wap.wml; charset=$encoding");
header("Cache-Control: no-store, no-cache, must-revalidate");
print "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<!-- GumChat by GumSlone Version 1.09 (c) 2008 All rights reserved. -->
<!-- Additional scripts can be found at http://www.coding-talk.com -->
<wml>
<?php
if ($nick && $room) {
$daten = 'online/on' . $room;
$time = time();
$user = explode('/', $_SERVER['HTTP_USER_AGENT']);
$user[0] = ereg_replace(' ', '_', $user[0]);
$ip = (trim($nick) . ' ' . trim($user[0]) . ' ' . trim($G) . ' ' . trim($A));
$ablaufzeit = $time - 250;
$pruefung = @file($daten);
while (list($line_num, $line) = @each($pruefung)) {
$zeiten = explode(":", $line);
if ($zeiten[0] <= $ablaufzeit) {
$fp = fopen($daten, "r");
$contents = fread($fp, filesize($daten));
fclose($fp);
$line = quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh = fopen($daten, "w");
@flock($fp, 2);
fputs($fh, $replace);
@flock($fp, 3);
fclose($fh);
}
}
$ippruefung = @file($daten);
while (list($line_num, $line) = @each($ippruefung)) {
$ips = explode(":", $line);
if ($ips[1] == $ip) {
$fp = fopen($daten, "r");
$contents = fread($fp, filesize($daten));
fclose($fp);
$line = quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh = fopen($daten, "w");
@flock($fp, 2);
fputs($fh, $replace);
@flock($fp, 3);
fclose($fh);
}
}
$fp = fopen($daten, "a+");
flock($fp, 2);
fputs($fp, "$time:$ip:\n");
flock($fp, 3);
fclose($fp);
}
if ($gum == "") {
echo "<card id=\"GumChat\" title=\"GumChat $_time\">";
echo "<p align=\"center\">";
echo "<img src=\"logo.gif\" alt=\"GumChat\"/><br/>";
echo $login_error_message;
$n = 0;
$files = '';
if ($handle = opendir("rooms/")) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'files' && $file != 'cgi-bin' && $file != 'chat') {
if ($n >= 0 && $n < 20) {
$onfile = file("online/on$file");
$counts = count($onfile);
if ($counts < 2) {
$gumdata = explode(":", $onfile[0]);
$ablaufzeit = time() - "250";
if ($gumdata[0] <= $ablaufzeit) {
$fp = fopen("online/on$file", "w+");
$counts = 0;
}
}
$total = $total + $counts;
$n++;
}
}
}
closedir($handle);
}
echo "$total $lang_user_in_chat!<br/>";
echo "$lang_nickname <input name=\"us\" maxlength=\"20\"/><br/>";
echo $lang_gender . '
<select name="g" multiple="false">
<option value="m">' . $lang_male . '</option>
<option value="f">' . $lang_female . '</option>
</select><br/>';
echo "$lang_age<input name=\"a\" maxlength=\"2\" format=\"NN\" size=\"2\"/><br/>";
echo $lang_show_smilies . '
<select name="sm" multiple="false">
<option value="1">' . $lang_yes . '</option>
<option value="0">' . $lang_no . '</option>
</select><br/>';
echo "<anchor title=\"Enter\">$lang_enter";
echo "<go href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&WLC=1\" method=\"post\">";
echo "<postfield name=\"nick\" value=\"\$us\"/>";
echo "<postfield name=\"sm\" value=\"\$sm\"/>";
echo "<postfield name=\"G\" value=\"\$g\"/>";
echo "<postfield name=\"A\" value=\"\$a\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><a href=\"index_xhtml.php\">[xhtml]</a> [wml]<br/><a href=\"$home_page_url\">$home_page_title</a>";
echo "<br/><small>(c) GumSlone 2004-2008<br/>GumChat v 1.9</small></p>";
echo "</card>";
}
if ($gum == "rooms") {
echo "<card id=\"ChatRooms\" title=\"$lang_chatrooms ($_time)\">";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"center\">";
$nick = ereg_replace(" ", "_", $nick);
if (preg_match("/[^\da-zA-Z-@_]+/", $nick) || $nick == "")
$error = 'Not suported chars in Nickname!<br/>';
if (empty($error)) {
if ($WLC)
echo "Welcome to chat $nick<br/>";
echo "$lang_select_chatroom<br/>";
$n = 0;
$files = '';
if ($handle = opendir("rooms/")) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'files' && $file != 'cgi-bin' && $file != 'chat') {
if ($n >= 0 && $n < 20) {
$onfile = file("online/on$file");
$counts = count($onfile);
$total = $total + $counts;
$n++;
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$file\">$file [$counts]</a><br/>";
}
}
}
closedir($handle);
}
} else
echo $error . "<anchor>Back<prev/></anchor><br/>";
echo "<br/>$total $lang_users $n $lang_chatrooms!";
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "\">$lang_exit</a><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "croom") {
$onxfile = @file("online/on$room");
$countonl = count($onxfile);
echo "<card id=\"card0\" title=\"$room in $countonl ($_time)\" ontimer=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\"><timer value=\"$_refresh\"/>";
echo "<do type=\"options\" name=\"say\" label=\"$lang_say\"><go href=\"#Say\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_refresh\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"whowhere\" label=\"$lang_who_is_online\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"changeroom\" label=\"$lang_change_chatroom\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&nick=$nick&sm=$sm&G=$G&A=$A\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"smilies\" label=\"$lang_smilies\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
echo "<a href=\"#Say\">$lang_say</a> ";
echo " <a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\">$lang_refresh</a><br/>";
////////////////////////////////////////
if ($mess != "") {
$mess = replace($mess);
$mess = filterFlood($mess);
$mess = filterBadWords($mess);
$mess = substr($mess, 0, 160);
$_mudata = explode(" ", $mess);
$count_spaces = count($_mudata);
$count_chars = strlen($mess);
if ($count_chars < 4 && !empty($mess)) {
$chat_error_message .= '<i>The message is to short, it has to be longer than 4 chars</i><br/>';
}
$text = "&&$nick $_time&&$mess&&";
if ($count_spaces < 3 && $count_chars > 30)
$FOUND = 1;
if ($count_spaces < 5 && $count_chars > 40)
$FOUND = 1;
}
//////////////////////////////////////////////
if ($mess != "" && !$chat_error_message) {
$udata = explode("&&", $text);
$udata[2] = htmlspecialchars($udata[2]);
$udata[2] = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
$udata[2] = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
if ($sm == 1)
$udata[2] = ReplaceTextToSmilies($udata[2]);
echo '<b>' . htmlspecialchars($udata[1]) . ' »</b> ' . $udata[2] . '<br/>';
} else
echo $chat_error_message;
$fp = fopen('rooms/' . $room, "r");
$smilies_decode_num = 1;
$I = 0;
$mini_found = 1;
while ($radka = fgets($fp, 512)) {
$udata = explode("&&", $radka);
if ($udata[2] != "") {
////////////////////////ANTIFLOOOOOOOOOOOOOOOOOD////////////////////
if (isset($mess)) {
if ($udata[3] == $antiflood) {
$FOUND = 1;
}
if (trim($udata[2]) == trim($mess)) {
$FOUND = 1;
}
if ($FOUND != 1) {
$checktext_1 = preg_replace('/[^[:alnum:]\^]/', '', strtolower($udata[2]));
$checktext_2 = preg_replace('/[^[:alnum:]\^]/', '', strtolower($mess));
$count_checktext_1 = strlen($checktext_1);
$count_checktext_2 = strlen($checktext_2);
$rand_start_1 = rand(1, $count_checktext_1 - 6);
$rand_start_2 = rand(1, $count_checktext_2 - 6);
for ($n = 1; $n <= $count_checktext_1; $n++) {
if (substr($checktext_1, $rand_start_1, 6) == substr($checktext_2, $n, 6)) {
$FOUND = 1;
break;
}
if (substr($checktext_2, $rand_start_2, 6) == substr($checktext_1, $n, 6)) {
$FOUND = 1;
break;
}
}
if ($FOUND != 1) {
for ($n = $count_checktext_1; $n >= 1; $n--) {
if (substr($checktext_1, $rand_start_1, 6) == substr($checktext_2, $n, 6)) {
$FOUND = 1;
break;
}
if (substr($checktext_2, $rand_start_2, 6) == substr($checktext_1, $n, 6)) {
$FOUND = 1;
break;
}
}
}
}
if (substr($udata[1], 0, 2) == substr($nick, 0, 2)) {
if (substr($checktext_1, 0, 2) == substr($checktext_2, 0, 2) && $checktext_1 < 6)
$mini_found++;
elseif (substr($checktext_1, $count_checktext_1 - 2, 2) == substr($checktext_2, $count_checktext_2 - 2, 2) && $count_chars < 6)
$mini_found++;
elseif ($count_checktext_1 == $count_checktext_2)
$mini_found++;
}
$count_mess_chars = strlen($mess);
if (!isset($FOUND) && $count_mess_chars > 30) {
$message_middle = ceil($count_mess_chars / 2);
preg_match_all("/" . substr(strtolower($mess), ($message_middle - 5), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
if (!isset($FOUND)) {
preg_match_all("/" . substr(strtolower($mess), ($message_middle - 7), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
if (!isset($FOUND)) {
preg_match_all("/" . substr(strtolower($mess), ($message_middle + 1), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
}
}
}
}
if ($mini_found > 3)
$FOUND = 1;
/////////////////////////END OF ANTIFLOOD CHECK////////////////////
$udata[2] = htmlspecialchars($udata[2]);
$udata[2] = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
$udata[2] = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
// $udata[2] = filterBadWords($udata[2]);
if ($sm == 1 && $smilies_decode_num <= $smilies_decode)
$udata[2] = ReplaceTextToSmilies($udata[2]);
$smilies_decode_num++;
$udata[1] = ereg_replace("_", " ", $udata[1]);
echo '<b>' . htmlspecialchars($udata[1]) . ' »</b> ' . $udata[2] . '<br/>';
}
}
fclose($fp);
/////////////////////WRITING A TEXT MESSAGE TO the FILE///////////////////////////
if (!$FOUND && $mess != "" && $nick != "" && !$chat_error_message) {
$text = stripslashes($text);
$text = strip_tags($text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
//$text = ereg_replace("_", " ", $text);
if (file_exists("rooms/" . $room)) {
$zpravy = file("rooms/" . $room);
}
$fp = fopen("rooms/" . $room, "w");
fputs($fp, $text . "\n");
for ($i = 0; $i < $_room_size; $i++) {
fputs($fp, $zpravy[$i]);
}
fclose($fp);
}
/////////////////////END OF WRITING A TEXT MESSAGE TO the FILE///////////////////////////
echo "<a href=\"#Say\">$lang_say</a> ";
echo " <a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\">$lang_refresh</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_who_is_online</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&nick=$nick&sm=$sm&G=$G&A=$A\">$lang_change_chatroom</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_smilies</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "\">$lang_exit</a><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
//////////////////SAY////////////////////////////////////////////////////////////////
echo "<card id=\"Say\" title=\"$lang_say ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"Chatroom\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
echo "$lang_message <input name=\"mess" . $New_Time . "\" maxlength=\"200\"/><br/>";
echo "<anchor title=\"Say\">$lang_say";
echo "<go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"post\">";
echo "<postfield name=\"mess\" value=\"\$(mess" . $New_Time . ")\"/>";
echo "</go>";
echo "</anchor>";
//echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><anchor>Back<prev/></anchor><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "smilies") {
echo "<card id=\"Smilies\" title=\"$lang_smilies ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_chat\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
$conf["items_per_page"] = 5;
if (isset($npage))
$page = $npage - 1;
if (!isset($page))
$page = 0;
if ($page < 0)
$page = 0;
$total = 0;
if (!($dp = opendir("./smilies/")))
die("Cannot open ./smilies/");
$file_array = array();
while ($file = readdir($dp)) {
if (substr($file, 0, 1) != '.' and $file != '..' and $file != 'index.php') {
$file_array[] = $file;
}
}
$file_count = count($file_array);
sort($file_array);
if ($file_count > 0) {
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];
while (list($fileIndexValue, $file_name) = each($file_array)) {
if (($fileIndexValue >= $first_record) and ($fileIndexValue < $last_record)) {
$user = explode('.', $file_name);
echo "<img src=\"smilies/$file_name\" alt=\"." . $user[0] . ".\"/> ." . $user[0] . ".<br/>";
}
}
if (($file_count > 0) and ($last_record < $file_count)) {
// next button
$next_page = $page + 1;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&page=$next_page\">$lang_next</a><br/>";
}
if (($file_count > 0) and ($page != 0)) {
// previous button
$prev_page = $page - 1;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&page=$prev_page\">$lang_prev</a><br/>";
}
}
closedir($dp);
echo "<b>$file_count</b> $lang_smilies<br/>";
$pages = ceil($file_count / $conf["items_per_page"]);
echo "Page <b>" . ($page + 1) . "</b> of $pages<br/>";
if ($pages > 2)
echo "Jump to Page: <input emptyok=\"true\" name=\"q\" format=\"*N\" size=\"3\" value=\"\" /><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&npage=$(q)&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">Jump</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "online") {
echo "<card id=\"Online\" title=\"$lang_who_is_online ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_chat\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
$xfile = @file("online/on$room");
$xfile = array_reverse($xfile);
$p = 25;
if ($npage == "") {
$npage = "1";
}
$countfile = count($xfile);
$first = $countfile - ($p * ($npage - 1));
$second = $countfile - ($p * $npage) + 1;
if ($second < 1) {
$second = 1;
}
$npages = ceil($countfile / $p);
if ($npage <= $npages and $npage > 1)
$gline_rew = "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&npage=" . ($npage - 1) . "\">$lang_prev</a>";
if ($npages > 1 and $npage < $npages)
$gline_next = "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&npage=" . ($npage + 1) . "\">$lang_next</a>";
if ($npage == 1)
$nn = 1;
else
$nn = (($npage - 1) * $p) + 1;
for ($i = $first - 1; $i >= $second - 1; $i--) {
$xdata = explode(':', $xfile[$i]);
$udata = explode(' ', $xdata[1]);
if ($udata[2] == m)
$gender = $lang_male;
if ($udata[2] == f)
$gender = $lang_female;
echo $nn++ . ". <small><b>$udata[0]</b> $gender ($udata[3]) $udata[1]</small><br/>";
}
print "<br/>";
if ($npages > 1)
print $gline_rew . "| " . $gline_next;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
function filterBadWords($str)
{
// words to filter, you can add here some more
// replace filtered words with
$badwords = array("2-wap", "htp", " dot ", "http", "\.biz", "\.mobi", "\.net", "\.ru", "\.c0m", "\.org", "\.wen", "\.com", "\.web.tr", "dhoomworld", "Chatworld", "Mobichat", "Desiclub", "Friendsgarage", "Friendsgarage", "Loverslane", "Mixit", "Mxit", "Prodigits", "Leeinc", "Eaglesnest", "Wap2chat", "Bdsaint", "Hitler", "Nazi", "Chod", "Wichser");
$replacements = array("???", "***");
for ($i = 0; $i < sizeof($badwords); $i++) {
srand((double)microtime() * 1000000);
$rand_key = (rand() % sizeof($replacements));
$str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
function filterFlood($str)
{
// words to filter, you can add here some more
$text = str_replace('~~', '', $text);
$text = str_replace('@@', '', $text);
$text = str_replace('-', ' - ', $text);
$text = str_replace('___', '_', $text);
$text = str_replace('__', '_', $text);
$text = str_replace(" . ..", " .", $text);
$text = str_replace(".. . ", ". ", $text);
$text = str_replace(" . . ", " ", $text);
$text = str_replace(" . ", " ", $text);
$text = str_replace("...", "..", $text);
$text = str_replace(" ", " ", $text);
$text = str_replace(" ", " ", $text);
$text = str_replace('??', "", $text);
$text = str_replace('**', "", $text);
$text = str_replace('* *', "", $text);
$text = str_replace('? ?', "", $text);
//[:punct:]
$text = str_replace("\\", "", $text);
// replace filtered words with
$badwords = array("gmg", "tpt", "gjg", "gwg", "pdp", "www", "wvw", "gaga", "tjt", "mjm", "wpw", "@@", "kmk", "momo", "mwm", "mvm", "gmg");
$replacements = array("");
for ($i = 0; $i < sizeof($badwords); $i++) {
srand((double)microtime() * 1000000);
$rand_key = (rand() % sizeof($replacements));
$str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
function ReplaceTextToSmilies($str)
{
$dir = "smilies/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$smilie_count = 0;
while (($file = readdir($dh)) !== false) {
$smilie = explode(".", $file);
if ($file != '.' && $file != '..') {
if (preg_match("/\." . $smilie[0] . "\./i", $str))
$smilie_count++;
if ($smilie_count < 4)
$str = preg_replace('(\.' . $smilie[0] . '\.)', '<img src="' . $dir . $file . '" alt="' . $smilie[0] . '" />', $str, 1);
//$str = str_replace('.'.$smilie[0].'.', '<img src="'.$dir.$file.'" alt="'.$smilie[0].'" />', $str);
elseif ($smilie_count > 3)
break;
}
}
closedir($dh);
}
}
return $str;
}
function replace($text)
{
$text = trim($text);
$text = strip_tags($text);
$text = stripslashes($text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
$text = str_replace('(www)', '', $text);
$text = preg_replace('/[^[:space:][:alnum:]\@\.\:\,\-\+\!\?\'\_\"\(\)\]\[\=\}\{\%\*\~\#\<\>\^]/', '', $text);
$text = str_replace("\$", "*", $text);
return $text;
}
function nick_replace($text)
{
$text = trim($text);
$text = str_replace(" ", "_", $text);
$text = str_replace("__", "_", $text);
$text = str_replace("--", "-", $text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
$text = preg_replace('/[^[:alnum:]\_\@\-\^]/', '', $text);
return $text;
}
///////////////////////////////////////////////////////////////////////////
// END OF SCRIPT ENJOY!
///////////////////////////////////////////////////////////////////////////
?>
</wml>
/////////////////////////////////////////////////////////////////////////////////////////////////
// //
// GumChat //
// Current Version : 1.19 //
// Author : GUMSLONE //
// You are not allowed to redistribute or modify this script //
// Copyright (c) 2008 GumSlone. All rights reserved. //
// Additional scripts can be found at http://www.coding-talk.com //
// Released on 08 April 2009 //
/////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// CONFIGURATION STARTS HERE
///////////////////////////////////////////////////////////////////////////
//0 means server time
$TimeZone = "0";
// hours* 60 mins* 60secs DONT TOUCH!
$New_Time = time() + ($TimeZone * 60 * 60);
//DONT TOUCH!
$_time = date("H:i", $New_Time);
//chatroom refreshtime
$_refresh = 200;
//means chatroom size of 15 messages
$_room_size = 20;
$home_page_url = "http://2wap.org";
$home_page_title = "2WAP.ORG";
//up to which text message should be smilies visible, from this text messages the smilies will be shown as a text not as an image
$smilies_decode = 5;
$waittime_sec = 5;
/* Set this to a minimum wait time between posts (in sec) */
//DONT TOUCH!
$encoding = "ISO-8859-1";
/////////////[Change language or menu]////////////////////////////////
$lang_user_in_chat = "users in chat";
$lang_enter = "- Enter -";
$lang_nickname = "Your Nickname:";
$lang_gender = "Gender:";
$lang_male = "Male";
$lang_female = "Female";
$lang_age = "Age: ";
$lang_show_smilies = "Show smilies? ";
$lang_yes = "YES";
$lang_no = "NO";
$lang_select_chatroom = "Select Chatroom";
$lang_users = "Users in";
$lang_chatrooms = "Chatrooms";
$lang_smilies = "Smilies";
$lang_next = "Next »";
$lang_prev = "« Prev";
$lang_chat = "Back to Chatroom";
$lang_say = "Say";
$lang_refresh = "Refresh";
$lang_message = "Message:";
$lang_ok = "OK";
$lang_change_chatroom = "Change Chatroom";
$lang_who_is_online = "Who's Inside";
$lang_loading = "Loading...<br/>please wait";
$lang_exit = "Logout";
///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////
/////////////[DO NOT EDIT AFTER THIS LINE]////////////////////////////////
foreach ($_POST as $key => $value) {
${$key} = $value;
}
foreach ($_GET as $key => $value) {
${$key} = $value;
}
$nick = nick_replace($nick);
$nick = substr(trim($nick), 0, 15);
global $nick;
///////////IF Nickname is shorter than 3 chars retur an error message and let the user relogin//////////
if ($nick != '' && strlen($nick) < 3) {
$gum = "";
$login_error_message .= '<i>Nickname is to short, it has to be longer than 3 chars, also avoid special chars in nickname. Allowed chars: A-Z, a-z, 0-9, - _ @</i><br/>';
}
$G = nick_replace(substr(trim($G), 0, 1));
$A = nick_replace(substr(trim($A), 0, 2));
$room = replace($room);
header("Content-type: text/vnd.wap.wml; charset=$encoding");
header("Cache-Control: no-store, no-cache, must-revalidate");
print "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<!-- GumChat by GumSlone Version 1.09 (c) 2008 All rights reserved. -->
<!-- Additional scripts can be found at http://www.coding-talk.com -->
<wml>
<?php
if ($nick && $room) {
$daten = 'online/on' . $room;
$time = time();
$user = explode('/', $_SERVER['HTTP_USER_AGENT']);
$user[0] = ereg_replace(' ', '_', $user[0]);
$ip = (trim($nick) . ' ' . trim($user[0]) . ' ' . trim($G) . ' ' . trim($A));
$ablaufzeit = $time - 250;
$pruefung = @file($daten);
while (list($line_num, $line) = @each($pruefung)) {
$zeiten = explode(":", $line);
if ($zeiten[0] <= $ablaufzeit) {
$fp = fopen($daten, "r");
$contents = fread($fp, filesize($daten));
fclose($fp);
$line = quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh = fopen($daten, "w");
@flock($fp, 2);
fputs($fh, $replace);
@flock($fp, 3);
fclose($fh);
}
}
$ippruefung = @file($daten);
while (list($line_num, $line) = @each($ippruefung)) {
$ips = explode(":", $line);
if ($ips[1] == $ip) {
$fp = fopen($daten, "r");
$contents = fread($fp, filesize($daten));
fclose($fp);
$line = quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh = fopen($daten, "w");
@flock($fp, 2);
fputs($fh, $replace);
@flock($fp, 3);
fclose($fh);
}
}
$fp = fopen($daten, "a+");
flock($fp, 2);
fputs($fp, "$time:$ip:\n");
flock($fp, 3);
fclose($fp);
}
if ($gum == "") {
echo "<card id=\"GumChat\" title=\"GumChat $_time\">";
echo "<p align=\"center\">";
echo "<img src=\"logo.gif\" alt=\"GumChat\"/><br/>";
echo $login_error_message;
$n = 0;
$files = '';
if ($handle = opendir("rooms/")) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'files' && $file != 'cgi-bin' && $file != 'chat') {
if ($n >= 0 && $n < 20) {
$onfile = file("online/on$file");
$counts = count($onfile);
if ($counts < 2) {
$gumdata = explode(":", $onfile[0]);
$ablaufzeit = time() - "250";
if ($gumdata[0] <= $ablaufzeit) {
$fp = fopen("online/on$file", "w+");
$counts = 0;
}
}
$total = $total + $counts;
$n++;
}
}
}
closedir($handle);
}
echo "$total $lang_user_in_chat!<br/>";
echo "$lang_nickname <input name=\"us\" maxlength=\"20\"/><br/>";
echo $lang_gender . '
<select name="g" multiple="false">
<option value="m">' . $lang_male . '</option>
<option value="f">' . $lang_female . '</option>
</select><br/>';
echo "$lang_age<input name=\"a\" maxlength=\"2\" format=\"NN\" size=\"2\"/><br/>";
echo $lang_show_smilies . '
<select name="sm" multiple="false">
<option value="1">' . $lang_yes . '</option>
<option value="0">' . $lang_no . '</option>
</select><br/>';
echo "<anchor title=\"Enter\">$lang_enter";
echo "<go href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&WLC=1\" method=\"post\">";
echo "<postfield name=\"nick\" value=\"\$us\"/>";
echo "<postfield name=\"sm\" value=\"\$sm\"/>";
echo "<postfield name=\"G\" value=\"\$g\"/>";
echo "<postfield name=\"A\" value=\"\$a\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><a href=\"index_xhtml.php\">[xhtml]</a> [wml]<br/><a href=\"$home_page_url\">$home_page_title</a>";
echo "<br/><small>(c) GumSlone 2004-2008<br/>GumChat v 1.9</small></p>";
echo "</card>";
}
if ($gum == "rooms") {
echo "<card id=\"ChatRooms\" title=\"$lang_chatrooms ($_time)\">";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"center\">";
$nick = ereg_replace(" ", "_", $nick);
if (preg_match("/[^\da-zA-Z-@_]+/", $nick) || $nick == "")
$error = 'Not suported chars in Nickname!<br/>';
if (empty($error)) {
if ($WLC)
echo "Welcome to chat $nick<br/>";
echo "$lang_select_chatroom<br/>";
$n = 0;
$files = '';
if ($handle = opendir("rooms/")) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'files' && $file != 'cgi-bin' && $file != 'chat') {
if ($n >= 0 && $n < 20) {
$onfile = file("online/on$file");
$counts = count($onfile);
$total = $total + $counts;
$n++;
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$file\">$file [$counts]</a><br/>";
}
}
}
closedir($handle);
}
} else
echo $error . "<anchor>Back<prev/></anchor><br/>";
echo "<br/>$total $lang_users $n $lang_chatrooms!";
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "\">$lang_exit</a><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "croom") {
$onxfile = @file("online/on$room");
$countonl = count($onxfile);
echo "<card id=\"card0\" title=\"$room in $countonl ($_time)\" ontimer=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\"><timer value=\"$_refresh\"/>";
echo "<do type=\"options\" name=\"say\" label=\"$lang_say\"><go href=\"#Say\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_refresh\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"whowhere\" label=\"$lang_who_is_online\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"changeroom\" label=\"$lang_change_chatroom\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&nick=$nick&sm=$sm&G=$G&A=$A\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"smilies\" label=\"$lang_smilies\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
echo "<a href=\"#Say\">$lang_say</a> ";
echo " <a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\">$lang_refresh</a><br/>";
////////////////////////////////////////
if ($mess != "") {
$mess = replace($mess);
$mess = filterFlood($mess);
$mess = filterBadWords($mess);
$mess = substr($mess, 0, 160);
$_mudata = explode(" ", $mess);
$count_spaces = count($_mudata);
$count_chars = strlen($mess);
if ($count_chars < 4 && !empty($mess)) {
$chat_error_message .= '<i>The message is to short, it has to be longer than 4 chars</i><br/>';
}
$text = "&&$nick $_time&&$mess&&";
if ($count_spaces < 3 && $count_chars > 30)
$FOUND = 1;
if ($count_spaces < 5 && $count_chars > 40)
$FOUND = 1;
}
//////////////////////////////////////////////
if ($mess != "" && !$chat_error_message) {
$udata = explode("&&", $text);
$udata[2] = htmlspecialchars($udata[2]);
$udata[2] = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
$udata[2] = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
if ($sm == 1)
$udata[2] = ReplaceTextToSmilies($udata[2]);
echo '<b>' . htmlspecialchars($udata[1]) . ' »</b> ' . $udata[2] . '<br/>';
} else
echo $chat_error_message;
$fp = fopen('rooms/' . $room, "r");
$smilies_decode_num = 1;
$I = 0;
$mini_found = 1;
while ($radka = fgets($fp, 512)) {
$udata = explode("&&", $radka);
if ($udata[2] != "") {
////////////////////////ANTIFLOOOOOOOOOOOOOOOOOD////////////////////
if (isset($mess)) {
if ($udata[3] == $antiflood) {
$FOUND = 1;
}
if (trim($udata[2]) == trim($mess)) {
$FOUND = 1;
}
if ($FOUND != 1) {
$checktext_1 = preg_replace('/[^[:alnum:]\^]/', '', strtolower($udata[2]));
$checktext_2 = preg_replace('/[^[:alnum:]\^]/', '', strtolower($mess));
$count_checktext_1 = strlen($checktext_1);
$count_checktext_2 = strlen($checktext_2);
$rand_start_1 = rand(1, $count_checktext_1 - 6);
$rand_start_2 = rand(1, $count_checktext_2 - 6);
for ($n = 1; $n <= $count_checktext_1; $n++) {
if (substr($checktext_1, $rand_start_1, 6) == substr($checktext_2, $n, 6)) {
$FOUND = 1;
break;
}
if (substr($checktext_2, $rand_start_2, 6) == substr($checktext_1, $n, 6)) {
$FOUND = 1;
break;
}
}
if ($FOUND != 1) {
for ($n = $count_checktext_1; $n >= 1; $n--) {
if (substr($checktext_1, $rand_start_1, 6) == substr($checktext_2, $n, 6)) {
$FOUND = 1;
break;
}
if (substr($checktext_2, $rand_start_2, 6) == substr($checktext_1, $n, 6)) {
$FOUND = 1;
break;
}
}
}
}
if (substr($udata[1], 0, 2) == substr($nick, 0, 2)) {
if (substr($checktext_1, 0, 2) == substr($checktext_2, 0, 2) && $checktext_1 < 6)
$mini_found++;
elseif (substr($checktext_1, $count_checktext_1 - 2, 2) == substr($checktext_2, $count_checktext_2 - 2, 2) && $count_chars < 6)
$mini_found++;
elseif ($count_checktext_1 == $count_checktext_2)
$mini_found++;
}
$count_mess_chars = strlen($mess);
if (!isset($FOUND) && $count_mess_chars > 30) {
$message_middle = ceil($count_mess_chars / 2);
preg_match_all("/" . substr(strtolower($mess), ($message_middle - 5), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
if (!isset($FOUND)) {
preg_match_all("/" . substr(strtolower($mess), ($message_middle - 7), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
if (!isset($FOUND)) {
preg_match_all("/" . substr(strtolower($mess), ($message_middle + 1), 4) . "/i", strtolower($mess), $treffer);
$matches = count($treffer[0]);
if ($matches > 2)
$FOUND = 1;
}
}
}
}
if ($mini_found > 3)
$FOUND = 1;
/////////////////////////END OF ANTIFLOOD CHECK////////////////////
$udata[2] = htmlspecialchars($udata[2]);
$udata[2] = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
$udata[2] = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '', $udata[2]);
// $udata[2] = filterBadWords($udata[2]);
if ($sm == 1 && $smilies_decode_num <= $smilies_decode)
$udata[2] = ReplaceTextToSmilies($udata[2]);
$smilies_decode_num++;
$udata[1] = ereg_replace("_", " ", $udata[1]);
echo '<b>' . htmlspecialchars($udata[1]) . ' »</b> ' . $udata[2] . '<br/>';
}
}
fclose($fp);
/////////////////////WRITING A TEXT MESSAGE TO the FILE///////////////////////////
if (!$FOUND && $mess != "" && $nick != "" && !$chat_error_message) {
$text = stripslashes($text);
$text = strip_tags($text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
//$text = ereg_replace("_", " ", $text);
if (file_exists("rooms/" . $room)) {
$zpravy = file("rooms/" . $room);
}
$fp = fopen("rooms/" . $room, "w");
fputs($fp, $text . "\n");
for ($i = 0; $i < $_room_size; $i++) {
fputs($fp, $zpravy[$i]);
}
fclose($fp);
}
/////////////////////END OF WRITING A TEXT MESSAGE TO the FILE///////////////////////////
echo "<a href=\"#Say\">$lang_say</a> ";
echo " <a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=";
echo $New_Time;
echo "\">$lang_refresh</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_who_is_online</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=rooms&nick=$nick&sm=$sm&G=$G&A=$A\">$lang_change_chatroom</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_smilies</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "\">$lang_exit</a><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
//////////////////SAY////////////////////////////////////////////////////////////////
echo "<card id=\"Say\" title=\"$lang_say ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"Chatroom\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
echo "$lang_message <input name=\"mess" . $New_Time . "\" maxlength=\"200\"/><br/>";
echo "<anchor title=\"Say\">$lang_say";
echo "<go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\" method=\"post\">";
echo "<postfield name=\"mess\" value=\"\$(mess" . $New_Time . ")\"/>";
echo "</go>";
echo "</anchor>";
//echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><anchor>Back<prev/></anchor><br/>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "smilies") {
echo "<card id=\"Smilies\" title=\"$lang_smilies ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_chat\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
$conf["items_per_page"] = 5;
if (isset($npage))
$page = $npage - 1;
if (!isset($page))
$page = 0;
if ($page < 0)
$page = 0;
$total = 0;
if (!($dp = opendir("./smilies/")))
die("Cannot open ./smilies/");
$file_array = array();
while ($file = readdir($dp)) {
if (substr($file, 0, 1) != '.' and $file != '..' and $file != 'index.php') {
$file_array[] = $file;
}
}
$file_count = count($file_array);
sort($file_array);
if ($file_count > 0) {
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];
while (list($fileIndexValue, $file_name) = each($file_array)) {
if (($fileIndexValue >= $first_record) and ($fileIndexValue < $last_record)) {
$user = explode('.', $file_name);
echo "<img src=\"smilies/$file_name\" alt=\"." . $user[0] . ".\"/> ." . $user[0] . ".<br/>";
}
}
if (($file_count > 0) and ($last_record < $file_count)) {
// next button
$next_page = $page + 1;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&page=$next_page\">$lang_next</a><br/>";
}
if (($file_count > 0) and ($page != 0)) {
// previous button
$prev_page = $page - 1;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&page=$prev_page\">$lang_prev</a><br/>";
}
}
closedir($dp);
echo "<b>$file_count</b> $lang_smilies<br/>";
$pages = ceil($file_count / $conf["items_per_page"]);
echo "Page <b>" . ($page + 1) . "</b> of $pages<br/>";
if ($pages > 2)
echo "Jump to Page: <input emptyok=\"true\" name=\"q\" format=\"*N\" size=\"3\" value=\"\" /><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=smilies&npage=$(q)&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">Jump</a><br/>";
echo "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
if ($gum == "online") {
echo "<card id=\"Online\" title=\"$lang_who_is_online ($_time)\">";
echo "<do type=\"options\" name=\"refresh\" label=\"$lang_chat\"><go href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&r=" . $New_Time . "\" method=\"get\"/></do>";
echo "<do type=\"options\" name=\"2wap\" label=\"2WAP.NET\"><go href=\"http://2wap.net/index.php\" method=\"get\"/></do>";
echo "<p align=\"left\">";
$xfile = @file("online/on$room");
$xfile = array_reverse($xfile);
$p = 25;
if ($npage == "") {
$npage = "1";
}
$countfile = count($xfile);
$first = $countfile - ($p * ($npage - 1));
$second = $countfile - ($p * $npage) + 1;
if ($second < 1) {
$second = 1;
}
$npages = ceil($countfile / $p);
if ($npage <= $npages and $npage > 1)
$gline_rew = "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&npage=" . ($npage - 1) . "\">$lang_prev</a>";
if ($npages > 1 and $npage < $npages)
$gline_next = "<a href=\"" . $_SERVER["PHP_SELF"] . "?gum=online&nick=$nick&sm=$sm&G=$G&A=$A&room=$room&npage=" . ($npage + 1) . "\">$lang_next</a>";
if ($npage == 1)
$nn = 1;
else
$nn = (($npage - 1) * $p) + 1;
for ($i = $first - 1; $i >= $second - 1; $i--) {
$xdata = explode(':', $xfile[$i]);
$udata = explode(' ', $xdata[1]);
if ($udata[2] == m)
$gender = $lang_male;
if ($udata[2] == f)
$gender = $lang_female;
echo $nn++ . ". <small><b>$udata[0]</b> $gender ($udata[3]) $udata[1]</small><br/>";
}
print "<br/>";
if ($npages > 1)
print $gline_rew . "| " . $gline_next;
echo "<br/><a href=\"" . $_SERVER["PHP_SELF"] . "?gum=croom&nick=$nick&sm=$sm&G=$G&A=$A&room=$room\">$lang_chat</a>";
echo "<br/><small>(c) GumSlone 2004-2008</small></p>";
echo "</card>";
}
function filterBadWords($str)
{
// words to filter, you can add here some more
// replace filtered words with
$badwords = array("2-wap", "htp", " dot ", "http", "\.biz", "\.mobi", "\.net", "\.ru", "\.c0m", "\.org", "\.wen", "\.com", "\.web.tr", "dhoomworld", "Chatworld", "Mobichat", "Desiclub", "Friendsgarage", "Friendsgarage", "Loverslane", "Mixit", "Mxit", "Prodigits", "Leeinc", "Eaglesnest", "Wap2chat", "Bdsaint", "Hitler", "Nazi", "Chod", "Wichser");
$replacements = array("???", "***");
for ($i = 0; $i < sizeof($badwords); $i++) {
srand((double)microtime() * 1000000);
$rand_key = (rand() % sizeof($replacements));
$str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
function filterFlood($str)
{
// words to filter, you can add here some more
$text = str_replace('~~', '', $text);
$text = str_replace('@@', '', $text);
$text = str_replace('-', ' - ', $text);
$text = str_replace('___', '_', $text);
$text = str_replace('__', '_', $text);
$text = str_replace(" . ..", " .", $text);
$text = str_replace(".. . ", ". ", $text);
$text = str_replace(" . . ", " ", $text);
$text = str_replace(" . ", " ", $text);
$text = str_replace("...", "..", $text);
$text = str_replace(" ", " ", $text);
$text = str_replace(" ", " ", $text);
$text = str_replace('??', "", $text);
$text = str_replace('**', "", $text);
$text = str_replace('* *', "", $text);
$text = str_replace('? ?', "", $text);
//[:punct:]
$text = str_replace("\\", "", $text);
// replace filtered words with
$badwords = array("gmg", "tpt", "gjg", "gwg", "pdp", "www", "wvw", "gaga", "tjt", "mjm", "wpw", "@@", "kmk", "momo", "mwm", "mvm", "gmg");
$replacements = array("");
for ($i = 0; $i < sizeof($badwords); $i++) {
srand((double)microtime() * 1000000);
$rand_key = (rand() % sizeof($replacements));
$str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
}
return $str;
}
function ReplaceTextToSmilies($str)
{
$dir = "smilies/";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
$smilie_count = 0;
while (($file = readdir($dh)) !== false) {
$smilie = explode(".", $file);
if ($file != '.' && $file != '..') {
if (preg_match("/\." . $smilie[0] . "\./i", $str))
$smilie_count++;
if ($smilie_count < 4)
$str = preg_replace('(\.' . $smilie[0] . '\.)', '<img src="' . $dir . $file . '" alt="' . $smilie[0] . '" />', $str, 1);
//$str = str_replace('.'.$smilie[0].'.', '<img src="'.$dir.$file.'" alt="'.$smilie[0].'" />', $str);
elseif ($smilie_count > 3)
break;
}
}
closedir($dh);
}
}
return $str;
}
function replace($text)
{
$text = trim($text);
$text = strip_tags($text);
$text = stripslashes($text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
$text = str_replace('(www)', '', $text);
$text = preg_replace('/[^[:space:][:alnum:]\@\.\:\,\-\+\!\?\'\_\"\(\)\]\[\=\}\{\%\*\~\#\<\>\^]/', '', $text);
$text = str_replace("\$", "*", $text);
return $text;
}
function nick_replace($text)
{
$text = trim($text);
$text = str_replace(" ", "_", $text);
$text = str_replace("__", "_", $text);
$text = str_replace("--", "-", $text);
$text = preg_replace("(\r\n|\n|\r)", "", $text);
$text = preg_replace('/[^[:alnum:]\_\@\-\^]/', '', $text);
return $text;
}
///////////////////////////////////////////////////////////////////////////
// END OF SCRIPT ENJOY!
///////////////////////////////////////////////////////////////////////////
?>
</wml>
En dan gaat het met name hier om:
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<select name="g" multiple="false">
<option value="m">'.$lang_male.'</option>
<option value="f">'.$lang_female.'</option>
</select><br/>';
echo"$lang_age<input name=\"a\" maxlength=\"2\" format=\"NN\" size=\"2\"/><br/>";
echo $lang_show_smilies.'
<select name="sm" multiple="false">
<option value="1">'.$lang_yes.'</option>
<option value="0">'.$lang_no.'</option>
</select><br/>';
<option value="m">'.$lang_male.'</option>
<option value="f">'.$lang_female.'</option>
</select><br/>';
echo"$lang_age<input name=\"a\" maxlength=\"2\" format=\"NN\" size=\"2\"/><br/>";
echo $lang_show_smilies.'
<select name="sm" multiple="false">
<option value="1">'.$lang_yes.'</option>
<option value="0">'.$lang_no.'</option>
</select><br/>';
Alvast bedankt!
Gewijzigd op 06/11/2011 18:34:43 door Misha Onbekend
Bij mij op de HTC Desire S gaat het fout, ik kan het veld dan niet aanklikken..
Emoticons weergeven? [ ]
O man
O vrouw
En hoe zou ik dit moeten doen? Ik probeer nu namelijk wel van alles maar het lukt allemaal niet.. Ik ben niet echt goed met PHP functies..
Dit heeft meer met opmaak en HTML te maken dan met PHP?
Dat kan wel zo zijn, maar dan snap ik er alsnog weinig van..
vervang de code
Code (php)
1
2
3
2
3
<select name="sm" multiple="false">
<option value="1">'.$lang_yes.'</option>
<option value="0">'.$lang_no.'</option>
<option value="1">'.$lang_yes.'</option>
<option value="0">'.$lang_no.'</option>
in
Code (php)
1
2
2
<INPUT TYPE="radio" NAME="sm" VALUE="1">'.$lang_yes.'
<INPUT TYPE="radio" NAME="sm" VALUE="0">'.$lang_no.'
<INPUT TYPE="radio" NAME="sm" VALUE="0">'.$lang_no.'
ps. ben niet zeker of het werkt ( niet getest en maar eens snel gemaakt )
En is het niet eens tijd om HTML te leren, als je dit nog niet begrijpt.
Op mijn Nokia C3 werkt het gewoon...
Gewijzigd op 06/11/2011 22:38:30 door Wouter J
Wouter J op 06/11/2011 22:13:28:
@php knipper, HTML schrijf je altijd met hoofdletters. In XHTML en HTML5 is dit zelf verplicht.
Ik weet niet hoe je erop komt, maar dat is uiteraard onzin.
Wouter J op 06/11/2011 22:13:28:
@php knipper, HTML schrijf je altijd met hoofdletters. In XHTML en HTML5 is dit zelf verplicht.
Klopt niks van?
Edit:
Zag dat Eddy bisschops al het goede antwoord heeft gegeven.
Gewijzigd op 06/11/2011 22:25:03 door Victor -
Type foutje.... Ik bedoel kleine letters.
Wouter J op 06/11/2011 22:38:03:
Slik...
Type foutje.... Ik bedoel kleine letters.
Type foutje.... Ik bedoel kleine letters.
Haha, dan klopt het.. in HTML5 mogen inderdaad geen hoofdletters gebruikt worden.