Marc check this.
[squirrelmail.git] / plugins / administrator / options.php
index f9f06adda65a06addea32f87db61eb2681e39316..3963b972136cc82c63f97811b12deb2fa06cc833 100644 (file)
@@ -181,7 +181,7 @@ if ( isset( $switch ) ) {
 }
 
 echo "<form action=options.php method=post name=options>" .
-    "<br><center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
+    "<center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
     "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
     "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
 
@@ -383,7 +383,8 @@ if ( $colapse['Group7'] == 'off' ) {
         $k1 = "\$theme[$i]['NAME']";
         $e1 = "theme_name_$i";
         if ( isset( $HTTP_POST_VARS[$e1] ) ) {
-            $v1 = '"' . $HTTP_POST_VARS[$e1] . '"';
+            $v1 = '"' . str_replace( '\"', '"', $HTTP_POST_VARS[$e1] ) . '"';
+            $v1 = '"' . str_replace( '"', '\"', $v1 ) . '"';
             $newcfg[$k1] = $v1;
         } else {
             $v1 = $newcfg[$k1];
@@ -391,7 +392,8 @@ if ( $colapse['Group7'] == 'off' ) {
         $k2 = "\$theme[$i]['PATH']";
         $e2 = "theme_path_$i";
         if ( isset( $HTTP_POST_VARS[$e2] ) ) {
-            $v2 = '"' . $HTTP_POST_VARS[$e2] . '"';
+            $v2 = '"' . str_replace( '\"', '"', $HTTP_POST_VARS[$e2] ) . '"';
+            $v2 = '"' . str_replace( '"', '\"', $v2 ) . '"';
             $newcfg[$k2] = $v2;
         } else {
             $v2 = $newcfg[$k2];
@@ -484,46 +486,29 @@ echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
     Write the options to the file.
 */
 
-$fp = fopen( $cfgfile, 'w' );
-fwrite( $fp, "<?PHP\n".
-            "/**\n".
-            " * SquirrelMail Configuration File\n".
-            " * Created using the Administrator Plugin\n".
-            " */\n" );
-
-/*
-fwrite( $fp, 'GLOBAL ' );
-$not_first = FALSE;
-foreach ( $newcfg as $k => $v ) {
-    if ( $k{0} == '$' ) {
-        if( $i = strpos( $k, '[' ) ) {
-            if( strpos( $k, '[0]' ) ) {
-                if( $not_first ) {
-                    fwrite( $fp, ', ' );
-                }
-                fwrite( $fp, substr( $k, 0, $i) );
+if( $fp = @fopen( $cfgfile, 'w' ) ) {
+    fwrite( $fp, "<?PHP\n".
+    "/**\n".
+    " * SquirrelMail Configuration File\n".
+    " * Created using the Administrator Plugin\n".
+    " */\n" );
+
+    foreach ( $newcfg as $k => $v ) {
+        if ( $k{0} == '$' && $v <> '' ) {
+            if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
+                $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
+                $v = str_replace( 'array(', "array(\n\t", $v );
+                $v = str_replace( "',", "',\n\t", $v );
             }
-        } else {
-            if( $not_first ) {
-                fwrite( $fp, ', ' );
-            }
-            fwrite( $fp, $k );
+            fwrite( $fp, "$k = $v;\n" );
         }
-        $not_first = TRUE;
-    }
-}
-fwrite( $fp, ";\n" );
-*/
-foreach ( $newcfg as $k => $v ) {
-    if ( $k{0} == '$' && $v <> '' ) {
-        if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
-            $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
-            $v = str_replace( 'array(', "array(\n\t", $v );
-            $v = str_replace( "',", "',\n\t", $v );
-        }
-        fwrite( $fp, "$k = $v;\n" );
     }
+    fwrite( $fp, '?>' );
+    fclose( $fp );
+} else {
+    echo '<font size=+1><br>'.
+         _("Config file can't be opened. Please check config.php.").
+         '</font>';
 }
-fwrite( $fp, '?>' );
-fclose( $fp );
-?>
\ No newline at end of file
+
+?>