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

include/inc.header.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 
00035 // get pear
00036 include("include/inc.get_pear.php");
00037 
00038 //include class.util first to start StopWatch
00039 require_once "classes/class.ilUtil.php";
00040 require_once "classes/class.ilBenchmark.php";
00041 $ilBench =& new ilBenchmark();
00042 $GLOBALS['ilBench'] =& $ilBench;
00043 $ilBench->start("Core", "HeaderInclude");
00044 
00045 // start the StopWatch
00046 $t_pagestart = ilUtil::StopWatch();
00047 
00048 $ilBench->start("Core", "HeaderInclude_IncludeFiles");
00049 
00050 //include files from PEAR
00051 require_once "PEAR.php";
00052 require_once "DB.php";
00053 require_once "Auth/Auth.php";
00054 
00055 // memory usage at this point (2005-02-09): ~781KB)
00056 //echo "<br>memory1:".memory_get_usage()."<br>";
00057 
00058 // wrapper for php 4.3.2 & higher
00059 @include_once "HTML/ITX.php";
00060 
00061 if (!class_exists("IntegratedTemplateExtension"))
00062 {
00063         include_once "HTML/Template/ITX.php";
00064         //include_once "classes/class.ilTemplate2.php";
00065         include_once "classes/class.ilTemplateHTMLITX.php";
00066 }
00067 else
00068 {
00069         //include_once "classes/class.ilTemplate.php";
00070         include_once "classes/class.ilTemplateITX.php";
00071 }
00072 require_once "classes/class.ilTemplate.php";
00073 
00074 //include classes and function libraries
00075 require_once "include/inc.db_session_handler.php";
00076 require_once "classes/class.ilIniFile.php";
00077 require_once "classes/class.ilDBx.php";
00078 require_once "classes/class.ilShibboleth.php";
00079 require_once "classes/class.ilias.php";
00080 require_once "classes/class.ilObjUser.php";
00081 require_once "classes/class.ilFormat.php";
00082 require_once "classes/class.ilSaxParser.php";
00083 require_once "classes/class.ilObjectDefinition.php";
00084 require_once "classes/class.ilStyleDefinition.php";
00085 require_once "classes/class.perm.php";
00086 require_once "classes/class.ilTree.php";
00087 require_once "classes/class.ilLanguage.php";
00088 require_once "classes/class.ilLog.php";
00089 require_once "classes/class.ilMailbox.php";
00090 require_once "classes/class.ilCtrl.php";
00091 require_once "classes/class.ilConditionHandler.php";
00092 require_once "classes/class.ilBrowser.php";
00093 require_once "classes/class.ilFrameTargetInfo.php";
00094 require_once "Services/Help/classes/class.ilHelp.php";
00095 require_once "include/inc.ilias_version.php";
00096 
00097 //include role based access control system
00098 require_once "Services/AccessControl/classes/class.ilAccessHandler.php";
00099 require_once "classes/class.ilRbacAdmin.php";
00100 require_once "classes/class.ilRbacSystem.php";
00101 require_once "classes/class.ilRbacReview.php";
00102 
00103 // include object_data cache
00104 require_once "classes/class.ilObjectDataCache.php";
00105 
00106 require_once 'Services/Tracking/classes/class.ilOnlineTracking.php';
00107 
00108 // memory usage at this point (2005-02-09): ~3MB)
00109 //echo "<br>memory2:".memory_get_usage()."<br>";
00110 
00111 // ### AA 03.10.29 added new LocatorGUI class ###
00112 //include LocatorGUI
00113 require_once "classes/class.ilLocatorGUI.php";
00114 
00115 // include error_handling
00116 require_once "classes/class.ilErrorHandling.php";
00117 
00118 $ilBench->stop("Core", "HeaderInclude_IncludeFiles");
00119 
00120 // remove unsafe characters from _GET
00121 if (is_array($_GET))
00122 {
00123         foreach($_GET as $k => $v)
00124         {
00125                 if (!in_array($k, array("file")))
00126                 {
00127                         $_GET[$k] = str_replace(array("\x00", "\n", "\r", "\\", "'", '"', "\x1a"), "", $v);
00128                 }
00129                 
00130                 // this one is for XSS of any kind
00131                 $_GET[$k] = strip_tags($_GET[$k]);
00132         }
00133 }
00134 
00135 
00136 $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
00137 $ilErr = new ilErrorHandling();
00138 $GLOBALS['ilErr'] =& $ilErr;
00139 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00140 $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
00141 
00142 // load main class
00143 $ilBench->start("Core", "HeaderInclude_GetILIASObject");
00144 $ilias =& new ILIAS($_COOKIE["ilClientId"]);
00145 $GLOBALS['ilias'] =& $ilias;
00146 $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
00147 
00148 // trace function calls in debug mode
00149 if (DEVMODE)
00150 {
00151         if (function_exists("xdebug_start_trace"))
00152         {
00153                 //xdebug_start_trace("/tmp/test.txt");
00154         }
00155 }
00156 
00157 
00158 require_once './classes/class.ilHTTPS.php';
00159 
00160 $https =& new ilHTTPS();
00161 $GLOBALS['https'] =& $https;
00162 $https->checkPort();
00163 
00164 /*
00165 if (!db_set_save_handler())
00166 {
00167         $message = "Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini";
00168         $ilias->raiseError($message, $ilias->error_obj->WARNING);
00169 }*/
00170 
00171 // Start object_data cache
00172 $ilObjDataCache = new ilObjectDataCache();
00173 $GLOBALS['ilObjDataCache'] =& $ilObjDataCache;
00174 
00175 
00176 // LOAD OLD POST VARS IF ERROR HANDLER 'MESSAGE' WAS CALLED
00177 if ($_SESSION["message"])
00178 {
00179         $_POST = $_SESSION["post_vars"];
00180 }
00181 
00182 // put debugging functions here
00183 //if (DEBUG)
00184 //{
00185         include_once "include/inc.debug.php";
00186 //}
00187 
00188 // start logging
00189 $log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,$ilias->getClientId(),ILIAS_LOG_ENABLED,ILIAS_LOG_LEVEL);
00190 $GLOBALS['log'] =& $log;
00191 $ilLog =& $log;
00192 $GLOBALS['ilLog'] =& $ilLog;
00193 
00194 //echo "1-".$ilias->account->skin."-";
00195 
00196 //authenticate & start session
00197 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
00198 $ilBench->start("Core", "HeaderInclude_Authentication");
00199 $ilias->auth->start();
00200 $ilias->setAuthError($ilErr->getLastError());
00201 $ilBench->stop("Core", "HeaderInclude_Authentication");
00202 
00203 
00204 // force login ; workaround for hsu
00205 if ($_GET["cmd"] == "force_login")
00206 {
00207         $ilias->auth->logout();
00208         $_SESSION["AccountId"] = "";
00209         $ilias->auth->start();
00210         $ilias->setAuthError($ilErr->getLastError());
00211 }
00212 
00213 // load object definitions
00214 $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
00215 $objDefinition = new ilObjectDefinition();
00216 $GLOBALS['objDefinition'] =& $objDefinition;
00217 $objDefinition->startParsing();
00218 $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
00219 
00220 
00221 // current user account
00222 $ilBench->start("Core", "HeaderInclude_getCurrentUser");
00223 $ilias->account = new ilObjUser();
00224 $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
00225 
00226 // create references for subobjects in ilias object
00227 $ilUser =& $ilias->account;
00228 $GLOBALS['ilUser'] =& $ilias->account;
00229 $ilCtrl = new ilCtrl();
00230 $GLOBALS['ilCtrl'] =& $ilCtrl;
00231 
00232 //but in login.php and index.php don't check for authentication
00233 $script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
00234 
00235 // set theme for login
00236 if (in_array($script, array("login.php", "register.php", "view_usr_agreement.php")))
00237 {
00238         // load style definitions
00239         $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
00240         $styleDefinition = new ilStyleDefinition();
00241         $GLOBALS['styleDefinition'] =& $styleDefinition;
00242         $styleDefinition->startParsing();
00243         $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
00244         
00245         if ($_GET['skin']  && $_GET['style'])
00246         {
00247                 include_once("classes/class.ilObjStyleSettings.php");
00248                 if ($styleDefinition->styleExists($_GET['skin'], $_GET['style']) &&
00249                         ilObjStyleSettings::_lookupActivatedStyle($_GET['skin'], $_GET['style']))
00250                 {
00251                         $_SESSION['skin'] = $_GET['skin'];
00252                         $_SESSION['style'] = $_GET['style'];
00253                 }
00254         }
00255         if ($_SESSION['skin'] && $_SESSION['style'])
00256         {
00257                 include_once("classes/class.ilObjStyleSettings.php");
00258                 if ($styleDefinition->styleExists($_SESSION['skin'], $_SESSION['style']) &&
00259                         ilObjStyleSettings::_lookupActivatedStyle($_SESSION['skin'], $_SESSION['style']))
00260                 {
00261                         $ilias->account->skin = $_SESSION['skin'];
00262                         $ilias->account->prefs['style'] = $_SESSION['style'];
00263                 }
00264         }
00265 }
00266 
00267 
00268 // check ilias 2 password, if authentication failed
00269 // only if AUTH_LOCAL
00270 if (AUTH_CURRENT == AUTH_LOCAL && !$ilias->auth->getAuth() && $script == "login.php" && $_POST["username"] != "")
00271 //if (!$ilias->auth->getAuth() && $script == "login.php" && $_POST["username"] != "")
00272 {
00273         if (ilObjUser::_lookupHasIlias2Password($_POST["username"]))
00274         {
00275                 if (ilObjUser::_switchToIlias3Password($_POST["username"], $_POST["password"]))
00276                 {
00277                         $ilias->auth->start();
00278                         $ilias->setAuthError($ilErr->getLastError());
00279                         ilUtil::redirect("start.php");
00280                 }
00281         }
00282 }
00283 
00284 if (strpos($_SERVER["SCRIPT_FILENAME"], "save_java_question_result") !== FALSE)
00285 {
00286         // dirty hack for the saving of java applet questions in tests. Unfortunately
00287         // some changes in this file for ILIAS 3.6 caused this script to stop at the
00288         // following check (worked in ILIAS <= 3.5).
00289         // So we return here, because it's only necessary to get the $ilias class for
00290         // the database connection
00291         // TODO: Find out what happens here. Talk to Alex Killing
00292         $lng = new ilLanguage($_SESSION['lang']);
00293         $GLOBALS['lng'] =& $lng;
00294         return;
00295 }
00296 
00297 if ($ilias->auth->getAuth() && $ilias->account->isCurrentUserActive())
00298 {
00299         $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
00300 
00301         //get user id
00302         if (empty($_SESSION["AccountId"]))
00303         {
00304                 $_SESSION["AccountId"] = $ilias->account->checkUserId();
00305 
00306         // assigned roles are stored in $_SESSION["RoleId"]
00307                 $rbacreview = new ilRbacReview();
00308                 $GLOBALS['rbacreview'] =& $rbacreview;
00309                 $_SESSION["RoleId"] = $rbacreview->assignedRoles($_SESSION["AccountId"]);
00310         } // TODO: do we need 'else' here?
00311         else
00312         {
00313                 // init user
00314                 $ilias->account->setId($_SESSION["AccountId"]);
00315         }
00316 
00317         // load account data of current user
00318         $ilias->account->read();
00319         
00320         // check client ip
00321         $clientip = $ilias->account->getClientIP();
00322         if (trim($clientip) !="" and $clientip != $_SERVER["REMOTE_ADDR"])
00323         {
00324                 $log ->logError(1,
00325                         $ilias->account->getLogin().":".$_SERVER["REMOTE_ADDR"].":".$message);
00326                 $ilias->auth->logout();
00327                 @session_destroy();
00328                 ilUtil::redirect("login.php?wrong_ip=true");
00329         }
00330         
00331         // check wether user has accepted the user agreement
00332         //      echo "-".$script;
00333         if (!$ilias->account->hasAcceptedUserAgreement() &&
00334                 $script != "view_usr_agreement.php" &&
00335                 $script != "login.php" &&
00336                 $ilias->account->getId() != ANONYMOUS_USER_ID)
00337         {
00338 //echo "redirect from $script for ".$ilias->account->getFirstName();
00339                 ilUtil::redirect("view_usr_agreement.php?cmd=getAcceptance");
00340         }
00341 
00342         // update last_login date once the user logged in
00343         if ($script == "login.php")
00344         {
00345                 $ilias->account->refreshLogin();
00346         }
00347 
00348         // set hits per page for all lists using table module
00349         // Since hits_per_page is always read in ilObjUser we don't need to read it from the session
00350         #_SESSION["tbl_limit"] = ($_SESSION["tbl_limit"]) ? intval($_SESSION["tbl_limit"]) : intval($ilias->account->prefs["hits_per_page"]);
00351         #_GET["limit"] = ($_SESSION["tbl_limit"]) ? ($_SESSION["tbl_limit"]) : intval($ilias->account->prefs["hits_per_page"]);
00352         #_GET["offset"] = intval($_GET["offset"]);
00353         $_GET['limit'] = $_SESSION['tbl_limit'] = (int) $ilUser->getPref('hits_per_page');
00354         
00355         // the next line makes it impossible to save the offset somehow in a session for
00356         // a specific table (I tried it for the user administration).
00357         // its not posssible to distinguish whether it has been set to page 1 (=offset = 0)
00358         // or not set at all (then we want the last offset, e.g. being used from a session var).
00359         // So I added the wrapping if statement. Seems to work (hopefully).
00360         // Alex April 14th 2006
00361         if ($_GET['offset'] != "")                                                      // added April 14th 2006
00362         {
00363                 $_GET['offset'] = (int) $_GET['offset'];                // old code
00364         }
00365 
00366         $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
00367 }
00368 elseif (
00369                         $script != "login.php" 
00370                         and $script != "shib_login.php" 
00371                         and $script != "nologin.php" 
00372                         and $script != "error.php" 
00373                         and $script != "index.php"
00374                         and $script != "view_usr_agreement.php" 
00375                         and $script != "register.php" 
00376                         and $script != "chat.php"
00377                         and $script != "pwassist.php"
00378                 )
00379 {
00380         // phpinfo();exit;
00381 
00382         $dirname = dirname($_SERVER["PHP_SELF"]);
00383         $ilurl = parse_url(ILIAS_HTTP_PATH);
00384         $subdir = substr(strstr($dirname,$ilurl["path"]),strlen($ilurl["path"]));
00385         $updir = "";
00386 
00387         if ($subdir)
00388         {
00389                 $num_subdirs = substr_count($subdir,"/");
00390 
00391                 for ($i=1;$i<=$num_subdirs;$i++)
00392                 {
00393                         $updir .= "../";
00394                 }
00395         }
00396 
00397     if ($ilias->auth->getAuth() && !$ilias->account->isCurrentUserActive())
00398     {
00399         $inactive = true;
00400     }
00401 
00402         session_unset();
00403         session_destroy();
00404         
00405         $return_to = urlencode(substr($_SERVER["REQUEST_URI"],strlen($ilurl["path"])+1));
00406 
00407         if (($_GET["inactive"]) || $inactive)
00408         {
00409                 ilUtil::redirect($updir."index.php?reload=true&inactive=true&return_to=".$return_to);
00410         }
00411         else
00412         {
00413                 ilUtil::redirect($updir."index.php?client_id=".$_COOKIE["ilClientId"]."&reload=true&return_to=".$return_to);
00414         }
00415 }
00416 
00417 //init language
00418 $ilBench->start("Core", "HeaderInclude_initLanguage");
00419 
00420 if (is_null($_SESSION['lang']))
00421 {
00422         $_GET["lang"] = ($_GET["lang"]) ? $_GET["lang"] : $ilias->account->getPref("language");
00423 }
00424 
00425 if ($_POST['change_lang_to'] != "")
00426 {
00427         $_GET['lang'] = $_POST['change_lang_to'];
00428 }
00429 
00430 $_SESSION['lang'] = ($_GET['lang']) ? $_GET['lang'] : $_SESSION['lang'];
00431 
00432 // prefer personal setting when coming from login screen 
00433 if ($script == "login.php")
00434 {
00435         $_SESSION['lang'] = $ilias->account->getPref("language");
00436 }
00437 
00438 $lng = new ilLanguage($_SESSION['lang']);
00439 $GLOBALS['lng'] =& $lng;
00440 $ilBench->stop("Core", "HeaderInclude_initLanguage");
00441 
00442 // init rbac
00443 $ilBench->start("Core", "HeaderInclude_initRBAC");
00444 $rbacsystem = new ilRbacSystem();
00445 $GLOBALS['rbacsystem'] =& $rbacsystem;
00446 $rbacadmin = new ilRbacAdmin();
00447 $GLOBALS['rbacadmin'] =& $rbacadmin;
00448 $rbacreview = new ilRbacReview();
00449 $GLOBALS['rbacreview'] =& $rbacreview;
00450 $ilAccess =& new ilAccessHandler();
00451 $GLOBALS["ilAccess"] =& $ilAccess;
00452 
00453 $ilBench->stop("Core", "HeaderInclude_initRBAC");
00454 
00455 
00456 // init ref_id on first start ref_id is set to ROOT_FOLDER_ID
00457 //$_GET["ref_id"] = $_GET["ref_id"] ? $_GET["ref_id"] : ROOT_FOLDER_ID;
00458 
00459 // init tree
00460 $tree = new ilTree(ROOT_FOLDER_ID);
00461 $GLOBALS['tree'] =& $tree;
00462 
00463 // instantiate main template
00464 $tpl = new ilTemplate("tpl.main.html", true, true);
00465 $GLOBALS['tpl'] =& $tpl;
00466 
00467 
00468 // ### AA 03.10.29 added new LocatorGUI class ###
00469 // when locator data array does not exist, initialise
00470 if ( !isset($_SESSION["locator_level"]) )
00471 {
00472         $_SESSION["locator_data"] = array();
00473         $_SESSION["locator_level"] = -1;
00474 }
00475 // initialise global ilias_locator object
00476 $ilias_locator = new ilLocatorGUI();                    // deprecated
00477 $ilLocator = new ilLocatorGUI();
00478 $GLOBALS['ilias_locator'] =& $ilias_locator;    // deprecated
00479 $GLOBALS['ilLocator'] =& $ilLocator;
00480 
00481 // load style definitions
00482 $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
00483 $styleDefinition = new ilStyleDefinition();
00484 $GLOBALS['styleDefinition'] =& $styleDefinition;
00485 $styleDefinition->startParsing();
00486 $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
00487 
00488 //navigation things
00489 /*
00490         I really don't know in which case the following code is needed.
00491         If any errors occur due to disabling this, please do
00492         not hesitate to mail me... alex.killing@gmx.de
00493 
00494         this function was used for the no_frames template set... shofmann@databay.de
00495 
00496 if ($script != "login.php" && $script != "index.php")
00497 {
00498         if ($tpl->includeNavigation() == true)
00499         {
00500                 $menu = new ilMainMenu();
00501                 $menu->setTemplate($tpl);
00502                 $menu->addMenuBlock("NAVIGATION", "navigation");
00503                 $menu->setTemplateVars();
00504                 //include("include/inc.mainmenu.php");
00505         }
00506 }*/
00507 
00508 // load style sheet depending on user's settings
00509 $location_stylesheet = ilUtil::getStyleSheetLocation();
00510 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
00511 $tpl->setVariable("LOCATION_JAVASCRIPT",dirname($location_stylesheet));
00512 
00513 // init infopanel
00514 if ($mail_id = ilMailbox::hasNewMail($_SESSION["AccountId"]))
00515 {
00516         $mbox = new ilMailbox($_SESSION["AccountId"]);
00517         $mail =& new ilMail($_SESSION['AccountId']);
00518         if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
00519         {
00520                 $folder_id = $mbox->getInboxFolder();
00521                 
00522                 $_SESSION["infopanel"] = array ("link"  => "mail_frameset.php?target=".
00523                                                                                 htmlentities(urlencode("mail_read.php?mobj_id=".$folder_id."&mail_id=".$mail_id)),
00524                                                                                 "text"  => "new_mail"
00525                                                                                 //"img" => "icon_mail.gif"
00526                         );
00527         }
00528 }
00529 
00530 // php5 downward complaince to php 4 dom xml and clone method
00531 if (version_compare(PHP_VERSION,'5','>='))
00532 {
00533         require_once("include/inc.xml5compliance.php");
00534         require_once("include/inc.xsl5compliance.php");
00535         require_once("include/inc.php4compliance.php");
00536 }
00537 else
00538 {
00539         require_once("include/inc.php5compliance.php");
00540 }
00541 
00542 // provide global browser information
00543 $ilBrowser = new ilBrowser();
00544 $GLOBALS['ilBrowser'] =& $ilBrowser;
00545 
00546 // provide global help object
00547 $ilHelp = new ilHelp();
00548 $GLOBALS['ilHelp'] =& $ilHelp;
00549 
00550 // main tabs gui
00551 include_once 'classes/class.ilTabsGUI.php';
00552 $ilTabs = new ilTabsGUI();
00553 $GLOBALS['ilTabs'] =& $ilTabs;
00554 
00555 // Store online time of user
00556 ilOnlineTracking::_updateAccess($ilUser->getId());
00557 
00558 
00559 // utf-8 fix?
00560 $q = "SET NAMES utf8";
00561 //$ilDB->query($q);
00562 
00563 $ilBench->stop("Core", "HeaderInclude");
00564 $ilBench->save();
00565 
00566 ?>

Generated on Fri Dec 13 2013 11:57:58 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1