* This script creates separate page, that allows to review and modify
* SquirrelMail configuration file.
*
- * @version $Id$
* @author Philippe Mingo
- * @copyright (c) 1999-2004 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
* @package plugins
* @subpackage administrator
*/
$mode = '';
$l = count( $cfg );
$modifier = FALSE;
+ $arraykey = 0;
for ($i=0;$i<$l;$i++) {
$line = trim( $cfg[$i] );
$mode = '=';
} else {
$key .= $line{$j};
+ // FIXME: this is only pour workaround for plugins[] array.
+ if ($line{$j}=='[' && $line{($j+1)}==']') {
+ $key .= $arraykey;
+ $arraykey++;
+ }
}
break;
case ';':
/* ---------------------- main -------------------------- */
-
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'functions/imap.php');
-require_once(SM_PATH . 'include/load_prefs.php');
-require_once(SM_PATH . 'plugins/administrator/defines.php');
-require_once(SM_PATH . 'plugins/administrator/auth.php');
+/** main SquirrelMail include */
+require('../../include/init.php');
+/* configuration definitions */
+include_once(SM_PATH . 'plugins/administrator/defines.php');
+/* additional functions */
+include_once(SM_PATH . 'plugins/administrator/auth.php');
global $data_dir, $username;
'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ),
'Group9' => getPref($data_dir, $username, 'adm_Group9', 'on' ),
'Group10' => getPref($data_dir, $username, 'adm_Group10', 'on' ),
- 'Group11' => getPref($data_dir, $username, 'adm_Group10', 'on' ) );
+ 'Group11' => getPref($data_dir, $username, 'adm_Group11', 'on' ) );
/* look in $_GET array for 'switch' */
if ( sqgetGlobalVar('switch', $switch, SQ_GET) ) {
}
echo '<form action="options.php" method="post" name="options">' .
- '<center><table width="95%" bgcolor="'.$color[5].'"><tr><td>'.
+ '<table width="95%" align="center" bgcolor="'.$color[5].'"><tr><td>'.
'<table width="100%" cellspacing="0" bgcolor="'.$color[4].'">'.
'<tr bgcolor="'.$color[5].'"><th colspan="2">'.
_("Configuration Administrator").'</th></tr>'.
$type = SMOPT_TYPE_PLUGINS;
} else if ( substr( $k, 0, 13 ) == '$ldap_server[' ) {
$type = SMOPT_TYPE_LDAP;
+ } else if ( substr( $k, 0, 9 ) == '$fontsets' ||
+ substr( $k, 0, 13 ) == '$aTemplateSet' ) {
+ $type = SMOPT_TYPE_CUSTOM;
}
if ( $type == SMOPT_TYPE_TITLE || $colapse[$act_grp] == 'off' ) {
switch ( $type ) {
case SMOPT_TYPE_LDAP:
+ case SMOPT_TYPE_CUSTOM:
case SMOPT_TYPE_PLUGINS:
case SMOPT_TYPE_THEME:
case SMOPT_TYPE_HIDDEN:
break;
case SMOPT_TYPE_INTEGER:
/* look for variable $e in POST, fill into $v */
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
- $v = intval( $v );
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = intval( $new_v );
$newcfg[$k] = $v;
}
echo "<tr><td>$name</td><td>".
echo "</td></tr>\n";
break;
case SMOPT_TYPE_NUMLIST:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = $new_v;
$newcfg[$k] = $v;
}
echo "<tr><td>$name</td><td>";
echo "</td></tr>\n";
break;
case SMOPT_TYPE_STRLIST:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
- $v = '"' . $v . '"';
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = '"' . $new_v . '"';
$newcfg[$k] = $v;
}
echo "<tr><td>$name</td><td>".
break;
case SMOPT_TYPE_TEXTAREA:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
- $v = '"' . $v . '"';
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = '"' . addslashes($new_v) . '"';
$newcfg[$k] = str_replace( "\n", '', $v );
}
- echo "<tr><td valign=\"top\">$name</td><td>".
- "<textarea cols=\"$size\" rows=\"4\" name=\"adm_$n\">" . substr( $v, 1, strlen( $v ) - 2 ) . "</textarea>";
+ echo "<tr><td valign=\"top\">$name</td><td>"
+ ."<textarea cols=\"$size\" rows=\"4\" name=\"adm_$n\">"
+ .htmlspecialchars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+ ."</textarea>";
if ( isset( $defcfg[$k]['comment'] ) ) {
echo ' ' . $defcfg[$k]['comment'];
}
echo "</td></tr>\n";
break;
case SMOPT_TYPE_STRING:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
- $v = '"' . $v . '"';
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = '"' . addslashes($new_v) . '"';
$newcfg[$k] = $v;
}
if ( $v == '""' && isset( $defcfg[$k]['default'] ) ) {
$v = "'" . $defcfg[$k]['default'] . "'";
$newcfg[$k] = $v;
}
- echo "<tr><td>$name</td><td>".
- "<input size=\"$size\" name=\"adm_$n\" value=\"" . substr( $v, 1, strlen( $v ) - 2 ) . '" />';
+ echo "<tr><td>$name</td><td>"
+ ."<input size=\"$size\" name=\"adm_$n\" value=\""
+ .htmlspecialchars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+ .'" />';
if ( isset( $defcfg[$k]['comment'] ) ) {
echo ' ' . $defcfg[$k]['comment'];
}
echo "</td></tr>\n";
break;
case SMOPT_TYPE_BOOLEAN:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ $v = $new_v;
$newcfg[$k] = $v;
} else {
$v = strtoupper( $v );
echo "</td></tr>\n";
break;
case SMOPT_TYPE_PATH:
- if ( sqgetGlobalVar($e, $v, SQ_POST) ) {
- $v = change_to_sm_path($v);
- $newcfg[$k] = $v;
+ if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
+ // FIXME: fix use of $data_dir in $attachment_dir
+ $v = change_to_sm_path($new_v);
+ $newcfg[$k] = $v;
}
if ( $v == "''" && isset( $defcfg[$k]['default'] ) ) {
$v = change_to_sm_path($defcfg[$k]['default']);
/* Lets get the plugins that are active */
$plugins = array();
- if ( sqgetGlobalVar('plg', $v, SQ_POST) ) {
+ if ( sqgetGlobalVar('plg', $v, SQ_POST) ) {
foreach ( $op_plugin as $plg ) {
- if ( sqgetGlobalVar("plgs_$plg", $v, SQ_POST) && $v == 'on' ) {
+ if ( sqgetGlobalVar("plgs_$plg", $v2, SQ_POST) && $v2 == 'on' ) {
$plugins[] = $plg;
}
}
$i++;
}
}
- echo '<tr><td colspan="2"><input type="hidden" name="plg" value="on" /><center><table>';
+ echo '<tr><td colspan="2"><input type="hidden" name="plg" value="on" /><table align="center">';
foreach ( $op_plugin as $plg ) {
if ( in_array( $plg, $plugins ) ) {
$sw = ' checked="checked"';
"<td><input$sw type=\"checkbox\" name=\"plgs_$plg\" /></td>".
"</tr>\n";
}
- echo '</table></center></td></tr>';
+ echo '</table></td></tr>';
} else {
echo '<tr><td colspan="2" align="center">'.
sprintf(_("Plugin directory could not be found: %s"), $plugpath).
_("Change Settings").'" type="submit" /><br />'.
'<a href="'.SM_PATH.'src/configtest.php" target="_blank">'.
_("Test Configuration")."</a></th></tr>\n".
- '</table></td></tr></table></center></form>';
+ '</table></td></tr></table></form>';
/*
Write the options to the file.
$v = str_replace( 'array(', "array(\n\t", $v );
$v = str_replace( "',", "',\n\t", $v );
}
+ /* FIXME: add elseif that reverts plugins[#] to plugins[] */
fwrite( $fp, "$k = $v;\n" );
}
}
+ // close php
fwrite( $fp, '?>' );
fclose( $fp );
} else {
_("Config file can't be opened. Please check config.php.").
'</big></p>';
}
+
?>
</body></html>
\ No newline at end of file