diff --git a/majordomo/index.cgi b/majordomo/index.cgi index b4343f51b..f4d861030 100755 --- a/majordomo/index.cgi +++ b/majordomo/index.cgi @@ -4,80 +4,14 @@ require './majordomo-lib.pl'; %access = &get_module_acl(); - -# Check for the majordomo config file -if (!-r $config{'majordomo_cf'}) { - &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, - &help_search_link("majordomo", "man", "doc", "google")); - print &text('index_econfig', "$config{'majordomo_cf'}", - "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } - -# Check for the programs dir -if (!-d $config{'program_dir'}) { - &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, - &help_search_link("majordomo", "man", "doc", "google")); - print &text('index_eprograms', "$config{'program_dir'}", - "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } - -# Check majordomo version -if (!-r "$config{'program_dir'}/majordomo_version.pl") { - &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, - &help_search_link("majordomo", "man", "doc", "google")); - print &text('index_eversion2', "majordomo_version.pl", - $config{'program_dir'}, - "$gconfig{'webprefix'}/config.cgi?$module_name"), - "

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } -require "$config{'program_dir'}/majordomo_version.pl"; -&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, - &help_search_link("majordomo", "man", "doc", "google"), - undef, undef, &text('index_version', $majordomo_version)); -if ($majordomo_version < 1.94 || $majordomo_version >= 2) { - print "$text{'index_eversion'}

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } - -# Check $homedir in majordomo.cf $conf = &get_config(); -if (!&homedir_valid($conf)) { - print &text('index_ehomedir', "$homedir"),"

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } -# Check $listdir in majordomo.cf -$listdir = &perl_var_replace(&find_value("listdir", $conf), $conf); -if (!-d $listdir) { - print &text('index_elistdir', "$listdir"),"

\n"; - &ui_print_footer("/", $text{'index'}); - exit; - } +eval { require "$config{'program_dir'}/majordomo_version.pl"; }; +&ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0, + &mdom_help(), + undef, undef, &text('index_version', $majordomo_version)); -# Check if module needed for aliases is OK -if ($config{'aliases_file'} eq 'postfix') { - # Postfix has to be installed - &foreign_installed("postfix", 1) || - &ui_print_endpage(&text('index_epostfix', '../postfix/')); - } -elsif ($config{'aliases_file'} eq '') { - # Sendmail has to be installed - &foreign_installed("sendmail", 1) || - &ui_print_endpage(&text('index_esendmail2', '','../sendmail/')); - } -else { - # Only the sendmail module has to be installed - &foreign_check("sendmail") || - &ui_print_endpage(&text('index_esendmail3')); - } +&check_mdom_config($conf); # Check for the majordomo aliases $aliases_files = &get_aliases_file(); diff --git a/majordomo/majordomo-lib.pl b/majordomo/majordomo-lib.pl index 8b21ea9d9..7d0952719 100755 --- a/majordomo/majordomo-lib.pl +++ b/majordomo/majordomo-lib.pl @@ -389,8 +389,11 @@ sub save_select sub multi_input { local $v = &find_value($_[0], $_[2]); +local $l = 1 + $v =~ tr/\n|\r//; +$l=4 if ($l <= 4); +$l=15 if ($l >= 14); local $rv = "$_[1] ". - "\n"; + "\n"; return $rv; } @@ -435,5 +438,78 @@ if (!-d $homedir) { return 1; } +# mdom_help() +# returns majordomo help link +sub mdom_help +{ +local $rv= &help_search_link("majordomo", "man", "doc", "google"); +return $rv; +} + +# check_mdom_config($conf) +# moved from index.cgi, can be used from others also +sub check_mdom_config +{ +local $conf=$_[0]; +# Check for the majordomo config file +if (!-r $config{'majordomo_cf'}) { + print &text('index_econfig', "$config{'majordomo_cf'}", + "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; + &ui_print_footer("/", $text{'index'}); + exit; + } +# Check for the programs dir +if (!-d $config{'program_dir'}) { + print &text('index_eprograms', "$config{'program_dir'}", + "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; + &ui_print_footer("/", $text{'index'}); + exit; + } +# Check majordomo version +if (!-r "$config{'program_dir'}/majordomo_version.pl") { + print &text('index_eversion2', "majordomo_version.pl", + $config{'program_dir'}, + "$gconfig{'webprefix'}/config.cgi?$module_name"),"

\n"; + &ui_print_footer("/", $text{'index'}); + exit; + } +if ($majordomo_version < 1.94 || $majordomo_version >= 2) { + print "$text{'index_eversion'}

\n"; + &ui_print_footer("/", $text{'index'}); + exit; + } +# Check $homedir in majordomo.cf +if (!&homedir_valid($conf)) { + print &text('index_ehomedir', "$homedir"),"

\n"; + &ui_print_footer("/", $text{'index'}); + exit; + } +# Check $listdir in majordomo.cf +local $listdir = &perl_var_replace(&find_value("listdir", $conf), $conf); +if (!-d $listdir) { + print &text('index_elistdir', "$listdir"),"

\n"; + &ui_print_footer("/", $text{'index'}); + exit 1; + } +# Check if module needed for aliases is OK +if ($config{'aliases_file'} eq 'postfix') { + # Postfix has to be installed + &foreign_installed("postfix", 1) || + &ui_print_endpage(&text('index_epostfix', '../postfix/')); + } +elsif ($config{'aliases_file'} eq '') { + # Sendmail has to be installed + &foreign_installed("sendmail", 1) || + &ui_print_endpage(&text('index_esendmail2', '','../sendmail/')); + } +else { + # Only the sendmail module has to be installed + &foreign_check("sendmail") || + &ui_print_endpage(&text('index_esendmail3')); + } + +return 0; +} + 1;