-
Notifications
You must be signed in to change notification settings - Fork 1
/
CaMykS.php.inc
executable file
·2064 lines (1718 loc) · 61.2 KB
/
CaMykS.php.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
/**
* @brief CaMykS version 2, CMS master class.
* @details Engine / Master Library
* @author CaMykS Team <camyks.contact@gmail.com>
* @version 2.0pre46
* @date Creation: Feb 2017
* @date Modification: Mar 2023
* @copyright 2017 - 2023 CaMykS Team
* @note This program is distributed as is - WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
namespace CaMykS2;
/**
* @def CAMYKS_MODE_VISIT
*/
define('CAMYKS_MODE_VISIT', 0);
/**
* @def CAMYKS_MODE_ADMIN
*/
define('CAMYKS_MODE_ADMIN', 1);
/**
* @def CAMYKS_MODE_REQUEST
*/
define('CAMYKS_MODE_REQUEST', 2);
/**
* @def CAMYKS_MODE_MANAGER
*/
define('CAMYKS_MODE_MANAGER', 3);
/**
* @def CAMYKS_MODE_INSTALL
*/
define('CAMYKS_MODE_INSTALL', 4);
/**
* CaMykS class.
*/
final class CaMykS {
/**
* @var integer $mode
* @brief CaMykS current mode.
*/
private $mode;
/**
* @var array $engineConfiguration
* @brief CaMykS configuration.
*/
private $engineConfiguration = array();
/**
* @var array $websiteConfiguration
* @brief Website configuration.
*/
private $websiteConfiguration = array();
/**
* @var array $plugins
* @brief Loaded plugins.
*/
private $plugins = array('Components'=>array(), 'Modules'=>array(), 'Templates'=>array(), 'Themes'=>array());
/**
* @var array $systemPlugins
* @brief System required plugins name.
*/
private $systemPlugins = array(
array('Name'=>'SystemPluginManager', 'Type'=>'Module', 'Location'=>'System'),
array('Name'=>'SystemLogManager', 'Type'=>'Module', 'Location'=>'System'),
array('Name'=>'SystemSessionManager', 'Type'=>'Module', 'Location'=>'System'),
array('Name'=>'SystemFileStorageManager', 'Type'=>'Module', 'Location'=>'System'),
);
/**
* @var integer $startMicroTime
* @brief Store CaMykS starting microtime
*/
private $startMicroTime;
/**
* @var Object $databaseConnection
* @brief Website, main database connection.
*/
private $databaseConnection;
/**
* @var array $openedDBConnections
* @brief CaMykS opened database connections.
*/
private $openedDBConnections = array();
/**
* @var array $eventsHandlers
* @brief CaMykS event handlers.
*/
private $eventsHandlers = array(
'onInitialise' => array(),
'onVisitPageLoad' => array(),
'onVisitBodyOpen' => array(),
'onVisitBodyClose' => array(),
'onAdminPageLoad' => array(),
'onAdminBodyOpen' => array(),
'onAdminBodyClose' => array(),
'onTerminate' => array(),
);
/**
* @var array $accessibilityFolders
* @brief List of accessible folders.
*/
private $accessibilityFolders;
/**
* @var boolean $falseRef
* @brief CaMykS false value as reference.
*/
private $falseRef = false;
/* Language variables */
/**
* @var array $currentLanguage
* @brief Optimised language currently used.
*/
private $currentLanguage = 'fr_FR';
/**
* @var array $locales
* @brief List of all available locales.
*/
private $locales = array();
/**
* @var array $loadedLocales
* @brief List all loaded locale files.
*/
private $loadedLocales = array();
/* Data */
/**
* @var array $assetData
* @brief Stores loaded asset data.
*/
private $assetData = array();
/* URLs and paths */
/**
* @var string $CaMykSPath
* @brief CaMykS path.
*/
private $CaMykSPath;
/**
* @var string $websitePath
* @brief Website path.
*/
private $websitePath;
/**
* @var string $websiteURL
* @brief Website URL.
*/
private $websiteURL;
/**
* @var string $corePluginLink
* @brief Symbolic link to core plugin folder
*/
private $corePluginLink = 'CorePlugins';
/**
* @var string $sharedPluginLink
* @brief Symbolic link to shared plugin folder
*/
private $sharedPluginLink = 'SharedPlugins';
/**
* @var string $coreAssetLink
* @brief Symbolic link to core asset folder
*/
private $coreAssetLink = 'CoreAssets';
/* Links to internal object libraries */
/**
* @var Object $bench
* @brief CaMykS internal bench object.
*/
private $bench = false;
/**
* @var Object $errorHandler
* @brief CaMykS internal error handler.
*/
private $errorHandler = false;
/**
* @var Object $HTMLPage
* @brief Main HTML page.
*/
private $HTMLPage;
/**
* @var Object $localStorage
* @brief Local storage object.
*/
private $localStorage;
/* Links to plugins */
/**
* @var Object $currentTheme
* @brief Link to current theme used in CaMykS.
*/
private $currentTheme;
/**
* @var Object $currentTemplate
* @brief Link to current template used in CaMykS.
*/
private $currentTemplate;
/**
* @var Object $manager
* @brief Link to manager special plugin.
*/
private $manager;
/**
* @var Object $installer
* @brief Link to installer special plugin.
*/
private $installer;
/**
* @var string $layoutContext
* @brief Selected layout context.
*/
private $layoutContext;
/**
* Class constructor.
* @param array $configuration
* @return void
*/
public function __construct($configuration=array()) {
/* Define website configuration */
$this->websiteConfiguration = $configuration;
/* Set start microtime value */
$this->startMicroTime = microtime(true);
/* Register shutdown internal function */
register_shutdown_function(array($this, 'terminate'));
}
/* CaMykS magic methods */
/**
* Makes some variables accessible in read-only
* @param string $variableName
* @return mixed
*/
public function __get($variableName) {
/* Temporary edit to find occurences */
if (in_array($variableName, array('name', 'version', 'versionMajor', 'versionMinor', 'lastModificationDate', 'CMSWebsiteURL', 'libraryExtension', 'layoutExtension'))) {
$this->trigger_error('CaMykS', 0, $variableName.' is unknown', '');
return null;
}
if (in_array($variableName, array('mode', 'databaseConnection', 'currentLanguage', 'currentTheme', 'currentTemplate', 'HTMLPage', 'manager', 'installer', 'localStorage', 'errorHandler', 'corePluginLink', 'sharedPluginLink', 'coreAssetLink')))
return $this->$variableName;
}
/* CaMykS main method */
/**
* Execute CaMykS engine.
* @param integer $mode to run
* @return void
*/
public function execute($mode) {
/* Store mode */
$this->mode = $mode;
/* Initialise */
$this->initialise();
/* Display */
$this->display();
/* Close */
//$this->close();
}
/* CaMykS main sub methods */
/**
* Initialise CaMykS.
* @return void
*/
private function initialise() {
/* Initialise engine */
$this->initialise_engine();
/* Run onInitialise event handlers */
$this->run_eventHandlers('onInitialise');
/* Add bench step */
$this->bench->add_step('CaMykS initialise mode.');
/* Create HTML page */
$this->HTMLPage = new HTMLPage();
/* Initialise mode */
switch ($this->mode) {
case CAMYKS_MODE_VISIT:
$this->initialise_visit();
break;
case CAMYKS_MODE_ADMIN:
$this->initialise_admin();
break;
case CAMYKS_MODE_REQUEST:
$this->initialise_request();
break;
case CAMYKS_MODE_MANAGER:
$this->initialise_manager();
break;
case CAMYKS_MODE_INSTALL:
$this->initialise_install();
break;
}
}
/**
* Display CaMykS.
* @return void
*/
private function display() {
/* Add bench step */
$this->bench->add_step('CaMykS display mode.');
/* Write HTML page header */
$this->HTMLPage->write_header();
/* Display mode */
switch ($this->mode) {
case CAMYKS_MODE_VISIT:
$this->display_visit();
break;
case CAMYKS_MODE_ADMIN:
$this->display_admin();
break;
case CAMYKS_MODE_REQUEST:
$this->display_request();
break;
case CAMYKS_MODE_MANAGER:
$this->display_manager();
break;
case CAMYKS_MODE_INSTALL:
$this->display_install();
break;
}
}
/**
* Close CaMykS.
* @return void
*/
public function close() {
/* Kill processus to call terminate through registered shutdown function */
die();
}
/**
* Terminate CaMykS.
* @return void
*/
public function terminate() {
/* Add bench step */
if ($this->bench !== false) $this->bench->add_step('CaMykS terminate.');
/* Close database connections */
$this->close_databaseConnections();
/* Run onTerminate event handlers */
$this->run_eventHandlers('onTerminate');
/* Export errorHandler result */
if ($this->errorHandler !== false) $this->errorHandler->export();
/* Export bench result */
if ($this->bench !== false) $this->bench->export();
/* Write HTML page footer */
if (isset($this->HTMLPage))
$this->HTMLPage->write_footer();
}
/* CaMykS initialisation methods */
/**
* Initialise engine.
* @return void
*/
private function initialise_engine() {
/* Set up CaMykS files path */
$this->CaMykSPath = dirname(__FILE__);
/* Set up website files path */
$this->websitePath = getcwd();
/* Load CaMykS configuration */
require_once $this->CaMykSPath.'/Core/Configuration/CaMykS.php.inc';
/* Check if website is installed */
if (in_array($this->mode, array(CAMYKS_MODE_VISIT, CAMYKS_MODE_ADMIN, CAMYKS_MODE_REQUEST)) and $this->get_configValue('Website_Status') == 0)
$this->mode = CAMYKS_MODE_INSTALL;
elseif ($this->mode === CAMYKS_MODE_INSTALL and $this->get_configValue('Website_Status') !== 0)
$this->mode = CAMYKS_MODE_VISIT;
/* Load first libraries */
$this->load_engineFirstLibraries();
/* Load engine configuration */
$this->load_configuration('Engine');
/* Define time zone */
date_default_timezone_set($this->get_configValue('Engine_TimeZone', 'Europe/Paris'));
/* Define encoding */
$this->define_encoding();
/* Load libraries */
$this->load_engineLibraries();
/* Load main dictionary */
$this->load_engineLocales('');
/* Load errorhandler object */
$this->errorHandler = new ErrorHandler();
/* Check server requirements */
$this->check_serverRequirements();
/* Load bench object */
$this->bench = new Bench();
$this->bench->start('CaMykS loading.', $this->startMicroTime);
/* Load local storage object */
$this->localStorage = new LocalStorage();
}
/**
* Initialise visit mode.
* @return void
*/
private function initialise_visit() {
/* Load visit configuration */
$this->load_configuration('Visit');
/* Set up base URL */
$this->define_baseURL($this->get_configValue('Visit_SSL'));
/* Start session */
session_set_cookie_params(array(
'Lifetime' => $this->get_configValue('Engine_SessionLifetime', 24)*60,
'Path' => parse_url($this->websiteURL, 'path').'/',
'Domain' => parse_url($this->websiteURL, 'host'),
'Secure' => $this->get_configValue('Visit_SSL'),
'HttpOnly' => "1",
'SameSite' => $this->get_configValue('Engine_SessionSameSite', "Strict"),
));
session_start();
/* Make common initialisation */
$this->initialise_common();
/* Run onVisitPageLoad event handlers */
$this->run_eventHandlers('onVisitPageLoad');
}
/**
* Initialise admin mode.
* @return void
*/
private function initialise_admin() {
/* Load admin configuration */
$this->load_configuration('Admin');
/* Set up base URL */
$this->define_baseURL($this->get_configValue('Admin_SSL'));
/* Start session */
session_set_cookie_params(array(
'Lifetime' => $this->get_configValue('Engine_SessionLifetime', 24)*60,
'Path' => parse_url($this->websiteURL, 'path').'/',
'Domain' => parse_url($this->websiteURL, 'host'),
'Secure' => $this->get_configValue('Admin_SSL'),
'HttpOnly' => "1",
'SameSite' => $this->get_configValue('Engine_SessionSameSite', "Strict"),
));
session_start();
/* Make common initialisation */
$this->initialise_common();
/* Load admin locales */
$this->load_engineLocales('Admin', 'Admin', $this->currentLanguage);
/* Run onAdminPageLoad event handlers */
$this->run_eventHandlers('onAdminPageLoad');
}
/**
* Execute common initialisation from visit and admin mode, can eventually be called from request mode.
* @return void
*/
public function initialise_common() {
/* Initialise database connection */
/* Load system plugins */
$this->load_systemPlugins();
/* Load website plugins */
$this->load_websitePlugins();
/* Check plugins for updates */
$this->check_plugins();
/* Load client session */
}
/**
* Initialise request mode.
* @return void
*/
private function initialise_request() {
}
/**
* Initialise manager mode.
* @return void
*/
private function initialise_manager() {
/* Load manager configuration */
$this->load_configuration('Manager');
/* Set up base URL */
$this->define_baseURL($this->get_configValue('Manager_SSL'));
/* Start session */
session_set_cookie_params(array(
'Lifetime' => $this->get_configValue('Engine_SessionLifetime', 24)*60,
'Secure' => $this->get_configValue('Manager_SSL'),
'HttpOnly' => "1",
'SameSite' => "Strict",
));
session_start();
/* Update folder links */
$this->corePluginLink = 'Core/Plugins/';
$this->sharedPluginLink = 'Plugins/';
$this->coreAssetLink = 'Core/Assets/';
/* Load language */
$this->load_currentLanguage();
/* Load manager plugin */
$this->manager = &$this->get_plugin('CaMykSManager', 'Special', true, 'System');
/* Load template */
$this->currentTemplate = &$this->get_template('AdminPage', true, 'System');
$this->currentTemplate->initialise();
/* Load theme */
$this->currentTheme = &$this->get_theme($this->get_configValue('Manager_Theme'), true);
$this->currentTheme->initialise();
$this->currentTheme->load_adminStyleFiles();
/* Initialise manager */
$this->manager->initialise();
}
/**
* Initialise install mode.
* @return void
*/
private function initialise_install() {
/* Load language */
$this->load_currentLanguage();
/* Load installer plugin */
$this->installer = &$this->get_plugin('CaMykSInstaller', 'Special', true, 'System');
/* Load template */
$this->currentTemplate = &$this->get_template('AdminPage', true, 'System');
$this->currentTemplate->initialise();
/* Load theme */
$this->currentTheme = &$this->get_theme('CaMykSStyle', true);
$this->currentTheme->initialise(array('FileMode'=>'Inserted'));
$this->currentTheme->load_adminStyleFiles('Inserted');
/* Initialise installer */
$this->installer->initialise();
}
/* CaMykS display methods */
/**
* Display visit mode.
* @return void
*/
private function display_visit() {
/* Run onVisitBodyOpen event handlers */
$this->run_eventHandlers('onVisitBodyOpen');
/* Display template main layout */
$this->currentTemplate->display();
/* Run onVisitBodyClose event handlers */
$this->run_eventHandlers('onVisitBodyClose');
}
/**
* Display admin mode.
* @return void
*/
private function display_admin() {
/* Run onAdminBodyOpen event handlers */
$this->run_eventHandlers('onAdminBodyOpen');
/* Display template main layout */
$this->currentTemplate->display();
/* Run onAdminBodyClose event handlers */
$this->run_eventHandlers('onAdminBodyClose');
}
/**
* Display visit mode.
* @return void
*/
private function display_request() {
}
/**
* Display manager mode.
* @return void
*/
private function display_manager() {
/* Display template main layout */
$this->currentTemplate->display();
}
/**
* Display install mode.
* @return void
*/
private function display_install() {
/* Display template main layout */
$this->currentTemplate->display();
}
/* CaMykS display sub methods */
/**
* Display template slot content.
* @param integer $slotIndex
* @return void
*/
public function display_templateSlotContent($slotIndex) {
/* Display mode */
switch ($this->mode) {
case CAMYKS_MODE_VISIT:
/* Display module */
break;
case CAMYKS_MODE_ADMIN:
/* Display module in admin module */
break;
case CAMYKS_MODE_REQUEST:
/* */
break;
case CAMYKS_MODE_MANAGER:
/* Display manager */
$this->manager->display();
break;
case CAMYKS_MODE_INSTALL:
/* Display installer */
$this->installer->display();
break;
}
}
/* Configuration related methods */
/**
* Load configuration.
* @param string $configFile
* @return void
*/
public function load_configuration($configFile) {
/* Load engine configuration file */
$config = new ConfigurationFile($configFile, 'Engine');
$this->engineConfiguration = array_merge($this->engineConfiguration, $config->export());
/* Load website configuration file */
$config = new ConfigurationFile($configFile, 'Website');
if ($this->mode !== CAMYKS_MODE_MANAGER and $this->get_configValue('Website_Status') !== 0)
$this->websiteConfiguration = array_merge($this->websiteConfiguration, $config->export());
}
/**
* Return configuration value.
* @param string $name
* @param mixed $default
* @return mixed
*/
public function get_configValue($name, $default=null) {
/* Check website configuration */
if (isset($this->websiteConfiguration[$name]) and !is_null($this->websiteConfiguration[$name]))
return $this->websiteConfiguration[$name];
/* Check CaMykS configuration */
if (isset($this->engineConfiguration[$name]) and !is_null($this->engineConfiguration[$name]))
return $this->engineConfiguration[$name];
/* Return default value */
return $default;
}
/**
* Define or update temporary configuration value.
* @param string $name
* @param mixed $value
* @return void
*/
public function set_configValue($name, $value) {
$this->websiteConfiguration[$name] = $value;
}
/* Session related method */
/**
* Save variable to session.
* @param string $name
* @param mixed $value
* @return void
*/
public function set_sessionValue($name, $value='') {
$_SESSION[$this->get_configValue('Website_Name').'_'.$name] = $value;
}
/**
* Return variable from session.
* @param string $name
* @param mixed $default
* @return mixed
*/
public function get_sessionValue($name, $default=null) {
/* Set up session variable */
$var = $this->get_configValue('Website_Name').'_'.$name;
/* Return value */
return isset($_SESSION[$var]) ? $_SESSION[$var] : $default;
}
/* Library related methods */
/**
* Load given library.
* @param string $library
* @param string $folder
* @return boolean success
*/
public function load_library($library, $folder='') {
/* Define file */
$file = 'Core/Libraries/'.($folder == '' ? '' : $folder.'/').$library.'.php.inc';
/* Check file */
if (!$this->check_engineFileExists($file))
return false;
/* Load library */
require_once($this->get_engineFileFullPath($file));
}
/**
* Load engine libraries.
* @return void
*/
private function load_engineFirstLibraries() {
/* Load tool libraries */
$this->load_library('folder', 'Tools');
/* Load object libraries */
$this->load_library('CaMykSLibrary', 'Objects');
$this->load_library('ConfigurationFile', 'Objects');
$this->load_library('File', 'Objects');
}
/**
* Load engine libraries.
* @return void
*/
private function load_engineLibraries() {
/* Start capturing extra code in live mode */
if ($this->get_configValue('Website_Status') == false)
ob_start();
/* Load tool libraries */
$this->load_library('array', 'Tools');
$this->load_library('client', 'Tools');
$this->load_library('country', 'Tools');
$this->load_library('currency', 'Tools');
$this->load_library('date', 'Tools');
$this->load_library('email', 'Tools');
$this->load_library('file', 'Tools');
$this->load_library('html', 'Tools');
$this->load_library('http', 'Tools');
$this->load_library('language', 'Tools');
$this->load_library('network', 'Tools');
$this->load_library('password', 'Tools');
$this->load_library('php', 'Tools');
$this->load_library('server', 'Tools');
$this->load_library('string', 'Tools');
$this->load_library('url', 'Tools');
$this->load_library('util', 'Tools');
/* Load parent object libraries */
$this->load_library('Plugin', 'Objects');
$this->load_library('PluginLibrary', 'Objects');
$this->load_library('PluginLibraryAttribute', 'Objects');
/* Load object libraries */
$this->load_library('Bench', 'Objects');
$this->load_library('DatabaseConnector', 'Objects');
$this->load_library('DatabaseDriverInterface', 'Objects');
$this->load_library('DbQuery', 'Objects');
$this->load_library('DbQueryWhereCondition', 'Objects');
$this->load_library('Component', 'Objects');
$this->load_library('Error', 'Objects');
$this->load_library('ErrorHandler', 'Objects');
$this->load_library('HTMLForm', 'Objects');
$this->load_library('HTMLFormInput', 'Objects');
$this->load_library('HTMLPage', 'Objects');
$this->load_library('LocalStorage', 'Objects');
$this->load_library('Module', 'Objects');
$this->load_library('Module/Admin', 'Objects');
$this->load_library('Module/Content', 'Objects');
$this->load_library('Module/Tool', 'Objects');
$this->load_library('ModuleLibrary', 'Objects');
$this->load_library('PluginConfiguration', 'Objects');
$this->load_library('RequestAnswer', 'Objects');
$this->load_library('Template', 'Objects');
$this->load_library('Theme', 'Objects');
/* Load ModuleLibrary object libraries */
$this->load_library('ModuleLibrary/Simple', 'Objects');
$this->load_library('ModuleLibrary/Advanced', 'Objects');
$this->load_library('ModuleLibrary/ObjectAssociation', 'Objects');
/* Load PluginLibraryAttribute simple object libraries */
$this->load_library('PluginLibraryAttribute/Date', 'Objects');
$this->load_library('PluginLibraryAttribute/Float', 'Objects');
$this->load_library('PluginLibraryAttribute/Integer', 'Objects');
$this->load_library('PluginLibraryAttribute/Text', 'Objects');
/* Load PluginLibraryAttribute advanced object libraries */
$this->load_library('PluginLibraryAttribute/Boolean', 'Objects');
$this->load_library('PluginLibraryAttribute/EmailAddress', 'Objects');
$this->load_library('PluginLibraryAttribute/IPAddress', 'Objects');
$this->load_library('PluginLibraryAttribute/ListItem', 'Objects');
$this->load_library('PluginLibraryAttribute/Name', 'Objects');
$this->load_library('PluginLibraryAttribute/ObjectId', 'Objects');
$this->load_library('PluginLibraryAttribute/Price', 'Objects');
$this->load_library('PluginLibraryAttribute/Version', 'Objects');
/* Build object from libraries */
$this->LocalStorage = new LocalStorage();
/* Load site libraries */
if ($this->websitePath != $this->CaMykSPath and file_exists($this->websitePath.'./Assets/Libraries')) {
foreach (glob($this->websitePath.'./Assets/Libraries/*'.CAMYKS_LIBRARYEXTENSION) as $file)
require_once($file);
}
/* Clean captured extra code in live mode */
if ($this->get_configValue('Website_Status') == false)
ob_clean();
}
/* Initialisation sub methods */
/**
* Define encoding.
* @return void
*/
private function define_encoding() {
if (extension_loaded('mbstring'))
mb_internal_encoding($this->get_configValue('Website_Encoding', 'UTF8'));
}
/**
* Check server requirements.
* @return void
*/
private function check_serverRequirements() {
/* Check PHP version */
if (version_compare(PHP_VERSION, CAMYKS_PHPMINVERSION, '<')) {
$this->trigger_error('CaMykS', 1, 'Current PHP version ('.PHP_VERSION.') doesn\'t meet minimum requirements.'."\n".
'To run CaMykS2 properly, PHP engine must be, at least, version '.$this->PHPMinVersion.".\n".
'Please update your version of PHP, before running CaMykS2.',
'', null, null, true);
}
/* Check mod_rewrite module */
if (!server_checkModuleAvailability('mod_rewrite')) {
$this->trigger_error('CaMykS', 2, 'URL rewriting module must be enabled.'."\n".
'Please turn on the URL rewriting module of your web software, before running CaMykS2.',
'', null, null, true);
}
}
/* Plugin related methods */
/**
* Load plugin from its source.
* @param string $name
* @param string $type
* @param string $location
* @return Plugin
*/
public function &load_plugin($name, $type, $location=null) {
/* Define plugins folder */
$folder = ucwords(strtolower($type)).'s';
/* Build full class name */
$class = 'CaMykS2\\'.$name;
/* Check class is already loaded */
if (!class_exists($class)) {
/* Check is in system plugins */
if ($location == 'System' or ($location === null and $this->check_engineFileExists('Core/Plugins/'.$folder.'/'.$name.'/'.$name.CAMYKS_LIBRARYEXTENSION))) {
$location = 'System';
$path = $this->get_engineFileFullPath('Core/Plugins/'.$folder.'/'.$name);
}
/* Check is in shared plugins */
elseif ($location == 'Shared' or ($location === null and $this->check_engineFileExists('Plugins/'.$folder.'/'.$name.'/'.$name.CAMYKS_LIBRARYEXTENSION))) {
$location = 'Shared';
$path = $this->get_engineFileFullPath('Plugins/'.$folder.'/'.$name);
}
/* Check is in website plugins */
elseif ($location == 'Website' or ($location === null and $this->check_websiteFileExists('Plugins/'.$folder.'/'.$name.'/'.$name.CAMYKS_LIBRARYEXTENSION))) {
$location = 'Website';
$path = $this->get_websiteFileFullPath('Plugins/'.$folder.'/'.$name);
}
/* Plugin not found */
else {
/* Log error ? */
/* Return failure */
return $this->falseRef;
}
/* Load plugin file */
require_once $path.'/'.$name.CAMYKS_LIBRARYEXTENSION;
/* Check if class exists */
if (!class_exists($class))
return $this->falseRef;
}
/* Load plugin object */