#!/usr/local/bin/perl # index.cgi # Display a list of protected directories and their users. The user can # add more directories, and specify the encryption mode for each. require './htaccess-lib.pl'; &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1); # Check needed Perl modules if ($config{'md5'}) { $missing = &check_md5(); if ($missing) { print &text('index_emd5', "$missing"),"\n"; } } if ($config{'sha1'} && !$missing) { $missing = &check_sha1(); if ($missing) { print &text('index_sha1', "$missing"),"\n"; } } if ($missing) { if (!$module_info{'usermin'}) { print &text('index_cpan', "../cpan/download.cgi?source=3&cpan=$missing&mode=2&return=/$module_name/&returndesc=".&urlize($text{'index_return'})); } print "

\n"; &ui_print_footer("/", $text{'index'}); exit; } # Check for htdigest command, if we need it if ($config{'digest'} && !$htdigest_command) { eval "use Digest::MD5"; if ($@) { print &text('index_digest2', "htdigest", "Digest::MD5"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; } } @accessdirs || &error($text{'index_eaccess'}); @links = ( &select_all_link("d"), &select_invert_link("d"), "$text{'index_add'}" ); @dirs = &list_directories(); @dirs = grep { &can_access_dir($_->[0]) } @dirs; if (@dirs) { @tds = ( "width=30% valign=top", "width=70% valign=top" ); if ($can_create) { print &ui_form_start("delete.cgi", "post"); @tds = ( "width=5", @tds ); print &ui_links_row(\@links); } print &ui_columns_start([ $can_create ? ( "" ) : ( ), $text{'index_dir'}, $text{'index_usersgroups'} ], 100, 0, \@tds); foreach $d (@dirs) { local @cols; if ($can_create) { push(@cols, "$d->[0]"); } else { push(@cols, $d->[0]); } # Show the users $utable = "\n"; $users = $d->[2] == 3 ? &list_digest_users($d->[1]) : &list_users($d->[1]); if ($userconfig{'sort'} == 1 || $config{'sort'} == 1) { $users = [ sort { $a->{'user'} cmp $b->{'user'} } @$users ]; } for($i=0; $i<@$users; $i++) { $u = $users->[$i]; $link = "$u->{'user'}"; $utable .= "\n" if ($i%4 == 0); if ($u->{'enabled'}) { $utable .= "\n"; } else { $utable .= "\n"; } $utable .= "\n" if ($i%4 == 3); } if ($i%4) { while($i++%4) { $utable .= "\n"; } $utable .= "\n"; } if (!@$users) { $utable .= "\n"; } $utable .= "
$link$link
". "$text{'index_nousers'}
\n"; # Show the groups if ($d->[4]) { $utable .= "\n"; $groups = &list_groups($d->[4]); if ($userconfig{'sort'} == 1 || $config{'sort'} == 1) { $groups = [ sort { $a->{'group'} cmp $b->{'group'} } @$groups ]; } for($i=0; $i<@$groups; $i++) { $u = $groups->[$i]; $link= "$u->{'group'} (". scalar(@{$u->{'members'}}).")"; $utable .= "\n" if ($i%4 == 0); if ($u->{'enabled'}) { $utable .= "\n"; } else { $utable .= "\n"; } $utable .= "\n" if ($i%4 == 3); } if ($i%4) { while($i++%4) { $utable .= "\n"; } $utable .= "\n"; } if (!@$groups) { $utable .= "\n"; } $utable .= "
$link$link
$text{'index_nogroups'}
\n"; } # User / group adder links $utable .= "$text{'index_uadd'}\n"; if ($d->[4]) { $utable .= "  "; $utable .= "$text{'index_gadd'}\n"; } push(@cols, $utable); if ($can_create) { print &ui_checked_columns_row(\@cols, \@tds, "d", $d->[0]); } else { print &ui_columns_row(\@cols, \@tds); } } print &ui_columns_end(); if ($can_create) { print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]); } } else { print "$text{'index_none'}

\n"; print &ui_links_row([ $links[2] ]); } # Form to find existing .htaccess files if ($can_create) { print "


\n"; print &ui_form_start("search.cgi"); print &ui_submit($text{'index_search'}),"\n"; print &ui_textbox("search", $accessdirs[0] eq "/" ? "" : $accessdirs[0], 40)." ".&file_chooser_button("search", 1)."
\n"; print &ui_form_end(); } &ui_print_footer("/", $text{'index'});