• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Init/classes/class.ilInitialisation.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00039 class ilInitialisation
00040 {
00041 
00045         function removeUnsafeCharacters()
00046         {
00047                 // Remove unsafe characters from GET parameters.
00048                 // We do not need this characters in any case, so it is
00049                 // feasible to filter them everytime. POST parameters
00050                 // need attention through ilUtil::stripSlashes() and similar functions)
00051                 if (is_array($_GET))
00052                 {
00053                         foreach($_GET as $k => $v)
00054                         {
00055                                 if (!in_array($k, array("file")))
00056                                 {
00057                                         // \r\n used for IMAP MX Injection
00058                                         // ' used for SQL Injection
00059                                         $_GET[$k] = str_replace(array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"), "", $v);
00060                                         
00061                                 }
00062 
00063                                 // this one is for XSS of any kind
00064                                 $_GET[$k] = strip_tags($_GET[$k]);
00065                         }
00066                 }
00067         }
00068         
00072         function requireCommonIncludes()
00073         {
00074                 global $ilBench;
00075                 
00076                 // get pear
00077                 require_once("include/inc.get_pear.php");
00078                 require_once("include/inc.check_pear.php");
00079                 
00080                 //include class.util first to start StopWatch
00081                 require_once "classes/class.ilUtil.php";
00082                 require_once "classes/class.ilBenchmark.php";
00083                 $ilBench =& new ilBenchmark();
00084                 $GLOBALS['ilBench'] =& $ilBench;
00085 
00086                 $ilBench->start("Core", "HeaderInclude");
00087                 
00088                 // start the StopWatch
00089                 $GLOBALS['t_pagestart'] = ilUtil::StopWatch();
00090                 
00091                 $ilBench->start("Core", "HeaderInclude_IncludeFiles");
00092                 
00093                 // Major PEAR Includes
00094                 require_once "PEAR.php";
00095                 require_once "DB.php";
00096                 require_once "Auth/Auth.php";
00097                 
00098                 // HTML_Template_IT support
00099                 // (location changed with 4.3.2 & higher)
00100                 @include_once "HTML/ITX.php";
00101                 if (!class_exists("IntegratedTemplateExtension"))
00102                 {
00103                         include_once "HTML/Template/ITX.php";
00104                         include_once "classes/class.ilTemplateHTMLITX.php";
00105                 }
00106                 else
00107                 {
00108                         include_once "classes/class.ilTemplateITX.php";
00109                 }
00110                 require_once "classes/class.ilTemplate.php";
00111                 
00112                 //include classes and function libraries
00113                 require_once "include/inc.db_session_handler.php";
00114                 require_once "classes/class.ilDBx.php";
00115                 require_once "classes/class.ilShibboleth.php";
00116                 require_once "classes/class.ilias.php";
00117                 require_once "classes/class.ilObjUser.php";
00118                 require_once "classes/class.ilFormat.php";
00119                 require_once "classes/class.ilSaxParser.php";
00120                 require_once "classes/class.ilObjectDefinition.php";
00121                 require_once "classes/class.ilStyleDefinition.php";
00122                 require_once "classes/class.perm.php";
00123                 require_once "classes/class.ilTree.php";
00124                 require_once "classes/class.ilLanguage.php";
00125                 require_once "classes/class.ilLog.php";
00126                 require_once "classes/class.ilMailbox.php";
00127                 require_once "classes/class.ilCtrl.php";
00128                 require_once "classes/class.ilConditionHandler.php";
00129                 require_once "classes/class.ilBrowser.php";
00130                 require_once "classes/class.ilFrameTargetInfo.php";
00131                 require_once "Services/Help/classes/class.ilHelp.php";
00132                 require_once "include/inc.ilias_version.php";
00133                 
00134                 //include role based access control system
00135                 require_once "Services/AccessControl/classes/class.ilAccessHandler.php";
00136                 require_once "classes/class.ilRbacAdmin.php";
00137                 require_once "classes/class.ilRbacSystem.php";
00138                 require_once "classes/class.ilRbacReview.php";
00139                 
00140                 // include object_data cache
00141                 require_once "classes/class.ilObjectDataCache.php";
00142                 require_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
00143                                 
00144                 // ### AA 03.10.29 added new LocatorGUI class ###
00145                 //include LocatorGUI
00146                 require_once "classes/class.ilLocatorGUI.php";
00147                 
00148                 // include error_handling
00149                 require_once "classes/class.ilErrorHandling.php";
00150                 
00151                 // php5 downward complaince to php 4 dom xml and clone method
00152                 if (version_compare(PHP_VERSION,'5','>='))
00153                 {
00154                         require_once("include/inc.xml5compliance.php");
00155                         //require_once("Services/CAS/phpcas/source/CAS/domxml-php4-php5.php");
00156                         
00157                         require_once("include/inc.xsl5compliance.php");
00158                         require_once("include/inc.php4compliance.php");
00159                 }
00160                 else
00161                 {
00162                         require_once("include/inc.php5compliance.php");
00163                 }
00164                 
00165                 $ilBench->stop("Core", "HeaderInclude_IncludeFiles");
00166         }
00167         
00175         function initIliasIniFile()
00176         {
00177                 global $ilIliasIniFile;
00178                 
00179                 require_once("classes/class.ilIniFile.php");
00180                 $ilIliasIniFile = new ilIniFile("./ilias.ini.php");
00181                 $GLOBALS['ilIliasIniFile'] =& $ilIliasIniFile;
00182                 $ilIliasIniFile->read();
00183                 
00184                 // initialize constants
00185                 define("ILIAS_DATA_DIR",$ilIliasIniFile->readVariable("clients","datadir"));
00186                 define("ILIAS_WEB_DIR",$ilIliasIniFile->readVariable("clients","path"));
00187                 define("ILIAS_ABSOLUTE_PATH",$ilIliasIniFile->readVariable('server','absolute_path'));
00188 
00189                 // logging
00190                 define ("ILIAS_LOG_DIR",$ilIliasIniFile->readVariable("log","path"));
00191                 define ("ILIAS_LOG_FILE",$ilIliasIniFile->readVariable("log","file"));
00192                 define ("ILIAS_LOG_ENABLED",$ilIliasIniFile->readVariable("log","enabled"));
00193                 define ("ILIAS_LOG_LEVEL",$ilIliasIniFile->readVariable("log","level"));
00194   
00195                 // read path + command for third party tools from ilias.ini
00196                 define ("PATH_TO_CONVERT",$ilIliasIniFile->readVariable("tools","convert"));
00197                 define ("PATH_TO_ZIP",$ilIliasIniFile->readVariable("tools","zip"));
00198                 define ("PATH_TO_UNZIP",$ilIliasIniFile->readVariable("tools","unzip"));
00199                 define ("PATH_TO_JAVA",$ilIliasIniFile->readVariable("tools","java"));
00200                 define ("PATH_TO_HTMLDOC",$ilIliasIniFile->readVariable("tools","htmldoc"));
00201                 define ("URL_TO_LATEX",$ilIliasIniFile->readVariable("tools","latex"));
00202                 define ("PATH_TO_FOP",$ilIliasIniFile->readVariable("tools","fop"));
00203                 
00204                 // read virus scanner settings
00205                 switch ($ilIliasIniFile->readVariable("tools", "vscantype"))
00206                 {
00207                         case "sophos":
00208                                 define("IL_VIRUS_SCANNER", "Sophos");
00209                                 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
00210                                 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
00211                                 break;
00212                                 
00213                         case "antivir":
00214                                 define("IL_VIRUS_SCANNER", "AntiVir");
00215                                 define("IL_VIRUS_SCAN_COMMAND", $ilIliasIniFile->readVariable("tools", "scancommand"));
00216                                 define("IL_VIRUS_CLEAN_COMMAND", $ilIliasIniFile->readVariable("tools", "cleancommand"));
00217                                 break;
00218                                 
00219                         default:
00220                                 define("IL_VIRUS_SCANNER", "None");
00221                                 break;
00222                 }
00223 
00224                 $this->buildHTTPPath();
00225         }
00226         
00233         function buildHTTPPath()
00234         {
00235                 if($_SERVER['HTTPS'] == 'on')
00236                 {
00237                         $protocol = 'https://';
00238                 }
00239                 else
00240                 {
00241                         $protocol = 'http://';
00242                 }
00243                 $host = $_SERVER['HTTP_HOST'];
00244 
00245                 if(!defined('ILIAS_MODULE'))
00246                 {
00247                         $path = pathinfo($_SERVER['REQUEST_URI']);
00248                         if(!$path['extension'])
00249                         {
00250                                 $uri = $_SERVER['REQUEST_URI'];
00251                         }
00252                         else
00253                         {
00254                                 $uri = dirname($_SERVER['REQUEST_URI']);
00255                         }
00256                 }
00257                 else
00258                 {
00259                         // if in module remove module name from HTTP_PATH
00260                         $path = dirname($_SERVER['REQUEST_URI']);
00261                         
00262                         // dirname cuts the last directory from a directory path e.g content/classes return content
00263                         
00264                         $module = ilUtil::removeTrailingPathSeparators(ILIAS_MODULE);
00265 
00266                         $dirs = explode('/',$module);
00267                         $uri = $path;
00268                         foreach($dirs as $dir)
00269                         {
00270                                 $uri = dirname($uri);
00271                         }
00272                 }
00273                 return define('ILIAS_HTTP_PATH',ilUtil::removeTrailingPathSeparators($protocol.$host.$uri));
00274         }
00275 
00276         
00281         function determineClient()
00282         {
00283                 global $ilIliasIniFile;
00284 
00285                 // check whether ini file object exists
00286                 if (!is_object($ilIliasIniFile))
00287                 {
00288                         die ("Fatal Error: ilInitialisation::determineClient called without initialisation of ILIAS ini file object.");
00289                 }
00290 
00291                 // set to default client if empty
00292                 if ($_GET["client_id"] != "")
00293                 {
00294                         setcookie("ilClientId", $_GET["client_id"]);
00295                         $_COOKIE["ilClientId"] = $_GET["client_id"];
00296                 }
00297                 else if (!$_COOKIE["ilClientId"])
00298                 {
00299                         // to do: ilias ini raus nehmen
00300                         $client_id = $ilIliasIniFile->readVariable("clients","default");
00301                         setcookie("ilClientId", $client_id);
00302                         $_COOKIE["ilClientId"] = $client_id;
00303 //echo "set cookie";
00304                 }
00305 //echo "-".$_COOKIE["ilClientId"]."-";
00306                 define ("CLIENT_ID", $_COOKIE["ilClientId"]);
00307         }
00308         
00321         function initClientIniFile()
00322         {
00323                 global $ilClientIniFile;
00324 
00325                 // check whether ILIAS_WEB_DIR is set.
00326                 if (ILIAS_WEB_DIR == "")
00327                 {
00328                         die ("Fatal Error: ilInitialisation::initClientIniFile called without ILIAS_WEB_DIR.");
00329                 }
00330 
00331                 // check whether CLIENT_ID is set.
00332                 if (CLIENT_ID == "")
00333                 {
00334                         die ("Fatal Error: ilInitialisation::initClientIniFile called without CLIENT_ID.");
00335                 }
00336 
00337                 $ini_file = "./".ILIAS_WEB_DIR."/".CLIENT_ID."/client.ini.php";
00338 
00339                 // get settings from ini file
00340                 require_once("classes/class.ilIniFile.php");
00341                 $ilClientIniFile = new ilIniFile($ini_file);
00342                 $GLOBALS['ilClientIniFile'] =& $ilClientIniFile; 
00343                 $ilClientIniFile->read();
00344 
00345                 // if no ini-file found switch to setup routine
00346                 if ($ilClientIniFile->ERROR != "")
00347                 {
00348                         return false;
00349                 }
00350 
00351                 // set constants
00352                 define ("DEBUG",$ilClientIniFile->readVariable("system","DEBUG"));
00353                 define ("DEVMODE",$ilClientIniFile->readVariable("system","DEVMODE"));
00354                 define ("ROOT_FOLDER_ID",$ilClientIniFile->readVariable('system','ROOT_FOLDER_ID'));
00355                 define ("SYSTEM_FOLDER_ID",$ilClientIniFile->readVariable('system','SYSTEM_FOLDER_ID'));
00356                 define ("ROLE_FOLDER_ID",$ilClientIniFile->readVariable('system','ROLE_FOLDER_ID'));
00357                 define ("MAIL_SETTINGS_ID",$ilClientIniFile->readVariable('system','MAIL_SETTINGS_ID'));
00358 
00359                 define ("SYSTEM_MAIL_ADDRESS",$ilClientIniFile->readVariable('system','MAIL_SENT_ADDRESS')); // Change SS
00360                 define ("MAIL_REPLY_WARNING",$ilClientIniFile->readVariable('system','MAIL_REPLY_WARNING')); // Change SS
00361 
00362                 define ("MAXLENGTH_OBJ_TITLE",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_TITLE'));
00363                 define ("MAXLENGTH_OBJ_DESC",$ilClientIniFile->readVariable('system','MAXLENGTH_OBJ_DESC'));
00364 
00365                 define ("CLIENT_DATA_DIR",ILIAS_DATA_DIR."/".CLIENT_ID);
00366                 define ("CLIENT_WEB_DIR",ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".CLIENT_ID);
00367                 define ("CLIENT_NAME",$ilClientIniFile->readVariable('client','name')); // Change SS
00368 
00369                 // build dsn of database connection and connect
00370                 define ("IL_DSN", $ilClientIniFile->readVariable("db","type").
00371                                          "://".$ilClientIniFile->readVariable("db", "user").
00372                                          ":".$ilClientIniFile->readVariable("db", "pass").
00373                                          "@".$ilClientIniFile->readVariable("db", "host").
00374                                          "/".$ilClientIniFile->readVariable("db", "name"));
00375 
00376                 return true;
00377         }
00378         
00382         function handleMaintenanceMode()
00383         {
00384                 global $ilClientIniFile;
00385                 
00386                 if (!$ilClientIniFile->readVariable("client","access"))
00387                 {
00388                         if (is_file("./maintenance.html"))
00389                         {
00390                                 ilUtil::redirect("./maintenance.html");
00391                         }
00392                         else
00393                         {
00394                                 // to do: include standard template here
00395                                 die('<br /><p style="text-align:center;">The server is not '.
00396                                         'available due to maintenance. We apologise for any inconvenience.</p>');
00397                         }
00398                 }
00399         }
00400         
00406         function initDatabase()
00407         {
00408                 global $ilDB;
00409 
00410                 // check whether ILIAS_WEB_DIR is set.
00411                 if (IL_DSN == "")
00412                 {
00413                         die ("Fatal Error: ilInitialisation::initDatabase called without IL_DSN.");
00414                 }
00415 
00416                 // build dsn of database connection and connect
00417                 require_once("classes/class.ilDBx.php");
00418                 $ilDB = new ilDBx(IL_DSN);
00419                 $GLOBALS['ilDB'] =& $ilDB;
00420         }
00421         
00422         
00426         function setSessionHandler()
00427         {
00428                 global $ilErr;
00429 
00430                 // set session handler
00431                 if(ini_get('session.save_handler') != 'user')
00432                 {
00433                         ini_set("session.save_handler", "user");
00434                 }
00435                 if (!db_set_save_handler())
00436                 {
00437                         die("Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini");
00438                 }
00439                 
00440         }
00441         
00445         function initSettings()
00446         {
00447                 global $ilSetting;
00448                 
00449                 require_once("Services/Administration/classes/class.ilSetting.php");
00450                 $ilSetting = new ilSetting();
00451                 $GLOBALS['ilSetting'] =& $ilSetting;
00452 
00453                 // set anonymous user & role id and system role id
00454                 define ("ANONYMOUS_USER_ID", $ilSetting->get("anonymous_user_id"));
00455                 define ("ANONYMOUS_ROLE_ID", $ilSetting->get("anonymous_role_id"));
00456                 define ("SYSTEM_USER_ID", $ilSetting->get("system_user_id"));
00457                 define ("SYSTEM_ROLE_ID", $ilSetting->get("system_role_id"));
00458                 
00459                 // recovery folder
00460                 define ("RECOVERY_FOLDER_ID", $ilSetting->get("recovery_folder_id"));
00461 
00462                 // installation id
00463                 define ("IL_INST_ID", $ilSetting->get("inst_id"));
00464                 
00465                 // define default suffix replacements
00466                 define ("SUFFIX_REPL_DEFAULT", "php,php3,php4,inc,lang,phtml,htaccess");
00467                 define ("SUFFIX_REPL_ADDITIONAL", $ilSetting->get("suffix_repl_additional"));
00468         }
00469         
00470         
00474         function determineScriptAndUpDir()
00475         {
00476                 $this->script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
00477                 $dirname = dirname($_SERVER["PHP_SELF"]);
00478                 $ilurl = @parse_url(ILIAS_HTTP_PATH);
00479                 $subdir = substr(strstr($dirname,$ilurl["path"]),strlen($ilurl["path"]));
00480                 $updir = "";
00481 
00482                 if ($subdir)
00483                 {
00484                         $num_subdirs = substr_count($subdir,"/");
00485         
00486                         for ($i=1;$i<=$num_subdirs;$i++)
00487                         {
00488                                 $updir .= "../";
00489                         }
00490                 }
00491                 $this->updir = $updir;
00492         }
00493         
00497         function initStyle()
00498         {
00499                 global $ilBench, $styleDefinition;
00500                 
00501                 // load style definitions
00502                 $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
00503                 $styleDefinition = new ilStyleDefinition();
00504                 $GLOBALS['styleDefinition'] =& $styleDefinition;
00505                 $styleDefinition->startParsing();
00506                 $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
00507         }
00508         
00509         
00513         function handleStyle()
00514         {
00515                 global $styleDefinition;
00516                 
00517                 if ($_GET['skin']  && $_GET['style'])
00518                 {
00519                         include_once("classes/class.ilObjStyleSettings.php");
00520                         if ($styleDefinition->styleExists($_GET['skin'], $_GET['style']) &&
00521                                 ilObjStyleSettings::_lookupActivatedStyle($_GET['skin'], $_GET['style']))
00522                         {
00523                                 $_SESSION['skin'] = $_GET['skin'];
00524                                 $_SESSION['style'] = $_GET['style'];
00525                         }
00526                 }
00527                 if ($_SESSION['skin'] && $_SESSION['style'])
00528                 {
00529                         include_once("classes/class.ilObjStyleSettings.php");
00530                         if ($styleDefinition->styleExists($_SESSION['skin'], $_SESSION['style']) &&
00531                                 ilObjStyleSettings::_lookupActivatedStyle($_SESSION['skin'], $_SESSION['style']))
00532                         {
00533                                 $ilias->account->skin = $_SESSION['skin'];
00534                                 $ilias->account->prefs['style'] = $_SESSION['style'];
00535                         }
00536                 }
00537         }
00538         
00539         function initUserAccount()
00540         {
00541                 global $ilUser, $ilLog, $ilAuth;
00542                 
00543                 //get user id
00544                 if (empty($_SESSION["AccountId"]))
00545                 {
00546                         $_SESSION["AccountId"] = $ilUser->checkUserId();
00547         
00548                         // assigned roles are stored in $_SESSION["RoleId"]
00549                         $rbacreview = new ilRbacReview();
00550                         $GLOBALS['rbacreview'] =& $rbacreview;
00551                         $_SESSION["RoleId"] = $rbacreview->assignedRoles($_SESSION["AccountId"]);
00552                 } // TODO: do we need 'else' here?
00553                 else
00554                 {
00555                         // init user
00556                         $ilUser->setId($_SESSION["AccountId"]);
00557                 }
00558         
00559                 // load account data of current user
00560                 $ilUser->read();
00561         }
00562                 
00563         function checkUserClientIP()
00564         {
00565                 global $ilUser, $ilLog, $ilAuth, $ilias;
00566                 
00567                 // check client ip
00568                 $clientip = $ilUser->getClientIP();
00569                 if (trim($clientip) != "" and $clientip != $_SERVER["REMOTE_ADDR"])
00570                 {
00571                         $ilLog ->logError(1,
00572                                 $ilias->account->getLogin().":".$_SERVER["REMOTE_ADDR"].":".$message);
00573                         $ilAuth->logout();
00574                         @session_destroy();
00575                         ilUtil::redirect("login.php?wrong_ip=true");
00576                 }
00577         }
00578         
00579         function checkUserAgreement()
00580         {
00581                 global $ilUser, $ilAuth;
00582 
00583                 // are we currently in user agreement acceptance?
00584                 $in_user_agreement = false;
00585                 if (strtolower($_GET["cmdClass"]) == "ilstartupgui" &&
00586                         (strtolower($_GET["cmd"]) == "getacceptance" ||
00587                         (is_array($_POST["cmd"]) &&
00588                         key($_POST["cmd"]) == "getAcceptance")))
00589                 {
00590                         $in_user_agreement = true;
00591                 }
00592                 
00593                 // check wether user has accepted the user agreement
00594                 //      echo "-".$script;
00595                 if (!$ilUser->hasAcceptedUserAgreement() &&
00596                         $ilAuth->getAuth() &&
00597                         !$in_user_agreement &&
00598                         $ilUser->getId() != ANONYMOUS_USER_ID)
00599                 {
00600                         ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=".$_GET["target"]."&cmd=getAcceptance");
00601                 }
00602         }
00603         
00604         
00608         function goToPublicSection()
00609         {
00610                 global $ilAuth;
00611 
00612                 // logout and end previous session
00613                 $ilAuth->logout();
00614                 session_unset();
00615                 session_destroy();
00616                 
00617                 // new session and login as anonymous
00618                 $this->setSessionHandler();
00619                 session_start();
00620                 $_POST["username"] = "anonymous";
00621                 $_POST["password"] = "anonymous";
00622                 ilAuthUtils::_initAuth();
00623                 $ilAuth->start();
00624 
00625                 if (ANONYMOUS_USER_ID == "")
00626                 {
00627                         die ("Public Section enabled, but no Anonymous user found.");
00628                 }
00629                 if (!$ilAuth->getAuth())
00630                 {
00631                         die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
00632                 }
00633 
00634                 // if target given, try to go there
00635                 if ($_GET["target"] != "")
00636                 {
00637                         $this->initUserAccount();
00638                         
00639                         // target is accessible -> goto target
00640                         include_once("Services/Init/classes/class.ilStartUpGUI.php");
00641                         if      (ilStartUpGUI::_checkGoto($_GET["target"]))
00642                         {
00643                                 // additional parameter capturing for survey access codes
00644                                 $survey_parameter = "";
00645                                 if (array_key_exists("accesscode", $_GET))
00646                                 {
00647                                         $survey_parameter = "&accesscode=" . $_GET["accesscode"];
00648                                 }
00649                                 ilUtil::redirect(ILIAS_HTTP_PATH.
00650                                         "/goto.php?target=".$_GET["target"].$survey_parameter);
00651                         }
00652                         else    // target is not accessible -> login
00653                         {
00654                                 $this->goToLogin();
00655                         }
00656                 }
00657                 
00658                 $_GET["ref_id"] = ROOT_FOLDER_ID;
00659 
00660                 $_GET["cmd"] = "frameset";
00661                 $jump_script = "repository.php";
00662                 $script = $this->updir.$jump_script."?reloadpublic=1&cmd=".$_GET["cmd"]."&ref_id=".$_GET["ref_id"];
00663 
00664                 // todo do it better, if JS disabled
00665                 //echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n";
00666                 echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
00667                         'Please click <a href="'.$script.'">here</a> if you are not redirected automatically.';
00668                 exit;
00669         }
00670         
00671         
00675         function goToLogin($a_auth_stat = "")
00676         {
00677                 global $PHP_SELF;
00678                 
00679                 session_unset();
00680                 session_destroy();
00681 
00682                 $add = "";
00683                 if ($_GET["soap_pw"] != "")
00684                 {
00685                         $add = "&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"];
00686                 }
00687                 
00688                 $script = $this->updir."login.php?target=".$_GET["target"]."&client_id=".$_COOKIE["ilClientId"].
00689                         "&auth_stat=".$a_auth_stat.$add;
00690 
00691                 // todo do it better, if JS disabled
00692                 // + this is, when session "ends", so
00693                 // we should try to prevent some information about current
00694                 // location
00695                 //
00696                 // check whether we are currently doing a goto call
00697                 if (is_int(strpos($PHP_SELF, "goto.php")) && $_GET["soap_pw"] == "" &&
00698                         $_GET["reloadpublic"] != "1")
00699                 {
00700                         $script = $this->updir."goto.php?target=".$_GET["target"]."&client_id=".CLIENT_ID.
00701                                 "&reloadpublic=1";
00702                 }
00703                 
00704                 echo "<script language=\"Javascript\">\ntop.location.href = \"".$script."\";\n</script>\n".
00705                         'Please click <a href="'.$script.'">here</a> if you are not redirected automatically.';
00706 
00707                 exit;
00708 
00709         }
00710         
00714         function initLanguage()
00715         {
00716                 global $ilBench, $lng, $ilUser;
00717                 //init language
00718                 $ilBench->start("Core", "HeaderInclude_initLanguage");
00719                 
00720                 if (is_null($_SESSION['lang']))
00721                 {
00722                         $_GET["lang"] = ($_GET["lang"]) ? $_GET["lang"] : $ilUser->getPref("language");
00723                 }
00724                 if ($_POST['change_lang_to'] != "")
00725                 {
00726                         $_GET['lang'] = ilUtil::stripSlashes($_POST['change_lang_to']);
00727                 }
00728                 
00729                 $_SESSION['lang'] = ($_GET['lang']) ? $_GET['lang'] : $_SESSION['lang'];
00730                 
00731                 // prefer personal setting when coming from login screen
00732                 // 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)
00733                 if (is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID && $ilUser->getId() > 0)
00734                 {
00735                         $_SESSION['lang'] = $ilUser->getPref("language");
00736                 }
00737                 
00738                 $lng = new ilLanguage($_SESSION['lang']);
00739                 $GLOBALS['lng'] =& $lng;
00740                 $ilBench->stop("Core", "HeaderInclude_initLanguage");
00741 
00742         }
00743         
00747         function initAccessHandling()
00748         {
00749                 global $ilBench, $rbacsystem, $rbacadmin, $rbacreview;
00750                 
00751                 $ilBench->start("Core", "HeaderInclude_initRBAC");
00752                 $rbacsystem = new ilRbacSystem();
00753                 $GLOBALS['rbacsystem'] =& $rbacsystem;
00754                 $rbacadmin = new ilRbacAdmin();
00755                 $GLOBALS['rbacadmin'] =& $rbacadmin;
00756                 $rbacreview = new ilRbacReview();
00757                 $GLOBALS['rbacreview'] =& $rbacreview;
00758                 $ilAccess =& new ilAccessHandler();
00759                 $GLOBALS["ilAccess"] =& $ilAccess;              
00760                 $ilBench->stop("Core", "HeaderInclude_initRBAC");
00761         }
00762         
00763         
00767         function initILIAS()
00768         {
00769                 global $ilDB, $ilUser, $ilLog, $ilErr, $ilClientIniFile, $ilIliasIniFile,
00770                         $ilSetting, $ilias, $https, $ilObjDataCache,
00771                         $ilLog, $objDefinition, $lng, $ilCtrl, $ilBrowser, $ilHelp,
00772                         $ilTabs, $ilMainMenu, $rbacsystem;
00773                 
00774                 // remove unsafe characters
00775                 $this->removeUnsafeCharacters();
00776                 
00777                 // include common code files
00778                 $this->requireCommonIncludes();
00779                 global $ilBench;
00780                 
00781                 // set error handler (to do: check preconditions for error handler to work)
00782                 $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
00783                 $ilErr = new ilErrorHandling();
00784                 $GLOBALS['ilErr'] =& $ilErr;
00785                 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00786                 $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
00787                 
00788                 
00789                 // prepare file access to work with safe mode (has been done in class ilias before)
00790                 umask(0117);
00791                 
00792                 
00793                 // $ilIliasIniFile initialisation
00794                 $this->initIliasIniFile();
00795                 
00796                 
00797                 // CLIENT_ID determination
00798                 $this->determineClient();
00799                 
00800                 
00801                 // $ilClientIniFile initialisation
00802                 if (!$this->initClientIniFile())
00803                 {
00804                         $c = $_COOKIE["ilClientId"];
00805                         setcookie("ilClientId", $ilIliasIniFile->readVariable("clients","default"));
00806                         $_COOKIE["ilClientId"] = $ilIliasIniFile->readVariable("clients","default");
00807                         if (CLIENT_ID != "" && CLIENT_ID != $ilIliasIniFile->readVariable("clients","default"))
00808                         {
00809                                 ilUtil::redirect("index.php?client_id=".$ilIliasIniFile->readVariable("clients","default"));
00810                         }
00811                         else
00812                         {
00813                                 echo ("Client $c does not exist. ".'Please <a href="./index.php">click here</a> to return to the default client.');
00814                         }
00815                         exit;
00816                         //ilUtil::redirect("./setup/setup.php");        // to do: this could fail in subdirectories
00817                                                                                                         // this is also source of a bug (see mantis)
00818                 }
00819                 
00820                 
00821                 // maintenance mode
00822                 $this->handleMaintenanceMode();
00823                 
00824                 // $ilDB initialisation
00825                 $this->initDatabase();
00826 
00827                 // set session handler
00828                 $this->setSessionHandler();
00829                 
00830                 // $ilSetting initialisation
00831                 $this->initSettings();
00832 
00833                 // $ilAuth initialisation
00834                 require_once("classes/class.ilAuthUtils.php");
00835                 ilAuthUtils::_initAuth();
00836                 global $ilAuth;
00837                 
00838                 // Do not accept external session ids
00839                 if ($_GET["PHPSESSID"] != "")
00840                 {
00841                         $_GET["PHPSESSID"] == "";
00842                         session_regenerate_id();
00843                 }
00844                 
00845                 // $ilias initialisation
00846                 $ilBench->start("Core", "HeaderInclude_GetILIASObject");
00847                 $ilias =& new ILIAS();
00848                 $GLOBALS['ilias'] =& $ilias;
00849                 $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
00850 //var_dump($_SESSION);
00851                 
00852                 // test: trace function calls in debug mode
00853                 if (DEVMODE)
00854                 {
00855                         if (function_exists("xdebug_start_trace"))
00856                         {
00857                                 //xdebug_start_trace("/tmp/test.txt");
00858                         }
00859                 }
00860                 
00861                 
00862                 // $https initialisation
00863                 require_once './classes/class.ilHTTPS.php';
00864                 $https =& new ilHTTPS();
00865                 $GLOBALS['https'] =& $https;
00866                 $https->checkPort();
00867                 
00868                 
00869                 // $ilObjDataCache initialisation
00870                 $ilObjDataCache = new ilObjectDataCache();
00871                 $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
00872                 
00873                 
00874                 // workaround: load old post variables if error handler 'message' was called
00875                 if ($_SESSION["message"])
00876                 {
00877                         $_POST = $_SESSION["post_vars"];
00878                 }
00879                 
00880                 
00881                 // put debugging functions here
00882                 require_once "include/inc.debug.php";
00883                 
00884                 
00885                 // $ilLog initialisation
00886                 $log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,$ilias->getClientId(),ILIAS_LOG_ENABLED,ILIAS_LOG_LEVEL);
00887                 $GLOBALS['log'] =& $log;
00888                 $ilLog =& $log;
00889                 $GLOBALS['ilLog'] =& $ilLog;
00890                 
00891                 // $objDefinition initialisation
00892                 $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
00893                 $objDefinition = new ilObjectDefinition();
00894                 $GLOBALS['objDefinition'] =& $objDefinition;
00895                 $objDefinition->startParsing();
00896                 $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
00897 
00898                 // $ilAccess and $rbac... initialisation
00899                 $this->initAccessHandling();
00900 
00901                 // init tree
00902                 $tree = new ilTree(ROOT_FOLDER_ID);
00903                 $GLOBALS['tree'] =& $tree;
00904 
00905                 // authenticate & start session
00906                 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
00907                 $ilBench->start("Core", "HeaderInclude_Authentication");
00908 //var_dump($_SESSION);
00909                 $ilAuth->start();
00910 //var_dump($_SESSION);
00911                 $ilias->setAuthError($ilErr->getLastError());
00912                 $ilBench->stop("Core", "HeaderInclude_Authentication");
00913                 
00914                 // workaround: force login
00915                 if ($_GET["cmd"] == "force_login" || $this->script == "login.php")
00916                 {
00917                         $ilAuth->logout();
00918                         $_SESSION["AccountId"] = "";
00919                         $ilAuth->start();
00920                         $ilias->setAuthError($ilErr->getLastError());
00921                 }
00922                 
00923                 // check correct setup
00924                 if (!$ilias->getSetting("setup_ok"))
00925                 {
00926                         die("Setup is not completed. Please run setup routine again.");
00927                 }
00928 
00929                 // $ilUser initialisation (1)
00930                 $ilBench->start("Core", "HeaderInclude_getCurrentUser");
00931                 $ilUser = new ilObjUser();
00932                 $ilias->account =& $ilUser;
00933                 $GLOBALS['ilUser'] =& $ilUser;
00934                 $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
00935                 
00936                 
00937                 // $ilCtrl initialisation
00938                 $ilCtrl = new ilCtrl();
00939                 $GLOBALS['ilCtrl'] =& $ilCtrl;
00940 
00941                 // determin current script and up-path to main directory
00942                 // (sets $this->script and $this->updir)
00943                 $this->determineScriptAndUpDir();
00944                 
00945                 // $styleDefinition initialisation and style handling for login and co.
00946                 $this->initStyle();
00947                 if (in_array($this->script,
00948                         array("login.php", "register.php", "view_usr_agreement.php"))
00949                         || $_GET["baseClass"] == "ilStartUpGUI")
00950                 {
00951                         $this->handleStyle();
00952                 }
00953                 
00954                 
00955                 // handle ILIAS 2 imported users:
00956                 // check ilias 2 password, if authentication failed
00957                 // only if AUTH_LOCAL
00958 //echo "A";
00959                 if (AUTH_CURRENT == AUTH_LOCAL && !$ilAuth->getAuth() && $this->script == "login.php" && $_POST["username"] != "")
00960                 {
00961                         if (ilObjUser::_lookupHasIlias2Password(ilUtil::stripSlashes($_POST["username"])))
00962                         {
00963                                 if (ilObjUser::_switchToIlias3Password(
00964                                         ilUtil::stripSlashes($_POST["username"]),
00965                                         ilUtil::stripSlashes($_POST["password"])))
00966                                 {
00967                                         $ilAuth->start();
00968                                         $ilias->setAuthError($ilErr->getLastError());
00969                                         ilUtil::redirect("index.php");
00970                                 }
00971                         }
00972                 }
00973                 
00974 //echo $_POST; exit;
00975                 //
00976                 // SUCCESSFUL AUTHENTICATION
00977                 //
00978 //echo "<br>B-".$ilAuth->getAuth()."-".$ilAuth->_sessionName."-";
00979 //var_dump ($session[_authsession]);
00980                 if ($ilAuth->getAuth() && $ilias->account->isCurrentUserActive())
00981                 {
00982 //echo "C"; exit;
00983                         $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
00984 //var_dump($_SESSION);
00985                         // get user data
00986                         $this->initUserAccount();
00987 //var_dump($_SESSION);
00988                         // check client IP of user
00989                         $this->checkUserClientIP();
00990                         
00991                         // check user agreement
00992                         $this->checkUserAgreement();
00993                         
00994                         // update last_login date once the user logged in
00995                         if ($this->script == "login.php" ||
00996                                 $_GET["baseClass"] == "ilStartUpGUI")
00997                         {
00998                                 $ilUser->refreshLogin();
00999                         }
01000                 
01001                         // set hits per page for all lists using table module
01002                         $_GET['limit'] = $_SESSION['tbl_limit'] = (int) $ilUser->getPref('hits_per_page');
01003                         
01004                         // the next line makes it impossible to save the offset somehow in a session for
01005                         // a specific table (I tried it for the user administration).
01006                         // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
01007                         // or not set at all (then we want the last offset, e.g. being used from a session var).
01008                         // So I added the wrapping if statement. Seems to work (hopefully).
01009                         // Alex April 14th 2006
01010                         if ($_GET['offset'] != "")                                                      // added April 14th 2006
01011                         {
01012                                 $_GET['offset'] = (int) $_GET['offset'];                // old code
01013                         }
01014                 
01015                         $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
01016                 }
01017                 elseif (
01018                                         $this->script != "login.php" 
01019                                         and $this->script != "shib_login.php"
01020                                         and $this->script != "error.php" 
01021                                         and $this->script != "index.php"
01022                                         and $this->script != "view_usr_agreement.php" 
01023                                         and $this->script != "register.php" 
01024                                         and $this->script != "chat.php"
01025                                         and $this->script != "pwassist.php"
01026                                 )
01027                 {
01028                         //
01029                         // AUTHENTICATION FAILED
01030                         //
01031 
01032                         // authentication failed due to inactive user?
01033                         if ($ilAuth->getAuth() && !$ilUser->isCurrentUserActive())
01034                         {
01035                                 $inactive = true;
01036                         }
01037 
01038                         // jump to public section (to do: is this always the indended
01039                         // behaviour, login could be another possibility (including
01040                         // message)
01041 //echo "-".$_GET["baseClass"]."-";
01042                         if ($_GET["baseClass"] != "ilStartUpGUI")
01043                         {
01044                                 // $lng initialisation
01045                                 $this->initLanguage();
01046 
01047                                 if ($ilSetting->get("pub_section") &&
01048                                         ($ilAuth->status == "" || $ilAuth->status == AUTH_EXPIRED ||
01049                                                 $ilAuth->status == AUTH_IDLED) &&
01050                                         $_GET["reloadpublic"] != "1")
01051                                 {
01052                                         $this->goToPublicSection();
01053                                 }
01054                                 else
01055                                 {
01056                                         $this->goToLogin($ilAuth->getStatus());
01057                                 }
01058                                 // we should not get here
01059                                 exit;
01060                         }
01061                 }
01062 
01063                 //
01064                 // SUCCESSFUL AUTHENTICATED or NON-AUTH-AREA (Login, Registration, ...)
01065                 //
01066                 
01067                 // $lng initialisation
01068                 $this->initLanguage();
01069                 
01070                 // store user language in tree
01071                 $GLOBALS['tree']->initLangCode();
01072                 
01073                 // instantiate main template
01074                 $tpl = new ilTemplate("tpl.main.html", true, true);
01075                 $GLOBALS['tpl'] =& $tpl;
01076                 
01077                 
01078                 // ### AA 03.10.29 added new LocatorGUI class ###
01079                 // when locator data array does not exist, initialise
01080                 if ( !isset($_SESSION["locator_level"]) )
01081                 {
01082                         $_SESSION["locator_data"] = array();
01083                         $_SESSION["locator_level"] = -1;
01084                 }
01085                 // initialise global ilias_locator object
01086                 $ilias_locator = new ilLocatorGUI();                    // deprecated
01087                 $ilLocator = new ilLocatorGUI();
01088                 $GLOBALS['ilias_locator'] =& $ilias_locator;    // deprecated
01089                 $GLOBALS['ilLocator'] =& $ilLocator;
01090                 
01091                 // load style definitions
01092                 $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
01093                 $styleDefinition = new ilStyleDefinition();
01094                 $GLOBALS['styleDefinition'] =& $styleDefinition;
01095                 $styleDefinition->startParsing();
01096                 $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
01097                                 
01098                 // load style sheet depending on user's settings
01099                 $location_stylesheet = ilUtil::getStyleSheetLocation();
01100                 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
01101                 $tpl->setVariable("LOCATION_JAVASCRIPT",dirname($location_stylesheet));
01102                 
01103                 // get P3P file location
01104                 //$location_p3p_file = ilUtil::getP3PLocation();
01105                 //$tpl->setVariable("LOCATION_P3PFILE", $location_p3p_file);
01106                 
01107                 // init infopanel
01108                                 
01109                 // provide global browser information
01110                 $ilBrowser = new ilBrowser();
01111                 $GLOBALS['ilBrowser'] =& $ilBrowser;
01112                 
01113                 // provide global help object
01114                 $ilHelp = new ilHelp();
01115                 $GLOBALS['ilHelp'] =& $ilHelp;
01116                 
01117                 // main tabs gui
01118                 include_once 'classes/class.ilTabsGUI.php';
01119                 $ilTabs = new ilTabsGUI();
01120                 $GLOBALS['ilTabs'] =& $ilTabs;
01121                 
01122                 // main menu
01123                 include_once 'classes/class.ilMainMenuGUI.php';
01124                 $ilMainMenu = new ilMainMenuGUI("_top");
01125                 $GLOBALS['ilMainMenu'] =& $ilMainMenu;
01126                 
01127                 // Store online time of user
01128                 ilOnlineTracking::_updateAccess($ilUser->getId());
01129                                 
01130                 $ilBench->stop("Core", "HeaderInclude");
01131                 $ilBench->save();
01132 
01133         }
01134 }
01135 ?>

Generated on Fri Dec 13 2013 13:52:11 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1