PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/user/logout.php

https://bitbucket.org/speedealing/speedealing
PHP | 86 lines | 45 code | 11 blank | 30 comment | 15 complexity | cdbc3d8fd3e1e784192f90e1c9fd31c9 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
  4. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2011-2012 Herve Prot <herve.prot@symeos.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
  22. if (!defined('NOREQUIREMENU'))
  23. define('NOREQUIREMENU', '1');
  24. if (!defined('NOREQUIREHTML'))
  25. define('NOREQUIREHTML', '1');
  26. if (!defined('NOREQUIREAJAX'))
  27. define('NOREQUIREAJAX', '1');
  28. if (!defined('NOREQUIRESOC'))
  29. define('NOREQUIRESOC', '1');
  30. if (!defined('EVEN_IF_ONLY_LOGIN_ALLOWED'))
  31. define('EVEN_IF_ONLY_LOGIN_ALLOWED', '1');
  32. require_once '../main.inc.php';
  33. // This can happen only with a bookmark or forged url call.
  34. if (!empty($_SESSION["dol_authmode"]) && ($_SESSION["dol_authmode"] == 'forceuser'
  35. || $_SESSION["dol_authmode"] == 'http')) {
  36. die("Disconnection does not work when connection was made in mode " . $_SESSION["dol_authmode"]);
  37. }
  38. // Appel des triggers
  39. include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
  40. $interface = new Interfaces($db);
  41. $result = $interface->run_triggers('USER_LOGOUT', $user, $user, $langs, $conf, $conf->entity);
  42. if ($result < 0) {
  43. $error++;
  44. }
  45. // Fin appel triggers
  46. // Define url to go after disconnect
  47. $urlfrom = empty($_SESSION["urlfrom"]) ? '' : $_SESSION["urlfrom"];
  48. // Destroy object of session
  49. unset($_SESSION['dol_login']);
  50. unset($_SESSION['dol_entity']);
  51. // Destroy session
  52. $prefix = dol_getprefix();
  53. dol_flushcache(); // reset cache
  54. $sessionname = 'DOLSESSID_' . $prefix;
  55. $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix;
  56. if (!empty($_COOKIE[$sessiontimeout]))
  57. ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
  58. session_name($sessionname);
  59. session_destroy();
  60. // destroy couchdb cookie
  61. setcookie('AuthSession', '', 1, '/');
  62. // Define url to go
  63. if ($conf->urlrewrite)
  64. $url = "/index.php"; // By default go to login page
  65. else
  66. $url = DOL_URL_ROOT . "/index.php"; // By default go to login page
  67. if ($urlfrom)
  68. $url = DOL_URL_ROOT . $urlfrom;
  69. if (!empty($conf->global->MAIN_LOGOUT_GOTO_URL))
  70. $url = $conf->global->MAIN_LOGOUT_GOTO_URL;
  71. //print 'url=' . $url;
  72. //exit;
  73. header("Location: " . $url);
  74. exit;
  75. ?>