ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilInitialisation.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4// TODO:
15
16require_once("libs/composer/vendor/autoload.php");
17
18// needed for slow queries, etc.
19if (!isset($GLOBALS['ilGlobalStartTime']) || !$GLOBALS['ilGlobalStartTime']) {
20 $GLOBALS['ilGlobalStartTime'] = microtime();
21}
22
23include_once "Services/Context/classes/class.ilContext.php";
24
41{
45 protected static function removeUnsafeCharacters()
46 {
47 // Remove unsafe characters from GET parameters.
48 // We do not need this characters in any case, so it is
49 // feasible to filter them everytime. POST parameters
50 // need attention through ilUtil::stripSlashes() and similar functions)
52 }
53
54 protected static function recursivelyRemoveUnsafeCharacters($var)
55 {
56 if (is_array($var)) {
57 $mod = [];
58 foreach ($var as $k => $v) {
61 }
62 return $mod;
63 }
64 return strip_tags(
65 str_replace(
66 array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"),
67 "",
68 $var
69 )
70 );
71 }
72
76 protected static function requireCommonIncludes()
77 {
78 // ilTemplate
80 require_once "./Services/UICore/classes/class.ilTemplate.php";
81 }
82
83 // really always required?
84 require_once "./Services/Utilities/classes/class.ilUtil.php";
85 require_once "./Services/Calendar/classes/class.ilDatePresentation.php";
86 require_once "include/inc.ilias_version.php";
87
88 include_once './Services/Authentication/classes/class.ilAuthUtils.php';
89
90 self::initGlobal("ilBench", "ilBenchmark", "./Services/Utilities/classes/class.ilBenchmark.php");
91 }
92
98 protected static function includePhp5Compliance()
99 {
100 include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
102 require_once("include/inc.xml5compliance.php");
103 }
104 require_once("include/inc.xsl5compliance.php");
105 }
106
114 protected static function initIliasIniFile()
115 {
116 require_once("./Services/Init/classes/class.ilIniFile.php");
117 $ilIliasIniFile = new ilIniFile("./ilias.ini.php");
118 $ilIliasIniFile->read();
119 self::initGlobal('ilIliasIniFile', $ilIliasIniFile);
120
121 // initialize constants
122 define("ILIAS_DATA_DIR", $ilIliasIniFile->readVariable("clients", "datadir"));
123 define("ILIAS_WEB_DIR", $ilIliasIniFile->readVariable("clients", "path"));
124 define("ILIAS_ABSOLUTE_PATH", $ilIliasIniFile->readVariable('server', 'absolute_path'));
125
126 // logging
127 define("ILIAS_LOG_DIR", $ilIliasIniFile->readVariable("log", "path"));
128 define("ILIAS_LOG_FILE", $ilIliasIniFile->readVariable("log", "file"));
129 define("ILIAS_LOG_ENABLED", $ilIliasIniFile->readVariable("log", "enabled"));
130 define("ILIAS_LOG_LEVEL", $ilIliasIniFile->readVariable("log", "level"));
131 define("SLOW_REQUEST_TIME", $ilIliasIniFile->readVariable("log", "slow_request_time"));
132
133 // read path + command for third party tools from ilias.ini
134 define("PATH_TO_CONVERT", $ilIliasIniFile->readVariable("tools", "convert"));
135 define("PATH_TO_FFMPEG", $ilIliasIniFile->readVariable("tools", "ffmpeg"));
136 define("PATH_TO_ZIP", $ilIliasIniFile->readVariable("tools", "zip"));
137 define("PATH_TO_MKISOFS", $ilIliasIniFile->readVariable("tools", "mkisofs"));
138 define("PATH_TO_UNZIP", $ilIliasIniFile->readVariable("tools", "unzip"));
139 define("PATH_TO_GHOSTSCRIPT", $ilIliasIniFile->readVariable("tools", "ghostscript"));
140 define("PATH_TO_JAVA", $ilIliasIniFile->readVariable("tools", "java"));
141 define("URL_TO_LATEX", $ilIliasIniFile->readVariable("tools", "latex"));
142 define("PATH_TO_FOP", $ilIliasIniFile->readVariable("tools", "fop"));
143 define("PATH_TO_LESSC", $ilIliasIniFile->readVariable("tools", "lessc"));
144 define("PATH_TO_PHANTOMJS", $ilIliasIniFile->readVariable("tools", "phantomjs"));
145
146 if ($ilIliasIniFile->groupExists('error')) {
147 if ($ilIliasIniFile->variableExists('error', 'editor_url')) {
148 define("ERROR_EDITOR_URL", $ilIliasIniFile->readVariable('error', 'editor_url'));
149 }
150
151 if ($ilIliasIniFile->variableExists('error', 'editor_path_translations')) {
152 define("ERROR_EDITOR_PATH_TRANSLATIONS", $ilIliasIniFile->readVariable('error', 'editor_path_translations'));
153 }
154 }
155
156 // read virus scanner settings
157 switch ($ilIliasIniFile->readVariable("tools", "vscantype")) {
158 case "sophos":
159 define("IL_VIRUS_SCANNER", "Sophos");
160 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
161 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
162 break;
163
164 case "antivir":
165 define("IL_VIRUS_SCANNER", "AntiVir");
166 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
167 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
168 break;
169
170 case "clamav":
171 define("IL_VIRUS_SCANNER", "ClamAV");
172 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
173 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
174 break;
175
176 default:
177 define("IL_VIRUS_SCANNER", "None");
178 break;
179 }
180
181 include_once './Services/Calendar/classes/class.ilTimeZone.php';
183 define("IL_TIMEZONE", $tz);
184 }
185
197 public static function bootstrapFilesystems()
198 {
199 global $DIC;
200
201 $DIC['filesystem.security.sanitizing.filename'] = function ($c) {
202 return new FilenameSanitizerImpl();
203 };
204
205 $DIC['filesystem.factory'] = function ($c) {
206 return new \ILIAS\Filesystem\Provider\DelegatingFilesystemFactory($c['filesystem.security.sanitizing.filename']);
207 };
208
209 $DIC['filesystem.web'] = function ($c) {
210 //web
211
215 $delegatingFactory = $c['filesystem.factory'];
216 $webConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID);
217 return $delegatingFactory->getLocal($webConfiguration);
218 };
219
220 $DIC['filesystem.storage'] = function ($c) {
221 //storage
222
226 $delegatingFactory = $c['filesystem.factory'];
227 $storageConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_DATA_DIR . '/' . CLIENT_ID);
228 return $delegatingFactory->getLocal($storageConfiguration);
229 };
230
231 $DIC['filesystem.temp'] = function ($c) {
232 //temp
233
237 $delegatingFactory = $c['filesystem.factory'];
238 $tempConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_DATA_DIR . '/' . CLIENT_ID . '/temp');
239 return $delegatingFactory->getLocal($tempConfiguration);
240 };
241
242 $DIC['filesystem.customizing'] = function ($c) {
243 //customizing
244
248 $delegatingFactory = $c['filesystem.factory'];
249 $customizingConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . 'Customizing');
250 return $delegatingFactory->getLocal($customizingConfiguration);
251 };
252
253 $DIC['filesystem.libs'] = function ($c) {
254 //customizing
255
259 $delegatingFactory = $c['filesystem.factory'];
260 $customizingConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . 'libs');
261 return $delegatingFactory->getLocal($customizingConfiguration, true);
262 };
263
264 $DIC['filesystem'] = function ($c) {
265 return new \ILIAS\Filesystem\FilesystemsImpl(
266 $c['filesystem.storage'],
267 $c['filesystem.web'],
268 $c['filesystem.temp'],
269 $c['filesystem.customizing'],
270 $c['filesystem.libs']
271 );
272 };
273 }
274
275
284 public static function initFileUploadService(\ILIAS\DI\Container $dic)
285 {
286 $dic['upload.processor-manager'] = function ($c) {
287 return new PreProcessorManagerImpl();
288 };
289
290 $dic['upload'] = function (\ILIAS\DI\Container $c) {
291 $fileUploadImpl = new \ILIAS\FileUpload\FileUploadImpl($c['upload.processor-manager'], $c['filesystem'], $c['http']);
292 if (IL_VIRUS_SCANNER != "None") {
293 $fileUploadImpl->register(new VirusScannerPreProcessor(ilVirusScannerFactory::_getInstance()));
294 }
295
296 $fileUploadImpl->register(new FilenameSanitizerPreProcessor());
297 $fileUploadImpl->register(new InsecureFilenameSanitizerPreProcessor());
298 $fileUploadImpl->register(new BlacklistExtensionPreProcessor(ilFileUtils::getExplicitlyBlockedFiles(), $c->language()->txt("msg_info_blacklisted")));
299
300 return $fileUploadImpl;
301 };
302 }
303
307 protected static function buildHTTPPath()
308 {
309 include_once './Services/Http/classes/class.ilHTTPS.php';
310 $https = new ilHTTPS();
311
312 if ($https->isDetected()) {
313 $protocol = 'https://';
314 } else {
315 $protocol = 'http://';
316 }
317 $host = $_SERVER['HTTP_HOST'];
318
319 $rq_uri = strip_tags($_SERVER['REQUEST_URI']);
320
321 // security fix: this failed, if the URI contained "?" and following "/"
322 // -> we remove everything after "?"
323 if (is_int($pos = strpos($rq_uri, "?"))) {
324 $rq_uri = substr($rq_uri, 0, $pos);
325 }
326
327 if (!defined('ILIAS_MODULE')) {
328 $path = pathinfo($rq_uri);
329 if (!$path['extension']) {
330 $uri = $rq_uri;
331 } else {
332 $uri = dirname($rq_uri);
333 }
334 } else {
335 // if in module remove module name from HTTP_PATH
336 $path = dirname($rq_uri);
337
338 // dirname cuts the last directory from a directory path e.g content/classes return content
340
341 $dirs = explode('/', $module);
342 $uri = $path;
343 foreach ($dirs as $dir) {
344 $uri = dirname($uri);
345 }
346 }
347
348 $iliasHttpPath = implode('', [$protocol, $host, $uri]);
352 if (strpos($iliasHttpPath, '/Services/Saml/lib/') !== false && strpos($iliasHttpPath, '/metadata.php') === false) {
353 $iliasHttpPath = substr($iliasHttpPath, 0, strpos($iliasHttpPath, '/Services/Saml/lib/'));
354 }
355 }
356
357 $f = new \ILIAS\Data\Factory();
359
360 return define('ILIAS_HTTP_PATH', $uri->getBaseURI());
361 }
362
367 protected static function determineClient()
368 {
369 global $ilIliasIniFile;
370
371 // check whether ini file object exists
372 if (!is_object($ilIliasIniFile)) {
373 self::abortAndDie('Fatal Error: ilInitialisation::determineClient called without initialisation of ILIAS ini file object.');
374 }
375
376 if (isset($_GET['client_id']) && strlen($_GET['client_id']) > 0) {
377 $_GET['client_id'] = \ilUtil::getClientIdByString((string) $_GET['client_id'])->toString();
378 if (!defined('IL_PHPUNIT_TEST')) {
380 ilUtil::setCookie('ilClientId', $_GET['client_id']);
381 }
382 }
383 } elseif (!isset($_COOKIE['ilClientId'])) {
384 ilUtil::setCookie('ilClientId', $ilIliasIniFile->readVariable('clients', 'default'));
385 }
386
387 if (!defined('IL_PHPUNIT_TEST') && ilContext::supportsPersistentSessions()) {
388 $clientId = $_COOKIE['ilClientId'];
389 } else {
390 $clientId = $_GET['client_id'];
391 }
392
393 define('CLIENT_ID', \ilUtil::getClientIdByString((string) $clientId)->toString());
394 }
395
408 protected static function initClientIniFile()
409 {
410 global $ilIliasIniFile;
411
412 // check whether ILIAS_WEB_DIR is set.
413 if (ILIAS_WEB_DIR == "") {
414 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile called without ILIAS_WEB_DIR.");
415 }
416
417 // check whether CLIENT_ID is set.
418 if (CLIENT_ID == "") {
419 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile called without CLIENT_ID.");
420 }
421
422 $ini_file = "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID . "/client.ini.php";
423
424 // get settings from ini file
425 $ilClientIniFile = new ilIniFile($ini_file);
426 $ilClientIniFile->read();
427
428 // invalid client id / client ini
429 if ($ilClientIniFile->ERROR != "") {
430 $c = $_COOKIE["ilClientId"];
431 $default_client = $ilIliasIniFile->readVariable("clients", "default");
432 ilUtil::setCookie("ilClientId", $default_client);
433 if (CLIENT_ID != "" && CLIENT_ID != $default_client) {
434 $mess = array("en" => "Client does not exist.",
435 "de" => "Mandant ist ungültig.");
436 self::redirect("index.php?client_id=" . $default_client, null, $mess);
437 } else {
438 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile initializing client ini file abborted with: " . $ilClientIniFile->ERROR);
439 }
440 }
441
442 self::initGlobal("ilClientIniFile", $ilClientIniFile);
443
444 // set constants
445 define("SESSION_REMINDER_LEADTIME", 30);
446 define("DEBUG", $ilClientIniFile->readVariable("system", "DEBUG"));
447 define("DEVMODE", $ilClientIniFile->readVariable("system", "DEVMODE"));
448 define("SHOWNOTICES", $ilClientIniFile->readVariable("system", "SHOWNOTICES"));
449 define("DEBUGTOOLS", $ilClientIniFile->readVariable("system", "DEBUGTOOLS"));
450 define("ROOT_FOLDER_ID", $ilClientIniFile->readVariable('system', 'ROOT_FOLDER_ID'));
451 define("SYSTEM_FOLDER_ID", $ilClientIniFile->readVariable('system', 'SYSTEM_FOLDER_ID'));
452 define("ROLE_FOLDER_ID", $ilClientIniFile->readVariable('system', 'ROLE_FOLDER_ID'));
453 define("MAIL_SETTINGS_ID", $ilClientIniFile->readVariable('system', 'MAIL_SETTINGS_ID'));
454 $error_handler = $ilClientIniFile->readVariable('system', 'ERROR_HANDLER');
455 define("ERROR_HANDLER", $error_handler ? $error_handler : "PRETTY_PAGE");
456
457 // this is for the online help installation, which sets OH_REF_ID to the
458 // ref id of the online module
459 define("OH_REF_ID", $ilClientIniFile->readVariable("system", "OH_REF_ID"));
460
461 define("SYSTEM_MAIL_ADDRESS", $ilClientIniFile->readVariable('system', 'MAIL_SENT_ADDRESS')); // Change SS
462 define("MAIL_REPLY_WARNING", $ilClientIniFile->readVariable('system', 'MAIL_REPLY_WARNING')); // Change SS
463
464 // see ilObject::TITLE_LENGTH, ilObject::DESC_LENGTH
465 // define ("MAXLENGTH_OBJ_TITLE",125);#$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_TITLE'));
466 // define ("MAXLENGTH_OBJ_DESC",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_DESC'));
467
468 define("CLIENT_DATA_DIR", ILIAS_DATA_DIR . "/" . CLIENT_ID);
469 define("CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . CLIENT_ID);
470 define("CLIENT_NAME", $ilClientIniFile->readVariable('client', 'name')); // Change SS
471
472 $val = $ilClientIniFile->readVariable("db", "type");
473 if ($val == "") {
474 define("IL_DB_TYPE", "mysql");
475 } else {
476 define("IL_DB_TYPE", $val);
477 }
478
479 $ilGlobalCacheSettings = new ilGlobalCacheSettings();
480 $ilGlobalCacheSettings->readFromIniFile($ilClientIniFile);
481 ilGlobalCache::setup($ilGlobalCacheSettings);
482
483 return true;
484 }
485
489 protected static function handleMaintenanceMode()
490 {
491 global $ilClientIniFile;
492
493 if (!$ilClientIniFile->readVariable("client", "access")) {
494 $mess = array(
495 "en" => "The server is not available due to maintenance." .
496 " We apologise for any inconvenience.",
497 "de" => "Der Server ist aufgrund von Wartungsarbeiten nicht verfügbar." .
498 " Wir bitten um Verständnis."
499 );
500 $mess_id = "init_error_maintenance";
501
502 if (ilContext::hasHTML() && is_file("./maintenance.html")) {
503 self::redirect("./maintenance.html", $mess_id, $mess);
504 } else {
505 $mess = self::translateMessage($mess_id, $mess);
506 self::abortAndDie($mess);
507 }
508 }
509 }
510
515 protected static function initDatabase()
516 {
517 // build dsn of database connection and connect
519 $ilDB->initFromIniFile();
520 $ilDB->connect();
521
522 self::initGlobal("ilDB", $ilDB);
523 }
524
530 public static function setSessionHandler()
531 {
532 if (ini_get('session.save_handler') != 'user' && version_compare(PHP_VERSION, '7.2.0', '<')) {
533 ini_set("session.save_handler", "user");
534 }
535
536 require_once "Services/Authentication/classes/class.ilSessionDBHandler.php";
537 $db_session_handler = new ilSessionDBHandler();
538 if (!$db_session_handler->setSaveHandler()) {
539 self::abortAndDie("Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini");
540 }
541
542 // Do not accept external session ids
543 if (!ilSession::_exists(session_id()) && !defined('IL_PHPUNIT_TEST')) {
544 // php7-todo, correct-with-php5-removal : alex, 1.3.2016: added if, please check
545 if (function_exists("session_status") && session_status() == PHP_SESSION_ACTIVE) {
546 session_regenerate_id();
547 }
548 }
549 }
550
554 protected static function setCookieConstants()
555 {
556 include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
558 $cookie_path = '/';
559 } elseif ($GLOBALS['COOKIE_PATH']) {
560 // use a predefined cookie path from WebAccessChecker
561 $cookie_path = $GLOBALS['COOKIE_PATH'];
562 } else {
563 $cookie_path = dirname($_SERVER['PHP_SELF']);
564 }
565
566 /* if ilias is called directly within the docroot $cookie_path
567 is set to '/' expecting on servers running under windows..
568 here it is set to '\'.
569 in both cases a further '/' won't be appended due to the following regex
570 */
571 $cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
572
573 if ($cookie_path == "\\") {
574 $cookie_path = '/';
575 }
576
577 define('IL_COOKIE_HTTPONLY', true); // Default Value
578 define('IL_COOKIE_EXPIRE', 0);
579 define('IL_COOKIE_PATH', $cookie_path);
580 define('IL_COOKIE_DOMAIN', '');
581 }
582
586 protected static function setSessionCookieParams()
587 {
588 global $ilSetting;
589
590 if (!defined('IL_COOKIE_SECURE')) {
591 // If this code is executed, we can assume that \ilHTTPS::enableSecureCookies was NOT called before
592 // \ilHTTPS::enableSecureCookies already executes session_set_cookie_params()
593
594 include_once './Services/Http/classes/class.ilHTTPS.php';
595 $cookie_secure = !$ilSetting->get('https', 0) && ilHTTPS::getInstance()->isDetected();
596 define('IL_COOKIE_SECURE', $cookie_secure); // Default Value
597
598 session_set_cookie_params(
599 IL_COOKIE_EXPIRE,
601 IL_COOKIE_DOMAIN,
602 IL_COOKIE_SECURE,
603 IL_COOKIE_HTTPONLY
604 );
605 }
606 }
607
611 protected static function initMail(\ILIAS\DI\Container $c)
612 {
613 $c["mail.mime.transport.factory"] = function (\ILIAS\DI\Container $c) {
614 return new \ilMailMimeTransportFactory($c->settings(), $c->event());
615 };
616 $c["mail.mime.sender.factory"] = function (\ILIAS\DI\Container $c) {
617 return new \ilMailMimeSenderFactory($c->settings());
618 };
619 $c["mail.texttemplates.service"] = function (\ILIAS\DI\Container $c) {
620 return new \ilMailTemplateService(new \ilMailTemplateRepository($c->database()));
621 };
622 }
623
627 protected static function initCustomObjectIcons(\ILIAS\DI\Container $c)
628 {
629 $c["object.customicons.factory"] = function ($c) {
630 require_once 'Services/Object/Icon/classes/class.ilObjectCustomIconFactory.php';
631 return new ilObjectCustomIconFactory(
632 $c->filesystem()->web(),
633 $c->upload(),
634 $c['ilObjDataCache']
635 );
636 };
637 }
638
642 protected static function initAvatar(\ILIAS\DI\Container $c)
643 {
644 $c["user.avatar.factory"] = function ($c) {
645 return new \ilUserAvatarFactory($c);
646 };
647 }
648
652 protected static function initTermsOfService(\ILIAS\DI\Container $c)
653 {
654 $c['tos.criteria.type.factory'] = function (\ILIAS\DI\Container $c) {
655 return new ilTermsOfServiceCriterionTypeFactory($c->rbac()->review(), $c['ilObjDataCache']);
656 };
657
658 $c['tos.document.evaluator'] = function (\ILIAS\DI\Container $c) {
661 $c['tos.criteria.type.factory'],
662 $c->user(),
663 $c->logger()->tos()
664 ),
665 $c->user(),
666 $c->logger()->tos(),
667 \ilTermsOfServiceDocument::orderBy('sorting')->get()
668 );
669 };
670 }
671
672 protected static function initAccessibilityControlConcept(\ILIAS\DI\Container $c)
673 {
674 $c['acc.criteria.type.factory'] = function (\ILIAS\DI\Container $c) {
675 return new ilAccessibilityCriterionTypeFactory($c->rbac()->review(), $c['ilObjDataCache']);
676 };
677
678 $c['acc.document.evaluator'] = function (\ILIAS\DI\Container $c) {
681 $c['acc.criteria.type.factory'],
682 $c->user(),
683 $c->logger()->acc()
684 ),
685 $c->user(),
686 $c->logger()->acc(),
687 \ilAccessibilityDocument::orderBy('sorting')->get()
688 );
689 };
690 }
691
697 protected static function initSettings()
698 {
699 global $ilSetting;
700
702 "ilSetting",
703 "ilSetting",
704 "Services/Administration/classes/class.ilSetting.php"
705 );
706
707 // check correct setup
708 if (!$ilSetting->get("setup_ok")) {
709 self::abortAndDie("Setup is not completed. Please run setup routine again.");
710 }
711
712 // set anonymous user & role id and system role id
713 define("ANONYMOUS_USER_ID", $ilSetting->get("anonymous_user_id"));
714 define("ANONYMOUS_ROLE_ID", $ilSetting->get("anonymous_role_id"));
715 define("SYSTEM_USER_ID", $ilSetting->get("system_user_id"));
716 define("SYSTEM_ROLE_ID", $ilSetting->get("system_role_id"));
717 define("USER_FOLDER_ID", 7);
718
719 // recovery folder
720 define("RECOVERY_FOLDER_ID", $ilSetting->get("recovery_folder_id"));
721
722 // installation id
723 define("IL_INST_ID", $ilSetting->get("inst_id", 0));
724
725 // define default suffix replacements
726 define("SUFFIX_REPL_DEFAULT", "php,php3,php4,inc,lang,phtml,htaccess");
727 define("SUFFIX_REPL_ADDITIONAL", $ilSetting->get("suffix_repl_additional"));
728
729 if (ilContext::usesHTTP()) {
731 }
732 }
733
737 protected static function initStyle()
738 {
739 global $DIC, $ilPluginAdmin;
740
741 // load style definitions
743 "styleDefinition",
744 "ilStyleDefinition",
745 "./Services/Style/System/classes/class.ilStyleDefinition.php"
746 );
747
748 // add user interface hook for style initialisation
749 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
750 foreach ($pl_names as $pl) {
751 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
752 $gui_class = $ui_plugin->getUIClassInstance();
753 $gui_class->modifyGUI("Services/Init", "init_style", array("styleDefinition" => $DIC->systemStyle()));
754 }
755 }
756
760 public static function initUserAccount()
761 {
762 global $DIC;
763
764 static $context_init;
765
766 $uid = $GLOBALS['DIC']['ilAuthSession']->getUserId();
767 if ($uid) {
768 $DIC->user()->setId($uid);
769 $DIC->user()->read();
770 if (!isset($context_init)) {
771 if ($DIC->user()->isAnonymous()) {
772 $DIC->globalScreen()->tool()->context()->claim()->external();
773 } else {
774 $DIC->globalScreen()->tool()->context()->claim()->internal();
775 }
776 $context_init = true;
777 }
778 // init console log handler
779 ilLoggerFactory::getInstance()->initUser($DIC->user()->getLogin());
780 \ilOnlineTracking::updateAccess($DIC->user());
781 } else {
782 if (is_object($GLOBALS['ilLog'])) {
783 $GLOBALS['ilLog']->logStack();
784 }
785 self::abortAndDie("Init user account failed");
786 }
787 }
788
792 protected static function initLocale()
793 {
794 global $ilSetting;
795
796 if (trim($ilSetting->get("locale") != "")) {
797 $larr = explode(",", trim($ilSetting->get("locale")));
798 $ls = array();
799 $first = $larr[0];
800 foreach ($larr as $l) {
801 if (trim($l) != "") {
802 $ls[] = $l;
803 }
804 }
805 if (count($ls) > 0) {
806 setlocale(LC_ALL, $ls);
807
808 // #15347 - making sure that floats are not changed
809 setlocale(LC_NUMERIC, "C");
810
811 if (class_exists("Collator")) {
812 $GLOBALS["ilCollator"] = new Collator($first);
813 $GLOBALS["DIC"]["ilCollator"] = function ($c) {
814 return $GLOBALS["ilCollator"];
815 };
816 }
817 }
818 }
819 }
820
826 public static function goToPublicSection()
827 {
828 global $ilAuth;
829
830 if (ANONYMOUS_USER_ID == "") {
831 self::abortAndDie("Public Section enabled, but no Anonymous user found.");
832 }
833
834 $session_destroyed = false;
835 if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
836 $session_destroyed = true;
838 }
839 if (!$GLOBALS['DIC']['ilAuthSession']->isAuthenticated()) {
840 $session_destroyed = true;
842 }
843
844 if ($session_destroyed) {
845 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, ANONYMOUS_USER_ID);
846 }
847
849
850 // if target given, try to go there
851 if (strlen($_GET["target"])) {
852 // when we are already "inside" goto.php no redirect is needed
853 $current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
854 if ($current_script == "goto.php") {
855 return;
856 }
857 // goto will check if target is accessible or redirect to login
858 self::redirect("goto.php?target=" . $_GET["target"]);
859 }
860
861 // check access of root folder otherwise redirect to login
862 #if(!$GLOBALS['DIC']->rbac()->system()->checkAccess('read', ROOT_FOLDER_ID))
863 #{
864 # return self::goToLogin();
865 #}
866
867 // we do not know if ref_id of request is accesible, so redirecting to root
868 $_GET["ref_id"] = ROOT_FOLDER_ID;
869 $_GET["cmd"] = "frameset";
871 "ilias.php?baseClass=ilrepositorygui&reloadpublic=1&cmd=" .
872 $_GET["cmd"] . "&ref_id=" . $_GET["ref_id"]
873 );
874 }
875
881 protected static function goToLogin()
882 {
883 ilLoggerFactory::getLogger('init')->debug('Redirecting to login page.');
884
885 if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
887 }
888 if (!$GLOBALS['DIC']['ilAuthSession']->isAuthenticated()) {
890 }
891
892 $script = "login.php?target=" . $_GET["target"] . "&client_id=" . $_COOKIE["ilClientId"] .
893 "&auth_stat=" . $a_auth_stat;
894
896 $script,
897 "init_error_authentication_fail",
898 array(
899 "en" => "Authentication failed.",
900 "de" => "Authentifizierung fehlgeschlagen.")
901 );
902 }
903
907 protected static function initLanguage($a_use_user_language = true)
908 {
909 global $DIC;
910
914 global $rbacsystem;
915
916 require_once 'Services/Language/classes/class.ilLanguage.php';
917
918 if ($a_use_user_language) {
919 if ($DIC->offsetExists('lng')) {
920 $DIC->offsetUnset('lng');
921 }
923 } else {
925 }
926 if (is_object($rbacsystem) && $DIC->offsetExists('tree')) {
927 $rbacsystem->initMemberView();
928 }
929 }
930
934 protected static function initAccessHandling()
935 {
937 "rbacreview",
938 "ilRbacReview",
939 "./Services/AccessControl/classes/class.ilRbacReview.php"
940 );
941
942 require_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
943 $rbacsystem = ilRbacSystem::getInstance();
944 self::initGlobal("rbacsystem", $rbacsystem);
945
947 "rbacadmin",
948 "ilRbacAdmin",
949 "./Services/AccessControl/classes/class.ilRbacAdmin.php"
950 );
951
953 "ilAccess",
954 "ilAccess",
955 "./Services/AccessControl/classes/class.ilAccess.php"
956 );
957
958 require_once "./Services/Conditions/classes/class.ilConditionHandler.php";
959 }
960
964 protected static function initLog()
965 {
966 include_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
968
969 self::initGlobal("ilLog", $log);
970 // deprecated
971 self::initGlobal("log", $log);
972 }
973
981 protected static function initGlobal($a_name, $a_class, $a_source_file = null)
982 {
983 global $DIC;
984
985 if ($a_source_file) {
986 include_once $a_source_file;
987 $GLOBALS[$a_name] = new $a_class;
988 } else {
989 $GLOBALS[$a_name] = $a_class;
990 }
991
992 $DIC[$a_name] = function ($c) use ($a_name) {
993 return $GLOBALS[$a_name];
994 };
995 }
996
1002 protected static function abortAndDie($a_message)
1003 {
1004 if (is_object($GLOBALS['ilLog'])) {
1005 $GLOBALS['ilLog']->write("Fatal Error: ilInitialisation - " . $a_message);
1006 $GLOBALS['ilLog']->logStack();
1007 }
1008 die($a_message);
1009 }
1010
1014 protected static function handleDevMode()
1015 {
1016 if (defined(SHOWNOTICES) && SHOWNOTICES) {
1017 // no further differentiating of php version regarding to 5.4 neccessary
1018 // when the error reporting is set to E_ALL anyway
1019
1020 // add notices to error reporting
1021 error_reporting(E_ALL);
1022 }
1023
1024 if (defined('DEBUGTOOLS') && DEBUGTOOLS) {
1025 include_once "include/inc.debug.php";
1026 }
1027 }
1028
1029 protected static $already_initialized;
1030
1031
1032 public static function reinitILIAS()
1033 {
1034 self::$already_initialized = false;
1036 }
1037
1041 public static function initILIAS()
1042 {
1043 if (self::$already_initialized) {
1044 return;
1045 }
1046
1047 $GLOBALS["DIC"] = new \ILIAS\DI\Container();
1048 $GLOBALS["DIC"]["ilLoggerFactory"] = function ($c) {
1050 };
1051
1052 self::$already_initialized = true;
1053
1056 if (ilContext::initClient()) {
1060
1061 if (ilContext::hasUser()) {
1063
1066 }
1067 }
1068
1069 // init after Auth otherwise breaks CAS
1071
1072 // language may depend on user setting
1073 self::initLanguage(true);
1074 $GLOBALS['DIC']['tree']->initLangCode();
1075
1079
1080 if (ilContext::hasHTML()) {
1082 }
1084 }
1085 }
1086
1090 protected static function initSession()
1091 {
1092 $GLOBALS["DIC"]["ilAuthSession"] = function ($c) {
1093 $auth_session = ilAuthSession::getInstance(
1094 $c['ilLoggerFactory']->getLogger('auth')
1095 );
1096 $auth_session->init();
1097 return $auth_session;
1098 };
1099 }
1100
1101
1105 public static function handleErrorReporting()
1106 {
1107 // push the error level as high as possible / sane
1108 error_reporting(E_ALL & ~E_NOTICE);
1109
1110 // see handleDevMode() - error reporting might be overwritten again
1111 // but we need the client ini first
1112 }
1113
1117 protected static function initCore()
1118 {
1119 global $ilErr;
1120
1122
1123 // breaks CAS: must be included after CAS context isset in AuthUtils
1124 //self::includePhp5Compliance();
1125
1127
1128
1129 // error handler
1131 "ilErr",
1132 "ilErrorHandling",
1133 "./Services/Init/classes/class.ilErrorHandling.php"
1134 );
1135 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, 'errorHandler'));
1136
1137 // :TODO: obsolete?
1138 // PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
1139
1140 // workaround: load old post variables if error handler 'message' was called
1141 include_once "Services/Authentication/classes/class.ilSession.php";
1142 if (ilSession::get("message")) {
1143 $_POST = ilSession::get("post_vars");
1144 }
1145
1147
1149
1150 define('IL_INITIAL_WD', getcwd());
1151
1152 // deprecated
1153 self::initGlobal("ilias", "ILIAS", "./Services/Init/classes/class.ilias.php");
1154 }
1155
1159 protected static function initClient()
1160 {
1161 global $https, $ilias, $DIC;
1162
1164
1166
1167 self::bootstrapFilesystems();
1168
1170
1171
1172 // --- needs client ini
1173
1174 $ilias->client_id = CLIENT_ID;
1175
1176 if (DEVMODE) {
1178 }
1179
1180
1182
1184
1185 // init dafault language
1186 self::initLanguage(false);
1187
1188 // moved after databases
1189 self::initLog();
1190
1192 "ilAppEventHandler",
1193 "ilAppEventHandler",
1194 "./Services/EventHandling/classes/class.ilAppEventHandler.php"
1195 );
1196
1197 // there are rare cases where initILIAS is called twice for a request
1198 // example goto.php is called and includes ilias.php later
1199 // we must prevent that ilPluginAdmin is initialized twice in
1200 // this case, since this won't get the values out of plugin.php the
1201 // second time properly
1202 if (!isset($DIC["ilPluginAdmin"]) || !$DIC["ilPluginAdmin"] instanceof ilPluginAdmin) {
1204 "ilPluginAdmin",
1205 "ilPluginAdmin",
1206 "./Services/Component/classes/class.ilPluginAdmin.php"
1207 );
1208 }
1209
1212 self::initMail($GLOBALS['DIC']);
1213 self::initAvatar($GLOBALS['DIC']);
1217
1218
1219 // --- needs settings
1220
1222
1223 if (ilContext::usesHTTP()) {
1224 // $https
1225 self::initGlobal("https", "ilHTTPS", "./Services/Http/classes/class.ilHTTPS.php");
1226 $https->enableSecureCookies();
1227 $https->checkPort();
1228 }
1229
1230
1231 // --- object handling
1232
1234 "ilObjDataCache",
1235 "ilObjectDataCache",
1236 "./Services/Object/classes/class.ilObjectDataCache.php"
1237 );
1238
1239 // needed in ilObjectDefinition
1240 require_once "./Services/Xml/classes/class.ilSaxParser.php";
1241
1243 "objDefinition",
1244 "ilObjectDefinition",
1245 "./Services/Object/classes/class.ilObjectDefinition.php"
1246 );
1247
1248 // $tree
1249 require_once "./Services/Tree/classes/class.ilTree.php";
1250 $tree = new ilTree(ROOT_FOLDER_ID);
1251 self::initGlobal("tree", $tree);
1252 unset($tree);
1253
1255 "ilCtrl",
1256 "ilCtrl",
1257 "./Services/UICore/classes/class.ilCtrl.php"
1258 );
1259
1261
1262 // Init GlobalScreen
1264 }
1265
1269 protected static function initUser()
1270 {
1271 global $ilias, $ilUser;
1272
1273 // $ilUser
1275 "ilUser",
1276 "ilObjUser",
1277 "./Services/User/classes/class.ilObjUser.php"
1278 );
1279 $ilias->account = $ilUser;
1280
1282 }
1283
1287 public static function resumeUserSession()
1288 {
1289 global $DIC;
1292 }
1293
1294 if (
1295 !$GLOBALS['DIC']['ilAuthSession']->isAuthenticated() or
1296 $GLOBALS['DIC']['ilAuthSession']->isExpired()
1297 ) {
1298 ilLoggerFactory::getLogger('init')->debug('Current session is invalid: ' . $GLOBALS['DIC']['ilAuthSession']->getId());
1299 $current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
1300 if (self::blockedAuthentication($current_script)) {
1301 ilLoggerFactory::getLogger('init')->debug('Authentication is started in current script.');
1302 // nothing todo: authentication is done in current script
1303 return;
1304 }
1305
1306 return self::handleAuthenticationFail();
1307 }
1308 // valid session
1309
1310 return self::initUserAccount();
1311 }
1312
1316 protected static function handleAuthenticationSuccess()
1317 {
1321 global $ilUser;
1322
1323 require_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
1324 ilOnlineTracking::updateAccess($ilUser);
1325 }
1326
1330 protected static function handleAuthenticationFail()
1331 {
1336 global $ilAuth, $ilSetting;
1337
1338 ilLoggerFactory::getLogger('init')->debug('Handling of failed authentication.');
1339
1340 // #10608
1341 if (
1344 throw new Exception("Authentication failed.");
1345 }
1346 if (
1347 $GLOBALS['DIC']['ilAuthSession']->isExpired() &&
1348 !\ilObjUser::_isAnonymous($GLOBALS['DIC']['ilAuthSession']->getUserId())
1349 ) {
1350 ilLoggerFactory::getLogger('init')->debug('Expired session found -> redirect to login page');
1351 return self::goToLogin();
1352 }
1353 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME'])) {
1354 ilLoggerFactory::getLogger('init')->debug('Redirect to public section.');
1355 return self::goToPublicSection();
1356 }
1357 ilLoggerFactory::getLogger('init')->debug('Redirect to login page.');
1358 return self::goToLogin();
1359 }
1360
1361
1365 protected static function initHTTPServices(\ILIAS\DI\Container $container)
1366 {
1367 $container['http.request_factory'] = function ($c) {
1368 return new \ILIAS\HTTP\Request\RequestFactoryImpl();
1369 };
1370
1371 $container['http.response_factory'] = function ($c) {
1372 return new \ILIAS\HTTP\Response\ResponseFactoryImpl();
1373 };
1374
1375 $container['http.cookie_jar_factory'] = function ($c) {
1376 return new \ILIAS\HTTP\Cookies\CookieJarFactoryImpl();
1377 };
1378
1379 $container['http.response_sender_strategy'] = function ($c) {
1380 return new \ILIAS\HTTP\Response\Sender\DefaultResponseSenderStrategy();
1381 };
1382
1383 $container['http'] = function ($c) {
1384 return new \ILIAS\DI\HTTPServices(
1385 $c['http.response_sender_strategy'],
1386 $c['http.cookie_jar_factory'],
1387 $c['http.request_factory'],
1388 $c['http.response_factory']
1389 );
1390 };
1391 }
1392
1393
1397 private static function initGlobalScreen(\ILIAS\DI\Container $c)
1398 {
1399 $c['global_screen'] = function () use ($c) {
1400 return new Services(new ilGSProviderFactory($c), htmlentities(str_replace(" ", "_", ILIAS_VERSION)));
1401 };
1402 $c->globalScreen()->tool()->context()->stack()->clear();
1403 $c->globalScreen()->tool()->context()->claim()->main();
1404// $c->globalScreen()->tool()->context()->current()->addAdditionalData('DEVMODE', (bool) DEVMODE);
1405 }
1406
1410 public static function initUIFramework(\ILIAS\DI\Container $c)
1411 {
1412 $c["ui.factory"] = function ($c) {
1413 $c["lng"]->loadLanguageModule("ui");
1415 $c["ui.factory.counter"],
1416 $c["ui.factory.button"],
1417 $c["ui.factory.listing"],
1418 $c["ui.factory.image"],
1419 $c["ui.factory.panel"],
1420 $c["ui.factory.modal"],
1421 $c["ui.factory.dropzone"],
1422 $c["ui.factory.popover"],
1423 $c["ui.factory.divider"],
1424 $c["ui.factory.link"],
1425 $c["ui.factory.dropdown"],
1426 $c["ui.factory.item"],
1427 $c["ui.factory.viewcontrol"],
1428 $c["ui.factory.chart"],
1429 $c["ui.factory.input"],
1430 $c["ui.factory.table"],
1431 $c["ui.factory.messagebox"],
1432 $c["ui.factory.card"],
1433 $c["ui.factory.layout"],
1434 $c["ui.factory.maincontrols"],
1435 $c["ui.factory.tree"],
1436 $c["ui.factory.menu"],
1437 $c["ui.factory.symbol"],
1438 $c["ui.factory.legacy"]
1439 );
1440 };
1441 $c["ui.signal_generator"] = function ($c) {
1443 };
1444 $c["ui.factory.counter"] = function ($c) {
1446 };
1447 $c["ui.factory.button"] = function ($c) {
1449 };
1450 $c["ui.factory.listing"] = function ($c) {
1452 };
1453 $c["ui.factory.image"] = function ($c) {
1455 };
1456 $c["ui.factory.panel"] = function ($c) {
1457 return new ILIAS\UI\Implementation\Component\Panel\Factory($c["ui.factory.panel.listing"]);
1458 };
1459 $c["ui.factory.modal"] = function ($c) {
1460 return new ILIAS\UI\Implementation\Component\Modal\Factory($c["ui.signal_generator"]);
1461 };
1462 $c["ui.factory.dropzone"] = function ($c) {
1463 return new ILIAS\UI\Implementation\Component\Dropzone\Factory($c["ui.factory.dropzone.file"]);
1464 };
1465 $c["ui.factory.popover"] = function ($c) {
1466 return new ILIAS\UI\Implementation\Component\Popover\Factory($c["ui.signal_generator"]);
1467 };
1468 $c["ui.factory.divider"] = function ($c) {
1470 };
1471 $c["ui.factory.link"] = function ($c) {
1473 };
1474 $c["ui.factory.dropdown"] = function ($c) {
1476 };
1477 $c["ui.factory.item"] = function ($c) {
1479 };
1480 $c["ui.factory.viewcontrol"] = function ($c) {
1481 return new ILIAS\UI\Implementation\Component\ViewControl\Factory($c["ui.signal_generator"]);
1482 };
1483 $c["ui.factory.chart"] = function ($c) {
1484 return new ILIAS\UI\Implementation\Component\Chart\Factory($c["ui.factory.progressmeter"]);
1485 };
1486 $c["ui.factory.input"] = function ($c) {
1488 $c["ui.signal_generator"],
1489 $c["ui.factory.input.field"],
1490 $c["ui.factory.input.container"]
1491 );
1492 };
1493 $c["ui.factory.table"] = function ($c) {
1494 return new ILIAS\UI\Implementation\Component\Table\Factory($c["ui.signal_generator"]);
1495 };
1496 $c["ui.factory.messagebox"] = function ($c) {
1498 };
1499 $c["ui.factory.card"] = function ($c) {
1501 };
1502 $c["ui.factory.layout"] = function ($c) {
1504 };
1505 $c["ui.factory.maincontrols.slate"] = function ($c) {
1507 $c['ui.signal_generator'],
1508 $c['ui.factory.counter'],
1509 $c["ui.factory.symbol"]
1510 );
1511 };
1512 $c["ui.factory.maincontrols"] = function ($c) {
1514 $c['ui.signal_generator'],
1515 $c['ui.factory.maincontrols.slate']
1516 );
1517 };
1518 $c["ui.factory.menu"] = function ($c) {
1520 };
1521 $c["ui.factory.symbol.glyph"] = function ($c) {
1523 };
1524 $c["ui.factory.symbol.icon"] = function ($c) {
1526 };
1527 $c["ui.factory.symbol.avatar"] = function ($c) {
1529 };
1530 $c["ui.factory.symbol"] = function ($c) {
1532 $c["ui.factory.symbol.icon"],
1533 $c["ui.factory.symbol.glyph"],
1534 $c["ui.factory.symbol.avatar"]
1535 );
1536 };
1537 $c["ui.factory.progressmeter"] = function ($c) {
1539 };
1540 $c["ui.factory.dropzone.file"] = function ($c) {
1542 };
1543 $c["ui.factory.input.field"] = function ($c) {
1544 $data_factory = new ILIAS\Data\Factory();
1545 $refinery = new ILIAS\Refinery\Factory($data_factory, $c["lng"]);
1546
1548 $c["ui.signal_generator"],
1549 $data_factory,
1550 $refinery,
1551 $c["lng"]
1552 );
1553 };
1554 $c["ui.factory.input.container"] = function ($c) {
1556 $c["ui.factory.input.container.form"],
1557 $c["ui.factory.input.container.filter"]
1558 );
1559 };
1560 $c["ui.factory.input.container.form"] = function ($c) {
1562 $c["ui.factory.input.field"]
1563 );
1564 };
1565 $c["ui.factory.input.container.filter"] = function ($c) {
1567 $c["ui.signal_generator"],
1568 $c["ui.factory.input.field"]
1569 );
1570 };
1571 $c["ui.factory.panel.listing"] = function ($c) {
1573 };
1574
1575 $c["ui.renderer"] = function ($c) {
1577 $c["ui.component_renderer_loader"]
1578 );
1579 };
1580 $c["ui.component_renderer_loader"] = function ($c) {
1582 new ILIAS\UI\Implementation\Render\LoaderResourceRegistryWrapper(
1583 $c["ui.resource_registry"],
1584 new ILIAS\UI\Implementation\Render\FSLoader(
1585 new ILIAS\UI\Implementation\Render\DefaultRendererFactory(
1586 $c["ui.factory"],
1587 $c["ui.template_factory"],
1588 $c["lng"],
1589 $c["ui.javascript_binding"],
1590 $c["refinery"]
1591 ),
1592 new ILIAS\UI\Implementation\Component\Symbol\Glyph\GlyphRendererFactory(
1593 $c["ui.factory"],
1594 $c["ui.template_factory"],
1595 $c["lng"],
1596 $c["ui.javascript_binding"],
1597 $c["refinery"]
1598 ),
1599 new ILIAS\UI\Implementation\Component\Input\Field\FieldRendererFactory(
1600 $c["ui.factory"],
1601 $c["ui.template_factory"],
1602 $c["lng"],
1603 $c["ui.javascript_binding"],
1604 $c["refinery"]
1605 )
1606 )
1607 )
1608 );
1609 };
1610 $c["ui.template_factory"] = function ($c) {
1612 $c["tpl"]
1613 );
1614 };
1615 $c["ui.resource_registry"] = function ($c) {
1617 };
1618 $c["ui.javascript_binding"] = function ($c) {
1620 };
1621
1622 $c["ui.factory.tree"] = function ($c) {
1623 return new ILIAS\UI\Implementation\Component\Tree\Factory($c["ui.signal_generator"]);
1624 };
1625
1626 $c["ui.factory.legacy"] = function ($c) {
1627 return new ILIAS\UI\Implementation\Component\Legacy\Factory($c["ui.signal_generator"]);
1628 };
1629
1631 foreach ($plugins as $plugin_data) {
1632 $plugin = ilPluginAdmin::getPluginObject($plugin_data["component_type"], $plugin_data["component_name"], $plugin_data["slot_id"], $plugin_data["name"]);
1633
1634 $c['ui.renderer'] = $plugin->exchangeUIRendererAfterInitialization($c);
1635
1636 foreach ($c->keys() as $key) {
1637 if (strpos($key, "ui.factory") === 0) {
1638 $c[$key] = $plugin->exchangeUIFactoryAfterInitialization($key, $c);
1639 }
1640 }
1641 }
1642 }
1643
1647 protected static function initRefinery(\ILIAS\DI\Container $container)
1648 {
1649 $container['refinery'] = function ($container) {
1650 $dataFactory = new \ILIAS\Data\Factory();
1651 $language = $container['lng'];
1652
1653 return new \ILIAS\Refinery\Factory($dataFactory, $language);
1654 };
1655 }
1656
1660 protected static function initHTML()
1661 {
1662 global $ilUser, $DIC;
1663
1664 if (ilContext::hasUser()) {
1665 // load style definitions
1666 // use the init function with plugin hook here, too
1668 }
1669
1671 $tpl = new ilGlobalPageTemplate($DIC->globalScreen(), $DIC->ui(), $DIC->http());
1672 self::initGlobal("tpl", $tpl);
1673
1674 if (ilContext::hasUser()) {
1675 $request_adjuster = new ilUserRequestTargetAdjustment(
1676 $ilUser,
1677 $GLOBALS['DIC']['ilCtrl'],
1678 $GLOBALS['DIC']->http()->request()
1679 );
1680 $request_adjuster->adjust();
1681 }
1682
1683 require_once "./Services/UICore/classes/class.ilFrameTargetInfo.php";
1684
1686 "ilNavigationHistory",
1687 "ilNavigationHistory",
1688 "Services/Navigation/classes/class.ilNavigationHistory.php"
1689 );
1690
1692 "ilBrowser",
1693 "ilBrowser",
1694 "./Services/Utilities/classes/class.ilBrowser.php"
1695 );
1696
1698 "ilHelp",
1699 "ilHelpGUI",
1700 "Services/Help/classes/class.ilHelpGUI.php"
1701 );
1702
1704 "ilToolbar",
1705 "ilToolbarGUI",
1706 "./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php"
1707 );
1708
1710 "ilLocator",
1711 "ilLocatorGUI",
1712 "./Services/Locator/classes/class.ilLocatorGUI.php"
1713 );
1714
1716 "ilTabs",
1717 "ilTabsGUI",
1718 "./Services/UIComponent/Tabs/classes/class.ilTabsGUI.php"
1719 );
1720
1721 if (ilContext::hasUser()) {
1722 include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
1723 $ilMainMenu = new ilMainMenuGUI("_top");
1724
1725 self::initGlobal("ilMainMenu", $ilMainMenu);
1726 unset($ilMainMenu);
1727
1728 // :TODO: tableGUI related
1729
1730 // set hits per page for all lists using table module
1731 $_GET['limit'] = (int) $ilUser->getPref('hits_per_page');
1732 ilSession::set('tbl_limit', $_GET['limit']);
1733
1734 // the next line makes it impossible to save the offset somehow in a session for
1735 // a specific table (I tried it for the user administration).
1736 // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
1737 // or not set at all (then we want the last offset, e.g. being used from a session var).
1738 // So I added the wrapping if statement. Seems to work (hopefully).
1739 // Alex April 14th 2006
1740 if (isset($_GET['offset']) && $_GET['offset'] != "") { // added April 14th 2006
1741 $_GET['offset'] = (int) $_GET['offset']; // old code
1742 }
1743
1744 self::initGlobal("lti", "ilLTIViewGUI", "./Services/LTI/classes/class.ilLTIViewGUI.php");
1745 $GLOBALS["DIC"]["lti"]->init();
1747 } else {
1748 // several code parts rely on ilObjUser being always included
1749 include_once "Services/User/classes/class.ilObjUser.php";
1750 }
1751 }
1752
1758 protected static function getCurrentCmd()
1759 {
1760 $cmd = $_REQUEST["cmd"];
1761 if (is_array($cmd)) {
1762 return array_shift(array_keys($cmd));
1763 } else {
1764 return $cmd;
1765 }
1766 }
1767
1773 protected static function blockedAuthentication($a_current_script)
1774 {
1776 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for WAC request.');
1777 return true;
1778 }
1780 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for sso request.');
1781 return true;
1782 }
1784 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for webdav request');
1785 return true;
1786 }
1788 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for shibboleth request.');
1789 return true;
1790 }
1792 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for lti provider requests.');
1793 return true;
1794 }
1796 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for SAML request.');
1797 return true;
1798 }
1799 if (
1800 $a_current_script == "register.php" ||
1801 $a_current_script == "pwassist.php" ||
1802 $a_current_script == "confirmReg.php" ||
1803 $a_current_script == "il_securimage_play.php" ||
1804 $a_current_script == "il_securimage_show.php" ||
1805 $a_current_script == 'login.php'
1806 ) {
1807 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for script: ' . $a_current_script);
1808 return true;
1809 }
1810
1811 $requestBaseClass = strtolower($_REQUEST['baseClass']);
1812 if ($requestBaseClass == strtolower(ilStartUpGUI::class)) {
1813 $requestCmdClass = strtolower($_REQUEST['cmdClass']);
1814 if (
1815 $requestCmdClass == strtolower(ilAccountRegistrationGUI::class) ||
1816 $requestCmdClass == strtolower(ilPasswordAssistanceGUI::class)
1817 ) {
1818 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for cmdClass: ' . $requestCmdClass);
1819 return true;
1820 }
1821 $cmd = self::getCurrentCmd();
1822 if (
1823 $cmd == "showTermsOfService" || $cmd == "showClientList" ||
1824 $cmd == 'showAccountMigration' || $cmd == 'migrateAccount' ||
1825 $cmd == 'processCode' || $cmd == 'showLoginPage' || $cmd == 'showLogout' ||
1826 $cmd == 'doStandardAuthentication' || $cmd == 'doCasAuthentication'
1827 ) {
1828 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for cmd: ' . $cmd);
1829 return true;
1830 }
1831 }
1832
1833 // #12884
1834 if (($a_current_script == "goto.php" && $_GET["target"] == "impr_0") ||
1835 strtolower($_GET["baseClass"]) == strtolower(ilImprintGUI::class)) {
1836 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for baseClass: ' . $_GET['baseClass']);
1837 return true;
1838 }
1839
1840 if ($a_current_script == 'goto.php' && in_array($_GET['target'], array(
1841 'usr_registration', 'usr_nameassist', 'usr_pwassist', 'usr_agreement'
1842 ))) {
1843 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for goto target: ' . $_GET['target']);
1844 return true;
1845 }
1846 ilLoggerFactory::getLogger('auth')->debug('Authentication required');
1847 return false;
1848 }
1849
1857 protected static function translateMessage($a_message_id, array $a_message_static = null)
1858 {
1859 global $ilDB, $lng, $ilSetting, $ilClientIniFile, $ilUser;
1860
1861 // current language
1862 if (!$lng) {
1863 $lang = "en";
1864 if ($ilUser) {
1865 $lang = $ilUser->getLanguage();
1866 } elseif ($_REQUEST["lang"]) {
1867 $lang = (string) $_REQUEST["lang"];
1868 } elseif ($ilSetting) {
1869 $lang = $ilSetting->get("language");
1870 } elseif ($ilClientIniFile) {
1871 $lang = $ilClientIniFile->readVariable("language", "default");
1872 }
1873 } else {
1874 $lang = $lng->getLangKey();
1875 }
1876
1877 $message = "";
1878 if ($ilDB && $a_message_id) {
1879 if (!$lng) {
1880 require_once "./Services/Language/classes/class.ilLanguage.php";
1881 $lng = new ilLanguage($lang);
1882 }
1883
1884 $lng->loadLanguageModule("init");
1885 $message = $lng->txt($a_message_id);
1886 } elseif (is_array($a_message_static)) {
1887 if (!isset($a_message_static[$lang])) {
1888 $lang = "en";
1889 }
1890 $message = $a_message_static[$lang];
1891 }
1892 return $message;
1893 }
1894
1902 protected static function redirect($a_target, $a_message_id = '', array $a_message_static = null)
1903 {
1904 // #12739
1905 if (defined("ILIAS_HTTP_PATH") &&
1906 !stristr($a_target, ILIAS_HTTP_PATH)) {
1907 $a_target = ILIAS_HTTP_PATH . "/" . $a_target;
1908 }
1909
1910 foreach (['ext_uid', 'soap_pw'] as $param) {
1911 if (false === strpos($a_target, $param . '=') && isset($GLOBALS['DIC']->http()->request()->getQueryParams()[$param])) {
1912 $a_target = \ilUtil::appendUrlParameterString($a_target, $param . '=' . \ilUtil::stripSlashes(
1913 $GLOBALS['DIC']->http()->request()->getQueryParams()[$param]
1914 ));
1915 }
1916 }
1917
1919 ilUtil::redirect($a_target);
1920 } else {
1921 $message = self::translateMessage($a_message_id, $a_message_static);
1922
1923 // user-directed linked message
1925 $link = self::translateMessage(
1926 "init_error_redirect_click",
1927 array("en" => 'Please click to continue.',
1928 "de" => 'Bitte klicken um fortzufahren.')
1929 );
1930 $mess = $message .
1931 '<br /><a href="' . $a_target . '">' . $link . '</a>';
1932 }
1933 // plain text
1934 else {
1935 // not much we can do here
1936 $mess = $message;
1937
1938 if (!trim($mess)) {
1939 $mess = self::translateMessage(
1940 "init_error_redirect_info",
1941 array("en" => 'Redirect not supported by context.',
1942 "de" => 'Weiterleitungen werden durch Kontext nicht unterstützt.')
1943 ) .
1944 ' (' . $a_target . ')';
1945 }
1946 }
1947
1948 self::abortAndDie($mess);
1949 }
1950 }
1951
1955 public static function redirectToStartingPage()
1956 {
1960 global $ilUser;
1961
1962 // fallback, should never happen
1963 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
1965 return true;
1966 }
1967
1968 // for password change and incomplete profile
1969 // see ilDashboardGUI
1970 if (!$_GET["target"]) {
1971 ilLoggerFactory::getLogger('init')->debug('Redirect to default starting page');
1972 // Redirect here to switch back to http if desired
1973 include_once './Services/User/classes/class.ilUserUtil.php';
1975 } else {
1976 ilLoggerFactory::getLogger('init')->debug('Redirect to target: ' . $_GET['target']);
1977 ilUtil::redirect("goto.php?target=" . $_GET["target"]);
1978 }
1979 }
1980
1981
1982 private static function initBackgroundTasks(\ILIAS\DI\Container $c)
1983 {
1984 global $ilIliasIniFile;
1985
1986 $n_of_tasks = $ilIliasIniFile->readVariable("background_tasks", "number_of_concurrent_tasks");
1987 $sync = $ilIliasIniFile->readVariable("background_tasks", "concurrency");
1988
1989 $n_of_tasks = $n_of_tasks ? $n_of_tasks : 5;
1990 $sync = $sync ? $sync : 'sync'; // The default value is sync.
1991
1992 $c["bt.task_factory"] = function ($c) {
1993 return new \ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory($c["di.injector"]);
1994 };
1995
1996 $c["bt.persistence"] = function ($c) {
1997 return BasicPersistence::instance();
1998 };
1999
2000 $c["bt.injector"] = function ($c) {
2001 return new \ILIAS\BackgroundTasks\Dependencies\Injector($c, new BaseDependencyMap());
2002 };
2003
2004 $c["bt.task_manager"] = function ($c) use ($sync) {
2005 if ($sync == 'sync') {
2006 return new \ILIAS\BackgroundTasks\Implementation\TaskManager\SyncTaskManager($c["bt.persistence"]);
2007 } elseif ($sync == 'async') {
2008 return new \ILIAS\BackgroundTasks\Implementation\TaskManager\AsyncTaskManager($c["bt.persistence"]);
2009 } else {
2010 throw new ilException("The supported Background Task Managers are sync and async. $sync given.");
2011 }
2012 };
2013 }
2014
2015
2016 private static function initInjector(\ILIAS\DI\Container $c)
2017 {
2018 $c["di.dependency_map"] = function ($c) {
2019 return new \ILIAS\BackgroundTasks\Dependencies\DependencyMap\BaseDependencyMap();
2020 };
2021
2022 $c["di.injector"] = function ($c) {
2023 return new \ILIAS\BackgroundTasks\Dependencies\Injector($c, $c["di.dependency_map"]);
2024 };
2025 }
2026
2027 private static function initKioskMode(\ILIAS\DI\Container $c)
2028 {
2029 $c["service.kiosk_mode"] = function ($c) {
2030 return new ilKioskModeService(
2031 $c['ilCtrl'],
2032 $c['lng'],
2033 $c['ilAccess'],
2034 $c['objDefinition']
2035 );
2036 };
2037 }
2038}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$_GET["client_id"]
$_POST["username"]
static orderBy($orderBy, $orderDirection='ASC')
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:18
Builds data types.
Definition: Factory.php:20
Class BlacklistExtensionPreProcessor PreProcessor which denies all blacklisted file extensions.
Implementation of factory for cards.
Definition: Factory.php:13
Implementation of factory for tables.
Definition: Factory.php:13
Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the ...
Caches renderers loaded by another loader.
Wraps global ilTemplate to provide JavaScriptBinding.
const IL_COMP_SERVICE
Interface ilAccessibilitySequentialDocumentEvaluation.
static getInstance(\ilLogger $logger)
Get instance.
static isAuthenticationForced()
Check if authentication is should be forced.
static handleForcedAuthentication()
static usesTemplate()
Uses template engine.
const CONTEXT_WEBDAV
const CONTEXT_SHIBBOLETH
const CONTEXT_APACHE_SSO
static supportsRedirects()
Are redirects supported?
static hasUser()
Based on user authentication?
const CONTEXT_SAML
static supportsPersistentSessions()
Check if context supports persistent session handling.
static getType()
Get context type.
static hasHTML()
Has HTML output.
static usesHTTP()
Uses HTTP aka browser.
const CONTEXT_LTI_PROVIDER
static initClient()
Init client.
const CONTEXT_SOAP
const CONTEXT_WAC
Base class for ILIAS Exception handling.
static getExplicitlyBlockedFiles()
Class ilGSProviderFactory.
Class ilGlobalCacheSettings.
static setup(ilGlobalCacheSettings $ilGlobalCacheSettings)
Class ilGlobalPageTemplate.
HTTPS.
static getInstance()
Get https instance.
INIFile Parser.
ILIAS Initialisation Utility Class perform basic setup: init database handler, load configuration fil...
static blockedAuthentication($a_current_script)
Block authentication based on current request.
static initDatabase()
initialise database object $ilDB
static initHTTPServices(\ILIAS\DI\Container $container)
static goToLogin()
go to login
static initILIAS()
ilias initialisation
static initLocale()
Init Locale.
static removeUnsafeCharacters()
Remove unsafe characters from GET.
static buildHTTPPath()
builds http path
static requireCommonIncludes()
get common include code files
static initClientIniFile()
This method provides a global instance of class ilIniFile for the client.ini.php file in variable $il...
static getCurrentCmd()
Extract current cmd from request.
static initSession()
Init auth session.
static initClient()
Init client-based objects (level 1)
static initCore()
Init core objects (level 0)
static recursivelyRemoveUnsafeCharacters($var)
static initUIFramework(\ILIAS\DI\Container $c)
init the ILIAS UI framework.
static includePhp5Compliance()
This is a hack for authentication.
static handleErrorReporting()
Set error reporting level.
static initFileUploadService(\ILIAS\DI\Container $dic)
Initializes the file upload service.
static determineClient()
This method determines the current client and sets the constant CLIENT_ID.
static translateMessage($a_message_id, array $a_message_static=null)
Translate message if possible.
static redirect($a_target, $a_message_id='', array $a_message_static=null)
Redirects to target url if context supports it.
static initHTML()
init HTML output (level 3)
static initLog()
Init log instance.
static initAvatar(\ILIAS\DI\Container $c)
static goToPublicSection()
go to public section
static resumeUserSession()
Resume an existing user session.
static setSessionHandler()
set session handler to db
static handleDevMode()
Prepare developer tools.
static initUser()
Init user / authentification (level 2)
static initKioskMode(\ILIAS\DI\Container $c)
static initGlobal($a_name, $a_class, $a_source_file=null)
Initialize global instance.
static initBackgroundTasks(\ILIAS\DI\Container $c)
static abortAndDie($a_message)
Exit.
static initInjector(\ILIAS\DI\Container $c)
static setSessionCookieParams()
set session cookie params
static initSettings()
initialise $ilSettings object and define constants
static initGlobalScreen(\ILIAS\DI\Container $c)
static initMail(\ILIAS\DI\Container $c)
static initTermsOfService(\ILIAS\DI\Container $c)
static initRefinery(\ILIAS\DI\Container $container)
static initAccessibilityControlConcept(\ILIAS\DI\Container $c)
static handleMaintenanceMode()
handle maintenance mode
static initAccessHandling()
$ilAccess and $rbac... initialisation
static initUserAccount()
Init user with current account id.
static initCustomObjectIcons(\ILIAS\DI\Container $c)
static initIliasIniFile()
This method provides a global instance of class ilIniFile for the ilias.ini.php file in variable $ilI...
static initStyle()
provide $styleDefinition object
Central entry point for users of the service.
language handling
static getFallbackInstance()
Builds a global default language instance.
static getGlobalInstance()
Builds the global language object.
static getRootLogger()
The unique root logger has a fixed error level.
static getLogger($a_component_id)
Get component logger.
Class ilMailTemplateRepository.
Handles display of the main menu.
static _isAnonymous($usr_id)
Class ilObjectCustomIconFactory.
Administration class for plugins.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
static getActivePlugins()
Get info for all active plugins.
Database Session Handling.
static _exists($a_session_id)
Check whether session exists.
static set($a_var, $a_val)
Set a value.
static setClosingContext($a_context)
set closing context (for statistics)
const SESSION_CLOSE_LOGIN
static get($a_var)
Get a value.
const SESSION_CLOSE_PUBLIC
const SESSION_CLOSE_EXPIRE
Interface ilTermsOfServiceSequentialDocumentEvaluation.
static initDefaultTimeZone(ilIniFile $ini)
Initialize default timezone from system settings.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Class ilUserAccountMaintenanceEnforcement.
static getStartingPointAsUrl()
Get current starting point setting as URL.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static redirect($a_script)
static getClientIdByString(string $clientId)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static removeTrailingPathSeparators($path)
const ILIAS_VERSION
This is how a factory for buttons looks like.
Definition: Factory.php:13
This is how a factory for filters looks like.
Definition: Factory.php:14
This is what a factory for layouts looks like.
Definition: Factory.php:9
This is how the factory for UI elements looks.
Definition: Factory.php:18
$cookie_path
Definition: metadata.php:22
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:47
Class HTTPServicesTest.
static http()
Fetches the global http state from ILIAS.
Class ChatMainBarProvider \MainMenu\Provider.
Class ilAsqQuestionAuthoringFactory.
Class Factory.
global $ilSetting
Definition: privfeed.php:17
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$ilErr
Definition: raiseError.php:18
$log
Definition: result.php:15
$dic
Definition: result.php:13
$lng
global $ilDB
$ilIliasIniFile
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
$iliasHttpPath
$https
Definition: imgupload.php:19
$ilUser
Definition: imgupload.php:18
$container
Definition: wac.php:13
const ILIAS_MODULE
Definition: server.php:14
$lang
Definition: xapiexit.php:8
$message
Definition: xapiexit.php:14
$DIC
Definition: xapitoken.php:46
$_COOKIE[session_name()]
Definition: xapitoken.php:39
$param
Definition: xapitoken.php:31