|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/libexec/webmin/status/ |
Upload File : |
#!/usr/bin/perl
# save_sched.cgi
# Save scheduled monitoring options
require './status-lib.pl';
$access{'sched'} || &error($text{'sched_ecannot'});
&ReadParse();
&error_setup($text{'sched_err'});
# Parse and save inputs
$in{'email_def'} || $in{'email'} =~ /\S/ || &error($text{'sched_eemail'});
$config{'sched_email'} = $in{'email_def'} ? '' : $in{'email'};
if ($config{'pager_cmd'}) {
$config{'sched_pager'} = $in{'pager_def'} ? '' : $in{'pager'};
}
if ($in{'sms_def'}) {
delete($config{'sched_carrier'});
delete($config{'sched_sms'});
}
else {
$config{'sched_carrier'} = $in{'carrier'};
$in{'sms'} =~ /^\d+$/ || &error($text{'sched_esmsnumber'});
$config{'sched_sms'} = $in{'sms'};
}
if ($in{'from_def'}) {
delete($config{'sched_from'});
}
else {
$in{'from'} =~ /^\S+$/ || &error($text{'sched_efrom'});
$config{'sched_from'} = $in{'from'};
}
if ($in{'smtp_def'}) {
if (!$in{'from_def'}) {
&foreign_require("mailboxes", "mailboxes-lib.pl");
$err = &mailboxes::test_mail_system();
$err && &error(&text('sched_eemailserver', $err));
}
delete($config{'sched_smtp'});
}
else {
if (!$in{'from_def'}) {
gethostbyname($in{'smtp'}) || &check_ipaddress($in{'smtp'}) ||
&error($text{'sched_esmtp'});
}
$config{'sched_smtp'} = $in{'smtp'};
}
$config{'sched_mode'} = $in{'mode'};
$in{'int'} =~ /^\d+$/ || &error($text{'sched_eint'});
$config{'sched_int'} = $in{'int'};
$config{'sched_period'} = $in{'period'};
$in{'offset'} =~ /^\d+$/ || &error($text{'sched_eoffset'});
$config{'sched_offset'} = $in{'offset'};
$config{'sched_warn'} = $in{'warn'};
$config{'sched_single'} = $in{'single'};
@hours = split(/\0/, $in{'hours'});
@hours || &error($text{'sched_ehours'});
$config{'sched_hours'} = @hours == 24 ? '' : join(" ", @hours);
@days = split(/\0/, $in{'days'});
@days || &error($text{'sched_edays'});
$config{'sched_days'} = @days == 7 ? '' : join(" ", @days);
&lock_file("$module_config_directory/config");
&save_module_config();
&unlock_file("$module_config_directory/config");
# Setup or remove the cron job
&setup_cron_job();
&webmin_log("sched");
&redirect("");