Lots of changes for variable initialization - clean up, really,
[squirrelmail.git] / src / options.php
index ef02ed880d83d3ca6ec4e830511630671e76bb7e..c6dd5c7d31c8b2c1010702723637f6acc9d9b9da 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * options.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Displays the options page. Pulls from proper user preference files
@@ -17,9 +17,9 @@ define('SM_PATH','../');
 
 /* SquirrelMail required files. */
 require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/global.php');
 require_once(SM_PATH . 'functions/display_messages.php');
 require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'functions/array.php');
 require_once(SM_PATH . 'functions/options.php');
 require_once(SM_PATH . 'functions/strings.php');
 require_once(SM_PATH . 'functions/html.php');
@@ -115,9 +115,22 @@ function print_optionpages_row($leftopt, $rightopt = false) {
 
 /* ---------------------------- main ---------------------------- */
 
+/* get the globals that we may need */
+sqgetGlobalVar('key',       $key,           SQ_COOKIE);
+sqgetGlobalVar('username',  $username,      SQ_SESSION);
+sqgetGlobalVar('onetimepad',$onetimepad,    SQ_SESSION);
+sqgetGlobalVar('delimiter', $delimiter,     SQ_SESSION);
+
+sqgetGlobalVar('optpage',     $optpage);
+sqgetGlobalVar('optmode',     $optmode,      SQ_POST);
+sqgetGlobalVar('optpage_data',$optpage_data, SQ_POST);
+/* end of getting globals */
+
 /* Make sure we have an Option Page set. Default to main. */
-if (!isset($optpage)) {
-    $optpage = 'main';
+if ( !isset($optpage) || $optpage == '' ) {
+    $optpage = SMOPT_PAGE_MAIN;
+} else {
+    $optpage = strip_tags( $optpage );
 }
 
 /* Make sure we have an Option Mode set. Default to display. */
@@ -136,7 +149,8 @@ $optpage_loader = '';
 
 /* Set the load information for each page. */
 switch ($optpage) {
-    case SMOPT_PAGE_MAIN: break;
+    case SMOPT_PAGE_MAIN: 
+        break;
     case SMOPT_PAGE_PERSONAL:
         $optpage_name     = _("Personal Information");
         $optpage_file     = SM_PATH . 'include/options/personal.php';
@@ -174,8 +188,11 @@ switch ($optpage) {
 /*** Second, load the option information for this page. ***/
 /**********************************************************/
 
-if ($optpage != SMOPT_PAGE_MAIN) {
+if ( !@is_file( $optpage_file ) ) {
+    $optpage = SMOPT_PAGE_MAIN;
+} else if ($optpage != SMOPT_PAGE_MAIN ) {
     /* Include the file for this optionpage. */
+    
     require_once($optpage_file);
 
     /* Assemble the data for this option page. */