2004-10-20 23:06:45 +02:00
|
|
|
<?php
|
2009-04-17 20:35:16 +02:00
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2009-04-17 09:45:00 +02:00
|
|
|
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
|
|
|
|
|
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2003-08-30 14:17:08 +02:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-08-30 14:17:08 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 01:19:04 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-08-30 14:17:08 +02:00
|
|
|
*/
|
2003-10-28 12:03:40 +01:00
|
|
|
|
2005-07-07 02:44:49 +02:00
|
|
|
/**
|
2009-05-18 00:40:53 +02:00
|
|
|
* \file htdocs/user/logout.php
|
|
|
|
|
* \brief Page called to disconnect a user
|
|
|
|
|
*/
|
2004-08-14 15:17:07 +02:00
|
|
|
|
2009-08-30 03:39:39 +02:00
|
|
|
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
|
|
|
|
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
|
|
|
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
|
|
|
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
2013-04-27 21:35:30 +02:00
|
|
|
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // We need company to get correct logo onto home page
|
2009-08-30 03:39:39 +02:00
|
|
|
if (! defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) define('EVEN_IF_ONLY_LOGIN_ALLOWED','1');
|
|
|
|
|
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once '../main.inc.php';
|
2009-05-21 16:07:25 +02:00
|
|
|
|
2009-08-30 03:39:39 +02:00
|
|
|
// This can happen only with a bookmark or forged url call.
|
2013-04-01 15:28:53 +02:00
|
|
|
if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser' || $_SESSION["dol_authmode"] == 'http'))
|
2008-05-02 03:10:00 +02:00
|
|
|
{
|
2008-05-02 08:39:53 +02:00
|
|
|
die("Disconnection does not work when connection was made in mode ".$_SESSION["dol_authmode"]);
|
2008-05-02 03:10:00 +02:00
|
|
|
}
|
2004-07-27 16:56:03 +02:00
|
|
|
|
2013-04-01 15:28:53 +02:00
|
|
|
|
2010-08-24 14:42:14 +02:00
|
|
|
// Appel des triggers
|
2012-08-23 02:04:35 +02:00
|
|
|
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
2010-08-24 14:42:14 +02:00
|
|
|
$interface=new Interfaces($db);
|
2010-12-27 11:48:50 +01:00
|
|
|
$result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf,$conf->entity);
|
2010-08-24 14:42:14 +02:00
|
|
|
if ($result < 0) { $error++; }
|
|
|
|
|
// Fin appel triggers
|
|
|
|
|
|
2008-12-10 15:56:05 +01:00
|
|
|
// Define url to go after disconnect
|
|
|
|
|
$urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"];
|
|
|
|
|
|
2009-08-30 03:39:39 +02:00
|
|
|
// Destroy some cookies
|
2012-07-13 10:15:47 +02:00
|
|
|
// TODO external module
|
|
|
|
|
if (! empty($conf->phenix->enabled) && ! empty($conf->phenix->cookie))
|
2007-10-02 15:54:34 +02:00
|
|
|
{
|
|
|
|
|
setcookie($conf->phenix->cookie, '', 1, "/");
|
|
|
|
|
}
|
2006-07-02 02:43:40 +02:00
|
|
|
|
2013-04-01 15:28:53 +02:00
|
|
|
// Define url to go
|
|
|
|
|
$url=DOL_URL_ROOT."/index.php"; // By default go to login page
|
|
|
|
|
if ($urlfrom) $url=DOL_URL_ROOT.$urlfrom;
|
|
|
|
|
if (! empty($conf->global->MAIN_LOGOUT_GOTO_URL)) $url=$conf->global->MAIN_LOGOUT_GOTO_URL;
|
|
|
|
|
|
2013-04-03 15:20:56 +02:00
|
|
|
if (GETPOST('dol_hide_topmenu')) $url.=(preg_match('/\?/',$url)?'&':'?').'dol_hide_topmenu=1';
|
|
|
|
|
if (GETPOST('dol_hide_leftmenu')) $url.=(preg_match('/\?/',$url)?'&':'?').'dol_hide_leftmenu=1';
|
|
|
|
|
if (GETPOST('dol_optimize_smallscreen')) $url.=(preg_match('/\?/',$url)?'&':'?').'dol_optimize_smallscreen=1';
|
2013-04-27 21:35:30 +02:00
|
|
|
if (GETPOST('dol_no_mouse_hover')) $url.=(preg_match('/\?/',$url)?'&':'?').'dol_no_mouse_hover=1';
|
|
|
|
|
if (GETPOST('dol_use_jmobile')) $url.=(preg_match('/\?/',$url)?'&':'?').'dol_use_jmobile=1';
|
2009-05-21 16:07:25 +02:00
|
|
|
|
2008-10-26 13:59:56 +01:00
|
|
|
// Destroy session
|
2010-12-27 20:13:06 +01:00
|
|
|
$prefix=dol_getprefix();
|
|
|
|
|
$sessionname='DOLSESSID_'.$prefix;
|
|
|
|
|
$sessiontimeout='DOLSESSTIMEOUT_'.$prefix;
|
2009-06-14 18:25:23 +02:00
|
|
|
if (! empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime',$_COOKIE[$sessiontimeout]);
|
2008-10-26 13:59:56 +01:00
|
|
|
session_name($sessionname);
|
2007-12-31 01:02:26 +01:00
|
|
|
session_destroy();
|
2009-05-21 15:37:18 +02:00
|
|
|
dol_syslog("End of session ".$sessionname);
|
2008-10-12 13:41:13 +02:00
|
|
|
|
2013-04-01 15:28:53 +02:00
|
|
|
// TODO Not sure this is required
|
|
|
|
|
unset($_SESSION['dol_login']);
|
|
|
|
|
unset($_SESSION['dol_entity']);
|
2010-08-23 20:09:24 +02:00
|
|
|
|
2008-12-10 15:56:05 +01:00
|
|
|
header("Location: ".$url);
|
2003-08-30 11:27:49 +02:00
|
|
|
?>
|