/
functions-msg.php
3620 lines (3217 loc) · 171 KB
/
functions-msg.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
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
// Funktionen, die NUR von interaktiv.php verwendet werden.
require_once("functions.php-func-verlasse_chat.php");
require_once("functions.php-func-nachricht.php");
require_once("functions.php-func-html_parse.php");
require_once("functions.php-func-raum_gehe.php");
if ($communityfeatures) {
require_once("functions.php-func-sms.php");
require_once("functions.php-freunde.php");
}
function chat_msg($o_id, $u_id, $u_name, $u_farbe, $admin, $r_id, $text, $typ)
{
// Schreibt Text in Raum r_id
// User, u_id, Farbe, Raum und Typ der Nachricht werden übergeben
// Vor Schreiben wird der Text geparsed und die Aktionen ausgeführt
// Art: N: Normal
// S: Systemnachricht
// P: Privatnachticht
// H: Versteckte Nachricht
// $raum_einstellungen und $ist_moderiert wurde von raum_ist_moderiert() gesetzt
global $mainchat_version, $akdbase, $conn, $dbase, $user_farbe, $hilfstext, $system_farbe, $moderationsmodul;
global $chat, $timeout, $chat_url, $datei_spruchliste, $t, $id, $ak, $check_name, $f1, $f2, $raumstatus1;
global $u_farbe_alle, $u_farbe_sys, $u_farbe_priv, $u_farbe_noise, $u_farbe_bg, $u_clearedit, $raum_max;
global $u_nick, $id, $http_host, $lobby, $o_raum, $o_js, $o_knebel, $r_status1, $u_level, $leveltext, $max_user_liste;
global $communityfeatures, $o_punkte, $beichtstuhl, $raum_einstellungen, $ist_moderiert, $ist_eingang, $userdata, $lustigefeatures;
global $punkte_ab_user, $punktefeatures, $whotext, $knebelzeit, $nickwechsel, $raumanlegenpunkte, $o_dicecheck;
global $einstellungen_aendern, $single_room_verhalten, $eingabe_light_farbe, $eingabe_light_hilfe;
// Text $text parsen, Befehle ausführen, Texte im Chat ausgeben
// Voreinstellung für Nachrichtenfilter
$privat = FALSE;
// N als Voreinstellung setzen
$typ OR $typ = "N";
// Farbe voreinstellen
$u_farbe OR $u_farbe = $user_farbe;
// Verbotene Zeichen filtern
$text = preg_replace("/[" . chr(1) . "-" . chr(31) . "]/", "", $text);
$text = str_replace(chr(173), "", $text);
// autoknebel - ist text unerwünscht? Falls ja, User automatisch knebeln
$text = auto_knebel($text);
// Eingabe parsen
$chatzeile = explode(" ", $text, 4);
if (!isset($chatzeile[1]))
$chatzeile[1] = "";
if (!isset($chatzeile[2]))
$chatzeile[2] = "";
if (!isset($chatzeile[3]))
$chatzeile[3] = "";
switch (strtolower($chatzeile[0])) {
case "/besitze":
case "/besitzeraum":
// Übernimmt Besitzrechte eines Raums
if (!$admin) {
system_msg("", 0, $u_id, $system_farbe,
"<B>He $u_name!</B> "
. str_replace("%chatzeile%", $chatzeile[0],
$t['chat_msg1']));
} else {
$query = "SELECT r_id,o_name,r_name FROM raum,online "
. "WHERE r_besitzer=o_user AND "
. ($chatzeile[1] ? "r_name LIKE '" . mysql_real_escape_string($chatzeile[1]) . "'"
: "r_id=$r_id");
$result = mysql_query($query, $conn);
$rows = mysql_num_rows($result);
if ($rows == 0) {
// nix gefunden. Besitzer evtl. nicht mehr existent?
// neue query ohne r_besitzer
$keinbesitzer = 1;
$query = "SELECT r_id,r_name FROM raum WHERE "
. ($chatzeile[1] ? "r_name LIKE '" . mysql_real_escape_string($chatzeile[1]) . "'"
: "r_id=$r_id");
$result = mysql_query($query, $conn);
$rows = mysql_num_rows($result);
}
if ($rows == 1) {
if (!$keinbesitzer) {
$uu_name = mysql_result($result, 0, "o_name");
} else {
$uu_name = "Nobody";
}
$rr_id = mysql_result($result, 0, "r_id");
$rr_name = mysql_result($result, 0, "r_name");
// Raum ändern
$f['r_besitzer'] = $u_id;
schreibe_db("raum", $f, $r_id, "r_id");
system_msg("", 0, $u_id, $system_farbe,
str_replace("%rr_name%", $rr_name,
str_replace("%uu_name%", $uu_name,
str_replace("%u_name%", $u_name,
$t['chat_msg2']))));
} else {
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg3']);
}
}
break;
case "/oplist":
// Admins auflisten
if ($admin || $u_level == "A") {
$query = "SELECT o_userdata,o_userdata2,o_userdata3,o_userdata4,o_level,r_name, "
. "UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_login) AS online "
. "FROM online left join raum on r_id=o_raum "
. "WHERE (o_level='S' OR o_level='C' OR o_level='A') "
. "ORDER BY r_name";
$result = mysql_query($query, $conn);
if ($result AND mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_object($result)) {
$userdaten = unserialize(
$row->o_userdata . $row->o_userdata2
. $row->o_userdata3 . $row->o_userdata4);
$txt = "";
if ($row->r_name && $row->r_name != "NULL") {
$raumname = $row->r_name;
} else {
$raumname = "[" . $whotext[2] . "]";
}
if (!$userdaten[u_away]) {
$txt .= "<B>" . $raumname . ":</B> "
. user($userdaten[u_id], $userdaten, TRUE,
TRUE, " ", $row->online, "", FALSE);
} else {
$txt .= $raumname . ": "
. user($userdaten[u_id], $userdaten, TRUE,
FALSE, " ", "", "", FALSE) . " -> "
. $userdaten[u_away];
}
system_msg("", 0, $u_id, $system_farbe, $txt);
}
mysql_free_result($result);
}
}
break;
case "/op":
// Nachrichten zwischen den Admins austauschen
case "/int":
// Admin um Hilfe rufen.
if ($u_level == "G") {
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg55']);
} else {
if ($o_knebel > 0) {
// user ist geknebelt...
$zeit = gmdate("H:i:s", $o_knebel);
$txt = str_replace("%zeit%", $zeit, $t['knebel6']);
system_msg("", 0, $u_id, $system_farbe, $txt);
break;
}
// Smilies parsen
$privat = TRUE;
$query = "SELECT r_name FROM raum WHERE r_id=$o_raum";
$result = mysql_query($query, $conn);
$r_name = mysql_result($result, 0, "r_name");
$tempadm = "";
if (strtolower($chatzeile[0] != "/int"))
$tempadm = " OR o_level='A'";
$query = "SELECT o_user FROM online WHERE (o_level='S' OR o_level='C'$tempadm)";
$result = mysql_query($query, $conn);
if ($result > 0) {
$nums = mysql_num_rows($result);
if ($nums > 0) {
// die Nachricht wurde weitergeleitet.
$txt = html_parse($privat,
htmlspecialchars(
$chatzeile[1] . " " . $chatzeile[2] . " "
. $chatzeile[3]));
if (!($admin || $u_level == "A")) {
// Admins wissen, daß das an alle Admins geht. daher nicht nötig.
system_msg("", 0, $u_id, $system_farbe,
$t['chat_msg47']);
$txt = "<b>" . $txt . "</b>";
}
if (strtolower($chatzeile[0]) == "/int") {
$txt2 = "<b>[=====$t[chat_msg52] "
. $t['chat_msg51'] . "=====]</b> " . $txt;
} else {
$txt2 = "<b>[" . $t['chat_msg52'] . " "
. $t['chat_msg50'] . "]</b> " . $txt;
}
while ($row = mysql_fetch_array($result)) {
$text = str_replace("%user%",
user($u_id, $userdata, TRUE, FALSE, " ",
"", "", FALSE), $t['chat_msg49']);
$text = str_replace("%raum%", $r_name, $text);
if (!($admin || $u_level == "A")) {
// User aus Raum... ruft um hilfe
system_msg("", $u_id, $row['o_user'],
$system_farbe, $text);
}
if (($admin || $u_level == "A")
&& $row['o_user'] == $u_id) {
// falls eigener nick:
if (strtolower($chatzeile[0]) == "/int") {
system_msg("", $u_id, $u_id, $system_farbe,
"<B>"
. user($u_id, $userdata, TRUE,
FALSE, " ", "", "", FALSE)
. " ===== $t[chat_msg24] $t[chat_msg51]: =====</B> $txt");
} else {
system_msg("", $u_id, $u_id, $system_farbe,
"<B>"
. user($u_id, $userdata, TRUE,
FALSE, " ", "", "", FALSE)
. " $t[chat_msg24] $t[chat_msg50]: </B> $txt");
}
} else {
priv_msg($u_name, $u_id, $row['o_user'],
$u_farbe, $txt2, $userdata);
}
}
} else {
// kein Admin im Chat :-(
system_msg("", $u_id, $u_id, $system_farbe,
$t['chat_msg48']);
}
mysql_free_result($result);
}
}
break;
case "/dupes":
// sucht nach doppelten IPs
if ($admin) {
$query = "SELECT o_ip,o_user,o_raum,o_browser,r_name,o_name "
. "FROM online left join raum on o_raum=r_id "
. "WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= $timeout "
. "ORDER BY o_ip";
$result = mysql_query($query, $conn);
if ($result > 0) {
while ($row = mysql_fetch_array($result)) {
if ($row['o_ip'] == $alt['o_ip']) {
$hostname = htmlspecialchars(
@gethostbyaddr($row['o_ip']));
if (!$shown) {
$dupecount++;
unset($userdaten);
$userdaten = ARRAY(u_id => $alt[o_user],
u_nick => $alt[o_name]);
$txt = "<BR><b>" . $hostname . "("
. $alt['o_ip'] . "):</b>";
$txt .= "<br><b>" . $alt['r_name'] . " "
. user($alt[o_user], $userdaten, $o_js,
FALSE, " ", "", "", FALSE)
. "</b> "
. htmlspecialchars($alt[o_browser])
. "<br>";
$shown = true;
}
unset($userdaten);
$userdaten = ARRAY(u_id => $row[o_user],
u_nick => $row[o_name]);
$txt .= "<b>" . $row['r_name'] . " "
. user($row[o_user], $userdaten, $o_js, FALSE,
" ", "", "", FALSE) . "</b> "
. htmlspecialchars($row[o_browser]);
system_msg("", 0, $u_id, $system_farbe, $txt);
$txt = "";
} else {
$shown = false;
}
$alt = $row;
}
if ($dupecount > 0) {
system_msg("", 0, $u_id, $system_farbe,
"<BR>\n" . $t['chat_msg45']);
} else {
system_msg("", 0, $u_id, $system_farbe,
$t['chat_msg46']);
}
}
}
break;
case "/pp":
case "/ip":
if (!$admin) {
system_msg("", 0, $u_id, $system_farbe,
"<B>He $u_name!</B> "
. str_replace("%chatzeile%", $chatzeile[0],
$t['chat_msg1']));
break;
}
unset($onlineip);
unset($onlinedatum);
if (!$chatzeile[1]) {
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg119']);
break;
}
if ($admin
&& preg_match(
"/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/",
$chatzeile[1])) {
$onlineip = $chatzeile[1];
} else if ($admin) {
$nick = nick_ergaenze($chatzeile[1], "online", 1);
if ($nick['u_nick'] != "") {
$query = "SELECT o_ip FROM online WHERE o_user = $nick[u_id]";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$o_nick = mysql_fetch_array($result);
$onlineip = $o_nick[o_ip];
unset($o_nick);
}
@mysql_free_result($result);
} else {
system_msg("", 0, $u_id, $system_farbe,
str_replace("%u_name%", $chatzeile[1],
$t['chat_msg120']));
// Nick nich Online - Hole IP aus History der Usertabelle
$query = "SELECT u_nick,u_id,u_ip_historie FROM user "
. "WHERE u_nick='"
. mysql_real_escape_string(coreCheckName($chatzeile[1], $check_name)) . "'";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$nick = mysql_fetch_array($result);
$uu_ip_historie = unserialize($nick['u_ip_historie']);
if (is_array($uu_ip_historie)) {
while (list($onlinedatum, $onlineip) = each(
$uu_ip_historie)) :
break;
endwhile;
$temp = $t['chat_msg123'];
$temp = str_replace("%datum%",
date("d.m.y H:i", $onlinedatum), $temp);
$temp = str_replace("%ip%", $onlineip, $temp);
system_msg("", 0, $u_id, $system_farbe, $temp);
}
}
@mysql_free_result($result);
}
}
if ($admin && $onlineip) {
$temp = $t['chat_msg122'];
$temp = str_replace("%datum%", strftime('%d.%m.%Y'), $temp);
$temp = str_replace("%uhrzeit%", strftime('%H:%M:%S'), $temp);
$temp = str_replace("%ip%", $onlineip, $temp);
system_msg("", 0, $u_id, $system_farbe, $temp);
$query = "SELECT o_ip,o_user,o_raum,o_browser,r_name,o_name "
. "FROM online left join raum on o_raum=r_id "
. "WHERE (UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(o_aktiv)) <= $timeout "
. "AND o_ip = '" . mysql_real_escape_string($onlineip) . "' " . "ORDER BY o_user";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) >= 1) {
$txt = "";
while ($row = mysql_fetch_array($result)) {
$userdaten = ARRAY(u_id => $row[o_user],
u_nick => $row[o_name]);
$txt .= "<b>" . $row['r_name'] . " "
. user($row[o_user], $userdaten, $o_js, FALSE,
" ", "", "", FALSE) . "</b> "
. htmlspecialchars($row[o_browser]) . "<br>";
}
system_msg("", 0, $u_id, $system_farbe, $txt);
} else {
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg121']);
}
@mysql_free_result($result);
}
break;
case "/edithistory":
case "/edithistorie":
if ($admin) {
$nick = nick_ergaenze($chatzeile[1], "online", 1);
// Falls keinen Empfänger gefunden, in Usertabelle nachsehen
if ($nick['u_nick'] == "") {
$query = "SELECT u_nick,u_id from user WHERE u_nick='"
. mysql_real_escape_string(coreCheckName($chatzeile[1], $check_name)) . "'";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$nick = mysql_fetch_array($result);
}
@mysql_free_result($result);
}
if ($nick['u_nick'] != "") {
$query = "SELECT u_profil_historie FROM user WHERE u_nick = '$nick[u_nick]'";
$result = mysql_query($query);
$bla = mysql_fetch_array($result);
$uu_profil_historie = unserialize($bla[u_profil_historie]);
} else {
system_msg("", 0, $u_id, $system_farbe,
"Es konnte kein eindeutiger Nick gefunden werden!");
}
if (is_array($uu_profil_historie)) {
system_msg("", 0, $u_id, $system_farbe,
"Das Profil von <b>$nick[u_nick]</b> wurde zuletzt geändert von: ");
while (list($datum, $nick) = each($uu_profil_historie)) :
$zeile = $nick . " ("
. str_replace(" ", " ",
date("d.m.y H:i", $datum)) . ")" . $f4;
system_msg("", 0, $u_id, $system_farbe, $zeile);
endwhile;
}
} else {
system_msg("", 0, $u_id, $system_farbe,
"<B>He $u_name!</B> "
. str_replace("%chatzeile%", $chatzeile[0],
$t['chat_msg1']));
}
break;
case "/knebel":
case "/gag":
case "/gaga":
// /gag - zeige alle geknebelten user
// /gag user - sperre user für 5 min
// /gag user x - sperre user für x min
// /gag user 0 - freigabe...
if (!$admin AND $u_level != "A") {
system_msg("", 0, $u_id, $system_farbe,
"<B>He $u_name!</B> "
. str_replace("%chatzeile%", $chatzeile[0],
$t['chat_msg1']));
break;
}
if (!isset($chatzeile[1]) || $chatzeile[1] == "") {
// Kurzhilfe ausgeben.
$temp = $t['knebel2'];
$temp = str_replace("%chatzeile%", $chatzeile[0], $temp);
system_msg("", 0, $u_id, $system_farbe, "<b>$chat</b>: $temp");
} else {
// knebel setzen, default=5 min...
if (!$knebelzeit)
$knebelzeit = 5;
// knebelzeit übergeben? dann setzen, absolut, vorzeichen ignorieren
if (isset($chatzeile[2]) && $chatzeile[2] != "")
$knebelzeit = abs(intval($chatzeile[2]));
// maximal 1440 Minuten
if ($knebelzeit > 1440)
$knebelzeit = 1440;
// User finden, zuerst im aktuellen Raum, dann global
$nick = nick_ergaenze($chatzeile[1], "raum", 1);
if (!$nick['u_nick'])
$nick = nick_ergaenze($chatzeile[1], "online", 0);
// Admins dürfen,
if ($nick['u_nick'])
switch ($nick['u_level']) {
case "C":
case "S":
case "M":
case "A":
$txt = str_replace("%admin%", $nick['u_nick'],
$t['knebel5']);
system_msg("", 0, $u_id, $system_farbe, $txt);
break;
default:
$query = "update online set o_knebel=FROM_UNIXTIME(UNIX_TIMESTAMP(NOW())+" . intval($knebelzeit) . "*60) "
. "where o_user=$nick[u_id]";
mysql_query($query, $conn);
$txt = ($knebelzeit ? $t['knebel4'] : $t['knebel3']);
$txt = str_replace("%admin%", $u_nick, $txt);
$txt = str_replace("%user%", $nick['u_nick'], $txt);
$txt = str_replace("%zeit%", $knebelzeit, $txt);
global_msg($u_id, $o_raum, $txt);
}
}
// knebel listen
if ($chatzeile[0] == "/gaga" && $admin) {
$query = "select o_id,o_raum,o_user,o_userdata,o_userdata2,o_userdata3,o_userdata4,"
. "UNIX_TIMESTAMP(o_knebel)-UNIX_TIMESTAMP(NOW()) as knebel from online "
. "where o_knebel>NOW()";
} else {
$query = "select o_id,o_raum,o_user,o_userdata,o_userdata2,o_userdata3,o_userdata4,"
. "UNIX_TIMESTAMP(o_knebel)-UNIX_TIMESTAMP(NOW()) as knebel from online "
. "where o_raum=$o_raum AND o_knebel>NOW()";
}
$result = mysql_query($query, $conn);
$txt = "";
if ($result > 0) {
$rows = mysql_num_rows($result);
for ($i = 0; $i < $rows; $i++) {
$row = mysql_fetch_object($result);
if ($txt != "")
$txt .= ", ";
$userdaten = unserialize(
$row->o_userdata . $row->o_userdata2
. $row->o_userdata3 . $row->o_userdata4);
$txt .= user($row->o_user, $userdaten, TRUE, FALSE,
" ", "", "", FALSE) . " "
. gmdate("H:i:s", $row->knebel);
}
mysql_free_result($result);
} else {
system_msg("", 0, $u_id, $system_farbe,
"Fehler beim Zugriff auf die Datenbank. <!--"
. mysql_errno() . " " . mysql_error() . "-->");
}
if ($txt != "")
system_msg("", 0, $u_id, $system_farbe,
"<b>$chat</b>:$t[knebel1]: " . $txt);
break;
case "/einlad":
case "/invite":
// Einladen in Räume... darf nur Admin oder Raumbesitzer
// Raum ermitteln
$raum_id = $r_id;
if ($chatzeile[2] != "") {
$query = "SELECT r_id from raum WHERE r_name LIKE '" . mysql_real_escape_string($chatzeile[2]) . "%'";
$result = mysql_query($query, $conn);
if ($result AND mysql_num_rows($result) > 0) {
$row = mysql_fetch_object($result);
$raum_id = $row->r_id;
mysql_free_result($result);
} else {
// Raum nicht gefunden -> Fehlermeldung
$txt = str_replace("%raumname%", $chatzeile[1],
$t['chat_msg53']);
system_msg("", $u_id, $u_id, $system_farbe, $txt);
break;
}
}
// Besitzer des Raums ermitteln
$query = "SELECT r_besitzer,r_name from raum WHERE r_id=$raum_id ";
$result = mysql_query($query, $conn);
if ($result > 0) {
$rows = mysql_num_rows($result);
if ($rows == 1) {
$r_besitzer = mysql_result($result, 0, "r_besitzer");
$r_name = mysql_result($result, 0, "r_name");
}
mysql_free_result($result);
}
if ($admin || $r_besitzer == $u_id) {
if ($chatzeile[1] != "") {
// user eintragen oder löschen
// schaue zuerst, ob online ein User ist, der genauso heisst wie angegeben
$nick = nick_ergaenze($chatzeile[1], "online", 1);
if ($nick['u_nick'] == $chatzeile[1]) {
} else {
$nick['u_nick'] == "";
}
if ($nick['u_nick'] == "")
$nick = nick_ergaenze($chatzeile[1], "raum", 1);
if ($nick['u_nick'] == "")
$nick = nick_ergaenze($chatzeile[1], "online", 1);
if ($nick['u_nick'] == "")
$nick = nick_ergaenze($chatzeile[1], "chat", 0);
if ($nick['u_nick'] != "") {
// nick gefunden. jetzt eintragen oder löschen...
$query = "SELECT inv_user FROM invite WHERE inv_raum=$raum_id AND inv_user=$nick[u_id]";
$result = mysql_query($query, $conn);
if ($result > 0) {
if (mysql_num_rows($result) > 0) {
$query = "DELETE FROM invite WHERE inv_raum=$raum_id AND inv_user=$nick[u_id]";
$result2 = mysql_query($query, $conn);
$msg = $t['invite4'];
} else {
$f['inv_id'] = 0;
$f['inv_user'] = $nick['u_id'];
$f['inv_raum'] = $raum_id;
schreibe_db("invite", $f, $f['inv_id'],
"inv_id");
if (!$beichtstuhl) {
$msg = str_replace("%admin%", $u_nick,
$t['invite5']);
} else {
$msg = str_replace("%admin%", $u_nick,
$t['invite6']);
}
;
$msg = str_replace("%raum%", $r_name, $msg);
system_msg($u_nick, $u_id, $nick['u_id'],
$system_farbe, $msg);
$msg = $t['invite3'];
}
// altes result löschen.
mysql_free_result($result);
$msg = str_replace("%admin%", $u_nick, $msg);
$msg = str_replace("%raum%", $r_name, $msg);
$msg = str_replace("%user%", $nick['u_nick'], $msg);
global_msg($u_id, $o_raum, "$msg");
}
} else {
// Nick nicht gefunden, d.h. nicht Online, aber vielleicht doch eingeladen zum runterwerfen?
$query = "SELECT u_nick,u_id from user,invite "
. "WHERE inv_raum=$raum_id AND inv_user=u_id AND u_nick='" . mysql_real_escape_string($chatzeile[1]) . "'"
. "ORDER BY u_nick";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$row = mysql_fetch_object($result);
$query2 = "DELETE FROM invite WHERE inv_raum=$raum_id AND inv_user=$row->u_id";
$result2 = mysql_query($query2, $conn);
$msg = $t['invite4'];
$msg = str_replace("%admin%", $u_nick, $msg);
$msg = str_replace("%raum%", $r_name, $msg);
$msg = str_replace("%user%", $row->u_nick, $msg);
global_msg($u_id, $o_raum, "$msg");
@mysql_free_result($result2);
}
@mysql_free_result($result);
}
}
// Invite-Liste ausgeben...
$query = "SELECT u_id,u_nick,u_level,u_punkte_gesamt,u_punkte_gruppe,inv_id "
. "FROM invite LEFT JOIN user ON u_id=inv_user "
. "WHERE inv_raum=$raum_id";
$result = mysql_query($query, $conn);
$txt = "";
if ($result && mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_object($result)) {
if ($row->u_id && $row->u_id != "NULL") {
if ($txt != "")
$txt .= ", ";
$txt .= user($row->u_id, $row, TRUE, FALSE,
" ", "", "", FALSE);
} else {
$query = "DELETE FROM invite WHERE inv_id=$row->inv_id";
$result2 = mysql_query($query, $conn);
}
}
}
if ($txt == "")
$txt = $t['invite2'];
else $txt = $t['invite1'] . " " . $txt;
system_msg("", 0, $u_id, $system_farbe, "<b>$chat:</b> $txt");
}
break;
case "/such":
case "/suche":
// Gibt Spruchliste aus
if (!isset($chatzeile[1]))
$chatzeile[1] = "";
$suchtext = preg_replace("/[*%$!?.,;:\\/]/i", "", $chatzeile[1]);
if (strlen($suchtext) > 2) :
// Sprüche in Array lesen
$spruchliste = file("conf/$datei_spruchliste");
// Treffer ausgeben
reset($spruchliste);
$anzahl = count($spruchliste);
$i = 0;
while ($i < $anzahl) :
$spname = key($spruchliste);
if (preg_match("/" . $suchtext . "/i",
$spruchliste[$spname])) :
$spruchtmp = preg_split("/\t/",
substr($spruchliste[$spname], 0,
strlen($spruchliste[$spname]) - 1), 3);
$spruchtmp[2] = str_replace("<", "<", $spruchtmp[2]);
$spruchtmp[2] = str_replace(">", ">", $spruchtmp[2]);
$spruchtmp[2] = preg_replace('|\*(.*?)\*|',
'<i>\1</i>',
preg_replace('|_(.*?)_|', '<b>\1</b>',
$spruchtmp[2]));
$txt = "<B>$t[chat_msg4] <I>" . $spruchtmp[0] . " "
. $spruchtmp[1] . "</I></B> <" . $spruchtmp[2]
. ">";
system_msg("", 0, $u_id, $system_farbe, $txt);
endif;
next($spruchliste);
$i++;
endwhile;
else :
// Fehler ausgeben
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg5']);
endif;
break;
case "/ende":
case "/exit":
case "/quit":
case "/bye":
// Ende-Nachricht absetzen?
if (strlen($chatzeile[1]) > 0) :
hidden_msg($u_name, $u_id, $u_farbe, $r_id,
$u_name . "$t[chat_msg6] "
. html_parse($privat,
htmlspecialchars(
$chatzeile[1] . " " . $chatzeile[2] . " "
. $chatzeile[3])));
endif;
// Logoff
verlasse_chat($u_id, $u_name, $r_id);
sleep(2);
logout($o_id, $u_id, "/quit");
echo "<HTML><BODY onLoad='javascript:parent.location.href=\"index.php?http_host=$http_host\";'>\n";
echo "</BODY></HTML>\n";
exit;
break;
case "/ig":
case "/ignore":
case "/ignoriere":
// User ignorieren oder freigeben
if (!$beichtstuhl && strlen($chatzeile[1]) > 0 && $u_level != "G") {
// Username angegeben -> ignorieren oder aufheben
// versuchen, den namen zu ergänzen.
// wenn geschafft, dann ist User auch online. Somit kann er ignoriert werden.
// sonst evtl. DB Probs weil der expire evtl. user löscht, die hier gerade
// eingetragen werden.
$nick = nick_ergaenze($chatzeile[1], "online", 0);
if ($nick['u_nick'] != "") {
$i_user_passiv = $nick['u_id'];
$i_user_name_passiv = $nick['u_nick'];
// testen, ob nicht DAU sich selbst ignoriert...
if ($i_user_passiv != $u_id) {
ignore($o_id, $u_id, $u_name, $i_user_passiv,
$i_user_name_passiv);
} else {
system_msg("", 0, $u_id, $u_farbe, $t['chat_msg7']);
}
} else {
// user nicht gefunden oder nicht online? dann testen, ob ignoriert, damit man das
// ignore auch wieder raus bekommt.
$query = "SELECT u_nick,u_id from user,iignore "
. "WHERE i_user_aktiv=$u_id AND i_user_passiv=u_id AND u_nick='" . mysql_real_escape_string($chatzeile[1]) . "'"
. "ORDER BY u_nick";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) == 1) {
$row = mysql_fetch_object($result);
ignore($o_id, $u_id, $u_name, $row->u_id, $row->u_nick);
}
@mysql_free_result($result);
}
}
// Prüfung sollte nach dem Einfügen sein, denn sonst können 17 User drauf sein
// Prüfung, ob bereits mehr als 16 user ignoriert werden
// Alle ignorierten user > 16 werden gelöscht
// Wenn mehr als 16 gebraucht werden, grössere Änderung in Tabelle online Feld o_ignore
// Denn da passt nur ein Array mit 255 chars rein.
$query = "SELECT u_nick,u_id from user,iignore "
. "WHERE i_user_aktiv=$u_id AND u_id=i_user_passiv order by i_id";
$result = @mysql_query($query, $conn);
$anzahl = @mysql_num_rows($result) - 16;
if ($result && $anzahl > 0) {
for ($i = 0; $i < $anzahl; $i++) {
$row = @mysql_fetch_object($result);
ignore($o_id, $u_id, $u_name, $row->u_id, $row->u_nick);
}
}
@mysql_free_result($result);
if ($u_level == "G") {
system_msg("", 0, $u_id, $system_farbe, $t['chat_msg55']);
} else {
// Liste der User ausgeben, die von mir ignoriert werden
$query = "SELECT i_id,u_id,u_nick,u_level,u_punkte_gesamt,u_punkte_gruppe "
. "FROM iignore LEFT JOIN user on i_user_passiv=u_id "
. "WHERE i_user_aktiv=$u_id ORDER BY u_nick,i_id";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) > 0) {
$i = 0;
$text = str_replace("%u_name%", $u_name, $t['chat_msg10']);
while ($row = mysql_fetch_object($result)) {
if ($row->u_id && $row->u_id != "NULL") {
if ($i > 0)
$text = $text . ", ";
$text = $text
. user($row->u_id, $row, TRUE, FALSE, " ",
"", "", FALSE);
} else {
$query = "DELETE FROM iignore WHERE i_id=$row->i_id";
$result2 = mysql_query($query, $conn);
}
$i++;
}
system_msg("", 0, $u_id, $system_farbe, $text . "");
} else {
system_msg("", 0, $u_id, $system_farbe,
str_replace("%u_name%", $u_name, $t['chat_msg9']));
}
@mysql_free_result($result);
// Liste der User ausgeben, die mich ignorieren
$query = "SELECT i_id,u_id,u_nick,u_level,u_punkte_gesamt,u_punkte_gruppe "
. "FROM iignore LEFT JOIN user on i_user_aktiv=u_id "
. "WHERE i_user_passiv=$u_id ORDER BY u_nick,i_id";
$result = mysql_query($query, $conn);
if ($result && mysql_num_rows($result) > 0) {
$i = 0;
$text = str_replace("%u_name%", $u_name, $t['chat_msg82']);
while ($row = mysql_fetch_object($result)) {
if ($row->u_id && $row->u_id != "NULL") {
if ($i > 0)
$text = $text . ", ";
$text = $text
. user($row->u_id, $row, TRUE, FALSE, " ",
"", "", FALSE);
} else {
$query = "DELETE FROM iignore WHERE i_id=$row->i_id";
$result2 = mysql_query($query, $conn);
}
$i++;
}
system_msg("", 0, $u_id, $system_farbe, $text . "");
}
@mysql_free_result($result);
}
break;
case "/channel":
case "/go":
case "/raum":
case "/rooms":
case "/j":
case "/join":
if ((($u_level == "G") || ($u_level == "U"))
&& ($single_room_verhalten == "1")) {
system_msg("", 0, $u_id, $system_farbe,
str_replace("%chatzeile%", $chatzeile[0],
$t['chat_spruch5']));
} else if ($chatzeile[1]) {
// Raumname erzeugen
$chatzeile[1] = preg_replace("/[ \\'\"]/", "", $chatzeile[1]);
$f['r_name'] = htmlspecialchars($chatzeile[1]);
if (!isset($chatzeile[2]))
$chatzeile[2] = "";
// Admin oder Raumbesitzer darf das Betreten geschlossener Räume erzwingen (Prüfung in raum_gehe)
if ($beichtstuhl || $chatzeile[2] == "immer"
|| $chatzeile[2] == "force" || $chatzeile[2] == "!") {
$raum_geschlossen = TRUE;
} else {
$raum_geschlossen = FALSE;
}
// Raum wechseln
$query = "SELECT r_id,(LENGTH(r_name)-length('$chatzeile[1]')) as laenge "
. "FROM raum WHERE r_name like '" . mysql_real_escape_string($chatzeile[1]) . "%' "
. "ORDER BY laenge";
$result = mysql_query($query, $conn);
if (mysql_num_rows($result) != 0) {
$r_id_neu = mysql_result($result, 0, "r_id");
if ($r_id_neu != $r_id) {
$r_id = raum_gehe($o_id, $u_id, $u_name, $r_id,
$r_id_neu, $raum_geschlossen);
raum_user($r_id, $u_id, "");
}
} elseif ($u_level != "G" && strlen($f['r_name']) <= $raum_max
&& strlen($f['r_name']) > 3) {
// Neuen Raum anlegen, ausser User ist Gast
$f['r_topic'] = htmlspecialchars($u_name . $t['chat_msg56']);
$f['r_eintritt'] = "";
$f['r_austritt'] = "";
$f['r_status1'] = "O";
$f['r_status2'] = "T";
$f['r_besitzer'] = $u_id;
$raumanlegen = true;
// ab hier neu: wir prüfen ob community an ist, der User kein Admin und $raumanlegenpunkte gesetzt
if ($communityfeatures && !$admin && $raumanlegenpunkte) {
$result = mysql_query(
"select u_punkte_gesamt FROM user WHERE u_id=$u_id");
if ($result && mysql_num_rows($result) == 1) {
$u_punkte_gesamt = mysql_result($result, 0, 0);
}
if ($u_punkte_gesamt < $raumanlegenpunkte) {
// Fehlermeldung und Raum nicht anlegen
system_msg("", 0, $u_id, $system_farbe,
str_replace("%punkte%", $raumanlegenpunkte,
$t['chat_msg108']));
$raumanlegen = false;
}
}
if ($raumanlegen == true) {
// Hier wird der Raum angelegt
$r_id_neu = schreibe_db("raum", $f, $f['r_id'], "r_id");
if ($r_id_neu != $r_id) {
$r_id = raum_gehe($o_id, $u_id, $u_name, $r_id,
$r_id_neu, $raum_geschlossen);
raum_user($r_id, $u_id, "");
}
}
} else {
// Fehlermeldung
system_msg("", 0, $u_id, $system_farbe,
str_replace("%chatzeile%", $chatzeile[1],
$t['chat_msg11']));
}
mysql_free_result($result);
} else {
// Liste alle Räume auf
if ($admin)
$query = "SELECT r_name from raum order by r_name";
else $query = "SELECT r_name from raum WHERE r_status1 = 'O' order by r_name";
$result = mysql_query($query, $conn);
$rows = mysql_num_rows($result);
$text = $t['chat_msg12'] . " ";
$i = 0;
while ($rows > $i) {
$text = $text . mysql_result($result, $i, "r_name");
$i++;
if ($i < $rows) {
$text = $text . ", ";
}
}
system_msg("", 0, $u_id, $system_farbe, $text);
mysql_free_result($result);
}
break;
case "/wer":
case "/who":
case "/w":
case "/user":
case "/list":
// User listen
if ($chatzeile[1] == "*") {
// * zeigt alle Räume
$chatzeile[0] = "/people";
} elseif ($chatzeile[1] != "") {
$query = "SELECT r_id from raum WHERE r_name LIKE '" . mysql_real_escape_string($chatzeile[1]) . "%' ";
if (!$admin)
$query .= " AND (r_status1='O' OR r_status1='m' OR r_id=$o_raum) ";
$result = mysql_query($query, $conn);
if ($result AND mysql_num_rows($result) > 0) {
$text = $t['chat_msg12'] . "<br>";
$row = mysql_fetch_object($result);
raum_user($row->r_id, $u_id, "");
mysql_free_result($result);
} else {
// Raum nicht gefunden -> Fehlermeldung
$txt = str_replace("%raumname%", $chatzeile[1],
$t['chat_msg53']);
system_msg("", $u_id, $u_id, $system_farbe, $txt);
}
break;
} else {
// Der aktuelle Raum wird gezeigt
raum_user($r_id, $u_id, "");