Eliminated all eveil chdir statements.
[squirrelmail.git] / plugins / translate / options.php
index de3f592306ac4905e25c6dfb20fa8224b8beebe3..ae55cb997c7d572b605cae7d338b0b622e35bf70 100644 (file)
@@ -1,43 +1,75 @@
 <?php
-   /**
-    **  options.php
-    **
-    **  Pick your translator to translate the body of incoming mail messages
-    **
-    **/
-
-   chdir('..');
-
-   session_start();
-
-   if (!isset($config_php))
-      include_once('../config/config.php');
-   if (!isset($strings_php))
-      include_once('../functions/strings.php');
-   if (!isset($page_header_php))
-      include_once('../functions/page_header.php');
-   if (!isset($display_messages_php))
-      include_once('../functions/display_messages.php');
-   if (!isset($imap_php))
-      include_once('../functions/imap.php');
-   if (!isset($array_php))
-      include_once('../functions/array.php');
-   if (!isset($i18n_php))
-      include_once('../functions/i18n.php');
-
-
-   require_once('../src/load_prefs.php');
-   displayPageHeader($color, 'None');
-
-  $translate_server = getPref($data_dir, $username, 'translate_server');
-  if ($translate_server == '')
+
+/**
+ * options.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Pick your translator to translate the body of incoming mail messages
+ *
+ * $Id$
+ */
+
+/* Path for SquirrelMail required files. */
+define('SM_PATH','../../');
+
+/* SquirrelMail required files. */
+require_once(SM_PATH . 'include/validate.php');
+require_once(SM_PATH . 'functions/strings.php');
+require_once(SM_PATH . 'functions/page_header.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/i18n.php');
+require_once(SM_PATH . 'include/load_prefs.php');
+
+    displayPageHeader($color, 'None');
+
+    if (isset($submit_translate) && $submit_translate ) {
+        if (isset($translate_translate_server)) {
+            setPref($data_dir, $username, 'translate_server', $translate_translate_server);
+        } else {
+            setPref($data_dir, $username, 'translate_server', 'babelfish');
+        }
+
+        if (isset($translate_translate_location)) {
+            setPref($data_dir, $username, 'translate_location', $translate_translate_location);
+        } else {
+            setPref($data_dir, $username, 'translate_location', 'center');
+        }
+
+        if (isset($translate_translate_show_read)) {
+            setPref($data_dir, $username, 'translate_show_read', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_show_read', '');
+        }
+
+        if (isset($translate_translate_show_send)) {
+            setPref($data_dir, $username, 'translate_show_send', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_show_send', '');
+        }
+
+        if (isset($translate_translate_same_window)) {
+           setPref($data_dir, $username, 'translate_same_window', '1');
+        } else {
+            setPref($data_dir, $username, 'translate_same_window', '');
+        }
+    }
+
+    $translate_server = getPref($data_dir, $username, 'translate_server');
+    if ($translate_server == '') {
     $translate_server = 'babelfish';
-  $translate_location = getPref($data_dir, $username, 'translate_location');
-  if ($translate_location == '')
+    }
+    $translate_location = getPref($data_dir, $username, 'translate_location');
+    if ($translate_location == '') {
     $translate_location = 'center';
-  $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
-  $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
-  $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
+    }
+    $translate_show_read = getPref($data_dir, $username, 'translate_show_read');
+    $translate_show_send = getPref($data_dir, $username, 'translate_show_send');
+    $translate_same_window = getPref($data_dir, $username, 'translate_same_window');
+  
 
    function ShowOption($Var, $value, $Desc)
    {
@@ -62,8 +94,7 @@
     }
 
 ?>
-   <br>
-   <table width=100% align=center border=0 cellpadding=2 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
+   <table width="95%" align=center border=0 cellpadding=1 cellspacing=0><tr><td bgcolor="<?php echo $color[0] ?>">
       <center><b><?php echo _("Options") . ' - '. _("Translator"); ?></b></center>
    </td></tr></table>
 
    </ul>
    <p>
 <?php
-   echo _("You also decide if you want the translation box displayed, and where it will be located.");
-?></p>
-
-   <form action="../../src/options.php" method=post>
-   <table border=0 cellpadding=0 cellspacing=2>
-   <tr><td align=right nowrap><?php echo _("Select your translator:"); ?></td>
-       <td><select name="translate_translate_server">
-<?PHP
+   echo _("You also decide if you want the translation box displayed, and where it will be located.") .
+        "<form action=\"$PHP_SELF\" method=post>".
+        '<table border=0 cellpadding=0 cellspacing=2>'.
+            '<tr><td align=right nowrap>' .
+             _("Select your translator:") .
+             '</td>'.
+            '<td><select name="translate_translate_server">';
+
     ShowOption('server', 'babelfish', 'Babelfish');
     ShowOption('server', 'go', 'Go.com');
     ShowOption('server', 'dictionary', 'Dictionary.com');
    '</table>'.
    '</form>'.
 "</body></html>\n";
+
+?>