* added signout_page option to redirect after signout
[squirrelmail.git] / src / signout.php
1 <?php
2 /**
3 ** signout.php -- cleans up session and logs the user out
4 **
5 ** Copyright (c) 1999-2000 The SquirrelMail development team
6 ** Licensed under the GNU GPL. For full terms see the file COPYING.
7 **
8 ** Cleans up after the user. Resets cookies and terminates
9 ** session.
10 **
11 ** $Id$
12 **/
13
14 include('../src/validate.php');
15 include('../functions/strings.php');
16 include ('../src/load_prefs.php');
17 include('../config/config.php');
18 include('../functions/i18n.php');
19 include ('../functions/prefs.php');
20 include ('../functions/plugin.php');
21
22 // Erase any lingering attachments
23 if (! isset($attachments)) {
24 $attachments = array();
25 }
26 foreach ($attachments as $info) {
27 if (file_exists($attachment_dir . $info['localfilename'])) {
28 unlink($attachment_dir . $info['localfilename']);
29 }
30 }
31 set_up_language(getPref($data_dir, $username, 'language'));
32
33 // If a user hits reload on the last page, $base_uri isn't set
34 // because it was deleted with the session.
35 if (! isset($base_uri)) {
36 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
37 $base_uri = $regs[1];
38 }
39
40 do_hook('logout');
41 setcookie('username', '', 0, $base_uri);
42 setcookie('key', '', 0, $base_uri);
43 setcookie('logged_in', '', 0, $base_uri);
44 session_destroy();
45
46 if ($signout_page) {
47 header("Status: 303 See Other");
48 header("Location: $signout_page");
49 exit; /* we send no content if we're redirecting. */
50 }
51 ?>
52 <HTML>
53 <HEAD>
54 <?php
55 if ($theme_css != '') {
56 ?>
57 <LINK REL="stylesheet" TYPE="text/css" HREF="<?php echo $theme_css ?>">
58 <?php
59 }
60 ?>
61 <TITLE><?php echo $org_title ?> - Signout</TITLE>
62 </HEAD>
63 <BODY TEXT="<?php echo $color[8] ?>" BGCOLOR="<?php echo $color[4] ?>"
64 LINK="<?php echo $color[7] ?>" VLINK="<?php echo $color[7] ?>" A
65 LINK="<?php echo $color[7] ?>">
66 <BR><BR>
67 <TABLE BGCOLOR="FFFFFF" BORDER="0" COLS="1" WIDTH="50%" CELLSPACING="0"
68 CELLPADDING="2" ALIGN="CENTER">
69 <TR BGCOLOR="<?php echo $color[0] ?>" WIDTH=100%>
70 <TD ALIGN="CENTER">
71 <B><?php echo _("Sign Out") ?></B>
72 </TD>
73 </TR>
74 <TR BGCOLOR="<?php echo $color[4] ?>" WIDTH=100%>
75 <TD ALIGN="CENTER">
76 <?php echo _("You have been successfully signed out.") ?><BR>
77 <A HREF="login.php" TARGET="_top">
78 <?php echo _("Click here to log back in.") ?>
79 </A><BR><BR>
80 </TD>
81 </TR>
82 <TR BGCOLOR="<?php echo $color[0] ?>" WIDTH=100%>
83 <TD ALIGN="CENTER">
84 <BR>
85 </TD>
86 </TR>
87 </TABLE>
88 </BODY>
89 </HTML>