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