-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasics.inc
8698 lines (7865 loc) · 606 KB
/
basics.inc
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
////////////////////////////////////////////////////////////////////////////////
// File name : basics.inc //
// Version : 21.2 //
// Begin : 2020-07-21 //
// Last Change : 2021-09-30 //
// Author : FeRox Management Consulting GmbH & Co. KG //
// Adolf-Langer-Weg 11a, D-94036 Passau (Germany) //
// https://www.ferox.de - info@ferox.de //
// License : GNU-GPL v3 (https://opensource.org/licenses/GPL-3.0) //
// -------------------------------------------------------------------------- //
// fx-project - An open source PHP Project Managament Software //
// Copyright © FeRox Management Consulting GmbH & Co. KG //
// -------------------------------------------------------------------------- //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
// //
// See ../LICENSE.TXT file for more information. //
// -------------------------------------------------------------------------- //
// LICENSING ADDENDUM: //
// Programs in the SPP (Special Programs) subfolder are coded extensions of //
// the open source software fx-project. These programs are offered for sale //
// by the manufacturer FeRox Management Consulting GmbH & Co. KG and require //
// a valid key for execution. It is forbidden to resell these programs //
// and/or keys or to pass them on free of charge or use them without the //
// express written permission of FeRox Management Consulting GmbH & Co. KG. //
////////////////////////////////////////////////////////////////////////////////
/**
* @file
* Set all definitions, variables and necessary dynamic paths.
* Contains all basic functions.
* Includes all basic subprograms and classes.
*
* @author FeRox Management Consulting GmbH & Co. KG, Adolf-Langer-Weg 11a, D-94036 Passau (Germany)
* @version 21.2
*/
$GLOBALS['__loaded_'.basename(__FILE__)]=true;
set_time_limit(0);
// Block screen display until headers are sent
ob_start();
////////////////////////////////////////////////////////////////////////////////
// DEBUG MODE
////////////////////////////////////////////////////////////////////////////////
// Debug level (bits)
define('FXP_DEBUG_OFF', 0); // Off
define('FXP_DEBUG_MAX', 1); // Bit 0 - Maximum: All debug messages (level 1 or higher)
define('FXP_DEBUG_DEF', 2); // Bit 1 - Default: Normal debug messages (level 2 or higher)
define('FXP_DEBUG_MIN', 4); // Bit 2 - Minimum: Special debug messages (level 3 or higher)
define('FXP_DEBUG_FIL', 8); // Bit 3 - Names of (optional) included files
define('FXP_DEBUG_FCT', 16); // Bit 4 - All function calls
define('FXP_DEBUG_PST', 32); // Bit 5 - Superglobals: POST + GET
define('FXP_DEBUG_TIM', 64); // Bit 6 - Runtimes
define('FXP_DEBUG_MEM', 128); // Bit 7 - Memory consumption
define('FXP_DEBUG_INF', 256); // Bit 8 - fx-project special: Global runtime + memory
define('FXP_DEBUG_FRM', 512); // Bit 9 - fx-project special: Framework routines
define('FXP_DEBUG_MST', 1024); // Bit 10 - fx-project special: Mask statuses
define('FXP_DEBUG_VAL', 2048); // Bit 11 - fx-project special: Default validation routines
define('FXP_DEBUG_ALL', FXP_DEBUG_MAX|FXP_DEBUG_FIL|FXP_DEBUG_FCT|FXP_DEBUG_PST|FXP_DEBUG_TIM|FXP_DEBUG_MEM|FXP_DEBUG_INF|FXP_DEBUG_FRM|FXP_DEBUG_MST|FXP_DEBUG_VAL); // All debug messages
// Array that contains as keys the program names to be debugged and as value the debug level and/or special debug modes
if(!isset($GLOBALS['__debug']) || !is_array($GLOBALS['__debug']))
$GLOBALS['__debug']=array();
if(!isset($GLOBALS['__debug']['debugmode']))
$GLOBALS['__debug']['__DBG']=0;
if(!isset($GLOBALS['__DGBLVL']))
$GLOBALS['__DGBLVL']=0;
// Debug this file? (Uncomment the next line)
//$GLOBALS['__debug'][__FILE__]=1;
////////////////////////////////////////////////////////////////////////////////
// DEFINITIONS
////////////////////////////////////////////////////////////////////////////////
// ...Version (= max version from subfiles)
define('FXP_VERSION', '21.2');
// ...Charset/Locale
define('FXP_CHARSET', 'UTF-8');
define('FXP_LOCALE', 'de_DE.UTF-8');
// ...Action modes
define('FXP_DISPLAY', 1);
define('FXP_CREATE', 2);
define('FXP_CHANGE', 3);
define('FXP_DELETE', 4);
// ...Newline for email class
define('CRLF', $GLOBALS['nl_b']);
// ...User statuses
define('FXP_USER_NEW', 0);
define('FXP_USER_ACTIVE', 1);
define('FXP_USER_INACTIVE', 2);
define('FXP_USER_LOCKED', 3);
// ...Text reference types
define('FXP_TRT_TABLE', 1);
define('FXP_TRT_MASK', 2);
define('FXP_TRT_FIELD', 3);
define('FXP_TRT_UNUSED_4', 4);
define('FXP_TRT_UNUSED_5', 5);
define('FXP_TRT_PROGRAM', 6);
// Person types (Value from table "references", field 30)
define('FXP_PT_CLIENT', 274); // Client
define('FXP_PT_CLIENT_CP', 2090); // Client's contact person
define('FXP_PT_CUSTOMER', 276); // Customer
define('FXP_PT_CUSTOMER_CP', 620); // Customer's contact person
define('FXP_PT_PARTNER', 2091); // Contract partner
define('FXP_PT_PARTNER_CP', 2092); // Contract partner's contact person
define('FXP_PT_EMPLOYEE', 275); // Employee (internal)
define('FXP_PT_CONTRACTOR', 840); // Contractor (external)
define('FXP_PT_CONTACT', 1372); // Contact
define('FXP_PT_CONTACT_CP', 841); // Contact's contact person
// Gender types
define('FXP_GT_MALE', 8); // male
define('FXP_GT_FEMALE', 9); // female
define('FXP_GT_DIVERSE', 2802); // diverse
// Project types (Value from table "category", mastercategory 57)
define('FXP_PRJ_MAIN', 59); // Main project / Mother project
define('FXP_PRJ_SUB', 60); // Sub-project
define('FXP_PRJ_TASK', 61); // Task
// Project status (Value from table "references", field 137)
define('FXP_PS_PLANNED', 297);
define('FXP_PS_INACTIVE', 299);
define('FXP_PS_ACTIVE', 300);
define('FXP_PS_COMPLETED', 301);
// Time entries (Value from table "references", field 336)
define('FXP_TE_TIMEREC', 101); // Time recording entry
define('FXP_TE_PROJECT', 102); // Project time data entry
define('FXP_TE_ABSENCES', 103); // Absence/Missing days entry
define('FXP_TE_CARRY_MONTH', 104); // Time recording: Monthly calculated carryover entry
define('FXP_TE_CARRY_START', 105); // Time recording: Start carryover entry
define('FXP_TE_TIMEREC_SUM', 110); // Time recording sum entry
define('FXP_TE_MATUSAGE', 1995); // Material usage recording entry
define('FXP_TE_TRAVELEXP', 2225); // Travel expanses entry
define('FXP_TE_TRAVELEXP_TIMEREC', 2273); // Travel expanses entry with time recording
// Time units (Value from table "references", field 330)
define('FXP_TU_HOUR', 484); // Hour
define('FXP_TU_PERSDAY', 485); // Person day / Man day
define('FXP_TU_PERSWEEK', 923); // Person week / Man week
define('FXP_TU_PERSMONTH', 486); // Person month / Man month
define('FXP_TU_PERSYEAR', 487); // Person year / Man year
// Appointment/Absent types (Value from table "references", field 434)
define('FXP_AT_REMINDER', 180);
define('FXP_AT_INVITATION', 187);
define('FXP_AT_MILESTONE', 375);
define('FXP_AT_MEETING', 661);
define('FXP_AT_CONFERENCE', 662);
define('FXP_AT_BUSINESSDINNER', 718);
define('FXP_AT_CONTACT', 719);
define('FXP_AT_MESSAGE', 971);
define('FXP_AT_PROJECTMESSAGE', 1131);
define('FXP_AT_PRIVATE', 720);
define('FXP_AT_TODO', 976);
define('FXP_AT_VACATIONREQUEST', 1178);
define('FXP_AT_VACATION', 1039);
define('FXP_AT_SPECIALVACATIONREQUEST', 2877);
define('FXP_AT_SPECIALVACATION', 2878);
define('FXP_AT_TRAININGREQUEST', 2106);
define('FXP_AT_TRAINING', 1468);
define('FXP_AT_SICKCALL', 2105);
define('FXP_AT_SICK', 1040);
define('FXP_AT_SLIDINGDAYREQUEST', 1940);
define('FXP_AT_SLIDINGDAY', 1941);
define('FXP_AT_OVERTIMEOUTPAYREQUEST', 1942);
define('FXP_AT_OVERTIMEOUTPAY', 1943);
define('FXP_AT_ABSENT', 2879);
define('FXP_AT_VARIOUS', 2297);
// Appointment/Absent categories
define('FXP_AC_VARIOUS', 0);
define('FXP_AC_PRIVATE', 1);
define('FXP_AC_BUSINESS', 2);
define('FXP_AC_ABSENT', 3);
// Holiday lengths (Value from table "references", field 1167)
define('FXP_HL_FULL', 2174); // Full Day
define('FXP_HL_HALF', 2175); // Half Day
define('FXP_HL_DISPLAY', 2176); // Display Only
// Bit mask for appointment roles
define('FXP_BAR_SYSADMIN', 128);
define('FXP_BAR_EXECUTIVE', 64);
define('FXP_BAR_MANAGEMENT', 32);
define('FXP_BAR_PROJECTLEAD', 16);
define('FXP_BAR_DEPARTMENTLEAD', 4);
define('FXP_BAR_SUPERVISOR', 2);
define('FXP_BAR_SELF', 1);
// Invoice types (Value from table "references", field 69)
define('FXP_INV_FIX', 483); // Fixed Price
define('FXP_INV_HOUR', 639); // On a per hour basis
define('FXP_INV_MAT_HU', 645); // On a per hour or unit basis
define('FXP_INV_DAYRATE', 646); // On a daily rate basis ---< not yet implemented >---
define('FXP_INV_NOT', 640); // Not invoiceable
// Chartdirector display types
define('FXP_CT_LINE', 0);
define('FXP_CT_AREA', 1);
define('NoValue', 1.7E+308);
// Scheduler program types (Value from table "references", field 1209)
define('FXP_SDL_EMAIL', 2693); // Send emails
define('FXP_SDL_WARNING', 2695); // Check project warnings
define('FXP_SDL_TIMEREC', 2166); // Check time recordings
////////////////////////////////////////////////////////////////////////////////
// OS SETTINGS + LOCALE + CHARSET
////////////////////////////////////////////////////////////////////////////////
fxSetOS(FXP_LOCALE, FXP_CHARSET);
////////////////////////////////////////////////////////////////////////////////
// VARIABLES
////////////////////////////////////////////////////////////////////////////////
// ...Current date and time in format YYYYMMDDhhmmss
$GLOBALS['datetime']=fxNow();
$GLOBALS['date']=substr($GLOBALS['datetime'],0,8);
// ...Error and/or success handling
$GLOBALS['err']=false; // Global error variable
$GLOBALS['ema']=array(); // Global error message array with keys, titles + messages
// ...Separators used in text files when returning via AJAX to javascript
$GLOBALS['_divstr']=array('!-0-!', '!-1-!', '!-2-!');
// ...Array of all fx-project subpaths
$GLOBALS['_subpath_array']=array();
// ...Min. program type and year
$GLOBALS['_min_pf_type']=10; // Min. for each user is program function type 10 (= User program)
$GLOBALS['_min_year']=1900; // Min. valid year
// ...Field types
$GLOBALS['_ftypes'] = array(
1=>'text', // 1 = Text
'autoinkrement', // 2 = Serial
'memo', // 3 = Memo
'ja/nein', // 4 = Bit
'ganzzahl', // 5 = Integer
'dezimal', // 6 = Decimal
'datum', // 7 = Date
'userformat', // 8 = User Format
'zeit', // 9 = Time
'datetime', // 10 = Date + Time
'betrag', // 11 = Amount
'ganzzahllang', // 12 = Long Integer
'systemvariable', // 13 = System
'zeitspanne', // 14 = Timespan
'text4000', // 15 = Long Text
'budget_int', // 16 = Internal Budget
'budget_ext', // 17 = External Budget
99=>'ganzzahl_tz' // 99 = Integer (with Thousand Separator)
);
// ...Database types
$GLOBALS['_dbtype']='';
$GLOBALS['_dbtypes']=array(
// 1 = PostgreSQL
1=>array(
'type'=>'pgsql',
'text'=>'PostgreSQL', 'alt1'=>'Postgres',
// Field types in database
'ftypes'=>array(
1=>'VARCHAR', // 1 = Text
'SERIAL', // 2 = Serial
'TEXT', // 3 = Memo
'INT2', // 4 = Bit
'INT8', // 5 = Integer
'DECIMAL(22,4)', // 6 = Decimal
'VARCHAR(14)', // 7 = Date
'VARCHAR', // 8 = User Format
'VARCHAR(14)', // 9 = Time
'VARCHAR(14)', // 10 = Date + Time
'DECIMAL(22,4)', // 11 = Amount
'INT8', // 12 = Long Integer
'VARCHAR', // 13 = System
'INT8', // 14 = Timespan
'TEXT', // 15 = Long Text
'DECIMAL(22,4)', // 16 = Internal Budget
'DECIMAL(22,4)', // 17 = External Budget
99=>'INT8' // 99 = Integer (with Thousand Separator)
)
),
// 2 = MS SQLServer
2=>array(
'type'=>'sqlsrv',
'text'=>'SQLServer', 'alt1'=>'MSSQL', 'alt2'=>'MSSQLServer',
// Field types in database
'ftypes'=>array(
1=>'VARCHAR', // 1 = Text
'INT IDENTITY(1,1)', // 2 = Serial
'TEXT', // 3 = Memo
'INT', // 4 = Bit
'INT', // 5 = Integer
'DECIMAL(22,4)', // 6 = Decimal
'VARCHAR(14)', // 7 = Date
'VARCHAR', // 8 = User Format
'VARCHAR(14)', // 9 = Time
'VARCHAR(14)', // 10 = Date + Time
'DECIMAL(22,4)', // 11 = Amount
'INT', // 12 = Long Integer
'VARCHAR', // 13 = System
'INT', // 14 = Timespan
'TEXT', // 15 = Long Text
'DECIMAL(22,4)', // 16 = Internal Budget
'DECIMAL(22,4)', // 17 = External Budget
99=>'INT' // 99 = Integer (with Thousand Separator)
)
)
);
////////////////////////////////////////////////////////////////////////////////
// INCLUDER
////////////////////////////////////////////////////////////////////////////////
// Array that contains as keys the program names to be included by the includer file.
// This array will be filled by each program with their requirements.
if(!isset($GLOBALS['__includer']) || !is_array($GLOBALS['__includer']))
$GLOBALS['__includer']=array();
// ...Globals
$GLOBALS['fxpglobals']=array();
$GLOBALS['fxptdata']=array();
$GLOBALS['fxpselects']=array();
$GLOBALS['fxpvars']=array('trrights'=>array(),'messages'=>array(),'msgarr'=>array(),'ibuffer'=>array(),'bbuffer'=>array());
$GLOBALS['_maskcounter']=0;
$GLOBALS['_fieldcounter']=0;
$__dagpia=array('no_headers', 'inapp', 'insync');
foreach($__dagpia as $__dagpi)
{
if(isset($GLOBALS[$__dagpi]))
{
if(fxIsArray($_GET) && isset($_GET[$__dagpi]))
{
unset($_GET[$__dagpi]);
if(isset($GLOBALS[$__dagpi]))
unset($GLOBALS[$__dagpi]);
}
if(fxIsArray($_POST) && isset($_POST[$__dagpi]))
{
unset($_POST[$__dagpi]);
if(isset($GLOBALS[$__dagpi]))
unset($GLOBALS[$__dagpi]);
}
}
}
// ...Appointment category array
$_tca=array(
FXP_AC_PRIVATE => FXP_AT_PRIVATE,
FXP_AC_BUSINESS => FXP_AT_MEETING.', '.FXP_AT_CONFERENCE.', '.FXP_AT_BUSINESSDINNER.', '.FXP_AT_CONTACT.', '.FXP_AT_MESSAGE.', '.FXP_AT_TODO.', '.FXP_AT_PROJECTMESSAGE,
FXP_AC_ABSENT => FXP_AT_ABSENT.', '.FXP_AT_VACATION.', '.FXP_AT_VACATIONREQUEST.', '.FXP_AT_SPECIALVACATION.', '.FXP_AT_SPECIALVACATIONREQUEST.', '.FXP_AT_SICK.', '.FXP_AT_SICKCALL.', '.FXP_AT_TRAINING.', '.FXP_AT_TRAININGREQUEST.', '.FXP_AT_SLIDINGDAY.', '.FXP_AT_SLIDINGDAYREQUEST,
FXP_AC_VARIOUS => FXP_AT_REMINDER.', '.FXP_AT_INVITATION.', '.FXP_AT_VARIOUS
);
////////////////////////////////////////////////////////////////////////////////
// DYNAMIC PATHS
////////////////////////////////////////////////////////////////////////////////
fxSetDynamicPaths();
////////////////////////////////////////////////////////////////////////////////
// SESSION ENVIRONMENT
////////////////////////////////////////////////////////////////////////////////
fxSetSession();
if($GLOBALS['locseskey'] === 'new')
{
@header('HTTP/1.1 301 Moved Permanently');
@header('location: '.$GLOBALS['__server_array']['url'].'index.php');
die;
}
////////////////////////////////////////////////////////////////////////////////
// HTML HEADERS
////////////////////////////////////////////////////////////////////////////////
if(!isset($GLOBALS['no_headers']))
{
@header('Content-type: text/html; charset='.FXP_CHARSET);
// Send additional headers?
if(fxIsArray($GLOBALS['__headers']))
{
foreach($GLOBALS['__headers'] as $htext)
@header($htext);
}
}
// Allow screen display again
$_pre_content=ob_get_contents();
ob_end_clean();
if(strlen($_pre_content))
echo($_pre_content);
////////////////////////////////////////////////////////////////////////////////
// SESSION
////////////////////////////////////////////////////////////////////////////////
if(!strlen($GLOBALS['locstoid']) || !strlen($GLOBALS['sesstoid']) || !strlen($GLOBALS['locseskey']) || !$GLOBALS['locseschecked'])
{
echo('<!DOCTYPE html>');
echo('<html style="width:100%;height:100%;font-family:verdana,arial,helvetica,sans-serif; font-size:12px;">');
echo('<head><title>fx-project: JavaScript Checker</title></head>');
echo('<body style="width:100%;height:100%;margin:0;padding:0;">');
echo('<div style="position:absolute;left:0;top:46%;width:100%;">');
if($GLOBALS['locsescnt'] < 10) // Max. 10 tries to get id's to prevent endless loop
{
echo('<div style="color:#444;font-size:larger;text-align:center;"><b>fx-project:</b> Starting local session …</div><div style="padding-top:12px;color:#aaa;font-size:smaller;text-align:center;">(If it isn\'t reloading, JavaScript is probalby not activated!)</div>');
echo('<form id="fxform" action="'.$GLOBALS['__server_array']['urlr'].'" method="post"><input id="locstoid" name="locstoid" type="hidden" value=""><input id="sesstoid" name="sesstoid" type="hidden" value=""><input id="locseskey" name="locseskey" type="hidden" value="'.$GLOBALS['locseskey'].'"><input id="locsescnt" name="locsescnt" type="hidden" value="'.($GLOBALS['locsescnt']+1).'"><input id="emode" name="emode" type="hidden" value="'.$GLOBALS['emode'].'"><input id="lts" name="lts" type="hidden" value="'.$GLOBALS['lts'].'"></form>');
echo('<script type="text/javascript">');
echo('locstoid=localStorage.getItem(\'locstoid\'); if(!locstoid || (locstoid.length != 15)) { locstoid=\'L'.date('YmdHis').'\'; localStorage.setItem(\'locstoid\', locstoid);} ');
echo('sesstoid=sessionStorage.getItem(\'sesstoid\'); if(!sesstoid || (sesstoid.length != 18)) { sesstoid=\'S'.date('YmdHis').substr(str_replace('.','', microtime(true)),-3).'\'; sessionStorage.setItem(\'sesstoid\', sesstoid);} ');
// if(!$GLOBALS['locsescnt']) echo('alert(\'New Local/Session storage: locsescnt='.$GLOBALS['locsescnt'].', locstoid=\'+locstoid+\', sesstoid=\'+sesstoid+\'\\nemode: \'+document.getElementById(\'emode\').value); ');
echo('document.getElementById(\'locstoid\').value=locstoid; document.getElementById(\'sesstoid\').value=sesstoid; document.getElementById(\'fxform\').submit();');
echo('</script>');
}
else
echo('<div style="color:#e1001a;font-size:larger;text-align:center;"><b>ERROR:</b> Could not get local/session storage id!</div><div style="padding-top:12px;color:#aaa;font-size:smaller;text-align:center;">(JavaScript is activated, but Browser probably doesn\'t support HTML5!)</div>');
echo('</div>');
echo('</body>');
echo('</html>');
die;
}
if(isset($GLOBALS['insync']))
{
$GLOBALS['locstoid']='L00000000000000';
$GLOBALS['sesstoid']='S00000000000000-'.$GLOBALS['insync'];
}
$GLOBALS['fxpglobals']['locstoid']=$GLOBALS['locstoid'];
$GLOBALS['fxpglobals']['sesstoid']=$GLOBALS['sesstoid'];
fxDebug(array('locstoid'=>$GLOBALS['locstoid'], 'sesstoid'=>$GLOBALS['sesstoid'], 'lts'=>$GLOBALS['lts']),'Local/Session storage id\'s + Login timestamp', 2);
// Login counter
if(!isset($GLOBALS['lcnt']))
{
if(fxIsArray($_GET) && isset($_GET['lcnt']))
$GLOBALS['lcnt']=(int)$_GET['lcnt'];
else
$GLOBALS['lcnt']=0;
}
fxDebug($GLOBALS['lcnt'],'$GLOBALS[\'lcnt\']',1);
// Load session globals
fxSession();
fxDebug($GLOBALS['fxpglobals'],'$GLOBALS[\'fxpglobals\']',2);
////////////////////////////////////////////////////////////////////////////////
// REQUIREMENTS
////////////////////////////////////////////////////////////////////////////////
if(!isset($GLOBALS['nosession']) || !$GLOBALS['nosession'])
{
// ...Database
$GLOBALS['__includer']['db']=true;
// ...Date and time functions
$GLOBALS['__includer']['datetime']=true;
$GLOBALS['__includer']['calendar']=true;
// ...Various function collections
$GLOBALS['__includer']['tools1']=true;
$GLOBALS['__includer']['tools2']=true;
$GLOBALS['__includer']['tools3']=true;
$GLOBALS['__includer']['tools4']=true;
$GLOBALS['__includer']['tools5']=true;
// ...Extended block function collection
$GLOBALS['__includer']['tools_spp']=true;
// ...Various special function collections
$GLOBALS['__includer']['tools_pers']=true;
$GLOBALS['__includer']['tools_prj']=true;
// ...Mask
$GLOBALS['__includer']['mask']=true;
// ...Select fields
$GLOBALS['__includer']['select']=true;
require('includer.inc');
}
// fx-project type + version (without trailing 0's)
fxSetVersion();
// Allow external links?
$author_string='FeRox Management Consulting GmbH & Co. KG';
$copyright_string='© '.$author_string;
$download_string='https://www.fx-project.org';
if(!fxIsArray($GLOBALS['fxpglobals']) || !fxIsArray($GLOBALS['fxpglobals']['dbparam']) || !isset($GLOBALS['fxpglobals']['dbparam']['elinks']) || !$GLOBALS['fxpglobals']['dbparam']['elinks'])
{
$_elinks=false;
$copyright_link=$copyright_string;
$download_link='<span class="blue normal">'.$download_string.'</span>';
}
else
{
$_elinks=true;
$copyright_link='<a class="fxlink" href="https://www.ferox.de" target="_blank">'.$copyright_string.'</a>';
$download_link='<a class="fxlink" href="https://www.fx-project.org" target="_blank">'.$download_string.'</a>';
}
// Determine which browser?
$browser_text=fxf_detBrowser();
fxDebug($browser_text, $GLOBALS['fxpglobals']['browser'].': $browser_text', 1);
// Set user menu?
if(fxIsArray($_POST) && isset($_POST['set_user_menu']))
$GLOBALS['fxpglobals']['umenu']=$_POST['set_user_menu'];
// CSS color info array
if(!fxIsArray($GLOBALS['cstyle']))
fxpGetCSSColors();
////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
/**
* Debug a variable, i.e. show the content of a variable - especially useful for arrays
*
* @param various $varname - Mandatory parameter: Variable that should be debugged
* @param string $dbgheader - Optional parameter (default = ''): Header to be displayed
* @param integer $level - Optional parameter (default = 1): Level of debug
*/
function fxDebug($varname, $dbgheader='', $level=1)
{
// Disable debug completely, uncomment the next line
// return;
// Debug informations
$dbga=debug_backtrace(); $dbgf=$dbga[0]['file']; $dbgl=$dbga[0]['line'];
// Special handling for Superglobals
if(($varname === '_POST') || ($varname === '_GET') || ($varname === '_FILES'))
{
$dbgheader=$varname;
$varname=$GLOBALS[$varname];
$level=0;
}
// Check if debug is turned on for this file or globally
$dbg=0;
if(isset($GLOBALS['__debug']) && is_array($GLOBALS['__debug']))
{
// ...turned on for this
if(isset($GLOBALS['__debug'][$dbgf]) && $GLOBALS['__debug'][$dbgf])
$dbg=(int)$GLOBALS['__debug'][$dbgf];
// ...turned on globally
else if(isset($GLOBALS['__debug']['_GDL']) && $GLOBALS['__debug']['_GDL'])
$dbg=(int)$GLOBALS['__debug']['_GDL'];
}
// ...Turned on debug level greater than call level -> leave debug function
// (Hint: Set call level to 0 if debug should be displayed regardless of the turned on debug level)
if(($level > 0) && (!$dbg || ($dbg > $level)))
return;
if(@isset($GLOBALS[$varname]))
{
$variablenname=$varname;
$varname=$GLOBALS[$varname];
}
$dbgheader=trim($dbgheader);
// Display
echo('<div style="position:relative;width:99%;margin-bottom:6px;background:#fff;border-top-left-radius:12px;border-top-right-radius:12px;box-shadow:4px 4px 4px rgba(0,0,0, 0.5);">'.$GLOBALS['nl']);
// ...Headline
echo(' <div style="position:relative;padding:4px 8px;padding-right:200px;background:#006b9f;color:#fff;font-size:1.5em;font-weight:bolder;border-top-left-radius:12px;border-top-right-radius:12px;">'.$GLOBALS['nl']);
if(strlen($dbgheader))
echo(' '.strtr(fxHtmlEncode(strtr($dbgheader, array('<br>'=>"#hr#", '<br />'=>"#hr#", "\r\n"=>"#br#", "\n"=>"#br#"))), array('#hr#'=>"<hr size=1 color=white />", '#br#'=>"<br />")).$GLOBALS['nl']);
else if(isset($variablenname) && strlen($variablenname))
echo(' Content of variable <b>$'.$variablenname.'</b> <i>(Type: '.gettype($varname).')</i>'.$GLOBALS['nl']);
else
echo(' Content of variable <i>(Type: '.gettype($varname).')</i>'.$GLOBALS['nl']);
echo(' <div style="position:absolute;bottom:4px;right:8px;color:#000;font-size:0.5em;">"'.$dbgf.'" (line '.$dbgl.')</div>'.$GLOBALS['nl']);
echo(' </div>'.$GLOBALS['nl']);
// ...Content
echo(' <div style="position:relative;width:100%;padding:0;background:#444;">'.$GLOBALS['nl']);
echo(' <table width=100% border=0 cellpadding=3 cellspacing=1">'.$GLOBALS['nl']);
fxDebugContent($varname);
echo(' </table>'.$GLOBALS['nl']);
echo(' </div>'.$GLOBALS['nl']);
echo('</div>'.$GLOBALS['nl']);
}
/**
* 2nd part of the debug a variable function that calls itself again for arrays
*
* @param various $varcontent - Mandatory parameter: Variable that should be debugged
* @param string $varkey - Optional parameter (default = ''): Array key to be displayed
*/
function fxDebugContent($varcontent, $varkey='')
{
$wt=64;
// Array: Cycle recursively through all keys
if(is_array($varcontent) && sizeof($varcontent))
{
echo(' <tr>'.$GLOBALS['nl']);
echo(' <td valign=top nowrap style="width:'.$wt.'px;background:#ccc;"><span style="color:#006b9f;">'.gettype($varcontent).'</span></td>'.$GLOBALS['nl']);
echo(' <td valign=top nowrap style="background:#ddd;color:#005077;">'.str_repeat(' ',2*max(0, substr_count($varkey,'[')-1)).$varkey.'</td>'.$GLOBALS['nl']);
echo(' <td valign=top nowrap style="background:#eee;"><i style="color:#888;">Size: '.sizeof($varcontent).'</i></td>'.$GLOBALS['nl']);
echo(' </tr>'.$GLOBALS['nl']);
foreach($varcontent as $vkey => $vvalue)
{
$ka="";
if(gettype($vkey) == 'string')
$ka="'";
fxDebugContent($vvalue, $varkey.'['.$ka.'<b>'.$vkey.'</b>'.$ka.']');
}
return;
}
echo(' <tr>'.$GLOBALS['nl']);
// ...Display type
$type=gettype($varcontent);
if($type == 'resource')
$type .= ': '.get_resource_type($varcontent);
echo(' <td nowrap valign=top style="width:'.$wt.'px;background:#ddd;"><span style="color:#006b9f;">'.$type.'</span></td>'.$GLOBALS['nl']);
// ...Recursive call from an array key?
if(strlen($varkey))
{
$lsp=strrpos($varkey,'[');
$varkey=substr($varkey,0,$lsp).'<span style="color:#000;">'.substr($varkey,$lsp).'</span>';
echo(' <td valign=top nowrap style="background:#eee;color:#005077;">'.str_repeat(' ',2*max(0, substr_count($varkey,'[')-1)).$varkey.'</td>'.$GLOBALS['nl']);
echo(' <td width=100% valign=top style="background:#fff;white-space:pre-wrap;word-wrap:break-word;">');
}
else
echo(' <td width=100% colspan=2 valign=top style="background:#fff;white-space:pre-wrap;word-wrap:break-word;">');
// ...Type: Array
if(is_array($varcontent))
echo('<i style="color:#666;">(empty)</i>');
// ...Type: Boolean
else if(gettype($varcontent) == 'boolean')
{
if($varcontent)
echo('<span class="dbg" style="color:#009f6b;">true</span>');
else
echo('<span class="dbg" style="color:#e1001a;">false</span>');
}
// ...Type: Resource or Object
else if((gettype($varcontent) == 'resource') || (gettype($varcontent) == 'object'))
echo('<span class="dbg" style="006b9f;">'.fxHtmlEncode(print_r($varcontent,true)).'</span>');
// ...Defined variable
else if(isset($varcontent))
echo('<span class="dbg" style="006b9f;">'.fxHtmlEncode($varcontent).'</span>');
// ...Undefined variable
else
echo('<i style="color:#e1001a;">(undefined)</i>');
echo('</td>'.$GLOBALS['nl']);
echo(' </tr>'.$GLOBALS['nl']);
}
/**
* Convert all html characters to printable charaters, i.e. also display tags
*
* @param string $h - Mandatory parameter: Html text
* @param string $enc - Optional parameter (default = ''): Encoding charset, if empty the default php charset will be used
*
* @return Converted html text
*/
function fxHtmlEncode($h, $enc='')
{
if(!strlen($enc))
$enc=ini_get('default_charset');
return htmlentities($h,ENT_QUOTES,$enc);
}
/**
* Check if a variable is an array that is not empty or has an explicit key
*
* @param various $arr - Mandatory parameter: Variable to be checked
* @param string $k - Optional parameter (default = ''): Check for this explicit key
*
* @return true or false
*/
function fxIsArray($arr, $k='')
{
if(is_array($arr) && sizeof($arr) && (!strlen($k) || isset($arr[$k])))
return true;
return false;
}
/**
* Convert string to lowercase
*
* @param string $str - Mandatory parameter: String to convert
*
* @return converted string
*/
function fxStrToLower($str)
{
if(function_exists('mb_strtolower'))
return mb_strtolower($str);
return strtolower($str);
}
/**
* Convert string to uppercase
*
* @param string $str - Mandatory parameter: String to convert
*
* @return converted string
*/
function fxStrToUpper($str)
{
if(function_exists('mb_strtoupper'))
return mb_strtoupper($str);
return strtoupper($str);
}
/**
* Helper debug function for comparing to values (Value 1 and 2)
*
* @param various $v1 - Mandantory parameter: Value 1
* @param various $v2 - Mandantory parameter: Value 2
* @param string $n1 - Optional parameter (default = ''): Variable name of Value 1 (just for display purposes)
* @param string $n2 - Optional parameter (default = ''): Variable name of Value 2 (just for display purposes)
*/
function fxf_compareDebug($v1, $v2, $n1='', $n2='')
{
// Value 1
$h='<b>$';
if(strlen($n1))
$h .= $n1;
else
$h .= 'v1';
$h .= '</b>: <span class=lightgrey>[</span><span class=blue>'.fxHtmlEncode($v1).'</span><span class=lightgrey>]</span> <span class=lightblue>('.gettype($v1);
if(is_string($v1))
{
$h .= ', strlen='.strlen($v1);
if(function_exists('mb_strlen'))
$h .= ', mb_strlen='.mb_strlen($v1);
}
$h .= ')</span>';
// Value 2
$h .= ', <b>$';
if(strlen($n2))
$h .= $n2;
else
$h .= 'v2';
$h .= '</b>: <span class=lightgrey>[</span><span class=blue>'.fxHtmlEncode($v2).'</span><span class=lightgrey>]</span> <span class=lightblue>('.gettype($v2);
if(is_string($v2))
{
$h .= ', strlen='.strlen($v2);
if(function_exists('mb_strlen'))
$h .= ', mb_strlen='.mb_strlen($v2);
}
$h .= ')</span>';
// Result
$h .= '<br />[==] → ';
if($v1 == $v2)
$h .= '<b class=green>true</b>';
else
$h .= '<b class=red>false</b>';
$h .= ', [===] → ';
if($v1 === $v2)
$h .= '<b class=green>true</b>';
else
$h .= '<b class=red>false</b>';
$h .= '<hr />';
echo($h);
}
/**
* Helper debug function for displaying string
*
* @param various $str - Mandantory parameter: String
*/
function fxf_debugString($str)
{
$h='<span class=lightgrey>[</span><span class=blue>'.fxHtmlEncode($str).'</span><span class=lightgrey>]</span> <span class=lightblue>('.gettype($str).', strlen='.strlen($str).', mb_strlen='.mb_strlen($str).')</span><br />';
for($i=0; $i<strlen($str); $i++)
{
$h .= $i.': [<b>'.substr($str,$i,1).'</b>] <i>(= '.ord(substr($str,$i,1)).')</i> ';
if($i && !($i%10))
$h .= '<br />';
}
$h .= '<hr />';
echo($h);
}
/**
* Helper debug function for calling functions
*/
function fxDebugFunction()
{
$_dbbta=debug_backtrace();
if(is_array($_dbbta) && (sizeof($_dbbta) > 1))
{
//if($_dbbta[1]['function'] == 'fxpdf_page') fxDebug($_dbbta, 'fxDebugFunction: $_dbbta', 0);
$_args='( ';
if(is_array($_dbbta[1]['args']) && sizeof($_dbbta[1]['args']))
{
foreach($_dbbta[1]['args'] as $_argc => $_arg)
{
if($_argc)
$_args .= ' <span class="lightergrey">,</span> ';
if(is_object($_arg))
$_args .= '<i class="green">{object}</i>';
else
{
if(is_resource($_arg))
$_args .= '<b class="green">'.$_arg.'</b>';
else if(is_bool($_arg))
{
if($_arg)
$_args .= '<b class="green">true</b>';
else
$_args .= '<b class="red">false</b>';
}
else if(is_string($_arg))
$_args .= '\'<b>'.$_arg.'\'</b>';
else
$_args .= '<b>'.$_arg.'</b>';
$_args .= ' <span class="lightergrey">(type='.gettype($_arg).')</span>';
}
}
}
$_args .= ' )';
$ds = '<div class="dbgdl" style="position:relative;width:100%;height:auto;text-align:top;align:top;">';
$ds .= '<div style="position:relative;display:inline-block;top:0;margin-left:2px;"><img src="'.$GLOBALS['gfxpath'].'tol_b_16x16.png"></div>';
$ds .= '<div style="position:relative;display:inline-block;top:0;margin-left:8px;width:200px;font-weight:bold;">'.$_dbbta[1]['function'].'</div>';
$ds .= '<div class="blue" style="position:relative;display:inline-block;top:0;width:800px;">'.$_args.'</div>';
$ds .= '<div class="lightergrey" style="position:relative;display:inline-block;top:0;font-size:smaller;">'.$_dbbta[1]['file'].' ('.$_dbbta[1]['line'].')</div>';
$ds .= '<div class="grey" style="position:relative;display:inline-block;top:0;font-size:smaller;"> → '.$_dbbta[0]['file'].' ('.$_dbbta[0]['line'].')</div>';
$ds .= '</div>'.$GLOBALS['nl'];
echo($ds);
}
}
/**
* Set and determine all OS relative things like newlines, file separators and server variables
*
* @param string $loc - Optional parameter (default = ''): Set locale
* @param string $cset - Optional parameter (default = ''): Set charset
*/
function fxSetOS($loc='', $cset='')
{
// Display function call?
if($GLOBALS['__debug']['debugmode']&FXP_DEBUG_FCT) { fxDebugFunction(); }
// Determine current OS (Operating System): Windows or Linux
$GLOBALS['_os']='windows';
if((isset($_SERVER) && (isset($_SERVER['PATH']) && (substr($_SERVER['PATH'], 0,1) == '/') || (isset($_SERVER['Path']) && substr($_SERVER['Path'], 0,1) == '/') || (isset($_SERVER['path']) && substr($_SERVER['path'], 0,1) == '/'))) || (isset($_ENV) && (isset($_ENV['PATH']) && (substr($_ENV['PATH'], 0,1) == '/') || (isset($_ENV['Path']) && substr($_ENV['Path'], 0,1) == '/') || (isset($_ENV['path']) && substr($_ENV['path'], 0,1) == '/'))))
$GLOBALS['_os']='linux';
// Set global newline for display
$GLOBALS['nl']="\r\n";
// Set global file separator according to OS
$GLOBALS['_oss']='\\';
if($GLOBALS['_os'] != 'windows')
$GLOBALS['_oss']='/';
// Set global newline for file actions according to OS
$GLOBALS['nl_b']=$GLOBALS['nl'];
if($GLOBALS['_os'] != 'windows')
$GLOBALS['nl_b']="\n";
// Server variables
$GLOBALS['__server_array']=array('addr'=>'', 'port'=>80, 'name'=>'', 'request_uri'=>'', 'script_name'=>'', 'prg'=>'', 'url'=>'http', 'urlr'=>'http', 'urls'=>'http');
if(fxIsArray($_SERVER))
{
if(isset($_SERVER['SERVER_NAME']))
$GLOBALS['__server_array']['name']=$_SERVER['SERVER_NAME'];
if(isset($_SERVER['SERVER_ADDR']))
$GLOBALS['__server_array']['addr']=$_SERVER['SERVER_ADDR'];
if(isset($_SERVER['SERVER_PORT']))
$GLOBALS['__server_array']['port']=(int)$_SERVER['SERVER_PORT'];
if(isset($_SERVER['REQUEST_URI']))
{
$GLOBALS['__server_array']['request_uri']=$_SERVER['REQUEST_URI'];
$GLOBALS['__server_array']['prg']=basename($_SERVER['REQUEST_URI']);
$qm=strpos($GLOBALS['__server_array']['prg'],'?');
if($qm !== false)
$GLOBALS['__server_array']['prg']=trim(substr($GLOBALS['__server_array']['prg'],0,$qm));
}
if(isset($_SERVER['SCRIPT_NAME']))
$GLOBALS['__server_array']['script_name']=$_SERVER['SCRIPT_NAME'];
if($GLOBALS['__server_array']['port'] == 443)
$GLOBALS['__server_array']['url'] .= 's';
$GLOBALS['__server_array']['url'] .= '://';
if(strlen($GLOBALS['__server_array']['name']))
$GLOBALS['__server_array']['url'] .= $GLOBALS['__server_array']['name'];
else if(strlen($GLOBALS['__server_array']['addr']))
$GLOBALS['__server_array']['url'] .= $GLOBALS['__server_array']['addr'];
else
$GLOBALS['__server_array']['url'] .= 'localhost';
if(($GLOBALS['__server_array']['port'] != 80) && ($GLOBALS['__server_array']['port'] != 443))
$GLOBALS['__server_array']['url'] .= ':'.$GLOBALS['__server_array']['port'];
$GLOBALS['__server_array']['urlr']=$GLOBALS['__server_array']['url'].$GLOBALS['__server_array']['request_uri'];
$GLOBALS['__server_array']['urls']=$GLOBALS['__server_array']['url'].$GLOBALS['__server_array']['script_name'];
if(strlen($GLOBALS['__server_array']['script_name']))
$burl=$GLOBALS['__server_array']['urls'];
else
$burl=$GLOBALS['__server_array']['urlr'];
$lsp=strrpos($burl,'/');
if($lsp)
$burl=substr($burl,0,$lsp+1);
$GLOBALS['__server_array']['url']=$burl;
}
fxDebug($GLOBALS['__server_array'], '$GLOBALS[\'__server_array\']', 128);
if(strlen($loc))
setlocale(LC_CTYPE, $los);
if(strlen($cset))
{
$ini_charset=strtoupper(ini_get('default_charset'));
$fxp_charset=strtoupper($cset);
if($ini_charset != $fxp_charset)
ini_set('default_charset', $fxp_charset);
}
}
/**
* Set current session and return as parameters
*
* @param boolean $all - Optional parameter (default = true): Return all paramters or just essentials?
*
* @return Current session parameter
*/
function fxSetSession($all=true)
{
// Display function call?
if($GLOBALS['__debug']['debugmode']&FXP_DEBUG_FCT) { fxDebugFunction(); }
//writeDebugTextfile('session', '*SESSION');
$chklocsesarr=array('locstoid','sesstoid','locseskey','locsescnt','emode','lts');
foreach($chklocsesarr as $chklocses)
{
if(!isset($GLOBALS[$chklocses]))
{
$GLOBALS[$chklocses]='';
if(!strlen(${$chklocses}) && isset($_POST) && is_array($_POST) && sizeof($_POST) && isset($_POST[$chklocses]))
$GLOBALS[$chklocses]=trim($_POST[$chklocses]);
if(!strlen(${$chklocses}) && isset($_GET) && is_array($_GET) && sizeof($_GET) && isset($_GET[$chklocses]))
$GLOBALS[$chklocses]=trim($_GET[$chklocses]);
if($chklocses == 'locsescnt')
$GLOBALS[$chklocses]=(int)$GLOBALS[$chklocses];
if(($chklocses == 'lts') && !strlen($GLOBALS[$chklocses]))
$GLOBALS[$chklocses]=date('YmdHis');
}
//writeDebugTextfile('session', '$GLOBALS['.$chklocses.']='.$GLOBALS[$chklocses]);
}
// Check if key matches local and storage session
$GLOBALS['locseschecked']=0;
if((strlen($GLOBALS['locstoid']) == 15) && (substr($GLOBALS['locstoid'],0,1) == 'L') && (strlen($GLOBALS['sesstoid']) == 18) && (substr($GLOBALS['sesstoid'],0,1) == 'S'))
{
$cip='aes-256-cbc';
$cil=openssl_cipher_iv_length($cip);
$lsp=$GLOBALS['usrpath'].$GLOBALS['locstoid'].'/'.$GLOBALS['sesstoid'].'/';
$lsf=$lsp.'k.pif';
//writeDebugTextfile('session', 'START -- $lsf=['.$lsf.'] -- $GLOBALS[\'locseskey\']=['.$GLOBALS['locseskey'].'] -- $lsk=['.$lsk.']');
if(file_exists($lsf))
{
$lsa=fxLoad($lsf, 1);
if(fxIsArray($lsa))
{
$lsc=1;
$lsk=trim($lsa[0]);
if(strlen($lsk) && (substr($lsk,0,4) == '<!--'))
{
$lsc=2;
$lsk=trim($lsa[1]);
}
else
$GLOBALS['locseskey']='new';
//writeDebugTextfile('session', 'CHECK -- $lsf=['.$lsf.'] -- $GLOBALS[\'locseskey\']=['.$GLOBALS['locseskey'].'] -- $lsk=['.$lsk.']');
if(!strlen($lsk) || (strlen($GLOBALS['locseskey']) && ($lsk !== $GLOBALS['locseskey'])))
$GLOBALS['locseskey']='new';
else if(sizeof($lsa) > $lsc)
{
$sdc=base64_decode(trim($lsa[$lsc]));
$rpb=substr($sdc,0,$cil);
$e64=substr($sdc,$cil,64);
$e32=substr($sdc,$cil+64);
$sec=openssl_decrypt($e32, $cip, $lsk, OPENSSL_RAW_DATA, $rpb);
$h64=hash_hmac('sha3-512', $e32, $lsk, true);
if(!hash_equals($e64, $h64) || ($sec !== $GLOBALS['locstoid'].$GLOBALS['sesstoid']))
$GLOBALS['locseskey']='set';
else
$GLOBALS['locseschecked']=1;
}
else
$GLOBALS['locseskey']='set';
}