* SquirrelMail configuration file.
*
* @author Philippe Mingo
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright 1999-2021 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package plugins
* @subpackage administrator
*/
+define('PAGE_NAME', 'administrator_options');
+
/**
* parse the config file
*
for ($j=0;$j<$s;$j++) {
switch ( $mode ) {
case '=':
- if ( $line{$j} == '=' ) {
+ if ( $line[$j] == '=' ) {
// Ok, we've got a right value, lets detect what type
$mode = 'D';
- } else if ( $line{$j} == ';' ) {
+ } else if ( $line[$j] == ';' ) {
// hu! end of command
$key = $mode = '';
}
break;
case 'K':
// Key detect
- if ( $line{$j} == ' ' ) {
+ if ( $line[$j] == ' ' ) {
$mode = '=';
} else {
- $key .= $line{$j};
+ $key .= $line[$j];
// FIXME: this is only pour workaround for plugins[] array.
- if ($line{$j}=='[' && $line{($j+1)}==']') {
+ if ($line[$j]=='[' && $line[($j+1)]==']') {
$key .= $arraykey;
$arraykey++;
}
break;
case ';':
// Skip until next ;
- if ( $line{$j} == ';' ) {
+ if ( $line[$j] == ';' ) {
$mode = '';
}
break;
case 'S':
- if ( $line{$j} == '\\' ) {
- $value .= $line{$j};
+ if ( $line[$j] == '\\' ) {
+ $value .= $line[$j];
$modifier = TRUE;
- } else if ( $line{$j} == $delimiter && $modifier === FALSE ) {
+ } else if ( $line[$j] == $delimiter && $modifier === FALSE ) {
// End of string;
$newcfg[$key] = $value . $delimiter;
$key = $value = '';
$mode = ';';
} else {
- $value .= $line{$j};
+ $value .= $line[$j];
$modifier = FALSE;
}
break;
case 'N':
- if ( $line{$j} == ';' ) {
- $newcfg{$key} = $value;
+ if ( $line[$j] == ';' ) {
+ $newcfg[$key] = $value;
$key = $mode = '';
} else {
- $value .= $line{$j};
+ $value .= $line[$j];
}
break;
case 'C':
// Comments
if ( $s > $j + 1 &&
- $line{$j}.$line{$j+1} == '*/' ) {
+ $line[$j].$line[$j+1] == '*/' ) {
$mode = '';
$j++;
}
break;
case 'D':
// Delimiter detect
- switch ( $line{$j} ) {
+ switch ( $line[$j] ) {
case '"':
case "'":
// Double quote string
- $delimiter = $value = $line{$j};
+ $delimiter = $value = $line[$j];
$mode = 'S';
break;
case ' ':
default:
if ( strtoupper( substr( $line, $j, 4 ) ) == 'TRUE' ) {
// Boolean TRUE
- $newcfg{$key} = 'TRUE';
+ $newcfg[$key] = 'TRUE';
$key = '';
$mode = ';';
} else if ( strtoupper( substr( $line, $j, 5 ) ) == 'FALSE' ) {
- $newcfg{$key} = 'FALSE';
+ $newcfg[$key] = 'FALSE';
$key = '';
$mode = ';';
} else {
// Number or function call
$mode = 'N';
- $value = $line{$j};
+ $value = $line[$j[;
}
}
break;
default:
- if ( $line{$j} == '$' ) {
+ if ( $line[$j] == '$' ) {
// We must detect $key name
$mode = 'K';
$key = '$';
// Skip untill next ;
$mode = ';';
$j += 6;
- } else if ( $line{$j}.$line{$j+1} == '/*' ) {
+ } else if ( $line[$j].$line[$j+1] == '/*' ) {
$mode = 'C';
$j++;
- } else if ( $line{$j} == '#' || $line{$j}.$line{$j+1} == '//' ) {
+ } else if ( $line[$j] == '#' || $line[$j].$line[$j+1] == '//' ) {
// Delete till the end of the line
$j = $s;
}
* empty_string --> ''
* ../images/logo.gif --> SM_PATH . 'images/logo.gif'
* images/logo.gif --> SM_PATH . 'config/images/logo.gif'
+ * C:/absolute/win/path --> 'C:/absolute/win/path'
* /absolute/path/logo.gif --> '/absolute/path/logo.gif'
* http://whatever/ --> 'http://whatever'
*
function change_to_sm_path($old_path) {
if ( $old_path === '' || $old_path == "''" ) {
return "''";
- } elseif ( preg_match("/^(\/|http)/", $old_path) ) {
+ } elseif ( preg_match("/^(\/|http)/", $old_path) ||
+ substr($old_path,1,2) == ':/' ) {
return "'" . $old_path . "'";
} elseif ( preg_match("/^(\$|SM_PATH)/", $old_path) ) {
return $old_path;
/* ---------------------- main -------------------------- */
-
-/** @ignore */
-define('SM_PATH','../../');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/imap.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;
exit;
}
-displayPageHeader($color, 'None');
+displayPageHeader($color);
$newcfg = array( );
}
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>'.
} else if ( $l == 'false' ) {
$v = 'FALSE';
$type = SMOPT_TYPE_BOOLEAN;
- } else if ( $v{0} == "'" ) {
+ } else if ( $v[0] == "'" ) {
$type = SMOPT_TYPE_STRING;
- } else if ( $v{0} == '"' ) {
+ } else if ( $v[0] == '"' ) {
$type = SMOPT_TYPE_STRING;
}
$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:
case SMOPT_TYPE_TEXTAREA:
if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
- $v = '"' . $new_v . '"';
+ $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\">"
+ .sm_encode_html_special_chars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+ ."</textarea>";
if ( isset( $defcfg[$k]['comment'] ) ) {
echo ' ' . $defcfg[$k]['comment'];
}
break;
case SMOPT_TYPE_STRING:
if ( sqgetGlobalVar($e, $new_v, SQ_POST) ) {
- $v = '"' . $new_v . '"';
+ $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=\""
+ .sm_encode_html_special_chars(stripslashes(substr( $v, 1, strlen( $v ) - 2 )))
+ .'" />';
if ( isset( $defcfg[$k]['comment'] ) ) {
echo ' ' . $defcfg[$k]['comment'];
}
$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.
*/
+// Test/debug
+// $cfgfile = '/tmp/config.php';
if ( $fp = @fopen( $cfgfile, 'w' ) ) {
fwrite( $fp, "<?php\n".
"/**\n".
" * SquirrelMail Configuration File\n".
" * Created using the Administrator Plugin\n".
" */\n".
- "\n".
- "global \$version;\n" );
+ "\n" );
foreach ( $newcfg as $k => $v ) {
- if ( $k{0} == '$' && $v <> '' || is_int($v)) {
+ if ( $k[0] == '$' && $v <> '' || is_int($v)) {
if ( substr( $k, 1, 11 ) == 'ldap_server' ) {
$v = substr( $v, 0, strlen( $v ) - 1 ) . "\n)";
$v = str_replace( 'array(', "array(\n\t", $v );
fwrite( $fp, "$k = $v;\n" );
}
}
- // add local config support
- fwrite( $fp, "@include SM_PATH . 'config/config_local.php';\n" );
// close php
fwrite( $fp, '?>' );
fclose( $fp );
_("Config file can't be opened. Please check config.php.").
'</big></p>';
}
+
?>
-</body></html>
\ No newline at end of file
+</body></html>