mirror of
https://github.com/webmin/webmin.git
synced 2026-06-19 02:40:32 +01:00
Use a separate mode input to determine whether the system time, hardware time or NTP time are being set. This is needed because authentic theme changes the values of submit buttons
This commit is contained in:
@@ -10,12 +10,27 @@ use Time::Local;
|
||||
|
||||
if (!$in{'action'}) {
|
||||
# user probably hit return in the time server field
|
||||
$in{'action'} = $text{ 'action_timeserver_sys' };
|
||||
$in{'action'} = $text{'index_sync'};
|
||||
}
|
||||
$mode = "time";
|
||||
|
||||
if( $in{ 'action' } eq $text{ 'action_apply' } )
|
||||
{
|
||||
if ($in{'action'} eq $text{'action_sync'}) {
|
||||
# Set system time to hardware time
|
||||
&error( $text{ 'acl_nosys' } ) if( $access{ 'sysdate' } );
|
||||
local $flags = &get_hwclock_flags();
|
||||
$out = &backquote_logged("hwclock $flags --hctosys");
|
||||
&error( &text( 'error_sync', $out ) ) if( $out ne "" );
|
||||
&webmin_log("sync");
|
||||
|
||||
} elsif ($in{'action'} eq $text{'action_sync_s'}) {
|
||||
# Set hardware time to system time
|
||||
&error( $text{ 'acl_nohw' } ) if( $access{ 'hwdate' } && $access{'sysdate'} );
|
||||
local $flags = &get_hwclock_flags();
|
||||
$out = &backquote_logged("hwclock $flags --systohc");
|
||||
&error( &text( 'error_sync', $out ) ) if( $out ne "" );
|
||||
&webmin_log("sync_s");
|
||||
|
||||
} elsif($in{'action'} eq $text{'action_apply'} || $in{'mode'} eq 'sysdate' ) {
|
||||
# Setting the system time
|
||||
&error( $text{ 'acl_nosys' } ) if( $access{ 'sysdate' } );
|
||||
$err = &set_system_time($in{ 'second' }, $in{'minute'}, $in{'hour'},
|
||||
@@ -23,7 +38,7 @@ if( $in{ 'action' } eq $text{ 'action_apply' } )
|
||||
&error($err) if ($err);
|
||||
&webmin_log("set", "date", time(), \%in);
|
||||
|
||||
} elsif ( $in{ 'action' } eq $text{ 'action_save' } ) {
|
||||
} elsif ($in{'action'} eq $text{'action_save'} || $in{'mode'} eq 'hwdate' ) {
|
||||
# Setting the hardware time
|
||||
&error( $text{ 'acl_nohw' } ) if( $access{ 'hwdate' } );
|
||||
$err = &set_hardware_time($in{ 'second' }, $in{'minute'}, $in{'hour'},
|
||||
@@ -34,23 +49,7 @@ if( $in{ 'action' } eq $text{ 'action_apply' } )
|
||||
$in{'year'} : $in{'year'}-1900);
|
||||
&webmin_log("set", "hwclock", $hwtime, \%in);
|
||||
|
||||
} elsif( $in{ 'action' } eq $text{ 'action_sync' } ) {
|
||||
# Set system time to hardware time
|
||||
&error( $text{ 'acl_nosys' } ) if( $access{ 'sysdate' } );
|
||||
local $flags = &get_hwclock_flags();
|
||||
$out = &backquote_logged("hwclock $flags --hctosys");
|
||||
&error( &text( 'error_sync', $out ) ) if( $out ne "" );
|
||||
&webmin_log("sync");
|
||||
|
||||
} elsif( $in{ 'action' } eq $text{ 'action_sync_s' } ) {
|
||||
# Set hardware time to system time
|
||||
&error( $text{ 'acl_nohw' } ) if( $access{ 'hwdate' } && $access{'sysdate'} );
|
||||
local $flags = &get_hwclock_flags();
|
||||
$out = &backquote_logged("hwclock $flags --systohc");
|
||||
&error( &text( 'error_sync', $out ) ) if( $out ne "" );
|
||||
&webmin_log("sync_s");
|
||||
|
||||
} elsif( $in{ 'action' } eq $text{ 'index_sync' }) {
|
||||
} elsif ($in{'action'} eq $text{'index_sync'} || $in{'mode'} eq 'ntp') {
|
||||
# Sync with a time server
|
||||
$access{'ntp'} || &error($text{'acl_nontp'});
|
||||
$in{'timeserver'} =~ /\S/ || &error($text{'error_etimeserver'});
|
||||
|
||||
@@ -57,6 +57,7 @@ if( !$access{'sysdate'} )
|
||||
{
|
||||
# Show system time for editing
|
||||
print &ui_form_start("apply.cgi");
|
||||
print &ui_hidden("mode", "sysdate");
|
||||
print &tabletime(&hlink($text{'sys_title'}, "system_time"), 0, %system_date);
|
||||
print &ui_submit($text{'action_apply'}, "action");
|
||||
if (&support_hwtime()) {
|
||||
@@ -95,6 +96,7 @@ if (&support_hwtime()) {
|
||||
}
|
||||
|
||||
print &ui_form_start("apply.cgi");
|
||||
print &ui_hidden("mode", "hwdate");
|
||||
print &tabletime(&hlink($text{'hw_title'}, "hardware_time"),
|
||||
0, %hw_date);
|
||||
print &ui_submit($text{'action_save'}, "action");
|
||||
@@ -154,6 +156,7 @@ if ( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } &
|
||||
print $text{'index_descsync'},"<p>\n";
|
||||
|
||||
print &ui_form_start("apply.cgi");
|
||||
print &ui_hidden("mode", "ntp");
|
||||
print &ui_table_start(&hlink($text{'index_timeserver'}, "timeserver"),
|
||||
"width=100%", 2, [ "width=30%" ]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user