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