You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
5.3 KiB

  1. <?php
  2. // turn on warnings and notice during developement
  3. include('initialize/PhpErrorSettings.inc.php');
  4. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  5. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  6. // original author(s).
  7. //
  8. // This code is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  10. // License for more details.
  11. //
  12. // File: ./user_logout.php
  13. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/user_logout.php $
  14. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  15. //
  16. // Created: 16-Apr-02, 10:54
  17. // Modified: $Date: 2015-02-16 20:53:19 +0000 (Mon, 16 Feb 2015) $
  18. // $Author: karnesky $
  19. // $Revision: 1405 $
  20. // This script logs a user out and redirects
  21. // to the calling page. If the script is called
  22. // unexpectedly, an error message is generated.
  23. // Incorporate some include files:
  24. include 'includes/include.inc.php'; // include common functions
  25. // --------------------------------------------------------------------
  26. // START A SESSION:
  27. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  28. start_session(true);
  29. // --------------------------------------------------------------------
  30. // Is the user logged in?
  31. if (isset($_SESSION['loginEmail']))
  32. {
  33. // Delete the 'loginEmail' session variable & other session variables we've registered on login:
  34. // (function 'deleteSessionVariable()' is defined in 'include.inc.php')
  35. deleteSessionVariable("loginEmail"); // remove the user's email address (as a result the user will be logged out)
  36. deleteSessionVariable("loginUserID"); // clear the user's user ID
  37. deleteSessionVariable("loginFirstName"); // clear the user's first name
  38. deleteSessionVariable("loginLastName"); // clear the user's last name
  39. deleteSessionVariable("abbrevInstitution"); // clear the user's abbreviated institution name
  40. deleteSessionVariable("userLanguage"); // clear the user's preferred language
  41. deleteSessionVariable("userDefaultView"); // clear the user's default view setting
  42. deleteSessionVariable("userRecordsPerPage"); // clear the user's preferred number of records per page
  43. deleteSessionVariable("userAutoCompletions"); // clear the user's preference for displaying auto-completions
  44. deleteSessionVariable("userMainFields"); // clear the user's preferred list of "main fields"
  45. deleteSessionVariable("lastLogin"); // clear the user's last login date & time
  46. if (isset($_SESSION['userGroups']))
  47. deleteSessionVariable("userGroups"); // clear the user's user groups (if any)
  48. if (isset($_SESSION['adminUserGroups']))
  49. deleteSessionVariable("adminUserGroups"); // clear the admin's user groups (if any)
  50. if (isset($_SESSION['userQueries']))
  51. deleteSessionVariable("userQueries"); // clear the user's saved queries (if any)
  52. if (isset($_SESSION['user_export_formats']))
  53. deleteSessionVariable("user_export_formats"); // clear the user's export formats (if any)
  54. if (isset($_SESSION['user_cite_formats']))
  55. deleteSessionVariable("user_cite_formats"); // clear the user's cite formats (if any)
  56. if (isset($_SESSION['user_styles']))
  57. deleteSessionVariable("user_styles"); // clear the user's styles (if any)
  58. if (isset($_SESSION['user_types']))
  59. deleteSessionVariable("user_types"); // clear the user's types (if any)
  60. if (isset($_SESSION['user_permissions']))
  61. deleteSessionVariable("user_permissions"); // clear any user-specific permissions
  62. if (isset($_SESSION['HeaderString']))
  63. deleteSessionVariable("HeaderString"); // clear any previous messages
  64. if (isset($_SESSION['cqlQuery']))
  65. deleteSessionVariable("cqlQuery"); // clear any stored OpenSearch/CQL query
  66. if (isset($_SESSION['oldQuery']))
  67. deleteSessionVariable("oldQuery"); // clear any query URL pointing to the formerly displayed results page
  68. if (isset($_SESSION['oldMultiRecordQuery']))
  69. deleteSessionVariable("oldMultiRecordQuery"); // clear any query URL pointing to the last multi-record query
  70. if (isset($_SESSION['lastListViewQuery']))
  71. deleteSessionVariable("lastListViewQuery"); // clear any SQL query generated for the last List view
  72. if (isset($_SESSION['lastDetailsViewQuery']))
  73. deleteSessionVariable("lastDetailsViewQuery"); // clear any SQL query generated for the last Details view
  74. // if (isset($_SESSION['lastCitationViewQuery']))
  75. // deleteSessionVariable("lastCitationViewQuery"); // clear any SQL query generated for the last Citation view
  76. if (isset($_SESSION['queryHistory']))
  77. deleteSessionVariable("queryHistory"); // clear any links to previous search results
  78. }
  79. else
  80. {
  81. // save an error message:
  82. $HeaderString = "You cannot logout since you are not logged in anymore!";
  83. // Write back session variables:
  84. saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
  85. }
  86. if (!preg_match("/.*user(_details|_options|_receipt|s)\.php.*|.*(error|install|query_manager|query_history)\.php.*/", $referer)) // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  87. header("Location: " . $referer); // redirect the user to the calling page
  88. else
  89. header("Location: index.php"); // back to main page
  90. ?>