Location: PHPKode > projects > DantoBB > DantoBB_1-0/sources/panel_logout.php
<?php

/*
	Copyright (C) 2009 DantoBB Team
	http://www.dantobb.com
*/

/**
 * Panel logout
 *
 * Gives an interface to logout out of user accounts.
 *
 * @author	DantoBB Team
 * @link	http://www.dantobb.com
 * @license	GPL-2
 * @version	$Revision: 1.0 $
 * @copyright	Copyright (C) 2009 DantoBB Team
 * @package	DantoBB
 * @subpackage	Panel
 */

//
// Die when called directly in browser
//
if ( !defined('INCLUDED') )
	exit();

//
// User wants to logout
//
$session->update('logout');

if ( !$session->sess_info['user_id'] ) {
	
	$functions->redirect('index.php');
	
} else {
	
	if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
		
		if ( !empty($_POST['logout']) ) {
			
			$refere_to = $functions->get_config('board_url').$functions->make_url('index.php', array(), false);
			$session->destroy();
			
		} else {
			
			//
			// Get us back to the previous page
			//
			$refere_to = ( !empty($_SESSION['refere_to']) ) ? $functions->attach_sid($_SESSION['refere_to']) : $functions->get_config('board_url').$functions->make_url('index.php', array(), false);
			unset($_SESSION['refere_to']);
			
		}
		
		$functions->raw_redirect($refere_to);
		
	} else {
	
		$_SERVER['HTTP_REFERER'] = ( !empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $functions->get_config('board_url')) === 0 && !preg_match('#(?:login|logout|register|activate|sendpwd|install)#', $_SERVER['HTTP_REFERER']) ) ? $_SERVER['HTTP_REFERER'] : '';
		$_SESSION['refere_to'] = ( !empty($_SESSION['referer']) ) ? $_SESSION['referer'] : $_SERVER['HTTP_REFERER'];
		unset($_SESSION['referer']);
		
		//
		// Include the page header
		//
		require(ROOT_PATH.'sources/page_head.php');
		
		$template->set_page_title(sprintf($lang['LogOut'], unhtml(stripslashes($session->sess_info['user_info']['name']))));
		$template->parse('confirm_form', 'global', array(
			'form_begin' => '<form action="'.$functions->make_url('panel.php', array('act' => 'logout')).'" method="post">',
			'title' => sprintf($lang['LogOut'], unhtml(stripslashes($session->sess_info['user_info']['name']))),
			'content' => $lang['LogOutConfirm'],
			'submit_button' => '<input type="submit" name="logout" value="'.$lang['Yes'].'" />',
			'cancel_button' => '<input type="submit" value="'.$lang['Cancel'].'" />',
			'form_end' => '</form>'
		));
		
		//
		// Include the page footer
		//
		require(ROOT_PATH.'sources/page_foot.php');
		
	}
	
}

?>
Return current item: DantoBB