ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilStartUpGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
14 {
15 
19  function ilStartUpGUI()
20  {
21  global $ilCtrl;
22 
23  $this->ctrl =& $ilCtrl;
24 
25  $ilCtrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
26  }
27 
31  function &executeCommand()
32  {
33  $cmd = $this->ctrl->getCmd("processIndexPHP",array('processIndexPHP','showLogin'));
34  $GLOBALS['ilLog']->write(__METHOD__.' cmd = '.$cmd);
35  $next_class = $this->ctrl->getNextClass($this);
36 
37  switch($next_class)
38  {
39  case 'ilpageobjectgui':
40  break;
41 
42 
43  case "ilaccountregistrationgui":
44  require_once("Services/Registration/classes/class.ilAccountRegistrationGUI.php");
45  return $this->ctrl->forwardCommand(new ilAccountRegistrationGUI());
46  break;
47 
48  case "ilpasswordassistancegui":
49  require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
50  return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
51  break;
52 
53  default:
54  $r = $this->$cmd();
55  return $r;
56  break;
57  }
58  }
59 
63  function jumpToRegistration()
64  {
65  $this->ctrl->setCmdClass("ilaccountregistrationgui");
66  $this->ctrl->setCmd("");
67  $this->executeCommand();
68  }
69 
74  {
75  $this->ctrl->setCmdClass("ilpasswordassistancegui");
76  $this->ctrl->setCmd("");
77  $this->executeCommand();
78  }
79 
85  function showLogin()
86  {
87  global $ilSetting, $ilAuth, $ilUser, $tpl, $ilIliasIniFile, $ilias, $lng;
88 
89  // if authentication of soap user failed, but email address is
90  // known, show users and ask for password
91  $status = $ilAuth->getStatus();
92  if ($status == "" && isset($_GET["auth_stat"]))
93  {
94  $status = $_GET["auth_stat"];
95  }
96  if ($status == AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL)
97  {
98  $this->showUserMappingSelection();
99  return;
100  }
101 
102  // check for session cookies enabled
103  if (!isset($_COOKIE['iltest']))
104  {
105  if (empty($_GET['cookies']))
106  {
107  $additional_params = '';
108  if((int)$_GET['forceShoppingCartRedirect'])# && (int)$_SESSION['price_id'] && (int)$_SESSION['pobject_id'])
109  {
110  $additional_params .= '&login_to_purchase_object=1&forceShoppingCartRedirect=1';
111  }
112 
113  ilUtil::setCookie("iltest","cookie",false);
114  header("Location: login.php?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".
115  rawurlencode(CLIENT_ID)."&lang=".$lng->getLangKey().$additional_params);
116  }
117  else
118  {
119  $_COOKIE['iltest'] = "";
120  }
121  }
122  else
123  {
124  unset($_GET['cookies']);
125  }
126 
127  // check correct setup
128  if (!$ilSetting->get("setup_ok"))
129  {
130  die("Setup is not completed. Please run setup routine again. (Login)");
131  }
132 
133  if ($ilSetting->get("shib_active") && $ilSetting->get("shib_hos_type"))
134  {
135  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
136  // Check if we user selects Home Organization
137  $WAYF = new ShibWAYF();
138  }
139 
140  if (isset($WAYF) && $WAYF->isSelection())
141  {
142  if ($WAYF->isValidSelection())
143  {
144  // Set cookie
145  $WAYF->setSAMLCookie();
146 
147  // Redirect
148  $WAYF->redirect();
149  }
150  }
151  elseif ($ilAuth->getAuth())
152  {
153  // Or we do authentication here
154  // To do: check whether some $ilInit method could be used here.
155 
156  if(!$ilUser->checkTimeLimit())
157  {
158  $ilAuth->logout();
159 
160  if($ilSetting->get('user_reactivate_code'))
161  {
162  return $this->showCodeForm();
163  }
164 
165  session_destroy();
166 
167  // to do: get rid of this
168  ilUtil::redirect('login.php?time_limit=true');
169  }
170 
171  include_once './Services/Tracking/classes/class.ilOnlineTracking.php';
172  ilOnlineTracking::_addUser($ilUser->getId());
173 
174  // update last forum visit
175  include_once './Modules/Forum/classes/class.ilObjForum.php';
176  ilObjForum::_updateOldAccess($ilUser->getId());
177 
178  if ($_GET["rep_ref_id"] != "")
179  {
180  $_GET["ref_id"] = $_GET["rep_ref_id"];
181  }
182  $this->processStartingPage();
183  exit;
184  }
185 
186  //
187  // Start new implementation here
188  //
189  //
190  //
191 
192  // Instantiate login template
193  // Use Shibboleth-only authentication if auth_mode is set to Shibboleth
194  $tpl->addBlockFile("CONTENT", "content", "tpl.login.html","Services/Init");
195 
196  #$this->ctrl->setTargetScript("login.php");
197  if(isset($_GET['forceShoppingCartRedirect']) && (int)$_GET['forceShoppingCartRedirect'] == 1)
198  {
199  $this->ctrl->setParameter($this, 'forceShoppingCartRedirect', 1);
200  $_SESSION['forceShoppingCartRedirect'] = 1;
201  }
202 
203  $page_editor_html = $this->getLoginPageEditorHTML();
204  $page_editor_html = $this->showLoginInformation($page_editor_html);
205  $page_editor_html = $this->showLoginForm($page_editor_html);
206  $page_editor_html = $this->showCASLoginForm($page_editor_html);
207  $page_editor_html = $this->showShibbolethLoginForm($page_editor_html);
208  $page_editor_html = $this->showOpenIdLoginForm($page_editor_html);
209  $page_editor_html = $this->showLanguageSelection($page_editor_html);
210  $page_editor_html = $this->showRegistrationLinks($page_editor_html);
211  $page_editor_html = $this->showUserAgreementLink($page_editor_html);
212 
213  $page_editor_html = $this->purgePlaceholders($page_editor_html);
214 
215  // not controlled by login page editor
216 
217  $tpl->setVariable("PAGETITLE", $lng->txt("startpage"));
218  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
219 
220  if (isset($_GET['inactive']) && $_GET['inactive'])
221  {
222  $this->showFailure($lng->txt("err_inactive"));
223  }
224  else if (isset($_GET['expired']) && $_GET['expired'])
225  {
226  $this->showFailure($lng->txt("err_session_expired"));
227  }
228  else if (isset($_GET['login_to_purchase_object']) && $_GET['login_to_purchase_object'])
229  {
230  $lng->loadLanguageModule('payment');
231  $this->showFailure($lng->txt("payment_login_to_buy_object"));
232  $_SESSION['forceShoppingCartRedirect'] = '1';
233  }
234  else if (isset($_GET['reg_confirmation_msg']) && strlen(trim($_GET['reg_confirmation_msg'])))
235  {
236  $lng->loadLanguageModule('registration');
237  if($_GET['reg_confirmation_msg'] == 'reg_account_confirmation_successful')
238  $this->showSuccess($lng->txt(trim($_GET['reg_confirmation_msg'])));
239  else
240  $this->showFailure($lng->txt(trim($_GET['reg_confirmation_msg'])));
241  }
242  elseif(isset($_GET['reached_session_limit']) && $_GET['reached_session_limit'])
243  {
244  $this->showFailure($lng->txt("reached_session_limit"));
245  }
246 
247  // TODO: Move this to header.inc since an expired session could not detected in login script
248  $status = $ilAuth->getStatus();
249 
250  if ($status == "" && isset($_GET["auth_stat"]))
251  {
252  $status = $_GET["auth_stat"];
253  }
254  $auth_error = $ilias->getAuthError();
255 
256  if (!empty($status))
257  {
258  switch ($status)
259  {
260  case AUTH_EXPIRED:
261  $this->showFailure($lng->txt("err_session_expired"));
262  break;
263  case AUTH_IDLED:
264  // lang variable err_idled not existing
265  //$tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
266  break;
267 
269  $this->showFailure($lng->txt("err_auth_cas_no_ilias_user"));
270  break;
271 
273  $this->showFailure($lng->txt("err_auth_soap_no_ilias_user"));
274  break;
275 
277  $this->showFailure($lng->txt("err_auth_ldap_no_ilias_user"));
278  break;
279 
281  $this->showFailure($lng->txt("err_auth_radius_no_ilias_user"));
282  break;
283 
284  case AUTH_MODE_INACTIVE:
285  $this->showFailure($lng->txt("err_auth_mode_inactive"));
286  break;
287 
288  case AUTH_APACHE_FAILED:
289  $this->showFailure($lng->txt("err_auth_apache_failed"));
290  break;
291 
292  case AUTH_WRONG_LOGIN:
293  default:
294  $add = "";
295  if (is_object($auth_error))
296  {
297  $add = "<br>".$auth_error->getMessage();
298  }
299  $this->showFailure($lng->txt("err_wrong_login").$add);
300  break;
301  }
302  }
303 
304 
305  if (isset($_GET['cu']) && $_GET['cu'])
306  {
307  $lng->loadLanguageModule("auth");
308  $this->showSuccess($lng->txt("auth_account_code_used"));
309  }
310 
311  if (isset($_GET['time_limit']) && $_GET['time_limit'])
312  {
313  $this->showFailure($lng->txt("time_limit_reached"));
314  }
315 
316  // output wrong IP message
317  if (isset($_GET['wrong_ip']) && $_GET['wrong_ip'])
318  {
319  $this->showFailure($lng->txt("wrong_ip_detected")." (".$_SERVER["REMOTE_ADDR"].")");
320  }
321 
322  // outout simultaneous login message
323  if (isset($_GET['simultaneous_login']) && $_GET['simultaneous_login'])
324  {
325  $this->showFailure($lng->txt("simultaneous_login_detected"));
326  }
327 
328  $this->ctrl->setTargetScript("ilias.php");
329  $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
330 
331  // browser does not accept cookies
332  if (isset($_GET['cookies']) && $_GET['cookies'] == 'nocookies')
333  {
334  $this->showFailure($lng->txt("err_no_cookies"));
335  $tpl->setVariable("COOKIES_HOWTO", $lng->txt("cookies_howto"));
336  $tpl->setVariable("LINK_NO_COOKIES",
337  $this->ctrl->getLinkTarget($this, "showNoCookiesScreen"));
338  }
339 
340 
341  if(strlen($page_editor_html))
342  {
343  $tpl->setVariable('LPE',$page_editor_html);
344  }
345 
346 
347  $tpl->show("DEFAULT", false);
348  }
349 
350  protected function showCodeForm($a_form = null)
351  {
352  global $tpl, $ilCtrl, $lng;
353 
354  $tpl->addBlockFile("CONTENT", "content", "tpl.login_reactivate_code.html","Services/Init");
355 
356  $this->showFailure($lng->txt("time_limit_reached"));
357 
358  if(!$a_form)
359  {
360  $a_form = $this->initCodeForm();
361  }
362 
363  if($_POST["username"])
364  {
365  $_SESSION["username"] = $_POST["username"];
366  }
367 
368  $tpl->setVariable("FORM", $a_form->getHTML());
369  $tpl->show("DEFAULT", false);
370  }
371 
372  protected function initCodeForm()
373  {
374  global $lng, $ilCtrl;
375 
376  $lng->loadLanguageModule("auth");
377 
378  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
379 
380  $form = new ilPropertyFormGUI();
381  $form->setFormAction($ilCtrl->getFormAction($this, 'showcodeform'));
382  $form->setTitle($lng->txt('auth_account_code_title'));
383 
384  $count = new ilTextInputGUI($lng->txt('auth_account_code'), 'code');
385  $count->setRequired(true);
386  $count->setInfo($lng->txt('auth_account_code_info'));
387  $form->addItem($count);
388 
389  $form->addCommandButton('processcode', $lng->txt('send'));
390 
391  return $form;
392  }
393 
394  protected function processCode()
395  {
396  global $lng, $ilAuth, $ilCtrl;
397 
398  $form = $this->initCodeForm();
399  if($form->checkInput())
400  {
401  $code = $form->getInput("code");
402 
403  include_once "Services/User/classes/class.ilAccountCode.php";
404  if(ilAccountCode::isUnusedCode($code))
405  {
406  $valid_until = ilAccountCode::getCodeValidUntil($code);
407 
408  if(!$user_id = ilObjUser::_lookupId($_SESSION["username"]))
409  {
410  $this->showLogin();
411  return false;
412  }
413 
414  $invalid_code = false;
415  $user = new ilObjUser($user_id);
416 
417  if($valid_until === "0")
418  {
419  $user->setTimeLimitUnlimited(true);
420  }
421  else
422  {
423  if(is_numeric($valid_until))
424  {
425  $valid_until = strtotime("+".$valid_until."days");
426  }
427  else
428  {
429  $valid_until = explode("-", $valid_until);
430  $valid_until = mktime(23, 59, 59, $valid_until[1],
431  $valid_until[2], $valid_until[0]);
432  if($valid_until < time())
433  {
434  $invalid_code = true;
435  }
436  }
437 
438  if(!$invalid_code)
439  {
440  $user->setTimeLimitUnlimited(false);
441  $user->setTimeLimitUntil($valid_until);
442  }
443  }
444 
445  if(!$invalid_code)
446  {
447  $user->setActive(true);
448  $user->update();
449 
450  ilAccountCode::useCode($code);
451 
452  $ilCtrl->setParameter($this, "cu", 1);
453  $ilCtrl->redirect($this, "showLogin");
454  }
455  }
456 
457  $lng->loadLanguageModule("user");
458  $field = $form->getItemByPostVar("code");
459  $field->setAlert($lng->txt("user_account_code_not_valid"));
460  }
461 
462  $form->setValuesByPost();
463  $this->showCodeForm($form);
464  }
465 
466 
467 
473  protected function showLoginForm($page_editor_html)
474  {
475  global $ilSetting,$lng,$tpl;
476 
477  // @todo move this to auth utils.
478  // login via ILIAS (this also includes radius and ldap)
479  // If local authentication is enabled for shibboleth users, we
480  // display the login form for ILIAS here.
481  if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
482  $ilSetting->get("shib_auth_allow_local")) &&
483  $ilSetting->get("auth_mode") != AUTH_CAS)
484  {
485  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
486  $form = new ilPropertyFormGUI();
487  $form->setTableWidth('500');
488  $form->setFormAction($this->ctrl->getFormAction($this,''));
489  $form->setName("formlogin");
490  $form->setShowTopButtons(false);
491  $form->setTitle($lng->txt("login_to_ilias"));
492 
493  // auth selection
494  include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
496  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
497  {
498  $visible_auth_methods = array();
499  $radg = new ilRadioGroupInputGUI($lng->txt("auth_selection"), "auth_mode");
500  foreach(ilAuthUtils::_getMultipleAuthModeOptions($lng) as $key => $option)
501  {
502  if(isset($option['hide_in_ui']) && $option['hide_in_ui'])
503  {
504  continue;
505  }
506 
507  $op1 = new ilRadioOption($option['txt'], $key);
508  $radg->addOption($op1);
509  if (isset($option['checked']))
510  {
511  $radg->setValue($key);
512  }
513  $visible_auth_methods[] = $op1;
514  }
515 
516  if(count($visible_auth_methods) == 1)
517  {
518  $first_auth_method = current($visible_auth_methods);
519  $hidden_auth_method = new ilHiddenInputGUI("auth_mode");
520  $hidden_auth_method->setValue($first_auth_method->getValue());
521  $form->addItem($hidden_auth_method);
522  }
523  else
524  {
525  $form->addItem($radg);
526  }
527  }
528 
529  // username
530  $ti = new ilTextInputGUI($lng->txt("username"), "username");
531  $ti->setSize(20);
532  $form->addItem($ti);
533 
534  // password
535  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
536  $pi->setRetype(false);
537  $pi->setSize(20);
538  $form->addItem($pi);
539  $form->addCommandButton("showLogin", $lng->txt("log_in"));
540  #$form->addCommandButton("butSubmit", $lng->txt("log_in"));
541 
542  return $this->substituteLoginPageElements(
543  $tpl,
544  $page_editor_html,
545  $form->getHTML(),
546  '[list-login-form]',
547  'LOGIN_FORM'
548  );
549 
550  }
551  return $page_editor_html;
552  }
553 
559  protected function showLoginInformation($page_editor_html)
560  {
561  global $lng,$tpl;
562 
563  if(strlen($page_editor_html))
564  {
565  // page editor active return
566  return $page_editor_html;
567  }
568 
569  $loginSettings = new ilSetting("login_settings");
570  $information = $loginSettings->get("login_message_".$lng->getLangKey());
571 
572  if(strlen(trim($information)))
573  {
574  $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
575  }
576  return $page_editor_html;
577  }
578 
585  protected function showCASLoginForm($page_editor_html)
586  {
587  global $ilSetting, $lng;
588 
589 
590  // cas login link
591  if ($ilSetting->get("cas_active"))
592  {
593  $tpl = new ilTemplate('tpl.login_form_cas.html', true, true, 'Services/Init');
594  $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
595  $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.gif"));
596  $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
597  $this->ctrl->setParameter($this, "forceCASLogin", "1");
598  $tpl->setVariable("TARGET_CAS_LOGIN",$this->ctrl->getLinkTarget($this, "showLogin"));
599  $this->ctrl->setParameter($this, "forceCASLogin", "");
600 
601  return $this->substituteLoginPageElements(
602  $GLOBALS['tpl'],
603  $page_editor_html,
604  $tpl->get(),
605  '[list-cas-login-form]',
606  'CAS_LOGIN_FORM'
607  );
608  }
609  return $page_editor_html;
610  }
611 
617  protected function showShibbolethLoginForm($page_editor_html)
618  {
619  global $ilSetting, $lng;
620 
621  // shibboleth login link
622  if ($ilSetting->get("shib_active"))
623  {
624  $tpl = new ilTemplate('tpl.login_form_shibboleth.html',true,true,'Services/Init');
625 
626  $tpl->setVariable('SHIB_FORMACTION',$this->ctrl->getFormAction($this));
627 
628  if($ilSetting->get("shib_hos_type") == 'external_wayf')
629  {
630  $tpl->setCurrentBlock("shibboleth_login");
631  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
632  $tpl->setVariable("IL_TARGET", $_GET["target"]);
633  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
634  $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
635  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS",
636  sprintf(
637  $lng->txt("shib_general_login_instructions"),
638  $ilSetting->get("shib_federation_name")) .
639  ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt("administrator") . '</a>.'
640  );
641  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS",$ilSetting->get("shib_login_instructions"));
642  $tpl->parseCurrentBlock();
643  }
644  elseif($ilSetting->get("shib_hos_type") == 'embedded_wayf')
645  {
646  $tpl->setCurrentBlock("cust_shibboleth_login");
647  $customInstructions = stripslashes( $ilSetting->get("shib_login_instructions"));
648  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS_B", $customInstructions);
649  $tpl->parseCurrentBlock();
650  }
651  else
652  {
653  $tpl->setCurrentBlock("shibboleth_wayf_login");
654  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
655  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
656  $tpl->setVariable(
657  "TXT_SELECT_HOME_ORGANIZATION",
658  sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
659  $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
660  $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
661  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS",
662  $lng->txt("shib_general_wayf_login_instructions").
663  ' <a href="mailto:'.$ilSetting->get("admin_email").'">ILIAS '. $lng->txt("administrator").'</a>.'
664  );
665  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
666 
667  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
668  $WAYF = new ShibWAYF();
669 
670  $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
671  $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
672  $tpl->setVariable("ILW_TARGET", $_GET["target"]);
673  $tpl->parseCurrentBlock();
674  }
675 
676  return $this->substituteLoginPageElements(
677  $GLOBALS['tpl'],
678  $page_editor_html,
679  $tpl->get(),
680  '[list-shibboleth-login-form]',
681  'SHIB_LOGIN_FORM'
682  );
683  }
684 
685  return $page_editor_html;
686  }
687 
688 
698  protected function substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
699  {
700  if(!strlen($page_editor_html))
701  {
702  $tpl->setVariable($fallback_tplvar,$element_html);
703  return $page_editor_html;
704  }
705  // Try to replace placeholders
706  if(!stristr($page_editor_html, $placeholder))
707  {
708  $tpl->setVariable($fallback_tplvar,$element_html);
709  return $page_editor_html;
710  }
711  return str_replace($placeholder, $element_html, $page_editor_html);
712  }
713 
718  protected function getLoginPageEditorHTML()
719  {
720  global $lng, $tpl;
721 
722  include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
724  $active_lang = $lpe->getIliasEditorLanguage($lng->getLangKey());
725 
726  if(!$active_lang)
727  {
728  return '';
729  }
730 
731  // if page does not exist, return nothing
732  include_once './Services/COPage/classes/class.ilPageUtil.php';
733  if(!ilPageUtil::_existsAndNotEmpty('auth', ilLanguage::lookupId($active_lang)))
734  {
735  return '';
736  }
737 
738  include_once './Services/COPage/classes/class.ilPageObject.php';
739  include_once './Services/COPage/classes/class.ilPageObjectGUI.php';
740 
741  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
742  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0));
743  $tpl->setCurrentBlock("SyntaxStyle");
744  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",ilObjStyleSheet::getSyntaxStylePath());
745  $tpl->parseCurrentBlock();
746 
747  // get page object
748  $page_gui = new ilPageObjectGUI('auth', ilLanguage::lookupId($active_lang));
749 
750  /*
751  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
752  $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
753  $this->object->getStyleSheetId(), $this->object->getType()));
754  */
755  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
756  $page_gui->setStyleId(0, 'auth');
757 
758  $page_gui->setIntLinkHelpDefault("RepositoryItem", $active_lang);
759  //$page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
760  //$page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "showMediaFullscreen"));
761  //$page_gui->setLinkParams($this->ctrl->getUrlParameterString()); // todo
762 // $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this, ""));
763  $page_gui->setPresentationTitle("");
764  $page_gui->setTemplateOutput(false);
765  $page_gui->setHeader("");
766  $page_gui->setEnabledRepositoryObjects(true);
767  $page_gui->setEnabledLoginPage(true);
768  $page_gui->setEnabledFileLists(false);
769  $page_gui->setEnabledPCTabs(false);
770  $page_gui->setEnabledMaps(true);
771  $ret = $page_gui->showPage();
772 
773  return $ret;
774  }
775 
780  protected function showLanguageSelection($page_editor_html)
781  {
782  global $lng;
783 
784  $languages = $lng->getInstalledLanguages();
785  if(count($languages) <= 1)
786  {
787  return '';
788  }
789 
790  $ltpl = new ilTemplate('tpl.login_form_lang_selection.html',true,true,'Services/Init');
791  foreach ($languages as $lang_key)
792  {
793  $ltpl->setCurrentBlock("languages");
794  $ltpl->setVariable("LANG_KEY", $lang_key);
795  $ltpl->setVariable("LANG_NAME",
796  ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
797  $ltpl->setVariable("BORDER", 0);
798  $ltpl->setVariable("VSPACE", 0);
799  $ltpl->parseCurrentBlock();
800  }
801  $ltpl->setCurrentBlock('lang_selection');
802  $ltpl->setVariable("TXT_OK", $lng->txt("ok"));
803  $ltpl->setVariable("LANG_FORM_ACTION",$this->ctrl->getFormAction($this));
804  $ltpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
805  $ltpl->setVariable("LANG_ID", $lng->getLangKey());
806  $ltpl->parseCurrentBlock();
807 
808  return $this->substituteLoginPageElements(
809  $GLOBALS['tpl'],
810  $page_editor_html,
811  $ltpl->get(),
812  '[list-language-selection]',
813  'LANG_SELECTION'
814  );
815 
816  }
817 
826  protected function showRegistrationLinks($page_editor_html)
827  {
829 
830  $rtpl = new ilTemplate('tpl.login_registration_links.html',true,true,'Services/Init');
831 
832  // allow new registrations?
833  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
835  {
836  $rtpl->setCurrentBlock("new_registration");
837  $rtpl->setVariable("REGISTER", $lng->txt("registration"));
838  $rtpl->setVariable("CMD_REGISTER",
839  $this->ctrl->getLinkTargetByClass("ilaccountregistrationgui", ""));
840  $rtpl->parseCurrentBlock();
841  }
842  // allow password assistance? Surpress option if Authmode is not local database
843  if ($ilSetting->get("password_assistance"))
844  {
845  $rtpl->setCurrentBlock("password_assistance");
846  $rtpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
847  $rtpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
848  $rtpl->setVariable("CMD_FORGOT_PASSWORD",
849  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
850  $rtpl->setVariable("CMD_FORGOT_USERNAME",
851  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
852  $rtpl->setVariable("LANG_ID", $lng->getLangKey());
853  $rtpl->parseCurrentBlock();
854  }
855 
856  if ($ilSetting->get("pub_section"))
857  {
858  $rtpl->setCurrentBlock("homelink");
859  $rtpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$lng->getLangKey());
860  $rtpl->setVariable("TXT_HOME",$lng->txt("home"));
861  $rtpl->parseCurrentBlock();
862  }
863 
864  if ($ilIliasIniFile->readVariable("clients","list"))
865  {
866  $rtpl->setCurrentBlock("client_list");
867  $rtpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
868  $rtpl->setVariable("CMD_CLIENT_LIST",$this->ctrl->getLinkTarget($this, "showClientList"));
869  $rtpl->parseCurrentBlock();
870  }
871 
872  return $this->substituteLoginPageElements(
873  $GLOBALS['tpl'],
874  $page_editor_html,
875  $rtpl->get(),
876  '[list-registration-link]',
877  'REG_PWD_CLIENT_LINKS'
878  );
879  }
880 
886  protected function showUserAgreementLink($page_editor_html)
887  {
888  global $lng;
889 
890  $utpl = new ilTemplate('tpl.login_user_agreement_link.html',true,true,'Services/Init');
891  $utpl->setVariable("USER_AGREEMENT", $lng->txt("usr_agreement"));
892  $utpl->setVariable("LINK_USER_AGREEMENT",$this->ctrl->getLinkTarget($this, "showUserAgreement"));
893 
894  return $this->substituteLoginPageElements(
895  $GLOBALS['tpl'],
896  $page_editor_html,
897  $utpl->get(),
898  '[list-user-agreement]',
899  'USER_AGREEMENT'
900  );
901 
902  }
903 
909  protected function purgePlaceholders($page_editor_html)
910  {
911  return str_replace(
912  array(
913  '[list-language-selection] ',
914  '[list-registration-link]',
915  '[list-user-agreement]',
916  '[list-login-form]',
917  '[list-cas-login-form]',
918  '[list-shibboleth-login-form]',
919  '[list-openid-login-form]'
920  ),
921  array('','','','','','',''),
922  $page_editor_html
923  );
924  }
925 
926 
927  function showFailure($a_mess)
928  {
929  global $tpl, $lng;
930 
931  $tpl->setCurrentBlock("warning");
932  $tpl->setVariable('TXT_MSG_LOGIN_FAILED', $a_mess);
933  $tpl->setVariable("MESSAGE_HEADING", $lng->txt("failure_message"));
934  $tpl->setVariable("ALT_IMAGE", $lng->txt("icon")." ".$lng->txt("failure_message"));
935  $tpl->setVariable("SRC_IMAGE", ilUtil::getImagePath("mess_failure.gif"));
936  $tpl->parseCurrentBlock();
937  }
938 
939  public function showSuccess($a_mess)
940  {
941  global $tpl, $lng;
942 
943  $tpl->setCurrentBlock('success');
944  $tpl->setVariable('TXT_MSG_LOGIN_SUCCESS', $a_mess);
945  $tpl->setVariable('MESSAGE_HEADING', $lng->txt('success_message'));
946  $tpl->setVariable('ALT_IMAGE', $lng->txt('icon').' '.$lng->txt('success_message'));
947  $tpl->setVariable('SRC_IMAGE', ilUtil::getImagePath('mess_success.gif'));
948  $tpl->parseCurrentBlock();
949  }
950 
958  public function showAccountMigration($a_message = '')
959  {
960  global $tpl,$lng;
961 
962  $lng->loadLanguageModule('auth');
963  $tpl->addBlockFile("CONTENT",
964  "content",
965  "tpl.login_account_migration.html",
966  "Services/Init");
967 
968  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
969  $form = new ilPropertyFormGUI();
970  $form->setFormAction($this->ctrl->getFormAction($this,'migrateAccount'));
971 
972  $form->setTitle($lng->txt('auth_account_migration'));
973  $form->addCommandButton('migrateAccount', $lng->txt('save'));
974  $form->addCommandButton('showLogin', $lng->txt('cancel'));
975 
976  $rad = new ilRadioGroupInputGUI($lng->txt('auth_account_migration_name'),'account_migration');
977  $rad->setValue(1);
978 
979  $keep = new ilRadioOption($lng->txt('auth_account_migration_keep'),1,$lng->txt('auth_info_migrate'));
980  $user = new ilTextInputGUI($lng->txt('login'),'mig_username');
981  $user->setValue(ilUtil::prepareFormOutput($_POST['mig_username']));
982  $user->setSize(32);
983  $user->setMaxLength(128);
984  $keep->addSubItem($user);
985 
986  $pass = new ilPasswordInputGUI($lng->txt('password'),'mig_password');
987  $pass->setValue(ilUtil::prepareFormOutput($_POST['mig_password']));
988  $pass->setRetype(false);
989  $pass->setSize(12);
990  $pass->setMaxLength(128);
991  $keep->addSubItem($pass);
992  $rad->addOption($keep);
993 
994  $new = new ilRadioOption($lng->txt('auth_account_migration_new'),2,$lng->txt('auth_info_add'));
995  $rad->addOption($new);
996 
997  $form->addItem($rad);
998 
999  $tpl->setVariable('MIG_FORM',$form->getHTML());
1000 
1001  if(strlen($a_message))
1002  {
1003  $this->showFailure($a_message);
1004  }
1005 
1006  $tpl->show('DEFAULT');
1007  }
1008 
1015  public function migrateAccount()
1016  {
1017  global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
1018 
1019  $lng->loadLanguageModule('auth');
1020 
1021  if(!isset($_POST['account_migration']))
1022  {
1023  $this->showAccountMigration($lng->txt('err_choose_migration_type'));
1024  return false;
1025  }
1026 
1027  if($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
1028  {
1029  $this->showAccountMigration($lng->txt('err_wrong_login'));
1030  return false;
1031  }
1032 
1033  if($_POST['account_migration'] == 1)
1034  {
1035  if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
1036  {
1037  $this->showAccountMigration($lng->txt('err_wrong_login'));
1038  return false;
1039  }
1040  $_POST['username'] = $_POST['mig_username'];
1041  $_POST['password'] = $_POST['mig_password'];
1042 
1043  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1044  include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
1045 
1047  $ilAuth->start();
1048  if(!$ilAuth->checkAuth())
1049  {
1050  $ilAuth->logout();
1051  $this->showAccountMigration($lng->txt('err_wrong_login'));
1052  return false;
1053  }
1054 
1055  $user = new ilObjUser($user_id);
1056  $user->setAuthMode($_SESSION['tmp_auth_mode']);
1057  $user->setExternalAccount($_SESSION['tmp_external_account']);
1058  $user->setActive(true);
1059  $user->update();
1060 
1061  // Assign to default role
1062  if(is_array($_SESSION['tmp_roles']))
1063  {
1064  foreach($_SESSION['tmp_roles'] as $role)
1065  {
1066  $rbacadmin->assignUser((int) $role,$user->getId());
1067  }
1068  }
1069 
1070  // Log migration
1071  $ilLog->write(__METHOD__.': Migrated '.$_SESSION['tmp_external_account'].' to ILIAS account '.$user->getLogin().'.');
1072  }
1073  elseif($_POST['account_migration'] == 2)
1074  {
1075  switch($_SESSION['tmp_auth_mode'])
1076  {
1077  case 'apache':
1078  $_POST['username'] = $_SESSION['tmp_external_account'];
1079  $_POST['password'] = $_SESSION['tmp_pass'];
1080 
1081  include_once('Services/Database/classes/class.ilAuthContainerApache.php');
1082  $container = new ilAuthContainerApache();
1083  $container->forceCreation(true);
1084  $ilAuth = ilAuthFactory::factory($container);
1085  $ilAuth->start();
1086  break;
1087 
1088  case 'ldap':
1089  $_POST['username'] = $_SESSION['tmp_external_account'];
1090  $_POST['password'] = $_SESSION['tmp_pass'];
1091 
1092  include_once('Services/LDAP/classes/class.ilAuthContainerLDAP.php');
1093  $container = new ilAuthContainerLDAP();
1094  $container->forceCreation(true);
1095  $ilAuth = ilAuthFactory::factory($container);
1096  $ilAuth->start();
1097  break;
1098 
1099  case 'radius':
1100  $_POST['username'] = $_SESSION['tmp_external_account'];
1101  $_POST['password'] = $_SESSION['tmp_pass'];
1102 
1103  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1104  include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
1105 
1106  $container = new ilAuthContainerRadius();
1107  $container->forceCreation(true);
1108  $ilAuth = ilAuthFactory::factory($container);
1109  $ilAuth->start();
1110  break;
1111 
1112  case 'openid':
1113  $_POST['username'] = $_SESSION['tmp_external_account'];
1114  $_POST['password'] = $_SESSION['tmp_pass'];
1115  $_POST['oid_username'] = $_SESSION['tmp_oid_username'];
1116  $_SESSION['force_creation'] = true;
1117 
1118  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1119  include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
1120 
1121  $container = new ilAuthContainerOpenId();
1122  $container->forceCreation(true);
1124  $ilAuth = ilAuthFactory::factory($container);
1125  $ilAuth->callProvider($_POST['username'], null, null);
1126  $ilAuth->start();
1127  break;
1128  }
1129  }
1130  // show personal desktop
1131  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
1132  }
1133 
1137  function showLogout()
1138  {
1139  global $tpl, $ilSetting, $ilAuth, $lng, $ilIliasIniFile;
1140 
1141  $ilAuth->logout();
1142  session_destroy();
1143 
1144  // reset cookie
1145  $client_id = $_COOKIE["ilClientId"];
1146  ilUtil::setCookie("ilClientId","");
1147 
1148  //instantiate logout template
1149  $tpl->addBlockFile("CONTENT", "content", "tpl.logout.html",
1150  "Services/Init");
1151 
1152  if ($ilSetting->get("pub_section"))
1153  {
1154  $tpl->setCurrentBlock("homelink");
1155  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1156  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
1157  $tpl->parseCurrentBlock();
1158  }
1159 
1160  if ($ilIliasIniFile->readVariable("clients","list"))
1161  {
1162  $tpl->setCurrentBlock("client_list");
1163  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1164  $this->ctrl->setParameter($this, "client_id", $client_id);
1165  $tpl->setVariable("CMD_CLIENT_LIST",
1166  $this->ctrl->getLinkTarget($this, "showClientList"));
1167  $tpl->parseCurrentBlock();
1168  $this->ctrl->setParameter($this, "client_id", "");
1169  }
1170 
1171  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
1172  $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
1173  $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
1174  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1175 
1176  $tpl->show();
1177  }
1178 
1184  {
1185  global $ilAuth, $tpl, $lng;
1186 
1187  $valid = $ilAuth->getValidationData();
1188 
1189  $tpl->addBlockFile("CONTENT", "content", "tpl.user_mapping_selection.html",
1190  "Services/Init");
1191  $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
1192 
1193 
1194  if ($ilAuth->sub_status == AUTH_WRONG_LOGIN)
1195  {
1196  $this->showFailure($lng->txt("err_wrong_login"));
1197  }
1198 
1199  include_once('./Services/User/classes/class.ilObjUser.php');
1200  if (count($email_user) == 1)
1201  {
1202  //$user = new ilObjUser(key($email_user));
1203  $tpl->setCurrentBlock("one_user");
1204  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
1205  $tpl->setVariable("VAL_USERNAME", current($email_user));
1206  $tpl->setVariable("USER_ID", key($email_user));
1207  $tpl->parseCurrentBlock();
1208  }
1209  else
1210  {
1211  foreach($email_user as $key => $login)
1212  {
1213  $tpl->setCurrentBlock("user");
1214  $tpl->setVariable("USR_ID", $key);
1215  $tpl->setVariable("VAL_USER", $login);
1216  $tpl->parseCurrentBlock();
1217  }
1218  $tpl->setCurrentBlock("multpiple_user");
1219  $tpl->parseCurrentBlock();
1220  }
1221 
1222  $tpl->setCurrentBlock("content");
1223  $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
1224  $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
1225  $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
1226  $tpl->setVariable("FORMACTION",
1227  $this->ctrl->getFormAction($this));
1228  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
1229  if (count($email_user) == 1)
1230  {
1231  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
1232  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
1233  }
1234  else
1235  {
1236  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
1237  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
1238  }
1239  $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
1240  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
1241  $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
1242  $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
1243 
1244  $tpl->show();
1245  }
1246 
1250  function showClientList()
1251  {
1252  global $tpl, $ilIliasIniFile, $ilCtrl;
1253 //echo "1";
1254  if (!$ilIliasIniFile->readVariable("clients","list"))
1255  {
1256  $this->processIndexPHP();
1257  return;
1258  }
1259 //echo "2";
1260  $tpl = new ilTemplate("tpl.main.html", true, true);
1261 
1262  // to do: get standard style
1263  $tpl->setVariable("PAGETITLE","Client List");
1264  $tpl->setVariable("LOCATION_STYLESHEET","./templates/default/delos.css");
1265 
1266  // load client list template
1267  $tpl->addBlockfile("CONTENT", "content", "tpl.client_list.html",
1268  "Services/Init");
1269 
1270  // load template for table
1271  $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1272 
1273  // load template for table content data
1274  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1275 
1276  // load table content data
1277  require_once("setup/classes/class.ilClientList.php");
1278  require_once("setup/classes/class.ilClient.php");
1279  require_once("setup/classes/class.ilDBConnections.php");
1280  require_once("./Services/Table/classes/class.ilTableGUI.php");
1281  $this->db_connections = new ilDBConnections();
1282  $clientlist = new ilClientList($this->db_connections);
1283  $list = $clientlist->getClients();
1284 
1285  if (count($list) == 0)
1286  {
1287  header("Location: ./setup/setup.php");
1288  exit();
1289  }
1290 
1291  foreach ($list as $key => $client)
1292  {
1293  $client->setDSN();
1294  $hasPublicSection = false;
1295  if ($client->checkDatabaseExists() and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
1296  {
1297  $this->ctrl->setParameter($this, "client_id", $key);
1298  $tmp = array();
1299  $tmp[] = $client->getName();
1300  $tmp[] = "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">Login page</a>";
1301 
1302  if($client->getSetting('pub_section'))
1303  {
1304  $hasPublicSection = true;
1305  $tmp[] = "<a href=\"" . "repository.php?client_id=" . urlencode($key) . "\">Start page</a>";
1306  }
1307  else
1308  {
1309  $tmp[] = '';
1310  }
1311 
1312  $data[] = $tmp;
1313  }
1314  }
1315  $this->ctrl->setParameter($this, "client_id", "");
1316 
1317  // create table
1318  $tbl = new ilTableGUI();
1319 
1320  // title & header columns
1321  if($hasPublicSection)
1322  {
1323  $tbl->setTitle("Available Clients");
1324  $tbl->setHeaderNames(array("Installation Name","Public Access","Login"));
1325  $tbl->setHeaderVars(array("name","index","login"));
1326  $tbl->setColumnWidth(array("50%","25%","25%"));
1327  }
1328  else
1329  {
1330  $tbl->setTitle("Available Clients");
1331  $tbl->setHeaderNames(array("Installation Name","Login",''));
1332  $tbl->setHeaderVars(array("name","login",''));
1333  $tbl->setColumnWidth(array("70%","25%",'1px'));
1334  }
1335 
1336  // control
1337  $tbl->setOrderColumn($_GET["sort_by"],"name");
1338  $tbl->setOrderDirection($_GET["sort_order"]);
1339  $tbl->setLimit($_GET["limit"]);
1340  $tbl->setOffset($_GET["offset"]);
1341 
1342  // content
1343  $tbl->setData($data);
1344 
1345  // footer
1346  $tbl->setFooter("tblfooter");
1347 
1348  // styles
1349  $tbl->setStyle("table","std");
1350 
1351  $tbl->disable("icon");
1352  $tbl->disable("numinfo");
1353  $tbl->disable("sort");
1354 
1355  // render table
1356  $tbl->render();
1357  $tpl->show("DEFAULT", true, true);
1358  }
1359 
1366  {
1367  global $tpl;
1368 
1369  $str = "<p style=\"margin:15px;\">
1370  You need to enable Session Cookies in your Browser to use ILIAS.
1371  <br/>
1372  <br/><b>Firefox</b>
1373  <br/>Tools -> Options -> Privacy -> Cookies
1374  <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
1375  <br/>cookies' auf 'until I close Firefox'
1376  <br/>
1377  <br/><b>Mozilla/Netscape</b>
1378  <br/>Edit -> Preferences -> Privacy&Security -> Cookies
1379  <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
1380  <br/>session only'.
1381  <br/>
1382  <br/><b>Internet Explorer</b>
1383  <br/>Tools -> Internet Options -> Privacy -> Advanced
1384  <br/>- Check 'Override automatic cookie handling'
1385  <br/>- Check 'Always allow session cookies'
1386  </p>";
1387  $tpl->setVariable("CONTENT", $str);
1388  $tpl->show();
1389  }
1390 
1394  function getAcceptance()
1395  {
1396  $this->showUserAgreement();
1397  }
1398 
1403  {
1404  global $lng, $tpl, $ilUser;
1405 
1406  require_once "./Services/User/classes/class.ilUserAgreement.php";
1407 
1408  $tpl->addBlockFile("CONTENT", "content", "tpl.view_usr_agreement.html",
1409  "Services/Init");
1410  $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1411 
1412 // ilUtil::sendInfo();
1413  // display infopanel if something happened
1415 
1416  $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
1417  $tpl->setVariable("TXT_OK", $lng->txt("ok"));
1418 
1419  // language selection
1420 
1421  // #9728
1422  $lang_opts = array();
1423  foreach ($lng->getInstalledLanguages() as $lang_key)
1424  {
1425  $lang_opts[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key);
1426  }
1427 
1428  asort($lang_opts);
1429 
1430  foreach($lang_opts as $lang_key => $lang_caption)
1431  {
1432  $tpl->setCurrentBlock("languages");
1433  $tpl->setVariable("LANG_VAL_CMD", $this->ctrl->getCmd());
1434  $tpl->setVariable("AGR_LANG_ACTION",
1435  $this->ctrl->getFormAction($this));
1436  $tpl->setVariable("LANG_NAME", $lang_caption);
1437  $tpl->setVariable("LANG_ICON", $lang_key);
1438  $tpl->setVariable("LANG_KEY", $lang_key);
1439  $tpl->setVariable("BORDER", 0);
1440  $tpl->setVariable("VSPACE", 0);
1441  $tpl->parseCurrentBlock();
1442  }
1443  $tpl->setCurrentBlock("content");
1444 
1445  // display tabs
1446  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("usr_agreement"));
1447  $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - ".$lng->txt("usr_agreement"));
1448  $tpl->setVariable("TXT_USR_AGREEMENT", ilUserAgreement::_getText());
1449 
1450  if ($this->ctrl->getCmd() == "getAcceptance")
1451  {
1452  if ($_POST["status"]=="accepted")
1453  {
1454  $ilUser->writeAccepted();
1455  ilUtil::redirect("index.php?target=".$_GET["target"]."&client_id=".CLIENT_ID);
1456  }
1457  $tpl->setVariable("VAL_CMD", "getAcceptance");
1458  $tpl->setVariable("AGR_LANG_ACTION",
1459  $this->ctrl->getFormAction($this));
1460  $tpl->setCurrentBlock("get_acceptance");
1461  $tpl->setVariable("FORM_ACTION",
1462  $this->ctrl->getFormAction($this));
1463  $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
1464  $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement"));
1465  $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
1466  $tpl->parseCurrentBlock();
1467  }
1468  else
1469  {
1470  $tpl->setCurrentBlock("back");
1471  $tpl->setVariable("BACK", $lng->txt("back"));
1472  $tpl->setVariable("LINK_BACK",
1473  $this->ctrl->getLinkTargetByClass("ilstartupgui", "showLogin"));
1474  $tpl->parseCurrentBlock();
1475  }
1476 
1477  $tpl->show();
1478 
1479 
1480  }
1481 
1485  function processIndexPHP()
1486  {
1487  global $ilIliasIniFile, $ilAuth, $ilSetting, $ilInit;
1488 
1489  // display client selection list if enabled
1490  if (!isset($_GET["client_id"]) &&
1491  $_GET["cmd"] == "" &&
1492  $ilIliasIniFile->readVariable("clients","list"))
1493  {
1494  $this->showClientList();
1495  //include_once "./include/inc.client_list.php";
1496  exit();
1497  }
1498 
1499  // if no start page was given, ILIAS defaults to the standard login page
1500  if ($start == "")
1501  {
1502  $start = "login.php";
1503  }
1504 
1505 
1506  //
1507  // index.php is called and public section is enabled
1508  //
1509  // && $ilAuth->status == -101 is important for soap auth (public section on + user mapping, alex)
1510  // $ilAuth->status -1 is given, if session ends (if public section -> jump to public section)
1511 
1512  if ($ilSetting->get("pub_section") && $_POST["sendLogin"] != "1"
1513  && ($ilAuth->getStatus() != -101 && $_GET["soap_pw"] == ""))
1514  {
1515  //
1516  // TO DO: THE FOLLOWING BLOCK IS COPY&PASTED FROM HEADER.INC
1517 
1518  $_POST["username"] = "anonymous";
1519  $_POST["password"] = "anonymous";
1520 
1521  $oldSid = session_id();
1522 
1523  $ilAuth->start();
1524  if (ANONYMOUS_USER_ID == "")
1525  {
1526  die ("Public Section enabled, but no Anonymous user found.");
1527  }
1528  if (!$ilAuth->getAuth())
1529  {
1530  die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
1531  }
1532 
1533  if(IS_PAYMENT_ENABLED)
1534  {
1535  $newSid = session_id();
1536  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
1537  ilPaymentShoppingCart::_migrateShoppingCart($oldSid, $newSid);
1538  }
1539  // get user id
1540  $ilInit->initUserAccount();
1541  $this->processStartingPage();
1542 
1543  exit;
1544  }
1545  else
1546  {
1547  // index.php is called and public section is disabled
1548  $this->showLogin();
1549  }
1550  }
1551 
1552 
1559  {
1560  global $ilBench, $ilCtrl, $ilAccess, $lng, $ilUser;
1561 //echo "here";
1562  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID || !empty($_GET["ref_id"]))
1563  {
1564 //echo "A";
1565  // if anonymous and a target given...
1566  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID && $_GET["target"] != "")
1567  {
1568  // target is accessible -> goto target
1569  if ($this->_checkGoto($_GET["target"]))
1570  {
1571 //echo "B";
1572  ilUtil::redirect("./goto.php?target=".$_GET["target"]);
1573  }
1574  else // target is not accessible -> login
1575  {
1576 //echo "C";
1577  $this->showLogin();
1578  }
1579  }
1580 
1581  // just go to public section
1582  if (empty($_GET["ref_id"]))
1583  {
1584  $_GET["ref_id"] = ROOT_FOLDER_ID;
1585  }
1586  $ilCtrl->initBaseClass("");
1587  $ilCtrl->setCmd("frameset");
1588  $start_script = "repository.php";
1589  include($start_script);
1590  return true;
1591  }
1592  else
1593  {
1594  if(IS_PAYMENT_ENABLED)
1595  {
1596  $usr_id = $ilUser->getId();
1597 
1598  include_once './Services/Payment/classes/class.ilShopLinkBuilder.php';
1600 
1601  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
1603 
1604  if((int)$_GET['forceShoppingCartRedirect'])
1605  {
1606  $class = 'ilshopshoppingcartgui';
1607  ilUtil::redirect('ilias.php?baseClass=ilShopController&cmd=redirect&redirect_class=ilshopshoppingcartgui');
1608  }
1609 
1610  // handle goto_ links for shop after login
1611  $tarr = explode("_", $_GET["target"]);
1612  if(in_array($tarr[0], $shop_classes))
1613  {
1614  $class = $tarr[0];
1615  ilUtil::redirect('ilias.php?baseClass='.ilShopLinkBuilder::$linkArray[strtolower($class)]['baseClass']
1616  .'&cmdClass='.strtolower(ilShopLinkBuilder::$linkArray[strtolower($class)]['cmdClass']));
1617  exit;
1618  }
1619  }
1620 
1621  if (!$this->_checkGoto($_GET["target"]))
1622  {
1623  // message if target given but not accessible
1624  if ($_GET["target"] != "")
1625  {
1626  $tarr = explode("_", $_GET["target"]);
1627  if ($tarr[0] != "pg" && $tarr[0] != "st" && $tarr[1] > 0)
1628  {
1629  ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"),
1631  }
1632  }
1633 
1634  // show personal desktop
1635  #$ilCtrl->initBaseClass("ilPersonalDesktopGUI");
1636  #$start_script = "ilias.php";
1637  // Redirect here to switch back to http if desired
1638  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
1639  }
1640  else
1641  {
1642 //echo "3";
1643  ilUtil::redirect("./goto.php?target=".$_GET["target"]);
1644  }
1645  }
1646 
1647  include($start_script);
1648  }
1649 
1650  function _checkGoto($a_target)
1651  {
1652  global $objDefinition, $ilPluginAdmin;
1653 
1654  if (is_object($ilPluginAdmin))
1655  {
1656  // get user interface plugins
1657  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1658 
1659  // search
1660  foreach ($pl_names as $pl)
1661  {
1662  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1663  $gui_class = $ui_plugin->getUIClassInstance();
1664  $resp = $gui_class->checkGotoHook($a_target);
1665  if ($resp["target"] !== false)
1666  {
1667  $a_target = $resp["target"];
1668  break;
1669  }
1670  }
1671  }
1672 
1673  if ($a_target == "")
1674  {
1675  return false;
1676  }
1677 
1678  $t_arr = explode("_", $a_target);
1679  $type = $t_arr[0];
1680 
1681  if ($type == "git")
1682  {
1683  $type = "glo";
1684  }
1685 
1686  if ($type == "pg" | $type == "st")
1687  {
1688  $type = "lm";
1689  }
1690 
1691  $class = $objDefinition->getClassName($type);
1692  if ($class == "")
1693  {
1694  return false;
1695  }
1696  $location = $objDefinition->getLocation($type);
1697  $full_class = "ilObj".$class."Access";
1698  include_once($location."/class.".$full_class.".php");
1699 
1700  return call_user_func(array($full_class, "_checkGoto"),
1701  $a_target);
1702  }
1703 
1704  public function confirmRegistration()
1705  {
1706  global $lng, $ilias, $ilLog;
1707 
1708  ilUtil::setCookie('iltest', 'cookie', false);
1709 
1710  if(!isset($_GET['rh']) || !strlen(trim($_GET['rh'])))
1711  {
1712  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
1713  }
1714 
1715  try
1716  {
1717  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
1718  $oRegSettings = new ilRegistrationSettings();
1719 
1722  $oUser->setActive(true);
1723  if($oRegSettings->passwordGenerationEnabled())
1724  {
1725  $passwd = ilUtil::generatePasswords(1);
1726  $password = $passwd[0];
1727  $oUser->setPasswd($password, IL_PASSWD_PLAIN);
1728  $oUser->setLastPasswordChangeTS( time() );
1729  }
1730  $oUser->update();
1731 
1732  if($lng->getLangKey() != $oUser->getPref('language'))
1733  {
1734  $lng = new ilLanguage($oUser->getPref('language'));
1735  }
1736 
1737  // send email
1738  // try individual account mail in user administration
1739  include_once("Services/Mail/classes/class.ilAccountMail.php");
1740  include_once './Services/User/classes/class.ilObjUserFolder.php';
1741  $amail = ilObjUserFolder::_lookupNewAccountMail($oUser->getPref('language'));
1742  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
1743  {
1744  $acc_mail = new ilAccountMail();
1745  $acc_mail->setUser($oUser);
1746  if($oRegSettings->passwordGenerationEnabled())
1747  {
1748  $acc_mail->setUserPassword($password);
1749  }
1750  $acc_mail->send();
1751  }
1752  else // do default mail
1753  {
1754  include_once 'Services/Mail/classes/class.ilMail.php';
1755  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
1756 
1757  // mail subject
1758  $subject = $lng->txt("reg_mail_subject");
1759 
1760  // mail body
1761  $body = $lng->txt("reg_mail_body_salutation")." ".$oUser->getFullname().",\n\n".
1762  $lng->txt("reg_mail_body_text1")."\n\n".
1763  $lng->txt("reg_mail_body_text2")."\n".
1764  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
1765  $body .= $lng->txt("login").": ".$oUser->getLogin()."\n";
1766 
1767  if($oRegSettings->passwordGenerationEnabled())
1768  {
1769  $body.= $lng->txt("passwd").": ".$password."\n";
1770  }
1771 
1772  $body.= "\n";
1773  $body.= $lng->txt('reg_mail_body_forgot_password_info')."\n";
1774 
1775  $body.= "\n";
1776 
1777  $body .= ($lng->txt("reg_mail_body_text3")."\n\r");
1778  $body .= $oUser->getProfileAsString($lng);
1779  $mail_obj->enableSoap(false);
1780  $mail_obj->appendInstallationSignature(true);
1781  $mail_obj->sendMail($oUser->getEmail(), '', '',
1782  $subject,
1783  $body,
1784  array(), array('normal'));
1785  }
1786 
1787  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful');
1788  }
1789  catch(ilRegConfirmationLinkExpiredException $exception)
1790  {
1791  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1792  $soap_client = new ilSoapClient();
1793  $soap_client->setResponseTimeout(1);
1794  $soap_client->enableWSDL(true);
1795  $soap_client->init();
1796 
1797  $ilLog->write(__METHOD__.': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
1798 
1799  $soap_client->call
1800  (
1801  'deleteExpiredDualOptInUserObjects',
1802  array
1803  (
1804  $_COOKIE['PHPSESSID'].'::'.$_COOKIE['ilClientId'], // session id and client id, not used for checking access -> not possible for anonymous
1805  $exception->getCode() // user id
1806  )
1807  );
1808 
1809  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage());
1810  }
1811  catch(ilRegistrationHashNotFoundException $exception)
1812  {
1813  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage());
1814  }
1815  }
1816 
1821  protected function showOpenIdLoginForm($page_editor_html)
1822  {
1823  global $lng,$tpl;
1824 
1825  include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
1826  if(!ilOpenIdSettings::getInstance()->isActive())
1827  {
1828  return $page_editor_html;
1829  }
1830 
1831  $lng->loadLanguageModule('auth');
1832 
1833  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1834  $form = new ilPropertyFormGUI();
1835  $form->setTableWidth('500');
1836  $form->setShowTopButtons(false);
1837  $form->setFormAction($this->ctrl->getFormAction($this));
1838  $form->setTitle($lng->txt('login_to_ilias_via_openid'));
1839 
1840  $openid = new ilTextInputGUI($lng->txt('auth_openid_login'),'oid_username');
1841  $openid->setSize(18);
1842  $openid->setMaxLength(255);
1843  $openid->setRequired(true);
1844  $openid->setCssClass('ilOpenIDBox');
1845  $openid->setInfo($lng->txt('auth_openid_login_info_a'));
1846  $form->addItem($openid);
1847 
1848  include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
1849  $pro = new ilSelectInputGUI($lng->txt('auth_openid_provider'),'oid_provider');
1850  $pro->setOptions(ilOpenIdProviders::getInstance()->getProviderSelection());
1851  $pro->setValue(ilOpenIdProviders::getInstance()->getSelectedProvider());
1852  $form->addItem($pro);
1853  $form->addCommandButton("showLogin", $lng->txt("log_in"));
1854 
1855  return $this->substituteLoginPageElements(
1856  $tpl,
1857  $page_editor_html,
1858  $form->getHTML(),
1859  '[list-openid-login-form]',
1860  'OID_LOGIN_FORM'
1861  );
1862  }
1863 }
1864 ?>