93370f64b1f96d463b006cb1a633930657a4fa5e
6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
14 function parseConfig( $cfg_file ) {
18 $cfg = file( $cfg_file );
22 for ( $i=0; $i < $j; $i++
) {
24 $first_char = $cfg[$i]{0};
27 $c = trim( $cfg[$i] );
28 $c = preg_replace( '/\/\*.*\*\//', '', $c );
29 $c = preg_replace( '/#.*$/', '', $c );
30 $c = preg_replace( '/\/\/.*$/', '', $c );
33 } while( $first_char == '$' && substr( $c, -1 ) <> ';' && $i < $j );
37 if( substr( $l, -2 ) == '*/' ) {
40 } else if( $k = strpos( $l, '*/' ) ) {
41 $l = substr( $l, $k );
47 if( $l{0}.$l{1} == '/*' ) {
50 } else if ( $k = strpos( $l, '/*' ) ) {
51 $l = substr( $l, 0, $k );
56 if ( $k = strpos( $l, '=' ) ) {
57 $key = trim( substr( $l, 0, $k - 1 ) );
58 $val = str_replace( ';', '', trim( substr( $l, $k +
1 ) ) );
66 /* ---------------------- main -------------------------- */
68 require_once('../src/validate.php');
69 require_once('../functions/page_header.php');
70 require_once('../functions/imap.php');
71 require_once('../src/load_prefs.php');
72 require_once('../plugins/administrator/defines.php');
75 if ( $adm_id = fileowner('../config/config.php') ) {
76 $adm = posix_getpwuid( $adm_id );
77 if ( $username == $adm['name'] ) {
83 header("Location: ../../src/options.php") ;
87 displayPageHeader($color, 'None');
91 foreach ( $defcfg as $key => $def ) {
95 $cfgfile = '../config/config.php';
96 parseConfig( '../config/config_default.php' );
97 parseConfig( $cfgfile );
99 echo "<form action=$PHP_SELF method=post>" .
100 "<br><center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
101 "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
102 "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>";
103 foreach ( $newcfg as $k => $v ) {
104 $l = strtolower( $v );
105 $type = SMOPT_TYPE_UNDEFINED
;
106 $n = substr( $k, 1 );
107 $n = str_replace( '[', '_', $n );
108 $n = str_replace( ']', '_', $n );
112 if ( isset( $defcfg[$k] ) ) {
113 $name = $defcfg[$k]['name'];
114 $type = $defcfg[$k]['type'];
115 $size = $defcfg[$k]['size'];
116 } else if ( $l == 'true' ) {
118 $type = SMOPT_TYPE_BOOLEAN
;
119 } else if ( $l == 'false' ) {
121 $type = SMOPT_TYPE_BOOLEAN
;
122 } else if ( $v{0} == "'" ) {
123 $type = SMOPT_TYPE_STRING
;
124 } else if ( $v{0} == '"' ) {
125 $type = SMOPT_TYPE_STRING
;
129 case SMOPT_TYPE_TITLE
:
130 echo "<tr bgcolor=\"$color[0]\"><th colspan=2>$name</th></tr>";
132 case SMOPT_TYPE_COMMENT
:
133 $v = substr( $v, 1, strlen( $v ) - 2 );
134 echo "<tr><td>$name</td><td>";
136 $newcfg[$k] = "'$v'";
138 case SMOPT_TYPE_INTEGER
:
139 if ( isset( $HTTP_POST_VARS[$e] ) ) {
140 $v = intval( $HTTP_POST_VARS[$e] );
143 echo "<tr><td>$name</td><td>";
144 echo "<input size=10 name=\"adm_$n\" value=\"$v\">";
146 case SMOPT_TYPE_NUMLIST
:
147 if ( isset( $HTTP_POST_VARS[$e] ) ) {
148 $v = $HTTP_POST_VARS[$e];
151 echo "<tr><td>$name</td><td>";
152 echo "<select name=\"adm_$n\">";
153 foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
154 echo "<option value=\"$kp\"";
158 echo ">$vp</option>";
162 case SMOPT_TYPE_STRLIST
:
163 if ( isset( $HTTP_POST_VARS[$e] ) ) {
164 $v = '"' . $HTTP_POST_VARS[$e] . '"';
167 echo "<tr><td>$name</td><td>";
168 echo "<select name=\"adm_$n\">";
169 foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
170 echo "<option value=\"$kp\"";
171 if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
174 echo ">$vp</option>";
179 case SMOPT_TYPE_STRING
:
180 if ( isset( $HTTP_POST_VARS[$e] ) ) {
181 $v = '"' . $HTTP_POST_VARS[$e] . '"';
184 echo "<tr><td>$name</td><td>";
185 echo "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
187 case SMOPT_TYPE_BOOLEAN
:
188 if ( isset( $HTTP_POST_VARS[$e] ) ) {
189 $v = $HTTP_POST_VARS[$e];
192 if ( $v == 'TRUE' ) {
199 echo "<tr><td>$name</td><td>";
200 echo "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
201 "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
204 echo "<tr><td>$name</td><td>";
205 echo "<b><i>$v</i></b>";
209 echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
210 _("Change Settings") . "\" type=submit></th></tr>" ,
211 '</table></td></tr></table></form>';
214 Write the options to the file.
216 $fp = fopen( $cfgfile, 'w' );
217 fwrite( $fp, "<?PHP\n".
219 " * SquirrelMail Configuration File\n".
220 " * Created using the Administrator Plugin\n".
223 fwrite( $fp, 'GLOBAL ' );
225 foreach ( $newcfg as $k => $v ) {
226 if ( $k{0} == '$' ) {
227 if( $i = strpos( $k, '[' ) ) {
228 if( strpos( $k, '[0]' ) ) {
232 fwrite( $fp, substr( $k, 0, $i) );
244 fwrite( $fp, ";\n" );
245 foreach ( $newcfg as $k => $v ) {
246 if ( $k{0} == '$' ) {
247 fwrite( $fp, "$k = $v;\n" );