ILIAS  Release_4_2_x_branch Revision 61807
 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 "classes/class.ilCtrl2.php";
133  require_once "./Services/AccessControl/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  $_GET["client_id"] = ilUtil::stripSlashes($_GET["client_id"]);
341  if (!defined("IL_PHPUNIT_TEST"))
342  {
343  ilUtil::setCookie("ilClientId", $_GET["client_id"]);
344  }
345  }
346  else if (!$_COOKIE["ilClientId"])
347  {
348  // to do: ilias ini raus nehmen
349  $client_id = $ilIliasIniFile->readVariable("clients","default");
350  ilUtil::setCookie("ilClientId", $client_id);
351 //echo "set cookie";
352  }
353 //echo "-".$_COOKIE["ilClientId"]."-";
354  if (!defined("IL_PHPUNIT_TEST"))
355  {
356  define ("CLIENT_ID", $_COOKIE["ilClientId"]);
357  }
358  else
359  {
360  define ("CLIENT_ID", $_GET["client_id"]);
361  }
362  }
363 
376  function initClientIniFile()
377  {
378  global $ilClientIniFile;
379 
380  // check whether ILIAS_WEB_DIR is set.
381  if (ILIAS_WEB_DIR == "")
382  {
383  die ("Fatal Error: ilInitialisation::initClientIniFile called without ILIAS_WEB_DIR.");
384  }
385 
386  // check whether CLIENT_ID is set.
387  if (CLIENT_ID == "")
388  {
389  die ("Fatal Error: ilInitialisation::initClientIniFile called without CLIENT_ID.");
390  }
391 
392  $ini_file = "./".ILIAS_WEB_DIR."/".CLIENT_ID."/client.ini.php";
393 
394  // get settings from ini file
395  require_once("classes/class.ilIniFile.php");
396  $ilClientIniFile = new ilIniFile($ini_file);
397  $GLOBALS['ilClientIniFile'] =& $ilClientIniFile;
398  $ilClientIniFile->read();
399 
400  // if no ini-file found switch to setup routine
401  if ($ilClientIniFile->ERROR != "")
402  {
403  return false;
404  }
405 
406  // set constants
407  define ("SESSION_REMINDER_LEADTIME", 30);
408  define ("DEBUG",$ilClientIniFile->readVariable("system","DEBUG"));
409  define ("DEVMODE",$ilClientIniFile->readVariable("system","DEVMODE"));
410  define ("SHOWNOTICES",$ilClientIniFile->readVariable("system","SHOWNOTICES"));
411  define ("ROOT_FOLDER_ID",$ilClientIniFile->readVariable('system','ROOT_FOLDER_ID'));
412  define ("SYSTEM_FOLDER_ID",$ilClientIniFile->readVariable('system','SYSTEM_FOLDER_ID'));
413  define ("ROLE_FOLDER_ID",$ilClientIniFile->readVariable('system','ROLE_FOLDER_ID'));
414  define ("MAIL_SETTINGS_ID",$ilClientIniFile->readVariable('system','MAIL_SETTINGS_ID'));
415 
416  define ("SYSTEM_MAIL_ADDRESS",$ilClientIniFile->readVariable('system','MAIL_SENT_ADDRESS')); // Change SS
417  define ("MAIL_REPLY_WARNING",$ilClientIniFile->readVariable('system','MAIL_REPLY_WARNING')); // Change SS
418 
419  define ("MAXLENGTH_OBJ_TITLE",125);#$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_TITLE'));
420  define ("MAXLENGTH_OBJ_DESC",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_DESC'));
421 
422  define ("CLIENT_DATA_DIR",ILIAS_DATA_DIR."/".CLIENT_ID);
423  define ("CLIENT_WEB_DIR",ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".CLIENT_ID);
424  define ("CLIENT_NAME",$ilClientIniFile->readVariable('client','name')); // Change SS
425 
426  $val = $ilClientIniFile->readVariable("db","type");
427  if ($val == "")
428  {
429  define ("IL_DB_TYPE", "mysql");
430  }
431  else
432  {
433  define ("IL_DB_TYPE", $val);
434  }
435  return true;
436  }
437 
442  {
443  global $ilClientIniFile;
444 
445  if (!$ilClientIniFile->readVariable("client","access"))
446  {
447  if (is_file("./maintenance.html"))
448  {
449  ilUtil::redirect("./maintenance.html");
450  }
451  else
452  {
453  // to do: include standard template here
454  die('<br /><p style="text-align:center;">The server is not '.
455  'available due to maintenance. We apologise for any inconvenience.</p>');
456  }
457  }
458  }
459 
464  function initDatabase()
465  {
466  global $ilDB, $ilClientIniFile;
467 
468  // build dsn of database connection and connect
469  require_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
470  $ilDB = ilDBWrapperFactory::getWrapper(IL_DB_TYPE);
471  $ilDB->initFromIniFile();
472  $ilDB->connect();
473  $GLOBALS['ilDB'] = $ilDB;
474 
475  }
476 
480  function initEventHandling()
481  {
482  global $ilAppEventHandler;
483 
484  // build dsn of database connection and connect
485  require_once("./Services/EventHandling/classes/class.ilAppEventHandler.php");
486  $ilAppEventHandler = new ilAppEventHandler();
487  $GLOBALS['ilAppEventHandler'] =& $ilAppEventHandler;
488  }
489 
493  function setSessionHandler()
494  {
495  global $ilErr;
496 
497  // set session handler
498  if(ini_get('session.save_handler') != 'user')
499  {
500  ini_set("session.save_handler", "user");
501  }
502  if (!db_set_save_handler())
503  {
504  die("Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini");
505  }
506 
507  }
511  function setCookieParams()
512  {
513  include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
515  {
516  $cookie_path = '/';
517  }
518  elseif ($GLOBALS['COOKIE_PATH'])
519  {
520  // use a predefined cookie path from WebAccessChecker
521  $cookie_path = $GLOBALS['COOKIE_PATH'];
522  }
523  else
524  {
525  $cookie_path = dirname( $_SERVER['PHP_SELF'] );
526  }
527 
528  /* if ilias is called directly within the docroot $cookie_path
529  is set to '/' expecting on servers running under windows..
530  here it is set to '\'.
531  in both cases a further '/' won't be appended due to the following regex
532  */
533  $cookie_path .= (!preg_match("/[\/|\\\\]$/", $cookie_path)) ? "/" : "";
534 
535  if($cookie_path == "\\") $cookie_path = '/';
536 
537  $cookie_domain = $_SERVER['SERVER_NAME'];
538 
539  define('IL_COOKIE_EXPIRE',0);
540  define('IL_COOKIE_PATH',$cookie_path);
541  define('IL_COOKIE_DOMAIN','');
542  define('IL_COOKIE_SECURE',false); // Default Value
543 
544  // session_set_cookie_params() supports 5th parameter
545  // only for php version 5.2.0 and above
546  if( version_compare(PHP_VERSION, '5.2.0', '>=') )
547  {
548  // PHP version >= 5.2.0
549  define('IL_COOKIE_HTTPONLY',false); // Default Value
550  session_set_cookie_params(
551  IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE, IL_COOKIE_HTTPONLY
552  );
553  }
554  else
555  {
556  // PHP version < 5.2.0
557  session_set_cookie_params(
558  IL_COOKIE_EXPIRE, IL_COOKIE_PATH, IL_COOKIE_DOMAIN, IL_COOKIE_SECURE
559  );
560  }
561  }
562 
566  function initSettings()
567  {
568  global $ilSetting;
569 
570  require_once("Services/Administration/classes/class.ilSetting.php");
571  $ilSetting = new ilSetting();
572  $GLOBALS['ilSetting'] =& $ilSetting;
573 
574  // set anonymous user & role id and system role id
575  define ("ANONYMOUS_USER_ID", $ilSetting->get("anonymous_user_id"));
576  define ("ANONYMOUS_ROLE_ID", $ilSetting->get("anonymous_role_id"));
577  define ("SYSTEM_USER_ID", $ilSetting->get("system_user_id"));
578  define ("SYSTEM_ROLE_ID", $ilSetting->get("system_role_id"));
579  define ("USER_FOLDER_ID", 7);
580 
581  // recovery folder
582  define ("RECOVERY_FOLDER_ID", $ilSetting->get("recovery_folder_id"));
583 
584  // installation id
585  define ("IL_INST_ID", $ilSetting->get("inst_id",0));
586 
587  // define default suffix replacements
588  define ("SUFFIX_REPL_DEFAULT", "php,php3,php4,inc,lang,phtml,htaccess");
589  define ("SUFFIX_REPL_ADDITIONAL", $ilSetting->get("suffix_repl_additional"));
590 
591  $this->buildHTTPPath();
592 
593  // payment setting
594  require_once('Services/Payment/classes/class.ilPaymentSettings.php');
595  define('IS_PAYMENT_ENABLED', ilPaymentSettings::_isPaymentEnabled());
596  }
597 
598 
603  {
604  $this->script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
605  $dirname = dirname($_SERVER["PHP_SELF"]);
606  $ilurl = @parse_url(ILIAS_HTTP_PATH);
607  if (!$ilurl["path"])
608  {
609  $ilurl["path"] = "/";
610  }
611  $subdir = substr(strstr($dirname,$ilurl["path"]),strlen($ilurl["path"]));
612  $updir = "";
613 
614  if ($subdir)
615  {
616  $num_subdirs = substr_count($subdir,"/");
617 
618  for ($i=1;$i<=$num_subdirs;$i++)
619  {
620  $updir .= "../";
621  }
622  }
623  $this->updir = $updir;
624  }
625 
629  function initStyle()
630  {
631  global $ilBench, $styleDefinition;
632 
633  // load style definitions
634  $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
635  $styleDefinition = new ilStyleDefinition();
636  $GLOBALS['styleDefinition'] =& $styleDefinition;
637 
638  // add user interface hook for style initialisation
639  global $ilPluginAdmin;
640  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
641  foreach ($pl_names as $pl)
642  {
643  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
644  $gui_class = $ui_plugin->getUIClassInstance();
645  $resp = $gui_class->modifyGUI("Services/Init", "init_style", array("styleDefinition" => $styleDefinition));
646  }
647 
648  $styleDefinition->startParsing();
649  $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
650  }
651 
652 
656  function handleStyle()
657  {
658  global $styleDefinition;
659 
660  if (isset($_GET['skin']) && isset($_GET['style']))
661  {
662  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
663  if ($styleDefinition->styleExists($_GET['skin'], $_GET['style']) &&
665  {
666  $_SESSION['skin'] = $_GET['skin'];
667  $_SESSION['style'] = $_GET['style'];
668  }
669  }
670  if (isset($_SESSION['skin']) && isset($_SESSION['style']))
671  {
672  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
673  if ($styleDefinition->styleExists($_SESSION['skin'], $_SESSION['style']) &&
675  {
676  $ilias->account->skin = $_SESSION['skin'];
677  $ilias->account->prefs['style'] = $_SESSION['style'];
678  }
679  }
680  }
681 
682  function initUserAccount()
683  {
684  global $ilUser, $ilLog, $ilAuth;
685 
686  //get user id
687  if (empty($_SESSION["AccountId"]))
688  {
689  $uid = $ilUser->checkUserId();
690  $_SESSION["AccountId"] = $uid;
691  if ($uid > 0)
692  {
693  $ilUser->setId($uid);
694  }
695  // assigned roles are stored in $_SESSION["RoleId"]
696  // DISABLED smeyer 20070510
697  #$rbacreview = new ilRbacReview();
698  #$GLOBALS['rbacreview'] =& $rbacreview;
699  #$_SESSION["RoleId"] = $rbacreview->assignedRoles($_SESSION["AccountId"]);
700  } // TODO: do we need 'else' here?
701  else
702  {
703  // init user
704  $ilUser->setId($_SESSION["AccountId"]);
705  }
706 
707  // load account data of current user
708  $ilUser->read();
709  }
710 
714  function initLocale()
715  {
716  global $ilSetting;
717 
718  if (trim($ilSetting->get("locale") != ""))
719  {
720  $larr = explode(",", trim($ilSetting->get("locale")));
721  $ls = array();
722  $first = $larr[0];
723  foreach ($larr as $l)
724  {
725  if (trim($l) != "")
726  {
727  $ls[] = $l;
728  }
729  }
730  if (count($ls) > 0)
731  {
732  setlocale(LC_ALL, $ls);
733  if (class_exists("Collator"))
734  {
735  $GLOBALS["ilCollator"] = new Collator($first);
736  }
737  }
738  }
739  }
740 
741 
742  function checkUserClientIP()
743  {
744  global $ilUser, $ilLog, $ilAuth, $ilias;
745 
746  // check client ip
747  $clientip = $ilUser->getClientIP();
748  if (trim($clientip) != "")
749  {
750  $clientip = preg_replace("/[^0-9.?*,:]+/","",$clientip);
751  $clientip = str_replace(".","\\.",$clientip);
752  $clientip = str_replace(Array("?","*",","), Array("[0-9]","[0-9]*","|"), $clientip);
753  if (!preg_match("/^".$clientip."$/", $_SERVER["REMOTE_ADDR"]))
754  {
755  $ilLog ->logError(1,
756  $ilias->account->getLogin().":".$_SERVER["REMOTE_ADDR"].":".$message);
757  $ilAuth->logout();
758  @session_destroy();
759  ilUtil::redirect("login.php?wrong_ip=true");
760  }
761  }
762  }
763 
765  {
766  global $ilUser, $ilAuth;
767 
768  // are we currently in user agreement acceptance?
769  $in_user_agreement = false;
770  if (strtolower($_GET["cmdClass"]) == "ilstartupgui" &&
771  (strtolower($_GET["cmd"]) == "getacceptance" ||
772  (is_array($_POST["cmd"]) &&
773  key($_POST["cmd"]) == "getAcceptance")))
774  {
775  $in_user_agreement = true;
776  }
777 
778  // check wether user has accepted the user agreement
779  // echo "-".$script;
780  if (!$ilUser->hasAcceptedUserAgreement() &&
781  $ilAuth->getAuth() &&
782  !$in_user_agreement &&
783  $ilUser->getId() != ANONYMOUS_USER_ID &&
784  $ilUser->checkTimeLimit())
785  {
786  if(!defined('IL_CERT_SSO') && $ilAuth->supportsRedirects())
787  {
788  ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=".$_GET["target"]."&cmd=getAcceptance");
789  }
790  }
791  }
792 
793 
797  function goToPublicSection()
798  {
799  global $ilAuth;
800 
801  // logout and end previous session
802  $ilAuth->logout();
803  session_unset();
804  session_destroy();
805 
806  // new session and login as anonymous
807  $this->setSessionHandler();
808  session_start();
809  $_POST["username"] = "anonymous";
810  $_POST["password"] = "anonymous";
812 
813  $oldSid = session_id();
814 
815  $ilAuth->start();
816  if(IS_PAYMENT_ENABLED)
817  {
818  $newSid = session_id();
819  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
820  ilPaymentShoppingCart::_migrateShoppingCart($oldSid, $newSid);
821  }
822  if (ANONYMOUS_USER_ID == "")
823  {
824  die ("Public Section enabled, but no Anonymous user found.");
825  }
826  if (!$ilAuth->getAuth())
827  {
828  die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
829  }
830 
831  // if target given, try to go there
832  if ($_GET["target"] != "")
833  {
834  $this->initUserAccount();
835 
836  // target is accessible -> goto target
837  include_once("Services/Init/classes/class.ilStartUpGUI.php");
838  if (ilStartUpGUI::_checkGoto($_GET["target"]))
839  {
840  // Disabled: GET parameter is kept, since no redirect. smeyer
841  // additional parameter capturing for survey access codes
842  /*
843  $survey_parameter = "";
844  if (array_key_exists("accesscode", $_GET))
845  {
846  $survey_parameter = "&accesscode=" . $_GET["accesscode"];
847  }
848  */
849  // Disabled redirect for public section
850  return true;
851  #ilUtil::redirect(ILIAS_HTTP_PATH.
852  # "/goto.php?target=".$_GET["target"].$survey_parameter);
853  }
854  else // target is not accessible -> login
855  {
856  $this->goToLogin($_GET['auth_stat']);
857  }
858  }
859 
860  $_GET["ref_id"] = ROOT_FOLDER_ID;
861 
862  $_GET["cmd"] = "frameset";
863  $jump_script = "repository.php";
864 
865  $script = $this->updir.$jump_script."?reloadpublic=1&cmd=".$_GET["cmd"]."&ref_id=".$_GET["ref_id"];
866 
867  // todo do it better, if JS disabled
868  //echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n";
869  echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
870  'Please click <a target="_top" href="'.$script.'">here</a> if you are not redirected automatically.';
871  exit;
872  }
873 
874 
878  function goToLogin($a_auth_stat = "")
879  {
880  global $PHP_SELF;
881 
882  session_unset();
883  session_destroy();
884 
885  $add = "";
886  if ($_GET["soap_pw"] != "")
887  {
888  $add = "&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"];
889  }
890 
891  $script = $this->updir."login.php?target=".$_GET["target"]."&client_id=".$_COOKIE["ilClientId"].
892  "&auth_stat=".$a_auth_stat.$add;
893 
894  // todo do it better, if JS disabled
895  // + this is, when session "ends", so
896  // we should try to prevent some information about current
897  // location
898  //
899  // check whether we are currently doing a goto call
900  if (is_int(strpos($PHP_SELF, "goto.php")) && $_GET["soap_pw"] == "" &&
901  $_GET["reloadpublic"] != "1")
902  {
903  $script = $this->updir."goto.php?target=".$_GET["target"]."&client_id=".CLIENT_ID.
904  "&reloadpublic=1";
905  }
906 
907  echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
908  'Please click <a target="_top" href="'.$script.'">here</a> if you are not redirected automatically.';
909 
910  exit;
911 
912  }
913 
917  function initLanguage()
918  {
919  global $ilBench, $lng, $ilUser, $ilSetting;
920 
921  //init language
922  $ilBench->start("Core", "HeaderInclude_initLanguage");
923 
924  if (!isset($_SESSION['lang']))
925  {
926  if ($_GET["lang"])
927  {
928  $_GET["lang"] = $_GET["lang"];
929  }
930  else
931  {
932  if (is_object($ilUser))
933  {
934  $_GET["lang"] = $ilUser->getPref("language");
935  }
936  }
937  }
938 
939  if (isset($_POST['change_lang_to']) && $_POST['change_lang_to'] != "")
940  {
941  $_GET['lang'] = ilUtil::stripSlashes($_POST['change_lang_to']);
942  }
943 
944  // prefer personal setting when coming from login screen
945  // 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)
946  if (is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID && $ilUser->getId() > 0)
947  {
948  $_SESSION['lang'] = $ilUser->getPref("language");
949  }
950 
951  $_SESSION['lang'] = (isset($_GET['lang']) && $_GET['lang']) ? $_GET['lang'] : $_SESSION['lang'];
952 
953  // check whether lang selection is valid
955  if (!in_array($_SESSION['lang'], $langs))
956  {
957  if (is_object($ilSetting) && $ilSetting->get("language") != "")
958  {
959  $_SESSION['lang'] = $ilSetting->get("language");
960  }
961  else
962  {
963  $_SESSION['lang'] = $langs[0];
964  }
965  }
966  $_GET['lang'] = $_SESSION['lang'];
967 
968  $lng = new ilLanguage($_SESSION['lang']);
969  $GLOBALS['lng'] =& $lng;
970  $ilBench->stop("Core", "HeaderInclude_initLanguage");
971 
972  // TODO: another location
973  global $rbacsystem;
974  if(is_object($rbacsystem))
975  {
976  $rbacsystem->initMemberView();
977  }
978 
979  }
980 
985  {
986  global $ilBench, $rbacsystem, $rbacadmin, $rbacreview;
987 
988  $ilBench->start("Core", "HeaderInclude_initRBAC");
989  $rbacreview = new ilRbacReview();
990  $GLOBALS['rbacreview'] =& $rbacreview;
991 
992  $rbacsystem = ilRbacSystem::getInstance();
993  $GLOBALS['rbacsystem'] =& $rbacsystem;
994 
995  $rbacadmin = new ilRbacAdmin();
996  $GLOBALS['rbacadmin'] =& $rbacadmin;
997 
998  $ilAccess = new ilAccessHandler();
999  $GLOBALS["ilAccess"] =& $ilAccess;
1000  $ilBench->stop("Core", "HeaderInclude_initRBAC");
1001  }
1002 
1003 
1008  function initILIAS($context = "web")
1009  {
1010  global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile,
1011  $ilSetting, $ilias, $https, $ilObjDataCache,
1012  $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp,
1013  $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
1014 
1015  // remove unsafe characters
1016  $this->removeUnsafeCharacters();
1017 
1018  // error reporting
1019  // remove notices from error reporting
1020  if (version_compare(PHP_VERSION, '5.4.0', '>='))
1021  {
1022  // Prior to PHP 5.4.0 E_ALL does not include E_STRICT.
1023  // With PHP 5.4.0 and above E_ALL >DOES< include E_STRICT.
1024 
1025  error_reporting(((ini_get("error_reporting") & ~E_NOTICE) & ~E_DEPRECATED) & ~E_STRICT);
1026  }
1027  elseif (version_compare(PHP_VERSION, '5.3.0', '>='))
1028  {
1029  error_reporting((ini_get("error_reporting") & ~E_NOTICE) & ~E_DEPRECATED);
1030  }
1031  else
1032  {
1033  error_reporting(ini_get('error_reporting') & ~E_NOTICE);
1034  }
1035 
1036 
1037  // include common code files
1038  $this->requireCommonIncludes();
1039  global $ilBench;
1040 
1041  // set error handler (to do: check preconditions for error handler to work)
1042  $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
1043  $ilErr = new ilErrorHandling();
1044  $GLOBALS['ilErr'] =& $ilErr;
1045  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
1046  $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
1047 
1048 
1049  // prepare file access to work with safe mode (has been done in class ilias before)
1050  umask(0117);
1051 
1052  // set cookie params
1053  $this->setCookieParams();
1054 
1055  // $ilIliasIniFile initialisation
1056  $this->initIliasIniFile();
1057 
1058  // CLIENT_ID determination
1059  $this->determineClient();
1060 
1061  // $ilAppEventHandler initialisation
1062  $this->initEventHandling();
1063 
1064  // $ilClientIniFile initialisation
1065  if (!$this->initClientIniFile())
1066  {
1067  $c = $_COOKIE["ilClientId"];
1068  ilUtil::setCookie("ilClientId", $ilIliasIniFile->readVariable("clients","default"));
1069  if (CLIENT_ID != "" && CLIENT_ID != $ilIliasIniFile->readVariable("clients","default"))
1070  {
1071  ilUtil::redirect("index.php?client_id=".$ilIliasIniFile->readVariable("clients","default"));
1072  }
1073  else
1074  {
1075  echo ("Client $c does not exist. ".'Please <a href="./index.php">click here</a> to return to the default client.');
1076  }
1077  exit;
1078  //ilUtil::redirect("./setup/setup.php"); // to do: this could fail in subdirectories
1079  // this is also source of a bug (see mantis)
1080  }
1081 
1082  if (DEVMODE && SHOWNOTICES)
1083  {
1084  // no further differentiating of php version regarding to 5.4 neccessary
1085  // when the error reporting is set to E_ALL anyway
1086 
1087  // remove notices from error reporting
1088  if (version_compare(PHP_VERSION, '5.3.0', '>='))
1089  {
1090  error_reporting(E_ALL);
1091  }
1092  else
1093  {
1094  error_reporting(E_ALL);
1095  }
1096  }
1097 
1098  // allow login by submitting user data
1099  // in query string when DEVMODE is enabled
1100  if( DEVMODE
1101  && isset($_GET['username']) && strlen($_GET['username'])
1102  && isset($_GET['password']) && strlen($_GET['password'])
1103  ){
1104  $_POST['username'] = $_GET['username'];
1105  $_POST['password'] = $_GET['password'];
1106  }
1107 
1108  // maintenance mode
1109  $this->handleMaintenanceMode();
1110 
1111  // $ilDB initialisation
1112  $this->initDatabase();
1113 
1114  // init plugin admin class
1115  include_once("./Services/Component/classes/class.ilPluginAdmin.php");
1116  $ilPluginAdmin = new ilPluginAdmin();
1117  $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
1118 
1119  // set session handler
1120  $this->setSessionHandler();
1121 
1122  // $ilSetting initialisation
1123  $this->initSettings();
1124 
1125 
1126  // $ilLog initialisation
1127  $this->initLog();
1128 
1129  // $https initialisation
1130  require_once './classes/class.ilHTTPS.php';
1131  $https = new ilHTTPS();
1132  $GLOBALS['https'] =& $https;
1133  $https->enableSecureCookies();
1134  $https->checkPort();
1135 
1136  if($this->returnBeforeAuth()) return;
1137 
1138  $ilCtrl = new ilCtrl2();
1139  $GLOBALS['ilCtrl'] =& $ilCtrl;
1140 
1141  // $ilAuth initialisation
1142  include_once("./Services/Authentication/classes/class.ilAuthUtils.php");
1144  global $ilAuth;
1145 
1146  $this->includePhp5Compliance();
1147 
1148 //echo get_class($ilAuth);
1149 //var_dump($ilAuth);
1150 
1151  // Do not accept external session ids
1152  if (!ilSession::_exists(session_id()) && !defined('IL_PHPUNIT_TEST'))
1153  {
1154 // $_GET["PHPSESSID"] = "";
1155  session_regenerate_id();
1156  }
1157 
1158  // $ilias initialisation
1159  global $ilias, $ilBench;
1160  $ilBench->start("Core", "HeaderInclude_GetILIASObject");
1161  $ilias = new ILIAS();
1162  $GLOBALS['ilias'] =& $ilias;
1163  $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
1164 
1165  // test: trace function calls in debug mode
1166  if (DEVMODE)
1167  {
1168  if (function_exists("xdebug_start_trace"))
1169  {
1170  //xdebug_start_trace("/tmp/test.txt");
1171  }
1172  }
1173 
1174  // $ilObjDataCache initialisation
1175  $ilObjDataCache = new ilObjectDataCache();
1176  $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
1177 
1178  // workaround: load old post variables if error handler 'message' was called
1179  if (isset($_SESSION["message"]) && $_SESSION["message"])
1180  {
1181  $_POST = $_SESSION["post_vars"];
1182  }
1183 
1184 
1185  // put debugging functions here
1186  require_once "include/inc.debug.php";
1187 
1188 
1189  // $objDefinition initialisation
1190  $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
1191  $objDefinition = new ilObjectDefinition();
1192  $GLOBALS['objDefinition'] =& $objDefinition;
1193 // $objDefinition->startParsing();
1194  $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
1195 
1196  // init tree
1197  $tree = new ilTree(ROOT_FOLDER_ID);
1198  $GLOBALS['tree'] =& $tree;
1199 
1200  // $ilAccess and $rbac... initialisation
1201  $this->initAccessHandling();
1202 
1203  // authenticate & start session
1204  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
1205  $ilBench->start("Core", "HeaderInclude_Authentication");
1206 //var_dump($_SESSION);
1210 
1211  if (!defined("IL_PHPUNIT_TEST"))
1212  {
1213  $oldSid = session_id();
1214 
1215  $ilAuth->start();
1216  if(IS_PAYMENT_ENABLED)
1217  {
1218  $newSid = session_id();
1219  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
1220  ilPaymentShoppingCart::_migrateShoppingCart($oldSid, $newSid);
1221  }
1222  }
1223 
1224 //var_dump($_SESSION);
1225  $ilias->setAuthError($ilErr->getLastError());
1226  $ilBench->stop("Core", "HeaderInclude_Authentication");
1227 
1228  // workaround: force login
1229  if ((isset($_GET["cmd"]) && $_GET["cmd"] == "force_login") || $this->script == "login.php")
1230  {
1231  $ilAuth->logout();
1232  if(!isset($_GET['forceShoppingCartRedirect']))
1233  $_SESSION = array();
1234  $_SESSION["AccountId"] = "";
1235  $ilAuth->start();
1236  $ilias->setAuthError($ilErr->getLastError());
1237  }
1238 
1239  // check correct setup
1240  if (!$ilias->getSetting("setup_ok"))
1241  {
1242  die("Setup is not completed. Please run setup routine again.");
1243  }
1244 
1245  // $ilUser initialisation (1)
1246  $ilBench->start("Core", "HeaderInclude_getCurrentUser");
1247  $ilUser = new ilObjUser();
1248  $ilias->account =& $ilUser;
1249  $GLOBALS['ilUser'] =& $ilUser;
1250  $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
1251 
1252  // $ilCtrl initialisation
1253  //$ilCtrl = new ilCtrl();
1254 
1255  // determin current script and up-path to main directory
1256  // (sets $this->script and $this->updir)
1257  $this->determineScriptAndUpDir();
1258 
1259  // $styleDefinition initialisation and style handling for login and co.
1260  $this->initStyle();
1261  if (in_array($this->script,
1262  array("login.php", "register.php", "view_usr_agreement.php"))
1263  || $_GET["baseClass"] == "ilStartUpGUI")
1264  {
1265  $this->handleStyle();
1266  }
1267 
1268  // init locale
1269  $this->initLocale();
1270 
1271  // handle ILIAS 2 imported users:
1272  // check ilias 2 password, if authentication failed
1273  // only if AUTH_LOCAL
1274 //echo "A";
1275  if (AUTH_CURRENT == AUTH_LOCAL && !$ilAuth->getAuth() && $this->script == "login.php" && $_POST["username"] != "")
1276  {
1278  {
1280  ilUtil::stripSlashes($_POST["username"]),
1281  ilUtil::stripSlashes($_POST["password"])))
1282  {
1283  $ilAuth->start();
1284  $ilias->setAuthError($ilErr->getLastError());
1285  ilUtil::redirect("index.php");
1286  }
1287  }
1288  }
1289 
1290 //echo $_POST; exit;
1291  //
1292  // SUCCESSFUL AUTHENTICATION
1293  //
1294 //if (!$ilAuth->getAuth() && $this->script != "login.php")
1295 //{
1296 // var_dump($_SESSION);
1297 // echo "<br>B-".$ilAuth->getAuth()."-".$ilAuth->_sessionName."-".$ilias->account->isCurrentUserActive()."-";
1298 //}
1299 //var_dump ($session[_authsession]);
1300  #if (($ilAuth->getAuth() && $ilias->account->isCurrentUserActive()) ||
1301  # (defined("IL_PHPUNIT_TEST") && DEVMODE))
1302 
1303  if($ilAuth->getStatus() == '' &&
1304  $ilias->account->isCurrentUserActive() ||
1305  (defined("IL_PHPUNIT_TEST") && DEVMODE))
1306  {
1307 //echo "C"; exit;
1308  $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
1309 //var_dump($_SESSION);
1310  // get user data
1311  $this->initUserAccount();
1312 
1313 //var_dump($_SESSION);
1314  // check client IP of user
1315  $this->checkUserClientIP();
1316 
1317  // check user agreement (went here due to bug 5634)
1318  $this->checkUserAgreement();
1319 
1320  // update last_login date once the user logged in
1321  if ($this->script == "login.php" ||
1322  $_GET["baseClass"] == "ilStartUpGUI")
1323  {
1324 
1325  // determine first login of user for setting an indicator
1326  // which still is available in PersonalDesktop, Repository, ...
1327  // (last login date is set to current date in next step)
1328  require_once('Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1329  $security_settings = ilSecuritySettings::_getInstance();
1330  if( $security_settings->isPasswordChangeOnFirstLoginEnabled() &&
1331  null == $ilUser->getLastLogin() )
1332  {
1333  $ilUser->resetLastPasswordChange();
1334  }
1335 
1336  $ilUser->refreshLogin();
1337  }
1338 
1339  // differentiate account security mode
1340  require_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1341  $security_settings = ilSecuritySettings::_getInstance();
1342  if( $security_settings->getAccountSecurityMode() ==
1344  {
1345  // reset counter for failed logins
1346  ilObjUser::_resetLoginAttempts( $ilUser->getId() );
1347  }
1348 
1349  // set hits per page for all lists using table module
1350  $_GET['limit'] = $_SESSION['tbl_limit'] = (int) $ilUser->getPref('hits_per_page');
1351 
1352  // the next line makes it impossible to save the offset somehow in a session for
1353  // a specific table (I tried it for the user administration).
1354  // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
1355  // or not set at all (then we want the last offset, e.g. being used from a session var).
1356  // So I added the wrapping if statement. Seems to work (hopefully).
1357  // Alex April 14th 2006
1358  if (isset($_GET['offset']) && $_GET['offset'] != "") // added April 14th 2006
1359  {
1360  $_GET['offset'] = (int) $_GET['offset']; // old code
1361  }
1362 
1363  $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
1364  }
1365  elseif (
1366  $this->script != "login.php"
1367  and $this->script != "shib_login.php"
1368  and $this->script != "shib_logout.php"
1369  and $this->script != "error.php"
1370  and $this->script != "index.php"
1371  and $this->script != "view_usr_agreement.php"
1372  and $this->script != "register.php"
1373  and $this->script != "chat.php"
1374  and $this->script != "pwassist.php"
1375  and $this->script != "confirmReg.php"
1376  )
1377  {
1378 
1379  // authentication failed due to inactive user?
1380  if ($ilAuth->getAuth() && !$ilUser->isCurrentUserActive())
1381  {
1382  $inactive = true;
1383  }
1384 
1385  // jump to public section (to do: is this always the indended
1386  // behaviour, login could be another possibility (including
1387  // message)
1388 //echo "-".$_GET["baseClass"]."-";
1389  if ($_GET["baseClass"] != "ilStartUpGUI")
1390  {
1391  // $lng initialisation
1392  $this->initLanguage();
1393 
1394  // Do not redirect for Auth_SOAP Auth_CRON Auth_HTTP
1395  if(!$ilAuth->supportsRedirects())
1396  {
1397  return false;
1398  }
1399 
1400  if ($ilSetting->get("pub_section") &&
1401  ($ilAuth->getStatus() == "" ||
1402  $ilAuth->getStatus() == AUTH_EXPIRED ||
1403  $ilAuth->getStatus() == AUTH_IDLED) &&
1404  $_GET["reloadpublic"] != "1")
1405  {
1406  $this->goToPublicSection();
1407  }
1408  else
1409  {
1410  if ($context == "web")
1411  {
1412  // normal access by webinterface
1413  $this->goToLogin(($_GET['auth_stat'] && !$ilAuth->getStatus()) ? $_GET['auth_stat'] : $ilAuth->getStatus());
1414  exit;
1415  }
1416  else
1417  {
1418  // called by soapAuthenticationLdap
1419  return;
1420  }
1421 
1422  }
1423  // we should not get here => public section needs no redirect smeyer
1424  // exit;
1425  }
1426  }
1427  //
1428  // SUCCESSFUL AUTHENTICATED or NON-AUTH-AREA (Login, Registration, ...)
1429  //
1430 
1431  // $lng initialisation
1432  $this->initLanguage();
1433 
1434  // store user language in tree
1435  $GLOBALS['tree']->initLangCode();
1436 
1437  // instantiate main template
1438  $tpl = new ilTemplate("tpl.main.html", true, true);
1439  $GLOBALS['tpl'] =& $tpl;
1440 
1441 
1442  // ### AA 03.10.29 added new LocatorGUI class ###
1443  // when locator data array does not exist, initialise
1444  if ( !isset($_SESSION["locator_level"]) )
1445  {
1446  $_SESSION["locator_data"] = array();
1447  $_SESSION["locator_level"] = -1;
1448  }
1449  // initialise global ilias_locator object
1450  $ilias_locator = new ilLocatorGUI(); // deprecated
1451  $ilLocator = new ilLocatorGUI();
1452  $GLOBALS['ilias_locator'] =& $ilias_locator; // deprecated
1453  $GLOBALS['ilLocator'] =& $ilLocator;
1454 
1455  // load style definitions
1456  // use the init function with plugin hook here, too
1457  $this->initStyle();
1458 
1459  // load style sheet depending on user's settings
1460  $location_stylesheet = ilUtil::getStyleSheetLocation();
1461  $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
1462 
1463  // Init Navigation History
1464  $ilNavigationHistory = new ilNavigationHistory();
1465  $GLOBALS['ilNavigationHistory'] =& $ilNavigationHistory;
1466 
1467  // init infopanel
1468 
1469  // provide global browser information
1470  $ilBrowser = new ilBrowser();
1471  $GLOBALS['ilBrowser'] =& $ilBrowser;
1472 
1473  // provide global help object
1474  $ilHelp = new ilHelp();
1475  $GLOBALS['ilHelp'] =& $ilHelp;
1476 
1477  // main tabs gui
1478  include_once 'classes/class.ilTabsGUI.php';
1479  $ilTabs = new ilTabsGUI();
1480  $GLOBALS['ilTabs'] =& $ilTabs;
1481 
1482  // main toolbar gui
1483  include_once './Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
1484  $ilToolbar = new ilToolbarGUI();
1488  $GLOBALS['ilToolbar'] =& $ilToolbar;
1489 
1490  // main menu
1491  include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
1492  $ilMainMenu = new ilMainMenuGUI("_top");
1493  $GLOBALS['ilMainMenu'] =& $ilMainMenu;
1494 
1495  // Store online time of user
1496  ilOnlineTracking::_updateAccess($ilUser->getId());
1497 
1498  // ECS Tasks
1499  include_once('./Services/WebServices/ECS/classes/class.ilECSTaskScheduler.php');
1500  $scheduler = ilECSTaskScheduler::start();
1501 
1502  $ilBench->stop("Core", "HeaderInclude");
1503 // $ilBench->save();
1504 
1505  }
1506 
1510  function initFeed()
1511  {
1512  global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile,
1513  $ilSetting, $ilias, $https, $ilObjDataCache,
1514  $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp,
1515  $ilTabs, $ilMainMenu, $rbacsystem, $ilNavigationHistory;
1516 
1517  // remove unsafe characters
1518  $this->removeUnsafeCharacters();
1519 
1520  // include common code files
1521  $this->requireCommonIncludes();
1522  global $ilBench;
1523 
1524  // $ilAppEventHandler initialisation
1525  $this->initEventHandling();
1526 
1527  // set error handler (to do: check preconditions for error handler to work)
1528  $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
1529  $ilErr = new ilErrorHandling();
1530  $GLOBALS['ilErr'] =& $ilErr;
1531  $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
1532  $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
1533 
1534  // prepare file access to work with safe mode (has been done in class ilias before)
1535  umask(0117);
1536 
1537  // $ilIliasIniFile initialisation
1538  $this->initIliasIniFile();
1539 
1540  // CLIENT_ID determination
1541  $this->determineClient();
1542 
1543  // $ilClientIniFile initialisation
1544  if (!$this->initClientIniFile())
1545  {
1546  $c = $_COOKIE["ilClientId"];
1547  ilUtil::setCookie("ilClientId", $ilIliasIniFile->readVariable("clients","default"));
1548  echo ("Client $c does not exist. Please reload this page to return to the default client.");
1549  exit;
1550  }
1551 
1552  // maintenance mode
1553  $this->handleMaintenanceMode();
1554 
1555  // $ilDB initialisation
1556  $this->initDatabase();
1557 
1558  // init plugin admin class
1559  include_once("./Services/Component/classes/class.ilPluginAdmin.php");
1560  $ilPluginAdmin = new ilPluginAdmin();
1561  $GLOBALS['ilPluginAdmin'] = $ilPluginAdmin;
1562 
1563  // $ilObjDataCache initialisation
1564  $ilObjDataCache = new ilObjectDataCache();
1565  $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
1566 
1567  // init settings
1568  $this->initSettings();
1569 
1570  // init tree
1571  $tree = new ilTree(ROOT_FOLDER_ID);
1572  $GLOBALS['tree'] =& $tree;
1573 
1574  // init language
1575  $lng = new ilLanguage($ilClientIniFile->readVariable("language","default"));
1576  $GLOBALS['lng'] =& $lng;
1577 
1578  }
1579 
1580  function initLog() {
1581  global $ilLog;
1582  $log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,CLIENT_ID,ILIAS_LOG_ENABLED,ILIAS_LOG_LEVEL);
1583  $GLOBALS['log'] = $log;
1584  $ilLog = $log;
1585  $GLOBALS['ilLog'] = $ilLog;
1586  }
1587 
1588  function initILIASObject() {
1589  global $ilias, $ilBench;
1590  $ilBench->start("Core", "HeaderInclude_GetILIASObject");
1591  $ilias = new ILIAS();
1592  $GLOBALS['ilias'] =& $ilias;
1593  $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
1594 //var_dump($_SESSION);
1595  }
1596 }
1597 ?>