Use compatibility_info() function if at all possible instead of compatibility_version()
[squirrelmail.git] / plugins / administrator / options.php
index 7faf33dd01fdff348ea97e3b60cd8a58cfb4ef32..15a1c4b2dafd346641eba6774e3e39ea7731f1ee 100644 (file)
@@ -7,7 +7,7 @@
  * SquirrelMail configuration file.
  *
  * @author Philippe Mingo
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2007 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -219,15 +219,12 @@ function change_to_sm_path($old_path) {
 
 
 /* ---------------------- main -------------------------- */
-
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'plugins/administrator/defines.php');
-require_once(SM_PATH . 'plugins/administrator/auth.php');
+/** main SquirrelMail include */
+require('../../include/init.php');
+/* configuration definitions */
+include_once(SM_PATH . 'plugins/administrator/defines.php');
+/* additional functions */
+include_once(SM_PATH . 'plugins/administrator/auth.php');
 
 global $data_dir, $username;
 
@@ -272,7 +269,7 @@ if ( sqgetGlobalVar('switch', $switch, SQ_GET) ) {
 }
 
 echo '<form action="options.php" method="post" name="options">' .
-     '<div style="text-align: center;"><table width="95%" bgcolor="'.$color[5].'"><tr><td>'.
+     '<table width="95%" align="center" bgcolor="'.$color[5].'"><tr><td>'.
      '<table width="100%" cellspacing="0" bgcolor="'.$color[4].'">'.
      '<tr bgcolor="'.$color[5].'"><th colspan="2">'.
      _("Configuration Administrator").'</th></tr>'.
@@ -321,7 +318,7 @@ foreach ( $newcfg as $k => $v ) {
     } else if ( substr( $k, 0, 13 ) == '$ldap_server[' ) {
         $type = SMOPT_TYPE_LDAP;
     } else if ( substr( $k, 0, 9 ) == '$fontsets' ||
-       substr( $k, 0, 13 ) == '$aTemplateSet' ) {
+                substr( $k, 0, 13 ) == '$aTemplateSet' ) {
         $type = SMOPT_TYPE_CUSTOM;
     }
 
@@ -416,11 +413,13 @@ foreach ( $newcfg as $k => $v ) {
 
         case SMOPT_TYPE_TEXTAREA:
             if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
-                $v = '"' . $new_v . '"';
+                $v = '"' . addslashes($new_v) . '"';
                 $newcfg[$k] = str_replace( "\n", '', $v );
             }
-            echo "<tr><td valign=\"top\">$name</td><td>".
-                 "<textarea cols=\"$size\" rows=\"4\" name=\"adm_$n\">" . substr( $v, 1, strlen( $v ) - 2 ) . "</textarea>";
+            echo "<tr><td valign=\"top\">$name</td><td>"
+                ."<textarea cols=\"$size\" rows=\"4\" name=\"adm_$n\">" 
+                .htmlspecialchars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+                ."</textarea>";
             if ( isset( $defcfg[$k]['comment'] ) ) {
                 echo ' &nbsp; ' . $defcfg[$k]['comment'];
             }
@@ -428,15 +427,17 @@ foreach ( $newcfg as $k => $v ) {
             break;
         case SMOPT_TYPE_STRING:
             if (  sqgetGlobalVar($e, $new_v, SQ_POST) ) {
-                $v = '"' . $new_v . '"';
+                $v = '"' . addslashes($new_v) . '"';
                 $newcfg[$k] = $v;
             }
             if ( $v == '""' && isset( $defcfg[$k]['default'] ) ) {
                 $v = "'" . $defcfg[$k]['default'] . "'";
                 $newcfg[$k] = $v;
             }
-            echo "<tr><td>$name</td><td>".
-                 "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . '" />';
+            echo "<tr><td>$name</td><td>"
+                ."<input size=\"$size\" name=\"adm_$n\" value=\""
+                .htmlspecialchars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+                .'" />';
             if ( isset( $defcfg[$k]['comment'] ) ) {
                 echo ' &nbsp; ' . $defcfg[$k]['comment'];
             }
@@ -581,7 +582,7 @@ if ( $colapse['Group8'] == 'off' ) {
                 $i++;
             }
         }
-        echo '<tr><td colspan="2"><input type="hidden" name="plg" value="on" /><div style="text-align: center;"><table>';
+        echo '<tr><td colspan="2"><input type="hidden" name="plg" value="on" /><table align="center">';
         foreach ( $op_plugin as $plg ) {
             if ( in_array( $plg, $plugins ) ) {
                 $sw = ' checked="checked"';
@@ -598,7 +599,7 @@ if ( $colapse['Group8'] == 'off' ) {
                  "<td><input$sw type=\"checkbox\" name=\"plgs_$plg\" /></td>".
                  "</tr>\n";
         }
-        echo '</table></div></td></tr>';
+        echo '</table></td></tr>';
     } else {
         echo '<tr><td colspan="2" align="center">'.
              sprintf(_("Plugin directory could not be found: %s"), $plugpath).
@@ -609,7 +610,7 @@ echo '<tr bgcolor="'.$color[5].'"><th colspan="2"><input value="'.
      _("Change Settings").'" type="submit" /><br />'.
      '<a href="'.SM_PATH.'src/configtest.php" target="_blank">'.
      _("Test Configuration")."</a></th></tr>\n".
-     '</table></td></tr></table></div></form>';
+     '</table></td></tr></table></form>';
 
 /*
     Write the options to the file.
@@ -635,8 +636,6 @@ if ( $fp = @fopen( $cfgfile, 'w' ) ) {
             fwrite( $fp, "$k = $v;\n" );
         }
     }
-    // add local config support
-    fwrite( $fp, "@include SM_PATH . 'config/config_local.php';\n" );
     // close php
     fwrite( $fp, '?>' );
     fclose( $fp );
@@ -645,5 +644,6 @@ if ( $fp = @fopen( $cfgfile, 'w' ) ) {
          _("Config file can't be opened. Please check config.php.").
          '</big></p>';
 }
+
 ?>
 </body></html>
\ No newline at end of file