[if cgi ui_remember] [calc] $CGI->{mv_data_table} = $Values->{mv_data_table}; return [/calc] [/if] [if !cgi mv_data_table] [bounce page="__UI_BASE__/gentable"] [/if] [value name=mv_data_table set="[cgi mv_data_table]" hide=1] [set page_perm]dbconfig[/set] [set table_perm]1[/set] [set page_title]Configuration[/set] [set ui_class]Admin[/set] [set help_name]genconfig.main[/set] [set icon_name]icon_config.gif[/set] @_UI_STD_HEAD_@ [perl tables="[list-databases] __UI_META_TABLE__"] %ignore; my @ignore = qw/ Class db_file db_file_extended db_file_extended db_text dir DSN dsn_id Exists_handle EXTENDED file _Insert_h _Checked_capability name Object Read_only type Update_handle /; @ignore{@ignore} = @ignore; %typemap = ( 1 => 'DBM/Memory, default delimiter (TAB)', 2 => 'DBM/Memory, LINE delimiter', 3 => 'DBM/Memory, %% delimiter', 4 => 'DBM/Memory, CSV delimiter', 5 => 'DBM/Memory, PIPE delimiter', 6 => 'DBM/Memory, TAB delimiter', 7 => 'This should never appear (old Msql)', 8 => 'DBI/SQL', 9 => 'LDAP', ); %str_typemap = ( 1 => 'DEFAULT', 2 => 'LINE', 3 => '%%', 4 => 'CSV', 5 => 'PIPE', 6 => 'TAB', 8 => 'SQL', 9 => 'LDAP', ); @include_dir = (); my %seen; for(keys %Db) { my $fig = $Db{$_}->config('included_from'); $fig =~ s:(.*)/::; my $dir = $1; push @include_dir, $dir unless $seen{$dir}++; } %Hash_ref = ( qw! FILTER_FROM FILTER_FROM FILTER_TO FILTER_TO COLUMN_DEF COLUMN_DEF DEFAULT DEFAULT FIELD_ALIAS FIELD_ALIAS NUMERIC NUMERIC WRITE_CATALOG WRITE_CATALOG ! ); %Ary_ref = ( qw! NAME NAME BINARY BINARY POSTCREATE POSTCREATE INDEX INDEX ! ); %Misc_set = ( GUESS_NUMERIC => '=No numeric guess, 1=Guess numeric fields', EXCEL => '=No Excel correction, 1=Correct for Excel peculiarities', HOT => '=Normal open, 1=Keep table always connected', CONTINUE => q{=No extra line processing, DITTO="Ditto" line continuation, UNIX=Unix-style \ continuation, NOTES=Lotus notes (only for LINE delimiter)}, ); %Misc_set_sql = ( LONGTRUNCOK => "1=Silently truncate too-long values, 0=Don't truncate", ); %Adv_set_sql = ( CHOPBLANKS => "1=Strip trailing white space from fixed-length text, 0=Don't strip (warning: dangerous)", HAS_LIMIT => "0=No LIMIT available, 1=has LIMIT to limit rows", AUTOCOMMIT => "=Honor default AutoCommit setting, 0=No AutoCommit, 1=Set AutoCommit", PRINTERROR => "=Honor default PrintError setting, 0=No PrintError, 1=Set PrintError", RAISEERROR => "=Honor default RaiseError setting, 0=No RaiseError, 1=Set RaiseError", ); @Adv_set_sql_text = qw( ALTER_ADD ALTER_CHANGE ALTER_DELETE ALTER_INDEX ALTER_RENAME ALTER_BACKUP ); LOCAL1: { my @k = keys %str_typemap; for (@keys) { $str_typemap{$str_typemap{$_}} = $_; } } [/perl] [if cgi mv_dbconf] [perl] $Dref = {}; my @keys = grep /^mv_dbconf_/, keys %$CGI; my $table = $CGI->{mv_data_table}; my $string = ''; #$string = join "\n", 'KEYS', @keys, ""; for(@keys) { my $key = $_; $key =~ s/^mv_dbconf_//; #$string .= "KEY: $key -- $_\n"; $Dref->{$key} = $CGI->{$_}; } sub tout { my ($param, $data, $prefix) = @_; $prefix = '' unless $prefix; if($data =~ /\n/) { $data = "<<_EOD\n$data\n_EOD\n"; } return sprintf("${prefix}Database %-11s %-15s %s\n", $table, $param, $data); } $string .= tout($Dref->{file}, $str_typemap{ $Dref->{type} } || $Dref->{type}); if($Dref->{DSN_default}) { $string .= tout('DSN', "__SQL" . 'DSN' . "__"); } else { $string .= tout('DSN', $Dref->{DSN}); } if($Dref->{USER_default}) { $string .= "#ifdef SQLPASS\n"; for (qw/USER PASS/) { $string .= tout($_, "__SQL" . $_ . "__"); } $string .= "#endif\n"; } else { for (qw/USER PASS/) { $string .= tout($_, $Dref->{$_}) if length $Dref->{$_}; } } for (keys %Misc_set, keys %Misc_set_sql,) { $string .= tout($_, $Dref->{$_}) if length $Dref->{$_}; } for (keys %Adv_set, keys %Adv_set_sql, @Adv_set_sql_text) { $string .= tout($_, $Dref->{$_}, '#') if length $Dref->{$_}; } if ($Dref->{CREATE_SQL} =~ /\S/) { $Dref->{CREATE_SQL} =~ s/\s*;\s*$//; $string .= tout('CREATE_SQL', $Dref->{CREATE_SQL}); } if($Dref->{COLUMN_DEF_type}) { my %def; for( qw/name type length notnull key default/) { $def{$_} = [ split /\0/, $Dref->{"COLUMN_DEF_$_"} ]; } my $count = scalar( @{$def{name}} ); for(my $i = 0; $i < $count; $i++) { my $cdef; last if ! ($cdef = $def{name}[$i]); next if ! $def{type}[$i]; $cdef = qq{"$cdef=}; $cdef .= $def{type}[$i]; $cdef .= qq{($def{length}[$i])} if $def{length}[$i] =~ /\S/; $cdef .= qq{ NOT NULL} if $def{notnull}[$i]; $cdef .= qq{ PRIMARY KEY} if $def{key}[$i]; $cdef .= qq{ DEFAULT $def{default}[$i]} if $def{default}[$i] =~ /\S/; $cdef .= qq{"}; $string .= tout('COLUMN_DEF', $cdef); } } if($Dref->{POSTCREATE}) { my @lines = grep /\S/, split /;/, $Dref->{POSTCREATE}; for(@lines) { s/^\s+//; s/\s+$//; $string .= tout('POSTCREATE', $_); } } return "