ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
20 {
21  private $return_before_auth = false;
22 
27  {
28  // Remove unsafe characters from GET parameters.
29  // We do not need this characters in any case, so it is
30  // feasible to filter them everytime. POST parameters
31  // need attention through ilUtil::stripSlashes() and similar functions)
32  if (is_array($_GET))
33  {
34  foreach($_GET as $k => $v)
35  {
36  // \r\n used for IMAP MX Injection
37  // ' used for SQL Injection
38  $_GET[$k] = str_replace(array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"), "", $v);
39 
40  // this one is for XSS of any kind
41  $_GET[$k] = strip_tags($_GET[$k]);
42  }
43  }
44  }
45 
46  public function returnBeforeAuth($a_flag = null)
47  {
48  if(null === $a_flag)
49  {
51  }
52 
53  $this->return_before_auth = $a_flag;
54  return $this;
55  }
56 
61  {
62  global $ilBench;
63 
64  // get pear
65  require_once("include/inc.get_pear.php");
66  require_once("include/inc.check_pear.php");
67 
68  //include class.util first to start StopWatch
69  require_once "./Services/Utilities/classes/class.ilUtil.php";
70  require_once "classes/class.ilBenchmark.php";
71  $ilBench = new ilBenchmark();
72  $GLOBALS['ilBench'] = $ilBench;
73 
74  // BEGIN Usability: Measure response time until footer is displayed on form
75  // The stop statement is in class.ilTemplate.php function addILIASfooter()
76  $ilBench->start("Core", "ElapsedTimeUntilFooter");
77  // END Usability: Measure response time until footer is displayed on form
78 
79  $ilBench->start("Core", "HeaderInclude");
80 
81  // start the StopWatch
82  $GLOBALS['t_pagestart'] = ilUtil::StopWatch();
83 
84  $ilBench->start("Core", "HeaderInclude_IncludeFiles");
85 //echo ":".class_exists("HTML_Template_ITX").":";
86  // Major PEAR Includes
87  require_once "PEAR.php";
88  //require_once "DB.php";
89  require_once "Auth/Auth.php";
90 
91  // HTML_Template_IT support
92  // (location changed with 4.3.2 & higher)
93 /* @include_once "HTML/ITX.php"; // old implementation
94  if (!class_exists("IntegratedTemplateExtension"))
95  {
96  include_once "HTML/Template/ITX.php";
97  include_once "classes/class.ilTemplateHTMLITX.php";
98  }
99  else
100  {
101  include_once "classes/class.ilTemplateITX.php";
102  }*/
103 
104  @include_once "HTML/Template/ITX.php"; // new implementation
105  if (class_exists("HTML_Template_ITX"))
106  {
107  include_once "classes/class.ilTemplateHTMLITX.php";
108  }
109  else
110  {
111  include_once "HTML/ITX.php"; // old implementation
112  include_once "classes/class.ilTemplateITX.php";
113  }
114 
115  require_once "classes/class.ilTemplate.php";
116 
117  //include classes and function libraries
118  require_once "include/inc.db_session_handler.php";
119  require_once "./Services/Database/classes/class.ilDB.php";
120  require_once "./Services/AuthShibboleth/classes/class.ilShibboleth.php";
121  require_once "classes/class.ilias.php";
122  require_once './Services/User/classes/class.ilObjUser.php';
123  require_once "classes/class.ilFormat.php";
124  require_once "./Services/Calendar/classes/class.ilDatePresentation.php";
125  require_once "classes/class.ilSaxParser.php";
126  require_once "./Services/Object/classes/class.ilObjectDefinition.php";
127  require_once "./Services/Style/classes/class.ilStyleDefinition.php";
128  require_once "./Services/Tree/classes/class.ilTree.php";
129  require_once "./Services/Language/classes/class.ilLanguage.php";
130  require_once "./Services/Logging/classes/class.ilLog.php";
131  require_once "Services/Mail/classes/class.ilMailbox.php";
132  require_once "classes/class.ilCtrl2.php";
133  require_once "classes/class.ilConditionHandler.php";
134  require_once "classes/class.ilBrowser.php";
135  require_once "classes/class.ilFrameTargetInfo.php";
136  require_once "Services/Navigation/classes/class.ilNavigationHistory.php";
137  require_once "Services/Help/classes/class.ilHelp.php";
138  require_once "include/inc.ilias_version.php";
139 
140  //include role based access control system
141  require_once "./Services/AccessControl/classes/class.ilAccessHandler.php";
142  require_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
143  require_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
144  require_once "./Services/AccessControl/classes/class.ilRbacReview.php";
145 
146  // include object_data cache
147  require_once "classes/class.ilObjectDataCache.php";
148  require_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
149 
150  //include LocatorGUI
151  require_once "./Services/Locator/classes/class.ilLocatorGUI.php";
152 
153  // include error_handling
154  require_once "classes/class.ilErrorHandling.php";
155 
156  $ilBench->stop("Core", "HeaderInclude_IncludeFiles");
157  }
158 
164  public function includePhp5Compliance()
165  {
166  // php5 downward complaince to php 4 dom xml and clone method
167  if (version_compare(PHP_VERSION,'5','>='))
168  {
170  {
171  require_once("include/inc.xml5compliance.php");
172  }
173  require_once("include/inc.xsl5compliance.php");
174  require_once("include/inc.php4compliance.php");
175  }
176  else
177  {
178  require_once("include/inc.php5compliance.php");
179  }
180 
181  }
182 
183 
191  function initIliasIniFile()
192  {
193  global $ilIliasIniFile;
194 
195  require_once("classes/class.ilIniFile.php");
196  $ilIliasIniFile = new ilIniFile("./ilias.ini.php");
197  $GLOBALS['ilIliasIniFile'] =& $ilIliasIniFile;
198  $ilIliasIniFile->read();
199 
200  // initialize constants
201  define("ILIAS_DATA_DIR",$ilIliasIniFile->readVariable("clients","datadir"));
202  define("ILIAS_WEB_DIR",$ilIliasIniFile->readVariable("clients","path"));
203  define("ILIAS_ABSOLUTE_PATH",$ilIliasIniFile->readVariable('server','absolute_path'));
204 
205  // logging
206  define ("ILIAS_LOG_DIR",$ilIliasIniFile->readVariable("log","path"));
207  define ("ILIAS_LOG_FILE",$ilIliasIniFile->readVariable("log","file"));
208  define ("ILIAS_LOG_ENABLED",$ilIliasIniFile->readVariable("log","enabled"));
209  define ("ILIAS_LOG_LEVEL",$ilIliasIniFile->readVariable("log","level"));
210 
211  // read path + command for third party tools from ilias.ini
212  define ("PATH_TO_CONVERT",$ilIliasIniFile->readVariable("tools","convert"));
213  define ("PATH_TO_ZIP",$ilIliasIniFile->readVariable("tools","zip"));
214  define ("PATH_TO_MKISOFS",$ilIliasIniFile->readVariable("tools","mkisofs"));
215  define ("PATH_TO_UNZIP",$ilIliasIniFile->readVariable("tools","unzip"));
216  define ("PATH_TO_JAVA",$ilIliasIniFile->readVariable("tools","java"));
217  define ("PATH_TO_HTMLDOC",$ilIliasIniFile->readVariable("tools","htmldoc"));
218  define ("URL_TO_LATEX",$ilIliasIniFile->readVariable("tools","latex"));
219  define ("PATH_TO_FOP",$ilIliasIniFile->readVariable("tools","fop"));
220 
221  // read virus scanner settings
222  switch ($ilIliasIniFile->readVariable("tools", "vscantype"))
223  {
224  case "sophos":
225  define("IL_VIRUS_SCANNER", "Sophos");
226  define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
227  define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
228  break;
229 
230  case "antivir":
231  define("IL_VIRUS_SCANNER", "AntiVir");
232  define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
233  define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
234  break;
235 
236  case "clamav":
237  define("IL_VIRUS_SCANNER", "ClamAV");
238  define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
239  define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
240  break;
241 
242  default:
243  define("IL_VIRUS_SCANNER", "None");
244  break;
245  }
246 
247  $tz = $ilIliasIniFile->readVariable("server","timezone");
248  if ($tz != "")
249  {
250  if (function_exists('date_default_timezone_set'))
251  {
252  date_default_timezone_set($tz);
253  }
254  }
255  define ("IL_TIMEZONE", $ilIliasIniFile->readVariable("server","timezone"));
256 
257  //$this->buildHTTPPath();
258  }
259 
266  function buildHTTPPath()
267  {
268  include_once 'classes/class.ilHTTPS.php';
269  $https = new ilHTTPS();
270 
271  if($https->isDetected())
272  {
273  $protocol = 'https://';
274  }
275  else
276  {
277  $protocol = 'http://';
278  }
279  $host = $_SERVER['HTTP_HOST'];
280 
281  $rq_uri = $_SERVER['REQUEST_URI'];
282 
283  // security fix: this failed, if the URI contained "?" and following "/"
284  // -> we remove everything after "?"
285  if (is_int($pos = strpos($rq_uri, "?")))
286  {
287  $rq_uri = substr($rq_uri, 0, $pos);
288  }
289 
290  if(!defined('ILIAS_MODULE'))
291  {
292  $path = pathinfo($rq_uri);
293  if(!$path['extension'])
294  {
295  $uri = $rq_uri;
296  }
297  else
298  {
299  $uri = dirname($rq_uri);
300  }
301  }
302  else
303  {
304  // if in module remove module name from HTTP_PATH
305  $path = dirname($rq_uri);
306 
307  // dirname cuts the last directory from a directory path e.g content/classes return content
308 
310 
311  $dirs = explode('/',$module);
312  $uri = $path;
313  foreach($dirs as $dir)
314  {
315  $uri = dirname($uri);
316  }
317  }
318 
319  return define('ILIAS_HTTP_PATH',ilUtil::removeTrailingPathSeparators($protocol.$host.$uri));
320  }
321 
322 
327  function determineClient()
328  {
329  global $ilIliasIniFile;
330 
331  // check whether ini file object exists
332  if (!is_object($ilIliasIniFile))
333  {
334  die ("Fatal Error: ilInitialisation::determineClient called without initialisation of ILIAS ini file object.");
335  }
336 
337  // set to default client if empty
338  if ($_GET["client_id"] != "")
339  {
340  if (!defined("IL_PHPUNIT_TEST"))
341  {
342  ilUtil::setCookie("ilClientId", $_GET["client_id"]);
343  }
344  }
345  else if (!$_COOKIE["ilClientId"])
346  {
347  // to do: ilias ini raus nehmen
348  $client_id = $ilIliasIniFile->readVariable("clients","default");
349  ilUtil::setCookie("ilClientId", $client_id);
350 //echo "set cookie";
351  }
352 //echo "-".$_COOKIE["ilClientId"]."-";
353  if (!defined("IL_PHPUNIT_TEST"))
354  {
355  define ("CLIENT_ID", $_COOKIE["ilClientId"]);
356  }
357  else
358  {
359  define ("CLIENT_ID", $_GET["client_id"]);
360  }
361  }
362 
375  function initClientIniFile()
376  {
377  global $ilClientIniFile;
378 
379  // check whether ILIAS_WEB_DIR is set.
380  if (ILIAS_WEB_DIR == "")
381  {
382  die ("Fatal Error: ilInitialisation::initClientIniFile called without ILIAS_WEB_DIR.");
383  }
384 
385  // check whether CLIENT_ID is set.
386  if (CLIENT_ID == "")
387  {
388  die ("Fatal Error: ilInitialisation::initClientIniFile called without CLIENT_ID.");
389  }
390 
391  $ini_file = "./".ILIAS_WEB_DIR."/".CLIENT_ID."/client.ini.php";
392 
393  // get settings from ini file
394  require_once("classes/class.ilIniFile.php");
395  $ilClientIniFile = new ilIniFile($ini_file);
396  $GLOBALS['ilClientIniFile'] =& $ilClientIniFile;
397  $ilClientIniFile->read();
398 
399  // if no ini-file found switch to setup routine
400  if ($ilClientIniFile->ERROR != "")
401  {
402  return false;
403  }
404 
405  // set constants
406  define ("SESSION_REMINDER_LEADTIME", 30);
407  define ("DEBUG",$ilClientIniFile->readVariable("system","DEBUG"));
408  define ("DEVMODE",$ilClientIniFile->readVariable("system","DEVMODE"));
409  define ("ROOT_FOLDER_ID",$ilClientIniFile->readVariable('system','ROOT_FOLDER_ID'));
410  define ("SYSTEM_FOLDER_ID",$ilClientIniFile->readVariable('system','SYSTEM_FOLDER_ID'));
411  define ("ROLE_FOLDER_ID",$ilClientIniFile->readVariable('system','ROLE_FOLDER_ID'));
412  define ("MAIL_SETTINGS_ID",$ilClientIniFile->readVariable('system','MAIL_SETTINGS_ID'));
413 
414  define ("SYSTEM_MAIL_ADDRESS",$ilClientIniFile->readVariable('system','MAIL_SENT_ADDRESS')); // Change SS
415  define ("MAIL_REPLY_WARNING",$ilClientIniFile->readVariable('system','MAIL_REPLY_WARNING')); // Change SS
416 
417  define ("MAXLENGTH_OBJ_TITLE",125);#$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_TITLE'));
418  define ("MAXLENGTH_OBJ_DESC",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_DESC'));
419 
420  define ("CLIENT_DATA_DIR",ILIAS_DATA_DIR."/".CLIENT_ID);
421  define ("CLIENT_WEB_DIR",ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".CLIENT_ID);
422  define ("CLIENT_NAME",$ilClientIniFile->readVariable('client','name')); // Change SS
423 
424  $val = $ilClientIniFile->readVariable("db","type");
425  if ($val == "")
426  {
427  define ("IL_DB_TYPE", "mysql");
428  }
429  else
430  {
431  define ("IL_DB_TYPE", $val);
432  }
433  return true;
434  }
435 
440  {
441  global $ilClientIniFile;
442 
443  if (!$ilClientIniFile->readVariable("client","access"))
444  {
445  if (is_file("./maintenance.html"))
446  {
447  ilUtil::redirect("./maintenance.html");
448  }
449  else
450  {
451  // to do: include standard template here
452  die('<br /><p style="text-align:center;">The server is not '.
453  'available due to maintenance. We apologise for any inconvenience.</p>');
454  }
455  }
456  }
457 
462  function initDatabase()
463  {
464  global $ilDB, $ilClientIniFile;
465 
466  // build dsn of database connection and connect
467  require_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
468  $ilDB = ilDBWrapperFactory::getWrapper(IL_DB_TYPE);
469  $ilDB->initFromIniFile();
470  $ilDB->connect();
471  $GLOBALS['ilDB'] = $ilDB;
472 
473  }
474 
478  function initEventHandling()
479  {
480  global $ilAppEventHandler;
481 
482  // build dsn of database connection and connect
483  require_once("./Services/EventHandling/classes/class.ilAppEventHandler.php");
484  $ilAppEventHandler = new ilAppEventHandler();
485  $GLOBALS['ilAppEventHandler'] =& $ilAppEventHandler;
486  }
487 
491  function setSessionHandler()
492  {
493  global $ilErr;
494 
495  // set session handler
496  if(ini_get('session.save_handler') != 'user')
497  {
498  ini_set("session.save_handler", "user");
499  }
500  if (!db_set_save_handler())
501  {
502  die("Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini");
503  }
504 
505  }
509  function setCookieParams($context)
510  {
511  if($context == 'webdav')
512  {
513  $cookie_path = '/';
514  }
515  else
516  {
517  $cookie_path = dirname( $_SERVER['PHP_SELF'] );
518  }
519 
520  /* if ilias is called directly within the docroot $cookie_path
521  is set to '/' expecting on servers running under windows..
522  here it is set to '\'.
523  in both cases a further '/' won't be appended due to the following regex
524  */
525  $cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
526 
527  if($cookie_path == "\\") $cookie_path = '/';
528 
529  $cookie_domain = $_SERVER['SERVER_NAME'];
530 
531  define('IL_COOKIE_EXPIRE',0);
532  define('IL_COOKIE_PATH',$cookie_path);
533  define('IL_COOKIE_DOMAIN','');
534  define('IL_COOKIE_SECURE',false); // Default Value
535 
536  // session_set_cookie_params() supports 5th parameter
537  // only for php version 5.2.0 and above
538  if( version_compare(PHP_VERSION, '5.2.0', '>=') )
539  {
540  // PHP version >= 5.2.0
541  define('IL_COOKIE_HTTPONLY',false); // Default Value
542  session_set_cookie_params(
543  IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
544  );
545  }
546  else
547  {
548  // PHP version < 5.2.0
549  session_set_cookie_params(
550  IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE
551  );
552  }
553  }
554 
558  function initSettings()
559  {
560  global $ilSetting;
561 
562  require_once("Services/Administration/classes/class.ilSetting.php");
563  $ilSetting = new ilSetting();
564  $GLOBALS['ilSetting'] =& $ilSetting;
565 
566  // set anonymous user & role id and system role id
567  define ("ANONYMOUS_USER_ID", $ilSetting->get("anonymous_user_id"));
568  define ("ANONYMOUS_ROLE_ID", $ilSetting->get("anonymous_role_id"));
569  define ("SYSTEM_USER_ID", $ilSetting->get("system_user_id"));
570  define ("SYSTEM_ROLE_ID", $ilSetting->get("system_role_id"));
571  define ("USER_FOLDER_ID", 7);
572 
573  // recovery folder
574  define ("RECOVERY_FOLDER_ID", $ilSetting->get("recovery_folder_id"));
575 
576  // installation id
577  define ("IL_INST_ID", $ilSetting->get("inst_id",0));
578 
579  // define default suffix replacements
580  define ("SUFFIX_REPL_DEFAULT", "php,php3,php4,inc,lang,phtml,htaccess");
581  define ("SUFFIX_REPL_ADDITIONAL", $ilSetting->get("suffix_repl_additional"));
582 
583  $this->buildHTTPPath();
584  }
585 
586 
591  {
592  $this->script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
593  $dirname = dirname($_SERVER["PHP_SELF"]);
594  $ilurl = @parse_url(ILIAS_HTTP_PATH);
595  if (!$ilurl["path"])
596  {
597  $ilurl["path"] = "/";
598  }
599  $subdir = substr(strstr($dirname,$ilurl["path"]),strlen($ilurl["path"]));
600  $updir = "";
601 
602  if ($subdir)
603  {
604  $num_subdirs = substr_count($subdir,"/");
605 
606  for ($i=1;$i<=$num_subdirs;$i++)
607  {
608  $updir .= "../";
609  }
610  }
611  $this->updir = $updir;
612  }
613 
617  function initStyle()
618  {
619  global $ilBench, $styleDefinition;
620 
621  // load style definitions
622  $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
623  $styleDefinition = new ilStyleDefinition();
624  $GLOBALS['styleDefinition'] =& $styleDefinition;
625  $styleDefinition->startParsing();
626  $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
627  }
628 
629 
633  function handleStyle()
634  {
635  global $styleDefinition;
636 
637  if ($_GET['skin'] && $_GET['style'])
638  {
639  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
640  if ($styleDefinition->styleExists($_GET['skin'], $_GET['style']) &&
642  {
643  $_SESSION['skin'] = $_GET['skin'];
644  $_SESSION['style'] = $_GET['style'];
645  }
646  }
647  if ($_SESSION['skin'] && $_SESSION['style'])
648  {
649  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
650  if ($styleDefinition->styleExists($_SESSION['skin'], $_SESSION['style']) &&
652  {
653  $ilias->account->skin = $_SESSION['skin'];
654  $ilias->account->prefs['style'] = $_SESSION['style'];
655  }
656  }
657  }
658 
659  function initUserAccount()
660  {
661  global $ilUser, $ilLog, $ilAuth;
662 
663  //get user id
664  if (empty($_SESSION["AccountId"]))
665  {
666  $uid = $ilUser->checkUserId();
667  $_SESSION["AccountId"] = $uid;
668  if ($uid > 0)
669  {
670  $ilUser->setId($uid);
671  }
672  // assigned roles are stored in $_SESSION["RoleId"]
673  // DISABLED smeyer 20070510
674  #$rbacreview = new ilRbacReview();
675  #$GLOBALS['rbacreview'] =& $rbacreview;
676  #$_SESSION["RoleId"] = $rbacreview->assignedRoles($_SESSION["AccountId"]);
677  } // TODO: do we need 'else' here?
678  else
679  {
680  // init user
681  $ilUser->setId($_SESSION["AccountId"]);
682  }
683 
684  // load account data of current user
685  $ilUser->read();
686  }
687 
691  function initLocale()
692  {
693  global $ilSetting;
694 
695  if (trim($ilSetting->get("locale") != ""))
696  {
697  $larr = explode(",", trim($ilSetting->get("locale")));
698  $ls = array();
699  $first = $larr[0];
700  foreach ($larr as $l)
701  {
702  if (trim($l) != "")
703  {
704  $ls[] = $l;
705  }
706  }
707  if (count($ls) > 0)
708  {
709  setlocale(LC_ALL, $ls);
710  if (class_exists("Collator"))
711  {
712  $GLOBALS["ilCollator"] = new Collator($first);
713  }
714  }
715  }
716  }
717 
718 
719  function checkUserClientIP()
720  {
721  global $ilUser, $ilLog, $ilAuth, $ilias;
722 
723  // check client ip
724  $clientip = $ilUser->getClientIP();
725  if (trim($clientip) != "")
726  {
727  $clientip = preg_replace("/[^0-9.?*,:]+/","",$clientip);
728  $clientip = str_replace(".","\\.",$clientip);
729  $clientip = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $clientip);
730  if (!preg_match("/^".$clientip."$/", $_SERVER["REMOTE_ADDR"]))
731  {
732  $ilLog ->logError(1,
733  $ilias->account->getLogin().":".$_SERVER["REMOTE_ADDR"].":".$message);
734  $ilAuth->logout();
735  @session_destroy();
736  ilUtil::redirect("login.php?wrong_ip=true");
737  }
738  }
739  }
740 
742  {
743  global $ilUser, $ilAuth;
744 
745  // are we currently in user agreement acceptance?
746  $in_user_agreement = false;
747  if (strtolower($_GET["cmdClass"]) == "ilstartupgui" &&
748  (strtolower($_GET["cmd"]) == "getacceptance" ||
749  (is_array($_POST["cmd"]) &&
750  key($_POST["cmd"]) == "getAcceptance")))
751  {
752  $in_user_agreement = true;
753  }
754 
755  // check wether user has accepted the user agreement
756  // echo "-".$script;
757  if (!$ilUser->hasAcceptedUserAgreement() &&
758  $ilAuth->getAuth() &&
759  !$in_user_agreement &&
760  $ilUser->getId() != ANONYMOUS_USER_ID)
761  {
762  if($ilAuth->supportsRedirects())
763  {
764  ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=".$_GET["target"]."&cmd=getAcceptance");
765  }
766  }
767  }
768 
769 
773  function goToPublicSection()
774  {
775  global $ilAuth;
776 
777  // logout and end previous session
778  $ilAuth->logout();
779  session_unset();
780  session_destroy();
781 
782  // new session and login as anonymous
783  $this->setSessionHandler();
784  session_start();
785  $_POST["username"] = "anonymous";
786  $_POST["password"] = "anonymous";
788  $ilAuth->start();
789 
790  if (ANONYMOUS_USER_ID == "")
791  {
792  die ("Public Section enabled, but no Anonymous user found.");
793  }
794  if (!$ilAuth->getAuth())
795  {
796  die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
797  }
798 
799  // if target given, try to go there
800  if ($_GET["target"] != "")
801  {
802  $this->initUserAccount();
803 
804  // target is accessible -> goto target
805  include_once("Services/Init/classes/class.ilStartUpGUI.php");
806  if (ilStartUpGUI::_checkGoto($_GET["target"]))
807  {
808  // Disabled: GET parameter is kept, since no redirect. smeyer
809  // additional parameter capturing for survey access codes
810  /*
811  $survey_parameter = "";
812  if (array_key_exists("accesscode", $_GET))
813  {
814  $survey_parameter = "&accesscode=" . $_GET["accesscode"];
815  }
816  */
817  // Disabled redirect for public section
818  return true;
819  #ilUtil::redirect(ILIAS_HTTP_PATH.
820  # "/goto.php?target=".$_GET["target"].$survey_parameter);
821  }
822  else // target is not accessible -> login
823  {
824  $this->goToLogin();
825  }
826  }
827 
828  $_GET["ref_id"] = ROOT_FOLDER_ID;
829 
830  $_GET["cmd"] = "frameset";
831  $jump_script = "repository.php";
832 
833  $script = $this->updir.$jump_script."?reloadpublic=1&cmd=".$_GET["cmd"]."&ref_id=".$_GET["ref_id"];
834 
835  // todo do it better, if JS disabled
836  //echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n";
837  echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
838  'Please click <a href="'.$script.'">here</a> if you are not redirected automatically.';
839  exit;
840  }
841 
842 
846  function goToLogin($a_auth_stat = "")
847  {
848  global $PHP_SELF;
849 
850  session_unset();
851  session_destroy();
852 
853  $add = "";
854  if ($_GET["soap_pw"] != "")
855  {
856  $add = "&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"];
857  }
858 
859  $script = $this->updir."login.php?target=".$_GET["target"]."&client_id=".$_COOKIE["ilClientId"].
860  "&auth_stat=".$a_auth_stat.$add;
861 
862  // todo do it better, if JS disabled
863  // + this is, when session "ends", so
864  // we should try to prevent some information about current
865  // location
866  //
867  // check whether we are currently doing a goto call
868  if (is_int(strpos($PHP_SELF, "goto.php")) && $_GET["soap_pw"] == "" &&
869  $_GET["reloadpublic"] != "1")
870  {
871  $script = $this->updir."goto.php?target=".$_GET["target"]."&client_id=".CLIENT_ID.
872  "&reloadpublic=1";
873  }
874 
875  echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
876  'Please click <a href="'.$script.'">here</a> if you are not redirected automatically.';
877 
878  exit;
879 
880  }
881 
885  function initLanguage()
886  {
887  global $ilBench, $lng, $ilUser, $ilSetting;
888 
889  //init language
890  $ilBench->start("Core", "HeaderInclude_initLanguage");
891 
892  if (is_null($_SESSION['lang']))
893  {
894  if ($_GET["lang"])
895  {
896  $_GET["lang"] = $_GET["lang"];
897  }
898  else
899  {
900  if (is_object($ilUser))
901  {
902  $_GET["lang"] = $ilUser->getPref("language");
903  }
904  }
905  }
906 
907  if ($_POST['change_lang_to'] != "")
908  {
909  $_GET['lang'] = ilUtil::stripSlashes($_POST['change_lang_to']);
910  }
911 
912  $_SESSION['lang'] = ($_GET['lang']) ? $_GET['lang'] : $_SESSION['lang'];
913 
914  // prefer personal setting when coming from login screen
915  // Added check for ilUser->getId > 0 because it is 0 when the language is changed and the user agreement should be displayes (Helmut Schottm��ller, 2006-10-14)
916  if (is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID && $ilUser->getId() > 0)
917  {
918  $_SESSION['lang'] = $ilUser->getPref("language");
919  }
920 
921  // check whether lang selection is valid
923  if (!in_array($_SESSION['lang'], $langs))
924  {
925  if (is_object($ilSetting) && $ilSetting->get("language") != "")
926  {
927  $_SESSION['lang'] = $ilSetting->get("language");
928  }
929  else
930  {
931  $_SESSION['lang'] = $langs[0];
932  }
933  }
934  $_GET['lang'] = $_SESSION['lang'];
935 
936  $lng = new ilLanguage($_SESSION['lang']);
937  $GLOBALS['lng'] =& $lng;
938  $ilBench->stop("Core", "HeaderInclude_initLanguage");
939 
940  // TODO: another location
941  global $rbacsystem;
942  if(is_object($rbacsystem))
943  {
944  $rbacsystem->initMemberView();
945  }
946 
947  }
948 
953  {
954  global $ilBench, $rbacsystem, $rbacadmin, $rbacreview;
955 
956  $ilBench->start("Core", "HeaderInclude_initRBAC");
957  $rbacreview = new ilRbacReview();
958  $GLOBALS['rbacreview'] =& $rbacreview;
959 
960  $rbacsystem = ilRbacSystem::getInstance();
961  $GLOBALS['rbacsystem'] =& $rbacsystem;
962 
963  $rbacadmin = new ilRbacAdmin();
964  $GLOBALS['rbacadmin'] =& $rbacadmin;
965 
966  $ilAccess = new ilAccessHandler();
967  $GLOBALS["ilAccess"] =& $ilAccess;
968  $ilBench->stop("Core", "HeaderInclude_initRBAC");
969  }
970 
971 
976  function initILIAS($context = "web")
977  {
978  global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile,
979  $ilSetting, $ilias, $https, $ilObjDataCache,
980  $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp,
981  $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
982 
983  // remove unsafe characters
984  $this->removeUnsafeCharacters();
985 
986  // error reporting
987  // remove notices from error reporting
988  if (version_compare(PHP_VERSION, '5.3.0', '>='))
989  {
990  error_reporting((ini_get("error_reporting") & ~E_NOTICE) & ~E_DEPRECATED);
991  }
992  else
993  {
994  error_reporting(ini_get('error_reporting') & ~E_NOTICE);
995  }
996 
997 
998  // include common code files
999  $this->requireCommonIncludes();
1000  global $ilBench;
1001 
1002  // set error handler (to do: check preconditions for error handler to work)
1003  $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
1004  $ilErr = new ilErrorHandling();
1005  $GLOBALS['ilErr'] =& $ilErr;
1006  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
1007  $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
1008 
1009 
1010  // prepare file access to work with safe mode (has been done in class ilias before)
1011  umask(0117);
1012 
1013  // set cookie params
1014  $this->setCookieParams($context);
1015 
1016  // $ilIliasIniFile initialisation
1017  $this->initIliasIniFile();
1018 
1019 
1020  // CLIENT_ID determination
1021  $this->determineClient();
1022 
1023  // $ilAppEventHandler initialisation
1024  $this->initEventHandling();
1025 
1026  // $ilClientIniFile initialisation
1027  if (!$this->initClientIniFile())
1028  {
1029  $c = $_COOKIE["ilClientId"];
1030  ilUtil::setCookie("ilClientId", $ilIliasIniFile->readVariable("clients","default"));
1031  if (CLIENT_ID != "" && CLIENT_ID != $ilIliasIniFile->readVariable("clients","default"))
1032  {
1033  ilUtil::redirect("index.php?client_id=".$ilIliasIniFile->readVariable("clients","default"));
1034  }
1035  else
1036  {
1037  echo ("Client $c does not exist. ".'Please <a href="./index.php">click here</a> to return to the default client.');
1038  }
1039  exit;
1040  //ilUtil::redirect("./setup/setup.php"); // to do: this could fail in subdirectories
1041  // this is also source of a bug (see mantis)
1042  }
1043 
1044  // allow login by submitting user data
1045  // in query string when DEVMODE is enabled
1046  if( DEVMODE
1047  && isset($_GET['username']) && strlen($_GET['username'])
1048  && isset($_GET['password']) && strlen($_GET['password'])
1049  ){
1050  $_POST['username'] = $_GET['username'];
1051  $_POST['password'] = $_GET['password'];
1052  }
1053 
1054  // maintenance mode
1055  $this->handleMaintenanceMode();
1056 
1057  // $ilDB initialisation
1058  $this->initDatabase();
1059 
1060  // init plugin admin class
1061  include_once("./Services/Component/classes/class.ilPluginAdmin.php");
1062  $ilPluginAdmin = new ilPluginAdmin();
1063  $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
1064 
1065  // set session handler
1066  $this->setSessionHandler();
1067 
1068  // $ilSetting initialisation
1069  $this->initSettings();
1070 
1071 
1072  // $ilLog initialisation
1073  $this->initLog();
1074 
1075  // $https initialisation
1076  require_once './classes/class.ilHTTPS.php';
1077  $https = new ilHTTPS();
1078  $GLOBALS['https'] =& $https;
1079  $https->enableSecureCookies();
1080  $https->checkPort();
1081 
1082  if($this->returnBeforeAuth()) return;
1083 
1084  // $ilAuth initialisation
1085  include_once("./Services/Authentication/classes/class.ilAuthUtils.php");
1087  global $ilAuth;
1088 
1089  $this->includePhp5Compliance();
1090 
1091 //echo get_class($ilAuth);
1092 //var_dump($ilAuth);
1093 
1094  // Do not accept external session ids
1095  if (!ilSession::_exists(session_id()))
1096  {
1097 // $_GET["PHPSESSID"] = "";
1098  session_regenerate_id();
1099  }
1100 
1101  // $ilias initialisation
1102  global $ilias, $ilBench;
1103  $ilBench->start("Core", "HeaderInclude_GetILIASObject");
1104  $ilias = new ILIAS();
1105  $GLOBALS['ilias'] =& $ilias;
1106  $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
1107 
1108  // test: trace function calls in debug mode
1109  if (DEVMODE)
1110  {
1111  if (function_exists("xdebug_start_trace"))
1112  {
1113  //xdebug_start_trace("/tmp/test.txt");
1114  }
1115  }
1116 
1117  // $ilObjDataCache initialisation
1118  $ilObjDataCache = new ilObjectDataCache();
1119  $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
1120 
1121  // workaround: load old post variables if error handler 'message' was called
1122  if ($_SESSION["message"])
1123  {
1124  $_POST = $_SESSION["post_vars"];
1125  }
1126 
1127 
1128  // put debugging functions here
1129  require_once "include/inc.debug.php";
1130 
1131 
1132  // $objDefinition initialisation
1133  $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
1134  $objDefinition = new ilObjectDefinition();
1135  $GLOBALS['objDefinition'] =& $objDefinition;
1136 // $objDefinition->startParsing();
1137  $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
1138 
1139  // init tree
1140  $tree = new ilTree(ROOT_FOLDER_ID);
1141  $GLOBALS['tree'] =& $tree;
1142 
1143  // $ilAccess and $rbac... initialisation
1144  $this->initAccessHandling();
1145 
1146  // authenticate & start session
1147  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
1148  $ilBench->start("Core", "HeaderInclude_Authentication");
1149 //var_dump($_SESSION);
1153 
1154  if (!defined("IL_PHPUNIT_TEST"))
1155  {
1156  $ilAuth->start();
1157  }
1158 
1159 //var_dump($_SESSION);
1160  $ilias->setAuthError($ilErr->getLastError());
1161  $ilBench->stop("Core", "HeaderInclude_Authentication");
1162 
1163  // workaround: force login
1164  if ($_GET["cmd"] == "force_login" || $this->script == "login.php")
1165  {
1166  $ilAuth->logout();
1167  if(!isset($_GET['forceShoppingCartRedirect']))
1168  $_SESSION = array();
1169  $_SESSION["AccountId"] = "";
1170  $ilAuth->start();
1171  $ilias->setAuthError($ilErr->getLastError());
1172  }
1173 
1174  // check correct setup
1175  if (!$ilias->getSetting("setup_ok"))
1176  {
1177  die("Setup is not completed. Please run setup routine again.");
1178  }
1179 
1180  // $ilUser initialisation (1)
1181  $ilBench->start("Core", "HeaderInclude_getCurrentUser");
1182  $ilUser = new ilObjUser();
1183  $ilias->account =& $ilUser;
1184  $GLOBALS['ilUser'] =& $ilUser;
1185  $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
1186 
1187  // $ilCtrl initialisation
1188  //$ilCtrl = new ilCtrl();
1189  $ilCtrl = new ilCtrl2();
1190  $GLOBALS['ilCtrl'] =& $ilCtrl;
1191 
1192  // determin current script and up-path to main directory
1193  // (sets $this->script and $this->updir)
1194  $this->determineScriptAndUpDir();
1195 
1196  // $styleDefinition initialisation and style handling for login and co.
1197  $this->initStyle();
1198  if (in_array($this->script,
1199  array("login.php", "register.php", "view_usr_agreement.php"))
1200  || $_GET["baseClass"] == "ilStartUpGUI")
1201  {
1202  $this->handleStyle();
1203  }
1204 
1205  // init locale
1206  $this->initLocale();
1207 
1208  // handle ILIAS 2 imported users:
1209  // check ilias 2 password, if authentication failed
1210  // only if AUTH_LOCAL
1211 //echo "A";
1212  if (AUTH_CURRENT == AUTH_LOCAL && !$ilAuth->getAuth() && $this->script == "login.php" && $_POST["username"] != "")
1213  {
1215  {
1217  ilUtil::stripSlashes($_POST["username"]),
1218  ilUtil::stripSlashes($_POST["password"])))
1219  {
1220  $ilAuth->start();
1221  $ilias->setAuthError($ilErr->getLastError());
1222  ilUtil::redirect("index.php");
1223  }
1224  }
1225  }
1226 
1227 //echo $_POST; exit;
1228  //
1229  // SUCCESSFUL AUTHENTICATION
1230  //
1231 //if (!$ilAuth->getAuth() && $this->script != "login.php")
1232 //{
1233 // var_dump($_SESSION);
1234 // echo "<br>B-".$ilAuth->getAuth()."-".$ilAuth->_sessionName."-".$ilias->account->isCurrentUserActive()."-";
1235 //}
1236 //var_dump ($session[_authsession]);
1237  #if (($ilAuth->getAuth() && $ilias->account->isCurrentUserActive()) ||
1238  # (defined("IL_PHPUNIT_TEST") && DEVMODE))
1239 
1240  if($ilAuth->getStatus() == '' &&
1241  $ilias->account->isCurrentUserActive() ||
1242  (defined("IL_PHPUNIT_TEST") && DEVMODE))
1243  {
1244 //echo "C"; exit;
1245  $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
1246 //var_dump($_SESSION);
1247  // get user data
1248  $this->initUserAccount();
1249 
1250 //var_dump($_SESSION);
1251  // check client IP of user
1252  $this->checkUserClientIP();
1253 
1254  // check user agreement (went here due to bug 5634)
1255  $this->checkUserAgreement();
1256 
1257  // update last_login date once the user logged in
1258  if ($this->script == "login.php" ||
1259  $_GET["baseClass"] == "ilStartUpGUI")
1260  {
1261 
1262  // determine first login of user for setting an indicator
1263  // which still is available in PersonalDesktop, Repository, ...
1264  // (last login date is set to current date in next step)
1265  require_once('Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1266  $security_settings = ilSecuritySettings::_getInstance();
1267  if( $security_settings->isPasswordChangeOnFirstLoginEnabled() &&
1268  null == $ilUser->getLastLogin() &&
1269  null == $ilUser->getApproveDate() )
1270  {
1271  $ilUser->resetLastPasswordChange();
1272  }
1273 
1274  $ilUser->refreshLogin();
1275  }
1276 
1277  // differentiate account security mode
1278  require_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1279  $security_settings = ilSecuritySettings::_getInstance();
1280  if( $security_settings->getAccountSecurityMode() ==
1282  {
1283  // reset counter for failed logins
1284  ilObjUser::_resetLoginAttempts( $ilUser->getId() );
1285  }
1286 
1287  // set hits per page for all lists using table module
1288  $_GET['limit'] = $_SESSION['tbl_limit'] = (int) $ilUser->getPref('hits_per_page');
1289 
1290  // the next line makes it impossible to save the offset somehow in a session for
1291  // a specific table (I tried it for the user administration).
1292  // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
1293  // or not set at all (then we want the last offset, e.g. being used from a session var).
1294  // So I added the wrapping if statement. Seems to work (hopefully).
1295  // Alex April 14th 2006
1296  if ($_GET['offset'] != "") // added April 14th 2006
1297  {
1298  $_GET['offset'] = (int) $_GET['offset']; // old code
1299  }
1300 
1301  $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
1302  }
1303  elseif (
1304  $this->script != "login.php"
1305  and $this->script != "shib_login.php"
1306  and $this->script != "shib_logout.php"
1307  and $this->script != "error.php"
1308  and $this->script != "index.php"
1309  and $this->script != "view_usr_agreement.php"
1310  and $this->script != "register.php"
1311  and $this->script != "chat.php"
1312  and $this->script != "pwassist.php"
1313  and $this->script != "confirmReg.php"
1314  )
1315  {
1316  //
1317  // AUTHENTICATION FAILED
1318  //
1319 
1320  // If ILIAS is accessed by a WebDAV client,
1321  // request login again.
1322  if ($context == "webdav")
1323  {
1324  $ilLog->write(__METHOD__.': Current Auth Class: '. get_class($ilAuth));
1325  $ilAuth->logout();
1326  $ilAuth->start();
1327 
1328  // $lng initialisation, in case authentication succeeds
1329  $this->initLanguage();
1330 
1331  return;
1332  }
1333  // authentication failed due to inactive user?
1334  if ($ilAuth->getAuth() && !$ilUser->isCurrentUserActive())
1335  {
1336  $inactive = true;
1337  }
1338 
1339  // jump to public section (to do: is this always the indended
1340  // behaviour, login could be another possibility (including
1341  // message)
1342 //echo "-".$_GET["baseClass"]."-";
1343  if ($_GET["baseClass"] != "ilStartUpGUI")
1344  {
1345  // $lng initialisation
1346  $this->initLanguage();
1347 
1348  // Do not redirect for Auth_SOAP Auth_CRON Auth_HTTP
1349  if(!$ilAuth->supportsRedirects())
1350  {
1351  return false;
1352  }
1353 
1354  if ($ilSetting->get("pub_section") &&
1355  ($ilAuth->getStatus() == "" ||
1356  $ilAuth->getStatus() == AUTH_EXPIRED ||
1357  $ilAuth->getStatus() == AUTH_IDLED) &&
1358  $_GET["reloadpublic"] != "1")
1359  {
1360  $this->goToPublicSection();
1361  }
1362  else
1363  {
1364  if ($context == "web")
1365  {
1366  // normal access by webinterface
1367  $this->goToLogin($ilAuth->getStatus());
1368  exit;
1369  }
1370  else
1371  {
1372  // called by soapAuthenticationLdap
1373  return;
1374  }
1375 
1376  }
1377  // we should not get here => public section needs no redirect smeyer
1378  // exit;
1379  }
1380  }
1381  else if(!$ilAuth->getAuth())
1382  {
1383  require_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1384  // differentiate account security mode
1385  $security = ilSecuritySettings::_getInstance();
1386  if( $security->getAccountSecurityMode() ==
1388  {
1389  if($_POST['username'] && $ilUser->getId() == 0)
1390  {
1391  $username = ilUtil::stripSlashes( $_POST['username'] );
1392  $usr_id = ilObjUser::_lookupId( $username );
1393 
1394  if( $usr_id != ANONYMOUS_USER_ID )
1395  {
1397 
1398  $login_attempts = ilObjUser::_getLoginAttempts( $usr_id );
1399  $max_attempts = $security->getLoginMaxAttempts();
1400 
1401  if( $login_attempts >= $max_attempts &&
1402  $usr_id != SYSTEM_USER_ID &&
1403  $max_attempts > 0 )
1404  {
1406  }
1407  }
1408  }
1409  }
1410  }
1411  //
1412  // SUCCESSFUL AUTHENTICATED or NON-AUTH-AREA (Login, Registration, ...)
1413  //
1414 
1415  // $lng initialisation
1416  $this->initLanguage();
1417 
1418  // store user language in tree
1419  $GLOBALS['tree']->initLangCode();
1420 
1421  // instantiate main template
1422  $tpl = new ilTemplate("tpl.main.html", true, true);
1423  $GLOBALS['tpl'] =& $tpl;
1424 
1425 
1426  // ### AA 03.10.29 added new LocatorGUI class ###
1427  // when locator data array does not exist, initialise
1428  if ( !isset($_SESSION["locator_level"]) )
1429  {
1430  $_SESSION["locator_data"] = array();
1431  $_SESSION["locator_level"] = -1;
1432  }
1433  // initialise global ilias_locator object
1434  $ilias_locator = new ilLocatorGUI(); // deprecated
1435  $ilLocator = new ilLocatorGUI();
1436  $GLOBALS['ilias_locator'] =& $ilias_locator; // deprecated
1437  $GLOBALS['ilLocator'] =& $ilLocator;
1438 
1439  // load style definitions
1440  $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
1441  $styleDefinition = new ilStyleDefinition();
1442  $GLOBALS['styleDefinition'] =& $styleDefinition;
1443  $styleDefinition->startParsing();
1444  $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
1445 
1446  // load style sheet depending on user's settings
1447  $location_stylesheet = ilUtil::getStyleSheetLocation();
1448  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1449 
1450  // Init Navigation History
1451  $ilNavigationHistory = new ilNavigationHistory();
1452  $GLOBALS['ilNavigationHistory'] =& $ilNavigationHistory;
1453 
1454  // init infopanel
1455 
1456  // provide global browser information
1457  $ilBrowser = new ilBrowser();
1458  $GLOBALS['ilBrowser'] =& $ilBrowser;
1459 
1460  // provide global help object
1461  $ilHelp = new ilHelp();
1462  $GLOBALS['ilHelp'] =& $ilHelp;
1463 
1464  // main tabs gui
1465  include_once 'classes/class.ilTabsGUI.php';
1466  $ilTabs = new ilTabsGUI();
1467  $GLOBALS['ilTabs'] =& $ilTabs;
1468 
1469  // main toolbar gui
1470  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1471  $ilToolbar = new ilToolbarGUI();
1472  $GLOBALS['ilToolbar'] =& $ilToolbar;
1473 
1474  // main menu
1475  include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
1476  $ilMainMenu = new ilMainMenuGUI("_top");
1477  $GLOBALS['ilMainMenu'] =& $ilMainMenu;
1478 
1479  // Store online time of user
1480  ilOnlineTracking::_updateAccess($ilUser->getId());
1481 
1482  // ECS Tasks
1483  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
1484  $scheduler = ilECSTaskScheduler::_getInstance();
1485  $scheduler->start();
1486 
1487  $ilBench->stop("Core", "HeaderInclude");
1488  $ilBench->save();
1489 
1490  }
1491 
1495  function initFeed()
1496  {
1497  global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile,
1498  $ilSetting, $ilias, $https, $ilObjDataCache,
1499  $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp,
1500  $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
1501 
1502  // remove unsafe characters
1503  $this->removeUnsafeCharacters();
1504 
1505  // include common code files
1506  $this->requireCommonIncludes();
1507  global $ilBench;
1508 
1509  // $ilAppEventHandler initialisation
1510  $this->initEventHandling();
1511 
1512  // set error handler (to do: check preconditions for error handler to work)
1513  $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
1514  $ilErr = new ilErrorHandling();
1515  $GLOBALS['ilErr'] =& $ilErr;
1516  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
1517  $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
1518 
1519  // prepare file access to work with safe mode (has been done in class ilias before)
1520  umask(0117);
1521 
1522  // $ilIliasIniFile initialisation
1523  $this->initIliasIniFile();
1524 
1525  // CLIENT_ID determination
1526  $this->determineClient();
1527 
1528  // $ilClientIniFile initialisation
1529  if (!$this->initClientIniFile())
1530  {
1531  $c = $_COOKIE["ilClientId"];
1532  ilUtil::setCookie("ilClientId", $ilIliasIniFile->readVariable("clients","default"));
1533  echo ("Client $c does not exist. Please reload this page to return to the default client.");
1534  exit;
1535  }
1536 
1537  // maintenance mode
1538  $this->handleMaintenanceMode();
1539 
1540  // $ilDB initialisation
1541  $this->initDatabase();
1542 
1543  // init plugin admin class
1544  include_once("./Services/Component/classes/class.ilPluginAdmin.php");
1545  $ilPluginAdmin = new ilPluginAdmin();
1546  $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
1547 
1548  // $ilObjDataCache initialisation
1549  $ilObjDataCache = new ilObjectDataCache();
1550  $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
1551 
1552  // init settings
1553  $this->initSettings();
1554 
1555  // init tree
1556  $tree = new ilTree(ROOT_FOLDER_ID);
1557  $GLOBALS['tree'] =& $tree;
1558 
1559  // init language
1560  $lng = new ilLanguage($ilClientIniFile->readVariable("language","default"));
1561  $GLOBALS['lng'] =& $lng;
1562 
1563  }
1564 
1565  function initLog() {
1566  global $ilLog;
1567  $log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,CLIENT_ID,ILIAS_LOG_ENABLED,ILIAS_LOG_LEVEL);
1568  $GLOBALS['log'] = $log;
1569  $ilLog = $log;
1570  $GLOBALS['ilLog'] = $ilLog;
1571  }
1572 
1573  function initILIASObject() {
1574  global $ilias, $ilBench;
1575  $ilBench->start("Core", "HeaderInclude_GetILIASObject");
1576  $ilias = new ILIAS();
1577  $GLOBALS['ilias'] =& $ilias;
1578  $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
1579 //var_dump($_SESSION);
1580  }
1581 }
1582 ?>