ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilStartUpGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35 
39  function ilStartUpGUI()
40  {
41  global $ilCtrl;
42 
43  $this->ctrl =& $ilCtrl;
44 
45  $ilCtrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
46  }
47 
51  function &executeCommand()
52  {
53  $cmd = $this->ctrl->getCmd("processIndexPHP");
54  $next_class = $this->ctrl->getNextClass($this);
55 
56  switch($next_class)
57  {
58  case "ilregistrationgui":
59  require_once("Services/Registration/classes/class.ilRegistrationGUI.php");
60  return $this->ctrl->forwardCommand(new ilRegistrationGUI());
61  break;
62 
63  case "ilpasswordassistancegui":
64  require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
65  return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
66  break;
67 
68  default:
69  return $this->$cmd();
70  break;
71  }
72  }
73 
77  function jumpToRegistration()
78  {
79  $this->ctrl->setCmdClass("ilregistrationgui");
80  $this->ctrl->setCmd("");
81  $this->executeCommand();
82  }
83 
88  {
89  $this->ctrl->setCmdClass("ilpasswordassistancegui");
90  $this->ctrl->setCmd("");
91  $this->executeCommand();
92  }
93 
97  function showLogin()
98  {
99  global $ilSetting, $ilAuth, $ilUser, $tpl, $ilIliasIniFile, $ilias;
100 
101  // if authentication of soap user failed, but email address is
102  // known, show users and ask for password
103  $status = $ilAuth->getStatus();
104  if ($status == "")
105  {
106  $status = $_GET["auth_stat"];
107  }
108  if ($status == AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL)
109  {
110  $this->showUserMappingSelection();
111  return;
112  }
113 
114  // login language selection is post type
115  if ($_POST["lang"] != "")
116  {
117  $_GET["lang"] = ilUtil::stripSlashes($_POST["lang"]);
118  }
119 
120  // check for session cookies enabled
121  if (!isset($_COOKIE['iltest']))
122  {
123  if (empty($_GET['cookies']))
124  {
125  setcookie("iltest","cookie");
126  //header('Location: '.$_SERVER['PHP_SELF']."?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".$_GET['client_id']."&lang=".$_GET['lang']);
127  header("Location: login.php?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".rawurlencode(CLIENT_ID)."&lang=".$_GET['lang']);
128  }
129  else
130  {
131  $_COOKIE['iltest'] = "";
132  }
133  }
134  else
135  {
136  unset($_GET['cookies']);
137  }
138 
139  // check correct setup
140  if (!$ilSetting->get("setup_ok"))
141  {
142  die("Setup is not completed. Please run setup routine again. (Login)");
143  }
144 
145  if ($ilSetting->get("shib_active") && $ilSetting->get("shib_hos_type"))
146  {
147  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
148  // Check if we user selects Home Organization
149  $WAYF = new ShibWAYF();
150  }
151 
152  if (isset($WAYF) && $WAYF->isSelection())
153  {
154  if ($WAYF->isValidSelection())
155  {
156  // Set cookie
157  $WAYF->setSAMLCookie();
158 
159  // Redirect
160  $WAYF->redirect();
161  }
162  }
163  elseif ($ilAuth->getAuth())
164  {
165  // Or we do authentication here
166  // To do: check whether some $ilInit method could be used here.
167 
168  if(!$ilUser->checkTimeLimit())
169  {
170  $ilAuth->logout();
171  session_destroy();
172 
173  // to do: get rid of this
174  ilUtil::redirect('login.php?time_limit=true');
175  }
176 
177  include_once './Services/Tracking/classes/class.ilOnlineTracking.php';
178  ilOnlineTracking::_addUser($ilUser->getId());
179 
180  // handle chat kicking
181  if ($ilSetting->get("chat_active"))
182  {
183  include_once "./Modules/Chat/classes/class.ilChatServerCommunicator.php";
184  include_once "./Modules/Chat/classes/class.ilChatRoom.php";
185 
187  ilChatRoom::_unkick($ilUser->getId());
188  }
189 
190  // update last forum visit
191  include_once './Modules/Forum/classes/class.ilObjForum.php';
192  ilObjForum::_updateOldAccess($ilUser->getId());
193 
194  if ($_GET["rep_ref_id"] != "")
195  {
196  $_GET["ref_id"] = $_GET["rep_ref_id"];
197  }
198  $this->processStartingPage();
199  exit;
200  }
201 
202  // Instantiate login template
203  // Use Shibboleth-only authentication if auth_mode is set to Shibboleth
204  $tpl->addBlockFile("CONTENT", "content", "tpl.login.html");
205 
206  //language handling
207  if ($_GET["lang"] == "")
208  {
209  $_GET["lang"] = $ilIliasIniFile->readVariable("language","default");
210  }
211 
212  //instantiate language
213  $lng = new ilLanguage($_GET["lang"]);
214 
215  $tpl->setVariable("PAGETITLE", $lng->txt("startpage"));
216  $tpl->setVariable("TXT_OK", $lng->txt("ok"));
217 
218  $languages = $lng->getInstalledLanguages();
219 
220  foreach ($languages as $lang_key)
221  {
222  $tpl->setCurrentBlock("languages");
223  $tpl->setVariable("LANG_KEY", $lang_key);
224  $tpl->setVariable("LANG_NAME",
225  ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
226  $tpl->setVariable("BORDER", 0);
227  $tpl->setVariable("VSPACE", 0);
228  $tpl->parseCurrentBlock();
229  }
230 
231  // allow new registrations?
232  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
234  {
235  $tpl->setCurrentBlock("new_registration");
236  $tpl->setVariable("REGISTER", $lng->txt("registration"));
237  $tpl->setVariable("CMD_REGISTER",
238  $this->ctrl->getLinkTargetByClass("ilregistrationgui", ""));
239  $tpl->parseCurrentBlock();
240  }
241  // allow password assistance? Surpress option if Authmode is not local database
242  if ($ilSetting->get("password_assistance"))
243  {
244  $tpl->setCurrentBlock("password_assistance");
245  $tpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
246  $tpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
247  $tpl->setVariable("CMD_FORGOT_PASSWORD",
248  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
249  $tpl->setVariable("CMD_FORGOT_USERNAME",
250  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
251  $tpl->setVariable("LANG_ID", $_GET["lang"]);
252  $tpl->parseCurrentBlock();
253  }
254 
255  if ($ilSetting->get("pub_section"))
256  {
257  $tpl->setCurrentBlock("homelink");
258  $tpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$_GET["lang"]);
259  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
260  $tpl->parseCurrentBlock();
261  }
262 
263  if ($ilIliasIniFile->readVariable("clients","list"))
264  {
265  $tpl->setCurrentBlock("client_list");
266  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
267  $tpl->setVariable("CMD_CLIENT_LIST",
268  $this->ctrl->getLinkTarget($this, "showClientList"));
269  $tpl->parseCurrentBlock();
270  }
271 
272  // shibboleth login link
273  if ($ilSetting->get("shib_active"))
274  {
275  if($ilSetting->get("shib_hos_type") != 'external_wayf'){
276  $tpl->setCurrentBlock("shibboleth_wayf_login");
277  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
278  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
279  $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
280  $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
281  $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
282  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $lng->txt("shib_general_wayf_login_instructions").' <a href="mailto:'.$ilias->getSetting("admin_email").'">ILIAS '. $lng->txt("administrator").'</a>.');
283  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
284  $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
285  $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
286  $tpl->setVariable("ILW_TARGET", $_GET["target"]);
287 
288  $tpl->parseCurrentBlock();
289  } else {
290  $tpl->setCurrentBlock("shibboleth_login");
291  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
292  $tpl->setVariable("IL_TARGET", $_GET["target"]);
293  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
294  $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
295  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", sprintf($lng->txt("shib_general_login_instructions"),$ilSetting->get("shib_federation_name")).' <a href="mailto:'.$ilias->getSetting("admin_email").'">ILIAS '. $lng->txt("administrator").'</a>.');
296  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
297  $tpl->parseCurrentBlock();
298  }
299  }
300 
301  // cas login link
302  if ($ilSetting->get("cas_active"))
303  {
304  $tpl->setCurrentBlock("cas_login");
305  $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
306  $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.gif"));
307  $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
308  $this->ctrl->setParameter($this, "forceCASLogin", "1");
309  $tpl->setVariable("TARGET_CAS_LOGIN",
310  $this->ctrl->getLinkTarget($this, "showLogin"));
311  $this->ctrl->setParameter($this, "forceCASLogin", "");
312  $tpl->parseCurrentBlock();
313  }
314 
315  // Show selection of auth modes
316  include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
318  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
319  {
320  foreach(ilAuthUtils::_getMultipleAuthModeOptions($lng) as $key => $option)
321  {
322  $tpl->setCurrentBlock('auth_mode_row');
323  $tpl->setVariable('VAL_AUTH_MODE',$key);
324  $tpl->setVariable('AUTH_CHECKED',isset($option['checked']) ? 'checked=checked' : '');
325  $tpl->setVariable('TXT_AUTH_MODE',$option['txt']);
326  $tpl->parseCurrentBlock();
327  }
328 
329  $tpl->setCurrentBlock('auth_selection');
330  $tpl->setVariable('TXT_AUTH_MODE',$lng->txt('auth_selection'));
331  $tpl->parseCurrentBlock();
332  }
333  // login via ILIAS (this also includes radius and ldap)
334  // If local authentication is enabled for shibboleth users, we
335  // display the login form for ILIAS here.
336  if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
337  $ilSetting->get("shib_auth_allow_local")) &&
338  $ilSetting->get("auth_mode") != AUTH_CAS)
339  {
340  $loginSettings = new ilSetting("login_settings");
341  if ($_GET["lang"] == false)
342  {
343  $information = $loginSettings->get("login_message_".$lng->getDefaultLanguage());
344  }
345  else
346  {
347  $information = $loginSettings->get("login_message_".$_GET["lang"]);
348  }
349 
350  if(strlen(trim($information)))
351  {
352  $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
353  }
354  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
355  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
356  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
357  $tpl->setVariable("USERNAME", ilUtil::prepareFormOutput($_POST["username"], true));
358  $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
359  $tpl->parseCurrentBlock();
360  }
361 
362  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
363 
364  $this->ctrl->setTargetScript("login.php");
365  $tpl->setVariable("FORMACTION",
366  $this->ctrl->getFormAction($this));
367 //echo "-".htmlentities($this->ctrl->getFormAction($this, "showLogin"))."-";
368  $tpl->setVariable("LANG_FORM_ACTION",
369  $this->ctrl->getFormAction($this));
370  $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
371  $tpl->setVariable("LANG_ID", $_GET["lang"]);
372 
373  if($_GET['inactive'])
374  {
375  $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt('err_inactive'));
376  }
377  else if($_GET['expired'])
378  {
379  $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt('err_session_expired'));
380  }
381  else if($_GET['login_to_purchase_object'])
382  {
383  $lng->loadLanguageModule('payment');
384  $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt('payment_login_to_buy_object'));
385  }
386 
387  // TODO: Move this to header.inc since an expired session could not detected in login script
388  $status = $ilAuth->getStatus();
389 
390 
391  if ($status == "")
392  {
393  $status = $_GET["auth_stat"];
394  }
395  $auth_error = $ilias->getAuthError();
396 
397  if (!empty($status))
398  {
399  switch ($status)
400  {
401  case AUTH_EXPIRED:
402  $tpl->setVariable('TXT_MSG_LOGIN_FAILED', $lng->txt("err_session_expired"));
403  break;
404  case AUTH_IDLED:
405  // lang variable err_idled not existing
406  //$tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
407  break;
408 
410  $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
411  $lng->txt("err_auth_cas_no_ilias_user"));
412  break;
413 
415  $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
416  $lng->txt("err_auth_soap_no_ilias_user"));
417  break;
418 
420  $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
421  $lng->txt('err_auth_ldap_no_ilias_user'));
422  break;
423 
425  $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
426  $lng->txt('err_auth_radius_no_ilias_user'));
427  break;
428 
429  case AUTH_MODE_INACTIVE:
430  $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
431  $lng->txt('err_auth_mode_inactive'));
432  break;
433 
434 
435  case AUTH_WRONG_LOGIN:
436  default:
437  $add = "";
438  if (is_object($auth_error))
439  {
440  $add = "<br>".$auth_error->getMessage();
441  }
442  $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_wrong_login").$add);
443  break;
444  }
445  }
446 
447 
448  if ($_GET['time_limit'])
449  {
450  $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt('time_limit_reached'));
451  }
452 
453  // output wrong IP message
454  if($_GET['wrong_ip'])
455  {
456  $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt('wrong_ip_detected')." (".$_SERVER["REMOTE_ADDR"].")");
457  }
458 
459  $this->ctrl->setTargetScript("ilias.php");
460  $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
461  $tpl->setVariable("USER_AGREEMENT", $lng->txt("usr_agreement"));
462  $tpl->setVariable("LINK_USER_AGREEMENT",
463  $this->ctrl->getLinkTarget($this, "showUserAgreement"));
464 
465  // browser does not accept cookies
466  if ($_GET['cookies'] == 'nocookies')
467  {
468  $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_no_cookies"));
469  $tpl->setVariable("COOKIES_HOWTO", $lng->txt("cookies_howto"));
470  $tpl->setVariable("LINK_NO_COOKIES",
471  $this->ctrl->getLinkTarget($this, "showNoCookiesScreen"));
472  }
473 
474  $tpl->show("DEFAULT", false);
475  }
476 
484  public function showAccountMigration($a_message = '')
485  {
486  global $tpl,$lng;
487 
488  $lng->loadLanguageModule('auth');
489  $tpl->addBlockFile("CONTENT", "content", "tpl.login_account_migration.html");
490  $tpl->addJavaScript('./Services/Authentication/js/account_migration.js');
491 
492  if(strlen($a_message))
493  {
494  ilUtil::sendInfo($a_message);
495  }
496  $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this,'migrateAccount'));
497  $tpl->setVariable('TXT_ACCOUNT_MIGRATION',$lng->txt('auth_account_migration'));
498  $tpl->setVariable('INFO_MIGRATE',$lng->txt('auth_info_migrate'));
499  $tpl->setVariable('INFO_ADD',$lng->txt('auth_info_add'));
500 
501  $tpl->setVariable('MIG_USER',$_POST['username']);
502  $tpl->setVariable('TXT_USER',$lng->txt('login'));
503  $tpl->setVariable('TXT_PASS',$lng->txt('password'));
504 
505  $tpl->setVariable('TXT_SUBMIT',$lng->txt('save'));
506  $tpl->setVariable('TXT_CANCEL',$lng->txt('cancel'));
507 
508  $tpl->show('DEFAULT');
509  }
510 
517  public function migrateAccount()
518  {
519  global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
520 
521  $lng->loadLanguageModule('auth');
522 
523  if(!isset($_POST['account_migration']))
524  {
525  $this->showAccountMigration($lng->txt('err_choose_migration_type'));
526  return false;
527  }
528 
529  if($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
530  {
531  $this->showAccountMigration($lng->txt('err_wrong_login'));
532  return false;
533  }
534 
535  if($_POST['account_migration'] == 1)
536  {
537  if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
538  {
539  $this->showAccountMigration($lng->txt('err_wrong_login'));
540  return false;
541  }
542  $_POST['username'] = $_POST['mig_username'];
543  $_POST['password'] = $_POST['mig_password'];
544  $auth_params = array(
545  'dsn' => IL_DSN,
546  'table' => $ilClientIniFile->readVariable("auth", "table"),
547  'usernamecol' => $ilClientIniFile->readVariable("auth", "usercol"),
548  'passwordcol' => $ilClientIniFile->readVariable("auth", "passcol")
549  );
550  $ilAuth = new Auth("DB", $auth_params,"",false);
551  $ilAuth->start();
552  if(!$ilAuth->getAuth())
553  {
554  $ilAuth->logout();
555  $this->showAccountMigration($lng->txt('err_wrong_login'));
556  return false;
557  }
558 
559  $user = new ilObjUser($user_id);
560  $user->setAuthMode($_SESSION['tmp_auth_mode']);
561  $user->setExternalAccount($_SESSION['tmp_external_account']);
562  $user->update();
563 
564  // Assign to default role
565  if(is_array($_SESSION['tmp_roles']))
566  {
567  foreach($_SESSION['tmp_roles'] as $role)
568  {
569  $rbacadmin->assignUser((int) $role,$user->getId());
570  }
571  }
572 
573  // Log migration
574  $ilLog->write(__METHOD__.': Migrated '.$_SESSION['tmp_external_account'].' to ILIAS account '.$user->getLogin().'.');
575  }
576  elseif($_POST['account_migration'] == 2)
577  {
578  switch($_SESSION['tmp_auth_mode'])
579  {
580  case 'ldap':
581  $_POST['username'] = $_SESSION['tmp_external_account'];
582  $_POST['password'] = $_SESSION['tmp_pass'];
583 
584  include_once('Services/LDAP/classes/class.ilAuthLDAP.php');
585  $ilAuth = new ilAuthLDAP();
586  $ilAuth->forceCreation(true);
587  $ilAuth->setIdle($ilClientIniFile->readVariable("session","expire"), false);
588  $ilAuth->setExpire(0);
589  $ilAuth->start();
590  break;
591 
592  case 'radius':
593  $_POST['username'] = $_SESSION['tmp_external_account'];
594  $_POST['password'] = $_SESSION['tmp_pass'];
595 
596  include_once('Services/Radius/classes/class.ilAuthRadius.php');
597  $ilAuth = new ilAuthRadius();
598  $ilAuth->forceCreation(true);
599  $ilAuth->setIdle($ilClientIniFile->readVariable("session","expire"), false);
600  $ilAuth->setExpire(0);
601  $ilAuth->start();
602  break;
603  }
604  }
605  // show personal desktop
606  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
607  }
608 
612  function showLogout()
613  {
615 
616  // LOGOUT CHAT USER
617  if($ilSetting->get("chat_active"))
618  {
619  include_once "./Modules/Chat/classes/class.ilChatServerCommunicator.php";
621  }
622 
623  $ilAuth->logout();
624  session_destroy();
625 
626  // reset cookie
627  $client_id = $_COOKIE["ilClientId"];
628  setcookie("ilClientId","");
629  $_COOKIE["ilClientId"] = "";
630 
631  //instantiate logout template
632  $tpl->addBlockFile("CONTENT", "content", "tpl.logout.html");
633 
634  if ($ilSetting->get("pub_section"))
635  {
636  $tpl->setCurrentBlock("homelink");
637  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$_GET['lang']);
638  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
639  $tpl->parseCurrentBlock();
640  }
641 
642  if ($ilIliasIniFile->readVariable("clients","list"))
643  {
644  $tpl->setCurrentBlock("client_list");
645  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
646  $tpl->setVariable("CMD_CLIENT_LIST",
647  $this->ctrl->getLinkTarget($this, "showClientList"));
648  $tpl->parseCurrentBlock();
649  }
650 
651  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
652  $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
653  $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
654  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$_GET['lang']);
655 
656  $tpl->show();
657  }
658 
664  {
665  global $ilAuth, $tpl, $lng;
666 
667  $valid = $ilAuth->getValidationData();
668 
669  $tpl->addBlockFile("CONTENT", "content", "tpl.user_mapping_selection.html");
670  $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
671 
672 
673  if ($ilAuth->sub_status == AUTH_WRONG_LOGIN)
674  {
675  $tpl->setCurrentBlock("msg");
676  $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt("err_wrong_login"));
677  $tpl->parseCurrentBlock();
678  }
679 
680  include_once('./Services/User/classes/class.ilObjUser.php');
681  if (count($email_user) == 1)
682  {
683  //$user = new ilObjUser(key($email_user));
684  $tpl->setCurrentBlock("one_user");
685  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
686  $tpl->setVariable("VAL_USERNAME", current($email_user));
687  $tpl->setVariable("USER_ID", key($email_user));
688  $tpl->parseCurrentBlock();
689  }
690  else
691  {
692  foreach($email_user as $key => $login)
693  {
694  $tpl->setCurrentBlock("user");
695  $tpl->setVariable("USR_ID", $key);
696  $tpl->setVariable("VAL_USER", $login);
697  $tpl->parseCurrentBlock();
698  }
699  $tpl->setCurrentBlock("multpiple_user");
700  $tpl->parseCurrentBlock();
701  }
702 
703  $tpl->setCurrentBlock("content");
704  $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
705  $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
706  $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
707  $tpl->setVariable("FORMACTION",
708  $this->ctrl->getFormAction($this));
709  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
710  if (count($email_user) == 1)
711  {
712  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
713  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
714  }
715  else
716  {
717  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
718  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
719  }
720  $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
721  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
722  $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
723  $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
724 
725  $tpl->show();
726  }
727 
731  function showClientList()
732  {
733  global $tpl, $ilIliasIniFile, $ilCtrl;
734 //echo "1";
735  if (!$ilIliasIniFile->readVariable("clients","list"))
736  {
737  $this->processIndexPHP();
738  return;
739  }
740 //echo "2";
741  $tpl = new ilTemplate("tpl.main.html", true, true);
742 
743  // to do: get standard style
744  $tpl->setVariable("PAGETITLE","Client List");
745  $tpl->setVariable("LOCATION_STYLESHEET","./templates/default/delos.css");
746 
747  // load client list template
748  $tpl->addBlockfile("CONTENT", "content", "tpl.client_list.html");
749 
750  // load template for table
751  $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
752 
753  // load template for table content data
754  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
755 
756  // load table content data
757  require_once("setup/classes/class.ilClientList.php");
758  require_once("setup/classes/class.ilClient.php");
759  require_once("setup/classes/class.ilDBConnections.php");
760  require_once("./Services/Table/classes/class.ilTableGUI.php");
761  $this->db_connections = new ilDBConnections();
762  $clientlist = new ilClientList($this->db_connections);
763  $list = $clientlist->getClients();
764 
765  if (count($list) == 0)
766  {
767  header("Location: ./setup/setup.php");
768  exit();
769  }
770 
771  foreach ($list as $key => $client)
772  {
773  if ($client->checkDatabaseExists() and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
774  {
775  $this->ctrl->setParameter($this, "client_id", $key);
776  //$data[] = array(
777  // $client->getName(),
778  // "<a href=\"".$ilCtrl->getLinkTarget($this, "processIndexPHP")."\">Start page</a>",
779  // "<a href=\"".$ilCtrl->getLinkTarget($this, "showLogin")."\">Login page</a>"
780  // );
781  $data[] = array(
782  $client->getName(),
783  "<a href=\"".$ilCtrl->getLinkTarget($this, "processIndexPHP")."\">Start page</a>",
784  "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">Login page</a>"
785  );
786  }
787  }
788  $this->ctrl->setParameter($this, "client_id", "");
789 
790  // create table
791  $tbl = new ilTableGUI();
792 
793  // title & header columns
794  $tbl->setTitle("Available Clients");
795  $tbl->setHeaderNames(array("Installation Name","Public Access","Login"));
796  $tbl->setHeaderVars(array("name","index","login"));
797  $tbl->setColumnWidth(array("50%","25%","25%"));
798 
799  // control
800  $tbl->setOrderColumn($_GET["sort_by"],"name");
801  $tbl->setOrderDirection($_GET["sort_order"]);
802  $tbl->setLimit($_GET["limit"]);
803  $tbl->setOffset($_GET["offset"]);
804 
805  // content
806  $tbl->setData($data);
807 
808  // footer
809  $tbl->setFooter("tblfooter");
810 
811  // styles
812  $tbl->setStyle("table","std");
813 
814  $tbl->disable("icon");
815  $tbl->disable("numinfo");
816 
817  // render table
818  $tbl->render();
819  $tpl->show();
820  }
821 
828  {
829  global $tpl;
830 
831  $str = "<p style=\"margin:15px;\">
832  You need to enable Session Cookies in your Browser to use ILIAS.
833  <br/>
834  <br/><b>Firefox</b>
835  <br/>Tools -> Options -> Privacy -> Cookies
836  <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
837  <br/>cookies' auf 'until I close Firefox'
838  <br/>
839  <br/><b>Mozilla/Netscape</b>
840  <br/>Edit -> Preferences -> Privacy&Security -> Cookies
841  <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
842  <br/>session only'.
843  <br/>
844  <br/><b>Internet Explorer</b>
845  <br/>Tools -> Internet Options -> Privacy -> Advanced
846  <br/>- Check 'Override automatic cookie handling'
847  <br/>- Check 'Always allow session cookies'
848  </p>";
849  $tpl->setVariable("CONTENT", $str);
850  $tpl->show();
851  }
852 
856  function getAcceptance()
857  {
858  $this->showUserAgreement();
859  }
860 
864  function showUserAgreement()
865  {
866  global $lng, $tpl, $ilUser;
867 
868  require_once "./Services/User/classes/class.ilUserAgreement.php";
869 
870  $tpl->addBlockFile("CONTENT", "content", "tpl.view_usr_agreement.html");
871  $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
872 
874  // display infopanel if something happened
876 
877  $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
878  $tpl->setVariable("TXT_OK", $lng->txt("ok"));
879 
880  // language selection
881  $languages = $lng->getInstalledLanguages();
882 
883  $count = (int) round(count($languages) / 2);
884  $num = 1;
885 
886  foreach ($languages as $lang_key)
887  {
888  $tpl->setCurrentBlock("languages");
889  $tpl->setVariable("LANG_VAL_CMD", $this->ctrl->getCmd());
890  $tpl->setVariable("AGR_LANG_ACTION",
891  $this->ctrl->getFormAction($this));
892  $tpl->setVariable("LANG_NAME",
893  ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
894  $tpl->setVariable("LANG_ICON", $lang_key);
895  $tpl->setVariable("LANG_KEY", $lang_key);
896  $tpl->setVariable("BORDER", 0);
897  $tpl->setVariable("VSPACE", 0);
898  $tpl->parseCurrentBlock();
899 
900  $num++;
901  }
902  $tpl->setCurrentBlock("content");
903 
904  // display tabs
905  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("usr_agreement"));
906  $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - ".$lng->txt("usr_agreement"));
907  $tpl->setVariable("TXT_USR_AGREEMENT", ilUserAgreement::_getText());
908 
909  if ($this->ctrl->getCmd() == "getAcceptance")
910  {
911  if ($_POST["status"]=="accepted")
912  {
913  $ilUser->writeAccepted();
914  ilUtil::redirect("index.php?target=".$_GET["target"]."&client_id=".CLIENT_ID);
915  }
916  $tpl->setVariable("VAL_CMD", "getAcceptance");
917  $tpl->setVariable("AGR_LANG_ACTION",
918  $this->ctrl->getFormAction($this));
919  $tpl->setCurrentBlock("get_acceptance");
920  $tpl->setVariable("FORM_ACTION",
921  $this->ctrl->getFormAction($this));
922  $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
923  $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement"));
924  $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
925  $tpl->parseCurrentBlock();
926  }
927  else
928  {
929  $tpl->setCurrentBlock("back");
930  $tpl->setVariable("BACK", $lng->txt("back"));
931  $tpl->setVariable("LINK_BACK",
932  $this->ctrl->getLinkTargetByClass("ilstartupgui", "showLogin"));
933  $tpl->parseCurrentBlock();
934  }
935 
936  $tpl->show();
937 
938 
939  }
940 
944  function processIndexPHP()
945  {
947 
948  // display client selection list if enabled
949  if (!isset($_GET["client_id"]) &&
950  $_GET["cmd"] == "" &&
951  $ilIliasIniFile->readVariable("clients","list"))
952  {
953  $this->showClientList();
954  //include_once "./include/inc.client_list.php";
955  exit();
956  }
957 
958  /*
959  if ($_GET["cmd"] == "login")
960  {
961  $rep_ref_id = $_SESSION["il_rep_ref_id"];
962 
963  $ilAuth->logout();
964  session_destroy();
965 
966  // reset cookie
967  $client_id = $_COOKIE["ilClientId"];
968  setcookie("ilClientId","");
969  $_COOKIE["ilClientId"] = "";
970 
971  $_GET["client_id"] = $client_id;
972  $_GET["rep_ref_id"] = $rep_ref_id;
973 
974 
975  ilUtil::redirect("login.php?client_id=".$client_id."&lang=".$_GET['lang'].
976  "&rep_ref_id=".$rep_ref_id);
977  }*/
978 
979 
980  // if no start page was given, ILIAS defaults to the standard login page
981  if ($start == "")
982  {
983  $start = "login.php";
984  }
985 
986 
987  //
988  // index.php is called and public section is enabled
989  //
990  // && $ilAuth->status == -101 is important for soap auth (public section on + user mapping, alex)
991  // $ilAuth->status -1 is given, if session ends (if public section -> jump to public section)
992  if ($ilSetting->get("pub_section") && $_POST["sendLogin"] != "1"
993  && ($ilAuth->getStatus() != -101 && $_GET["soap_pw"] == ""))
994  {
995  //
996  // TO DO: THE FOLLOWING BLOCK IS COPY&PASTED FROM HEADER.INC
997 
998  $_POST["username"] = "anonymous";
999  $_POST["password"] = "anonymous";
1000  $ilAuth->start();
1001  if (ANONYMOUS_USER_ID == "")
1002  {
1003  die ("Public Section enabled, but no Anonymous user found.");
1004  }
1005  if (!$ilAuth->getAuth())
1006  {
1007  die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
1008  }
1009 
1010  // get user id
1011  $ilInit->initUserAccount();
1012  $this->processStartingPage();
1013  exit;
1014  }
1015  else
1016  {
1017  // index.php is called and public section is disabled
1018  $this->showLogin();
1019  }
1020  }
1021 
1022 
1029  {
1030  global $ilBench, $ilCtrl, $ilAccess, $lng;
1031 //echo "here";
1032  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID || !empty($_GET["ref_id"]))
1033  {
1034 //echo "A";
1035  // if anonymous and a target given...
1036  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID && $_GET["target"] != "")
1037  {
1038  // target is accessible -> goto target
1039  if ($this->_checkGoto($_GET["target"]))
1040  {
1041 //echo "B";
1042  ilUtil::redirect("./goto.php?target=".$_GET["target"]);
1043  }
1044  else // target is not accessible -> login
1045  {
1046 //echo "C";
1047  $this->showLogin();
1048  }
1049  }
1050 
1051  // just go to public section
1052  if (empty($_GET["ref_id"]))
1053  {
1054  $_GET["ref_id"] = ROOT_FOLDER_ID;
1055  }
1056  $ilCtrl->initBaseClass("");
1057  $ilCtrl->setCmd("frameset");
1058  $start_script = "repository.php";
1059  include($start_script);
1060  return true;
1061  }
1062  else
1063  {
1064  if (!$this->_checkGoto($_GET["target"]))
1065  {
1066  // message if target given but not accessible
1067  if ($_GET["target"] != "")
1068  {
1069  $tarr = explode("_", $_GET["target"]);
1070  if ($tarr[0] != "pg" && $tarr[0] != "st" && $tarr[1] > 0)
1071  {
1072  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
1074  }
1075  }
1076 
1077  // show personal desktop
1078  #$ilCtrl->initBaseClass("ilPersonalDesktopGUI");
1079  #$start_script = "ilias.php";
1080  // Redirect here to switch back to http if desired
1081  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
1082  }
1083  else
1084  {
1085 //echo "3";
1086  ilUtil::redirect("./goto.php?target=".$_GET["target"]);
1087  }
1088  }
1089 
1090  include($start_script);
1091  }
1092 
1093  function _checkGoto($a_target)
1094  {
1095  global $objDefinition;
1096 
1097  if ($a_target == "")
1098  {
1099  return false;
1100  }
1101 
1102  $t_arr = explode("_", $_GET["target"]);
1103  $type = $t_arr[0];
1104 
1105  if ($type == "git")
1106  {
1107  $type = "glo";
1108  }
1109 
1110  if ($type == "pg" | $type == "st")
1111  {
1112  $type = "lm";
1113  }
1114 
1115  $class = $objDefinition->getClassName($type);
1116  if ($class == "")
1117  {
1118  return false;
1119  }
1120  $location = $objDefinition->getLocation($type);
1121  $full_class = "ilObj".$class."Access";
1122  include_once($location."/class.".$full_class.".php");
1123 
1124  return call_user_func(array($full_class, "_checkGoto"),
1125  $a_target);
1126  }
1127 
1128 }
1129 ?>