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

login.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 
00024 
00035 // get pear
00036 include("include/inc.get_pear.php");
00037 
00038 
00039 // login language selection is post type
00040 if ($_POST["lang"] != "")
00041 {
00042         $_GET["lang"] = $_POST["lang"];
00043 }
00044 
00045 // check for session cookies enabled
00046 if (!isset($_COOKIE['iltest']))
00047 {
00048         if (empty($_GET['cookies']))
00049         {
00050                 setcookie("iltest","cookie");
00051                 header('Location: '.$_SERVER['PHP_SELF']."?cookies=nocookies&lang=".$_GET['lang']);
00052         }
00053         else
00054         {
00055                 $_COOKIE['iltest'] = "";
00056         }
00057 }
00058 else
00059 {
00060         unset($_GET['cookies']);
00061 }
00062 
00063 // start correct client
00064 // if no client_id is given, default client is loaded (in class.ilias.php)
00065 if (isset($_GET["client_id"]))
00066 {       
00067         setcookie("ilClientId",$_GET["client_id"]);
00068         $_COOKIE["ilClientId"] = $_GET["client_id"];
00069 }
00070 
00071 require_once "include/inc.check_pear.php";
00072 require_once "include/inc.header.php";
00073 
00074 // check correct setup
00075 if (!$ilias->getSetting("setup_ok"))
00076 {
00077         echo "setup is not completed. Please run setup routine again. (login.php)";
00078         exit();
00079 }
00080 
00081 // check for auth
00082 if ($ilias->auth->getAuth())
00083 {
00084 
00085         
00086         if(!$ilias->account->checkTimeLimit())
00087         {
00088                 $ilias->auth->logout();
00089                 session_destroy();
00090                 ilUtil::redirect('login.php?time_limit=true');
00091         }
00092 
00093         if ($ilias->getSetting("chat_active"))
00094         {
00095                 include_once "./chat/classes/class.ilChatServerCommunicator.php";
00096                 include_once "./chat/classes/class.ilChatRoom.php";
00097 
00098                 ilChatServerCommunicator::_login();
00099                 ilChatRoom::_unkick($ilUser->getId());
00100         }
00101 
00102         // UPDATE LAST FORUM VISIT
00103         include_once './classes/class.ilObjForum.php';
00104 
00105         ilObjForum::_updateOldAccess($ilUser->getId());
00106 
00107         $return_to = "start.php";
00108 
00109         if ($_GET["rep_ref_id"] != "")
00110         {
00111                 $return_to.= "?script=".rawurlencode("repository.php?cmd=frameset&ref_id=".$_GET["rep_ref_id"]);
00112         }
00113 
00114         if (!empty($_GET["return_to"]))
00115         {
00116                 $return_to = urldecode($_GET["return_to"]);
00117         }
00118 
00119         ilUtil::redirect($return_to);
00120 }
00121 
00122 // Instantiate login template
00123 // Use Shibboleth-only authentication if auth_mode is set to Shibboleth
00124 if ($ilias->getSetting("auth_mode") == AUTH_SHIBBOLETH)
00125 {
00126         $tpl->addBlockFile("CONTENT", "content", "tpl.login.shib_only.html");
00127 }
00128 // Use dual login template if Shibboleth is configured and enabled
00129 elseif ($ilias->getSetting("shib_active"))
00130 {
00131         $tpl->addBlockFile("CONTENT", "content", "tpl.login.dual.html");
00132 }
00133 else
00134 {
00135         $tpl->addBlockFile("CONTENT", "content", "tpl.login.html");
00136 }
00137 
00138 //language handling
00139 if ($_GET["lang"] == "")
00140 {
00141         $_GET["lang"] = $ilias->ini->readVariable("language","default");
00142 }
00143 
00144 //instantiate language
00145 $lng = new ilLanguage($_GET["lang"]);
00146 
00147 // catch reload
00148 if ($_GET["reload"])
00149 {
00150     if ($_GET["inactive"])
00151     {
00152         $tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./login.php?inactive=true\";\n</script>\n");
00153     }
00154     else
00155     {
00156         $tpl->setVariable("RELOAD","<script language=\"Javascript\">\ntop.location.href = \"./login.php?expired=true\";\n</script>\n");
00157     }
00158 }
00159 
00160 
00161 $tpl->setVariable("TXT_OK", $lng->txt("ok"));
00162 
00163 $languages = $lng->getInstalledLanguages();
00164 
00165 foreach ($languages as $lang_key)
00166 {
00167         $tpl->setCurrentBlock("languages");
00168         $tpl->setVariable("LANG_KEY", $lang_key);
00169         $tpl->setVariable("LANG_NAME",
00170                 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00171         $tpl->setVariable("BORDER", 0);
00172         $tpl->setVariable("VSPACE", 0);
00173         $tpl->parseCurrentBlock();
00174 }
00175 
00176 // allow new registrations? 
00177 if ($ilias->getSetting("enable_registration"))
00178 {
00179         $tpl->setCurrentBlock("new_registration");
00180         $tpl->setVariable("REGISTER", $lng->txt("registration"));
00181         $tpl->setVariable("LANG_ID", $_GET["lang"]);
00182         $tpl->parseCurrentBlock();
00183 }
00184 // allow password assistance? Surpress option if Authmode is not local database
00185 if ($ilias->getSetting("password_assistance") and AUTH_DEFAULT == AUTH_LOCAL)
00186 {
00187         $tpl->setCurrentBlock("password_assistance");
00188         $tpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
00189         $tpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
00190         $tpl->setVariable("LANG_ID", $_GET["lang"]);
00191         $tpl->parseCurrentBlock();
00192 }
00193 
00194 if ($ilias->getSetting("pub_section"))
00195 {
00196         $tpl->setCurrentBlock("homelink");
00197         $tpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$_GET["lang"]);
00198         $tpl->setVariable("TXT_HOME",$lng->txt("home"));
00199         $tpl->parseCurrentBlock();
00200 }
00201 
00202 if ($ilias->ini_ilias->readVariable("clients","list"))
00203 {
00204         $tpl->setCurrentBlock("client_list");
00205         $tpl->setVariable("TXT_CLIENT_LIST",$lng->txt("to_client_list"));
00206         $tpl->parseCurrentBlock();      
00207 }
00208 
00209 $tpl->setVariable("ILIAS_RELEASE", $ilias->getSetting("ilias_version"));
00210 $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
00211 $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilias->getSetting("shib_login_button"));
00212 $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $ilias->getSetting("shib_login_instructions"));
00213 $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
00214 $tpl->setVariable("FORMACTION", "login.php?rep_ref_id=".$_GET["rep_ref_id"]);
00215 $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
00216 $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
00217 $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
00218 $tpl->setVariable("LANG_FORM_ACTION", "login.php?rep_ref_id=".$_GET["rep_ref_id"]);
00219 $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00220 $tpl->setVariable("LANG_ID", $_GET["lang"]);
00221 
00222 if ($_GET["inactive"])
00223 {
00224     $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_inactive"));
00225 }
00226 elseif ($_GET["expired"])
00227 {
00228     $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_session_expired"));
00229 }
00230 
00231 // TODO: Move this to header.inc since an expired session could not detected in login script 
00232 $status = $ilias->auth->getStatus();
00233 $auth_error = $ilias->getAuthError();
00234 
00235 if (!empty($status))
00236 {
00237         switch ($status)
00238         {
00239                 case AUTH_EXPIRED:
00240                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_session_expired"));
00241                         break;
00242                 case AUTH_IDLED:
00243                         // lang variable err_idled not existing
00244                         //$tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
00245                         break;
00246                 case AUTH_WRONG_LOGIN:
00247                 default:
00248                         $add = "";
00249                         if (is_object($auth_error))
00250                         {
00251                                 $add = "<br>".$auth_error->getMessage();
00252                         }
00253                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_wrong_login").$add);                     
00254                         break;
00255         }
00256 }
00257 
00258 
00259 if($_GET['time_limit'])
00260 {
00261         $tpl->setVariable("TXT_MSG_LOGIN_FAILED",$lng->txt('time_limit_reached'));
00262 }
00263 
00264 // output wrong IP message
00265 if($_GET['wrong_ip'])
00266 {
00267         $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt('wrong_ip_detected')." (".$_SERVER["REMOTE_ADDR"].")");
00268 }
00269 
00270 $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
00271 $tpl->setVariable("USERNAME", $_POST["username"]);
00272 $tpl->setVariable("USER_AGREEMENT", $lng->txt("usr_agreement"));
00273 
00274 // browser does not accept cookies
00275 if ($_GET['cookies'] == 'nocookies')
00276 {
00277         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_no_cookies"));
00278         $tpl->setVariable("COOKIES_HOWTO", $lng->txt("cookies_howto"));
00279 }
00280 
00281 $tpl->show(false);
00282 ?>

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