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.

113 lines
5.2 KiB

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