From 3c66c567ff1ec35d730b15368cf9563f1979496e Mon Sep 17 00:00:00 2001 From: kink Date: Tue, 11 Mar 2003 16:57:21 +0000 Subject: [PATCH] More global cleanup. Now all SESSION and COOKIE use sqgetglobalvar, what's remaining is a wide deployment of _POST and _GET. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4644 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/bug_report/setup.php | 6 +-- plugins/filters/filters.php | 6 +-- plugins/filters/options.php | 29 +++++------- plugins/filters/spamoptions.php | 16 +++---- plugins/mail_fetch/fetch.php | 24 +++++----- plugins/mail_fetch/options.php | 79 +++++++++++---------------------- plugins/mail_fetch/setup.php | 38 ++++++---------- 7 files changed, 75 insertions(+), 123 deletions(-) diff --git a/plugins/bug_report/setup.php b/plugins/bug_report/setup.php index 208deea5..3aed1958 100644 --- a/plugins/bug_report/setup.php +++ b/plugins/bug_report/setup.php @@ -42,11 +42,7 @@ function bug_report_button() { function bug_report_save() { global $username,$data_dir; - if ( !check_php_version(4,1) ) { - global $_POST; - } - - if(isset($_POST['bug_report_bug_report_visible'])) { + if( sqgetGlobalVar('bug_report_bug_report_visible', $vis, SQ_POST) ) { setPref($data_dir, $username, 'bug_report_visible', '1'); } else { setPref($data_dir, $username, 'bug_report_visible', ''); diff --git a/plugins/filters/filters.php b/plugins/filters/filters.php index 803eea91..89a89ba6 100644 --- a/plugins/filters/filters.php +++ b/plugins/filters/filters.php @@ -164,10 +164,10 @@ function filters_bulkquery($filters_spam_scan, $filters, $read) { function start_filters() { global $mailbox, $imapServerAddress, $imapPort, $imap, $imap_general, $filters, $imap_stream, $imapConnection, - $UseSeparateImapConnection, $AllowSpamFilters, $_SESSION, $_COOKIE; + $UseSeparateImapConnection, $AllowSpamFilters; - $username = $_SESSION['username']; - $key = $_COOKIE['key']; + sqgetGlobalVar('username', $username, SQ_SESSION); + sqgetGlobalVar('key', $key, SQ_COOKIE); # if ($mailbox == 'INBOX') { // Detect if we have already connected to IMAP or not. diff --git a/plugins/filters/options.php b/plugins/filters/options.php index 2bae7054..73d03e37 100644 --- a/plugins/filters/options.php +++ b/plugins/filters/options.php @@ -36,23 +36,20 @@ require_once(SM_PATH . 'functions/imap_mailbox.php'); require_once(SM_PATH . 'include/load_prefs.php'); require_once(SM_PATH . 'plugins/filters/filters.php'); - global $AllowSpamFilters; +global $AllowSpamFilters; - displayPageHeader($color, 'None'); +displayPageHeader($color, 'None'); - $username = $_SESSION['username']; - $key = $_COOKIE['key']; - $onetimepad = $_SESSION['onetimepad']; - $delimiter = $_SESSION['delimiter']; - if(isset($_GET['theid'])) { - $theid = $_GET['theid']; - } - if(isset($_POST['theid'])) { - $theid = $_POST['theid']; - } - if(isset($_GET['action'])) { - $action = $_GET['action']; - } +/* get globals */ +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); + +sqgetGlobalVar('theid', $theid); +sqgetGlobalVar('action', $action, SQ_GET); + +// FIXME: use sqgetGlobalVar below. if (isset($_POST['filter_submit'])) { if(isset($_GET['theid'])) { @@ -130,8 +127,6 @@ require_once(SM_PATH . 'plugins/filters/filters.php'); 'center' ) . '
'; if (isset($action) && ($action == 'add' || $action == 'edit')) { - $username = $_SESSION['username']; - $key = $_COOKIE['key']; $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); $boxes = sqimap_mailbox_list($imapConnection); diff --git a/plugins/filters/spamoptions.php b/plugins/filters/spamoptions.php index 21719494..2fc1706e 100644 --- a/plugins/filters/spamoptions.php +++ b/plugins/filters/spamoptions.php @@ -36,14 +36,14 @@ require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'plugins/filters/filters.php'); global $AllowSpamFilters; -$username = $_SESSION['username']; -$key = $_COOKIE['key']; -$onetimepad = $_SESSION['onetimepad']; -$delimiter = $_SESSION['delimiter']; - -if (isset($_GET['action'])) { - $action = $_GET['action']; -} +/* get globals */ +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); + +sqgetGlobalVar('action', $action, SQ_GET); +/* end globals */ displayPageHeader($color, 'None'); diff --git a/plugins/mail_fetch/fetch.php b/plugins/mail_fetch/fetch.php index 69c98225..b2639f10 100644 --- a/plugins/mail_fetch/fetch.php +++ b/plugins/mail_fetch/fetch.php @@ -21,20 +21,20 @@ require_once(SM_PATH . 'plugins/mail_fetch/class.POP3.php'); require_once(SM_PATH . 'plugins/mail_fetch/functions.php' ); require_once(SM_PATH . 'functions/html.php' ); - /* globals */ - $username = $_SESSION['username']; - $key = $_COOKIE['key']; - $onetimepad = $_SESSION['onetimepad']; - $delimter = $_SESSION['delimiter']; +/* globals */ +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); - /* This form, like the advanced identities form - uses dynamic post variable names so we need - to extract the whole $_POST array to make - things work - */ +/* FIXME: This form, like the advanced identities form + * uses dynamic post variable names so we need + * to extract the whole $_POST array to make + * things work + */ - extract($_POST); - /* end globals */ +extract($_POST); +/* end globals */ function Mail_Fetch_Status($msg) { echo html_tag( 'table', diff --git a/plugins/mail_fetch/options.php b/plugins/mail_fetch/options.php index 2d019413..59202257 100644 --- a/plugins/mail_fetch/options.php +++ b/plugins/mail_fetch/options.php @@ -17,61 +17,34 @@ require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'include/load_prefs.php'); - /* globals */ - $username = $_SESSION['username']; - $key = $_COOKIE['key']; - $onetimepad = $_SESSION['onetimepad']; - $delimiter = $_SESSION['delimiter']; +/* globals */ +sqgetGlobalVar('username', $username, SQ_SESSION); +sqgetGlobalVar('key', $key, SQ_COOKIE); +sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); +sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); - if(isset($_POST['mf_cypher'])) { - $mf_cypher = $_POST['mf_cypher']; - } - else { - $mf_cyper = ''; - } - if(isset($_POST['mf_sn'])) { - $mf_sn = $_POST['mf_sn']; - } - if(isset($_POST['mf_server'])) { - $mf_server = $_POST['mf_server']; - } - if(isset($_POST['mf_port'])) { - $mf_port = $_POST['mf_port']; - } - if(isset($_POST['mf_alias'])) { - $mf_alias = $_POST['mf_alias']; - } - if(isset($_POST['mf_user'])) { - $mf_user = $_POST['mf_user']; - } - if(isset($_POST['mf_pass'])) { - $mf_pass = $_POST['mf_pass']; - } - if(isset($_POST['mf_subfolder'])) { - $mf_subfolder = $_POST['mf_subfolder']; - } - if(isset($_POST['mf_login'])) { - $mf_login = $_POST['mf_login']; - } - if(isset($_POST['mf_fref'])) { - $mf_fref = $_POST['mf_fref']; - } - if(isset($_POST['submit_mailfetch'])) { - $submit_mailfetch = $_POST['submit_mailfetch']; - } - if(isset($_POST['mf_lmos'])) { - $mf_lmos = $_POST['mf_lmos']; - } - /* end globals */ +if(!sqgetGlobalVar('mf_cypher', $mf_cypher, SQ_POST)) { + $mf_cypher = ''; +} +if(! sqgetGlobalVar('mf_action', $mf_action, SQ_POST) ) { + $mf_action = 'config'; +} - displayPageHeader( $color, 'None' ); +sqgetGlobalVar('mf_sn', $mf_an, SQ_POST); +sqgetGlobalVar('mf_server', $mf_server, SQ_POST); +sqgetGlobalVar('mf_port', $mf_port, SQ_POST); +sqgetGlobalVar('mf_alias', $mf_alias, SQ_POST); +sqgetGlobalVar('mf_user', $mf_user, SQ_POST); +sqgetGlobalVar('mf_pass', $mf_pass, SQ_POST); +sqgetGlobalVar('mf_subfolder', $mf_subfolder, SQ_POST); +sqgetGlobalVar('mf_login', $mf_login, SQ_POST); +sqgetGlobalVar('mf_fref', $mf_fref, SQ_POST); +sqgetGlobalVar('mf_lmos', $mf_lmos, SQ_POST); +sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST); - //if dosen't select any option - if (!isset($_POST['mf_action'])) { - $mf_action = 'config'; - } else { - $mf_action = $_POST['mf_action']; - } +/* end globals */ + + displayPageHeader( $color, 'None' ); switch( $mf_action ) { case 'add': @@ -156,7 +129,7 @@ require_once(SM_PATH . 'include/load_prefs.php'); } - echo '
' . + echo '
' . html_tag( 'table', html_tag( 'tr', html_tag( 'td', diff --git a/plugins/mail_fetch/setup.php b/plugins/mail_fetch/setup.php index 5b1dc739..8155251c 100644 --- a/plugins/mail_fetch/setup.php +++ b/plugins/mail_fetch/setup.php @@ -39,10 +39,8 @@ global $mailfetch_server_,$mailfetch_alias_,$mailfetch_user_,$mailfetch_pass_; global $mailfetch_lmos_, $mailfetch_uidl_, $mailfetch_login_, $mailfetch_fref_; global $PHP_SELF; - if ( !check_php_version(4,1) ) { - global $_SESSION; - } - $username = $_SESSION['username']; + + sqgetGlobalVar('username', $username, SQ_SESSION); if( stristr( $PHP_SELF, 'mail_fetch' ) ) { $mailfetch_server_number = getPref($data_dir, $username, 'mailfetch_server_number', 0); @@ -71,11 +69,9 @@ require_once (SM_PATH . 'plugins/mail_fetch/functions.php'); global $data_dir, $imapServerAddress, $imapPort; - if ( !check_php_version(4,1) ) { - global $_SESSION, $_COOKIE; - } - $username = $_SESSION['username']; - $key = $_COOKIE['key']; + + sqgetGlobalVar('username', $username, SQ_SESSION); + sqgetGlobalVar('key', $key, SQ_COOKIE); $mailfetch_newlog = getPref($data_dir, $username, 'mailfetch_newlog'); @@ -204,12 +200,12 @@ } } - if( trim( $outMsg ) <> '' ) - echo '
' . _("Mail Fetch Result:") . "
$outMsg
"; - - if( $mailfetch_newlog == 'on' ) - setPref($data_dir,$username,"mailfetch_newlog", 'off'); - + if( trim( $outMsg ) <> '' ) { + echo '
' . _("Mail Fetch Result:") . "
$outMsg
"; + } + if( $mailfetch_newlog == 'on' ) { + setPref($data_dir, $username, 'mailfetch_newlog', 'off'); + } } function mail_fetch_setnew() { @@ -217,17 +213,9 @@ global $data_dir; require_once(SM_PATH . 'functions/prefs.php'); - if (isset($_SESSION['username'])) { - $username = $_SESSION['username']; - } else { - $username = ''; - } - - if( $username <> '' ) { - // Creates the pref file if it does not exist. - setPref( $data_dir, $username, 'mailfetch_newlog', 'on' ); - } + sqgetGlobalVar('username', $username, SQ_SESSION); + setPref( $data_dir, $username, 'mailfetch_newlog', 'on' ); } function mailfetch_optpage_register_block() { -- 2.25.1