utf-8 is already converted by ja_JP extra functions.
[squirrelmail.git] / plugins / administrator / options.php
CommitLineData
abd7a3f8 1<?php
2
3/**
4 * Administrator Plugin
5 *
76911253 6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
abd7a3f8 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Philippe Mingo
10 *
11 * $Id$
12 */
13
37d90494 14function parseConfig( $cfg_file ) {
15
16 global $newcfg;
17
18 $cfg = file( $cfg_file );
71e5c245 19 $mode = '';
20 $l = count( $cfg );
21 $modifier = FALSE;
37d90494 22
71e5c245 23 for ($i=0;$i<$l;$i++) {
24 $line = trim( $cfg[$i] );
25 $s = strlen( $line );
26 for ($j=0;$j<$s;$j++) {
27 switch ( $mode ) {
28 case '=':
29 if ( $line{$j} == '=' ) {
30 // Ok, we've got a right value, lets detect what type
31 $mode = 'D';
32 } else if ( $line{$j} == ';' ) {
33 // hu! end of command
34 $key = $mode = '';
35 }
36 break;
37 case 'K':
38 // Key detect
39 if( $line{$j} == ' ' ) {
40 $mode = '=';
37d90494 41 } else {
71e5c245 42 $key .= $line{$j};
37d90494 43 }
71e5c245 44 break;
45 case ';':
46 // Skip until next ;
47 if ( $line{$j} == ';' ) {
48 $mode = '';
49 }
50 break;
51 case 'S':
52 if ( $line{$j} == '\\' ) {
53 $value .= $line{$j};
54 $modifier = TRUE;
55 } else if ( $line{$j} == $delimiter && $modifier === FALSE ) {
56 // End of string;
57 $newcfg[$key] = $value . $delimiter;
58 $key = $value = '';
59 $mode = ';';
60 } else {
61 $value .= $line{$j};
62 $modifier = FALSE;
63 }
64 break;
65 case 'N':
66 if ( $line{$j} == ';' ) {
67 $newcfg{$key} = $value;
68 $key = $mode = '';
69 } else {
70 $value .= $line{$j};
71 }
72 break;
73 case 'C':
74 // Comments
88cb1b4d 75 if ( $s > $j + 1 &&
76 $line{$j}.$line{$j+1} == '*/' ) {
71e5c245 77 $mode = '';
78 $j++;
79 }
80 break;
81 case 'D':
82 // Delimiter detect
83 switch ( $line{$j} ) {
84 case '"':
85 case "'":
86 // Double quote string
87 $delimiter = $value = $line{$j};
88 $mode = 'S';
89 break;
90 case ' ':
91 // Nothing yet
92 break;
93 default:
94 if ( strtoupper( substr( $line, $j, 4 ) ) == 'TRUE' ) {
95 // Boolean TRUE
96 $newcfg{$key} = 'TRUE';
97 $key = '';
98 $mode = ';';
99 } else if ( strtoupper( substr( $line, $j, 5 ) ) == 'FALSE' ) {
100 $newcfg{$key} = 'FALSE';
101 $key = '';
102 $mode = ';';
103 } else {
104 // Number or function call
105 $mode = 'N';
106 $value = $line{$j};
107 }
108 }
109 break;
110 default:
88cb1b4d 111 if ( $line{$j} == '$' ) {
112 // We must detect $key name
113 $mode = 'K';
114 $key = '$';
115 } else if ( $s < $j + 2 ) {
116 } else if ( strtoupper( substr( $line, $j, 7 ) ) == 'GLOBAL ' ) {
71e5c245 117 // Skip untill next ;
118 $mode = ';';
119 $j += 6;
120 } else if ( $line{$j}.$line{$j+1} == '/*' ) {
121 $mode = 'C';
122 $j++;
123 } else if ( $line{$j} == '#' || $line{$j}.$line{$j+1} == '//' ) {
124 // Delete till the end of the line
125 $j = $s;
37d90494 126 }
37d90494 127 }
128 }
37d90494 129 }
a28a56da 130}
131
132/* Change paths containing SM_PATH to admin-friendly paths
133 relative to the config dir, i.e.:
134 '' --> <empty string>
135 SM_PATH . 'images/logo.gif' --> ../images/logo.gif
136 '/absolute/path/logo.gif' --> /absolute/path/logo.gif
137 'http://whatever/' --> http://whatever
138 Note removal of quotes in returned value
139*/
140function change_to_rel_path($old_path) {
141 $new_path = str_replace("SM_PATH . '", "../", $old_path);
142 $new_path = str_replace("../config/","", $new_path);
143 $new_path = str_replace("'","", $new_path);
144 return $new_path;
145}
37d90494 146
a28a56da 147/* Change relative path (relative to config dir) to
148 internal SM_PATH, i.e.:
149 empty_string --> ''
150 ../images/logo.gif --> SM_PATH . 'images/logo.gif'
151 images/logo.gif --> SM_PATH . 'config/images/logo.gif'
152 /absolute/path/logo.gif --> '/absolute/path/logo.gif'
153 http://whatever/ --> 'http://whatever'
154*/
155function change_to_sm_path($old_path) {
156 if ( $old_path === '' || $old_path == "''" ) {
157 return "''";
158 } elseif ( preg_match("/^(\/|http)/", $old_path) ) {
159 return "'" . $old_path . "'";
160 } elseif ( preg_match("/^(\$|SM_PATH)/", $old_path) ) {
161 return $old_path;
162 }
163
164 $new_path = '';
165 $rel_path = explode("../", $old_path);
166 if ( count($rel_path) > 2 ) {
167 // Since we're relative to the config dir,
168 // more than 1 ../ puts us OUTSIDE the SM tree.
169 // get full path to config.php, then pop the filename
170 $abs_path = explode('/', realpath (SM_PATH . 'config/config.php'));
171 array_pop ($abs_path);
172 foreach ( $rel_path as $subdir ) {
173 if ( $subdir === '' ) {
174 array_pop ($abs_path);
175 } else {
176 array_push($abs_path, $subdir);
177 }
178 }
179 foreach ($abs_path as $subdir) {
180 $new_path .= $subdir . '/';
181 }
182 $new_path = "'$new_path'";
183 } elseif ( count($rel_path) > 1 ) {
184 // we're within the SM tree, prepend SM_PATH
185 $new_path = str_replace('../',"SM_PATH . '", $old_path . "'");
186 } else {
187 // Last, if it's a relative path without a .. prefix,
188 // we're somewhere within the config dir, so prepend
189 // SM_PATH . 'config/
190 $new_path = "SM_PATH . 'config/" . $old_path . "'";
191 }
192 return $new_path;
37d90494 193}
71e5c245 194
a28a56da 195
37d90494 196/* ---------------------- main -------------------------- */
71e5c245 197
8d6a115b 198define('SM_PATH','../../');
cf1efdce 199
200/* SquirrelMail required files. */
201require_once(SM_PATH . 'include/validate.php');
202require_once(SM_PATH . 'functions/page_header.php');
203require_once(SM_PATH . 'functions/imap.php');
aa7fb30c 204require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 205require_once(SM_PATH . 'plugins/administrator/defines.php');
206require_once(SM_PATH . 'plugins/administrator/auth.php');
abd7a3f8 207
a3fab7e3 208GLOBAL $data_dir, $username;
209
7004cc32 210if ( !adm_check_user() ) {
a28a56da 211 header('Location: ' . SM_PATH . 'src/options.php') ;
dcd6f144 212 exit;
213}
214
abd7a3f8 215displayPageHeader($color, 'None');
216
37d90494 217$newcfg = array( );
0e66bc84 218
219foreach ( $defcfg as $key => $def ) {
220 $newcfg[$key] = '';
221}
222
b59d1a7d 223$cfgfile = SM_PATH . 'config/config.php';
224parseConfig( SM_PATH . 'config/config_default.php' );
37d90494 225parseConfig( $cfgfile );
abd7a3f8 226
88cb1b4d 227$colapse = array( 'Titles' => 'off',
228 'Group1' => getPref($data_dir, $username, 'adm_Group1', 'off' ),
229 'Group2' => getPref($data_dir, $username, 'adm_Group2', 'on' ),
230 'Group3' => getPref($data_dir, $username, 'adm_Group3', 'on' ),
231 'Group4' => getPref($data_dir, $username, 'adm_Group4', 'on' ),
232 'Group5' => getPref($data_dir, $username, 'adm_Group5', 'on' ),
233 'Group6' => getPref($data_dir, $username, 'adm_Group6', 'on' ),
234 'Group7' => getPref($data_dir, $username, 'adm_Group7', 'on' ),
39d3ec89 235 'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ),
236 'Group9' => getPref($data_dir, $username, 'adm_Group9', 'on' ),
237 'Group10' => getPref($data_dir, $username, 'adm_Group10', 'on' ) );
a3fab7e3 238
4cd8ae7d 239/* look in $_GET array for 'switch' */
240if ( sqgetGlobalVar('switch', $switch, SQ_GET) ) {
88cb1b4d 241 if ( $colapse[$switch] == 'on' ) {
242 $colapse[$switch] = 'off';
243 } else {
244 $colapse[$switch] = 'on';
245 }
a3fab7e3 246 setPref($data_dir, $username, "adm_$switch", $colapse[$switch] );
247}
248
88cb1b4d 249echo "<form action=options.php method=post name=options>" .
6206f6c4 250 "<center><table width=95% bgcolor=\"$color[5]\"><tr><td>".
0e66bc84 251 "<table width=100% cellspacing=0 bgcolor=\"$color[4]\">" ,
b8319c5c 252 "<tr bgcolor=\"$color[5]\"><th colspan=2>" . _("Configuration Administrator") . "</th></tr>",
39d3ec89 253 "<tr bgcolor=\"$color[5]\"><td colspan=2 align=\"center\">";
254
255echo "<small>";
256echo _("Note: it is recommended that you configure your system using conf.pl, and not this plugin. conf.pl contains additional information regarding the purpose of variables and appropriate values, as well as additional verification steps.");
257echo "<br />";
258echo _("Run or consult conf.pl should you run into difficulty with your configuration.");
259echo "</small></td></tr>";
260
a3fab7e3 261
262$act_grp = 'Titles'; /* Active group */
c83b38c1 263
abd7a3f8 264foreach ( $newcfg as $k => $v ) {
265 $l = strtolower( $v );
266 $type = SMOPT_TYPE_UNDEFINED;
267 $n = substr( $k, 1 );
268 $n = str_replace( '[', '_', $n );
269 $n = str_replace( ']', '_', $n );
270 $e = 'adm_' . $n;
271 $name = $k;
272 $size = 50;
0e66bc84 273 if ( isset( $defcfg[$k] ) ) {
274 $name = $defcfg[$k]['name'];
275 $type = $defcfg[$k]['type'];
88cb1b4d 276 if ( isset( $defcfg[$k]['size'] ) ) {
277 $size = $defcfg[$k]['size'];
278 } else {
279 $size = 40;
280 }
abd7a3f8 281 } else if ( $l == 'true' ) {
282 $v = 'TRUE';
283 $type = SMOPT_TYPE_BOOLEAN;
284 } else if ( $l == 'false' ) {
285 $v = 'FALSE';
286 $type = SMOPT_TYPE_BOOLEAN;
287 } else if ( $v{0} == "'" ) {
288 $type = SMOPT_TYPE_STRING;
289 } else if ( $v{0} == '"' ) {
290 $type = SMOPT_TYPE_STRING;
291 }
292
edd4a552 293 if ( substr( $k, 0, 7 ) == '$theme[' ) {
294 $type = SMOPT_TYPE_THEME;
295 } else if ( substr( $k, 0, 9 ) == '$plugins[' ) {
296 $type = SMOPT_TYPE_PLUGINS;
65a5bae6 297 } else if ( substr( $k, 0, 13 ) == '$ldap_server[' ) {
298 $type = SMOPT_TYPE_LDAP;
edd4a552 299 }
300
88cb1b4d 301 if( $type == SMOPT_TYPE_TITLE || $colapse[$act_grp] == 'off' ) {
a3fab7e3 302
303 switch ( $type ) {
304 case SMOPT_TYPE_LDAP:
305 case SMOPT_TYPE_PLUGINS:
306 case SMOPT_TYPE_THEME:
307 case SMOPT_TYPE_HIDDEN:
308 break;
88cb1b4d 309 case SMOPT_TYPE_EXTERNAL:
310 echo "<tr><td>$name</td><td><b>" .
311 $defcfg[$k]['value'] .
312 "</b></td></tr>";
313 break;
a3fab7e3 314 case SMOPT_TYPE_TITLE:
88cb1b4d 315 if ( $colapse[$k] == 'on' ) {
a3fab7e3 316 $sw = '(+)';
317 } else {
318 $sw = '(-)';
dcd6f144 319 }
a3fab7e3 320 echo "<tr bgcolor=\"$color[0]\"><th colspan=2>" .
321 "<a href=options.php?switch=$k STYLE=\"text-decoration:none\"><b>$sw</b> </a>" .
322 "$name</th></tr>";
323 $act_grp = $k;
324 break;
325 case SMOPT_TYPE_COMMENT:
326 $v = substr( $v, 1, strlen( $v ) - 2 );
327 echo "<tr><td>$name</td><td>".
328 "<b>$v</b>";
329 $newcfg[$k] = "'$v'";
330 if ( isset( $defcfg[$k]['comment'] ) ) {
331 echo ' &nbsp; ' . $defcfg[$k]['comment'];
abd7a3f8 332 }
a3fab7e3 333 echo "</td></tr>\n";
334 break;
335 case SMOPT_TYPE_INTEGER:
4cd8ae7d 336 /* look for variable $e in POST, fill into $v */
337 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
338 $v = intval( $v );
a3fab7e3 339 $newcfg[$k] = $v;
340 }
341 echo "<tr><td>$name</td><td>".
342 "<input size=10 name=\"adm_$n\" value=\"$v\">";
343 if ( isset( $defcfg[$k]['comment'] ) ) {
344 echo ' &nbsp; ' . $defcfg[$k]['comment'];
345 }
346 echo "</td></tr>\n";
347 break;
348 case SMOPT_TYPE_NUMLIST:
4cd8ae7d 349 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
a3fab7e3 350 $newcfg[$k] = $v;
351 }
352 echo "<tr><td>$name</td><td>";
353 echo "<select name=\"adm_$n\">";
354 foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
355 echo "<option value=\"$kp\"";
356 if ( $kp == $v ) {
357 echo ' selected';
358 }
359 echo ">$vp</option>";
360 }
361 echo '</select>';
362 if ( isset( $defcfg[$k]['comment'] ) ) {
363 echo ' &nbsp; ' . $defcfg[$k]['comment'];
364 }
365 echo "</td></tr>\n";
366 break;
367 case SMOPT_TYPE_STRLIST:
4cd8ae7d 368 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
369 $v = '"' . $v . '"';
a3fab7e3 370 $newcfg[$k] = $v;
371 }
372 echo "<tr><td>$name</td><td>".
373 "<select name=\"adm_$n\">";
374 foreach ( $defcfg[$k]['posvals'] as $kp => $vp ) {
375 echo "<option value=\"$kp\"";
376 if ( $kp == substr( $v, 1, strlen( $v ) - 2 ) ) {
377 echo ' selected';
378 }
379 echo ">$vp</option>";
380 }
381 echo '</select>';
382 if ( isset( $defcfg[$k]['comment'] ) ) {
383 echo ' &nbsp; ' . $defcfg[$k]['comment'];
384 }
385 echo "</td></tr>\n";
386 break;
c83b38c1 387
a3fab7e3 388 case SMOPT_TYPE_TEXTAREA:
4cd8ae7d 389 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
390 $v = '"' . $v . '"';
a3fab7e3 391 $newcfg[$k] = str_replace( "\n", '', $v );
392 }
393 echo "<tr><td valign=top>$name</td><td>".
394 "<textarea cols=\"$size\" name=\"adm_$n\">" . substr( $v, 1, strlen( $v ) - 2 ) . "</textarea>";
395 if ( isset( $defcfg[$k]['comment'] ) ) {
396 echo ' &nbsp; ' . $defcfg[$k]['comment'];
397 }
398 echo "</td></tr>\n";
399 break;
400 case SMOPT_TYPE_STRING:
4cd8ae7d 401 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
402 $v = '"' . $v . '"';
a3fab7e3 403 $newcfg[$k] = $v;
404 }
feba1a41 405 if ( $v == '""' && isset( $defcfg[$k]['default'] ) ) {
406 $v = "'" . $defcfg[$k]['default'] . "'";
407 $newcfg[$k] = $v;
408 }
a3fab7e3 409 echo "<tr><td>$name</td><td>".
410 "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . "\">";
411 if ( isset( $defcfg[$k]['comment'] ) ) {
412 echo ' &nbsp; ' . $defcfg[$k]['comment'];
413 }
414 echo "</td></tr>\n";
415 break;
416 case SMOPT_TYPE_BOOLEAN:
4cd8ae7d 417 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
a3fab7e3 418 $newcfg[$k] = $v;
419 } else {
420 $v = strtoupper( $v );
421 }
422 if ( $v == 'TRUE' ) {
423 $ct = ' checked';
424 $cf = '';
425 } else {
426 $ct = '';
427 $cf = ' checked';
428 }
429 echo "<tr><td>$name</td><td>" .
430 "<INPUT$ct type=radio NAME=\"adm_$n\" value=\"TRUE\">" . _("Yes") .
431 "<INPUT$cf type=radio NAME=\"adm_$n\" value=\"FALSE\">" . _("No");
432 if ( isset( $defcfg[$k]['comment'] ) ) {
433 echo ' &nbsp; ' . $defcfg[$k]['comment'];
434 }
435 echo "</td></tr>\n";
436 break;
a28a56da 437 case SMOPT_TYPE_PATH:
4cd8ae7d 438 if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
439 $v = change_to_sm_path($v);
a28a56da 440 $newcfg[$k] = $v;
441 }
442 if ( $v == "''" && isset( $defcfg[$k]['default'] ) ) {
443 $v = change_to_sm_path($defcfg[$k]['default']);
444 $newcfg[$k] = $v;
445 }
446 echo "<tr><td>$name</td><td>".
447 "<input size=\"$size\" name=\"adm_$n\" value=\"" . change_to_rel_path($v) . "\">";
448 if ( isset( $defcfg[$k]['comment'] ) ) {
449 echo ' &nbsp; ' . $defcfg[$k]['comment'];
450 }
451 echo "</td></tr>\n";
452 break;
a3fab7e3 453 default:
454 echo "<tr><td>$name</td><td>" .
455 "<b><i>$v</i></b>";
456 if ( isset( $defcfg[$k]['comment'] ) ) {
457 echo ' &nbsp; ' . $defcfg[$k]['comment'];
458 }
459 echo "</td></tr>\n";
6a9acbca 460 }
a3fab7e3 461 }
a3fab7e3 462}
463
1fa5ece1 464/* Special Themes Block */
88cb1b4d 465if ( $colapse['Group7'] == 'off' ) {
a3fab7e3 466 $i = 0;
467 echo '<tr><th>' . _("Theme Name") .
468 '</th><th>' . _("Theme Path") .
469 '</th></tr>';
470 while ( isset( $newcfg["\$theme[$i]['NAME']"] ) ) {
471 $k1 = "\$theme[$i]['NAME']";
472 $e1 = "theme_name_$i";
4cd8ae7d 473 if ( sqgetGlobalVar($e, $v1, SQ_POST) ) {
474 $v1 = '"' . str_replace( '\"', '"', $v1 ) . '"';
b5a29535 475 $v1 = '"' . str_replace( '"', '\"', $v1 ) . '"';
a3fab7e3 476 $newcfg[$k1] = $v1;
a55bb207 477 } else {
a3fab7e3 478 $v1 = $newcfg[$k1];
abd7a3f8 479 }
a3fab7e3 480 $k2 = "\$theme[$i]['PATH']";
481 $e2 = "theme_path_$i";
4cd8ae7d 482 if ( sqgetGlobalVar($e, $v2, SQ_POST) ) {
483 $v2 = change_to_sm_path($v2);
a28a56da 484 $newcfg[$k2] = $v2;
abd7a3f8 485 } else {
a3fab7e3 486 $v2 = $newcfg[$k2];
abd7a3f8 487 }
a3fab7e3 488 $name = substr( $v1, 1, strlen( $v1 ) - 2 );
a28a56da 489 $path = change_to_rel_path($v2);
a3fab7e3 490 echo '<tr>'.
491 "<td align=right>$i. <input name=\"$e1\" value=\"$name\" size=30></td>".
492 "<td><input name=\"$e2\" value=\"$path\" size=40></td>".
493 "</tr>\n";
494 $i++;
c83b38c1 495
6a9acbca 496 }
6a9acbca 497}
498
1fa5ece1 499/* Special Plugins Block */
88cb1b4d 500if ( $colapse['Group8'] == 'on' ) {
a3fab7e3 501 $sw = '(+)';
502} else {
503 $sw = '(-)';
6a9acbca 504}
a3fab7e3 505echo "<tr bgcolor=\"$color[0]\"><th colspan=2>" .
c83b38c1 506 "<a href=options.php?switch=Group8 STYLE=\"text-decoration:none\"><b>$sw</b> </a>" .
a3fab7e3 507 _("Plugins") . '</th></tr>';
6a9acbca 508
88cb1b4d 509if( $colapse['Group8'] == 'off' ) {
6a9acbca 510
f0b554f9 511 $plugpath = SM_PATH . 'plugins/';
512 if ( file_exists($plugpath) ) {
513 $fd = opendir( $plugpath );
514 $op_plugin = array();
515 $p_count = 0;
516 while (false !== ($file = readdir($fd))) {
517 if ($file != '.' && $file != '..' && $file != 'CVS' && is_dir($plugpath . $file) ) {
518 $op_plugin[] = $file;
519 $p_count++;
6a9acbca 520 }
f0b554f9 521 }
522 closedir($fd);
523 asort( $op_plugin );
c83b38c1 524
f0b554f9 525 /* Lets get the plugins that are active */
526 $plugins = array();
4cd8ae7d 527 if ( sqgetGlobalVar('plg', $v, SQ_POST) ) {
c83b38c1 528 foreach ( $op_plugin as $plg ) {
4cd8ae7d 529 if ( sqgetGlobalVar("plgs_$plg", $v, SQ_POST) && $v == 'on' ) {
c83b38c1 530 $plugins[] = $plg;
531 }
532 }
533 $i = 0;
534 foreach ( $plugins as $plg ) {
535 $k = "\$plugins[$i]";
536 $newcfg[$k] = "'$plg'";
537 $i++;
538 }
539 while ( isset( $newcfg["\$plugins[$i]"] ) ) {
540 $k = "\$plugins[$i]";
541 $newcfg[$k] = '';
542 $i++;
543 }
f0b554f9 544 } else {
c83b38c1 545 $i = 0;
546 while ( isset( $newcfg["\$plugins[$i]"] ) ) {
547 $k = "\$plugins[$i]";
a3fab7e3 548 $v = $newcfg[$k];
c83b38c1 549 $plugins[] = substr( $v, 1, strlen( $v ) - 2 );
550 $i++;
6a9acbca 551 }
f0b554f9 552 }
553 echo "<tr><td colspan=2><input type=hidden name=plg value=on><center><table><tr><td>";
554 foreach ( $op_plugin as $plg ) {
c83b38c1 555 if ( in_array( $plg, $plugins ) ) {
556 $sw = ' checked';
557 } else {
558 $sw = '';
a3fab7e3 559 }
c83b38c1 560 echo '<tr>' .
561 "<td>$plg</td><td><input$sw type=checkbox name=plgs_$plg></td>".
88cb1b4d 562 "</tr>\n";
f0b554f9 563 }
564 echo '</td></tr></table></td></tr>';
565 } else {
566 echo '<tr><td colspan=2 align="center">Plugin directory could not be found: ' . $plugpath . "</td></tr>\n";
567 }
6a9acbca 568}
abd7a3f8 569echo "<tr bgcolor=\"$color[5]\"><th colspan=2><input value=\"" .
570 _("Change Settings") . "\" type=submit></th></tr>" ,
0e66bc84 571 '</table></td></tr></table></form>';
abd7a3f8 572
573/*
574 Write the options to the file.
575*/
71e5c245 576
c05c489a 577if( $fp = @fopen( $cfgfile, 'w' ) ) {
578 fwrite( $fp, "<?PHP\n".
b5a29535 579 "/**\n".
580 " * SquirrelMail Configuration File\n".
581 " * Created using the Administrator Plugin\n".
39d3ec89 582 " */\n".
583 "\n".
584 "global \$version;\n" );
b5a29535 585
c05c489a 586 foreach ( $newcfg as $k => $v ) {
b5a29535 587 if ( $k{0} == '$' && $v <> '' ) {
c05c489a 588 if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
b5a29535 589 $v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
590 $v = str_replace( 'array(', "array(\n\t", $v );
591 $v = str_replace( "',", "',\n\t", $v );
c05c489a 592 }
593 fwrite( $fp, "$k = $v;\n" );
b5a29535 594 }
0e66bc84 595 }
c05c489a 596 fwrite( $fp, '?>' );
597 fclose( $fp );
598} else {
599 echo '<font size=+1><br>'.
600 _("Config file can't be opened. Please check config.php.").
601 '</font>';
abd7a3f8 602}
6206f6c4 603?>