This repository has been archived by the owner on Feb 24, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
6211 lines (5726 loc) · 267 KB
/
index.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
/*
* status codes
* 0 - Kicked/Banned
* 1 - Guest
* 2 - Applicant
* 3 - Member
* 4 - System message
* 5 - Moderator
* 6 - Super-Moderator
* 7 - Admin
* 8 - Super-Admin
* 9 - Private messages
*/
// Dasho (https://dasho.dev)
send_headers();
// initialize and load variables/configuration
$I=[];// Translations
$L=[];// Languages
$U=[];// This user data
$db;// Database connection
$memcached;// Memcached connection
$language;// user selected language
load_config();
// set session variable to cookie if cookies are enabled
if(!isset($_REQUEST['session']) && isset($_COOKIE[COOKIENAME])){
//Modification that prevents users from doing unwanted things (for exmaple unintenionally deleting their account), if someone else posts a malicious link.
// MODIFICATION added logout to list of unwanted things
if(isset($_REQUEST['action']) && ($_REQUEST['action']==='profile'||$_REQUEST['action']==='post'|| $_REQUEST['action']==='admin' || $_REQUEST['action']==='setup'||$_REQUEST['action']==='logout')){
$_REQUEST['action']='login';
}
$_REQUEST['session']=$_COOKIE[COOKIENAME];
}
$_REQUEST['session'] = preg_replace('/[^0-9a-zA-Z]/', '', $_REQUEST['session'] ?? '');
load_lang();
check_db();
cron();
route();
// main program: decide what to do based on queries
function route(){
global $U;
if(!isset($_REQUEST['action'])){
send_login();
}elseif($_REQUEST['action']==='view'){
check_session();
//Modification chat rooms
if(isset($_REQUEST['room'])){
change_room();
check_session();
}
// show_rooms('true');
send_messages();
}elseif($_REQUEST['action']==='redirect' && !empty($_REQUEST['url'])){
send_redirect($_REQUEST['url']);
}elseif($_REQUEST['action']==='rooms'){
check_session();
rooms();
}elseif($_REQUEST['action']==='wait'){
parse_sessions();
send_waiting_room();
}elseif($_REQUEST['action']==='post'){
check_session();
if(isset($_REQUEST['kick']) && isset($_REQUEST['sendto']) && $_REQUEST['sendto']!==('s 48' || 's 56' || 's 65')){
//Modification to allow members to kick guests, if memdel (DEL-Buttons) enabled
if($U['status']>=5 || ($U['status']>=3 && get_count_mods()==0 && get_setting('memkick')) || ($U['status']>=3 && (int)get_setting('memdel')===2)){
if(isset($_REQUEST['what']) && $_REQUEST['what']==='purge'){
kick_chatter([$_REQUEST['sendto']], $_REQUEST['message'], true);
}else{
kick_chatter([$_REQUEST['sendto']], $_REQUEST['message'], false);
}
}
}elseif(isset($_REQUEST['message']) && isset($_REQUEST['sendto'])){
send_post(validate_input());
}
send_post();
}elseif($_REQUEST['action']==='login'){
check_login();
send_frameset();
}elseif($_REQUEST['action']==='controls'){
check_session();
send_controls();
}elseif($_REQUEST['action']==='greeting'){
check_session();
send_greeting();
}elseif($_REQUEST['action']==='delete'){
check_session();
if($_REQUEST['what']==='all'){
if(isset($_REQUEST['confirm'])){
del_all_messages($U['nickname'], $U['status']==1 ? $U['entry'] : 0);
}else{
send_del_confirm();
}
}elseif($_REQUEST['what']==='last'){
del_last_message();
}
send_post();
}elseif($_REQUEST['action']==='profile'){
check_session();
$arg='';
if(!isset($_REQUEST['do'])){
}elseif($_REQUEST['do']==='save'){
$arg=save_profile();
}elseif($_REQUEST['do']==='delete'){
if(isset($_REQUEST['confirm'])){
delete_account();
}else{
send_delete_account();
}
}
send_profile($arg);
}elseif($_REQUEST['action']==='logout'){
kill_session();
send_logout();
}elseif($_REQUEST['action']==='colours'){
check_session();
send_colours();
}elseif($_REQUEST['action']==='notes'){
check_session();
$sparenotesaccess = (int) get_setting('sparenotesaccess');
if(isset($_REQUEST['do']) && $_REQUEST['do']==='admin' && $U['status']>6){
send_notes(0);
}elseif(isset($_REQUEST['do']) && $_REQUEST['do']==='staff' && $U['status']>=5){
send_notes(1);
// Modification Spare Notes
}elseif (isset($_REQUEST['do']) && $_REQUEST['do']==='spare' && $U['status']>=$sparenotesaccess) {
send_notes(3);
}
if($U['status']<3 || !get_setting('personalnotes')){
send_access_denied();
}
send_notes(2);
}elseif($_REQUEST['action']==='help'){
check_session();
send_help();
}elseif($_REQUEST['action']==='inbox'){
check_session();
if(isset($_REQUEST['do'])){
clean_inbox_selected();
}
send_inbox();
}elseif($_REQUEST['action']==='download'){
send_download();
}elseif($_REQUEST['action']==='admin'){
check_session();
send_admin(route_admin());
//MODIFICATION DEL-BUTTONS 3 Lines added to enable delete buttons in front of each message.
}elseif($_REQUEST['action']==='admin_clean_message'){
check_session();
//These lines allows members to use the DEL-buttons according to the memdel setting (0 = not allowed , 2 = allowed, 1 = allowed if not mod is present and if DEL-Buttons are activated for members.)
$memdel = (int)get_setting('memdel');
if (($U['status']>= 5) || ($U['status']>=3 && $memdel===2) || ($U['status']>=3 && get_count_mods()==0 && $memdel===1)){
clean_selected($U['status'], $U['nickname']);
}
send_messages();
//MODIFICATION gallery
}elseif($_REQUEST['action']==='gallery'){
check_session(); //to get $U['status']
if(!isset($_REQUEST['do'])){
send_gallery();
}else{
send_gallery($_REQUEST['do']);
}
//MODIFICATION links page
}elseif($_REQUEST['action']==='links'){
check_session(); //to allow links page only for logged in users.
send_links_page();
//Forum Button was moved to the post box (function send_post)
/*
}elseif($_REQUEST['action']==='forum'){
check_session(); //to allow link to form only for logged in users.
send_to_forum();
*/
}elseif($_REQUEST['action']==='setup'){
route_setup();
}else{
send_login();
}
}
function route_admin(){
global $U, $db;
if($U['status']<5){
send_access_denied();
}
//Modification chat rooms
$roomcreateaccess = (int) get_setting('roomcreateaccess');
if(!isset($_REQUEST['do'])){
}elseif($_REQUEST['do']==='clean'){
if($_REQUEST['what']==='choose'){
send_choose_messages();
}elseif($_REQUEST['what']==='selected'){
clean_selected($U['status'], $U['nickname']);
}elseif($_REQUEST['what']==='chat'){
clean_chat();
}elseif($_REQUEST['what']==='room'){
clean_room();
}elseif($_REQUEST['what']==='nick'){
$stmt=$db->prepare('SELECT null FROM ' . PREFIX . 'members WHERE nickname=? AND status>=?;');
$stmt->execute([$_REQUEST['nickname'], $U['status']]);
if(!$stmt->fetch(PDO::FETCH_ASSOC)){
del_all_messages($_REQUEST['nickname'], 0);
}
}
}elseif($_REQUEST['do']==='kick'){
if(isset($_REQUEST['name'])){
if(isset($_REQUEST['what']) && $_REQUEST['what']==='purge'){
kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], true);
}else{
kick_chatter($_REQUEST['name'], $_REQUEST['kickmessage'], false);
}
}
}elseif($_REQUEST['do']==='logout'){
if(isset($_REQUEST['name'])){
logout_chatter($_REQUEST['name']);
}
}elseif($_REQUEST['do']==='sessions'){
if(isset($_REQUEST['kick']) && isset($_REQUEST['nick'])){
kick_chatter([$_REQUEST['nick']], '', false);
}elseif(isset($_REQUEST['logout']) && isset($_REQUEST['nick'])){
logout_chatter([$_REQUEST['nick']], '', false);
}
send_sessions();
// MODIFICATION only admins can register to member
}elseif($_REQUEST['do']==='register' && $U['status']>6){
return register_guest(3, $_REQUEST['name']);
}elseif($_REQUEST['do']==='superguest'){
return register_guest(2, $_REQUEST['name']);
// MODIFICATION only admins can change status
}elseif($_REQUEST['do']==='status' && $U['status']>6){
return change_status($_REQUEST['name'], $_REQUEST['set']);
// MODIFICATION only admins can register new members
}elseif($_REQUEST['do']==='regnew' && $U['status']>6){
return register_new($_REQUEST['name'], $_REQUEST['pass']);
}elseif($_REQUEST['do']==='approve'){
approve_session();
send_approve_waiting();
}elseif($_REQUEST['do']==='guestaccess'){
if(isset($_REQUEST['guestaccess']) && preg_match('/^[0123]$/', $_REQUEST['guestaccess'])){
update_setting('guestaccess', $_REQUEST['guestaccess']);
}
//MODIFICATION 2019-08-28 line changed. only smods (status = 6) with name Jonie , admins and above can view or change filters.
}elseif(($_REQUEST['do']==='filter' && $U['status']>=7) || ($_REQUEST['do']==='filter' && $U['status']>=6 && $U['nickname']==='Jonie')) {
send_filter(manage_filter());
//MODIFICATION 2019-08-28 line changed. only smods (status = 6) with name Jonie , admins and above can view or change linkfilters.
}elseif(($_REQUEST['do']==='linkfilter' && $U['status']>=7) || ($_REQUEST['do']==='linkfilter' && $U['status']>=6 && $U['nickname']==='Jonie')){
send_linkfilter(manage_linkfilter());
}elseif($_REQUEST['do']==='lastlogin' && $U['status']>=7){
send_lastlogin();
}elseif($_REQUEST['do']==='topic'){
//Modification "topic with html-code" (2 Lines)
if(isset($_REQUEST['topic']) && $U['status'] >= 7){
update_setting('topic', $_REQUEST['topic']);
}
// MODIFICATION only admins can reset passwords
}elseif($_REQUEST['do']==='passreset' && $U['status']>6){
return passreset($_REQUEST['name'], $_REQUEST['pass']);
//Modification chat rooms
}elseif ($_REQUEST['do']==='rooms' && $U['status']>=$roomcreateaccess) {
send_rooms(manage_rooms());
}
}
function route_setup(){
global $U;
if(!valid_admin()){
send_alogin();
}
//MODIFICATION incognito setting only for super admin
$C['bool_settings']=['suguests', 'imgembed', 'timestamps', 'trackip', 'memkick', 'forceredirect', 'sendmail', 'modfallback', 'disablepm', 'eninbox', 'enablegreeting', 'sortupdown', 'hidechatters', 'personalnotes', 'filtermodkick'];
$C['colour_settings']=['colbg', 'coltxt'];
$C['msg_settings']=['msgenter', 'msgexit', 'msgmemreg', 'msgsureg', 'msgkick', 'msgmultikick', 'msgallkick', 'msgclean', 'msgsendall', 'msgsendmem', 'msgsendmod', 'msgsendadm', 'msgsendprv', 'msgattache'];
$C['number_settings']=['memberexpire', 'guestexpire', 'kickpenalty', 'entrywait', 'captchatime', 'messageexpire', 'messagelimit', 'maxmessage', 'maxname', 'minpass', 'defaultrefresh', 'numnotes', 'maxuploadsize', 'enfileupload'];
$C['textarea_settings']=['rulestxt', 'css', 'disabletext'];
$C['text_settings']=['dateformat', 'captchachars', 'redirect', 'chatname', 'mailsender', 'mailreceiver', 'nickregex', 'passregex', 'externalcss'];
//MODIFICATION for links page. setting links and linksenabled added.
//MODIFICATION for DEL-Buttons: setting memdel added.
//MODIFICATION for galleryaccess: setting galleryaccess added.
//MODIFICATION for forumbtnaccess: setting forumbtnaccess added.
//MODIFICATION for forumbtnlink: setting forumbtnlink added.
//MODIFICATION for frontpagetext: setting frontpagetext added.
//MODIFICATION for adminjoinleavemsg: setting adminjoinleavemsg
//MODIFICATION for clickablne nicknames: setting clickablenicknamesglobal
//MODIFICATION for spare notes: setting sparenotesname, setting sparenotesaccess
//MODIFICATION for chat rooms: setting roomcreateaccess, setting roomexpire, setting channelvisinroom
$C['settings']=array_merge(['guestaccess', 'englobalpass', 'globalpass', 'captcha', 'dismemcaptcha', 'topic', 'guestreg', 'defaulttz', 'links', 'linksenabled', 'memdel', 'galleryaccess', 'forumbtnaccess', 'forumbtnlink', 'frontpagetext', 'adminjoinleavemsg', 'clickablenicknamesglobal', 'sparenotesname', 'sparenotesaccess', 'roomcreateaccess', 'roomexpire', 'channelvisinroom'], $C['bool_settings'], $C['colour_settings'], $C['msg_settings'], $C['number_settings'], $C['textarea_settings'], $C['text_settings']); // All settings in the database
//Modification Super Admin settings
//MODIFICATION for modsdeladminmsg: Super Admin setting modsdeladminmsg added
$C_SAdmin = $C;
$C_SAdmin['settings']= array_merge($C['settings'],['modsdeladminmsg', 'incognito']);
//Modificatoin Super Admin settings
if(!isset($_REQUEST['do'])){
}elseif($_REQUEST['do']==='save' && $U['status']==8){
save_setup($C_SAdmin);
}elseif($_REQUEST['do']==='save'){
save_setup($C);
}elseif($_REQUEST['do']==='backup' && $U['status']==8){
send_backup($C);
}elseif($_REQUEST['do']==='restore' && $U['status']==8){
restore_backup($C);
send_backup($C);
}elseif($_REQUEST['do']==='destroy' && $U['status']==8){
if(isset($_REQUEST['confirm'])){
destroy_chat($C);
}else{
send_destroy_chat();
}
}
send_setup($C);
}
// html output subs
function print_stylesheet($init=false){
global $U;
//default css
echo '<style type="text/css">';
echo 'body{background-color:#000000;color:#FFFFFF;font-size:14px;text-align:center;} body .rooms {background-color: transparent !important;}';
echo 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} #messages{word-wrap:break-word;} ';
echo 'input,select,textarea{color:#FFFFFF;background-color:#000000;} .messages a img{width:15%} .messages a:hover img{width:35%} ';
echo '.error{color:#FF0033;text-align:left;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;} ';
echo '.setup table table,.admin table table,.profile table table{width:100%;text-align:left} ';
echo '.alogin table,.init table,.destroy_chat table,.delete_account table,.sessions table,.filter table,.linkfilter table,.notes table,.approve_waiting table,.del_confirm table,.profile table,.admin table,.backup table,.setup table{margin-left:auto;margin-right:auto;} ';
echo '.setup table table table,.admin table table table,.profile table table table{border-spacing:0px;margin-left:auto;margin-right:unset;width:unset;} ';
echo '.setup table table td,.backup #restoresubmit,.backup #backupsubmit,.admin table table td,.profile table table td,.login td+td,.alogin td+td{text-align:right;} ';
echo '.init td,.backup #restorecheck td,.admin #clean td,.admin #regnew td,.session td,.messages,.inbox,.approve_waiting td,.choose_messages,.greeting,.help,.login td,.alogin td{text-align:left;} ';
echo '.messages #chatters{max-height:100px;overflow-y:auto;} .messages #chatters a{text-decoration-line:none;} .messages #chatters table{border-spacing:0px;} ';
echo '.messages #chatters th,.messages #chatters td,.post #firstline{vertical-align:top;} ';
echo '.approve_waiting #action td:only-child,.help #backcredit,.login td:only-child,.alogin td:only-child,.init td:only-child{text-align:center;} .sessions td,.sessions th,.approve_waiting td,.approve_waiting th{padding: 5px;} ';
echo '.sessions td td{padding: 1px;} .messages #bottom_link{position:fixed;top:0.5em;right:0.5em;} .messages #top_link{position:fixed;bottom:0.5em;right:0.5em;} ';
echo '.post table,.controls table,.login table{border-spacing:0px;margin-left:auto;margin-right:auto;} .login table{border:2px solid;} .controls{overflow-y:none;} ';
echo '#manualrefresh{display:block;position:fixed;text-align:center;left:25%;width:50%;top:-200%;animation:timeout_messages ';
if(isset($U['refresh'])){
echo $U['refresh']+20;
}else{
echo '160';
}
echo 's forwards;z-index:2;background-color:#500000;border:2px solid #ff0000;} ';
echo '@keyframes timeout_messages{0%{top:-200%;} 99%{top:-200%;} 100%{top:0%;}} ';
echo '.notes textarea{height:80vh;width:80%;}iframe{width:100%;height:100%;margin:0;padding:0;border:none}';
echo '@import url("style.css");';
echo '</style>';
if($init){
return;
}
$css=get_setting('css');
$coltxt=get_setting('coltxt');
if(!empty($U['bgcolour'])){
$colbg=$U['bgcolour'];
}else{
$colbg=get_setting('colbg');
}
echo "<link rel=\"shortcut icon\" href=\"https://cdn.sokka.dev/global/images/favicon.svg\">";
//overwrite with custom css
echo "<style type=\"text/css\">body{background-color:#$colbg;color:#$coltxt;} $css</style>";
echo "<link rel=\"preload\" href=\"style.css\" as=\"style\"><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";
}
function print_end(){
echo '</body></html>';
exit;
}
function credit(){
return '<small><br><br><a target="_blank" style="color:var(--accent); text-decoration: underline dotted var(--accent)" href="https://onionz.dev/">The Onionz Project</a></small>';
}
function meta_html(){
return '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate, max-age=0"><meta http-equiv="expires" content="0"><meta name="referrer" content="no-referrer">';
}
function form($action, $do=''){
global $language;
$form="<form action=\"$_SERVER[SCRIPT_NAME]\" enctype=\"multipart/form-data\" method=\"post\">".hidden('lang', $language).hidden('nc', substr(time(), -6)).hidden('action', $action);
if(!empty($_REQUEST['session'])){
$form.=hidden('session', $_REQUEST['session']);
}
if($do!==''){
$form.=hidden('do', $do);
}
return $form;
}
function form_target($target, $action, $do=''){
global $language;
$form="<form action=\"$_SERVER[SCRIPT_NAME]\" enctype=\"multipart/form-data\" method=\"post\" target=\"$target\">".hidden('lang', $language).hidden('nc', substr(time(), -6)).hidden('action', $action);
if(!empty($_REQUEST['session'])){
$form.=hidden('session', $_REQUEST['session']);
}
if($do!==''){
$form.=hidden('do', $do);
}
return $form;
}
function hidden($arg1='', $arg2=''){
return "<input type=\"hidden\" name=\"$arg1\" value=\"$arg2\">";
}
function submit($arg1='', $arg2=''){
return "<input type=\"submit\" value=\"$arg1\" $arg2>";
}
function thr(){
echo '<tr><td><hr></td></tr>';
}
function print_start($class='', $ref=0, $url=''){
global $I;
if(!empty($url)){
$url=str_replace('&', '&', $url);// Don't escape "&" in URLs here, it breaks some (older) browsers and js refresh!
header("Refresh: $ref; URL=$url");
}
echo '<!DOCTYPE html><html><head>'.meta_html();
if(!empty($url)){
echo "<meta http-equiv=\"Refresh\" content=\"$ref; URL=$url\">";
$ref+=5;//only use js if browser refresh stopped working
$ref*=1000;//js uses milliseconds
// MODIFICATION removed window refresh js
/* echo "<script type=\"text/javascript\">setTimeout(function(){window.location.replace(\"$url\");}, $ref);</script>";*/
}
if($class==='init'){
echo "<title>$I[init]</title>";
print_stylesheet(true);
}else{
echo '<title>'.get_setting('chatname').'</title>';
print_stylesheet();
}
if($class!=='init' && ($externalcss=get_setting('externalcss'))!=''){
//external css - in body to make it non-renderblocking
}
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";
echo '<meta http-equiv="onion-location" content="http://cboxkuuxrtulkkxhod2pxo3la25tztcp4cdjmc75wc5airqqliq2srad.onion" />';
echo "</head><body class=\"$class\">";
}
function send_redirect($url){
global $I;
$url=trim(htmlspecialchars_decode(rawurldecode($url)));
preg_match('~^(.*)://~u', $url, $match);
$url=preg_replace('~^(.*)://~u', '', $url);
$escaped=htmlspecialchars($url);
if(isset($match[1]) && ($match[1]==='http' || $match[1]==='https')){
print_start('redirect', 0, $match[0].$escaped);
echo "<p>$I[redirectto] <a href=\"$match[0]$escaped\">$match[0]$escaped</a>.</p>";
}else{
print_start('redirect');
if(!isset($match[0])){
$match[0]='';
}
if(preg_match('~^(javascript|blob|data):~', $url)){
echo "<p>$I[dangerousnonhttp] $match[0]$escaped</p>";
} else {
echo "<p>$I[nonhttp] <a href=\"$match[0]$escaped\">$match[0]$escaped</a>.</p>";
}
echo "<p>$I[httpredir] <a href=\"http://$escaped\">http://$escaped</a>.</p>";
}
print_end();
}
function send_access_denied(){
global $I, $U;
header('HTTP/1.1 403 Forbidden');
print_start('access_denied');
echo "<h1>$I[accessdenied]</h1>".sprintf($I['loggedinas'], style_this(htmlspecialchars($U['nickname']), $U['style'])).'<br>';
echo form('logout');
if(!isset($_REQUEST['session'])){
echo hidden('session', $U['session']);
}
echo submit($I['logout'], 'id="exitbutton"')."</form>";
print_end();
}
function send_captcha(){
global $I, $db, $memcached;
$difficulty=(int) get_setting('captcha');
if($difficulty===0 || !extension_loaded('gd')){
return;
}
$captchachars=get_setting('captchachars');
$length=strlen($captchachars)-1;
$code='';
for($i=0;$i<5;++$i){
$code.=$captchachars[mt_rand(0, $length)];
}
$randid=mt_rand();
$time=time();
if(MEMCACHED){
$memcached->set(DBNAME . '-' . PREFIX . "captcha-$randid", $code, get_setting('captchatime'));
}else{
$stmt=$db->prepare('INSERT INTO ' . PREFIX . 'captcha (id, time, code) VALUES (?, ?, ?);');
$stmt->execute([$randid, $time, $code]);
}
echo "<tr id=\"captcha\"><td><span class=\"centerWrap sprite-decaptcha-logo-night\"></span> ";
if($difficulty===1){
$im=imagecreatetruecolor(55, 24);
$bg=imagecolorallocatealpha($im, 0, 0, 0, 127);
$fg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5, $code, $fg);
imagesavealpha($im, true);
echo '<img class="captchalogincbox" width="55" height="24" src="data:image/gif;base64,';
}elseif($difficulty===2){
$im=imagecreatetruecolor(55, 24);
$bg=imagecolorallocatealpha($im, 0, 0, 0, 0);
$fg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5, $code, $fg);
$line=imagecolorallocate($im, 255, 255, 255);
for($i=0;$i<2;++$i){
imageline($im, 0, mt_rand(0, 24), 55, mt_rand(0, 24), $line);
}
$dots=imagecolorallocate($im, 255, 255, 255);
for($i=0;$i<100;++$i){
imagesetpixel($im, mt_rand(0, 55), mt_rand(0, 24), $dots);
}
echo '<img class="captchalogincbox" width="55" height="24" src="data:image/gif;base64,';
}else{
$im=imagecreatetruecolor(150, 200);
$bg=imagecolorallocatealpha($im, 0, 0, 0, 0);
$fg=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $bg);
$chars=[];
for($i=0;$i<10;++$i){
$found=false;
while(!$found){
$x=mt_rand(10, 140);
$y=mt_rand(10, 180);
$found=true;
foreach($chars as $char){
if($char['x']>=$x && ($char['x']-$x)<25){
$found=false;
}elseif($char['x']<$x && ($x-$char['x'])<25){
$found=false;
}
if(!$found){
if($char['y']>=$y && ($char['y']-$y)<25){
break;
}elseif($char['y']<$y && ($y-$char['y'])<25){
break;
}else{
$found=true;
}
}
}
}
$chars[]=['x', 'y'];
$chars[$i]['x']=$x;
$chars[$i]['y']=$y;
if($i<5){
imagechar($im, 5, $chars[$i]['x'], $chars[$i]['y'], $captchachars[mt_rand(0, $length)], $fg);
}else{
imagechar($im, 5, $chars[$i]['x'], $chars[$i]['y'], $code[$i-5], $fg);
}
}
$follow=imagecolorallocate($im, 200, 0, 0);
imagearc($im, $chars[5]['x']+4, $chars[5]['y']+8, 16, 16, 0, 360, $follow);
for($i=5;$i<9;++$i){
imageline($im, $chars[$i]['x']+4, $chars[$i]['y']+8, $chars[$i+1]['x']+4, $chars[$i+1]['y']+8, $follow);
}
$line=imagecolorallocate($im, 255, 255, 255);
for($i=0;$i<5;++$i){
imageline($im, 0, mt_rand(0, 200), 150, mt_rand(0, 200), $line);
}
$dots=imagecolorallocate($im, 255, 255, 255);
for($i=0;$i<1000;++$i){
imagesetpixel($im, mt_rand(0, 150), mt_rand(0, 200), $dots);
}
echo '<img class="captchalogincbox" width="150" height="200" src="data:image/gif;base64,';
}
ob_start();
imagegif($im);
imagedestroy($im);
echo base64_encode(ob_get_clean()).'">';
echo '</td><td>'.hidden('challenge', $randid).'<input type="text" name="captcha" size="15" autocomplete="off"></td></tr>';
}
function send_setup($C){
global $I, $U;
print_start('setup');
echo "<h2>$I[setup]</h2>".form('setup', 'save');
if(!isset($_REQUEST['session'])){
echo hidden('session', $U['session']);
}
echo '<table id="guestaccess">';
thr();
$ga=(int) get_setting('guestaccess');
echo "<tr><td><table><tr><th>$I[guestacc]</th><td>";
echo '<select name="guestaccess">';
echo '<option value="1"';
if($ga===1){
echo ' selected';
}
echo ">$I[guestallow]</option>";
echo '<option value="2"';
if($ga===2){
echo ' selected';
}
echo ">$I[guestwait]</option>";
echo '<option value="3"';
if($ga===3){
echo ' selected';
}
echo ">$I[adminallow]</option>";
echo '<option value="0"';
if($ga===0){
echo ' selected';
}
echo ">$I[guestdisallow]</option>";
echo '<option value="4"';
if($ga===4){
echo ' selected';
}
echo ">$I[disablechat]</option>";
echo '</select></td></tr></table></td></tr>';
thr();
$englobal=(int) get_setting('englobalpass');
echo "<tr><td><table id=\"globalpass\"><tr><th>$I[globalloginpass]</th><td>";
echo '<table>';
echo '<tr><td><select name="englobalpass">';
echo '<option value="0"';
if($englobal===0){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($englobal===1){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '<option value="2"';
if($englobal===2){
echo ' selected';
}
echo ">$I[onlyguests]</option>";
echo '</select></td><td> </td>';
echo '<td><input type="text" name="globalpass" value="'.htmlspecialchars(get_setting('globalpass')).'"></td></tr>';
echo '</table></td></tr></table></td></tr>';
thr();
$ga=(int) get_setting('guestreg');
echo "<tr><td><table id=\"guestreg\"><tr><th>$I[guestreg]</th><td>";
echo '<select name="guestreg">';
echo '<option value="0"';
if($ga===0){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($ga===1){
echo ' selected';
}
echo ">$I[assuguest]</option>";
echo '<option value="2"';
if($ga===2){
echo ' selected';
}
echo ">$I[asmember]</option>";
echo '</select></td></tr></table></td></tr>';
thr();
echo "<tr><td><table id=\"sysmessages\"><tr><th>$I[sysmessages]</th><td>";
echo '<table>';
foreach($C['msg_settings'] as $setting){
echo "<tr><td> $I[$setting]</td><td> <input type=\"text\" name=\"$setting\" value=\"".get_setting($setting).'"></td></tr>';
}
echo '</table></td></tr></table></td></tr>';
foreach($C['text_settings'] as $setting){
thr();
echo "<tr><td><table id=\"$setting\"><tr><th>".$I[$setting].'</th><td>';
echo "<input type=\"text\" name=\"$setting\" value=\"".htmlspecialchars(get_setting($setting)).'">';
echo '</td></tr></table></td></tr>';
}
foreach($C['colour_settings'] as $setting){
thr();
echo "<tr><td><table id=\"$setting\"><tr><th>".$I[$setting].'</th><td>';
echo "<input type=\"color\" name=\"$setting\" value=\"#".htmlspecialchars(get_setting($setting)).'">';
echo '</td></tr></table></td></tr>';
}
thr();
echo "<tr><td><table id=\"captcha\"><tr><th>$I[captcha]</th><td>";
echo '<table>';
if(!extension_loaded('gd')){
echo "<tr><td>$I[gdextrequired]</td></tr>";
}else{
echo '<tr><td><select name="dismemcaptcha">';
$dismemcaptcha=(bool) get_setting('dismemcaptcha');
echo '<option value="0"';
if(!$dismemcaptcha){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '<option value="1"';
if($dismemcaptcha){
echo ' selected';
}
echo ">$I[onlyguests]</option>";
echo '</select></td><td><select name="captcha">';
$captcha=(int) get_setting('captcha');
echo '<option value="0"';
if($captcha===0){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($captcha===1){
echo ' selected';
}
echo ">$I[simple]</option>";
echo '<option value="2"';
if($captcha===2){
echo ' selected';
}
echo ">$I[moderate]</option>";
echo '<option value="3"';
if($captcha===3){
echo ' selected';
}
echo ">$I[extreme]</option>";
echo '</select></td></tr>';
}
echo '</table></td></tr></table></td></tr>';
thr();
echo "<tr><td><table id=\"defaulttz\"><tr><th>$I[defaulttz]</th><td>";
echo "<select name=\"defaulttz\">";
$tzs=timezone_identifiers_list();
$defaulttz=get_setting('defaulttz');
foreach($tzs as $tz){
echo "<option value=\"$tz\"";
if($defaulttz==$tz){
echo ' selected';
}
echo ">$tz</option>";
}
echo '</select>';
echo '</td></tr></table></td></tr>';
foreach($C['textarea_settings'] as $setting){
thr();
echo "<tr><td><table id=\"$setting\"><tr><th>".$I[$setting].'</th><td>';
echo "<textarea name=\"$setting\" rows=\"4\" cols=\"60\">".htmlspecialchars(get_setting($setting)).'</textarea>';
echo '</td></tr></table></td></tr>';
}
//MODIFICATION textarea to edit links page
thr();
echo "<tr><td><table id=\"links\"><tr><th>Links Page (html)</th><td>";
echo "<textarea name=\"links\" rows=\"4\" cols=\"60\">".htmlspecialchars(get_setting('links')).'</textarea>';
echo '</td></tr></table></td></tr>';
//End of Modification
//MODIFICATION frontpagetext: textarea to edit front page
thr();
echo "<tr><td><table id=\"frontpagetext\"><tr><th>Text on front page (html)</th><td>";
echo "<textarea name=\"frontpagetext\" rows=\"4\" cols=\"60\">".htmlspecialchars(get_setting('frontpagetext')).'</textarea>';
echo '</td></tr></table></td></tr>';
//End of Modification
foreach($C['number_settings'] as $setting){
thr();
echo "<tr><td><table id=\"$setting\"><tr><th>".$I[$setting].'</th><td>';
echo "<input type=\"number\" name=\"$setting\" value=\"".htmlspecialchars(get_setting($setting)).'">';
echo '</td></tr></table></td></tr>';
}
foreach($C['bool_settings'] as $setting){
thr();
echo "<tr><td><table id=\"$setting\"><tr><th>".$I[$setting].'</th><td>';
echo "<select name=\"$setting\">";
$value=(bool) get_setting($setting);
echo '<option value="0"';
if(!$value){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($value){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '</select></td></tr>';
echo '</table></td></tr>';
}
//thr();
//MODIFICATION to enable links page
thr();
echo "<tr><td><table id=\"linksenabled\"><tr><th>Links Page</th><td>";
echo "<select name=\"linksenabled\">";
$value=(bool) get_setting('linksenabled');
echo '<option value="0"';
if(!$value){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($value){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of Modification
//MODIFICATION to enable DEL-Buttons for members (2 = always, 1 = if no mod is present.)
//thr();
echo "<tr><td><table id=\"memdel\"><tr><th>Members can delete messages (DEL) and can kick</th><td>";
echo "<select name=\"memdel\">";
$value=(int) get_setting('memdel');
echo '<option value="0"';
if($value == 0){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($value == 1){
echo ' selected';
}
echo ">DEL-Buttons enabled, if no mod is present</option>";
/*
echo '</select></td></tr>';
echo '</table></td></tr>';
*/
echo '<option value="2"';
if($value == 2){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of Modification
//Modification gallery access
echo "<tr><td><table id=\"galleryaccess\"><tr><th>Gallery access</th><td>";
echo "<select name=\"galleryaccess\">";
$value=(int) get_setting('galleryaccess');
$options = array(1, 2, 3, 5, 6, 7, 10);
foreach($options as $option){
echo "<option value=\"$option\"";
if($value==$option){
echo ' selected';
}
if ($option == 1) echo ">All</option>";
elseif($option == 2) echo ">Registered guests</option>";
elseif($option == 3) echo ">Members</option>";
elseif($option == 5) echo ">Moderators</option>";
elseif($option == 6) echo ">Super Moderators</option>";
elseif($option == 7) echo ">Admins</option>";
elseif($option == 10) echo ">Disabled</option>";
}
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of modification
//Modification forum button visibility
echo "<tr><td><table id=\"forumbtnaccess\"><tr><th>Forum Button visibility</th><td>";
echo "<select name=\"forumbtnaccess\">";
$value=(int) get_setting('forumbtnaccess');
$options = array(1, 2, 3, 5, 6, 7, 10);
foreach($options as $option){
echo "<option value=\"$option\"";
if($value==$option){
echo ' selected';
}
if ($option == 1) echo ">All</option>";
elseif($option == 2) echo ">Registered guests</option>";
elseif($option == 3) echo ">Members</option>";
elseif($option == 5) echo ">Moderators</option>";
elseif($option == 6) echo ">Super Moderators</option>";
elseif($option == 7) echo ">Admins</option>";
elseif($option == 10) echo ">Disabled</option>";
}
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of modification
//Modification forum button link
echo "<tr><td><table id=\"forumbtnlink\"><tr><th>Forum Button link</th><td>";
echo "<input type=\"text\" name=\"forumbtnlink\" value=\"".htmlspecialchars(get_setting('forumbtnlink')).'">';
echo '</td></tr></table></td></tr>';
thr();
//End of modification
//MODIFICATION adminjoinleavemsg to not create a system message if an admins arrives or leaves the chat
echo "<tr><td><table id=\"adminjoinleavemsg\"><tr><th>Show system message if an admin joined or left the chat</th><td>";
echo "<select name=\"adminjoinleavemsg\">";
$value=(bool) get_setting('adminjoinleavemsg');
echo '<option value="0"';
if(!$value){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($value){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of Modification
//MODIFICATION clickablenicknamesglobal to enable/disable clickablenicknames, e. g. in case of errors
echo "<tr><td><table id=\"clickablenicknamesglobal\"><tr><th>Clickable nicknames</th><td>";
echo "<select name=\"clickablenicknamesglobal\">";
$value=(bool) get_setting('clickablenicknamesglobal');
echo '<option value="0"';
if(!$value){
echo ' selected';
}
echo ">$I[disabled]</option>";
echo '<option value="1"';
if($value){
echo ' selected';
}
echo ">$I[enabled]</option>";
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
//End of Modification
// Modification Spare Notes.
// Spare Notes name
echo '<tr><td><table id="sparenotesname"><tr><th>Spare Notes Name</th><td>';
echo '<input type="text" name="sparenotesname" value="'.htmlspecialchars(get_setting('sparenotesname')).'">';
echo '</td></tr></table></td></tr>';
thr();
// Spare Notes Access
echo "<tr><td><table id=\"sparenotesaccess\"><tr><th>Spare Notes Access</th><td>";
echo "<select name=\"sparenotesaccess\">";
$value=(int) get_setting('sparenotesaccess');
$options = array(3, 5, 6, 7, 10);
foreach($options as $option){
echo "<option value=\"$option\"";
if($value==$option){
echo ' selected';
}
if($option == 3) echo ">Members</option>";
elseif($option == 5) echo ">Moderators</option>";
elseif($option == 6) echo ">Super Moderators</option>";
elseif($option == 7) echo ">Admins</option>";
elseif($option == 10) echo ">Disabled</option>";
}
// End of Modification
echo '</select></td></tr>';
echo '</table></td></tr>';
thr();
// Modificatin create chat rooms
echo "<tr><td><table id=\"roomcreateaccess\"><tr><th>Rooms can be created by:</th><td>";
echo "<select name=\"roomcreateaccess\">";
$value=(int) get_setting('roomcreateaccess');
$options = array(5, 6, 7);
foreach($options as $option){
echo "<option value=\"$option\"";
if($value==$option){
echo ' selected';
}
if($option == 5) echo ">Moderators</option>";
elseif($option == 6) echo ">Super Moderators</option>";
elseif($option == 7) echo ">Admins</option>";