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

Generated on Fri Dec 13 2013 08:00:17 for ILIAS Release_3_3_x_branch .rev 46803 by  doxygen 1.7.1