* added signout_page option to redirect after signout
[squirrelmail.git] / src / signout.php
index 83c78ccde93ab4f02a9f63a3199ab0dfbb87d692..a30910d2fa06adb74eb6c0bfcf0c46a401b64572 100644 (file)
    include ('../functions/prefs.php');
    include ('../functions/plugin.php');
 
-
    // Erase any lingering attachments
-   foreach ($attachments as $info)
-   {
-       if (file_exists($attachment_dir . $info['localfilename']))
-       {
+   if (! isset($attachments)) {
+       $attachments = array();
+   }
+   foreach ($attachments as $info) {
+       if (file_exists($attachment_dir . $info['localfilename'])) {
            unlink($attachment_dir . $info['localfilename']);
        }
    }
-
    set_up_language(getPref($data_dir, $username, 'language'));
 
    // 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))
-   {
+   if (! isset($base_uri)) {
        ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
        $base_uri = $regs[1];
    }
    setcookie('key', '', 0, $base_uri);
    setcookie('logged_in', '', 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. */
+   }
 ?>
 <HTML>
    <HEAD>