-$username = $_SESSION['username'];
-$onetimepad = $_SESSION['onetimepad'];
-$base_uri = $_SESSION['base_uri'];
-$delimiter = $_SESSION['delimiter'];
-
-if (isset($_POST['return'])) {
- $html_addr_search_done = 'Use Addresses';
-}
-if ( isset($_SESSION['composesession']) ) {
- $composesession = $_SESSION['composesession'];
-}
-sqextractGlobalVar('action');
-sqextractGlobalVar('session');
-sqextractGlobalVar('mailbox');
-sqextractGlobalVar('identity');
-sqextractGlobalVar('send_to');
-sqextractGlobalVar('send_to_cc');
-sqextractGlobalVar('send_to_bcc');
-sqextractGlobalVar('subject');
-sqextractGlobalVar('body');
-sqextractGlobalVar('mailprio');
-sqextractGlobalVar('request_mdn');
-sqextractGlobalVar('request_dr');
-sqextractGlobalVar('html_addr_search');
-sqextractGlobalVar('mail_sent');
-sqextractGlobalVar('passed_id');
-sqextractGlobalVar('passed_ent_id');
-sqextractGlobalVar('send');
-
-if ( isset($_POST['sigappend']) ) {
- $sigappend = $_POST['sigappend'];
-}
-/* From addressbook search */
-if ( isset($_POST['from_htmladdr_search']) ) {
- $from_htmladdr_search = $_POST['from_htmladdr_search'];
-}
-if ( isset($_POST['addr_search_done']) ) {
- $html_addr_search_done = $_POST['addr_search_done'];
-}
-if ( isset($_POST['send_to_search']) ) {
- $send_to_search = &$_POST['send_to_search'];
-}
-
-/* Attachments */
-sqextractGlobalVar('attach');
-if ( isset($_POST['do_delete']) ) {
- $do_delete = $_POST['do_delete'];
-}
-if ( isset($_POST['delete']) ) {
- $delete = &$_POST['delete'];
-}
-if ( isset($_SESSION['compose_messages']) ) {
- $compose_messages = &$_SESSION['compose_messages'];
-}
-
-
-/* Forward message as attachment */
-if ( isset($_GET['attachedmessages']) ) {
- $attachedmessages = $_GET['attachedmessages'];
+/** COOKIE VARS */
+sqgetGlobalVar('key', $key, SQ_COOKIE);
+
+/** SESSION VARS */
+sqgetGlobalVar('username', $username, SQ_SESSION);
+sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION);
+sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION);
+sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
+
+sqgetGlobalVar('composesession', $composesession, SQ_SESSION);
+sqgetGlobalVar('compose_messages', $compose_messages, SQ_SESSION);
+
+/** SESSION/POST/GET VARS */
+sqgetGlobalVar('action',$action);
+sqgetGlobalVar('session',$session);
+sqgetGlobalVar('mailbox',$mailbox);
+sqgetGlobalVar('identity',$identity);
+sqgetGlobalVar('send_to',$send_to);
+sqgetGlobalVar('send_to_cc',$send_to_cc);
+sqgetGlobalVar('send_to_bcc',$send_to_bcc);
+sqgetGlobalVar('subject',$subject);
+sqgetGlobalVar('body',$body);
+sqgetGlobalVar('mailprio',$mailprio);
+sqgetGlobalVar('request_mdn',$request_mdn);
+sqgetGlobalVar('request_dr',$request_dr);
+sqgetGlobalVar('html_addr_search',$html_addr_search);
+sqgetGlobalVar('mail_sent',$mail_sent);
+sqgetGlobalVar('passed_id',$passed_id);
+sqgetGlobalVar('passed_ent_id',$passed_ent_id);
+sqgetGlobalVar('send',$send);
+
+sqgetGlobalVar('attach',$attach);
+
+sqgetGlobalVar('draft',$draft);
+sqgetGlobalVar('draft_id',$draft_id);
+sqgetGlobalVar('ent_num',$ent_num);
+sqgetGlobalVar('saved_draft',$saved_draft);
+sqgetGlobalVar('delete_draft',$delete_draft);
+
+
+/** POST VARS */
+sqgetGlobalVar('sigappend', $sigappend, SQ_POST);
+sqgetGlobalVar('from_htmladdr_search', $from_htmladdr_search, SQ_POST);
+sqgetGlobalVar('addr_search_done', $html_addr_search_done, SQ_POST);
+sqgetGlobalVar('send_to_search', $send_to_search, SQ_POST);
+sqgetGlobalVar('do_delete', $do_delete, SQ_POST);
+sqgetGlobalVar('delete', $delete, SQ_POST);
+sqgetGlobalVar('restoremessages', $restoremessages, SQ_POST);
+if ( sqgetGlobalVar('return', $temp, SQ_POST) ) {
+ $html_addr_search_done = 'Use Addresses';