#!./tclsh # $Id: init.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 # # ======================================================================== # init.tcl # # Purpose: CGI script to establish foundation for webpine session # and any global config source ./alpine.tcl cgi_eval { if {$_wp(debug)} { cgi_debug -on } # # Import username and password from pubcookie, if possible. # Otherwise get it from the form that was submitted. # cgi_input if {[catch {cgi_import User}] || 0 == [string length $User]} { WPInfoPage "Bogus Username" \ "[font size=+2 "Sorry, didn't catch your [bold name]!"]" \ "Please click your browser's [bold Back] button to return to the [cgi_link Start], and fill in a [italic Username]..." return } if {[catch {cgi_import Pass}]} { set Pass "" } if {[catch {cgi_import Server}] || 0 == [string length $Server]} { WPInfoPage "Bogus Server" \ "[font size=+2 "Invalid Server specified"]" \ "Please click your browser's [bold Back] button to return to the [cgi_link Start], and fill in a [italic Server]..." return } catch {cgi_import hPx} set defconf [file join $_wp(confdir) $_wp(defconf)] set confloc "" if {[string length $Server] < 256 && 0 == [regexp {[[:cntrl:]]} $Server]} { if {[info exists _wp(hosts)] && $Server >= 0 && $Server < [llength $_wp(hosts)]} { set sdata [lindex $_wp(hosts) $Server] set env(IMAP_SERVER) "[subst [lindex $sdata 1]]/user=$User" if {[llength $sdata] > 2 && [string length [lindex $sdata 2]]} { set defconf [subst [lindex $sdata 2]] } else { # # Validate input? # WPInfoPage "Internal Error" \ [font size=+2 "IMAP Server Mismatch"] \ "Please complain to the [link Admin] and visit the [cgi_link Start] later." return } } elseif {[regexp {/user=} $Server]} { set env(IMAP_SERVER) "$Server" } else { set env(IMAP_SERVER) "$Server/user=$User" } set confloc "\{$env(IMAP_SERVER)\}$_wp(config)" regexp {^[^:/]*} $env(IMAP_SERVER) env(IMAP_SERVER_BASE) } else { WPInfoPage "Bad Server Name" [font size=+2 "Server Name too long or has bogus characters."] \ "Please click your browser's [bold Back] button to return to the [cgi_link Start] to try again..." return } set confloc "\{$env(IMAP_SERVER)\}$_wp(config)" if {[catch {regexp {^[^:/]*} $env(IMAP_SERVER) env(IMAP_SERVER_BASE)}]} { set env(IMAP_SERVER_BASE) "" } # in less rigid settings, it might make sense to allow # for random input folder names... # cgi_import Folder # # Server, folder and credentials in hand, fork the client... #