ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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:
12
13require_once("libs/composer/vendor/autoload.php");
14
15// needed for slow queries, etc.
16if (!isset($GLOBALS['ilGlobalStartTime']) || !$GLOBALS['ilGlobalStartTime']) {
17 $GLOBALS['ilGlobalStartTime'] = microtime();
18}
19
20include_once "Services/Context/classes/class.ilContext.php";
21
38{
42 protected static function removeUnsafeCharacters()
43 {
44 // Remove unsafe characters from GET parameters.
45 // We do not need this characters in any case, so it is
46 // feasible to filter them everytime. POST parameters
47 // need attention through ilUtil::stripSlashes() and similar functions)
49 }
50
51 protected static function recursivelyRemoveUnsafeCharacters($var)
52 {
53 if (is_array($var)) {
54 $mod = [];
55 foreach ($var as $k => $v) {
58 }
59 return $mod;
60 }
61 return strip_tags(
62 str_replace(
63 array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"),
64 "",
65 $var
66 )
67 );
68 }
69
73 protected static function requireCommonIncludes()
74 {
75 // ilTemplate
77 require_once "./Services/UICore/classes/class.ilTemplate.php";
78 }
79
80 // really always required?
81 require_once "./Services/Utilities/classes/class.ilUtil.php";
82 require_once "./Services/Calendar/classes/class.ilDatePresentation.php";
83 require_once "include/inc.ilias_version.php";
84
85 include_once './Services/Authentication/classes/class.ilAuthUtils.php';
86
87 self::initGlobal("ilBench", "ilBenchmark", "./Services/Utilities/classes/class.ilBenchmark.php");
88 }
89
95 protected static function includePhp5Compliance()
96 {
97 include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
99 require_once("include/inc.xml5compliance.php");
100 }
101 require_once("include/inc.xsl5compliance.php");
102 }
103
111 protected static function initIliasIniFile()
112 {
113 require_once("./Services/Init/classes/class.ilIniFile.php");
114 $ilIliasIniFile = new ilIniFile("./ilias.ini.php");
115 $ilIliasIniFile->read();
116 self::initGlobal('ilIliasIniFile', $ilIliasIniFile);
117
118 // initialize constants
119 define("ILIAS_DATA_DIR", $ilIliasIniFile->readVariable("clients", "datadir"));
120 define("ILIAS_WEB_DIR", $ilIliasIniFile->readVariable("clients", "path"));
121 define("ILIAS_ABSOLUTE_PATH", $ilIliasIniFile->readVariable('server', 'absolute_path'));
122
123 // logging
124 define("ILIAS_LOG_DIR", $ilIliasIniFile->readVariable("log", "path"));
125 define("ILIAS_LOG_FILE", $ilIliasIniFile->readVariable("log", "file"));
126 define("ILIAS_LOG_ENABLED", $ilIliasIniFile->readVariable("log", "enabled"));
127 define("ILIAS_LOG_LEVEL", $ilIliasIniFile->readVariable("log", "level"));
128 define("SLOW_REQUEST_TIME", $ilIliasIniFile->readVariable("log", "slow_request_time"));
129
130 // read path + command for third party tools from ilias.ini
131 define("PATH_TO_CONVERT", $ilIliasIniFile->readVariable("tools", "convert"));
132 define("PATH_TO_FFMPEG", $ilIliasIniFile->readVariable("tools", "ffmpeg"));
133 define("PATH_TO_ZIP", $ilIliasIniFile->readVariable("tools", "zip"));
134 define("PATH_TO_MKISOFS", $ilIliasIniFile->readVariable("tools", "mkisofs"));
135 define("PATH_TO_UNZIP", $ilIliasIniFile->readVariable("tools", "unzip"));
136 define("PATH_TO_GHOSTSCRIPT", $ilIliasIniFile->readVariable("tools", "ghostscript"));
137 define("PATH_TO_JAVA", $ilIliasIniFile->readVariable("tools", "java"));
138 define("URL_TO_LATEX", $ilIliasIniFile->readVariable("tools", "latex"));
139 define("PATH_TO_FOP", $ilIliasIniFile->readVariable("tools", "fop"));
140 define("PATH_TO_LESSC", $ilIliasIniFile->readVariable("tools", "lessc"));
141 define("PATH_TO_PHANTOMJS", $ilIliasIniFile->readVariable("tools", "phantomjs"));
142
143 // read virus scanner settings
144 switch ($ilIliasIniFile->readVariable("tools", "vscantype")) {
145 case "sophos":
146 define("IL_VIRUS_SCANNER", "Sophos");
147 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
148 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
149 break;
150
151 case "antivir":
152 define("IL_VIRUS_SCANNER", "AntiVir");
153 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
154 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
155 break;
156
157 case "clamav":
158 define("IL_VIRUS_SCANNER", "ClamAV");
159 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
160 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
161 break;
162
163 default:
164 define("IL_VIRUS_SCANNER", "None");
165 break;
166 }
167
168 include_once './Services/Calendar/classes/class.ilTimeZone.php';
170 define("IL_TIMEZONE", $tz);
171 }
172
184 public static function bootstrapFilesystems()
185 {
186 global $DIC;
187
188 $DIC['filesystem.security.sanitizing.filename'] = function ($c) {
189 return new FilenameSanitizerImpl();
190 };
191
192 $DIC['filesystem.factory'] = function ($c) {
193 return new \ILIAS\Filesystem\Provider\DelegatingFilesystemFactory($c['filesystem.security.sanitizing.filename']);
194 };
195
196 $DIC['filesystem.web'] = function ($c) {
197 //web
198
202 $delegatingFactory = $c['filesystem.factory'];
203 $webConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID);
204 return $delegatingFactory->getLocal($webConfiguration);
205 };
206
207 $DIC['filesystem.storage'] = function ($c) {
208 //storage
209
213 $delegatingFactory = $c['filesystem.factory'];
214 $storageConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_DATA_DIR . '/' . CLIENT_ID);
215 return $delegatingFactory->getLocal($storageConfiguration);
216 };
217
218 $DIC['filesystem.temp'] = function ($c) {
219 //temp
220
224 $delegatingFactory = $c['filesystem.factory'];
225 $tempConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_DATA_DIR . '/' . CLIENT_ID . '/temp');
226 return $delegatingFactory->getLocal($tempConfiguration);
227 };
228
229 $DIC['filesystem.customizing'] = function ($c) {
230 //customizing
231
235 $delegatingFactory = $c['filesystem.factory'];
236 $customizingConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . 'Customizing');
237 return $delegatingFactory->getLocal($customizingConfiguration);
238 };
239
240 $DIC['filesystem.libs'] = function ($c) {
241 //customizing
242
246 $delegatingFactory = $c['filesystem.factory'];
247 $customizingConfiguration = new \ILIAS\Filesystem\Provider\Configuration\LocalConfig(ILIAS_ABSOLUTE_PATH . '/' . 'libs');
248 return $delegatingFactory->getLocal($customizingConfiguration, true);
249 };
250
251 $DIC['filesystem'] = function ($c) {
252 return new \ILIAS\Filesystem\FilesystemsImpl(
253 $c['filesystem.storage'],
254 $c['filesystem.web'],
255 $c['filesystem.temp'],
256 $c['filesystem.customizing'],
257 $c['filesystem.libs']
258 );
259 };
260 }
261
262
271 public static function initFileUploadService(\ILIAS\DI\Container $dic)
272 {
273 $dic['upload.processor-manager'] = function ($c) {
274 return new \ILIAS\FileUpload\Processor\PreProcessorManagerImpl();
275 };
276
277 $dic['upload'] = function ($c) {
278 $fileUploadImpl = new \ILIAS\FileUpload\FileUploadImpl($c['upload.processor-manager'], $c['filesystem'], $c['http']);
279 if (IL_VIRUS_SCANNER != "None") {
280 $fileUploadImpl->register(new \ILIAS\FileUpload\Processor\VirusScannerPreProcessor(ilVirusScannerFactory::_getInstance()));
281 }
282
283 $fileUploadImpl->register(new \ILIAS\FileUpload\Processor\FilenameSanitizerPreProcessor());
284
285 return $fileUploadImpl;
286 };
287 }
288
292 protected static function buildHTTPPath()
293 {
294 include_once './Services/Http/classes/class.ilHTTPS.php';
295 $https = new ilHTTPS();
296
297 if ($https->isDetected()) {
298 $protocol = 'https://';
299 } else {
300 $protocol = 'http://';
301 }
302 $host = $_SERVER['HTTP_HOST'];
303
304 $rq_uri = strip_tags($_SERVER['REQUEST_URI']);
305
306 // security fix: this failed, if the URI contained "?" and following "/"
307 // -> we remove everything after "?"
308 if (is_int($pos = strpos($rq_uri, "?"))) {
309 $rq_uri = substr($rq_uri, 0, $pos);
310 }
311
312 if (!defined('ILIAS_MODULE')) {
313 $path = pathinfo($rq_uri);
314 if (!$path['extension']) {
315 $uri = $rq_uri;
316 } else {
317 $uri = dirname($rq_uri);
318 }
319 } else {
320 // if in module remove module name from HTTP_PATH
321 $path = dirname($rq_uri);
322
323 // dirname cuts the last directory from a directory path e.g content/classes return content
325
326 $dirs = explode('/', $module);
327 $uri = $path;
328 foreach ($dirs as $dir) {
329 $uri = dirname($uri);
330 }
331 }
333 return define('ILIAS_HTTP_PATH', ilUtil::removeTrailingPathSeparators(dirname($protocol . $host . $uri)));
335 $iliasHttpPath = implode('', [$protocol, $host, $uri]);
336 if (strpos($iliasHttpPath, '/Services/Saml/lib/') !== false && strpos($iliasHttpPath, '/metadata.php') === false) {
337 return define('ILIAS_HTTP_PATH', ilUtil::removeTrailingPathSeparators(
338 substr($iliasHttpPath, 0, strpos($iliasHttpPath, '/Services/Saml/lib/'))
339 ));
340 }
341 }
342 return define('ILIAS_HTTP_PATH', ilUtil::removeTrailingPathSeparators($protocol . $host . $uri));
343 }
344
349 protected static function determineClient()
350 {
351 global $ilIliasIniFile;
352
353 // check whether ini file object exists
354 if (!is_object($ilIliasIniFile)) {
355 self::abortAndDie('Fatal Error: ilInitialisation::determineClient called without initialisation of ILIAS ini file object.');
356 }
357
358 if (isset($_GET['client_id']) && strlen($_GET['client_id']) > 0) {
359 $_GET['client_id'] = \ilUtil::getClientIdByString((string) $_GET['client_id'])->toString();
360 if (!defined('IL_PHPUNIT_TEST')) {
362 ilUtil::setCookie('ilClientId', $_GET['client_id']);
363 }
364 }
365 } elseif (!isset($_COOKIE['ilClientId'])) {
366 ilUtil::setCookie('ilClientId', $ilIliasIniFile->readVariable('clients', 'default'));
367 }
368
369 if (!defined('IL_PHPUNIT_TEST') && ilContext::supportsPersistentSessions()) {
370 $clientId = $_COOKIE['ilClientId'];
371 } else {
372 $clientId = $_GET['client_id'];
373 }
374
375 define('CLIENT_ID', \ilUtil::getClientIdByString((string) $clientId)->toString());
376 }
377
390 protected static function initClientIniFile()
391 {
392 global $ilIliasIniFile;
393
394 // check whether ILIAS_WEB_DIR is set.
395 if (ILIAS_WEB_DIR == "") {
396 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile called without ILIAS_WEB_DIR.");
397 }
398
399 // check whether CLIENT_ID is set.
400 if (CLIENT_ID == "") {
401 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile called without CLIENT_ID.");
402 }
403
404 $ini_file = "./" . ILIAS_WEB_DIR . "/" . CLIENT_ID . "/client.ini.php";
405
406 // get settings from ini file
407 $ilClientIniFile = new ilIniFile($ini_file);
408 $ilClientIniFile->read();
409
410 // invalid client id / client ini
411 if ($ilClientIniFile->ERROR != "") {
412 $c = $_COOKIE["ilClientId"];
413 $default_client = $ilIliasIniFile->readVariable("clients", "default");
414 ilUtil::setCookie("ilClientId", $default_client);
415 if (CLIENT_ID != "" && CLIENT_ID != $default_client) {
416 $mess = array("en" => "Client does not exist.",
417 "de" => "Mandant ist ungültig.");
418 self::redirect("index.php?client_id=" . $default_client, null, $mess);
419 } else {
420 self::abortAndDie("Fatal Error: ilInitialisation::initClientIniFile initializing client ini file abborted with: " . $ilClientIniFile->ERROR);
421 }
422 }
423
424 self::initGlobal("ilClientIniFile", $ilClientIniFile);
425
426 // set constants
427 define("SESSION_REMINDER_LEADTIME", 30);
428 define("DEBUG", $ilClientIniFile->readVariable("system", "DEBUG"));
429 define("DEVMODE", $ilClientIniFile->readVariable("system", "DEVMODE"));
430 define("SHOWNOTICES", $ilClientIniFile->readVariable("system", "SHOWNOTICES"));
431 define("DEBUGTOOLS", $ilClientIniFile->readVariable("system", "DEBUGTOOLS"));
432 define("ROOT_FOLDER_ID", $ilClientIniFile->readVariable('system', 'ROOT_FOLDER_ID'));
433 define("SYSTEM_FOLDER_ID", $ilClientIniFile->readVariable('system', 'SYSTEM_FOLDER_ID'));
434 define("ROLE_FOLDER_ID", $ilClientIniFile->readVariable('system', 'ROLE_FOLDER_ID'));
435 define("MAIL_SETTINGS_ID", $ilClientIniFile->readVariable('system', 'MAIL_SETTINGS_ID'));
436 $error_handler = $ilClientIniFile->readVariable('system', 'ERROR_HANDLER');
437 define("ERROR_HANDLER", $error_handler ? $error_handler : "PRETTY_PAGE");
438
439 // this is for the online help installation, which sets OH_REF_ID to the
440 // ref id of the online module
441 define("OH_REF_ID", $ilClientIniFile->readVariable("system", "OH_REF_ID"));
442
443 define("SYSTEM_MAIL_ADDRESS", $ilClientIniFile->readVariable('system', 'MAIL_SENT_ADDRESS')); // Change SS
444 define("MAIL_REPLY_WARNING", $ilClientIniFile->readVariable('system', 'MAIL_REPLY_WARNING')); // Change SS
445
446 // see ilObject::TITLE_LENGTH, ilObject::DESC_LENGTH
447 // define ("MAXLENGTH_OBJ_TITLE",125);#$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_TITLE'));
448 // define ("MAXLENGTH_OBJ_DESC",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_DESC'));
449
450 define("CLIENT_DATA_DIR", ILIAS_DATA_DIR . "/" . CLIENT_ID);
451 define("CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . CLIENT_ID);
452 define("CLIENT_NAME", $ilClientIniFile->readVariable('client', 'name')); // Change SS
453
454 $val = $ilClientIniFile->readVariable("db", "type");
455 if ($val == "") {
456 define("IL_DB_TYPE", "mysql");
457 } else {
458 define("IL_DB_TYPE", $val);
459 }
460
461 $ilGlobalCacheSettings = new ilGlobalCacheSettings();
462 $ilGlobalCacheSettings->readFromIniFile($ilClientIniFile);
463 ilGlobalCache::setup($ilGlobalCacheSettings);
464
465 return true;
466 }
467
471 protected static function handleMaintenanceMode()
472 {
473 global $ilClientIniFile;
474
475 if (!$ilClientIniFile->readVariable("client", "access")) {
476 $mess = array("en" => "The server is not available due to maintenance." .
477 " We apologise for any inconvenience.",
478 "de" => "Der Server ist aufgrund von Wartungsarbeiten nicht verfügbar." .
479 " Wir bitten um Verständnis.");
480 $mess_id = "init_error_maintenance";
481
482 if (ilContext::hasHTML() && is_file("./maintenance.html")) {
483 self::redirect("./maintenance.html", $mess_id, $mess);
484 } else {
485 $mess = self::translateMessage($mess_id, $mess);
486 self::abortAndDie($mess);
487 }
488 }
489 }
490
495 protected static function initDatabase()
496 {
497 // build dsn of database connection and connect
498 require_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
499 $ilDB = ilDBWrapperFactory::getWrapper(IL_DB_TYPE);
500 $ilDB->initFromIniFile();
501 $ilDB->connect();
502
503 self::initGlobal("ilDB", $ilDB);
504 }
505
511 public static function setSessionHandler()
512 {
513 if (ini_get('session.save_handler') != 'user' && version_compare(PHP_VERSION, '7.2.0', '<')) {
514 ini_set("session.save_handler", "user");
515 }
516
517 require_once "Services/Authentication/classes/class.ilSessionDBHandler.php";
518 $db_session_handler = new ilSessionDBHandler();
519 if (!$db_session_handler->setSaveHandler()) {
520 self::abortAndDie("Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini");
521 }
522
523 // Do not accept external session ids
524 if (!ilSession::_exists(session_id()) && !defined('IL_PHPUNIT_TEST')) {
525 // php7-todo, correct-with-php5-removal : alex, 1.3.2016: added if, please check
526 if (function_exists("session_status") && session_status() == PHP_SESSION_ACTIVE) {
527 session_regenerate_id();
528 }
529 }
530 }
531
535 protected static function setCookieConstants()
536 {
537 include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
539 $cookie_path = '/';
540 } elseif ($GLOBALS['COOKIE_PATH']) {
541 // use a predefined cookie path from WebAccessChecker
542 $cookie_path = $GLOBALS['COOKIE_PATH'];
543 } else {
544 $cookie_path = dirname($_SERVER['PHP_SELF']);
545 }
546
547 /* if ilias is called directly within the docroot $cookie_path
548 is set to '/' expecting on servers running under windows..
549 here it is set to '\'.
550 in both cases a further '/' won't be appended due to the following regex
551 */
552 $cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
553
554 if ($cookie_path == "\\") {
555 $cookie_path = '/';
556 }
557
558 define('IL_COOKIE_HTTPONLY', true); // Default Value
559 define('IL_COOKIE_EXPIRE', 0);
560 define('IL_COOKIE_PATH', $cookie_path);
561 define('IL_COOKIE_DOMAIN', '');
562 }
563
567 protected static function setSessionCookieParams()
568 {
569 global $ilSetting;
570
571 if (!defined('IL_COOKIE_SECURE')) {
572 // If this code is executed, we can assume that \ilHTTPS::enableSecureCookies was NOT called before
573 // \ilHTTPS::enableSecureCookies already executes session_set_cookie_params()
574
575 include_once './Services/Http/classes/class.ilHTTPS.php';
576 $cookie_secure = !$ilSetting->get('https', 0) && ilHTTPS::getInstance()->isDetected();
577 define('IL_COOKIE_SECURE', $cookie_secure); // Default Value
578
579 session_set_cookie_params(
580 IL_COOKIE_EXPIRE,
582 IL_COOKIE_DOMAIN,
583 IL_COOKIE_SECURE,
584 IL_COOKIE_HTTPONLY
585 );
586 }
587 }
588
592 protected static function initMail(\ILIAS\DI\Container $c)
593 {
594 $c["mail.mime.transport.factory"] = function (\ILIAS\DI\Container $c) {
595 return new \ilMailMimeTransportFactory($c->settings(), $c->event());
596 };
597 $c["mail.mime.sender.factory"] = function (\ILIAS\DI\Container $c) {
598 return new \ilMailMimeSenderFactory($c->settings());
599 };
600 $c["mail.texttemplates.service"] = function (\ILIAS\DI\Container $c) {
601 return new \ilMailTemplateService(new \ilMailTemplateRepository($c->database()));
602 };
603 }
604
608 protected static function initCustomObjectIcons(\ILIAS\DI\Container $c)
609 {
610 $c["object.customicons.factory"] = function ($c) {
611 require_once 'Services/Object/Icon/classes/class.ilObjectCustomIconFactory.php';
612 return new ilObjectCustomIconFactory(
613 $c->filesystem()->web(),
614 $c->upload(),
615 $c['ilObjDataCache']
616 );
617 };
618 }
619
623 protected static function initAvatar(\ILIAS\DI\Container $c)
624 {
625 $c["user.avatar.factory"] = function ($c) {
626 return new \ilUserAvatarFactory($c);
627 };
628 }
629
633 protected static function initTermsOfService(\ILIAS\DI\Container $c)
634 {
635 $c['tos.criteria.type.factory'] = function (\ILIAS\DI\Container $c) {
636 return new ilTermsOfServiceCriterionTypeFactory($c->rbac()->review(), $c['ilObjDataCache']);
637 };
638
639 $c['tos.document.evaluator'] = function (\ILIAS\DI\Container $c) {
642 $c['tos.criteria.type.factory'],
643 $c->user(),
644 $c->logger()->tos()
645 ),
646 $c->user(),
647 $c->logger()->tos(),
648 \ilTermsOfServiceDocument::orderBy('sorting')->get()
649 );
650 };
651 }
652
658 protected static function initSettings()
659 {
660 global $ilSetting;
661
663 "ilSetting",
664 "ilSetting",
665 "Services/Administration/classes/class.ilSetting.php"
666 );
667
668 // check correct setup
669 if (!$ilSetting->get("setup_ok")) {
670 self::abortAndDie("Setup is not completed. Please run setup routine again.");
671 }
672
673 // set anonymous user & role id and system role id
674 define("ANONYMOUS_USER_ID", $ilSetting->get("anonymous_user_id"));
675 define("ANONYMOUS_ROLE_ID", $ilSetting->get("anonymous_role_id"));
676 define("SYSTEM_USER_ID", $ilSetting->get("system_user_id"));
677 define("SYSTEM_ROLE_ID", $ilSetting->get("system_role_id"));
678 define("USER_FOLDER_ID", 7);
679
680 // recovery folder
681 define("RECOVERY_FOLDER_ID", $ilSetting->get("recovery_folder_id"));
682
683 // installation id
684 define("IL_INST_ID", $ilSetting->get("inst_id", 0));
685
686 // define default suffix replacements
687 define("SUFFIX_REPL_DEFAULT", "php,php3,php4,inc,lang,phtml,htaccess");
688 define("SUFFIX_REPL_ADDITIONAL", $ilSetting->get("suffix_repl_additional"));
689
690 if (ilContext::usesHTTP()) {
692 }
693 }
694
698 protected static function initStyle()
699 {
700 global $DIC, $ilPluginAdmin;
701
702 // load style definitions
704 "styleDefinition",
705 "ilStyleDefinition",
706 "./Services/Style/System/classes/class.ilStyleDefinition.php"
707 );
708
709 // add user interface hook for style initialisation
710 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
711 foreach ($pl_names as $pl) {
712 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
713 $gui_class = $ui_plugin->getUIClassInstance();
714 $gui_class->modifyGUI("Services/Init", "init_style", array("styleDefinition" => $DIC->systemStyle()));
715 }
716 }
717
721 public static function initUserAccount()
722 {
726 global $ilUser;
727
728 $uid = $GLOBALS['DIC']['ilAuthSession']->getUserId();
729 if ($uid) {
730 $ilUser->setId($uid);
731 $ilUser->read();
732
733 // init console log handler
734 include_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
735 ilLoggerFactory::getInstance()->initUser($ilUser->getLogin());
736 \ilOnlineTracking::updateAccess($ilUser);
737 } else {
738 if (is_object($GLOBALS['ilLog'])) {
739 $GLOBALS['ilLog']->logStack();
740 }
741 self::abortAndDie("Init user account failed");
742 }
743 }
744
748 protected static function initLocale()
749 {
750 global $ilSetting;
751
752 if (trim($ilSetting->get("locale") != "")) {
753 $larr = explode(",", trim($ilSetting->get("locale")));
754 $ls = array();
755 $first = $larr[0];
756 foreach ($larr as $l) {
757 if (trim($l) != "") {
758 $ls[] = $l;
759 }
760 }
761 if (count($ls) > 0) {
762 setlocale(LC_ALL, $ls);
763
764 // #15347 - making sure that floats are not changed
765 setlocale(LC_NUMERIC, "C");
766
767 if (class_exists("Collator")) {
768 $GLOBALS["ilCollator"] = new Collator($first);
769 $GLOBALS["DIC"]["ilCollator"] = function ($c) {
770 return $GLOBALS["ilCollator"];
771 };
772 }
773 }
774 }
775 }
776
782 public static function goToPublicSection()
783 {
784 global $ilAuth;
785
786 if (ANONYMOUS_USER_ID == "") {
787 self::abortAndDie("Public Section enabled, but no Anonymous user found.");
788 }
789
790 $session_destroyed = false;
791 if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
792 $session_destroyed = true;
794 }
795 if (!$GLOBALS['DIC']['ilAuthSession']->isAuthenticated()) {
796 $session_destroyed = true;
798 }
799
800 if ($session_destroyed) {
801 $GLOBALS['DIC']['ilAuthSession']->setAuthenticated(true, ANONYMOUS_USER_ID);
802 }
803
804 self::initUserAccount();
805
806 // if target given, try to go there
807 if (strlen($_GET["target"])) {
808 // when we are already "inside" goto.php no redirect is needed
809 $current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
810 if ($current_script == "goto.php") {
811 return;
812 }
813 // goto will check if target is accessible or redirect to login
814 self::redirect("goto.php?target=" . $_GET["target"]);
815 }
816
817 // check access of root folder otherwise redirect to login
818 #if(!$GLOBALS['DIC']->rbac()->system()->checkAccess('read', ROOT_FOLDER_ID))
819 #{
820 # return self::goToLogin();
821 #}
822
823 // we do not know if ref_id of request is accesible, so redirecting to root
824 $_GET["ref_id"] = ROOT_FOLDER_ID;
825 $_GET["cmd"] = "frameset";
827 "ilias.php?baseClass=ilrepositorygui&reloadpublic=1&cmd=" .
828 $_GET["cmd"] . "&ref_id=" . $_GET["ref_id"]
829 );
830 }
831
837 protected static function goToLogin()
838 {
839 ilLoggerFactory::getLogger('init')->debug('Redirecting to login page.');
840
841 if ($GLOBALS['DIC']['ilAuthSession']->isExpired()) {
843 }
844 if (!$GLOBALS['DIC']['ilAuthSession']->isAuthenticated()) {
846 }
847
848 $script = "login.php?target=" . $_GET["target"] . "&client_id=" . $_COOKIE["ilClientId"] .
849 "&auth_stat=" . $a_auth_stat;
850
852 $script,
853 "init_error_authentication_fail",
854 array(
855 "en" => "Authentication failed.",
856 "de" => "Authentifizierung fehlgeschlagen.")
857 );
858 }
859
863 protected static function initLanguage($a_use_user_language = true)
864 {
865 global $DIC;
866
870 global $rbacsystem;
871
872 require_once 'Services/Language/classes/class.ilLanguage.php';
873
874 if ($a_use_user_language) {
875 if ($DIC->offsetExists('lng')) {
876 $DIC->offsetUnset('lng');
877 }
879 } else {
881 }
882 if (is_object($rbacsystem) && $DIC->offsetExists('tree')) {
883 $rbacsystem->initMemberView();
884 }
885 }
886
890 protected static function initAccessHandling()
891 {
893 "rbacreview",
894 "ilRbacReview",
895 "./Services/AccessControl/classes/class.ilRbacReview.php"
896 );
897
898 require_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
899 $rbacsystem = ilRbacSystem::getInstance();
900 self::initGlobal("rbacsystem", $rbacsystem);
901
903 "rbacadmin",
904 "ilRbacAdmin",
905 "./Services/AccessControl/classes/class.ilRbacAdmin.php"
906 );
907
909 "ilAccess",
910 "ilAccess",
911 "./Services/AccessControl/classes/class.ilAccess.php"
912 );
913
914 require_once "./Services/Conditions/classes/class.ilConditionHandler.php";
915 }
916
920 protected static function initLog()
921 {
922 include_once './Services/Logging/classes/public/class.ilLoggerFactory.php';
924
925 self::initGlobal("ilLog", $log);
926 // deprecated
927 self::initGlobal("log", $log);
928 }
929
937 protected static function initGlobal($a_name, $a_class, $a_source_file = null)
938 {
939 global $DIC;
940
941 if ($a_source_file) {
942 include_once $a_source_file;
943 $GLOBALS[$a_name] = new $a_class;
944 } else {
945 $GLOBALS[$a_name] = $a_class;
946 }
947
948 $DIC[$a_name] = function ($c) use ($a_name) {
949 return $GLOBALS[$a_name];
950 };
951 }
952
958 protected static function abortAndDie($a_message)
959 {
960 if (is_object($GLOBALS['ilLog'])) {
961 $GLOBALS['ilLog']->write("Fatal Error: ilInitialisation - " . $a_message);
962 }
963 die($a_message);
964 }
965
969 protected static function handleDevMode()
970 {
971 if (defined(SHOWNOTICES) && SHOWNOTICES) {
972 // no further differentiating of php version regarding to 5.4 neccessary
973 // when the error reporting is set to E_ALL anyway
974
975 // add notices to error reporting
976 error_reporting(E_ALL);
977 }
978
979 if (defined('DEBUGTOOLS') && DEBUGTOOLS) {
980 include_once "include/inc.debug.php";
981 }
982 }
983
984 protected static $already_initialized;
985
986
987 public static function reinitILIAS()
988 {
989 self::$already_initialized = false;
991 }
992
996 public static function initILIAS()
997 {
998 if (self::$already_initialized) {
999 // workaround for bug #17990
1000 // big mess. we prevent double initialisations with ILIAS 5.1, which is good, but...
1001 // the style service uses $_GET["ref_id"] to determine
1002 // the context styles. $_GET["ref_id"] is "corrected" by the "goto" procedure and which calls
1003 // initILIAS again.
1004 // we need a mechanism that detemines our repository context and stores that in an information object
1005 // usable by the style component afterwars. This needs new concepts and a refactoring.
1006 if (ilContext::initClient()) {
1007 global $tpl;
1008 if (is_object($tpl)) {
1009 // load style sheet depending on user's settings
1010 $location_stylesheet = ilUtil::getStyleSheetLocation();
1011 $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
1012 }
1013 }
1014
1015 return;
1016 }
1017
1018 $GLOBALS["DIC"] = new \ILIAS\DI\Container();
1019 $GLOBALS["DIC"]["ilLoggerFactory"] = function ($c) {
1021 };
1022
1023 self::$already_initialized = true;
1024
1027 if (ilContext::initClient()) {
1031
1032 if (ilContext::hasUser()) {
1034
1037 }
1038 }
1039
1040 // init after Auth otherwise breaks CAS
1042
1043 // language may depend on user setting
1044 self::initLanguage(true);
1045 $GLOBALS['DIC']['tree']->initLangCode();
1046
1050
1051 if (ilContext::hasHTML()) {
1052 include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
1054
1056 }
1057 }
1058 }
1059
1063 protected static function initSession()
1064 {
1065 $GLOBALS["DIC"]["ilAuthSession"] = function ($c) {
1066 $auth_session = ilAuthSession::getInstance(
1067 $c['ilLoggerFactory']->getLogger('auth')
1068 );
1069 $auth_session->init();
1070 return $auth_session;
1071 };
1072 }
1073
1074
1078 public static function handleErrorReporting()
1079 {
1080 // push the error level as high as possible / sane
1081 error_reporting(E_ALL & ~E_NOTICE);
1082
1083 // see handleDevMode() - error reporting might be overwritten again
1084 // but we need the client ini first
1085 }
1086
1090 protected static function initCore()
1091 {
1092 global $ilErr;
1093
1095
1096 // breaks CAS: must be included after CAS context isset in AuthUtils
1097 //self::includePhp5Compliance();
1098
1100
1101
1102 // error handler
1104 "ilErr",
1105 "ilErrorHandling",
1106 "./Services/Init/classes/class.ilErrorHandling.php"
1107 );
1108 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, 'errorHandler'));
1109
1110 // :TODO: obsolete?
1111 // PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
1112
1113 // workaround: load old post variables if error handler 'message' was called
1114 include_once "Services/Authentication/classes/class.ilSession.php";
1115 if (ilSession::get("message")) {
1116 $_POST = ilSession::get("post_vars");
1117 }
1118
1120
1122
1123 define('IL_INITIAL_WD', getcwd());
1124
1125 // deprecated
1126 self::initGlobal("ilias", "ILIAS", "./Services/Init/classes/class.ilias.php");
1127 }
1128
1132 protected static function initClient()
1133 {
1134 global $https, $ilias, $DIC;
1135
1137
1139
1140 self::bootstrapFilesystems();
1141
1143
1144
1145 // --- needs client ini
1146
1147 $ilias->client_id = CLIENT_ID;
1148
1149 if (DEVMODE) {
1151 }
1152
1153
1155
1157
1158 // init dafault language
1159 self::initLanguage(false);
1160
1161 // moved after databases
1162 self::initLog();
1163
1165 "ilAppEventHandler",
1166 "ilAppEventHandler",
1167 "./Services/EventHandling/classes/class.ilAppEventHandler.php"
1168 );
1169
1170 // there are rare cases where initILIAS is called twice for a request
1171 // example goto.php is called and includes ilias.php later
1172 // we must prevent that ilPluginAdmin is initialized twice in
1173 // this case, since this won't get the values out of plugin.php the
1174 // second time properly
1175 if (!isset($DIC["ilPluginAdmin"]) || !$DIC["ilPluginAdmin"] instanceof ilPluginAdmin) {
1177 "ilPluginAdmin",
1178 "ilPluginAdmin",
1179 "./Services/Component/classes/class.ilPluginAdmin.php"
1180 );
1181 }
1182
1185 self::initMail($GLOBALS['DIC']);
1186 self::initAvatar($GLOBALS['DIC']);
1189
1190
1191 // --- needs settings
1192
1194
1195 if (ilContext::usesHTTP()) {
1196 // $https
1197 self::initGlobal("https", "ilHTTPS", "./Services/Http/classes/class.ilHTTPS.php");
1198 $https->enableSecureCookies();
1199 $https->checkPort();
1200 }
1201
1202
1203 // --- object handling
1204
1206 "ilObjDataCache",
1207 "ilObjectDataCache",
1208 "./Services/Object/classes/class.ilObjectDataCache.php"
1209 );
1210
1211 // needed in ilObjectDefinition
1212 require_once "./Services/Xml/classes/class.ilSaxParser.php";
1213
1215 "objDefinition",
1216 "ilObjectDefinition",
1217 "./Services/Object/classes/class.ilObjectDefinition.php"
1218 );
1219
1220 // $tree
1221 require_once "./Services/Tree/classes/class.ilTree.php";
1222 $tree = new ilTree(ROOT_FOLDER_ID);
1223 self::initGlobal("tree", $tree);
1224 unset($tree);
1225
1227 "ilCtrl",
1228 "ilCtrl",
1229 "./Services/UICore/classes/class.ilCtrl.php"
1230 );
1231
1233 }
1234
1238 protected static function initUser()
1239 {
1240 global $ilias, $ilUser;
1241
1242 // $ilUser
1244 "ilUser",
1245 "ilObjUser",
1246 "./Services/User/classes/class.ilObjUser.php"
1247 );
1248 $ilias->account = $ilUser;
1249
1251 }
1252
1256 public static function resumeUserSession()
1257 {
1258 include_once './Services/Authentication/classes/class.ilAuthUtils.php';
1261 }
1262
1263 if (
1264 !$GLOBALS['DIC']['ilAuthSession']->isAuthenticated() or
1265 $GLOBALS['DIC']['ilAuthSession']->isExpired()
1266 ) {
1267 ilLoggerFactory::getLogger('init')->debug('Current session is invalid: ' . $GLOBALS['DIC']['ilAuthSession']->getId());
1268 $current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
1269 if (self::blockedAuthentication($current_script)) {
1270 ilLoggerFactory::getLogger('init')->debug('Authentication is started in current script.');
1271 // nothing todo: authentication is done in current script
1272 return;
1273 }
1274 return self::handleAuthenticationFail();
1275 }
1276 // valid session
1277 return self::initUserAccount();
1278 }
1279
1285 public static function authenticate()
1286 {
1287 global $ilAuth, $ilias, $ilErr;
1288
1289 $current_script = substr(strrchr($_SERVER["PHP_SELF"], "/"), 1);
1290
1291 if (self::blockedAuthentication($current_script)) {
1292 return;
1293 }
1294
1295 $oldSid = session_id();
1296
1297 $ilAuth->start();
1298 $ilias->setAuthError($ilErr->getLastError());
1299
1300 if ($ilAuth->getAuth() && $ilAuth->getStatus() == '') {
1301 self::initUserAccount();
1302
1303 self::handleAuthenticationSuccess();
1304 } else {
1305 if (!self::showingLoginForm($current_script)) {
1306 // :TODO: should be moved to context?!
1307 $mandatory_auth = ($current_script != "shib_login.php"
1308 && $current_script != "shib_logout.php"
1309 && $current_script != "saml.php"
1310 && $current_script != "error.php"
1311 && $current_script != "chat.php"
1312 && $current_script != "wac.php"
1313 && $current_script != "index.php"); // #10316
1314
1315 if ($mandatory_auth) {
1316 self::handleAuthenticationFail();
1317 }
1318 }
1319 }
1320 }
1321
1325 protected static function handleAuthenticationSuccess()
1326 {
1330 global $ilUser;
1331
1332 require_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
1333 ilOnlineTracking::updateAccess($ilUser);
1334 }
1335
1339 protected static function handleAuthenticationFail()
1340 {
1345 global $ilAuth, $ilSetting;
1346
1347 ilLoggerFactory::getLogger('init')->debug('Handling of failed authentication.');
1348
1349 // #10608
1350 if (
1353 throw new Exception("Authentication failed.");
1354 }
1355 if (
1356 $GLOBALS['DIC']['ilAuthSession']->isExpired() &&
1357 !\ilObjUser::_isAnonymous($GLOBALS['DIC']['ilAuthSession']->getUserId())
1358 ) {
1359 ilLoggerFactory::getLogger('init')->debug('Expired session found -> redirect to login page');
1360 return self::goToLogin();
1361 }
1362 if (ilPublicSectionSettings::getInstance()->isEnabledForDomain($_SERVER['SERVER_NAME'])) {
1363 ilLoggerFactory::getLogger('init')->debug('Redirect to public section.');
1364 return self::goToPublicSection();
1365 }
1366 ilLoggerFactory::getLogger('init')->debug('Redirect to login page.');
1367 return self::goToLogin();
1368 }
1369
1373 protected static function initHTTPServices(\ILIAS\DI\Container $container)
1374 {
1375 $container['http.request_factory'] = function ($c) {
1376 return new \ILIAS\HTTP\Request\RequestFactoryImpl();
1377 };
1378
1379 $container['http.response_factory'] = function ($c) {
1380 return new \ILIAS\HTTP\Response\ResponseFactoryImpl();
1381 };
1382
1383 $container['http.cookie_jar_factory'] = function ($c) {
1384 return new \ILIAS\HTTP\Cookies\CookieJarFactoryImpl();
1385 };
1386
1387 $container['http.response_sender_strategy'] = function ($c) {
1388 return new \ILIAS\HTTP\Response\Sender\DefaultResponseSenderStrategy();
1389 };
1390
1391 $container['http'] = function ($c) {
1392 return new \ILIAS\DI\HTTPServices(
1393 $c['http.response_sender_strategy'],
1394 $c['http.cookie_jar_factory'],
1395 $c['http.request_factory'],
1396 $c['http.response_factory']
1397 );
1398 };
1399 }
1400
1404 protected static function initGlobalScreen(\ILIAS\DI\Container $c)
1405 {
1406 $c["global_screen"] = function () use ($c) {
1407 return new Services(new ilGSProviderFactory($c));
1408 };
1409 }
1410
1411 protected static function initUIFramework(\ILIAS\DI\Container $c)
1412 {
1413 $c["ui.factory"] = function ($c) {
1415 $c["ui.factory.counter"],
1416 $c["ui.factory.glyph"],
1417 $c["ui.factory.button"],
1418 $c["ui.factory.listing"],
1419 $c["ui.factory.image"],
1420 $c["ui.factory.panel"],
1421 $c["ui.factory.modal"],
1422 $c["ui.factory.dropzone"],
1423 $c["ui.factory.popover"],
1424 $c["ui.factory.divider"],
1425 $c["ui.factory.link"],
1426 $c["ui.factory.dropdown"],
1427 $c["ui.factory.item"],
1428 $c["ui.factory.icon"],
1429 $c["ui.factory.viewcontrol"],
1430 $c["ui.factory.chart"],
1431 $c["ui.factory.input"],
1432 $c["ui.factory.table"],
1433 $c["ui.factory.messagebox"],
1434 $c["ui.factory.card"]
1435 );
1436 };
1437 $c["ui.signal_generator"] = function ($c) {
1439 };
1440 $c["ui.factory.counter"] = function ($c) {
1442 };
1443 $c["ui.factory.glyph"] = function ($c) {
1445 };
1446 $c["ui.factory.button"] = function ($c) {
1448 };
1449 $c["ui.factory.listing"] = function ($c) {
1451 };
1452 $c["ui.factory.image"] = function ($c) {
1454 };
1455 $c["ui.factory.panel"] = function ($c) {
1456 return new ILIAS\UI\Implementation\Component\Panel\Factory($c["ui.factory.panel.listing"]);
1457 };
1458 $c["ui.factory.modal"] = function ($c) {
1459 return new ILIAS\UI\Implementation\Component\Modal\Factory($c["ui.signal_generator"]);
1460 };
1461 $c["ui.factory.dropzone"] = function ($c) {
1462 return new ILIAS\UI\Implementation\Component\Dropzone\Factory($c["ui.factory.dropzone.file"]);
1463 };
1464 $c["ui.factory.popover"] = function ($c) {
1465 return new ILIAS\UI\Implementation\Component\Popover\Factory($c["ui.signal_generator"]);
1466 };
1467 $c["ui.factory.divider"] = function ($c) {
1469 };
1470 $c["ui.factory.link"] = function ($c) {
1472 };
1473 $c["ui.factory.dropdown"] = function ($c) {
1475 };
1476 $c["ui.factory.item"] = function ($c) {
1478 };
1479 $c["ui.factory.icon"] = function ($c) {
1481 };
1482 $c["ui.factory.viewcontrol"] = function ($c) {
1483 return new ILIAS\UI\Implementation\Component\ViewControl\Factory($c["ui.signal_generator"]);
1484 };
1485 $c["ui.factory.chart"] = function ($c) {
1486 return new ILIAS\UI\Implementation\Component\Chart\Factory($c["ui.factory.progressmeter"]);
1487 };
1488 $c["ui.factory.input"] = function ($c) {
1490 $c["ui.signal_generator"],
1491 $c["ui.factory.input.field"],
1492 $c["ui.factory.input.container"]
1493 );
1494 };
1495 $c["ui.factory.table"] = function ($c) {
1496 return new ILIAS\UI\Implementation\Component\Table\Factory($c["ui.signal_generator"]);
1497 };
1498 $c["ui.factory.messagebox"] = function ($c) {
1500 };
1501 $c["ui.factory.card"] = function ($c) {
1503 };
1504 $c["ui.factory.progressmeter"] = function ($c) {
1506 };
1507 $c["ui.factory.dropzone.file"] = function ($c) {
1509 };
1510 $c["ui.factory.input.field"] = function ($c) {
1511 $data_factory = new ILIAS\Data\Factory();
1512 $validation_factory = new ILIAS\Validation\Factory($data_factory, $c["lng"]);
1513 $transformation_factory = new ILIAS\Transformation\Factory();
1515 $c["ui.signal_generator"],
1516 $data_factory,
1517 $validation_factory,
1518 $transformation_factory
1519 );
1520 };
1521 $c["ui.factory.input.container"] = function ($c) {
1523 $c["ui.factory.input.container.form"]
1524 );
1525 };
1526 $c["ui.factory.input.container.form"] = function ($c) {
1528 $c["ui.factory.input.field"]
1529 );
1530 };
1531 $c["ui.factory.panel.listing"] = function ($c) {
1533 };
1534
1535 $c["ui.renderer"] = function ($c) {
1537 $c["ui.component_renderer_loader"]
1538 );
1539 };
1540 $c["ui.component_renderer_loader"] = function ($c) {
1542 new ILIAS\UI\Implementation\Render\LoaderResourceRegistryWrapper(
1543 $c["ui.resource_registry"],
1544 new ILIAS\UI\Implementation\Render\FSLoader(
1545 new ILIAS\UI\Implementation\Render\DefaultRendererFactory(
1546 $c["ui.factory"],
1547 $c["ui.template_factory"],
1548 $c["lng"],
1549 $c["ui.javascript_binding"]
1550 ),
1551 new ILIAS\UI\Implementation\Component\Glyph\GlyphRendererFactory(
1552 $c["ui.factory"],
1553 $c["ui.template_factory"],
1554 $c["lng"],
1555 $c["ui.javascript_binding"]
1556 )
1557 )
1558 )
1559 );
1560 };
1561 $c["ui.template_factory"] = function ($c) {
1563 $c["tpl"]
1564 );
1565 };
1566 $c["ui.resource_registry"] = function ($c) {
1568 };
1569 $c["ui.javascript_binding"] = function ($c) {
1571 };
1572 }
1573
1577 protected static function initHTML()
1578 {
1579 global $ilUser;
1580 require_once "./Services/LTI/classes/class.ilLTIViewGUI.php";
1581 $lti = new ilLTIViewGUI($ilUser);
1582 $GLOBALS["DIC"]["lti"] = $lti;
1583
1584 if (ilContext::hasUser()) {
1585 // load style definitions
1586 // use the init function with plugin hook here, too
1588 }
1591
1592 // LTI
1593 if ($lti->isActive()) {
1594 include_once "./Services/LTI/classes/class.ilTemplate.php";
1595 $tpl = new LTI\ilTemplate("tpl.main.html", true, true, "Services/LTI");
1596 } else {
1597 $tpl = new ilTemplate("tpl.main.html", true, true);
1598 }
1599
1600 self::initGlobal("tpl", $tpl);
1601
1602 if (ilContext::hasUser()) {
1603 require_once 'Services/User/classes/class.ilUserRequestTargetAdjustment.php';
1604 $request_adjuster = new ilUserRequestTargetAdjustment($ilUser, $GLOBALS['DIC']['ilCtrl']);
1605 $request_adjuster->adjust();
1606 }
1607
1608
1609 // load style sheet depending on user's settings
1610 $location_stylesheet = ilUtil::getStyleSheetLocation();
1611 $tpl->setVariable("LOCATION_STYLESHEET", $location_stylesheet);
1612
1613 require_once "./Services/UICore/classes/class.ilFrameTargetInfo.php";
1614
1616 "ilNavigationHistory",
1617 "ilNavigationHistory",
1618 "Services/Navigation/classes/class.ilNavigationHistory.php"
1619 );
1620
1622 "ilBrowser",
1623 "ilBrowser",
1624 "./Services/Utilities/classes/class.ilBrowser.php"
1625 );
1626
1628 "ilHelp",
1629 "ilHelpGUI",
1630 "Services/Help/classes/class.ilHelpGUI.php"
1631 );
1632
1634 "ilToolbar",
1635 "ilToolbarGUI",
1636 "./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php"
1637 );
1638
1640 "ilLocator",
1641 "ilLocatorGUI",
1642 "./Services/Locator/classes/class.ilLocatorGUI.php"
1643 );
1644
1646 "ilTabs",
1647 "ilTabsGUI",
1648 "./Services/UIComponent/Tabs/classes/class.ilTabsGUI.php"
1649 );
1650
1651 if (ilContext::hasUser()) {
1652 // LTI
1653 if ($lti->isActive()) {
1654 include_once './Services/LTI/classes/class.ilMainMenuGUI.php';
1655 $ilMainMenu = new LTI\ilMainMenuGUI("_top");
1656 } else {
1657 include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
1658 $ilMainMenu = new ilMainMenuGUI("_top");
1659 }
1660
1661 self::initGlobal("ilMainMenu", $ilMainMenu);
1662 unset($ilMainMenu);
1663
1664 // :TODO: tableGUI related
1665
1666 // set hits per page for all lists using table module
1667 $_GET['limit'] = (int) $ilUser->getPref('hits_per_page');
1668 ilSession::set('tbl_limit', $_GET['limit']);
1669
1670 // the next line makes it impossible to save the offset somehow in a session for
1671 // a specific table (I tried it for the user administration).
1672 // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
1673 // or not set at all (then we want the last offset, e.g. being used from a session var).
1674 // So I added the wrapping if statement. Seems to work (hopefully).
1675 // Alex April 14th 2006
1676 if (isset($_GET['offset']) && $_GET['offset'] != "") { // added April 14th 2006
1677 $_GET['offset'] = (int) $_GET['offset']; // old code
1678 }
1679
1681 } else {
1682 // several code parts rely on ilObjUser being always included
1683 include_once "Services/User/classes/class.ilObjUser.php";
1684 }
1685 }
1686
1692 protected static function getCurrentCmd()
1693 {
1694 $cmd = $_REQUEST["cmd"];
1695 if (is_array($cmd)) {
1696 return array_shift(array_keys($cmd));
1697 } else {
1698 return $cmd;
1699 }
1700 }
1701
1707 protected static function blockedAuthentication($a_current_script)
1708 {
1710 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for WAC request.');
1711 return true;
1712 }
1714 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for sso request.');
1715 return true;
1716 }
1718 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for webdav request');
1719 return true;
1720 }
1722 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for shibboleth request.');
1723 return true;
1724 }
1726 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for lti provider requests.');
1727 return true;
1728 }
1730 ilLoggerFactory::getLogger('init')->debug('Blocked authentication for SAML request.');
1731 return true;
1732 }
1733 if (
1734 $a_current_script == "register.php" ||
1735 $a_current_script == "pwassist.php" ||
1736 $a_current_script == "confirmReg.php" ||
1737 $a_current_script == "il_securimage_play.php" ||
1738 $a_current_script == "il_securimage_show.php" ||
1739 $a_current_script == 'login.php'
1740 ) {
1741 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for script: ' . $a_current_script);
1742 return true;
1743 }
1744
1745 if ($_REQUEST["baseClass"] == "ilStartUpGUI") {
1746 $cmd_class = $_REQUEST["cmdClass"];
1747
1748 if ($cmd_class == "ilaccountregistrationgui" ||
1749 $cmd_class == "ilpasswordassistancegui") {
1750 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for cmdClass: ' . $cmd_class);
1751 return true;
1752 }
1753
1754 $cmd = self::getCurrentCmd();
1755 if (
1756 $cmd == "showTermsOfService" || $cmd == "showClientList" ||
1757 $cmd == 'showAccountMigration' || $cmd == 'migrateAccount' ||
1758 $cmd == 'processCode' || $cmd == 'showLoginPage' || $cmd == 'doStandardAuthentication' || $cmd == 'doCasAuthentication'
1759 ) {
1760 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for cmd: ' . $cmd);
1761 return true;
1762 }
1763 }
1764
1765 // #12884
1766 if (($a_current_script == "goto.php" && $_GET["target"] == "impr_0") ||
1767 $_GET["baseClass"] == "ilImprintGUI") {
1768 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for baseClass: ' . $_GET['baseClass']);
1769 return true;
1770 }
1771
1772 if ($a_current_script == 'goto.php' && in_array($_GET['target'], array(
1773 'usr_registration', 'usr_nameassist', 'usr_pwassist', 'usr_agreement'
1774 ))) {
1775 ilLoggerFactory::getLogger('auth')->debug('Blocked authentication for goto target: ' . $_GET['target']);
1776 return true;
1777 }
1778
1779 ilLoggerFactory::getLogger('auth')->debug('Authentication required');
1780 return false;
1781 }
1782
1788 protected static function showingLoginForm($a_current_script)
1789 {
1790 if ($a_current_script == "login.php") {
1791 return true;
1792 }
1793
1794 if ($_REQUEST["baseClass"] == "ilStartUpGUI" &&
1795 self::getCurrentCmd() == "showLoginPage") {
1796 return true;
1797 }
1798
1799 return false;
1800 }
1801
1809 protected static function translateMessage($a_message_id, array $a_message_static = null)
1810 {
1811 global $ilDB, $lng, $ilSetting, $ilClientIniFile, $ilUser;
1812
1813 // current language
1814 if (!$lng) {
1815 $lang = "en";
1816 if ($ilUser) {
1817 $lang = $ilUser->getLanguage();
1818 } elseif ($_REQUEST["lang"]) {
1819 $lang = (string) $_REQUEST["lang"];
1820 } elseif ($ilSetting) {
1821 $lang = $ilSetting->get("language");
1822 } elseif ($ilClientIniFile) {
1823 $lang = $ilClientIniFile->readVariable("language", "default");
1824 }
1825 } else {
1826 $lang = $lng->getLangKey();
1827 }
1828
1829 $message = "";
1830 if ($ilDB && $a_message_id) {
1831 if (!$lng) {
1832 require_once "./Services/Language/classes/class.ilLanguage.php";
1833 $lng = new ilLanguage($lang);
1834 }
1835
1836 $lng->loadLanguageModule("init");
1837 $message = $lng->txt($a_message_id);
1838 } elseif (is_array($a_message_static)) {
1839 if (!isset($a_message_static[$lang])) {
1840 $lang = "en";
1841 }
1842 $message = $a_message_static[$lang];
1843 }
1844
1845 return utf8_decode($message);
1846 }
1847
1855 protected static function redirect($a_target, $a_message_id = '', array $a_message_static = null)
1856 {
1857 // #12739
1858 if (defined("ILIAS_HTTP_PATH") &&
1859 !stristr($a_target, ILIAS_HTTP_PATH)) {
1860 $a_target = ILIAS_HTTP_PATH . "/" . $a_target;
1861 }
1862
1863 foreach (['ext_uid', 'soap_pw'] as $param) {
1864 if (false === strpos($a_target, $param . '=') && isset($GLOBALS['DIC']->http()->request()->getQueryParams()[$param])) {
1865 $a_target = \ilUtil::appendUrlParameterString($a_target, $param . '=' . \ilUtil::stripSlashes(
1866 $GLOBALS['DIC']->http()->request()->getQueryParams()[$param]
1867 ));
1868 }
1869 }
1870
1872 ilUtil::redirect($a_target);
1873 } else {
1874 $message = self::translateMessage($a_message_id, $a_message_static);
1875
1876 // user-directed linked message
1878 $link = self::translateMessage(
1879 "init_error_redirect_click",
1880 array("en" => 'Please click to continue.',
1881 "de" => 'Bitte klicken um fortzufahren.')
1882 );
1883 $mess = $message .
1884 '<br /><a href="' . $a_target . '">' . $link . '</a>';
1885 }
1886 // plain text
1887 else {
1888 // not much we can do here
1889 $mess = $message;
1890
1891 if (!trim($mess)) {
1892 $mess = self::translateMessage(
1893 "init_error_redirect_info",
1894 array("en" => 'Redirect not supported by context.',
1895 "de" => 'Weiterleitungen werden durch Kontext nicht unterstützt.')
1896 ) .
1897 ' (' . $a_target . ')';
1898 }
1899 }
1900
1901 self::abortAndDie($mess);
1902 }
1903 }
1904
1908 public static function redirectToStartingPage()
1909 {
1913 global $ilUser;
1914
1915 // fallback, should never happen
1916 if ($ilUser->getId() == ANONYMOUS_USER_ID) {
1918 return true;
1919 }
1920
1921 // for password change and incomplete profile
1922 // see ilPersonalDesktopGUI
1923 if (!$_GET["target"]) {
1924 ilLoggerFactory::getLogger('init')->debug('Redirect to default starting page');
1925 // Redirect here to switch back to http if desired
1926 include_once './Services/User/classes/class.ilUserUtil.php';
1928 } else {
1929 ilLoggerFactory::getLogger('init')->debug('Redirect to target: ' . $_GET['target']);
1930 ilUtil::redirect("goto.php?target=" . $_GET["target"]);
1931 }
1932 }
1933
1934
1935 private static function initBackgroundTasks(\ILIAS\DI\Container $c)
1936 {
1937 global $ilIliasIniFile;
1938
1939 $n_of_tasks = $ilIliasIniFile->readVariable("background_tasks", "number_of_concurrent_tasks");
1940 $sync = $ilIliasIniFile->readVariable("background_tasks", "concurrency");
1941
1942 $n_of_tasks = $n_of_tasks ? $n_of_tasks : 5;
1943 $sync = $sync ? $sync : 'sync'; // The default value is sync.
1944
1945 $c["bt.task_factory"] = function ($c) {
1946 return new \ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory($c["di.injector"]);
1947 };
1948
1949 $c["bt.persistence"] = function ($c) {
1951 };
1952
1953 $c["bt.injector"] = function ($c) {
1954 return new \ILIAS\BackgroundTasks\Dependencies\Injector($c, new BaseDependencyMap());
1955 };
1956
1957 $c["bt.task_manager"] = function ($c) use ($sync) {
1958 if ($sync == 'sync') {
1959 return new \ILIAS\BackgroundTasks\Implementation\TaskManager\SyncTaskManager($c["bt.persistence"]);
1960 } elseif ($sync == 'async') {
1961 return new \ILIAS\BackgroundTasks\Implementation\TaskManager\AsyncTaskManager($c["bt.persistence"]);
1962 } else {
1963 throw new ilException("The supported Background Task Managers are sync and async. $sync given.");
1964 }
1965 };
1966 }
1967
1968
1969 private static function initInjector(\ILIAS\DI\Container $c)
1970 {
1971 $c["di.dependency_map"] = function ($c) {
1972 return new \ILIAS\BackgroundTasks\Dependencies\DependencyMap\BaseDependencyMap();
1973 };
1974
1975 $c["di.injector"] = function ($c) {
1976 return new \ILIAS\BackgroundTasks\Dependencies\Injector($c, $c["di.dependency_map"]);
1977 };
1978 }
1979
1980 private static function initKioskMode(\ILIAS\DI\Container $c)
1981 {
1982 $c["service.kiosk_mode"] = function ($c) {
1983 return new ilKioskModeService(
1984 $c['ilCtrl'],
1985 $c['lng'],
1986 $c['ilAccess'],
1987 $c['objDefinition']
1988 );
1989 };
1990 }
1991}
const PEAR_ERROR_CALLBACK
Definition: PEAR.php:35
$tpl
Definition: ilias.php:10
$cookie_path
Definition: metadata.php:7
const IL_COOKIE_PATH(isset($_GET["client_id"]))
Definition: metadata.php:32
$_COOKIE['client_id']
Definition: server.php:9
global $l
Definition: afr.php:30
$path
Definition: aliased.php:25
$_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:17
Builds data types.
Definition: Factory.php:15
Factory for basic transformations.
Definition: Factory.php:12
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.
Handles display of the main menu for LTI.
special template class to simplify handling of ITX/PEAR
const IL_COMP_SERVICE
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
static start()
Start task scheduler for each server instance.
Base class for ILIAS Exception handling.
Class ilGSProviderFactory.
Class ilGlobalCacheSettings.
static setup(ilGlobalCacheSettings $ilGlobalCacheSettings)
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)
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 authenticate()
Try authentication.
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 showingLoginForm($a_current_script)
Is current view the login form?
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)
init the ILIAS UI framework.
static initMail(\ILIAS\DI\Container $c)
static initTermsOfService(\ILIAS\DI\Container $c)
static handleMaintenanceMode()
handle maintenance mode
static initAccessHandling()
$ilAccess and $rbac... initialisation
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.
@classDescription class for ILIAS ViewLTI
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.
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
special template class to simplify handling of ITX/PEAR
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 getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
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)
This is how a factory for buttons looks like.
Definition: Factory.php:13
This is how the factory for UI elements looks.
Definition: Factory.php:16
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
catch(Exception $e) $message
$sync
if($modEnd===false) $module
Definition: module.php:59
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Class HTTPServicesTest.
static http()
Fetches the global http state from ILIAS.
Class BaseForm.
if(array_key_exists('provider', $_GET)) elseif(array_key_exists( 'provider', $_SESSION)) if(!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) $clientId
instance(Loop $newLoop=null)
Retrieves or sets the global Loop object.
Definition: functions.php:173
Class ilCertificateAppEventListener.
Class Factory.
global $ilSetting
Definition: privfeed.php:17
$ilErr
Definition: raiseError.php:18
$log
Definition: sabredav.php:21
global $DIC
Definition: saml.php:7
$lng
global $ilDB
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$ilIliasIniFile
$iliasHttpPath
$https
Definition: imgupload.php:19
$ilUser
Definition: imgupload.php:18
$container
Definition: wac.php:13
const ILIAS_MODULE
Definition: server.php:14