Sponsorenverwaltung - Team StarCraft e.V.
 All Data Structures Files Functions Variables
logout.php
Go to the documentation of this file.
1 <?php
2  /**
3  * @file logout.php
4  *
5  * @brief Does the logout.
6  *
7  * @details
8  * Calls the userLogOut() function of class LoggedInUser. Therefore it checks
9  * if the user has a one-time-password but has not changed it. If so the user
10  * is alerted of that fact. If the user ignores this his password will be made
11  * invalid
12  *
13  * This file depends on inc/common.php and inc/templates/logout.tpl.
14  *
15  * @copyright (c) 2013, Team StarCraft e.V.
16  * @version 1.0.0
17  * @author Usercake (http://www.usercake.com)
18  * @author Daniel Seichter
19  * @author Alexander Vorndran
20  * @date 02.07.2013
21  */
22 
23  /// @cond MAINPART
24 
25  // include
26  include("inc/common.php");
27 
28 
29  // UserCake
30  if(!accessGranted($_SERVER['PHP_SELF'])) {
31  if (isUserLoggedIn()) {
32  exitWithErrorTemplate(array('Die angeforderte Seite ist gesperrt.'));
33  }
34  else {
35  exitWithErrorTemplateAndRedirect(array('Die angeforderte Seite ist gesperrt oder geschützt.'), 'login.php', 2);
36  }
37  }
38 
39  if(!isUserLoggedIn()) {
40  header("Location: login.php");
41  die();
42  }
43 
44  //Log the user out
45  if(isset($_POST['logout']) && $_POST['logout']==1 && isUserLoggedIn()) {
46  if(hasOnetimePassword($loggedInUser->userId)) {
47  flagPassword($loggedInUser->userId, -3);
48  }
49  $result = $loggedInUser->userLogOut();
50  header("Location: index.php");
51  die();
52  }
53 
54  // run template
55  displayTemplateWithErrorsAndSuccesses('Abmelden','logout.tpl');
56 
57  /// @endcond
58 ?>