#!/usr/local/bin/perl # index.cgi # Display a list of all cron jobs, with the username and command for each one require './cron-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1); $max_jobs = $userconfig{'max_jobs'} || $config{'max_jobs'}; # Make sure cron is installed (very likely!) $err = &check_cron_config(); if ($err) { print $err,"
\n"; &ui_print_footer("/", $text{'index'}); exit; } # Work out which users can be viewed map { $ucan{$_}++ } split(/\s+/, $access{'users'}); @jobs = &list_cron_jobs(); @ulist = &unique(map { $_->{'user'} } @jobs); if ($access{'mode'} == 1) { @ulist = grep { $ucan{$_} } @ulist; } elsif ($access{'mode'} == 2) { @ulist = grep { !$ucan{$_} } @ulist; } elsif ($access{'mode'} == 3) { @ulist = ( $remote_user ); } elsif ($access{'mode'} == 4) { @ulist = grep { local @u = getpwnam($_); (!$access{'uidmin'} || $u[2] >= $access{'uidmin'}) && (!$access{'uidmax'} || $u[2] <= $access{'uidmax'}) } @ulist; } elsif ($access{'mode'} == 5) { @ulist = grep { local @u = getpwnam($_); $u[3] == $access{'users'} } @ulist; } if ($config{'show_run'}) { &foreign_require("proc", "proc-lib.pl"); @procs = &proc::list_processes(); } # Work out creation links @crlinks = ( ); if ($access{'create'}) { push(@crlinks, "$text{'index_create'}"); push(@crlinks, "$text{'index_ecreate'}") if ($env_support); } if ($config{cron_allow_file} && $config{cron_deny_file} && $access{'allow'}) { push(@crlinks, "$text{'index_allow'}"); } # Build a list of cron job rows to show $single_user = !&supports_users() || @ulist == 1; @links = ( &select_all_link("d"), &select_invert_link("d"), @crlinks ); @rows = ( ); foreach $u (@ulist) { if (!$config{'single_file'}) { # Get the Unix user's real name if ((@uinfo = getpwnam($u)) && $uinfo[5] =~ /\S/) { $uname = "$u ($uinfo[5])"; } else { $uname = $u; } } @jlist = grep { $_->{'user'} eq $u } @jobs; @plist = (); for($i=0; $i<@jlist; $i++) { local $rpd = &is_run_parts($jlist[$i]->{'command'}); local @exp = $rpd ? &expand_run_parts($rpd) : (); if (!$rpd || @exp) { push(@plist, [ $jlist[$i], \@exp ]); } } for($i=0; $i<@plist; $i++) { local $job = $plist[$i]->[0]; &convert_range($job); &convert_comment($job); local @exp = @{$plist[$i]->[1]}; local $idx = $job->{'index'}; local @cols; print "
\n"; print &ui_links_row(\@crlinks); } elsif (@rows) { # Show jobs if ($in{'search'}) { print "",&text('index_searchres', "".&html_escape($in{'search'}).""),"
\n"; push(@links, "$text{'index_reset'}"); } print &ui_form_start("delete_jobs.cgi", "post"); print &ui_links_row(\@links); @tds = ( "width=5" ); print &ui_columns_start([ "", $single_user ? ( ) : ( $text{'index_user'} ), $text{'index_active'}, $access{'command'} ? ( $text{'index_command'} ) : ( ), !$access{'command'} || $config{'show_time'} || $userconfig{'show_time'} ? ( $text{'index_when'} ) : ( ), $config{'show_comment'} || $userconfig{'show_comment'} ? ( $text{'index_comment'} ) : ( ), $config{'show_run'} ? ( $text{'index_run'} ) : ( ), $access{'move'} ? ( $text{'index_move'} ) : ( ), ], 100, 0, \@tds); foreach my $r (@rows) { print &ui_checked_columns_row([ @$r[1..(@$r-1)] ], \@tds, "d", $r->[0]); } print &ui_columns_end(); print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'index_delete'} ], [ "disable", $text{'index_disable'} ], [ "enable", $text{'index_enable'} ] ]); } else { # Show message if ($in{'search'}) { push(@crlinks, "$text{'index_reset'}"); } print $in{'search'} ? "".&text('index_esearch', "".&html_escape($in{'search'})."")."
" : $module_info{'usermin'} ? "$text{'index_none3'}
\n" : $access{'mode'} ? "$text{'index_none2'}
\n" : "$text{'index_none'}
\n"; print &ui_links_row(\@crlinks); } &ui_print_footer("/", $text{'index'});