* SquirrelMail configuration file.
*
* @author Philippe Mingo
- * @copyright 1999-2013 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
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;
}
} 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;
}
Write the options to the file.
*/
+// Test/debug
+// $cfgfile = '/tmp/config.php';
if ( $fp = @fopen( $cfgfile, 'w' ) ) {
fwrite( $fp, "<?php\n".
"/**\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 );