PageRenderTime 30ms CodeModel.GetById 25ms RepoModel.GetById 3ms app.codeStats 0ms

/users/logout.php

http://showslow.googlecode.com/
PHP | 50 lines | 37 code | 8 blank | 5 comment | 9 complexity | 1ed81812a39bf59be691f07e118ccd03 MD5 | raw file
  1. <?php
  2. require_once(dirname(__FILE__).'/config.php');
  3. require_once(dirname(__FILE__).'/User.php');
  4. // first, we need to auto-logout all modules that require that
  5. $autologgedout_module_reached = false;
  6. $module_logout_url = null;
  7. foreach (UserConfig::$authentication_modules as $module) {
  8. if (array_key_exists('autologgedout', $_GET)) {
  9. // skip modules that were already autologged out
  10. if (!$autologgedout_module_reached && $module->getID() == $_GET['autologgedout']) {
  11. $autologgedout_module_reached = true;
  12. continue;
  13. }
  14. if ($autologgedout_module_reached) {
  15. $module_logout_url = $module->getAutoLogoutURL(UserConfig::$USERSROOTFULLURL.'/logout.php?autologgedout='.urlencode($module->getID()));
  16. }
  17. } else {
  18. // if we didn't auto-logout any modules yet, do it for first module
  19. $module_logout_url = $module->getAutoLogoutURL(UserConfig::$USERSROOTFULLURL.'/logout.php?autologgedout='.urlencode($module->getID()));
  20. }
  21. // if we reached a module that needs auto-logout, redirect there
  22. if (!is_null($module_logout_url)) {
  23. header('Location: '.$module_logout_url);
  24. exit;
  25. }
  26. }
  27. // if we're here, it means there were no auto-logout modules or all auto-logouts are complete
  28. User::clearSession();
  29. $user = User::get();
  30. if (!is_null($user)) {
  31. $user->recordActivity(USERBASE_ACTIVITY_LOGOUT);
  32. }
  33. $return = User::getReturn();
  34. User::clearReturn();
  35. if (!is_null($return))
  36. {
  37. header('Location: '.$return);
  38. }
  39. else
  40. {
  41. header('Location: '.UserConfig::$DEFAULTLOGOUTRETURN);
  42. }