X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=plugins%2Fadministrator%2Foptions.php;h=f9f06adda65a06addea32f87db61eb2681e39316;hp=d75b06251aafd87ebb81b7e388e308436a49d5ff;hb=71bf4974159d140aa474621f0ad4f154b6000088;hpb=0e66bc84e81ea32f8d44c54b2142db17d040c0ef diff --git a/plugins/administrator/options.php b/plugins/administrator/options.php index d75b0625..f9f06add 100644 --- a/plugins/administrator/options.php +++ b/plugins/administrator/options.php @@ -11,100 +11,182 @@ * $Id$ */ +function parseConfig( $cfg_file ) { + + global $newcfg; + + $cfg = file( $cfg_file ); + $mode = ''; + $l = count( $cfg ); + $modifier = FALSE; + + for ($i=0;$i<$l;$i++) { + $line = trim( $cfg[$i] ); + $s = strlen( $line ); + for ($j=0;$j<$s;$j++) { + switch ( $mode ) { + case '=': + if ( $line{$j} == '=' ) { + // Ok, we've got a right value, lets detect what type + $mode = 'D'; + } else if ( $line{$j} == ';' ) { + // hu! end of command + $key = $mode = ''; + } + break; + case 'K': + // Key detect + if( $line{$j} == ' ' ) { + $mode = '='; + } else { + $key .= $line{$j}; + } + break; + case ';': + // Skip until next ; + if ( $line{$j} == ';' ) { + $mode = ''; + } + break; + case 'S': + if ( $line{$j} == '\\' ) { + $value .= $line{$j}; + $modifier = TRUE; + } else if ( $line{$j} == $delimiter && $modifier === FALSE ) { + // End of string; + $newcfg[$key] = $value . $delimiter; + $key = $value = ''; + $mode = ';'; + } else { + $value .= $line{$j}; + $modifier = FALSE; + } + break; + case 'N': + if ( $line{$j} == ';' ) { + $newcfg{$key} = $value; + $key = $mode = ''; + } else { + $value .= $line{$j}; + } + break; + case 'C': + // Comments + if ( $s > $j + 1 && + $line{$j}.$line{$j+1} == '*/' ) { + $mode = ''; + $j++; + } + break; + case 'D': + // Delimiter detect + switch ( $line{$j} ) { + case '"': + case "'": + // Double quote string + $delimiter = $value = $line{$j}; + $mode = 'S'; + break; + case ' ': + // Nothing yet + break; + default: + if ( strtoupper( substr( $line, $j, 4 ) ) == 'TRUE' ) { + // Boolean TRUE + $newcfg{$key} = 'TRUE'; + $key = ''; + $mode = ';'; + } else if ( strtoupper( substr( $line, $j, 5 ) ) == 'FALSE' ) { + $newcfg{$key} = 'FALSE'; + $key = ''; + $mode = ';'; + } else { + // Number or function call + $mode = 'N'; + $value = $line{$j}; + } + } + break; + default: + if ( $line{$j} == '$' ) { + // We must detect $key name + $mode = 'K'; + $key = '$'; + } else if ( $s < $j + 2 ) { + } else if ( strtoupper( substr( $line, $j, 7 ) ) == 'GLOBAL ' ) { + // Skip untill next ; + $mode = ';'; + $j += 6; + } else if ( $line{$j}.$line{$j+1} == '/*' ) { + $mode = 'C'; + $j++; + } else if ( $line{$j} == '#' || $line{$j}.$line{$j+1} == '//' ) { + // Delete till the end of the line + $j = $s; + } + } + } + } + +} + +/* ---------------------- main -------------------------- */ + chdir('..'); require_once('../src/validate.php'); require_once('../functions/page_header.php'); require_once('../functions/imap.php'); require_once('../src/load_prefs.php'); require_once('../plugins/administrator/defines.php'); +require_once('../plugins/administrator/auth.php'); + +GLOBAL $data_dir, $username; + +if ( !adm_check_user() ) { + header("Location: ../../src/options.php") ; + exit; +} displayPageHeader($color, 'None'); -$cfgfile = '../config/config.php'; -$cfg_defaultfile = '../config/config_default.php'; -$cfg = file( $cfg_defaultfile ); -$newcfg = $dfncfg = array( ); -$cm = FALSE; +$newcfg = array( ); foreach ( $defcfg as $key => $def ) { $newcfg[$key] = ''; } -foreach ( $cfg as $l ) { - // Remove inline /* */ Blocks - $l = preg_replace( '/\/\*.*\*\//', '', $l ); - $l = preg_replace( '/#.*$/', '', $l ); - $l = preg_replace( '/\/\/.*$/', '', $l ); - $v = $s = trim( $l ); - if ( $cm ) { - if( substr( $v, -2 ) == '*/' ) { - $v = ''; - $cm = FALSE; - } else if( $i = strpos( $v, '*/' ) ) { - $v = substr( $v, $i ); - $cm = FALSE; - } else { - $v = ''; - } - } else { - if( $v{0}.$v{1} == '/*' ) { - $v = ''; - $cm = TRUE; - } else if ( $i = strpos( $v, '/*' ) ) { - $v = substr( $v, 0, $i ); - $cm = TRUE; - } - } +$cfgfile = '../config/config.php'; +parseConfig( '../config/config_default.php' ); +parseConfig( $cfgfile ); - if ( $i = strpos( $v, '=' ) ) { - $key = trim( substr( $v, 0, $i - 1 ) ); - $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) ); - $newcfg[$key] = $val; - $dfncfg[$key] = $val; - } +$colapse = array( 'Titles' => 'off', + 'Group1' => getPref($data_dir, $username, 'adm_Group1', 'off' ), + 'Group2' => getPref($data_dir, $username, 'adm_Group2', 'on' ), + 'Group3' => getPref($data_dir, $username, 'adm_Group3', 'on' ), + 'Group4' => getPref($data_dir, $username, 'adm_Group4', 'on' ), + 'Group5' => getPref($data_dir, $username, 'adm_Group5', 'on' ), + 'Group6' => getPref($data_dir, $username, 'adm_Group6', 'on' ), + 'Group7' => getPref($data_dir, $username, 'adm_Group7', 'on' ), + 'Group8' => getPref($data_dir, $username, 'adm_Group8', 'on' ) ); -} +if ( isset( $switch ) ) { -$cfg = file( $cfgfile ); - -$cm = FALSE; -foreach ( $cfg as $l ) { - $l = preg_replace( '/\/\*.*\*\//', '', $l ); - $l = preg_replace( '/#.*$/', '', $l ); - $l = preg_replace( '/\/\/.*$/', '', $l ); - $v = $s = trim( $l ); - if ( $cm ) { - if( substr( $v, -2 ) == '*/' ) { - $v = ''; - $cm = FALSE; - } else if( $i = strpos( $v, '*/' ) ) { - $v = substr( $v, $i ); - $cm = FALSE; - } else { - $v = ''; - } + if ( $colapse[$switch] == 'on' ) { + $colapse[$switch] = 'off'; } else { - if( $v{0}.$v{1} == '/*' ) { - $v = ''; - $cm = TRUE; - } else if ( $i = strpos( $v, '/*' ) ) { - $v = substr( $v, 0, $i ); - $cm = TRUE; - } - } - - if ( $i = strpos( $v, '=' ) ) { - $key = trim( substr( $v, 0, $i - 1 ) ); - $val = str_replace( ';', '', trim( substr( $v, $i + 1 ) ) ); - $newcfg[$key] = $val; + $colapse[$switch] = 'on'; } + setPref($data_dir, $username, "adm_$switch", $colapse[$switch] ); } -echo "