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