-<?
- /**
- ** signout.php3
- **
- ** Clears the cookie, and logs them out.
- **
- **/
-
- $username = "";
- $key = "";
- $logged_in = 0;
-
- setcookie("username", "", time(), "/");
- setcookie("key", "", time(), "/");
- setcookie("logged_in", 0, time(), "/");
+<?php
+ /**
+ ** signout.php -- cleans up session and logs the user out
+ **
+ ** Copyright (c) 1999-2000 The SquirrelMail development team
+ ** Licensed under the GNU GPL. For full terms see the file COPYING.
+ **
+ ** Cleans up after the user. Resets cookies and terminates
+ ** session.
+ **
+ ** $Id$
+ **/
+
+ include('../src/validate.php');
+ include ('../functions/prefs.php');
+ include ('../functions/plugin.php');
+
+ // Erase any lingering attachments
+ if (! isset($attachments)) {
+ $attachments = array();
+ }
+ foreach ($attachments as $info) {
+ if (file_exists($attachment_dir . $info['localfilename'])) {
+ unlink($attachment_dir . $info['localfilename']);
+ }
+ }
+
+ // If a user hits reload on the last page, $base_uri isn't set
+ // because it was deleted with the session.
+ if (! isset($base_uri)) {
+ ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
+ $base_uri = $regs[1];
+ }
+
+ do_hook('logout');
+ setcookie('username', '', 0, $base_uri);
+ setcookie('key', '', 0, $base_uri);
+ session_destroy();
+
+ if ($signout_page) {
+ header("Status: 303 See Other");
+ header("Location: $signout_page");
+ exit; /* we send no content if we're redirecting. */
+ }