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