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

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1