summaryrefslogtreecommitdiff
path: root/web/cgi/session/logout.tcl
blob: 698e355825246ad8e8bd63c13118de1c09227a1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!./tclsh
# $Id: logout.tcl 1204 2009-02-02 19:54:23Z hubert@u.washington.edu $
# ========================================================================
# Copyright 2006 University of Washington
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# ========================================================================

# Imported args
set logout_vars {
  {serverid	{}	0}
  {expinbox	{}	0}
  {expcurrent	{}	0}
  {cid		"Missing Command ID"}
}

# and any global config
source ./alpine.tcl

WPEval $logout_vars {
  
  if {$cid != [WPCmd PEInfo key]} {
    error [list _action Logout "Invalid Operation ID" "Please close this window."]
  }

  if {$expinbox &&  [catch {WPCmd PEMailbox expunge inbox} result]} {
    set logouterr $result
  }

  if {$expcurrent &&  [catch {WPCmd PEMailbox expunge current} result]} {
    if {[info exists logouterr] == 0} {
      set logouterr $result
    }
  }

  if {[catch {WPCmd PESession close} result]} {
    if {[info exists logouterr] == 0} {
      set logouterr $result
    }
  }

  if {[catch {WPCmd set wp_ver_dir} verdir]} {
    set verdir $_wp(appdir)
  }

  catch {WPCmd exit}

  cgi_http_head {
    set parms "?verdir=${verdir}"

    if {[regexp {^[0-9]+$} $serverid]} {
      append parms "&serverid=$serverid"
    }

    if {[info exists logouterr]} {
      append parms "&logerr=[WPPercentQuote $logouterr]"
    }

    cgi_redirect $_wp(serverpath)/$_wp(appdir)/farewell.tcl${parms}
  }
}