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