6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
15 require_once('../src/validate.php');
16 require_once('../functions/page_header.php');
17 require_once('../functions/imap.php');
18 require_once('../src/load_prefs.php');
19 require_once('../plugins/administrator/defines.php');
21 displayPageHeader($color, 'None');
23 $cfgfile = '../config/config.php';
24 $cfg_defaultfile = '../config/config_default.php';
25 $cfg = file( $cfg_defaultfile );
26 $newcfg = $dfncfg = array( );
29 foreach ( $defcfg as $key => $def ) {
33 foreach ( $cfg as $l ) {
34 // Remove inline /* */ Blocks
35 $l = preg_replace( '/\/\*.*\*\//', '', $l );
36 $l = preg_replace( '/#.*$/', '', $l );
37 $l = preg_replace( '/\/\/.*$/', '', $l );
40 if( substr( $v, -2 ) == '*/' ) {
43 } else if( $i = strpos( $v, '*/' ) ) {
44 $v = substr( $v, $i );
50 if( $v{0}.$v{1} == '/*' ) {
53 } else if ( $i = strpos( $v, '/*' ) ) {
54 $v = substr( $v, 0, $i );
59 if ( $i = strpos( $v, '=' ) ) {
60 $key = trim( substr( $v, 0, $i - 1 ) );
61 $val = str_replace( ';', '', trim( substr( $v, $i +
1 ) ) );
68 $cfg = file( $cfgfile );
71 foreach ( $cfg as $l ) {
72 $l = preg_replace( '/\/\*.*\*\//', '', $l );
73 $l = preg_replace( '/#.*$/', '', $l );
74 $l = preg_replace( '/\/\/.*$/', '', $l );
77 if( substr( $v, -2 ) == '*/' ) {
80 } else if( $i = strpos( $v, '*/' ) ) {
81 $v = substr( $v, $i );
87 if( $v{0}.$v{1} == '/*' ) {
90 } else if ( $i = strpos( $v, '/*' ) ) {
91 $v = substr( $v, 0, $i );
96 if ( $i = strpos( $v, '=' ) ) {
97 $key = trim( substr( $v, 0, $i - 1 ) );
98 $val = str_replace( ';', '', trim( substr( $v, $i +
1 ) ) );
104 echo "<form action=$PHP_SELF method=post>" .
105 "<br><center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
106 "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
107 "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
108 foreach ( $newcfg as $k => $v ) {
109 $l = strtolower( $v );
110 $type = SMOPT_TYPE_UNDEFINED
;
111 $n = substr( $k, 1 );
112 $n = str_replace( '[', '_', $n );
113 $n = str_replace( ']', '_', $n );
117 if ( isset( $defcfg[$k] ) ) {
118 $name = $defcfg[$k]['name'];
119 $type = $defcfg[$k]['type'];
120 $size = $defcfg[$k]['size'];
121 } else if ( $l == 'true' ) {
123 $type = SMOPT_TYPE_BOOLEAN
;
124 } else if ( $l == 'false' ) {
126 $type = SMOPT_TYPE_BOOLEAN
;
127 } else if ( $v{0} == "'" ) {
128 $type = SMOPT_TYPE_STRING
;
129 } else if ( $v{0} == '"' ) {
130 $type = SMOPT_TYPE_STRING
;
134 case SMOPT_TYPE_TITLE
:
135 echo "<tr bgcolor=\"$color[5]\"><th colspan=2>$name</th></tr>";
137 case SMOPT_TYPE_COMMENT
:
138 $v = substr( $v, 1, strlen( $v ) - 2 );
139 echo "<tr><td>$name</td><td>";
141 $newcfg[$k] = "'$v'";
143 case SMOPT_TYPE_INTEGER
:
144 if ( isset( $HTTP_POST_VARS[$e] ) ) {
145 $v = intval( $HTTP_POST_VARS[$e] );
148 echo "<tr><td>$name</td><td>";
149 echo "<input size=10 name=\"adm_$n\" value=\"$v\">";
151 case SMOPT_TYPE_STRLIST
:
152 if ( isset( $HTTP_POST_VARS[$e] ) ) {
153 $v = '"' . $HTTP_POST_VARS[$e] . '"';
156 echo "<tr><td>$name</td><td>";
157 echo "<select name=\"adm_$n\">";
158 foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
159 echo "<option value=\"$kp\"";
160 if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
163 echo ">$vp</option>";
168 case SMOPT_TYPE_STRING
:
169 if ( isset( $HTTP_POST_VARS[$e] ) ) {
170 $v = '"' . $HTTP_POST_VARS[$e] . '"';
173 echo "<tr><td>$name</td><td>";
174 echo "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
176 case SMOPT_TYPE_BOOLEAN
:
177 if ( isset( $HTTP_POST_VARS[$e] ) ) {
178 $v = $HTTP_POST_VARS[$e];
181 if ( $v == 'TRUE' ) {
188 echo "<tr><td>$name</td><td>";
189 echo "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
190 "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
193 echo "<tr><td>$name</td><td>";
194 echo "<b><i>$v</i></b>";
198 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
199 _("Change Settings") . "\" type=submit></th></tr>" ,
200 '</table></td></tr></table></form>';
203 Write the options to the file.
205 $fp = fopen( $cfgfile, 'w' );
206 fwrite( $fp, "<?PHP\n".
208 " * SquirrelMail Configuration File\n".
209 " * Created using the Administrator Plugin\n".
212 fwrite( $fp, 'GLOBAL ' );
214 foreach ( $newcfg as $k => $v ) {
215 if ( $k{0} == '$' ) {
216 if( $i = strpos( $k, '[' ) ) {
217 if( strpos( $k, '[0]' ) ) {
221 fwrite( $fp, substr( $k, 0, $i) );
233 fwrite( $fp, ";\n" );
234 foreach ( $newcfg as $k => $v ) {
235 if ( $k{0} == '$' ) {
236 fwrite( $fp, "$k = $v;\n" );