#!/usr/local/bin/perl # edit_cron.cgi # Edit an existing or new cron job require './cron-lib.pl'; &ReadParse(); @jobs = &list_cron_jobs(); if (!$in{'new'}) { $job = $jobs[$in{'idx'}]; &can_edit_user(\%access, $job->{'user'}) || &error($text{'edit_ecannot'}); &ui_print_header(undef, $text{'edit_title'}, ""); } else { &ui_print_header(undef, $text{'create_title'}, ""); if (defined($in{'clone'})) { # Default to clone source $clone = $jobs[$in{'clone'}]; $job = { %$clone }; } elsif ($config{'vixie_cron'}) { # Default to hourly, using @ format $job = { 'special' => 'hourly', 'active' => 1 }; } else { # Default to hourly, using standard notation $job = { 'mins' => '0', 'hours' => '*', 'days' => '*', 'months' => '*', 'weekdays' => '*', 'active' => 1 }; } } print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'edit_details'}
\n"; if (&supports_users()) { # Allow selection of user print "\n"; if ($access{'mode'} == 1) { print "\n"; } elsif ($access{'mode'} == 3) { print "\n"; print "\n"; } else { print "\n"; } } else { # No such thing as users! print "\n"; } print "\n"; printf "\n", $job->{'active'} ? "" : "checked"; &convert_comment($job); $rpd = &is_run_parts($job->{'command'}); if ($rpd) { # run-parts command.. just show scripts that will be run print "\n"; print "\n"; print "\n"; } elsif (!$access{'command'}) { # Just show command, which cannot be edited print "\n"; print "\n"; } else { # Normal cron job.. can edit command &convert_range($job); $rangeable = 1; ($command, $input) = &extract_input($job->{'command'}); @lines = split(/%/, $input); print "\n"; print "\n"; if ($config{'cron_input'}) { print "\n"; print "\n"; } } # Show comment print "\n"; print "\n"; print "
$text{'edit_user'}$remote_user{'user'}\"> ", &user_chooser_button("user", 0),"
$text{'edit_active'} $text{'yes'}\n", $job->{'active'} ? "checked" : ""; printf " $text{'no'}
$text{'edit_commands'}",join("
",&expand_run_parts($rpd)), "
$text{'edit_command'}$job->{'command'}
$text{'edit_command'}
$text{'edit_input'}
$text{'edit_comment'}",&ui_textbox("comment", $job->{'comment'}, 60), "

\n"; # Show times and days to run print "\n"; print "\n"; &show_times_input($job); print "
$text{'edit_when'}
\n"; if ($rangeable) { # Show date range to run print "

\n"; print "\n"; print "
$text{'edit_range'}
"; &show_range_input($job); print "
\n"; } if (!$in{'new'}) { print "\n"; # Save button print "\n"; # Run button if (!$rpd) { print "\n"; print "\n"; print "\n"; } # Clone button print "\n"; print "\n"; print "\n"; print "\n"; # Delete button if ($access{'delete'}) { print "\n"; print "\n"; print "\n"; } else { print "\n"; } print "
", "

\n"; } else { print "

\n"; } &ui_print_footer("", $text{'index_return'});