ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5 
16 {
19 
20  protected $ctrl;
21  protected $lng;
22  protected $logger;
23 
27  public function __construct()
28  {
29  global $ilCtrl, $lng;
30 
31  $this->ctrl = $ilCtrl;
32  $this->lng = $lng;
33  $this->lng->loadLanguageModule('auth');
34  $this->logger = ilLoggerFactory::getLogger('init');
35 
36  $ilCtrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
37  }
38 
43  public function executeCommand()
44  {
45  $cmd = $this->ctrl->getCmd("processIndexPHP",array('processIndexPHP','showLoginPage'));
46  $next_class = $this->ctrl->getNextClass($this);
47 
48  switch($next_class)
49  {
50  case 'ilLoginPageGUI':
51  break;
52 
53  case "ilaccountregistrationgui":
54  require_once("Services/Registration/classes/class.ilAccountRegistrationGUI.php");
55  return $this->ctrl->forwardCommand(new ilAccountRegistrationGUI());
56 
57  case "ilpasswordassistancegui":
58  require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
59  return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
60 
61  default:
62  return $this->$cmd();
63  }
64  }
65 
70  public function getLogger()
71  {
72  return $this->logger;
73  }
74 
79  public function jumpToRegistration()
80  {
81  $this->ctrl->setCmdClass("ilaccountregistrationgui");
82  $this->ctrl->setCmd("");
83  $this->executeCommand();
84  }
85 
90  public function jumpToPasswordAssistance()
91  {
92  $this->ctrl->setCmdClass("ilpasswordassistancegui");
93  $this->ctrl->setCmd("");
94  $this->executeCommand();
95  }
96 
100  protected function showLoginPageOrStartupPage()
101  {
105  $auth_session = $GLOBALS['DIC']['ilAuthSession'];
106 
107  $force_login = false;
108  if(
109  !is_array($_REQUEST['cmd']) &&
110  strcmp($_REQUEST['cmd'], 'force_login') === 0
111  )
112  {
113  $force_login = true;
114  }
115 
116  if($force_login)
117  {
118  $this->logger->debug('Force login');
119  if($auth_session->isValid())
120  {
121  $this->logger->debug('Valid session -> logout current user');
123  $auth_session->logout();
124 
125  $GLOBALS['ilAppEventHandler']->raise(
126  'Services/Authentication',
127  'afterLogout',
128  array(
129  'username' => $GLOBALS['DIC']->user()->getLogin()
130  )
131  );
132  }
133  $this->logger->debug('Show login page');
134  return $this->showLoginPage();
135  }
136 
140  if($auth_session->isValid())
141  {
142  $this->logger->debug('Valid session -> redirect to starting page');
143  return ilInitialisation::redirectToStartingPage();
144  }
145  $this->logger->debug('No valid session -> show login');
146  $this->showLoginPage();
147  }
148 
149 
154  protected function showLoginPage(ilPropertyFormGUI $form = null)
155  {
156  global $tpl, $ilSetting;
157 
158  $this->getLogger()->debug('Showing login page');
159 
160  // try apache auth
161  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsApache.php';
162  $frontend = new ilAuthFrontendCredentialsApache();
163  $frontend->tryAuthenticationOnLoginPage();
164 
165  // Instantiate login template
166  self::initStartUpTemplate("tpl.login.html");
167 
168  $page_editor_html = $this->getLoginPageEditorHTML();
169  $page_editor_html = $this->showLoginInformation($page_editor_html);
170  $page_editor_html = $this->showLoginForm($page_editor_html, $form);
171  $page_editor_html = $this->showCASLoginForm($page_editor_html);
172  $page_editor_html = $this->showShibbolethLoginForm($page_editor_html);
173  $page_editor_html = $this->showRegistrationLinks($page_editor_html);
174  $page_editor_html = $this->showTermsOfServiceLink($page_editor_html);
175 
176  $page_editor_html = $this->purgePlaceholders($page_editor_html);
177 
178  // not controlled by login page editor
179  $tpl->setVariable("PAGETITLE", "- ".$this->lng->txt("startpage"));
180  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
181 
182  $this->ctrl->setTargetScript("ilias.php");
183 
184  // check expired session and send message
185  if($GLOBALS['DIC']['ilAuthSession']->isExpired())
186  {
187  ilUtil::sendFailure($GLOBALS['lng']->txt('auth_err_expired'));
188  }
189 
190 
191  if(strlen($page_editor_html))
192  {
193  $tpl->setVariable('LPE',$page_editor_html);
194  }
195 
196  $tpl->fillWindowTitle();
197  $tpl->fillCssFiles();
198  $tpl->fillJavaScriptFiles();
199  $tpl->show("DEFAULT", false);
200  }
201 
208  protected function showLogin()
209  {
210  global $ilSetting, $ilAuth, $tpl, $ilias, $lng;
211 
212  $this->getLogger()->warning('Using deprecated startup method');
213  $this->getLogger()->logStack(ilLogLevel::WARNING);
214 
215  $status = $ilAuth->getStatus();
216  if ($status == "" && isset($_GET["auth_stat"]))
217  {
218  $status = $_GET["auth_stat"];
219  }
220 
221  if($ilAuth->getAuth() && !$status)
222  {
223  // deprecated?
224  if ($_GET["rep_ref_id"] != "")
225  {
226  $_GET["ref_id"] = $_GET["rep_ref_id"];
227  }
228  include_once './Services/Init/classes/class.ilInitialisation.php';
229  ilInitialisation::redirectToStartingPage();
230  return;
231  }
232 
233  // check for session cookies enabled
234  if (!isset($_COOKIE['iltest']))
235  {
236  if (empty($_GET['cookies']))
237  {
238  $additional_params = '';
239  ilUtil::setCookie("iltest","cookie",false);
240  ilUtil::redirect("login.php?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"].
241  "&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".
242  rawurlencode(CLIENT_ID)."&lang=".$lng->getLangKey().$additional_params);
243  }
244  else
245  {
246  $_COOKIE['iltest'] = "";
247  }
248  }
249  else
250  {
251  unset($_GET['cookies']);
252  }
253 
254  if ($ilSetting->get("shib_active") && $ilSetting->get("shib_hos_type"))
255  {
256  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
257  // Check if we user selects Home Organization
258  $WAYF = new ShibWAYF();
259  }
260 
261  if (isset($WAYF) && $WAYF->is_selection())
262  {
263  if ($WAYF->is_valid_selection())
264  {
265  // Set cookie
266  $WAYF->setSAMLCookie();
267 
268  // Redirect
269  $WAYF->redirect();
270  }
271  }
272 
273  $failure = $success = null;
274 
275  // :TODO: handle internally?
276  if (isset($_GET['reg_confirmation_msg']) && strlen(trim($_GET['reg_confirmation_msg'])))
277  {
278  $lng->loadLanguageModule('registration');
279  if($_GET['reg_confirmation_msg'] == 'reg_account_confirmation_successful')
280  {
281  $success = $lng->txt(trim($_GET['reg_confirmation_msg']));
282  }
283  else
284  {
285  $failure = $lng->txt(trim($_GET['reg_confirmation_msg']));
286  }
287  }
288  else if(isset($_GET['reached_session_limit']) && $_GET['reached_session_limit'])
289  {
290  $failure = $lng->txt("reached_session_limit");
291  }
292  else if(isset($_GET['accdel']) && $_GET['accdel'])
293  {
294  $lng->loadLanguageModule('user');
295  $failure = $lng->txt("user_account_deleted_confirmation");
296  }
297 
298  if (!empty($status))
299  {
300  switch ($status)
301  {
302  case AUTH_IDLED:
303  // lang variable err_idled not existing
304  // $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
305  // fallthrough
306 
307  case AUTH_EXPIRED:
308  $failure = $lng->txt("err_session_expired");
309  break;
310 
312  $failure = $lng->txt("err_auth_cas_no_ilias_user");
313  break;
314 
316  $failure = $lng->txt("err_auth_soap_no_ilias_user");
317  break;
318 
320  $failure = $lng->txt("err_auth_ldap_no_ilias_user");
321  break;
322 
324  $failure = $lng->txt("err_auth_radius_no_ilias_user");
325  break;
326 
327  case AUTH_MODE_INACTIVE:
328  $failure = $lng->txt("err_auth_mode_inactive");
329  break;
330 
331  case AUTH_APACHE_FAILED:
332  $failure = $lng->txt("err_auth_apache_failed");
333  break;
334 
336  $lng->loadLanguageModule('cptch');
338  $ilAuth->logout();
339  session_destroy();
340  $failure = $lng->txt("cptch_wrong_input");
341  break;
342 
343  // special cases: extended user validation failed
344  // ilAuth was successful, so we have to logout here
345 
346  case AUTH_USER_WRONG_IP:
348  $ilAuth->logout();
349  session_destroy();
350 
351  $failure = sprintf($lng->txt('wrong_ip_detected'), $_SERVER['REMOTE_ADDR']);
352  break;
353 
356  $ilAuth->logout();
357  session_destroy();
358 
359  $failure = $lng->txt("simultaneous_login_detected");
360  break;
361 
364  $username = $ilAuth->getExceededUserName(); // #16327
365  $ilAuth->logout();
366 
367  // user could reactivate by code?
368  if($ilSetting->get('user_reactivate_code'))
369  {
370  return $this->showCodeForm($username);
371  }
372 
373  session_destroy();
374 
375  $failure = $lng->txt("time_limit_reached");
376  break;
377 
378  case AUTH_USER_INACTIVE:
380  $ilAuth->logout();
381  session_destroy();
382 
383  $failure = $lng->txt("err_inactive");
384  break;
385 
386  // special cases end
387 
388 
389  case AUTH_WRONG_LOGIN:
390  default:
391  $add = "";
392  $auth_error = $ilias->getAuthError();
393  if (is_object($auth_error))
394  {
395  $add = "<br>".$auth_error->getMessage();
396  }
397  $failure = $lng->txt("err_wrong_login").$add;
398  break;
399  }
400  }
401 
402  if (isset($_GET['cu']) && $_GET['cu'])
403  {
404  $lng->loadLanguageModule("auth");
405  $success = $lng->txt("auth_account_code_used");
406  }
407 
408 
409  // --- render
410 
411  // Instantiate login template
412  self::initStartUpTemplate("tpl.login.html");
413 
414  // we need the template for this
415  if($failure)
416  {
418  }
419  else if($success)
420  {
422  }
423 
424  // Draw single page editor elements
425  $page_editor_html = $this->getLoginPageEditorHTML();
426  $page_editor_html = $this->showLoginInformation($page_editor_html);
427  $page_editor_html = $this->showLoginForm($page_editor_html);
428  $page_editor_html = $this->showCASLoginForm($page_editor_html);
429  $page_editor_html = $this->showShibbolethLoginForm($page_editor_html);
430  $page_editor_html = $this->showRegistrationLinks($page_editor_html);
431  $page_editor_html = $this->showTermsOfServiceLink($page_editor_html);
432  $page_editor_html = $this->purgePlaceholders($page_editor_html);
433 
434  // not controlled by login page editor
435  $tpl->setVariable("PAGETITLE", "- ".$lng->txt("startpage"));
436  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
437 
438  $this->ctrl->setTargetScript("ilias.php");
439  $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
440 
441  // browser does not accept cookies
442  if (isset($_GET['cookies']) && $_GET['cookies'] == 'nocookies')
443  {
444  ilUtil::sendFailure($lng->txt("err_no_cookies"));
445  }
446 
447  if(strlen($page_editor_html))
448  {
449  $tpl->setVariable('LPE',$page_editor_html);
450  }
451 
452  $tpl->fillWindowTitle();
453  $tpl->fillCssFiles();
454  $tpl->fillJavaScriptFiles();
455 
456  $tpl->show("DEFAULT", false);
457  }
458 
459  protected function showCodeForm($a_username = null, $a_form = null)
460  {
461  global $tpl, $lng;
462 
463  self::initStartUpTemplate("tpl.login_reactivate_code.html");
464 
465  ilUtil::sendFailure($lng->txt("time_limit_reached"));
466 
467  if(!$a_form)
468  {
469  $a_form = $this->initCodeForm($a_username);
470  }
471 
472  $tpl->setVariable("FORM", $a_form->getHTML());
473  $tpl->show("DEFAULT", false);
474  }
475 
476  protected function initCodeForm($a_username)
477  {
478  global $lng, $ilCtrl;
479 
480  $lng->loadLanguageModule("auth");
481 
482  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
483 
484  $form = new ilPropertyFormGUI();
485  $form->setFormAction($ilCtrl->getFormAction($this, 'showcodeform'));
486  $form->setTitle($lng->txt('auth_account_code_title'));
487 
488  $count = new ilTextInputGUI($lng->txt('auth_account_code'), 'code');
489  $count->setRequired(true);
490  $count->setInfo($lng->txt('auth_account_code_info'));
491  $form->addItem($count);
492 
493  // #11658
494  $uname = new ilHiddenInputGUI("uname");
495  $uname->setValue($a_username);
496  $form->addItem($uname);
497 
498  $form->addCommandButton('processCode', $lng->txt('send'));
499 
500  return $form;
501  }
502 
510  protected function processCode()
511  {
512  global $lng, $ilAuth, $ilCtrl;
513 
514  $uname = $_POST["uname"];
515 
516  $form = $this->initCodeForm($uname);
517  if($uname && $form->checkInput())
518  {
519  $code = $form->getInput("code");
520 
521  include_once "Services/User/classes/class.ilAccountCode.php";
523  {
524  $valid_until = ilAccountCode::getCodeValidUntil($code);
525 
526  if(!$user_id = ilObjUser::_lookupId($uname))
527  {
528  $this->showLogin();
529  return false;
530  }
531 
532  $invalid_code = false;
533  $user = new ilObjUser($user_id);
534 
535  if($valid_until === "0")
536  {
537  $user->setTimeLimitUnlimited(true);
538  }
539  else
540  {
541  if(is_numeric($valid_until))
542  {
543  $valid_until = strtotime("+".$valid_until."days");
544  }
545  else
546  {
547  $valid_until = explode("-", $valid_until);
548  $valid_until = mktime(23, 59, 59, $valid_until[1],
549  $valid_until[2], $valid_until[0]);
550  if($valid_until < time())
551  {
552  $invalid_code = true;
553  }
554  }
555 
556  if(!$invalid_code)
557  {
558  $user->setTimeLimitUnlimited(false);
559  $user->setTimeLimitUntil($valid_until);
560  }
561  }
562 
563  if(!$invalid_code)
564  {
565  $user->setActive(true);
566 
568 
569  // apply registration code role assignments
571 
572  // apply registration code time limits
574 
575  $user->update();
576 
577  $ilCtrl->setParameter($this, "cu", 1);
578  $GLOBALS['DIC']->language()->loadLanguageModule('auth');
579  ilUtil::sendSuccess($GLOBALS['DIC']->language()->txt('auth_activation_code_success'),true);
580  $ilCtrl->redirect($this, "showLoginPage");
581  }
582  }
583 
584  $lng->loadLanguageModule("user");
585  $field = $form->getItemByPostVar("code");
586  $field->setAlert($lng->txt("user_account_code_not_valid"));
587  }
588 
589  $form->setValuesByPost();
590  $this->showCodeForm($uname, $form);
591  }
592 
593 
598  protected function initStandardLoginForm()
599  {
600  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
601  $form = new ilPropertyFormGUI();
602  $form->setFormAction($this->ctrl->getFormAction($this,''));
603  $form->setName("formlogin");
604  $form->setShowTopButtons(false);
605  $form->setTitle($this->lng->txt("login_to_ilias"));
606 
607  include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
609 
610  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
611  {
612  $visible_auth_methods = array();
613  $radg = new ilRadioGroupInputGUI($this->lng->txt("auth_selection"), "auth_mode");
614  foreach(ilAuthUtils::_getMultipleAuthModeOptions($this->lng) as $key => $option)
615  {
616  if(isset($option['hide_in_ui']) && $option['hide_in_ui'])
617  {
618  continue;
619  }
620 
621  $op1 = new ilRadioOption($option['txt'], $key);
622  $radg->addOption($op1);
623  if (isset($option['checked']))
624  {
625  $radg->setValue($key);
626  }
627  $visible_auth_methods[] = $op1;
628  }
629 
630  if(count($visible_auth_methods) == 1)
631  {
632  $first_auth_method = current($visible_auth_methods);
633  $hidden_auth_method = new ilHiddenInputGUI("auth_mode");
634  $hidden_auth_method->setValue($first_auth_method->getValue());
635  $form->addItem($hidden_auth_method);
636  }
637  else
638  {
639  $form->addItem($radg);
640  }
641  }
642 
643  $ti = new ilTextInputGUI($this->lng->txt("username"), "username");
644  $ti->setSize(20);
645  $ti->setRequired(true);
646  $form->addItem($ti);
647 
648  $pi = new ilPasswordInputGUI($this->lng->txt("password"), "password");
649  $pi->setUseStripSlashes(false);
650  $pi->setRetype(false);
651  $pi->setSkipSyntaxCheck(true);
652  $pi->setSize(20);
653  $pi->setDisableHtmlAutoComplete(false);
654  $pi->setRequired(true);
655  $form->addItem($pi);
656 
657  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
658  if(ilCaptchaUtil::isActiveForLogin())
659  {
660  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
661  $captcha = new ilCaptchaInputGUI($this->lng->txt('captcha_code'), 'captcha_code');
662  $captcha->setRequired(true);
663  $form->addItem($captcha);
664  }
665 
666  $form->addCommandButton("doStandardAuthentication", $this->lng->txt("log_in"));
667 
668  return $form;
669  }
670 
674  protected function doShibbolethAuthentication()
675  {
676  $this->getLogger()->debug('Trying shibboleth authentication');
677 
678  include_once './Services/AuthShibboleth/classes/class.ilAuthFrontendCredentialsShibboleth.php';
679  $credentials = new ilAuthFrontendCredentialsShibboleth();
680  $credentials->initFromRequest();
681 
682  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
683  $provider_factory = new ilAuthProviderFactory();
684  $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_SHIBBOLETH);
685 
686  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
687  $status = ilAuthStatus::getInstance();
688 
689  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
690  $frontend_factory = new ilAuthFrontendFactory();
691  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
692  $frontend = $frontend_factory->getFrontend(
693  $GLOBALS['DIC']['ilAuthSession'],
694  $status,
695  $credentials,
697  );
698 
699  $frontend->authenticate();
700 
701  switch($status->getStatus())
702  {
704  ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
705  include_once './Services/Init/classes/class.ilInitialisation.php';
706  ilInitialisation::redirectToStartingPage();
707  return;
708 
710  return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
711 
713  ilUtil::sendFailure($status->getTranslatedReason(),true);
714  $GLOBALS['ilCtrl']->redirect($this, 'showLoginPage');
715  return false;
716  }
717 
718  ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
719  $this->showLoginPage();
720  return false;
721  }
722 
726  protected function doCasAuthentication()
727  {
728  global $DIC;
729 
730  $this->getLogger()->debug('Trying cas authentication');
731 
732  include_once './Services/CAS/classes/class.ilAuthFrontendCredentialsCAS.php';
733  $credentials = new ilAuthFrontendCredentialsCAS();
734 
735  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
736  $provider_factory = new ilAuthProviderFactory();
737  $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_CAS);
738 
739  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
740  $status = ilAuthStatus::getInstance();
741 
742  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
743  $frontend_factory = new ilAuthFrontendFactory();
744  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
745  $frontend = $frontend_factory->getFrontend(
746  $GLOBALS['DIC']['ilAuthSession'],
747  $status,
748  $credentials,
750  );
751 
752  $frontend->authenticate();
753  switch($status->getStatus()) {
755  $this->getLogger()->debug('Authentication successful.');
756  ilInitialisation::redirectToStartingPage();
757  break;
758 
760  default:
761  ilUtil::sendFailure($DIC->language()->txt($status->getReason()));
762  $this->showLoginPage();
763  return false;
764  }
765  }
766 
767 
771  protected function doApacheAuthentication()
772  {
773  $this->getLogger()->debug('Trying apache authentication');
774 
775  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentialsApache.php';
776  $credentials = new ilAuthFrontendCredentialsApache();
777  $credentials->initFromRequest();
778 
779  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
780  $provider_factory = new ilAuthProviderFactory();
781  $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_APACHE);
782 
783  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
784  $status = ilAuthStatus::getInstance();
785 
786  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
787  $frontend_factory = new ilAuthFrontendFactory();
788  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
789  $frontend = $frontend_factory->getFrontend(
790  $GLOBALS['DIC']['ilAuthSession'],
791  $status,
792  $credentials,
794  );
795 
796  $frontend->authenticate();
797 
798  switch($status->getStatus())
799  {
801  ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
802  if($credentials->hasValidTargetUrl())
803  {
804  ilUtil::redirect($credentials->getTargetUrl());
805  }
806  else
807  {
808  require_once './Services/Init/classes/class.ilInitialisation.php';
809  ilInitialisation::redirectToStartingPage();
810  }
811  return;
812 
814  return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
815 
817  ilUtil::sendFailure($status->getTranslatedReason(), true);
820  $GLOBALS['ilCtrl']->getLinkTarget($this, 'showLoginPage', '', false, false),
821  'passed_sso=1'
822  )
823  );
824  return false;
825  }
826 
827  ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
828  $this->showLoginPage();
829  return false;
830  }
831 
835  protected function doStandardAuthentication()
836  {
837  $form = $this->initStandardLoginForm();
838  if($form->checkInput())
839  {
840  $this->getLogger()->debug('Trying to authenticate user.');
841 
842  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
843  $credentials = new ilAuthFrontendCredentials();
844  $credentials->setUsername($form->getInput('username'));
845  $credentials->setPassword($form->getInput('password'));
846  $credentials->setCaptchaCode($form->getInput('captcha_code'));
847 
848  // set chosen auth mode
849  include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
851  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
852  {
853  $credentials->setAuthMode($form->getInput('auth_mode'));
854  }
855 
856  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
857  $provider_factory = new ilAuthProviderFactory();
858  $providers = $provider_factory->getProviders($credentials);
859 
860  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
861  $status = ilAuthStatus::getInstance();
862 
863  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
864  $frontend_factory = new ilAuthFrontendFactory();
865  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
866  $frontend = $frontend_factory->getFrontend(
867  $GLOBALS['DIC']['ilAuthSession'],
868  $status,
869  $credentials,
870  $providers
871  );
872 
873  $frontend->authenticate();
874 
875  switch($status->getStatus())
876  {
878  ilLoggerFactory::getLogger('auth')->debug('Authentication successful; Redirecting to starting page.');
879  include_once './Services/Init/classes/class.ilInitialisation.php';
880  ilInitialisation::redirectToStartingPage();
881  return;
882 
884  return $this->showCodeForm(ilObjUser::_lookupLogin($status->getAuthenticatedUserId()));
885 
887  return $GLOBALS['ilCtrl']->redirect($this, 'showAccountMigration');
888 
890  ilUtil::sendFailure($status->getTranslatedReason());
891  return $this->showLoginPage($form);
892  }
893 
894  }
895  ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
896  $this->showLoginPage($form);
897  return false;
898  }
899 
900 
901 
902 
903 
909  protected function showLoginForm($page_editor_html, ilPropertyFormGUI $form = null)
910  {
911  global $ilSetting,$lng,$tpl;
912 
913  // @todo move this to auth utils.
914  // login via ILIAS (this also includes radius and ldap)
915  // If local authentication is enabled for shibboleth users, we
916  // display the login form for ILIAS here.
917  if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
918  $ilSetting->get("shib_auth_allow_local")) &&
919  $ilSetting->get("auth_mode") != AUTH_CAS)
920  {
921  if(!$form instanceof ilPropertyFormGUI)
922  {
923  $form = $this->initStandardLoginForm();
924  }
925 
926  return $this->substituteLoginPageElements(
927  $tpl,
928  $page_editor_html,
929  $form->getHTML(),
930  '[list-login-form]',
931  'LOGIN_FORM'
932  );
933 
934  }
935  return $page_editor_html;
936  }
937 
943  protected function showLoginInformation($page_editor_html)
944  {
945  global $lng,$tpl;
946 
947  if(strlen($page_editor_html))
948  {
949  // page editor active return
950  return $page_editor_html;
951  }
952 
953  $loginSettings = new ilSetting("login_settings");
954  $information = $loginSettings->get("login_message_".$lng->getLangKey());
955 
956  if(strlen(trim($information)))
957  {
958  $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
959  }
960  return $page_editor_html;
961  }
962 
969  protected function showCASLoginForm($page_editor_html)
970  {
971  global $ilSetting, $lng;
972 
973 
974  // cas login link
975  if ($ilSetting->get("cas_active"))
976  {
977  $tpl = new ilTemplate('tpl.login_form_cas.html', true, true, 'Services/Init');
978  $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
979  $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.png"));
980  $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
981  $this->ctrl->setParameter($this, "forceCASLogin", "1");
982  $tpl->setVariable("TARGET_CAS_LOGIN",$this->ctrl->getLinkTarget($this, "doCasAuthentication"));
983  $this->ctrl->setParameter($this, "forceCASLogin", "");
984 
985  return $this->substituteLoginPageElements(
986  $GLOBALS['tpl'],
987  $page_editor_html,
988  $tpl->get(),
989  '[list-cas-login-form]',
990  'CAS_LOGIN_FORM'
991  );
992  }
993  return $page_editor_html;
994  }
995 
1001  protected function showShibbolethLoginForm($page_editor_html)
1002  {
1003  global $ilSetting, $lng;
1004 
1005  // Refactoring with ilFormPropertyGUI
1006  // [...]
1007 
1008  // shibboleth login link
1009  if ($ilSetting->get("shib_active")) {
1010  $tpl = new ilTemplate('tpl.login_form_shibboleth.html', true, true, 'Services/Init');
1011 
1012  $tpl->setVariable('SHIB_FORMACTION', './shib_login.php'); // Bugfix http://ilias.de/mantis/view.php?id=10662 {$tpl->setVariable('SHIB_FORMACTION', $this->ctrl->getFormAction($this));}
1013 
1014  if ($ilSetting->get("shib_hos_type") == 'external_wayf') {
1015  $tpl->setCurrentBlock("shibboleth_login");
1016  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
1017  $tpl->setVariable("IL_TARGET", $_GET["target"]);
1018  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
1019  $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
1020  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", sprintf($lng->txt("shib_general_login_instructions"), $ilSetting->get("shib_federation_name")) . ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt("administrator") . '</a>.');
1021  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
1022  $tpl->parseCurrentBlock();
1023  } elseif ($ilSetting->get("shib_hos_type") == 'embedded_wayf') {
1024  $tpl->setCurrentBlock("shibboleth_custom_login");
1025  $customInstructions = stripslashes($ilSetting->get("shib_login_instructions"));
1026  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $customInstructions);
1027  $tpl->parseCurrentBlock();
1028  } else {
1029  $tpl->setCurrentBlock("shibboleth_wayf_login");
1030  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
1031  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
1032  $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
1033  $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
1034  $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
1035  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $lng->txt("shib_general_wayf_login_instructions") . ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt("administrator") . '</a>.');
1036  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
1037 
1038  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
1039  $WAYF = new ShibWAYF();
1040 
1041  $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
1042  $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
1043  $tpl->setVariable("ILW_TARGET", $_GET["target"]);
1044  $tpl->parseCurrentBlock();
1045  }
1046 
1047  return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, $tpl->get(), '[list-shibboleth-login-form]', 'SHIB_LOGIN_FORM');
1048  }
1049 
1050  return $page_editor_html;
1051  }
1052 
1053 
1063  protected function substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
1064  {
1065  if(!strlen($page_editor_html))
1066  {
1067  $tpl->setVariable($fallback_tplvar,$element_html);
1068  return $page_editor_html;
1069  }
1070  // Try to replace placeholders
1071  if(!stristr($page_editor_html, $placeholder))
1072  {
1073  $tpl->setVariable($fallback_tplvar,$element_html);
1074  return $page_editor_html;
1075  }
1076  return str_replace($placeholder, $element_html, $page_editor_html);
1077  }
1078 
1083  protected function getLoginPageEditorHTML()
1084  {
1085  global $lng, $tpl;
1086 
1087  include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
1089  $active_lang = $lpe->getIliasEditorLanguage($lng->getLangKey());
1090 
1091  if(!$active_lang)
1092  {
1093  return '';
1094  }
1095 
1096  // if page does not exist, return nothing
1097  include_once './Services/COPage/classes/class.ilPageUtil.php';
1098  if(!ilPageUtil::_existsAndNotEmpty('auth', ilLanguage::lookupId($active_lang)))
1099  {
1100  return '';
1101  }
1102 
1103  include_once './Services/Authentication/classes/class.ilLoginPage.php';
1104  include_once './Services/Authentication/classes/class.ilLoginPageGUI.php';
1105 
1106  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1107  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0));
1108  $tpl->setCurrentBlock("SyntaxStyle");
1109  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",ilObjStyleSheet::getSyntaxStylePath());
1110  $tpl->parseCurrentBlock();
1111 
1112  // get page object
1113  $page_gui = new ilLoginPageGUI(ilLanguage::lookupId($active_lang));
1114 
1115  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1116  $page_gui->setStyleId(0, 'auth');
1117 
1118  $page_gui->setPresentationTitle("");
1119  $page_gui->setTemplateOutput(false);
1120  $page_gui->setHeader("");
1121  $ret = $page_gui->showPage();
1122 
1123  return $ret;
1124  }
1125 
1134  protected function showRegistrationLinks($page_editor_html)
1135  {
1136  global $lng, $ilSetting, $ilIliasIniFile, $ilAccess;
1137 
1138  $rtpl = new ilTemplate('tpl.login_registration_links.html',true,true,'Services/Init');
1139 
1140  // allow new registrations?
1141  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
1143  {
1144  $rtpl->setCurrentBlock("new_registration");
1145  $rtpl->setVariable("REGISTER", $lng->txt("registration"));
1146  $rtpl->setVariable("CMD_REGISTER",
1147  $this->ctrl->getLinkTargetByClass("ilaccountregistrationgui", ""));
1148  $rtpl->parseCurrentBlock();
1149  }
1150  // allow password assistance? Surpress option if Authmode is not local database
1151  if ($ilSetting->get("password_assistance"))
1152  {
1153  $rtpl->setCurrentBlock("password_assistance");
1154  $rtpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
1155  $rtpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
1156  $rtpl->setVariable("CMD_FORGOT_PASSWORD",
1157  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
1158  $rtpl->setVariable("CMD_FORGOT_USERNAME",
1159  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
1160  $rtpl->setVariable("LANG_ID", $lng->getLangKey());
1161  $rtpl->parseCurrentBlock();
1162  }
1163 
1164  if ($ilSetting->get("pub_section") &&
1165  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", ROOT_FOLDER_ID))
1166  {
1167  $rtpl->setCurrentBlock("homelink");
1168  $rtpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$lng->getLangKey());
1169  $rtpl->setVariable("TXT_HOME",$lng->txt("home"));
1170  $rtpl->parseCurrentBlock();
1171  }
1172 
1173  if ($ilIliasIniFile->readVariable("clients","list"))
1174  {
1175  $rtpl->setCurrentBlock("client_list");
1176  $rtpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1177  $rtpl->setVariable("CMD_CLIENT_LIST",$this->ctrl->getLinkTarget($this, "showClientList"));
1178  $rtpl->parseCurrentBlock();
1179  }
1180 
1181  return $this->substituteLoginPageElements(
1182  $GLOBALS['tpl'],
1183  $page_editor_html,
1184  $rtpl->get(),
1185  '[list-registration-link]',
1186  'REG_PWD_CLIENT_LINKS'
1187  );
1188  }
1189 
1195  protected function showTermsOfServiceLink($page_editor_html)
1196  {
1200  global $lng;
1201 
1202 
1203  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
1205  if(ilTermsOfServiceHelper::isEnabled() && $document->exists())
1206  {
1207  $utpl = new ilTemplate('tpl.login_terms_of_service_link.html', true, true, 'Services/Init');
1208  $utpl->setVariable('TXT_TERMS_OF_SERVICE', $lng->txt('usr_agreement'));
1209  $utpl->setVariable('LINK_TERMS_OF_SERVICE', $this->ctrl->getLinkTarget($this, 'showTermsOfService'));
1210 
1211  return $this->substituteLoginPageElements(
1212  $GLOBALS['tpl'],
1213  $page_editor_html,
1214  $utpl->get(),
1215  '[list-user-agreement]',
1216  'USER_AGREEMENT'
1217  );
1218  }
1219 
1220  return $this->substituteLoginPageElements(
1221  $GLOBALS['tpl'],
1222  $page_editor_html,
1223  '',
1224  '[list-user-agreement]',
1225  'USER_AGREEMENT'
1226  );
1227  }
1228 
1234  protected function purgePlaceholders($page_editor_html)
1235  {
1236  return str_replace(
1237  array(
1238  '[list-language-selection] ',
1239  '[list-registration-link]',
1240  '[list-user-agreement]',
1241  '[list-login-form]',
1242  '[list-cas-login-form]',
1243  '[list-shibboleth-login-form]'
1244  ),
1245  array('','','','','','',''),
1246  $page_editor_html
1247  );
1248  }
1249 
1254  public function showAccountMigration($a_message = '')
1255  {
1260  global $tpl, $lng;
1261 
1262  $lng->loadLanguageModule('auth');
1263  self::initStartUpTemplate('tpl.login_account_migration.html');
1264 
1265  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1266  $form = new ilPropertyFormGUI();
1267  $form->setFormAction($this->ctrl->getFormAction($this,'migrateAccount'));
1268 
1269  $form->setTitle($lng->txt('auth_account_migration'));
1270  $form->addCommandButton('migrateAccount', $lng->txt('save'));
1271  $form->addCommandButton('showLogin', $lng->txt('cancel'));
1272 
1273  $rad = new ilRadioGroupInputGUI($lng->txt('auth_account_migration_name'),'account_migration');
1274  $rad->setValue(1);
1275 
1276  $keep = new ilRadioOption(
1277  $lng->txt('auth_account_migration_keep'),
1278  static::ACCOUNT_MIGRATION_MIGRATE,
1279  $lng->txt('auth_info_migrate')
1280  );
1281  $user = new ilTextInputGUI($lng->txt('login'),'mig_username');
1282  $user->setRequired(true);
1283  $user->setValue(ilUtil::prepareFormOutput($_POST['mig_username']));
1284  $user->setSize(32);
1285  $user->setMaxLength(128);
1286  $keep->addSubItem($user);
1287 
1288  $pass = new ilPasswordInputGUI($lng->txt('password'),'mig_password');
1289  $pass->setRetype(false);
1290  $pass->setRequired(true);
1291  $pass->setValue(ilUtil::prepareFormOutput($_POST['mig_password']));
1292  $pass->setSize(12);
1293  $pass->setMaxLength(128);
1294  $keep->addSubItem($pass);
1295  $rad->addOption($keep);
1296 
1297  $new = new ilRadioOption(
1298  $lng->txt('auth_account_migration_new'),
1299  static::ACCOUNT_MIGRATION_NEW,
1300  $lng->txt('auth_info_add')
1301  );
1302  $rad->addOption($new);
1303 
1304  $form->addItem($rad);
1305 
1306  $tpl->setVariable('MIG_FORM',$form->getHTML());
1307 
1308  if(strlen($a_message))
1309  {
1310  ilUtil::sendFailure($a_message);
1311  }
1312 
1313  $tpl->show('DEFAULT');
1314  }
1315 
1320  protected function migrateAccount()
1321  {
1322  if(!isset($_POST['account_migration']))
1323  {
1324  $this->showAccountMigration(
1325  $GLOBALS['DIC']->language()->txt('err_choose_migration_type')
1326  );
1327  return false;
1328  }
1329 
1330  if(
1331  ($_POST['account_migration'] == self::ACCOUNT_MIGRATION_MIGRATE) &&
1332  (!strlen($_POST['mig_username']) || !strlen($_POST['mig_password']))
1333  )
1334  {
1335  $this->showAccountMigration(
1336  $GLOBALS['DIC']->language()->txt('err_wrong_login')
1337  );
1338  return false;
1339  }
1340 
1341  if((int) $_POST['account_migration'] == self::ACCOUNT_MIGRATION_MIGRATE)
1342  {
1343  return $this->doMigration();
1344  }
1345  if((int) $_POST['account_migration'] == static::ACCOUNT_MIGRATION_NEW)
1346  {
1347  return $this->doMigrationNewAccount();
1348  }
1349  }
1350 
1354  protected function doMigrationNewAccount()
1355  {
1356  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontend.php';
1357 
1358  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
1359  $credentials = new ilAuthFrontendCredentials();
1360  $credentials->setUsername(ilSession::get(ilAuthFrontend::MIG_EXTERNAL_ACCOUNT));
1361 
1362  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
1363  $provider_factory = new ilAuthProviderFactory();
1364  $provider = $provider_factory->getProviderByAuthMode($credentials, ilSession::get(ilAuthFrontend::MIG_TRIGGER_AUTHMODE));
1365 
1366  $this->logger->debug('Using provider: ' . get_class($provider).' for further processing.');
1367 
1368  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
1369  $status = ilAuthStatus::getInstance();
1370 
1371  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
1372  $frontend_factory = new ilAuthFrontendFactory();
1373  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1374  $frontend = $frontend_factory->getFrontend(
1375  $GLOBALS['DIC']['ilAuthSession'],
1376  $status,
1377  $credentials,
1378  array($provider)
1379  );
1380 
1381  if($frontend->migrateAccountNew())
1382  {
1383  include_once './Services/Init/classes/class.ilInitialisation.php';
1384  ilInitialisation::redirectToStartingPage();
1385  }
1386 
1387  ilUtil::sendFailure($this->lng->txt('err_wrong_login'));
1388  $this->ctrl->redirect($this, 'showAccountMigration');
1389  }
1390 
1391 
1392 
1393 
1397  protected function doMigration()
1398  {
1399  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1400 
1401  $this->logger->debug('Starting account migration for user: ' . (string) ilSession::get('mig_ext_account'));
1402 
1403  // try database authentication
1404  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
1405  $credentials = new ilAuthFrontendCredentials();
1406  $credentials->setUsername((string) $_POST['mig_username']);
1407  $credentials->setPassword((string) $_POST['mig_password']);
1408 
1409  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
1410  $provider_factory = new ilAuthProviderFactory();
1411  $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_LOCAL);
1412 
1413  include_once './Services/Authentication/classes/class.ilAuthStatus.php';
1414  $status = ilAuthStatus::getInstance();
1415 
1416  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
1417  $frontend_factory = new ilAuthFrontendFactory();
1418  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1419  $frontend = $frontend_factory->getFrontend(
1420  $GLOBALS['DIC']['ilAuthSession'],
1421  $status,
1422  $credentials,
1423  array($provider)
1424  );
1425 
1426  $frontend->authenticate();
1427 
1428  switch($status->getStatus())
1429  {
1431  $this->getLogger()->debug('Account migration: authentication successful for ' . (string) $_POST['mig_username']);
1432 
1433  $provider = $provider_factory->getProviderByAuthMode(
1434  $credentials,
1436  );
1437  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
1438  $frontend = $frontend_factory->getFrontend(
1439  $GLOBALS['DIC']['ilAuthSession'],
1440  $status,
1441  $credentials,
1442  array($provider)
1443  );
1444  if(
1445  $frontend->migrateAccount($GLOBALS['DIC']['ilAuthSession'])
1446  )
1447  {
1448  include_once './Services/Init/classes/class.ilInitialisation.php';
1449  ilInitialisation::redirectToStartingPage();
1450  }
1451  else
1452  {
1453  ilUtil::sendFailure($this->lng->txt('err_wrong_login'),true);
1454  $this->ctrl->redirect($this, 'showAccountMigration');
1455  }
1456  break;
1457 
1458  default:
1459  $this->getLogger()->info('Account migration failed for user ' . (string) $_POST['mig_username']);
1460  $this->showAccountMigration($GLOBALS['lng']->txt('err_wrong_login'));
1461  return false;
1462  }
1463  }
1464 
1465 
1472  public function migrateAccount2()
1473  {
1474  global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
1475 
1476  $lng->loadLanguageModule('auth');
1477 
1478  if(!isset($_POST['account_migration']))
1479  {
1480  $this->showAccountMigration($lng->txt('err_choose_migration_type'));
1481  return false;
1482  }
1483 
1484  if(
1485  $_POST['account_migration'] == static::ACCOUNT_MIGRATION_MIGRATE and
1486  (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
1487  {
1488  $this->showAccountMigration($lng->txt('err_wrong_login'));
1489  return false;
1490  }
1491 
1492  if($_POST['account_migration'] == static::ACCOUNT_MIGRATION_MIGRATE)
1493  {
1494  if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
1495  {
1496  $this->showAccountMigration($lng->txt('err_wrong_login'));
1497  return false;
1498  }
1499  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1500  include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
1501 
1502  // try database authentication
1503  include_once './Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
1504  $credentials = new ilAuthFrontendCredentials();
1505  $credentials->setUsername($_POST['mig_username']);
1506  $credentials->setPassword($_POST['mig_password']);
1507 
1508  // set chosen auth mode
1509  include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
1511  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
1512  {
1513  $credentials->setAuthMode($form->getInput('auth_mode'));
1514  }
1515 
1516  include_once './Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
1517  $provider_factory = new ilAuthProviderFactory();
1518  $provider = $provider_factory->getProviderByAuthMode($credentials, AUTH_LOCAL);
1519  $provider->getProviderByAuthMode($credentials, AUTH_LOCAL);
1520 
1521  $status = new ilAuthStatus();
1522  $provider->doAuthentication($status);
1523  switch($status->getStatus())
1524  {
1526  break;
1527 
1528  default:
1529  $this->showAccountMigration($lng->txt('err_wrong_login'));
1530  return false;
1531  }
1532  // auth success
1533 
1534 
1535 
1537  $ilAuth->start();
1538  if(!$ilAuth->checkAuth())
1539  {
1540  $ilAuth->logout();
1541  $this->showAccountMigration($lng->txt('err_wrong_login'));
1542  return false;
1543  }
1544 
1545  $user = new ilObjUser($user_id);
1546  $user->setAuthMode(ilSession::get('tmp_auth_mode'));
1547 
1548  ilLoggerFactory::getLogger('auth')->debug('Auth mode is: ' . ilSession::get('tmp_auth_mode'));
1549 
1550  $user->setExternalAccount(ilSession::get('tmp_external_account'));
1551  $user->setActive(true);
1552  $user->update();
1553 
1554  // Assign to default role
1555  if(is_array(ilSession::get('tmp_roles')))
1556  {
1557  foreach(ilSession::get('tmp_roles') as $role)
1558  {
1559  $rbacadmin->assignUser((int) $role,$user->getId());
1560  }
1561  }
1562 
1563  // Log migration
1564  ilLoggerFactory::getLogger('auth')->info('Migrated '. ilSession::get('tmp_external_account').' to ILIAS account '. $user->getLogin());
1565  }
1566  elseif($_POST['account_migration'] == static::ACCOUNT_MIGRATION_NEW)
1567  {
1568  switch(ilSession::get('tmp_auth_mode_type'))
1569  {
1570  case 'apache':
1571  $_POST['username'] = ilSession::get('tmp_external_account');
1572  $_POST['password'] = ilSession::get('tmp_pass');
1573 
1574  include_once('Services/AuthApache/classes/class.ilAuthContainerApache.php');
1575  $container = new ilAuthContainerApache();
1576  $container->forceCreation(true);
1577  $ilAuth = ilAuthFactory::factory($container);
1578  $ilAuth->start();
1579  break;
1580 
1581  case 'ldap':
1582  $_POST['username'] = ilSession::get('tmp_external_account');
1583  $_POST['password'] = ilSession::get('tmp_pass');
1584  $server_id = ilSession::get('tmp_auth_mode_id');
1585 
1586  include_once('Services/LDAP/classes/class.ilAuthContainerLDAP.php');
1587  $container = new ilAuthContainerLDAP($server_id);
1588  $container->forceCreation(true);
1589  $ilAuth = ilAuthFactory::factory($container);
1590  $ilAuth->start();
1591  break;
1592 
1593  case 'radius':
1594  $_POST['username'] = ilSession::get('tmp_external_account');
1595  $_POST['password'] = ilSession::get('tmp_pass');
1596 
1597  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1598  include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
1599 
1600  $container = new ilAuthContainerRadius();
1601  $container->forceCreation(true);
1602  $ilAuth = ilAuthFactory::factory($container);
1603  $ilAuth->start();
1604  break;
1605  }
1606  }
1607 
1608  include_once './Services/Init/classes/class.ilInitialisation.php';
1609  ilInitialisation::redirectToStartingPage();
1610  return;
1611  }
1612 
1616  function showLogout()
1617  {
1618  global $tpl, $ilSetting, $lng, $ilIliasIniFile;
1619 
1621  $GLOBALS['DIC']['ilAuthSession']->logout();
1622 
1623  $GLOBALS['ilAppEventHandler']->raise(
1624  'Services/Authentication',
1625  'afterLogout',
1626  array(
1627  'username' => $GLOBALS['DIC']->user()->getLogin()
1628  )
1629  );
1630 
1631  // reset cookie
1632  $client_id = $_COOKIE["ilClientId"];
1633  ilUtil::setCookie("ilClientId","");
1634 
1635  //instantiate logout template
1636  self::initStartUpTemplate("tpl.logout.html");
1637 
1638  if ($ilSetting->get("pub_section"))
1639  {
1640  $tpl->setCurrentBlock("homelink");
1641  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1642  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
1643  $tpl->parseCurrentBlock();
1644  }
1645 
1646  if ($ilIliasIniFile->readVariable("clients","list"))
1647  {
1648  $tpl->setCurrentBlock("client_list");
1649  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1650  $this->ctrl->setParameter($this, "client_id", $client_id);
1651  $tpl->setVariable("CMD_CLIENT_LIST",
1652  $this->ctrl->getLinkTarget($this, "showClientList"));
1653  $tpl->parseCurrentBlock();
1654  $this->ctrl->setParameter($this, "client_id", "");
1655  }
1656 
1657  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
1658  $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
1659  $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
1660  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1661 
1662  $tpl->show();
1663  }
1664 
1670  {
1671  global $ilAuth, $tpl, $lng;
1672 
1673  $valid = $ilAuth->getValidationData();
1674 
1675  self::initStartUpTemplate("tpl.user_mapping_selection.html");
1676  $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
1677 
1678 
1679  if ($ilAuth->getSubStatus() == AUTH_WRONG_LOGIN)
1680  {
1681  ilUtil::sendFailure($lng->txt("err_wrong_login"));
1682  }
1683 
1684  include_once('./Services/User/classes/class.ilObjUser.php');
1685  if (count($email_user) == 1)
1686  {
1687  //$user = new ilObjUser(key($email_user));
1688  $tpl->setCurrentBlock("one_user");
1689  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
1690  $tpl->setVariable("VAL_USERNAME", current($email_user));
1691  $tpl->setVariable("USER_ID", key($email_user));
1692  $tpl->parseCurrentBlock();
1693  }
1694  else
1695  {
1696  foreach($email_user as $key => $login)
1697  {
1698  $tpl->setCurrentBlock("user");
1699  $tpl->setVariable("USR_ID", $key);
1700  $tpl->setVariable("VAL_USER", $login);
1701  $tpl->parseCurrentBlock();
1702  }
1703  $tpl->setCurrentBlock("multpiple_user");
1704  $tpl->parseCurrentBlock();
1705  }
1706 
1707  $tpl->setCurrentBlock("content");
1708  $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
1709  $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
1710  $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
1711  $tpl->setVariable("FORMACTION",
1712  $this->ctrl->getFormAction($this));
1713  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
1714  if (count($email_user) == 1)
1715  {
1716  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
1717  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
1718  }
1719  else
1720  {
1721  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
1722  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
1723  }
1724  $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
1725  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
1726  $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
1727  $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
1728 
1729  $tpl->show();
1730  }
1731 
1735  function showClientList()
1736  {
1737  global $tpl, $ilIliasIniFile, $lng;
1738 //echo "1";
1739  if (!$ilIliasIniFile->readVariable("clients","list"))
1740  {
1741  $this->processIndexPHP();
1742  return;
1743  }
1744 //echo "2";
1745  $tpl = new ilTemplate("tpl.main.html", true, true);
1746  $tpl->setAddFooter(false); // no client yet
1747 
1748  $tpl->setVariable("PAGETITLE", $lng->txt("clientlist_clientlist"));
1749  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1750 
1751  // load client list template
1752  self::initStartUpTemplate("tpl.client_list.html");
1753 
1754  // load template for table
1755  $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1756 
1757  // load template for table content data
1758  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1759 
1760  // load table content data
1761  require_once("setup/classes/class.ilClientList.php");
1762  require_once("setup/classes/class.ilClient.php");
1763  require_once("setup/classes/class.ilDBConnections.php");
1764  require_once("./Services/Table/classes/class.ilTableGUI.php");
1765  $this->db_connections = new ilDBConnections();
1766  $clientlist = new ilClientList($this->db_connections);
1767  $list = $clientlist->getClients();
1768 
1769  if (count($list) == 0)
1770  {
1771  header("Location: ./setup/setup.php");
1772  exit();
1773  }
1774 
1775  $hasPublicSection = false;
1776  foreach ($list as $key => $client)
1777  {
1778  $client->setDSN();
1779 
1780  if ($client->checkDatabaseExists(true) and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
1781  {
1782  $this->ctrl->setParameter($this, "client_id", $key);
1783  $tmp = array();
1784  $tmp[] = $client->getName();
1785  $tmp[] = "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">".$lng->txt("clientlist_login_page")."</a>";
1786 
1787  if($client->getSetting('pub_section'))
1788  {
1789  $hasPublicSection = true;
1790  $tmp[] = "<a href=\"" . "ilias.php?baseClass=ilRepositoryGUI&client_id=" . urlencode($key) . "\">".$lng->txt("clientlist_start_page")."</a>";
1791  }
1792  else
1793  {
1794  $tmp[] = '';
1795  }
1796 
1797  $data[] = $tmp;
1798  }
1799  }
1800 
1801  // create table
1802  $tbl = new ilTableGUI();
1803 
1804  // title & header columns
1805  if($hasPublicSection)
1806  {
1807  $tbl->setTitle($lng->txt("clientlist_available_clients"));
1808  $tbl->setHeaderNames(array($lng->txt("clientlist_installation_name"), $lng->txt("clientlist_login"), $lng->txt("clientlist_public_access")));
1809  $tbl->setHeaderVars(array("name","index","login"));
1810  $tbl->setColumnWidth(array("50%","25%","25%"));
1811  }
1812  else
1813  {
1814  $tbl->setTitle($lng->txt("clientlist_available_clients"));
1815  $tbl->setHeaderNames(array($lng->txt("clientlist_installation_name"), $lng->txt("clientlist_login"), ''));
1816  $tbl->setHeaderVars(array("name","login",''));
1817  $tbl->setColumnWidth(array("70%","25%",'1px'));
1818  }
1819 
1820  // control
1821  $tbl->setOrderColumn($_GET["sort_by"],"name");
1822  $tbl->setOrderDirection($_GET["sort_order"]);
1823  $tbl->setLimit($_GET["limit"]);
1824  $tbl->setOffset($_GET["offset"]);
1825 
1826  // content
1827  $tbl->setData($data);
1828 
1829  $tbl->disable("icon");
1830  $tbl->disable("numinfo");
1831  $tbl->disable("sort");
1832  $tbl->disable("footer");
1833 
1834  // render table
1835  $tbl->render();
1836  $tpl->show("DEFAULT", true, true);
1837  }
1838 
1845  {
1846  global $tpl;
1847 
1848  $str = "<p style=\"margin:15px;\">
1849  You need to enable Session Cookies in your Browser to use ILIAS.
1850  <br/>
1851  <br/><b>Firefox</b>
1852  <br/>Tools -> Options -> Privacy -> Cookies
1853  <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
1854  <br/>cookies' auf 'until I close Firefox'
1855  <br/>
1856  <br/><b>Mozilla/Netscape</b>
1857  <br/>Edit -> Preferences -> Privacy&Security -> Cookies
1858  <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
1859  <br/>session only'.
1860  <br/>
1861  <br/><b>Internet Explorer</b>
1862  <br/>Tools -> Internet Options -> Privacy -> Advanced
1863  <br/>- Check 'Override automatic cookie handling'
1864  <br/>- Check 'Always allow session cookies'
1865  </p>";
1866  $tpl->setVariable("CONTENT", $str);
1867  $tpl->show();
1868  }
1869 
1873  protected function getAcceptance()
1874  {
1875  $this->showTermsOfService();
1876  }
1877 
1881  protected function showTermsOfService()
1882  {
1889  global $lng, $tpl, $ilUser, $ilSetting;
1890 
1891  $back_to_login = ('getAcceptance' != $this->ctrl->getCmd());
1892 
1893  self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
1894  $tpl->setVariable('TXT_PAGEHEADLINE', $lng->txt('usr_agreement'));
1895 
1896  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
1898  if($document->exists())
1899  {
1900  if('getAcceptance' == $this->ctrl->getCmd())
1901  {
1902  if(isset($_POST['status']) && 'accepted' == $_POST['status'])
1903  {
1904  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
1905  ilTermsOfServiceHelper::trackAcceptance($ilUser, $document);
1906 
1907  if(ilSession::get('orig_request_target'))
1908  {
1909  $target = ilSession::get('orig_request_target');
1910  ilSession::set('orig_request_target', '');
1912  }
1913  else
1914  {
1915  ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
1916  }
1917  }
1918 
1919  $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
1920  $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
1921  $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $lng->txt('accept_usr_agreement'));
1922  $tpl->setVariable('TXT_SUBMIT', $lng->txt('submit'));
1923  }
1924 
1925  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->getContent());
1926  }
1927  else
1928  {
1929  include_once("./Modules/SystemFolder/classes/class.ilSystemSupportContacts.php");
1930  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', sprintf($lng->txt('no_agreement_description'), 'mailto:' . ilUtil::prepareFormOutput(ilSystemSupportContacts::getMailToAddress())));
1931  }
1932 
1933  $tpl->show();
1934  }
1935 
1939  protected function processIndexPHP()
1940  {
1941  global $ilIliasIniFile, $ilAuth, $ilSetting;
1942 
1943  // In case of an valid session, redirect to starting page
1944  if($GLOBALS['DIC']['ilAuthSession']->isValid())
1945  {
1946  include_once './Services/Init/classes/class.ilInitialisation.php';
1947  ilInitialisation::redirectToStartingPage();
1948  return;
1949  }
1950  else
1951  {
1952 
1953  }
1954 
1955  // no valid session => show client list, if no client info is given
1956  if (
1957  !isset($_GET["client_id"]) &&
1958  ($_GET["cmd"] == "") &&
1959  $ilIliasIniFile->readVariable("clients","list"))
1960  {
1961  return $this->showClientList();
1962  }
1963 
1964  if($GLOBALS['ilSetting']->get('pub_section', false)
1965  )
1966  {
1968  }
1969 
1970  // otherwise show login page
1971  return $this->showLoginPage();
1972  }
1973 
1974 
1975  static function _checkGoto($a_target)
1976  {
1977  global $objDefinition, $ilPluginAdmin, $ilUser;
1978 
1979  if (is_object($ilPluginAdmin))
1980  {
1981  // get user interface plugins
1982  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1983 
1984  // search
1985  foreach ($pl_names as $pl)
1986  {
1987  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1988  $gui_class = $ui_plugin->getUIClassInstance();
1989  $resp = $gui_class->checkGotoHook($a_target);
1990  if ($resp["target"] !== false)
1991  {
1992  $a_target = $resp["target"];
1993  break;
1994  }
1995  }
1996  }
1997 
1998  if ($a_target == "")
1999  {
2000  return false;
2001  }
2002 
2003  $t_arr = explode("_", $a_target);
2004  $type = $t_arr[0];
2005 
2006  if ($type == "git")
2007  {
2008  $type = "glo";
2009  }
2010 
2011  if ($type == "pg" | $type == "st")
2012  {
2013  $type = "lm";
2014  }
2015 
2016  $class = $objDefinition->getClassName($type);
2017  if ($class == "")
2018  {
2019  return false;
2020  }
2021 
2022  $location = $objDefinition->getLocation($type);
2023  $full_class = "ilObj".$class."Access";
2024  include_once($location."/class.".$full_class.".php");
2025 
2026  $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
2027 
2028  // if no access and repository object => check for parent course/group
2029  if(!$ret &&
2030  !stristr($a_target, "_wsp") &&
2031  $ilUser->getId() != ANONYMOUS_USER_ID && // #10637
2032  !$objDefinition->isAdministrationObject($type) &&
2033  $objDefinition->isRBACObject($type) &&
2034  $t_arr[1])
2035  {
2036  global $tree, $rbacsystem, $ilAccess;
2037 
2038  // original type "pg" => pg_<page_id>[_<ref_id>]
2039  if($t_arr[0] == "pg")
2040  {
2041  if(isset($t_arr[2]))
2042  {
2043  $ref_id = $t_arr[2];
2044  }
2045  else
2046  {
2047  $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
2049  if($ref_id)
2050  {
2051  $ref_id = array_shift($ref_id);
2052  }
2053  }
2054  }
2055  else
2056  {
2057  $ref_id = $t_arr[1];
2058  }
2059 
2060  include_once "Services/Membership/classes/class.ilParticipants.php";
2061  $block_obj = array();
2062 
2063  // walk path to find parent container
2064  $path = $tree->getPathId($ref_id);
2065  array_pop($path);
2066  foreach($path as $path_ref_id)
2067  {
2068  $redirect_infopage = false;
2069  $add_member_role = false;
2070 
2071  $ptype = ilObject::_lookupType($path_ref_id, true);
2072  $pobj_id = ilObject::_lookupObjId($path_ref_id);
2073 
2074  // core checks: timings/object-specific
2075  if(!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) ||
2076  !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype))
2077  {
2078  // object in path is inaccessible - aborting
2079  return false;
2080  }
2081  else if($ptype == "crs")
2082  {
2083  // check if already participant
2084  include_once "Modules/Course/classes/class.ilCourseParticipant.php";
2085  $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
2086  if(!$participants->isAssigned())
2087  {
2088  // subscription currently possible?
2089  include_once "Modules/Course/classes/class.ilObjCourse.php";
2090  if(ilObjCourse::_isActivated($pobj_id) &&
2092  {
2093  $block_obj[] = $path_ref_id;
2094  $add_member_role = true;
2095  }
2096  else
2097  {
2098  $redirect_infopage = true;
2099  }
2100  }
2101  }
2102  else if($ptype == "grp")
2103  {
2104  // check if already participant
2105  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
2106  if(!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId()))
2107  {
2108  // subscription currently possible?
2109  include_once "Modules/Group/classes/class.ilObjGroup.php";
2110  $group_obj = new ilObjGroup($path_ref_id);
2111  if($group_obj->isRegistrationEnabled())
2112  {
2113  $block_obj[] = $path_ref_id;
2114  $add_member_role = true;
2115  }
2116  else
2117  {
2118  $redirect_infopage = true;
2119  }
2120  }
2121  }
2122 
2123  // add members roles for all "blocking" objects
2124  if($add_member_role)
2125  {
2126  // cannot join? goto will never work, so redirect to current object
2127  $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
2128  if(!$rbacsystem->checkAccess("join", $path_ref_id))
2129  {
2130  $redirect_infopage = true;
2131  }
2132  else
2133  {
2134  $rbacsystem->addTemporaryRole($ilUser->getId(),
2135  ilParticipants::getDefaultMemberRole($path_ref_id));
2136  }
2137  }
2138 
2139  // redirect to infopage of 1st blocking object in path
2140  if($redirect_infopage)
2141  {
2142  if($rbacsystem->checkAccess("visible", $path_ref_id))
2143  {
2144  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
2145  "&ref_id=".$path_ref_id."&cmd=infoScreen");
2146  }
2147  else
2148  {
2149  return false;
2150  }
2151  }
2152  }
2153 
2154  // check if access will be possible with all (possible) member roles added
2155  $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
2156  if($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) // #12128
2157  {
2158  // this won't work with lm-pages (see above)
2159  // include_once "Services/Link/classes/class.ilLink.php";
2160  // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
2161 
2162  // keep original target
2163  $_SESSION["pending_goto"] = "goto.php?target=".$a_target;
2164 
2165  // redirect to 1st non-member object in path
2166  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
2167  "&ref_id=".array_shift($block_obj));
2168  }
2169  }
2170 
2171  return $ret;
2172  }
2173 
2174  public function confirmRegistration()
2175  {
2176  global $lng, $ilias, $ilLog;
2177 
2178  ilUtil::setCookie('iltest', 'cookie', false);
2179 
2180  if(!isset($_GET['rh']) || !strlen(trim($_GET['rh'])))
2181  {
2182  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
2183  }
2184 
2185  try
2186  {
2187  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
2188  $oRegSettings = new ilRegistrationSettings();
2189 
2190  $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
2191  $oUser = ilObjectFactory::getInstanceByObjId($usr_id);
2192  $oUser->setActive(true);
2193  if($oRegSettings->passwordGenerationEnabled())
2194  {
2195  $passwd = ilUtil::generatePasswords(1);
2196  $password = $passwd[0];
2197  $oUser->setPasswd($password, IL_PASSWD_PLAIN);
2198  $oUser->setLastPasswordChangeTS( time() );
2199  }
2200  $oUser->update();
2201 
2202  $usr_lang = $oUser->getPref('language');
2203 
2204  if($lng->getLangKey() != $usr_lang)
2205  {
2206  $lng = new ilLanguage($usr_lang);
2207  }
2208 
2209  $target = $oUser->getPref('reg_target');
2210  if(strlen($target) > 0)
2211  {
2212  $_GET['target'] = $target;
2213  }
2214 
2215  // send email
2216  // try individual account mail in user administration
2217  include_once("Services/Mail/classes/class.ilAccountMail.php");
2218  include_once './Services/User/classes/class.ilObjUserFolder.php';
2219  $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
2220  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
2221  {
2222  $acc_mail = new ilAccountMail();
2223  $acc_mail->setUser($oUser);
2224  if($oRegSettings->passwordGenerationEnabled())
2225  {
2226  $acc_mail->setUserPassword($password);
2227  }
2228  $acc_mail->send();
2229  }
2230  else // do default mail
2231  {
2232  include_once 'Services/Mail/classes/class.ilMail.php';
2233  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
2234 
2235  // mail subject
2236  $subject = $lng->txt("reg_mail_subject");
2237 
2238  // mail body
2239  $body = $lng->txt("reg_mail_body_salutation")." ".$oUser->getFullname().",\n\n".
2240  $lng->txt("reg_mail_body_text1")."\n\n".
2241  $lng->txt("reg_mail_body_text2")."\n".
2242  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
2243  $body .= $lng->txt("login").": ".$oUser->getLogin()."\n";
2244 
2245  if($oRegSettings->passwordGenerationEnabled())
2246  {
2247  $body.= $lng->txt("passwd").": ".$password."\n";
2248  }
2249 
2250  $body.= "\n";
2251  $body.= $lng->txt('reg_mail_body_forgot_password_info')."\n";
2252 
2253  $body.= "\n";
2254 
2255  $body .= ($lng->txt("reg_mail_body_text3")."\n\r");
2256  $body .= $oUser->getProfileAsString($lng);
2257  $mail_obj->enableSoap(false);
2258  $mail_obj->appendInstallationSignature(true);
2259  $mail_obj->sendMail($oUser->getEmail(), '', '',
2260  $subject,
2261  $body,
2262  array(), array('normal'));
2263  }
2264 
2265  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang='.$usr_lang);
2266  }
2267  catch(ilRegConfirmationLinkExpiredException $exception)
2268  {
2269  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
2270  $soap_client = new ilSoapClient();
2271  $soap_client->setResponseTimeout(1);
2272  $soap_client->enableWSDL(true);
2273  $soap_client->init();
2274 
2275  $ilLog->write(__METHOD__.': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
2276 
2277  $soap_client->call
2278  (
2279  'deleteExpiredDualOptInUserObjects',
2280  array
2281  (
2282  $_COOKIE['PHPSESSID'].'::'.$_COOKIE['ilClientId'], // session id and client id, not used for checking access -> not possible for anonymous
2283  $exception->getCode() // user id
2284  )
2285  );
2286 
2287  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
2288  }
2289  catch(ilRegistrationHashNotFoundException $exception)
2290  {
2291  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
2292  }
2293  }
2294 
2301  public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_show_logout = false)
2302  {
2310  global $tpl, $lng, $ilCtrl, $ilSetting, $ilAccess;
2311 
2312  // #13574 - basic.js is included with ilTemplate, so jQuery is needed, too
2313  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
2315 
2316  // framework is needed for language selection
2317  include_once("./Services/UICore/classes/class.ilUIFramework.php");
2319 
2320  $tpl->addBlockfile('CONTENT', 'content', 'tpl.startup_screen.html', 'Services/Init');
2321  $tpl->setVariable('HEADER_ICON', ilUtil::getImagePath('HeaderIcon.svg'));
2322 
2323  if($a_show_back)
2324  {
2325  // #13400
2326  $param = 'client_id=' . $_COOKIE['ilClientId'] . '&lang=' . $lng->getLangKey();
2327 
2328  $tpl->setCurrentBlock('link_item_bl');
2329  $tpl->setVariable('LINK_TXT', $lng->txt('login_to_ilias'));
2330  $tpl->setVariable('LINK_URL', 'login.php?cmd=force_login&'.$param);
2331  $tpl->parseCurrentBlock();
2332 
2333  if($ilSetting->get('pub_section') &&
2334  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, 'read', '', ROOT_FOLDER_ID))
2335  {
2336  $tpl->setVariable('LINK_URL', 'index.php?'.$param);
2337  $tpl->setVariable('LINK_TXT', $lng->txt('home'));
2338  $tpl->parseCurrentBlock();
2339  }
2340  }
2341  else if($a_show_logout)
2342  {
2343  $tpl->setCurrentBlock('link_item_bl');
2344  $tpl->setVariable('LINK_TXT', $lng->txt('logout'));
2345  $tpl->setVariable('LINK_URL', ILIAS_HTTP_PATH . '/logout.php');
2346  $tpl->parseCurrentBlock();
2347  }
2348 
2349  if(is_array($a_tmpl))
2350  {
2351  $template_file = $a_tmpl[0];
2352  $template_dir = $a_tmpl[1];
2353  }
2354  else
2355  {
2356  $template_file = $a_tmpl;
2357  $template_dir = 'Services/Init';
2358  }
2359 
2360  //Header Title
2361  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
2362  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
2363  if (trim($header_top_title) != "" && $tpl->blockExists("header_top_title"))
2364  {
2365  $tpl->setCurrentBlock("header_top_title");
2366  $tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
2367  $tpl->parseCurrentBlock();
2368  }
2369 
2370  // language selection
2371  $selection = self::getLanguageSelection();
2372  if($selection)
2373  {
2374  $tpl->setCurrentBlock("lang_select");
2375  $tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
2376  $tpl->setVariable("LANG_SELECT", $selection);
2377  $tpl->parseCurrentBlock();
2378  }
2379 
2380  $tpl->addBlockFile('STARTUP_CONTENT', 'startup_content', $template_file, $template_dir);
2381  }
2382 
2387  protected static function getLanguageSelection()
2388  {
2389  include_once("./Services/MainMenu/classes/class.ilMainMenuGUI.php");
2391  }
2392 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
showLogout()
show logout screen
static _lookupLogin($a_user_id)
lookup login
static applyRoleAssignments(ilObjUser $user, $code)
static _checkGoto($a_target)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
ILIAS Setting Class.
const AUTH_MODE_INACTIVE
const ACCOUNT_MIGRATION_MIGRATE
const AUTH_USER_INACTIVE
$path
Definition: aliased.php:25
$failure
const IL_PASSWD_PLAIN
Login page GUI class.
initCodeForm($a_username)
const SESSION_CLOSE_CAPTCHA
showLoginForm($page_editor_html, ilPropertyFormGUI $form=null)
Show login form ilSetting $ilSetting.
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static applyAccessLimits(ilObjUser $user, $code)
showCodeForm($a_username=null, $a_form=null)
const AUTH_USER_WRONG_IP
getLoginPageEditorHTML()
Get HTML of ILIAS login page editor.
Administrates DB connections in setup.
$_SESSION["AccountId"]
static _hasMultipleAuthenticationMethods()
This class represents a property form user interface.
Class ilAccountRegistrationGUI.
This class represents a captcha input in a property form.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
$tbl
Definition: example_048.php:81
const SESSION_CLOSE_INACTIVE
$location
Definition: buildRTE.php:44
static _registrationEnabled($a_obj_id)
Registration enabled? Method is in Access class, since it is needed by Access/ListGUI.
Overwritten Pear class AuthContainerLDAP This class is overwritten to support nested groups...
Class for user related exception handling in ILIAS.
const STATUS_AUTHENTICATION_FAILED
$code
Definition: example_050.php:99
showShibbolethLoginForm($page_editor_html)
Show shibboleth login form.
$valid
const AUTH_CAPTCHA_INVALID
Factory for auth frontend classes.
const AUTH_CAS
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$cmd
Definition: sahs_server.php:35
const AUTH_SHIBBOLETH
static get($a_var)
Get a value.
const AUTH_RADIUS_NO_ILIAS_USER
static useCode($code)
const SESSION_CLOSE_TIME
static set($a_var, $a_val)
Set a value.
static _lookupId($a_user_str)
Lookup id by login.
static goToPublicSection()
go to public section
migrateAccount()
Migrate Account.
const AUTH_CAS_NO_ILIAS_USER
static generatePasswords($a_number)
Generate a number of passwords.
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static init($a_tpl=null)
Init.
static getDefaultMemberRole($a_ref_id)
Class ilTableGUI.
processIndexPHP()
process index.php
const AUTH_APACHE
Authentication against ILIAS database.
getAcceptance()
Get terms of service.
const AUTH_USER_TIME_LIMIT_EXCEEDED
executeCommand()
execute command
Class ShibbolethWAYF.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
doShibbolethAuthentication()
Trying shibboleth authentication.
static _verifyRegistrationHash($a_hash)
Verifies a registration hash.
getLogger()
Get logger.
__construct()
constructor
global $tpl
Definition: ilias.php:8
initStandardLoginForm()
Initialize the standard.
global $ilCtrl
Definition: ilias.php:18
client management
showLogin()
Show login.
$client
showLoginPage(ilPropertyFormGUI $form=null)
const AUTH_APACHE_FAILED
This class represents a hidden form property in a property form.
substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
Substitute login page elements.
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
This class represents a property in a property form.
setValue($a_value)
Set Value.
$success
Definition: Utf8Test.php:86
static getMailToAddress()
Get mailto: email.
setUseStripSlashes($a_stat)
En/disable use of stripslashes.
static _existsAndNotEmpty($a_parent_type, $a_id, $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages) ...
static _getLocalAccountsForEmail($a_email)
check whether external account and authentication method matches with a user
doApacheAuthentication()
Try apache auth.
addSubItem($a_item)
Add Subitem.
const AUTH_SOAP_NO_ILIAS_USER
static _lookupNewAccountMail($a_lang)
static _getMultipleAuthModeOptions($lng)
const SESSION_CLOSE_USER
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class handles base functions for mail handling.
migrateAccount2()
migrate account
static _lookupObjId($a_id)
StartUp GUI class.
doCasAuthentication()
Try CAS auth.
special template class to simplify handling of ITX/PEAR
purgePlaceholders($page_editor_html)
Purge page editor html from unused placeholders.
doMigrationNewAccount()
Create new account for migration.
setSize($a_size)
Set Size.
static getLanguageSelection($a_in_topbar=false)
This class represents a text property in a property form.
showRegistrationLinks($page_editor_html)
Show registration, password forgotten, client slection links ilLanguage $lng ilSetting $ilSetting ...
This class represents a password property in a property form.
$ilUser
Definition: imgupload.php:18
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
showClientList()
show client list
Add a drawing to the header
Definition: 04printing.php:69
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static getSyntaxStylePath()
get syntax style path
const AUTH_LOCAL
doStandardAuthentication()
Check form input; authenticate user.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
Password assistance facility for users who have forgotten their password or for users for whom no pas...
static trackAcceptance(ilObjUser $user, ilTermsOfServiceSignableDocument $document)
static getCodeValidUntil($code)
const AUTH_USER_SIMULTANEOUS_LOGIN
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
doMigration()
Do migration of existing ILIAS database user account.
const AUTH_LDAP_NO_ILIAS_USER
static getContentStylePath($a_style_id)
get content style path
showNoCookiesScreen()
show help screen, if cookies are disabled
const SESSION_CLOSE_SIMUL
Class ilObjAuthSettingsGUI.
static getLanguageSelection()
language selection list
static _isActivated($a_obj_id)
Is activated.
const STATUS_CODE_ACTIVATION_REQUIRED
showUserMappingSelection()
Show user selection screen, if external account could not be mapped to an ILIAS account, but the provided e-mail address is known.
static setClosingContext($a_context)
set closing context (for statistics)
$ref_id
Definition: sahs_server.php:39
static getInstance()
Get status instance.
global $ilSetting
Definition: privfeed.php:17
showLoginInformation($page_editor_html)
Show login information.
Overwritten Pear class AuthContainerRadius This class is overwritten to support to perform Radius aut...
Authentication against ILIAS database.
$ret
Definition: parser.php:6
static lookupId($a_lang_key)
Lookup obj_id of language ilDB $ilDB.
Class ilAccountMail.
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
static factory(ilAuthContainerBase $deco)
The factory.
static initjQuery($a_tpl=null)
Init jQuery.
Class ilObjGroup.
static isUnusedCode($code)
$ilIliasIniFile
language handling
global $DIC
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getInstance()
Get singelton instance.
$client_id
Class for user related exception handling in ILIAS.
static redirect($a_script)
http redirect to other script
Auth status implementation.
showCASLoginForm($page_editor_html)
Show cas login ilSetting $ilSetting.
const STATUS_ACCOUNT_MIGRATION_REQUIRED
$_POST["username"]
setRequired($a_required)
Set Required.
const SESSION_CLOSE_IP
const IL_COMP_SERVICE
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
jumpToPasswordAssistance()
jump to password assistance
jumpToRegistration()
jump to registration gui
Auth frontend credentials for CAS auth.