<?php
require './include/common.inc.php';

if($HS['enableserverpassport'])
{
	$logouturl = $HS['passport_serverurl'].$HS['passport_logouturl'];
	$addstr = $PHP_QUERYSTRING ? $PHP_QUERYSTRING : 'forward='.$PHP_REFERER;
	$logouturl .= (strpos($logouturl, '?') ? '&' : '?').$addstr;
	header('location:'.$logouturl);
	exit;
}

if(!isset($action)) $action = '';

if($action == 'ajax_message')
{
	echo $LANG['logout_success'];
	exit;
}

$member->logout();

if($HS['enablepassport'])
{
	if($action == 'logout_ajax')
	{
		$forward = linkurl($MOD['linkurl'], 1).'logout.php?action=ajax_message';
	}
	else
	{
		$forward = isset($forward) ? linkurl($forward, 1) : $PHP_SITEURL;
	}
	$action = 'logout';
	require MOD_ROOT.'/passport/'.$HS['passport_file'].'.php';
	header('location:'.$url);
	exit;
}

if($action == 'logout_ajax')
{
	echo $LANG['logout_success'];
	exit;
}

if(!$forward) $forward = $PHP_SITEURL;
//showmessage($LANG['logout_success'], $forward);
showmessage($LANG['logout_success'], "/member/index.php");
?>