-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl_Flow.php
More file actions
1386 lines (1386 loc) · 89.7 KB
/
Control_Flow.php
File metadata and controls
1386 lines (1386 loc) · 89.7 KB
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
/**
* Open Source GPLv3
*/
declare(strict_types=1);
//declare(encoding='UTF-8');
declare(ticks=1);
namespace iZiTA
{
//<editor-fold desc="Initialization Process">
//<editor-fold desc="Check Startup">
$included_files = False;
((__FILE__ ?? $included_files = True ?: $included_files = True) === (get_included_files()[0] ?? $included_files = True ?: $included_files = True)) ? True : ($included_files === False ? False : True) and exit;
//</editor-fold>
date_default_timezone_set('UTC');
defined('iZiTA>Control_Flow') or exit;
defined('iZiTA>Array_Library') or define('iZiTA>Array_Library', False) or exit;
//<editor-fold desc="Test Use Settings">
error_reporting(error_level: E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set(option:'display_errors', value:'1');
ini_set(option:'display_startup_errors', value:'1');
//</editor-fold>
//</editor-fold>
/**
* iZiTA::Control_Flow<br>
* Script version: <b>202602.0.0.90</b><br>
* PHP Version: <b>8.5</b><br>
* <b>Info:</b><br>
* iZiTA::Control Flow is a library to manage execution and variable reads/writes based on accesses, usage state and execution.<br>
* <b>Details:</b><br>
* Call: Control_Flow::Construct('Rules Path', 'Execution Token') to initialize.<br>
* iZiTA::Control Flow can manage access to hooked variable read/writes and execution of a script, based on the execution of the script from a list of token of executions that are allowed. A list of allowed actions to be performed.
* @package iZiTA::Control_Flow
* @author : TheTimeAuthority
*/
Final Class Control_Flow
{
//<editor-fold desc="Control_Flow::Initialize [v4]">
/**
* The constructor for iZiTA::Control_Flow
* @param String $Token_Database_Path is the path to load the configuration file from.<br>
* If a file is not provided the script will exit.
* @param String $Execution_Token is the Token that allow the class to load.<br>
* If the Token is not correct the script will exit.
* @return Control_Flow|Bool Returns <b>Control_Flow::class Object</b> or <b>False</b> on failure.
*/
Final Static Function Construct(String $Token_Database_Path = '', String $Execution_Token = ''): Control_Flow|Bool
{
if(self::$is_it_Constructed === False and self::$is_Construct_Tried === False and self::$is_Construct_Tried = True)
{
$Constructor = False;
if($Constructor = new Control_Flow($Token_Database_Path, $Execution_Token) and self::$is_it_Constructed === True and isset($Constructor) === True and is_object($Constructor) === True and $Constructor instanceof \iZiTA\Control_Flow)
{
return $Constructor;
}
unset($Constructor);
}
return False;
}
/**
* The constructor for iZiTA::Control_Flow
*/
Final Private Function __construct(String $Token_Database_Path = '', String $Execution_Token = '')
{
if(isset($Token_Database_Path) === False or empty($Token_Database_Path) === True)
{
echo PHP_EOL.' [ I! ] ( Control_Flow Class ) Initialization failed. Empty configuration path.';
exit;
}elseif(isset($Execution_Token) === False or empty($Execution_Token) === True)
{
echo PHP_EOL.' [ I! ] ( Control_Flow Class ) Initialization failed. Empty execution token.';
exit;
}elseif(isset($this->is_configuration_loaded) === False and mb_detect_encoding($Token_Database_Path, 'UTF-8', True) === 'UTF-8' and mb_detect_encoding($Execution_Token, 'UTF-8', True) === 'UTF-8' and $this->is_Class_Allowed($Execution_Token) === True)
{
echo PHP_EOL.' [ I ] ( Control_Flow Class ) Initializing Control Flow Class.';
(require_once 'Array_Library.php') or exit;
(require_once 'Logger.php') or exit;
if(class_exists(\iZiTA\Array_Library::class, False) === True and enum_exists(\iZiTA\Array_Library::class, False) === False and isset($this->Array_Library) === False and $this->Array_Library = new \iZiTA\Array_Library and isset($this->Array_Library) === True and $this->Array_Library instanceof \iZiTA\Array_Library and isset($this->is_Array_Library) === False and $this->is_Array_Library = True and isset($this->is_Array_Library) === True and $this->is_Array_Library === True)
{
echo PHP_EOL.' [ I ] ( Control_Flow Class ) Control Flow loaded Array_Library.';
}else
{
echo PHP_EOL.' [ I ] ( Control_Flow Class ) Control Flow failed loading Array_Library.';
exit;
}
(class_exists(\iZiTA\Logger::class, False) === True and enum_exists(\iZiTA\Logger::class, False) === False) ?: exit;
$is_configuration_loaded = False;
if($is_configuration_loaded = ($this->Load_Configuration($Token_Database_Path) ?? False) and is_array($is_configuration_loaded) === True and empty($is_configuration_loaded) === False and isset($this->Control_Flow_Database) === False and $this->Control_Flow_Database = $is_configuration_loaded and isset($this->Control_Flow_Database) === True)
{
if($this->Control_Flow_Database === $is_configuration_loaded and $this->is_configuration_loaded = True and self::$is_it_Constructed = True)
{
echo PHP_EOL.' [ I ] ( Control_Flow Class ) Control Flow Database was loaded successfully.';
}else
{
echo PHP_EOL.' [ I! ] ( Control_Flow Class ) Error: Failed to save Control Flow Database rules. Exiting.';
exit;
}
}else
{
echo PHP_EOL.' [ I! ] ( Control_Flow Class ) Error: Failed loading Control Flow Database rules. Exiting.';
exit;
}
unset($is_configuration_loaded);
}else
{
echo PHP_EOL.' [ I! ] ( Control_Flow Class ) Initialization failed.';
exit;
}
}
/**
* Check if the Class is allowed to run.
* @param String $Execution_Token
* @return Bool Returns <b>True</b> if allowed to execute <b>False</b> otherwise.
*/
Private Function is_Class_Allowed(String $Execution_Token = ''): Bool
{
if(isset($this->is_configuration_loaded) === True or self::$is_it_Constructed === True)
{
return False;
}
if(isset($Execution_Token) === True and empty($Execution_Token) === False and mb_detect_encoding($Execution_Token, 'UTF-8', True) === 'UTF-8' and isset($Execution_Token[161]) === True and isset($Execution_Token[162]) === False)
{
$Execution_Token = (preg_replace("/[^a-zA-Z0-9:]/", '', $Execution_Token) ?? '') ?: '';
$HMAC_Secret_Key = explode(':',$Execution_Token)[0] ?? '' ?: '';
$Payload = explode(':',$Execution_Token)[1] ?? '' ?: '';
$Execution_Token = explode(':',$Execution_Token)[2] ?? '' ?: '';
$Day_Month_Year_Hour = hash('sha3-256', date("d:m:Y:H")) ?: '';
$Check = hash_hmac('SHA3-256', $Day_Month_Year_Hour.$Payload, $HMAC_Secret_Key);
$Execution_Token_File = '../Dba/InternalAccess/'.$Day_Month_Year_Hour.'/'.$Execution_Token.'.izita';
$Day_Month_Year_Hour = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
unset($Day_Month_Year_Hour);
if($Check === $Execution_Token and hash_equals($Check, $Execution_Token) === True and isset($Execution_Token_File[156]) === True and isset($Execution_Token_File[157]) === False and file_exists($Execution_Token_File) === True and filetype($Execution_Token_File) === 'file' and (filesize($Execution_Token_File) ?? 0) === 1)
{
$Execution_Token = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
unset($Execution_Token);
$read_execution_file = (file_get_contents($Execution_Token_File, length:1) ?? '') ?: '';
if(mb_detect_encoding($read_execution_file, 'UTF-8', True) === 'UTF-8')
{
$read_execution_file = (preg_replace("/[^2]/", '', $read_execution_file) ?? '') ?: '';
if($read_execution_file === '2' and file_put_contents($Execution_Token_File, '',LOCK_EX) === 0 and unlink($Execution_Token_File) === True)
{
$Execution_Token_File = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
unset($Execution_Token_File);
echo PHP_EOL.' [ I_CF ] ( is_Class_Allowed ) Class is allowed to initialize.';
return True;
}else
{
echo PHP_EOL.' [ I!CF ] ( is_Class_Allowed ) Error: Verifying execution access failed. No execution data.';
}
}else
{
echo PHP_EOL.' [ I!CF ] ( is_Class_Allowed ) Error: Verifying execution access failed. Wrong data format.';
}
}elseif(isset($Execution_Token_File[156]) === True and isset($Execution_Token_File[157]) === False and file_exists($Execution_Token_File) === False)
{
echo PHP_EOL.' [ I!CF ] ( is_Class_Allowed ) Error: Initialization of class is not allowed.';
}else
{
echo PHP_EOL.' [ I!CF ] ( is_Class_Allowed ) Error: Initialization data is malformed.';
}
}else
{
echo PHP_EOL.' [ I!CF ] ( is_Class_Allowed ) Error: Initialization data is malformed.';
}
return False;
}
/**
* Loads the configuration file to be used for the Control_Flow of the Class.
* @param String $Token_Database_Path Is the path to load the configuration from.
* @return array | Bool Returns the <b>database</b> as an array <b>False</b> otherwise.
*/
Private Function Load_Configuration(String $Token_Database_Path = ''): array|Bool
{
if(isset($this->is_configuration_loaded) === False and isset($this->Control_Flow_Database) === False and isset($this->Shadow_Control_Flow_Database) === True and empty($this->Shadow_Control_Flow_Database) === True and self::$is_it_Constructed === False)
{
if(isset($Token_Database_Path) === True and empty($Token_Database_Path) === False and is_string($Token_Database_Path) === True and mb_detect_encoding($Token_Database_Path, 'UTF-8', true) === 'UTF-8')
{
$Token_Database_Path_Extension = '';
$Token_Database_Path_Length = strlen($Token_Database_Path);
if($Token_Database_Path_Length > 5)
{# Get extension from the path string
$Token_Database_Path_Extension = ($Token_Database_Path[$Token_Database_Path_Length-6].$Token_Database_Path[$Token_Database_Path_Length-5].$Token_Database_Path[$Token_Database_Path_Length-4].$Token_Database_Path[$Token_Database_Path_Length-3].$Token_Database_Path[$Token_Database_Path_Length-2].$Token_Database_Path[$Token_Database_Path_Length-1] ?? '');
}
$Token_Database_Path_Length = 0;
unset($Token_Database_Path_Length);
clearstatcache(True, $Token_Database_Path);
if($Token_Database_Path_Extension === '.izita' and file_exists($Token_Database_Path) === True and filetype($Token_Database_Path) === 'file')
{# Load Execution Database and proceed.
$Token_Database_Path_Extension = '';
unset($Token_Database_Path_Extension);
$Token_Database_Size = (filesize($Token_Database_Path) ?? 0) ?: ($Token_Database_Size = 0);
if(is_int($Token_Database_Size) === False or $Token_Database_Size < 128 or $Token_Database_Size > 8192)
{# Exit on wrong database file size.
$this->Execution_Expelliarmus = True;
}
$Token_Database_Size = 0;
unset($Token_Database_Size);
$Load_Token_Database = '';
$Load_Token_Database = (file_get_contents($Token_Database_Path) ?? '') ?: ($Load_Token_Database = '');
$Token_Database_Path = '';
unset($Token_Database_Path);
if(empty($Load_Token_Database) === False and is_string($Load_Token_Database) === True and mb_detect_encoding($Load_Token_Database, 'UTF-8', true) === 'UTF-8' and str_contains($Load_Token_Database, '.') === True)
{# . | ; =
$Load_Token_Database = preg_replace("/[^A-Z_|=:;.]/", '', $Load_Token_Database) ?: $Load_Token_Database = '';
$Load_Token_Database = (explode('.', $Load_Token_Database) ?? '') ?: $Load_Token_Database = '';
$Control_Flow_Database = [];
$Positive_X = 0;
foreach($Load_Token_Database as $Current_Script_Depth)
{# Build Control_Flow_Database from the provided data. ( . is the Script_Depth ) ( explode | [0] is $Current_Script_Access ) ( Sub_Script_Depth is ; )
if($Current_Script_Depth === '' or empty($Current_Script_Depth) === True)
{
continue;
}
# # # START Struct
$Current_Action = '';
$Other_Actions = '';
$Equals_Sign_Key = '';
$Equals_Sign_Value = '';
[$Current_Action, $Other_Actions] = (explode('|', $Current_Script_Depth, 2) ?? '') ?: ($Current_Action = '')($Other_Actions = '');
if(empty($Current_Action) === False)
{
$Current_Action = (preg_replace("/[^A-Z_]/", '', $Current_Action) ?? '') ?: $Current_Action = '';
}
if(empty($Other_Actions) === False)
{
$Other_Actions = (preg_replace("/[^A-Z_=:;]/", '', $Other_Actions) ?? '') ?: $Other_Actions = '';
$Equals_Sign_Key = (explode('=', $Other_Actions, 1)[0] ?? '') ?: $Equals_Sign_Key = '';
$Equals_Sign_Value = (explode('=', $Other_Actions, 2)[1] ?? '') ?: $Equals_Sign_Value = '';
}
$is_valid_entry = false;
# # # END Struct
if(empty($Current_Script_Depth) === False and empty($Current_Action) === False and empty($Other_Actions) === False and isset($Equals_Sign_Key[0]) === True and isset($Equals_Sign_Value[0]) === True and isset($Equals_Sign_Value[1]) === True and $Equals_Sign_Value[strlen($Equals_Sign_Value)-1] === ';')
{# Validates execution control flow database
$Other_Actions = (explode(';', $Other_Actions) ?? '') ?: $Other_Actions = '';
foreach($Other_Actions as $Other_Action)
{
$Sub_Action = '';
$Sub_Action_Value = '';
[$Sub_Action, $Sub_Action_Value] = (explode('=', $Other_Action, 2) ?? '') ?: ($Sub_Action = False)($Sub_Action_Value = False);
if(isset($Sub_Action) === True and empty($Sub_Action) === False and is_string($Sub_Action) === True and isset($Sub_Action_Value) === True and empty($Sub_Action_Value) === False and is_string($Sub_Action_Value) === True and isset($Sub_Action_Value[60]) === False)
{# Validates and adds the sub script depth to the control flow database
$is_valid_entry = true;
$Control_Flow_Database[$Positive_X][$Current_Action][] = [$Sub_Action => $Sub_Action_Value];
$Sub_Action = '';
$Sub_Action_Value = '';
}
}
if($is_valid_entry === True)
{# Add array key index only if everything was valid.
$Positive_X++;
}
$Current_Action = '';
$Other_Actions = '';
$Sub_Script_Depth = 0;
}
}
$Positive_X = 0;
unset($Positive_X);
$Load_Token_Database = [];
unset($Load_Token_Database);
if(empty($Control_Flow_Database) === False and is_array($Control_Flow_Database) === True)
{
$OK_Status = $Control_Flow_Database;
$Control_Flow_Database = [];
unset($Control_Flow_Database);
return $OK_Status;
}
unset($Control_Flow_Database);
}
}else
{
echo PHP_EOL.' [ ! ] ( CF_LOAD_CONFIG ) Failed verifying the configuration file.';
exit;
}
}else
{
echo PHP_EOL.' [ ! ] ( CF_LOAD_CONFIG ) Empty configuration file.';
}
}else
{
echo PHP_EOL.' [ ! ] ( CF_LOAD_CONFIG ) Configuration already loaded.';
}
return False;
}
//</editor-fold>
//<editor-fold desc="Control_Flow::Terminate">
Final Function __destruct()
{
}
/**
* Spell caller.<br>
* @var bool This bool is used to stop the script execution on control flow validation error.
*/
Private Bool $Execution_Expelliarmus = False
{
get
{
$trampoline = $this->Execution_Expelliarmus;
$trampoline = null;
unset($trampoline);
return False;
}
set(Bool $Expelliarmus)
{
$this->Execution_Expelliarmus = True;
exit;
}
}
//<editor-fold desc="Override Hooked Functions">
/**
* Prevent cloning
* @throws \Exception
*/
Private Function __clone(): void {}
/**
* Prevent var_dump
* @throws \Exception
*/
Final Public Static Function __set_state(array $data): self
{
Throw New \Exception("Exporting state is not allowed for Control_Flow.");
}
/**
* Prevent Serialization.
* @throws \Exception
*/
Final Public Function __sleep(): array
{
Throw New \Exception("Serialization is not allowed for Control_Flow.");
}
/**
* Prevent Serialization.
* @throws \Exception
*/
Final Public Function __serialize(): array
{
Throw New \Exception("Serialization is not allowed for Control_Flow.");
}
/**
* Prevent Unserialization.
* @throws \Exception
*/
Final Public Function __wakeup(): void
{
Throw New \Exception("Unserialization is not allowed for Control_Flow.");
}
/**
* Prevent Unserialization.
* @throws \Exception
*/
Final Public Function __unserialize(array $data): void
{
Throw New \Exception("Unserialization is not allowed for Control_Flow.");
}
//</editor-fold>
//</editor-fold>
//<editor-fold desc="Private Variables">
//<editor-fold desc="Private Static Class fail-safe indicators [v1]">
Private Static Bool $is_Construct_Tried = False;
Private Static Bool $is_it_Constructed = False;
//</editor-fold>
//<editor-fold desc="Private Hooked Class Objects [v4]">
//<editor-fold desc="Private fail-safe indicators [v1]">
Private ReadOnly Bool $is_Array_Library;
//</editor-fold>
/**
* @var Object
* This is the <b>iZiTA::Array_Library</b> class object.<br>
* It will be used to access the shared functions inside the class.
*/
Private ?Object $Array_Library
{
get
{
if(isset($this->Array_Library) === True)
{
return $this->Array_Library;
}
return null;
}
set(?Object $Array_Library_Object)
{
if(isset($this->is_Array_Library) === False and isset($this->Array_Library) === False and isset($Array_Library_Object) === True and $Array_Library_Object instanceof \iZiTA\Array_Library)
{
if($this->Array_Library = $Array_Library_Object and isset($this->Array_Library) === True and $this->Array_Library instanceof \iZiTA\Array_Library)
{}else
{
$this->Array_Library = null;
}
}
$Array_Library_Object = null;
unset($Array_Library_Object);
}
}
//</editor-fold>
//<editor-fold desc="Private Structure Execution Controller Variables [v1]">
Private Bool $Current_Script_Set = False;
Private Bool $Current_Script_Times = False;
/**
* [ P ] Disables write access to the Execution Tokens.<br>
* When the boolean is True shared functions won't execute writes to the specified internal objects/variables/functions.
*/
Private Bool $is_Execution_Tokens_Writable = True;
/**
* [ P ] Disables access to the Execution Guard function for shared classes.
*/
Private Bool $OK_Access_Execution_Guard = False;
/**
* @var bool This variable is set to True when the execution of the selected variable is completed from inside the variable.
*/
Private Bool $Shadow_Execution_Token_OK_Status = False;
/**
* @var bool When this is set to True it returns the status (isset, empty, strlen, etc.) of the selected variable bypassing the getter code execution like emptying the variable on read.
*/
Private Bool $Shadow_Execution_Token_Bypass_Return = False;
Private Bool $Execution_Token_OK_Status = False;
/**
* @var bool When this is set to True call to Execution Token bypass the validation and return check.
*/
Private Bool $Execution_Token_Bypass_Return = False;
//</editor-fold>
//<editor-fold desc="Control Flow: Private Shadow Hooked Variables">
/**
* Execution_Guard with this verifies that you don't use future points to execute.<br>
* This is a Guard protection that enroll the next array points dynamically on execution for the <i>$Shadow_Control_Flow_Database</i>.
* @var array
*/
Private array $Shadow_Enroll_Guard = []
{
get
{
echo PHP_EOL.' [ + ] ( Shadow_Enroll_Guard ) Called Shadow Enroll Guard';
if(isset($this->Shadow_Enroll_Guard[0][0][1]['00101']) === True)
{
$this->Execution_Expelliarmus = True;
}
# Get Script Access Details
$Script_Depth = ($this->Script_Depth ?? 0);
$Current_Script_Access = ($this->Current_Script_Access ?? '');
$Sub_Script_Depth = ($this->Sub_Script_Depth ?? 0);
# / Get Script Access Details
if(isset($this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth]) === True)
{# This array index exists.
if(isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth]) === False and isset($this->Shadow_Enroll_Guard[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth]) === False)
{# This array index for Shadow_Control_Flow and Shadow_Enroll_Guard should not exist.
$Control_Flow_Database = $this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth];
$Shadow_Next_Array_Index = (key($Control_Flow_Database) ?? '') ?: '';
$Shadow_Next_Array_Key = (current($Control_Flow_Database) ?? '') ?: '';
if($Sub_Script_Depth > 0)
{
if(isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth - 1]) === True and isset($this->Shadow_Enroll_Guard[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth - 1]) === True and isset($this->Shadow_Enroll_Guard[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth][$Shadow_Next_Array_Index][$Shadow_Next_Array_Key]) === False)
{# The Shadow_Control_Flow_Database index in pos - 1 from this one should exist
$Out_Of_Bounds = False;
$Shadow_Control_Flow_Database = $this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access];
$Shadow_Control_Flow_Database = ($this->Array_Library->Array_Get_Last($Shadow_Control_Flow_Database, 4) ?? ['AA']);
//print_r($Shadow_Control_Flow_Database);
$Shadow_Last = 0;
if(is_array($Shadow_Control_Flow_Database) === True)
{
$Shadow_Last = count($Shadow_Control_Flow_Database)-1;
}
if(isset($Shadow_Control_Flow_Database[$Shadow_Last]) === True and empty($Shadow_Control_Flow_Database[$Shadow_Last]) === True)
{
$Shadow_Control_Flow_Database[$Shadow_Last] = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
}
if($Sub_Script_Depth !== ($Shadow_Last+1))
{
$Out_Of_Bounds = True;
}else
{
foreach($Shadow_Control_Flow_Database as $is_Valid)
{
if(is_string($is_Valid) === False or isset($is_Valid[63]) === False or isset($is_Valid[64]) === True)
{
$Out_Of_Bounds = True;
break;
}
}
}
if($Out_Of_Bounds === False)
{
$Set_Shadow_Control_Flow_Database = [];
$Set_Shadow_Control_Flow_Database = ($this->Shadow_Control_Flow_Database ?? []);
$Set_Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth][$Shadow_Next_Array_Index][$Shadow_Next_Array_Key] = '';
$this->Shadow_Control_Flow_Database = $Set_Shadow_Control_Flow_Database;
if($this->Shadow_Control_Flow_Database === $Set_Shadow_Control_Flow_Database)
{# Set the array out of order.
$this->Shadow_Enroll_Guard[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth][$Shadow_Next_Array_Index][$Shadow_Next_Array_Key] = '';
}else
{#
echo PHP_EOL.' [ ! ] ( Shadow_Enroll_Guard ) Critical: Error enrolling Shadow Control Flow.';
}
$Set_Shadow_Control_Flow_Database = [];
unset($Set_Shadow_Control_Flow_Database);
}else
{# Error: Out of bound database execution.
echo PHP_EOL.' [ ! ] ( Shadow_Enroll_Guard ) Critical: Error with Shadow Control Flow. Executions have been bypassed.';
}
}else
{# Previous line does not exist.
echo PHP_EOL.' [ ! ] ( Shadow_Enroll_Guard ) Previous line does not exist.';
}
}elseif($Sub_Script_Depth === 0)
{# We are at the beginning of a script depth.
echo PHP_EOL.' [ + ] ( Shadow_Enroll_Guard ) Setting line for the begin of a script depth.';
$Set_Shadow_Control_Flow_Database = $this->Shadow_Control_Flow_Database;
$Set_Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth][$Shadow_Next_Array_Index][$Shadow_Next_Array_Key] = '';
$this->Shadow_Control_Flow_Database = $Set_Shadow_Control_Flow_Database;
if($this->Shadow_Control_Flow_Database === $Set_Shadow_Control_Flow_Database)
{# Set the array out of order.
$this->Shadow_Enroll_Guard[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth][$Shadow_Next_Array_Index][$Shadow_Next_Array_Key] = '';
}else
{#
echo PHP_EOL.' [ ! ] ( Shadow_Enroll_Guard ) Critical: Error enrolling Shadow Control Flow.';
}
}
}else
{
echo PHP_EOL.' [ !! ] ( Shadow_Enroll_Guard ) Critical: The database is out of order.'.PHP_EOL;
}
}else
{
echo PHP_EOL.' [ !! ] ( Shadow_Enroll_Guard ) Error enrolling next control flow in: '.$Script_Depth.' : '.$Current_Script_Access.' : '.$Sub_Script_Depth;
}
return [''];
}
set(array $value)
{
$this->Shadow_Enroll_Guard[0][0][1] = '00101';
}
}
/**
* Execution_Guard with this verifies that script do not use the same used tokens.
* @var array
*/
Private array $Shadow_Control_Flow_Tokens = []
{
get
{
return $this->Shadow_Control_Flow_Tokens;
}
set(array $value)
{
if(isset($this->Shadow_Control_Flow_Tokens[';']) === False)
{
$this->Shadow_Control_Flow_Tokens[';'] = '';
$Set_Shadow_Control_Flow_Token = (array_key_last($value) ?? []) ?: $Set_Shadow_Control_Flow_Token = [];
$Shadow_Control_Flow_Tokens = $this->Shadow_Control_Flow_Tokens;
unset($Shadow_Control_Flow_Tokens[';']);
$Shadow_Control_Flow_Tokens[$Set_Shadow_Control_Flow_Token] = '';
if($Shadow_Control_Flow_Tokens === $value and strlen($Set_Shadow_Control_Flow_Token) === 64)
{
if(isset($this->Shadow_Control_Flow_Tokens[';']) === True)
{
echo PHP_EOL.' [ + ] ( Shadow_Control_Flow_Tokens ) TOKEN ENROLLED: '.$Set_Shadow_Control_Flow_Token;
unset($this->Shadow_Control_Flow_Tokens[';']);
$this->Shadow_Control_Flow_Tokens[] = $Set_Shadow_Control_Flow_Token;
}
}else
{
unset($this->Shadow_Control_Flow_Tokens[';']);
echo PHP_EOL.' [ ! ] ( Shadow_Control_Flow_Tokens ) Error writing tokens.';
}
}else
{
echo PHP_EOL.' [ ! ] ( Shadow_Control_Flow_Tokens ) Error writing: In Use.';
}
}
}
/**
* Execution_Guard with this verifies that you are not in another used flow point.
* @var array
*/
Private array $Shadow_Control_Flow_Database = []
{
get
{
return $this->Shadow_Control_Flow_Database;
}
set(array $value)
{# Can find the location verify it and set.
if(empty($value) === False)
{
$Set_Shadow_Control_Flow_Database = $this->Array_Library->Array_To_String($value, '#');
$Shadow_Control_Flow_Database = $this->Array_Library->Array_To_String($this->Shadow_Control_Flow_Database, '#');
$Shadow_Previous_Array_Value = '0';
$Shadow_Previous_Array_Index = '0';
$Current_Script_Access = $this->Current_Script_Access;
if(empty($this->Shadow_Control_Flow_Database) === False)
{
$Script_Depth = $this->Script_Depth;
$Sub_Script_Depth = $this->Sub_Script_Depth;
if(isset($this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth - 1]) === True and isset($this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth]) === True)
{# Setting value ^ | Already exists ^
$Control_Flow_Database = $this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth - 1];
$Shadow_Previous_Array_Key = key($Control_Flow_Database);
$Shadow_Previous_Array_Value = current($Control_Flow_Database);
$Shadow_Previous_Array_Index = $this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$Sub_Script_Depth - 1][$Shadow_Previous_Array_Key][$Shadow_Previous_Array_Value];
}
}
if($Shadow_Control_Flow_Database != $Set_Shadow_Control_Flow_Database and str_contains($Set_Shadow_Control_Flow_Database, $Shadow_Control_Flow_Database) === True)
{# Write the used token value.
$Separators = substr_count($Set_Shadow_Control_Flow_Database, '#');
if($Separators > 3)
{
$Sub_Index_OK_Message = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators];
$minus_val = 0;
if(strlen($Sub_Index_OK_Message) === 64)
{
if($Separators > 4)
{
$minus_val = 1;
}
}
$Sub_Index_OK_Message = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - $minus_val];
$minus_val += 1;
$Sub_Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - $minus_val];
$minus_val += 1;
$Index_Sub_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - $minus_val];
$minus_val += 1;
$Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - $minus_val];
$minus_val += 1;
$Control_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - $minus_val];
if(isset($value[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === True and isset($this->Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier]) === True and $this->Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier] === $Sub_Index_OK_Message)
{
$OK_Message_Status = $value[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message];
if(is_string($OK_Message_Status) === True and $OK_Message_Status === '' and isset($this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === False)
{# Create the next exec
$this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] = $OK_Message_Status;
echo PHP_EOL.' [ + ] ( Shadow_Control_Flow_Database ) Added: { '.$Control_Index.' '.$Index_Identifier.' '.$Index_Sub_Index.' '.$Sub_Index_Identifier.' '.$Sub_Index_OK_Message.' } to the database.';
}elseif(is_string($OK_Message_Status) === True and strlen($OK_Message_Status) === 64 and isset($this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === True and $this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] === '')
{# Add the token to the database
$this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] = $OK_Message_Status;
echo PHP_EOL.' [ + ] ( Shadow_Control_Flow_Database ) Added to: { '.$Control_Index.' '.$Index_Identifier.' '.$Index_Sub_Index.' '.$Sub_Index_Identifier.' '.$Sub_Index_OK_Message.' } this: '.$OK_Message_Status;
}else
{# Failed to enrol into the Database
echo PHP_EOL.' [ ! ] ( Shadow_Control_Flow_Database ) Array not written. Verification message error.';
}
}else
{
echo PHP_EOL.' [ !! ] ( Shadow_Control_Flow_Database ) Error writing access path. This access path does not exist.';
}
}
}elseif($Shadow_Previous_Array_Index === '')
{# Backwards write the used token value.
$Separators = substr_count($Set_Shadow_Control_Flow_Database, '#');
if($Separators > 10)
{
$Sub_Index_OK_Message = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators];
if(strlen($Sub_Index_OK_Message) === 64)
{
$Sub_Index_OK_Message = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 1];
$Sub_Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 2];
$Index_Sub_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 3];
$Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 4];
$Control_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 5];
if(isset($value[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === True and isset($this->Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier]) === True and $this->Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier] === $Sub_Index_OK_Message)
{
$OK_Message_Status = $value[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message];
if(is_string($OK_Message_Status) === True and strlen($OK_Message_Status) === 64 and isset($this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === True and $this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] === $OK_Message_Status)
{
$OK_Message_Status = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 6];
$Sub_Index_OK_Message = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 7];
$Sub_Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 8];
$Index_Sub_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 9];
$Index_Identifier = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 10];
$Control_Index = explode('#', $Set_Shadow_Control_Flow_Database)[$Separators - 11];
if(strlen($OK_Message_Status) === 64 and isset($this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message]) === True and $this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] === '')
{
echo PHP_EOL.' [ + ] ( Shadow_Control_Flow_Database ) Added to prev: { '.$Control_Index.' '.$Index_Identifier.' '.$Index_Sub_Index.' '.$Sub_Index_Identifier.' '.$Sub_Index_OK_Message.' } this: '.$OK_Message_Status;
$this->Shadow_Control_Flow_Database[$Control_Index][$Index_Identifier][$Index_Sub_Index][$Sub_Index_Identifier][$Sub_Index_OK_Message] = $OK_Message_Status;
}
}
}
}else
{
echo PHP_EOL.' [ ! ] ( Shadow_Enroll_Guard ) Failed to write backwards in Shadow_Control_Flow_Database.';
}
}
}else
{
echo PHP_EOL.' [ !! ] ( Shadow_Enroll_Guard ) Failed to write Shadow_Control_Flow_Database: '.$Set_Shadow_Control_Flow_Database;
}
}
}
}
/**
* @var string value is a verification execution token to be used for action validation.<br>
* Notice: The value is emptied after being read twice and can't be written while not empty.
*/
Private String $Shadow_Execution_Token = ''
{
get
{
if($this->Shadow_Execution_Token_Bypass_Return === True)
{# Bypasses the execution of get.
echo PHP_EOL.' [ N ] ( Shadow_Execution_Token ) Notice: Return bypass.';
$this->Shadow_Execution_Token_Bypass_Return = False;
if(empty($this->Shadow_Execution_Token) === False)
{# Fixes empty, strlen checks etc.
return 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
}else
{
return '';
}
}
$trampoline = $this->Shadow_Execution_Token;
if(str_contains($trampoline, ':') === True)
{
echo PHP_EOL.' [ P ] ( Shadow_Execution_Token ) Returned token { '.$trampoline.' } and emptied.';
$this->Shadow_Execution_Token = '';
$this->Shadow_Execution_Token_OK_Status = True;
return explode(':', $trampoline)[0];
}else
{
echo PHP_EOL.' [ P ] ( Shadow_Execution_Token ) Returned token { '.$trampoline.' }.';
if(empty($this->Shadow_Execution_Token) === False)
{
$this->Shadow_Execution_Token = $trampoline.':';
}
$this->Shadow_Execution_Token_OK_Status = True;
return $trampoline;
}
}
set(String $SET_Value)
{
$this->Shadow_Execution_Token_OK_Status = False;
if(empty($this->Shadow_Execution_Token) === True and isset($SET_Value) === True and is_string($SET_Value) === True and strlen($SET_Value) === 64 and str_contains($SET_Value, ':') === False)
{
echo PHP_EOL.' [ + ] ( Shadow_Execution_Token ) Wrote Shadow Execution Token { '.$SET_Value.' }.';
$this->Shadow_Execution_Token_OK_Status = True;
$this->Shadow_Execution_Token = $SET_Value;
}else
{
if(empty($this->Shadow_Execution_Token) === False)
{
echo PHP_EOL.' [ - ] ( Shadow_Execution_Token ) Failed at writing to Shadow Execution Token: Not empty.';
}else
{
echo PHP_EOL.' [ - ] ( Shadow_Execution_Token ) Failed at writing to Shadow Execution Token.';
}
}
}
}
//</editor-fold>
//<editor-fold desc="Control Flow: Private ReadOnly Variables">
/**
* This array defines the allowed control flow of the data that get checked.<br>
* This is a <b>set once</b> array.
*/
Private ReadOnly array $Control_Flow_Database;
//</editor-fold>
//<editor-fold desc="Control Flow: Private Hooked Variables">
/**
* @var int The current depth inside the script.<br>
* The result is in what function you are in from the ones checked.
*/
Private Int $Script_Depth = 0
{
get
{
return $this->Script_Depth;
}
set(Int $Set_SD)
{
$is_depth = $this->Script_Depth + 1;
if($is_depth === $Set_SD)
{# Allow only +1 values
$Current_Script_Access = ($this->Current_Script_Access ?? 'FAIL');
$is_Sub_Script_Depth = ($this->Sub_Script_Depth ?? 0);
if(isset($Current_Script_Access) === True and is_string($Current_Script_Access) === True and isset($is_Sub_Script_Depth) === True and is_integer($is_Sub_Script_Depth) === True and isset($this->Control_Flow_Database[$is_depth]) === True and isset($this->Control_Flow_Database[$this->Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth]) === True and isset($this->Control_Flow_Database[$this->Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth + 1]) === False and isset($this->Shadow_Control_Flow_Database[$is_depth]) === False and isset($this->Shadow_Control_Flow_Database[$this->Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth]) === True and isset($this->Shadow_Control_Flow_Database[$this->Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth + 1]) === False)
{# Checks before adding: next depth exist, if no next place exist, is at last depth.
$Shadow_Data = ($this->Shadow_Control_Flow_Database ?? 'FAIL');
$Enrol_Next_Depth = False;
$Shadow_Corruption_Status = 0;
if(is_array($Shadow_Data) === True and empty($Shadow_Data) === False)
{
$is_Shadow_Data = ($this->Array_Library->Array_Get_Last(Array: $Shadow_Data) ?? ['']);
$Enrol_Next_Depth = True;
foreach($is_Shadow_Data as $Check_Last)
{# Scan and verify all the previous Shadow_Control_Flow_Database.
$Shadow_Corruption_Status += 1;
if(is_string($Check_Last) === False or empty($Check_Last) or isset($Check_Last[63]) === False or isset($Check_Last[64]) === True)
{
$Enrol_Next_Depth = False;
break;
}
}
}
if($Enrol_Next_Depth === True)
{
if($this->Script_Depth < 9999)
{
echo PHP_EOL.' [ + ] ( Script_Depth ) Adding +1 to Script Depth.';
$this->Script_Depth += 1;
}else
{
echo PHP_EOL.' [ ! ] ( Script_Depth ) The Script_Depth have exceeded the allowed execution limit.';
$this->Execution_Expelliarmus = True;
}
}else
{
echo PHP_EOL.' [ ! ] ( Script_Depth ) Corruption at sub script depth. Script bypassed without verification at length: '.$Shadow_Corruption_Status;
$this->Execution_Expelliarmus = True;
}
}else
{
echo PHP_EOL.' [ ! ] ( Script_Depth ) Script depth can not be changed. Depth: '.$is_depth.' Sub: '.$is_Sub_Script_Depth;
}
}else
{
echo PHP_EOL.' [ ! ] ( Script_Depth ) Script depth can not be changed from: '.$is_depth.' to: '.$Set_SD;
}
}
}
/**
* @var int The current depth (sub script depth) inside a script depth.<br>
* The result is where inside an execution of a function the script is, in what sub execution (only the calls that validates).
*/
Private Int $Sub_Script_Depth = 0
{
get
{
return $this->Sub_Script_Depth;
}
set(Int $Set_SSD)
{
$Script_Depth = ($this->Script_Depth ?? 0);
$is_Sub_Script_Depth = $this->Sub_Script_Depth + 1;
$Current_Script_Access = ($this->Current_Script_Access ?? '');
if($Set_SSD === 0)
{# Set up the next Script_Depth.
$Script_Depth_Minus = 0;
$Sub_Depth_Start = $is_Sub_Script_Depth;
if($Script_Depth > 0)
{
$Script_Depth_Minus = $Script_Depth - 1;
}elseif($Script_Depth === 0)
{
$Sub_Depth_Start = 'fail';
}
$Old_Script_Access = key(($this->Control_Flow_Database[$Script_Depth_Minus]) ?? 'FAIL');
/*
* If on the previous script depth on Control and Shadow Flow Databases no more sub script depth exist
* and on current Shadow the first script depth does not exist THEN PROCEED
* [!] Else the script depth will be out of order and execution will stop.
*/
if(isset($Old_Script_Access) === True and is_string($Old_Script_Access) === True and isset($this->Control_Flow_Database[$Script_Depth_Minus][$Old_Script_Access]) === True and isset($this->Control_Flow_Database[$Script_Depth_Minus][$Old_Script_Access][$Sub_Depth_Start]) === False and isset($this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][0]) === True and isset($this->Shadow_Control_Flow_Database[$Script_Depth_Minus][$Old_Script_Access][$this->Sub_Script_Depth+1]) === False and isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][0]) === False and isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$this->Sub_Script_Depth+1]) === False)
{
echo PHP_EOL.' [ + ] ( Sub_Script_Depth ) Changing Script Depth to the begin of a script depth.';
$this->Sub_Script_Depth = 0;
$tmp_void = ($this->Shadow_Enroll_Guard ?? False) ?: False;
if(is_array($tmp_void) === False)
{
echo PHP_EOL.' [ ! ] ( Sub_Script_Depth ) Failed enrolling guard.';
}
$tmp_void = null;
unset($tmp_void);
}else
{
echo PHP_EOL.' [ ! ] ( Sub_Script_Depth ) Exiting: Out of bounds. [ ' . $this->Script_Depth.':' . $this->Sub_Script_Depth . ' ]';
$this->Execution_Expelliarmus = True;
}
}elseif($is_Sub_Script_Depth === $Set_SSD)
{# Set up the next Sub_Script_Depth
if(isset($this->Control_Flow_Database[$Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth]) === True and isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth]) === False and isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth-1]) === True)
{# If next Sub_Script_Depth that is to be enrolled is in Control_Flow_Database database and isn't in Shadow_Control_Flow_Database and on Shadow the current one exist.
$is_to_Enroll = False;
if(isset($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth - 2]) === True)
{# Verify that -2 is set before changing sub script depth to the next (the current) value.
$is_Registered = current((current(($this->Shadow_Control_Flow_Database[$Script_Depth][$Current_Script_Access][$is_Sub_Script_Depth - 2] ?? [])) ?? []));
if(isset($is_Registered) === True and is_string($is_Registered) === True and isset($is_Registered[63]) === True)
{
$is_to_Enroll = True;
}
}else
{
$is_to_Enroll = True;
}
if($is_to_Enroll === True)
{
if($this->Sub_Script_Depth < 9999)
{
echo PHP_EOL.' [ + ] ( Sub_Script_Depth ) Adding +1 to Sub_Script_Depth.';
$this->Sub_Script_Depth++;
$tmp_void = ($this->Shadow_Enroll_Guard ?? False) ?: False;
}else
{
echo PHP_EOL.' [ ! ] ( Sub_Script_Depth ) The Sub_Script_Depth have exceeded the allowed execution limit.';
}
}else
{
echo PHP_EOL.' [ ! ] ( Sub_Script_Depth ) The Sub_Script_Depth isn\'t to be enrolled. Incorrect Execution Flow.';
}
}else
{
echo PHP_EOL.' [ !! ] ( Sub_Script_Depth ) The Sub_Script_Depth isn\'t to be enrolled. Incorrect Execution Path.';
}
}else
{
echo PHP_EOL.' [ !! ] ( Sub_Script_Depth ) Illegal value set.';
}
}
}
/**
* @var string The execution token to be used for execution verification.<br>
* / This execution token verifies the execution of actions. Example: Reading writing to Client variables, executing functions or actions inside functions.
*/
Private String $Execution_Token = 'ac0e8e46f3fc327491d4a56ca3410b4e9f5d7294556ee38bc62e3d403b1fc5e4'#
{
get
{
if(isset($this->Execution_Token_Bypass_Return) === True and $this->Execution_Token_Bypass_Return === True)
{
echo PHP_EOL.' [ N ] ( Execution_Token ) Notice: Return bypass.';
$this->Execution_Token_Bypass_Return = False;
if(empty($this->Execution_Token) === False)
{# Fixes empty, strlen checks etc.
return 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
}else
{
return '';
}
}
$this->Execution_Token_OK_Status = False;
$is_exec_token = $this->Execution_Token;
$is_bypassed = '';
$this->Shadow_Execution_Token_Bypass_Return = False;
$is_bypassed = ($this->Shadow_Execution_Token ?? False) ?: False;
$Current_Script_Access = ($this->Current_Script_Access ?? '') ?: '';
if($is_bypassed === $is_exec_token)
{# Tokens match.
$is_script_depth = ($this->Script_Depth ?? False) ?: False;
$is_sub_script_depth = ($this->Sub_Script_Depth ?? False) ?: False;
if(isset($this->Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth+1]['READ_EXECUTION_TOKEN']) === True and isset($this->Shadow_Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth+1]) === False)
{# Enrol the next sub script depth to read the Execution Token when needed.
$this->Sub_Script_Depth += 1;
}else
{
echo PHP_EOL.' --- Untrue';
}
$is_sub_script_depth = ($this->Sub_Script_Depth ?? False) ?: False;
if(isset($this->Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']) === True)
{
if(isset($this->Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth-1]['READ_EXECUTION_TOKEN']) === False)
{# If last command is read do not empty Shadow Token because it is needed to verify the action.
$tmp_void = $this->Shadow_Execution_Token;
$tmp_void = '';
unset($tmp_void);
}
$is_Shadow = '';
$is_Shadow = isset($this->Shadow_Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']['OK_READ_EXEC_TOKEN:']);
$is_Shadow_Text = $this->Shadow_Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']['OK_READ_EXEC_TOKEN:'] ?: $is_Shadow_Text = False;
if($is_Shadow === True and is_string($is_Shadow_Text) === True and empty($is_Shadow_Text) === True)
{# Set execution token for the action
$Set_Completed_Value = $this->Shadow_Control_Flow_Tokens;
$Set_Completed_Value[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']['OK_READ_EXEC_TOKEN:'] = $this->Execution_Token;
$this->Shadow_Control_Flow_Tokens = $Set_Completed_Value;
}
if(isset($this->Shadow_Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]) === True and isset($this->Shadow_Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth + 1]) === False)
{# Set token if previous execution flow exist and next doesn't
if(isset($this->Control_Flow_Database[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']) === True and $is_Shadow === True and empty($is_Shadow_Text) === True)
{# Write the execution token for this execution
echo PHP_EOL.' [ + ] ( Execution_Token ) Bypassed read : Script_Depth: '.$is_script_depth.' | Sub_Script_Depth: '.$is_sub_script_depth.' | Current Sub_Script_Depth: '.$this->Sub_Script_Depth;
$Shadow_Clone = [];
$Shadow_Clone = $this->Shadow_Control_Flow_Database;
$Shadow_Clone[$is_script_depth][$Current_Script_Access][$is_sub_script_depth]['READ_EXECUTION_TOKEN']['OK_READ_EXEC_TOKEN:'] = $this->Execution_Token;
$this->Shadow_Control_Flow_Database = $Shadow_Clone;
if($this->Shadow_Control_Flow_Database !== $Shadow_Clone)
{
echo PHP_EOL.' [ !! ] ( Execution_Token ) Critical: Failed to set the token on the shadow control flow database.';
}
}else
{
echo PHP_EOL.' [ ! ] ( Execution_Token ) Execution token failed to set the token.';
}
}
$this->Execution_Token_OK_Status = True;
return $is_exec_token;
}else
{
echo PHP_EOL.' [ ! ] ( Execution_Token ) Not bypassed. : '.$is_sub_script_depth.' : '.$this->Sub_Script_Depth;
}
}else
{
echo PHP_EOL.' [ ! ] ( Execution_Token ) Not bypassed. Depth: [ '.$this->Sub_Script_Depth . ' ] Execution Token: [' . $is_exec_token .' ] Shadow Execution Token: '. $is_bypassed;
}
return '';
}
set(String $value)
{
$this->Execution_Token_OK_Status = False;
$is_depth = 0;
$is_exec_token = $this->Execution_Token;
$Current_Script_Access = $this->Current_Script_Access;
if($Current_Script_Access === 'WRITE_EXECUTION_TOKEN')
{# Check if we are on Script_Depth or Sub_Script_Depth
$is_depth = $this->Script_Depth;
$this->Shadow_Execution_Token = $is_exec_token;
$this->Shadow_Execution_Token_OK_Status = False;