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