-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.php
1434 lines (1408 loc) · 67.8 KB
/
template.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
echo "<script>console.log(`Hello! If you're seeing this, this is my special little console where i spend hours debugging! You shouldnt need to do anything here unless told by someone important, but you can always check the source code on my github if you want to poke around!`);</script>"; // Debug code
$asc = 0; // Fixes issues, so it's not empty
if ($_SERVER["REQUEST_METHOD"] == "POST") { //* Used as a flip-flop switch between ASC Chat
if (empty($_POST['name'])) {
$asc = 1;
}
else {
if ($asc = 1) {
$asc = 0;
}
else {
$asc = 1;
}
}
}
if (!empty($asc)){
echo "<script>console.log(`Asc: $asc`);</script>"; // Debug code
}
if ($asc == 1){
$chatbox = 'agentchatbox';
}
else {
$chatbox = 'chatbox';
}
ini_set('memory_limit', '512M');
ini_set('display_errors', '1');
function csv_content_parser($content)
{
foreach (explode("\n", $content) as $line) {
yield str_getcsv($line);
}
}
function csvstring_to_array($string, $separatorChar = ',', $enclosureChar = '"', $newlineChar = "\n") {
$array = array(); // idk who i took this from
$size = strlen($string);
$columnIndex = 0;
$rowIndex = 0;
$fieldValue="";
$isEnclosured = false;
for($i=0; $i<$size;$i++) {
$char = $string[$i];
$addChar = "";
if($isEnclosured) {
if($char==$enclosureChar) {
if($i+1<$size && $string[$i+1]==$enclosureChar){
$addChar=$char;
$i++;
}else{
$isEnclosured = false;
}
}else {
$addChar=$char;
}
}else {
if($char==$enclosureChar) {
$isEnclosured = true;
}else {
if($char==$separatorChar) {
$array[$rowIndex][$columnIndex] = $fieldValue;
$fieldValue="";
$columnIndex++;
}elseif($char==$newlineChar) {
echo $char; // this echo's like 1200 blank lines into the php web-side. this doesnt show on the html so i dont care.
$array[$rowIndex][$columnIndex] = $fieldValue;
$fieldValue="";
$columnIndex=0;
$rowIndex++;
}else {
$addChar=$char;
}
}
}
if($addChar!=""){
$fieldValue.=$addChar;
}
}
if($fieldValue) { // save last field
$array[$rowIndex][$columnIndex] = $fieldValue;
}
return $array;
}
$data1 = csvstring_to_array(file_get_contents("messages.csv")); // Im using 2 csv tbh but like idk man
$content2 = file_get_contents("opsummary.csv");$data2 = [];foreach (csv_content_parser($content2) as $fields) {array_push($data2, $fields);}
$content3 = file_get_contents("prechat.csv");$data3 = [];foreach (csv_content_parser($content3) as $fields) {array_push($data3, $fields);}
$content4 = file_get_contents("topology.csv");$data4 = [];foreach (csv_content_parser($content4) as $fields) {array_push($data4, $fields);}
$content5 = file_get_contents("users.csv");$data5 = [];foreach (csv_content_parser($content5) as $fields) {array_push($data5, $fields);}
$jsonText = file_get_contents('../json/classData-season6.json');
$classes = json_decode($jsonText, true);
$classes = array_map(function($obj) {return array_values($obj);},$classes);
$charges = json_decode(file_get_contents('../json/charges-season6.json'), true);
$adder = 1;
$helpmenumber = 1;
$mailchecker = 1;
$player = array("role");
$findernumber = 1;
$coverfind = array();
$deaths = array();
$skills = array(["role","skill","used_on","day"]);
$lifechangearray = array(["color","line","dayof","ifdied","ifmoled","ifarrested","ifimprovised","improviseddayof"]);
$sidebarnumber = 1;
$colornumber = 1;
$addman = 1;
$user = 1;
$admin = 0;
$daytime = 01;
function checkrole($number, $style_top)
{
global $data2, $player, $data5, $user, $role, $admin, $coverfind, $daytime;
$agent_class = "Agent Leader | Field Agent | Forensics Specialist | Mole (Converted Field Ops) | Mole (Converted Inv.) | Mole (Converted Offensive) | Runaway Snitch |";
$netsec_class = "Operation Leader | CCTV Specialist | Enforcer | Inside Man | Analyst | Network Specialist | Social Engineer | Blackhat | Improvised Hacker | Spearphisher | ";
$nuet_class = "Bounty Hunter | Corrupt Detective | Double-crosser | Journalist | Loose Cannon | Script Kiddie | Panicked Blabbermouth | Resentful Criminal | Sociopath | Rival Hacker | ";
if (empty($player[$number])){
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/blank.png">';
} else {
if (str_contains($agent_class, $player[$number][0])){
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') {
if ($data2[$number][0] == $coverfind[0][0] && $daytime < 40) { // Check if agent has cover
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/netsec.png">';
}
else {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/agent.png">';
}
}
else {
if ($data5[$user][3]==$data5[$number][3]) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/agent.png">';
}
else {
if (str_contains($agent_class, $role)){
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/agent.png">';
}
else {
if ($admin == 1) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/agent.png">';
} else {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/blank.png">';
}
}
}
}
} else {
if(str_contains($netsec_class, $player[$number][0])){
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/netsec.png">';
}
else {
if ($data5[$user][3]==$data5[$number][3]) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/netsec.png">';
}
else {
if ($admin == 1) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/netsec.png">';
} else {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/blank.png">';
}
}
}
} else {
if(str_contains($nuet_class, $player[$number][0])){
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/nuet.png">';
}
else {
if ($data5[$user][3]==$data5[$number][3]) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/nuet.png">';
}
else {
if ($admin == 1) {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/nuet.png">';
} else {
echo '<img style="top:'.$style_top.';left:50px;" class="factionimg" src="/images/blank.png">';
}
}
}
}
}
}
}
}
function checkheartbeat($number, $style_top)
{
global $data2, $daytime, $player, $deaths;
$alive = 'Alive';
$dead = 'Dead';
$arrested = 'Arrested';
if (empty($data2[$number][3])){
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/blank.png">';
} else {
if(str_contains($alive, $data2[$number][3])){
if ($player[$number][2] == 'before') {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/alive.png">';
}
else {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/alive.png">';
}
} else {
if(str_contains($dead, $data2[$number][3])){
if ($player[$number][2] == 'before') {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/alive.png">';
}
else {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/dead.png">';
$deaths[$data2[$number][0]] = "died"; // Used for votes, bodged together because i can woohoo!!!
}
} else {
if(str_contains($arrested, $data2[$number][3])){
if ($player[$number][2] == 'before') {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/alive.png">';
}
else {
echo '<img style="top:'.$style_top.';" class="alivestatusimg" src="/images/arrested.png">';
$deaths[$data2[$number][0]] = "arrested"; // Used for votes, bodged together because i can woohoo!!!
}
}
}
}
}
}
function checkcolor($number)
{
global $data2, $player, $admin, $user, $role;
$agent_class = "Agent Leader | Field Agent | Forensics Specialist | Mole (Converted Field Ops) | Mole (Converted Inv.) | Mole (Converted Offensive) | Runaway Snitch |";
$netsec_class = "Operation Leader | CCTV Specialist | Enforcer | Inside Man | Analyst | Network Specialist | Social Engineer | Blackhat | Improvised Hacker | Spearphisher | ";
$nuet_class = "Bounty Hunter | Corrupt Detective | Double-crosser | Journalist | Loose Cannon | Script Kiddie | Panicked Blabbermouth | Resentful Criminal | Sociopath | Rival Hacker | ";
if (empty($data2[$number][3])){
echo "blank";
} else {
if(str_contains($agent_class, $player[$number][0])){
// Role is agent
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') { //check if they are alive or dead/arrested, anmd if its after its happened
echo "841fa4"; // Dead Color
}
else {
if($user == $number) {
echo "846414"; // Agent Color
}
else {
echo "e6e6e6"; // Unknown color (white)
}
}
} else {
if(str_contains($netsec_class, $player[$number][0])){
// Role is Netsec
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') { //check if they are alive or dead/arrested, anmd if its after its happened
echo "841fa4"; // Dead Color
}
else {
if($user == $number) {
echo "077d0c"; // Netsec Color
}
else {
echo "e6e6e6"; // Unknown color (white)
}
}
} else {
if(str_contains($nuet_class, $player[$number][0])){
// Role is neutral. Nuetral is hard to spell.
if($player[$number][3] == 'Dead' || $player[$number][3] == 'Arrested' and $player[$number][2] == 'after') { //check if they are alive or dead/arrested, anmd if its after its happened
echo "841fa4"; // Dead Color
}
else {
if($user == $number) {
echo "4f0404"; // Neutral Color
}
else {
echo "e6e6e6"; // Unknown color (white)
}
}
}
}
}
}
}
function checkcolornodeath($role) //* used for top right name
{
global $data2;
$agent_class = "Agent Leader | Field Agent | Forensics Specialist | Mole (Converted Field Ops) | Mole (Converted Inv.) | Mole (Converted Offensive) | Runaway Snitch |";
$netsec_class = "Operation Leader | CCTV Specialist | Enforcer | Inside Man | Analyst | Network Specialist | Social Engineer | Blackhat | Improvised Hacker | Spearphisher | ";
$nuet_class = "Bounty Hunter | Corrupt Detective | Double-crosser | Journalist | Loose Cannon | Script Kiddie | Panicked Blabbermouth | Resentful Criminal | Sociopath | Rival Hacker | ";
if (empty($role)){
echo "blank";
} else {
if(str_contains($agent_class, $role)){
// Role is agent
echo "cca11d";
} else {
if(str_contains($netsec_class, $role)){
// Role is Netsec
echo "04d116";
} else {
if(str_contains($nuet_class, $role)){
// Role is neutral. Nuetral is hard to spell.
echo "ffffff";
}
}
}
}
}
function findday($param)
{
global $lifechangearray, $adder, $data2, $daytime;
if ($lifechangearray[$adder][0] == $data2[$param][0]){
$keys = array_keys(array_column($lifechangearray, 0), $data2[$param][0]);
//echo "<script>console.log('kegs: %O', ".json_encode($keys)." );</script>"; // Debug code
if (count($keys) >= 2) { // Check for people with more than 2 logs. They are imp i thnk
$impday = $lifechangearray[$keys[0]][7]; // Day of imping
$otherday = $lifechangearray[$keys[1]][2]; // Day or arrest or whatever
if (!empty($lifechangearray[$keys[1]][3])) {
$pushrole = $lifechangearray[$keys[1]][3];
}
else {
if (!empty($lifechangearray[$keys[1]][4])) {
$pushrole = $lifechangearray[$keys[1]][4];
}
else {
$pushrole = $lifechangearray[$keys[1]][5];
}
}
if ($impday < $daytime) { // They are imp
if ($otherday < $daytime) { // They are arrested/dead or sum
$pushstring = [$data2[$param][2],$otherday,"after",$pushrole];
global $player;
array_push($player,$pushstring);
$adder = 1;
} else { // Not yet arrested/dead
$pushstring = [$data2[$param][2],$otherday,"before",$pushrole];
global $player;
array_push($player,$pushstring);
$adder = 1;
}
}
else { // They are not imp, nor arrested/murdered/or whatever
$pushstring = [$data2[$param][2],$impday,"before",$lifechangearray[$keys[0]][6]];
global $player;
array_push($player,$pushstring);
$adder = 1;
}
}
else {
$day = $lifechangearray[$adder][2]; // It for some reason removes the _, so its 21 rather than 2_1, which is genuinely a blessing
//echo "<script>console.log(`".$lifechangearray[$adder][0]."`);</script>"; // Debug code
//echo "<script>console.log(".$day.");</script>"; // Debug code
if ($day >= $daytime) {
$pushstring = [$data2[$param][1],$day,"before",$data2[$param][3]];
global $player;
array_push($player,$pushstring);
$adder = 1;
}
else {
$pushstring = [$data2[$param][2],$day,"after",$data2[$param][3]];
global $player;
array_push($player,$pushstring);
$adder = 1;
}
}
}
else {
$adder++;
findday($param);
}
}
function findrole($param) // todo: Check for frames. I check for al cover, but no one in my test game used frame so i dont wanna check if if i cant debug
{
global $data2, $role, $lifechangearray;
if (empty($param)) {
return;
}
else {
if (empty($data2[$param][1])){
return;
} else {// Checks if user has been moled, arrested, or murdered.
foreach ($lifechangearray as $sub_array) {
if (@$sub_array[0] === $data2[$param][0]) {
findday($param);
return true;
}
}
global $player;
$pushstring = [$data2[$param][1],[],[],$data2[$param][3]];
array_push($player,$pushstring);
return false;
}
}
}
function roleimage($classname)
{
if (empty($classname)){
echo "blank";
}
else {
echo $classname;
}
}
function printsidebar($sidebarnumber) //* made this so my html part of the code looks better.
{
global $data5, $user;
if(empty($data5[$sidebarnumber][3])) {
}else {
if($data5[$user][3]==$data5[$sidebarnumber][3]){
$output = $data5[$sidebarnumber][3] . " (You)";
echo $output;
}else{
echo $data5[$sidebarnumber][3];
}
}
}
function findeaths() //* Checks for changes to roles (moles, ih, maybe cover/frame), and cementation of roles (arrest/death/nothing)
{
global $data1, $findernumber, $matches, $lifechangearray;
$color = "";
$linenumber = "";
$dayof = "";
$died = "";
$moled = "";
$arrested = "";
$ih = "";
$ihdayof = "";
$mole_message = "In order to avoid prison, you have accepted a plea deal from AGENTs. You are now working for them";
if (empty($data1[$findernumber][9])) {
echo "<script>console.log('Life Change Array: %O', ".json_encode($lifechangearray)." );</script>"; // Debug code
}
else {
if (preg_match('/style="color:#fff;text-align:center;">[A-Za-z0-9]+\\.[A-Za-z0-9]+ was found dead under suspicious circumstances\\./i',$data1[$findernumber][9])) { // Checks if died
preg_match('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i',$data1[$findernumber][9], $matches, PREG_UNMATCHED_AS_NULL);
$color = implode(" ", $matches);
$linenumber = $findernumber;
$dayof = $data1[$findernumber][2];
$died = "Died";
}
if (str_contains($data1[$findernumber][9], $mole_message)) { // Checks if moled
preg_match('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i',$data1[$findernumber][9], $matches, PREG_UNMATCHED_AS_NULL);
$color = implode(" ", $matches);
$linenumber = $findernumber;
$dayof = $data1[$findernumber][2];
$moled = "Moled";
}
if (preg_match('/style="color:#fff;text-align:center;">[A-Za-z]+\\.[A-Za-z]+ was arrested last night\\./i',$data1[$findernumber][9])) { // Checks if arrested
preg_match('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i',$data1[$findernumber][9], $matches, PREG_UNMATCHED_AS_NULL);
$color = implode(" ", $matches);
$linenumber = $findernumber;
$dayof = $data1[$findernumber][2];
$arrested = "Arrested";
}
if (preg_match('/You have followed the Operation Leader\'s emergency protocols/i',$data1[$findernumber][9])) { // Checks if ih
preg_match('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i',$data1[$findernumber][9], $matches, PREG_UNMATCHED_AS_NULL);
$color = implode(" ", $matches);
$linenumber = $findernumber;
$dayof = $data1[$findernumber][2];
$ih = "Improvised";
$ihdayof = $data1[$findernumber][2];
}
if(empty($color)) {
$findernumber++;
findeaths();
}
else {
$push_array = [$color,$linenumber,$dayof,$died,$moled,$arrested,$ih,$ihdayof];
array_push($lifechangearray,$push_array);
$findernumber++;
findeaths();
}
}
}
function classimages($agentnumber, $style_top)
{
global $player, $user, $admin, $coverfind, $daytime, $data2;
$agent_class = "Agent Leader | Field Agent | Forensics Specialist | Mole (Converted Field Ops) | Mole (Converted Inv.) | Mole (Converted Offensive) | Runaway Snitch |";
$netsec_class = "Operation Leader | CCTV Specialist | Enforcer | Inside Man | Analyst | Network Specialist | Social Engineer | Blackhat | Improvised Hacker | Spearphisher | ";
$nuet_class = "Bounty Hunter | Corrupt Detective | Double-crosser | Journalist | Loose Cannon | Script Kiddie | Panicked Blabbermouth | Resentful Criminal | Sociopath | Rival Hacker | ";
if (empty($player[$agentnumber][0])) {
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/blank.png">';
return;
}
if ($player[$agentnumber][3] == 'Dead' || $player[$agentnumber][3] == 'Arrested' and $player[$agentnumber][2] == 'after') { // User, dead, always gets image
if ($data2[$agentnumber][0] == $coverfind[0][0] && $daytime < 40) {
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/classes/'.$coverfind[0][1].'.png">';
}
else {
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/classes/'.$player[$agentnumber][0].'.png">';
}
}
else {
if (str_contains($agent_class, $player[$agentnumber][0]) && str_contains($agent_class, $player[$user][0])){ // Check if current user is agent
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/classes/'.$player[$agentnumber][0].'.png">';
}
else {
if ($admin == 1) {
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/classes/'.$player[$agentnumber][0].'.png">';
}
else {
echo '<img style="top:'.$style_top.';left:398px;" class="agentimg" src="/images/blank.png">';
}
}
}
}
function findcover()
{
global $data1, $addman, $matches, $coverfind;
$color = "";
$role = "";
if (!empty($coverfind)) {
echo "<script>console.log('Cover: %O', ".json_encode($coverfind)." );</script>"; // Debug code
}
else {
if (preg_match('/have a cover as \'[^\']*\' in the event of an early /i',$data1[$addman][9])) { // Checks if died
preg_match('/\'[^\']*\'/i' ,$data1[$addman][9], $matches1,);
$role_before = implode("", $matches1);
$role = trim($role_before,"'"); // remove the ' characters
preg_match('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$addman][9], $matches2,);
$color = implode(" ", $matches2);
}
if(empty($color)) {
$addman++;
findcover();
}
else {
$push_array = [$color,$role];
array_push($coverfind,$push_array);
$addman++;
findcover();
}
}
}
function messages() // TODO: doesnt show the stupid fucking messages where it shows you tried to like hack or ddos, yknow, here: https://cdn.upload.systems/uploads/gIkMUSyd.png
{
global $data1, $helpmenumber, $daytime, $player, $user, $data2, $asc, $end, $lastday;
if (empty($data1[$helpmenumber][9])){
//done
}
else {
if ($asc == 1){ //* Should be impossible to reach if you arent agent
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][3] == 1 ) { //* ASC Chat
echo "<div>";
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches);
echo '<img class="avatarimg" src="/images/avatars/'.$matches[0][0].'">';
$param = '<tr> <td style="text-align:left;width:25%;"> <img src="../../avatars/'.$matches[0][0].'" style="width:48px;height:48px;"/> '.$matches[0][1].': </td> <td style="text-align:justify;width:75%;color: #ffc91b;;">';
$message_1 = str_replace($param,'',$data1[$helpmenumber][9]);
if (str_contains(str_replace('</td></tr>','',$message_1),'[!]')) { //! Needs Fix: Multiple Pings, as in [!][!], are not accounted for
$message = substr(str_replace('</td></tr>','',$message_1), 3);
echo '<div class="chatusername">'.$matches[0][1].': <div class="chatmessagehighlighted"><span style="color:#FFFF00;">[!]</span>'.$message.'</div></div>';
}
else {
$message = str_replace('</td></tr>','',$message_1);
echo '<div class="chatusername ">'.$matches[0][1].': <div class="chatmessage">'.$message.'</div></div>';
}
echo "</div>";
}
}else {
if (empty($data1[$helpmenumber][0]) && $data1[$helpmenumber][0] <= $daytime) { //* Day Change messages | has to be manual, so its like 150~ lines
{ // Messages
$endline = '<tr><td colspan="2" style="color:#fff;text-left;">No actions were committed this turn.</td></tr>';
$prepnight = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Preparation Night Chat Log «</td></tr>';
$day1 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 1 Chat Log «</td></tr>';
$night1 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 1 Chat Log «</td></tr>';
$day2 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 2 Chat Log «</td></tr>';
$night2 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 2 Chat Log «</td></tr>';
$day3 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 3 Chat Log «</td></tr>';
$night3 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 3 Chat Log «</td></tr>';
$day4 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 4 Chat Log «</td></tr>';
$night4 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 4 Chat Log «</td></tr>';
$day5 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 5 Chat Log «</td></tr>';
$night5 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 5 Chat Log «</td></tr>';
$day6 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 6 Chat Log «</td></tr>';
$night6 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 6 Chat Log «</td></tr>';
$day7 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 7 Chat Log «</td></tr>';
$night7 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 7 Chat Log «</td></tr>';
$day8 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 8 Chat Log «</td></tr>';
$night8 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 8 Chat Log «</td></tr>';
$day9 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 9 Chat Log «</td></tr>';
$night9 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 9 Chat Log «</td></tr>';
$day10 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Day 10 Chat Log «</td></tr>';
$night10 = '<tr><td colspan="2" style="color:#00ff01;text-align:right;font-size:1.5em;">Night 10 Chat Log «</td></tr>';
}
$param = $helpmenumber+1;
if ($data1[$helpmenumber][10] == 01 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> PREPARATION NIGHT</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 10 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 1</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 11 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 1</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 20 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 2</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 21 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 2</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 30 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 3</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 31 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 3</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 40 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 4</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 41 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 4</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 50 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 5</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 51 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 5</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 60 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 6</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 61 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 6</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 70 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 7</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 71 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 7</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 80 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 8</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 81 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 8</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 90 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 9</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 91 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 9</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 100 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> DAY 10</div>';
echo "</div>";
}
if ($data1[$helpmenumber][10] == 101 && $data1[$param][0] < $daytime && $data1[$param][9] !== $endline) {
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
echo '<div class="chatusername" style="color:#04ca15">>>>> Night 10</div>';
echo "</div>";
}
}
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][4] == 1 ) { //* Dead Chat
if ($player[$user][2] = "After" && $player[$user][3] = "Dead") {
echo "<div>";
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches);
echo '<img class="avatarimg" src="/images/avatars/'.$matches[0][0].'">';
$param = '<tr> <td style="text-align:left;width:25%;"> <img src="../../avatars/'.$matches[0][0].'" style="width:48px;height:48px;"/> '.$matches[0][1].': </td> <td style="text-align:justify;width:75%;color: #911eb4;;">';
$message_1 = str_replace($param,'',$data1[$helpmenumber][9]);
if (str_contains(str_replace('</td></tr>','',$message_1),'[!]')) { //! Needs Fix: Multiple Pings, as in [!][!], are not accounted for
$message = substr(str_replace('</td></tr>','',$message_1), 3);
echo '<div class="chatusernamedead">'.$matches[0][1].': <div class="chatmessagehighlighted"><span style="color:#FFFF00;">[!]</span>'.$message.'</div></div>';
}
else {
$message = str_replace('</td></tr>','',$message_1);
echo '<div class="chatusernamedead">'.$matches[0][1].': <div class="chatmessage">'.$message.'</div></div>';
}
echo "</div>";
}
}
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][5] == 1 ) { //* Alive Chat
echo "<div>";
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches);
echo '<img class="avatarimg" src="/images/avatars/'.$matches[0][0].'">';
$param = '<tr> <td style="text-align:left;width:25%;"> <img src="../../avatars/'.$matches[0][0].'" style="width:48px;height:48px;"/> '.$matches[0][1].': </td> <td style="text-align:justify;width:75%;color: #fff;;">';
$message_1 = str_replace($param,'',$data1[$helpmenumber][9]);
if (str_contains(str_replace('</td></tr>','',$message_1),'[!]')) { //! Needs Fix: Multiple Pings, as in [!][!], are not accounted for
$message = substr(str_replace('</td></tr>','',$message_1), 3);
echo '<div class="chatusername">'.$matches[0][1].': <div class="chatmessagehighlighted"><span style="color:#FFFF00;">[!]</span>'.$message.'</div></div>';
}
else {
$message = str_replace('</td></tr>','',$message_1);
echo '<div class="chatusername">'.$matches[0][1].': <div class="chatmessage">'.$message.'</div></div>';
}
echo "</div>";
//echo "<script>console.log('matrches: %O', ".json_encode($matches)." );</script>"; // Debug code
}
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][6] == 1 ) { //* Broadcast
echo "<div>";
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches);
echo '<img class="avatarimg" src="/images/blank.png">';
$message_1 = str_replace('<tr><td colspan="2"><pre><b>ANONYMOUS BROADCAST:</b>','',$data1[$helpmenumber][9]);
$message = str_replace('</pre></td></tr>','',$message_1);
echo '<div class="chatusername" style="color:#04ca15">New mail from undisclosed sender: <div class="chatmessage" style="color:#04ca15">[BROADCAST]'.$message_1.'</div></div>';
echo "</div>";
//echo "<script>console.log('matrches: %O', ".json_encode($matches)." );</script>"; // Debug code
}
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][7] == 1 ) { //* Mail
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches2);
if ($matches2[0][3] == $data2[$user][0]) { // Checks if its being sent TO the current user
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches2);
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
$text = '<tr><td><table><tbody><tr><td style="text-center;margin:auto;"> <img src="../../avatars/'.$matches2[0][0].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][1].' </td><td style="vertical-align:middle;">» » »</td> <td style="text-align:center;margin:auto;"> <img src="../../avatars/'.$matches2[0][2].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][3].' </td></tr></tbody></table></td><td><pre><b>Private message:</b>';
$broadcast_1 = str_replace($text, '', $data1[$helpmenumber][9]);
$broadcast_2 = str_replace('</pre></td></tr>', '', $broadcast_1);
$result = explode('<br/>',$broadcast_2); // Future refrence : This line removes everything after the br tag, only displaying the title of the mail, and not body.
echo '<div class="chatusername" style="color:#04ca15">New mail from '.$matches2[0][1].': <div class="chatmessage" style="color:#04ca15">'.$result[0].'</div></div>';
echo "</div>";
//echo "<script>console.log('matrches: %O', ".json_encode($matches)." );</script>"; // Debug code
}
if ($matches2[0][1] == $data2[$user][0]) { // Checks if its being sent FROM the current user
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches2);
echo "<div>";
echo '<img class="avatarimg" src="/images/blank.png">';
$text = '<tr><td><table><tbody><tr><td style="text-center;margin:auto;"> <img src="../../avatars/'.$matches2[0][0].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][1].' </td><td style="vertical-align:middle;">» » »</td> <td style="text-align:center;margin:auto;"> <img src="../../avatars/'.$matches2[0][2].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][3].' </td></tr></tbody></table></td><td><pre><b>Private message:</b>';
$broadcast_1 = str_replace($text, '', $data1[$helpmenumber][9]);
$broadcast_2 = str_replace('</pre></td></tr>', '', $broadcast_1);
$result = explode('<br/>',$broadcast_2); // Future refrence : This line removes everything after the br tag, only displaying the title of the mail, and not body.
echo '<div class="chatusername" style="color:#04ca15">The email \''.$result[0].'\' has been sent sucessfully to '.$matches2[0][3].'</div>';
echo "</div>";
//echo "<script>console.log('matrches: %O', ".json_encode($matches)." );</script>"; // Debug code
}
}
if ($data1[$helpmenumber][0] <= $daytime && $data1[$helpmenumber][8] == 1 ) { //* Votes
echo "<div>";
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$helpmenumber][9], $matches);
echo '<img class="avatarimg" src="/blank.png">';
$message_1 = str_replace('<tr><td colspan="2" style="color:#ff0001;text-align:center;font-size:1.0em;">','',$data1[$helpmenumber][9]);
$message = str_replace('</td></tr>','',$message_1);
echo '<div class="chatusername" style="color:#04ca15">'.$message.'</div>';
echo "</div>";
//echo "<script>console.log('matrches: %O', ".json_encode($matches)." );</script>"; // Debug code
}
}
$helpmenumber++;
messages();
}
}
function mail2() // TODO: Scrollbar, onclick show mail
{
global $data1, $daytime, $mailchecker, $data2, $user;
$i1 = count($data1);
while ($i1 > 0) { // Scrolls through until 0
if (empty($data1[$i1][9]) && $mailchecker == 1){
$i1 --;
}
if (empty($data1[$i1][9]) && $mailchecker == 0){
//done
}
else {
if ($data1[$i1][0] <= $daytime && $data1[$i1][6] == 1 ) { // echo broadcast
//echo "<script>console.log(2);</script>"; // Debug code
echo '<div class="mailholderinner">';
echo '<img style="width:36px;height:28px;float:left;" src="/images/mail.png">';
$broadcast_1 = str_replace('<tr><td colspan="2"><pre><b>ANONYMOUS BROADCAST:</b> ', '', $data1[$i1][9]);
echo '<div class="mailmessage">Undisclosed  <div class="mailmessage2">[BROADCAST] '.str_replace('</pre></td></tr>', '', $broadcast_1).'</div></div>';;
echo '</div>';
$mailchecker = 0;
}
if ($data1[$i1][0] <= $daytime && $data1[$i1][7] == 1 ) { // Echo mail
preg_match_all('/[A-Za-z0-9]+\\.[A-Za-z0-9]+/i' ,$data1[$i1][9], $matches2,);
if ($matches2[0][3] == $data2[$user][0]) {
echo '<div class="mailholderinner">';
echo '<img style="width:36px;height:28px;float:left;" src="/images/mail.png">';
$text = '<tr><td><table><tbody><tr><td style="text-center;margin:auto;"> <img src="../../avatars/'.$matches2[0][0].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][1].' </td><td style="vertical-align:middle;">» » »</td> <td style="text-align:center;margin:auto;"> <img src="../../avatars/'.$matches2[0][2].'" style="width:48px;height:48px;"/><br/> '.$matches2[0][3].' </td></tr></tbody></table></td><td><pre><b>Private message:</b>';
$broadcast_1 = str_replace($text, '', $data1[$i1][9]);
$broadcast_2 = str_replace('</pre></td></tr>', '', $broadcast_1);
$result = explode('<br/>',$broadcast_2); // Future refrence : This line removes everything after the br tag, only displaying the title of the mail, and not body.
echo '<div class="mailmessage">'.$matches2[0][1].'  <div class="mailmessage2">'.$result[0].'</div></div>';;
echo '</div>';
$mailchecker = 0;
}
}
}
$i1--;
}
if ($i1 == 0 && $mailchecker == 1) { // Checks if there is no mail
echo '<div class="mailholderinner">';
echo '<div class="mailempty">No emails yet.</div>';
echo '</div>';
return('done');
}
}
function checkforooc($role, $time)
{
global $classes, $player, $user, $day, $data1, $data2, $skills, $charges;
$i = 0;
while ($i < count($data1)){ //* We should theoretically put *every* ooc message, but i dont have that.
if ($data1[$i][2] == $time && str_contains($data1[$i][9],'('.$role.') You were occupied last night and failed to complete your task.')) {
return true;
}
$i++;
}
}
function capabilities() // TODO: Make it work with skills that give a random skill; ex. AL; check for skills that add to other skills, like create hideout.
{
global $daytime, $role, $classes, $player, $user, $day, $data1, $data2, $skills, $charges;
if ($daytime == 01) {
echo '<div class="prepcapabilities">Tonight\'s the night we meet.<br>The hack begins tomorrow.</div>';
}
else {
// Find out what role the player is via the role variable and comparing it with the classes array.
$i = 0;
while ($i < 16) {
if ($classes[$i][2] == $role) {
$i2 = 0;
while ($i2 < count($data1)) {
$html_param = 'used skill <a href="https://www.playuntrusted.com/manual/skills/#';
if (strpos($data1[$i2][9], ''.$data2[$user][0].':') == true && $data1[$i2][1] < $daytime && strpos($data1[$i2][9],$html_param) == true) { // Before today
if (strpos($data1[$i2][9], '</a> on') == true) { // Checks if the skill was used on someone/something
$text = str_replace(''.$data2[$user][0].': '.$data2[$user][0].' used skill', '', trim(strip_tags($data1[$i2][9])));
//$used_on = str_replace(' on', '',substr($text, strpos($text, ' on')));
$findit = explode(' on ', $text);
$used_on = $findit[1];
$used = trim($findit[0]); // We use trim because of a lone space at the start of the string.
if (checkforooc($data2[$user][0], $data1[$i2][1]) == false){
array_push($skills, [$data2[$user][0], $used, $used_on, $data1[$i2][1]]);
}
//echo "<script>console.log(`Used: ".$used.", Used on: ".$used_on."`);</script>"; // Debug code
}
else { // Used on self
$text = str_replace(''.$data2[$user][0].': '.$data2[$user][0].' used skill', '', trim(strip_tags($data1[$i2][9])));
$used = trim($text);
if (checkforooc($data2[$user][0], $data1[$i2][1]) == false){
array_push($skills, [$data2[$user][0], $used,'', $data1[$i2][1]]);
}
//echo "<script>console.log(`Used: ".$used."`);</script>"; // Debug code
}
}
if (strpos($data1[$i2][9], ''.$data2[$user][0].':') == true && $data1[$i2][1] == $daytime && strpos($data1[$i2][9],$html_param) == true) { // Today
if (strpos($data1[$i2][9], '</a> on') == true) { // Checks if the skill was used on someone/something
$text = str_replace(''.$data2[$user][0].': '.$data2[$user][0].' used skill', '', trim(strip_tags($data1[$i2][9])));
//$used_on = str_replace(' on', '',substr($text, strpos($text, ' on')));
$findit = explode(' on ', $text);
$used_on = $findit[1];
$used = trim($findit[0]); // We use trim because of a lone space at the start of the string.
if (checkforooc($data2[$user][0], $data1[$i2][1]) == false){
array_push($skills, [$data2[$user][0], $used, $used_on, $data1[$i2][1]]);
}
//echo "<script>console.log(`Used-T: ".$used.", Used on: ".$used_on."`);</script>"; // Debug code
}
else { // Used on self
$text = str_replace(''.$data2[$user][0].': '.$data2[$user][0].' used skill', '', trim(strip_tags($data1[$i2][9])));
$used = trim($text);
if (checkforooc($data2[$user][0], $data1[$i2][1]) == false){
array_push($skills, [$data2[$user][0], $used,'', $data1[$i2][1]]);
}
//echo "<script>console.log(`Used-T: ".$used."`);</script>"; // Debug code
}
}
$i2++;
}
echo "<script>console.log('Skills: %O', ".json_encode($skills)." );</script>"; // Debug code
echo "<script>console.log('Charges Object: %O', ".json_encode($charges)." );</script>"; // Debug code
if (substr($daytime, -1) == 0) { // Checks if it's daytime
$switch = 9; // Use this for the day-time skills, allows us to copy and paste the below code when we need to make changes
for ($i3 = 0; $i3 <= 4; $i3++){
if (!empty($classes[$i][$switch][$i3])) {
$charges_param = $charges[$role][$classes[$i][$switch][$i3]]['charges'];
$cd = $charges[$role][$classes[$i][$switch][$i3]]['cd'];
//look in $skills array for the skill and see how many times its been used
$i4 = 0;
$skills_param = 0;
$time_since_use = 'unset';
while ($i4 < count($skills)) {
if ($skills[$i4][1] == $classes[$i][$switch][$i3] && $skills[$i4][3] < $daytime) { // process to remove charges from skills that have been used
$skills_param++;
$time_since_use = $daytime-$skills[$i4][3];
}
$i4++;
}
// If the above function has been used, then echo we enter
if ($charges_param == 999999){
echo '<div class="capaholderinner">';
echo '<img style="width:50px;height:50px;float:left;" src="/images/skills/'.$classes[$i][$switch][$i3].'.png">';
echo '<div class="capaskill">'.$classes[$i][$switch][$i3].'<div class="capacharges"><img style="margin-top:18px;float:right;" src="/images/infinity.png"></div></div>';
echo '</div>';
}
else {
if ($skills_param >= 0) {
if ($charges_param-$skills_param === 0) { // Optimacy lower for unusable skills
echo '<div class="capaholderinner" style="opacity: 0.3;">';
echo '<img style="width:50px;height:50px;float:left;" src="/images/skills/'.$classes[$i][$switch][$i3].'.png">';
echo '<div class="capaskill">'.$classes[$i][$switch][$i3].'<div class="capacharges">'.$charges_param-$skills_param.'x</div></div>';
echo '</div>';
}
else {
if (!$time_since_use == 'unset'|| $time_since_use < $cd){ // If they are still on cooldown, make it unsuable
echo '<div class="capaholderinner" style="opacity: 0.3;">';
echo '<img style="width:50px;height:50px;float:left;" src="/images/skills/'.$classes[$i][$switch][$i3].'.png">';
echo '<div class="capaskill">'.$classes[$i][$switch][$i3].'<div class="capacharges">'.$charges_param-$skills_param.'x</div></div>';
echo '</div>';
}
else {
echo '<div class="capaholderinner">';
echo '<img style="width:50px;height:50px;float:left;" src="/images/skills/'.$classes[$i][$switch][$i3].'.png">';
echo '<div class="capaskill">'.$classes[$i][$switch][$i3].'<div class="capacharges">'.$charges_param-$skills_param.'x</div></div>';
echo '</div>';
}
}
}
else {
echo '<div class="capaholderinner">';
echo '<img style="width:50px;height:50px;float:left;" src="/images/skills/'.$classes[$i][$switch][$i3].'.png">';
echo '<div class="capaskill">'.$classes[$i][$switch][$i3].'<div class="capacharges">'.$charges_param.'x</div></div>';
echo '</div>';
}
}
}
}
}
else { // Its night-time
$switch = 10; // Use this for the night-time skills, allows us to copy and paste the above code when we need to make changes
for ($i3 = 0; $i3 <= 4; $i3++){
if (!empty($classes[$i][$switch][$i3])) {
$charges_param = $charges[$role][$classes[$i][$switch][$i3]]['charges'];
$cd = $charges[$role][$classes[$i][$switch][$i3]]['cd'];
//look in $skills array for the skill and see how many times its been used
$i4 = 0;
$skills_param = 0;
$time_since_use = 'unset';
while ($i4 < count($skills)) {
if ($skills[$i4][1] == $classes[$i][$switch][$i3] && $skills[$i4][3] < $daytime) { // process to remove charges from skills that have been used
$skills_param++;
$time_since_use = $daytime-$skills[$i4][3];
}
$i4++;
}