• 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-2004 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 "include/inc.ilias_version.php";
00095 
00096 //include role based access control system
00097 require_once "Services/AccessControl/classes/class.ilAccessHandler.php";
00098 require_once "classes/class.ilRbacAdmin.php";
00099 require_once "classes/class.ilRbacSystem.php";
00100 require_once "classes/class.ilRbacReview.php";
00101 
00102 // memory usage at this point (2005-02-09): ~3MB)
00103 //echo "<br>memory2:".memory_get_usage()."<br>";
00104 
00105 // ### AA 03.10.29 added new LocatorGUI class ###
00106 //include LocatorGUI
00107 require_once "classes/class.ilLocatorGUI.php";
00108 
00109 // include error_handling
00110 require_once "classes/class.ilErrorHandling.php";
00111 
00112 $ilBench->stop("Core", "HeaderInclude_IncludeFiles");
00113 
00114 $ilBench->start("Core", "HeaderInclude_GetErrorHandler");
00115 $ilErr = new ilErrorHandling();
00116 $GLOBALS['ilErr'] =& $ilErr;
00117 $ilErr->setErrorHandling(PEAR_ERROR_CALLBACK,array($ilErr,'errorHandler'));
00118 $ilBench->stop("Core", "HeaderInclude_GetErrorHandler");
00119 
00120 // load main class
00121 $ilBench->start("Core", "HeaderInclude_GetILIASObject");
00122 $ilias =& new ILIAS($_COOKIE["ilClientId"]);
00123 $GLOBALS['ilias'] =& $ilias;
00124 $ilBench->stop("Core", "HeaderInclude_GetILIASObject");
00125 
00126 // trace function calls in debug mode
00127 if (DEVMODE)
00128 {
00129         if (function_exists("xdebug_start_trace"))
00130         {
00131                 //xdebug_start_trace("/tmp/test.txt");
00132         }
00133 }
00134 
00135 
00136 require_once './classes/class.ilHTTPS.php';
00137 
00138 $https =& new ilHTTPS();
00139 $GLOBALS['https'] =& $https;
00140 $https->checkPort();
00141 
00142 
00143 /*
00144 $ilDB = $ilias->db;
00145 $GLOBALS['ilDB'] =& $ilDB;
00146 if (!db_set_save_handler())
00147 {
00148         $message = "Please turn off Safe mode OR set session.save_handler to \"user\" in your php.ini";
00149         $ilias->raiseError($message, $ilias->error_obj->WARNING);
00150 }*/
00151 
00152 
00153 // LOAD OLD POST VARS IF ERROR HANDLER 'MESSAGE' WAS CALLED
00154 if ($_SESSION["message"])
00155 {
00156         $_POST = $_SESSION["post_vars"];
00157 }
00158 
00159 // put debugging functions here
00160 //if (DEBUG)
00161 //{
00162         include_once "include/inc.debug.php";
00163 //}
00164 
00165 // start logging
00166 $log = new ilLog(ILIAS_LOG_DIR,ILIAS_LOG_FILE,$ilias->getClientId(),ILIAS_LOG_ENABLED,ILIAS_LOG_LEVEL);
00167 $GLOBALS['log'] =& $log;
00168 $ilLog =& $log;
00169 $GLOBALS['ilLog'] =& $ilLog;
00170 
00171 //authenticate & start session
00172 PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($ilErr, "errorHandler"));
00173 $ilBench->start("Core", "HeaderInclude_Authentication");
00174 $ilias->auth->start();
00175 $ilias->setAuthError($ilErr->getLastError());
00176 $ilBench->stop("Core", "HeaderInclude_Authentication");
00177 
00178 // force login ; workaround for hsu
00179 if ($_GET["cmd"] == "force_login")
00180 {
00181         $ilias->auth->logout();
00182         $_SESSION["AccountId"] = "";
00183         $ilias->auth->start();
00184         $ilias->setAuthError($ilErr->getLastError());
00185 }
00186 
00187 
00188 // load object definitions
00189 $ilBench->start("Core", "HeaderInclude_getObjectDefinitions");
00190 $objDefinition = new ilObjectDefinition();
00191 $GLOBALS['objDefinition'] =& $objDefinition;
00192 $objDefinition->startParsing();
00193 $ilBench->stop("Core", "HeaderInclude_getObjectDefinitions");
00194 
00195 
00196 // current user account
00197 $ilBench->start("Core", "HeaderInclude_getCurrentUser");
00198 $ilias->account = new ilObjUser();
00199 $ilBench->stop("Core", "HeaderInclude_getCurrentUser");
00200 
00201 // create references for subobjects in ilias object
00202 $ilUser =& $ilias->account;
00203 $GLOBALS['ilUser'] =& $ilias->account;
00204 $ilCtrl = new ilCtrl();
00205 $GLOBALS['ilCtrl'] =& $ilCtrl;
00206 
00207 //but in login.php and index.php don't check for authentication
00208 $script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
00209 
00210 // check ilias 2 password, if authentication failed
00211 // only if AUTH_LOCAL
00212 if (AUTH_CURRENT == AUTH_LOCAL && !$ilias->auth->getAuth() && $script == "login.php" && $_POST["username"] != "")
00213 //if (!$ilias->auth->getAuth() && $script == "login.php" && $_POST["username"] != "")
00214 {
00215         if (ilObjUser::_lookupHasIlias2Password($_POST["username"]))
00216         {
00217                 if (ilObjUser::_switchToIlias3Password($_POST["username"], $_POST["password"]))
00218                 {
00219                         $ilias->auth->start();
00220                         $ilias->setAuthError($ilErr->getLastError());
00221                         ilUtil::redirect("start.php");
00222                 }
00223         }
00224 }
00225 
00226 if ($ilias->auth->getAuth() && $ilias->account->isCurrentUserActive())
00227 {
00228         $ilBench->start("Core", "HeaderInclude_getCurrentUserAccountData");
00229 
00230         //get user id
00231         if (empty($_SESSION["AccountId"]))
00232         {
00233                 $_SESSION["AccountId"] = $ilias->account->checkUserId();
00234 
00235         // assigned roles are stored in $_SESSION["RoleId"]
00236                 $rbacreview = new ilRbacReview();
00237                 $GLOBALS['rbacreview'] =& $rbacreview;
00238                 $_SESSION["RoleId"] = $rbacreview->assignedRoles($_SESSION["AccountId"]);
00239         } // TODO: do we need 'else' here?
00240         else
00241         {
00242                 // init user
00243                 $ilias->account->setId($_SESSION["AccountId"]);
00244         }
00245 
00246         // load account data of current user
00247         $ilias->account->read();
00248         
00249         // check client ip
00250         $clientip = $ilias->account->getClientIP();
00251         if (trim($clientip) !="" and $clientip != $_SERVER["REMOTE_ADDR"])
00252         {
00253                 $log ->logError(1,
00254                         $ilias->account->getLogin().":".$_SERVER["REMOTE_ADDR"].":".$message);
00255                 $ilias->auth->logout();
00256                 @session_destroy();
00257                 ilUtil::redirect("login.php?wrong_ip=true");
00258         }
00259         
00260         // check wether user has accepted the user agreement
00261         //      echo "-".$script;
00262         if (!$ilias->account->hasAcceptedUserAgreement() &&
00263                 $script != "view_usr_agreement.php" &&
00264                 $script != "login.php" &&
00265                 $ilias->account->getId() != ANONYMOUS_USER_ID)
00266         {
00267 //echo "redirect from $script for ".$ilias->account->getFirstName();
00268                 ilUtil::redirect("view_usr_agreement.php?cmd=getAcceptance");
00269         }
00270 
00271         // update last_login date once the user logged in
00272         if ($script == "login.php")
00273         {
00274                 $ilias->account->refreshLogin();
00275         }
00276 
00277         // set hits per page for all lists using table module
00278         // Since hits_per_page is always read in ilObjUser we don't need to read it from the session
00279         #_SESSION["tbl_limit"] = ($_SESSION["tbl_limit"]) ? intval($_SESSION["tbl_limit"]) : intval($ilias->account->prefs["hits_per_page"]);
00280         #_GET["limit"] = ($_SESSION["tbl_limit"]) ? ($_SESSION["tbl_limit"]) : intval($ilias->account->prefs["hits_per_page"]);
00281         #_GET["offset"] = intval($_GET["offset"]);
00282         $_GET['limit'] = $_SESSION['tbl_limit'] = (int) $ilUser->getPref('hits_per_page');
00283         #$_GET['offset'] = (int) $_GET['offset'];
00284         
00285 
00286         $ilBench->stop("Core", "HeaderInclude_getCurrentUserAccountData");
00287 }
00288 elseif (
00289                         $script != "login.php" 
00290                         and $script != "shib_login.php" 
00291                         and $script != "nologin.php" 
00292                         and $script != "error.php" 
00293                         and $script != "index.php"
00294                         and $script != "view_usr_agreement.php" 
00295                         and $script != "register.php" 
00296                         and $script != "chat.php"
00297                         and $script != "pwassist.php"
00298                 )
00299 {
00300         // phpinfo();exit;
00301 
00302         $dirname = dirname($_SERVER["PHP_SELF"]);
00303         $ilurl = parse_url(ILIAS_HTTP_PATH);
00304         $subdir = substr(strstr($dirname,$ilurl["path"]),strlen($ilurl["path"]));
00305         $updir = "";
00306 
00307         if ($subdir)
00308         {
00309                 $num_subdirs = substr_count($subdir,"/");
00310 
00311                 for ($i=1;$i<=$num_subdirs;$i++)
00312                 {
00313                         $updir .= "../";
00314                 }
00315         }
00316 
00317     if ($ilias->auth->getAuth() && !$ilias->account->isCurrentUserActive())
00318     {
00319         $inactive = true;
00320     }
00321 
00322         session_unset();
00323         session_destroy();
00324         
00325         $return_to = urlencode(substr($_SERVER["REQUEST_URI"],strlen($ilurl["path"])+1));
00326 
00327         if (($_GET["inactive"]) || $inactive)
00328         {
00329                 ilUtil::redirect($updir."index.php?reload=true&inactive=true&return_to=".$return_to);
00330         }
00331         else
00332         {
00333                 ilUtil::redirect($updir."index.php?client_id=".$_COOKIE["ilClientId"]."&reload=true&return_to=".$return_to);
00334         }
00335 }
00336 
00337 //init language
00338 $ilBench->start("Core", "HeaderInclude_initLanguage");
00339 
00340 if (is_null($_SESSION['lang']))
00341 {
00342         $_GET["lang"] = ($_GET["lang"]) ? $_GET["lang"] : $ilias->account->getPref("language");
00343 }
00344 
00345 if ($_POST['change_lang_to'] != "")
00346 {
00347         $_GET['lang'] = $_POST['change_lang_to'];
00348 }
00349 
00350 $_SESSION['lang'] = ($_GET['lang']) ? $_GET['lang'] : $_SESSION['lang'];
00351 
00352 // prefer personal setting when coming from login screen 
00353 if ($script == "login.php")
00354 {
00355         $_SESSION['lang'] = $ilias->account->getPref("language");
00356 }
00357 
00358 $lng = new ilLanguage($_SESSION['lang']);
00359 $GLOBALS['lng'] =& $lng;
00360 $ilBench->stop("Core", "HeaderInclude_initLanguage");
00361 
00362 // init rbac
00363 $ilBench->start("Core", "HeaderInclude_initRBAC");
00364 $rbacsystem = new ilRbacSystem();
00365 $GLOBALS['rbacsystem'] =& $rbacsystem;
00366 $rbacadmin = new ilRbacAdmin();
00367 $GLOBALS['rbacadmin'] =& $rbacadmin;
00368 $rbacreview = new ilRbacReview();
00369 $GLOBALS['rbacreview'] =& $rbacreview;
00370 $ilAccess =& new ilAccessHandler();
00371 $GLOBALS["ilAccess"] =& $ilAccess;
00372 
00373 $ilBench->stop("Core", "HeaderInclude_initRBAC");
00374 
00375 
00376 // init ref_id on first start ref_id is set to ROOT_FOLDER_ID
00377 //$_GET["ref_id"] = $_GET["ref_id"] ? $_GET["ref_id"] : ROOT_FOLDER_ID;
00378 
00379 // init tree
00380 $tree = new ilTree(ROOT_FOLDER_ID);
00381 $GLOBALS['tree'] =& $tree;
00382 
00383 // instantiate main template
00384 $tpl = new ilTemplate("tpl.main.html", true, true);
00385 $GLOBALS['tpl'] =& $tpl;
00386 
00387 
00388 // ### AA 03.10.29 added new LocatorGUI class ###
00389 // when locator data array does not exist, initialise
00390 if ( !isset($_SESSION["locator_level"]) )
00391 {
00392         $_SESSION["locator_data"] = array();
00393         $_SESSION["locator_level"] = -1;
00394 }
00395 // initialise global ilias_locator object
00396 $ilias_locator = new ilLocatorGUI();
00397 $GLOBALS['ilias_locator'] =& $ilias_locator;
00398 
00399 // load style definitions
00400 $ilBench->start("Core", "HeaderInclude_getStyleDefinitions");
00401 $styleDefinition = new ilStyleDefinition();
00402 $GLOBALS['styleDefinition'] =& $styleDefinition;
00403 $styleDefinition->startParsing();
00404 $ilBench->stop("Core", "HeaderInclude_getStyleDefinitions");
00405 
00406 //navigation things
00407 /*
00408         I really don't know in which case the following code is needed.
00409         If any errors occur due to disabling this, please do
00410         not hesitate to mail me... alex.killing@gmx.de
00411 
00412         this function was used for the no_frames template set... shofmann@databay.de
00413 
00414 if ($script != "login.php" && $script != "index.php")
00415 {
00416         if ($tpl->includeNavigation() == true)
00417         {
00418                 $menu = new ilMainMenu();
00419                 $menu->setTemplate($tpl);
00420                 $menu->addMenuBlock("NAVIGATION", "navigation");
00421                 $menu->setTemplateVars();
00422                 //include("include/inc.mainmenu.php");
00423         }
00424 }*/
00425 
00426 // load style sheet depending on user's settings
00427 $location_stylesheet = ilUtil::getStyleSheetLocation();
00428 $tpl->setVariable("LOCATION_STYLESHEET",$location_stylesheet);
00429 $tpl->setVariable("LOCATION_JAVASCRIPT",dirname($location_stylesheet));
00430 
00431 // init infopanel
00432 if ($mail_id = ilMailbox::hasNewMail($_SESSION["AccountId"]))
00433 {
00434         $mbox = new ilMailbox($_SESSION["AccountId"]);
00435         $mail =& new ilMail($_SESSION['AccountId']);
00436         if($rbacsystem->checkAccess('mail_visible',$mail->getMailObjectReferenceId()))
00437         {
00438                 $folder_id = $mbox->getInboxFolder();
00439                 
00440                 $_SESSION["infopanel"] = array ("link"  => "mail_frameset.php?target=".
00441                                                                                 htmlentities(urlencode("mail_read.php?mobj_id=".$folder_id."&mail_id=".$mail_id)),
00442                                                                                 "text"  => "new_mail"
00443                                                                                 //"img" => "icon_mail.gif"
00444                         );
00445         }
00446 }
00447 
00448 // php5 downward complaince to php 4 dom xml
00449 if (version_compare(PHP_VERSION,'5','>='))
00450 {
00451         require_once("include/inc.xml5compliance.php");
00452 }
00453 
00454 // php5 downward complaince to php 4 sablotorn xslt
00455 if (version_compare(PHP_VERSION,'5','>='))
00456 {
00457         require_once("include/inc.xsl5compliance.php");
00458 }
00459 
00460 // provide global browser information
00461 $ilBrowser = new ilBrowser();
00462 $GLOBALS['ilBrowser'] =& $ilBrowser;
00463 
00464 // utf-8 fix?
00465 $q = "SET NAMES utf8";
00466 //$ilDB->query($q);
00467 
00468 $ilBench->stop("Core", "HeaderInclude");
00469 $ilBench->save();
00470 ?>

Generated on Fri Dec 13 2013 10:18:30 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1