###############################################################################
use strict;
+use POSIX qw(strftime);
# enable only the following on debugging purpose
#use warnings;
if ($timesettings{'ENABLENTP'} eq 'on' && $timesettings{'VALID'} eq 'yes')
{
- system ('/usr/bin/touch', "${General::swroot}/time/enable");
- system ('/usr/local/bin/timectrl enable >/dev/null 2>&1');
+ &General::system('/usr/bin/touch', "${General::swroot}/time/enable");
+ &General::system('/usr/local/bin/timectrl', 'enable');
&General::log($Lang::tr{'ntp syncro enabled'});
unlink "/var/lock/time/counter";
if ($timesettings{'UPDATE_METHOD'} eq 'periodically')
}
if ($timesettings{'ENABLECLNTP'} eq 'on') # DPC added to 1.3.1
{
- system ('/usr/bin/touch', "${General::swroot}/time/allowclients"); # DPC added to 1.3.1
+ &General::system('/usr/bin/touch', "${General::swroot}/time/allowclients"); # DPC added to 1.3.1
&General::log($Lang::tr{'ntpd restarted'}); # DPC added to 1.3.1
} else {
unlink "${General::swroot}/time/allowclients";
unlink "${General::swroot}/time/enable";
unlink "/var/lock/time/settimenow";
unlink "${General::swroot}/time/allowclients"; # DPC added to 1.3.1
- system ('/usr/local/bin/timectrl disable >/dev/null 2>&1');
+ &General::system('/usr/local/bin/timectrl', 'disable');
&General::log($Lang::tr{'ntp syncro disabled'})
}
if (! $errormessage) {
- system ('/usr/local/bin/timectrl restart >/dev/null 2>&1'); # DPC added to 1.3.1
+ &General::system('/usr/local/bin/timectrl', 'restart'); # DPC added to 1.3.1
}
}
$timesettings{'ACTION'} = &Header::cleanhtml ($timesettings{'ACTION'});
if ($timesettings{'ACTION'} eq $Lang::tr{'set time now'} && $timesettings{'ENABLENTP'} eq 'on')
{
- system ('/usr/bin/touch', "/var/lock/time/settimenow");
+ &General::system('/usr/bin/touch', "/var/lock/time/settimenow");
}
&General::readhash("${General::swroot}/time/settings", \%timesettings);
}
unless ($errormessage) {
- $timesettings{'SETMONTH'} = `date +'%m %e %Y %H %M'|cut -c 1-2`;
- $timesettings{'SETDAY'} = `date +'%m %e %Y %H %M'|cut -c 4-5`;
- $timesettings{'SETYEAR'} = `date +'%m %e %Y %H %M'|cut -c 7-10`;
- $timesettings{'SETHOUR'} = `date +'%m %e %Y %H %M'|cut -c 12-13`;
- $timesettings{'SETMINUTES'} = `date +'%m %e %Y %H %M'|cut -c 15-16`;
+ # Get date and time.
+ my $date = strftime("%m %e %Y %H %M", localtime);
+
+ # Split date string into single values.
+ my ($month, $day, $year, $hour, $minute) = split(/ /, $date);
+
+ # Assign values to the hash.
+ $timesettings{'SETMONTH'} = $month;
+ $timesettings{'SETDAY'} = $day;
+ $timesettings{'SETYEAR'} = $year;
+ $timesettings{'SETHOUR'} = $hour;
+ $timesettings{'SETMINUTES'} = $minute;
$_=$timesettings{'SETDAY'};
$timesettings{'SETDAY'}=~ tr/ /0/;
}
print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
-&Header::openbox('100%', 'left', $Lang::tr{'network time'});
+&Header::openbox('100%', 'left', $Lang::tr{'ntp common settings'});
print <<END
<table width='100%'>
-<tr>
- <td colspan='2'><strong>$Lang::tr{'ntp common settings'}</strong></td>
-</tr>
-
<tr>
<td><input type='checkbox' name='ENABLENTP' $checked{'ENABLENTP'}{'on'} /></td>
<td width='100%' colspan='4' class='base'>$Lang::tr{'network time from'}</td>
</td></tr>
<tr>
<td> </td>
- <td width='25%' class='base'>$Lang::tr{'primary ntp server'}:</td>
+ <td width='25%' class='base'>$Lang::tr{'primary ntp server'}: <img src='/blob.gif' alt='*' /></td>
<td width='25%'><input type='text' name='NTP_ADDR_1' value='$timesettings{'NTP_ADDR_1'}' /></td>
- <td width='25%' class='base'>$Lang::tr{'secondary ntp server'}: <img src='/blob.gif' align='top' alt='*' /></td>
+ <td width='25%' class='base'>$Lang::tr{'secondary ntp server'}:</td>
<td width='25%'><input type='text' name='NTP_ADDR_2' value='$timesettings{'NTP_ADDR_2'}' /></td>
</tr>
<tr>
<td class='base' colspan='4'><input type='checkbox' name='ENABLESETONBOOT' $checked{'ENABLESETONBOOT'}{'on'} /> $Lang::tr{'Set time on boot'}</td>
</tr>
</table>
+END
+;
+&Header::closebox();
+&Header::openbox('100%',1,$Lang::tr{'ntp sync'});
+print <<END
<table width='100%'>
-<tr>
- <td colspan='4'><hr /><strong>$Lang::tr{'ntp sync'}</strong></td>
-</tr>
<tr>
<td class='base'><input type='radio' name='UPDATE_METHOD' value='periodically' $checked{'UPDATE_METHOD'}{'periodically'} /></td>
<td width='10%'>$Lang::tr{'every'}</td>
<td colspan='2'>$Lang::tr{'manually'}</td>
</tr>
<tr>
- <td colspan='4'><hr /><strong>$Lang::tr{'update time'}</strong></td>
+ <td colspan='4'><br><br><strong>$Lang::tr{'update time'}</strong></td>
</tr>
<tr>
<td> </td>
<hr />
<table width='100%'>
<tr>
- <td width='30%'><img src='/blob.gif' alt='*' /> $Lang::tr{'this field may be blank'}</td>
- <td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'set time now'}' /></td>
- <td width='25%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
- <td width='5%' align='right'> </td>
+ <td width='30%'><img src='/blob.gif' alt='*' /> $Lang::tr{'required field'}</td>
+ <td width='65%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'set time now'}' /></td>
+ <td width='5%' align='right'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
</tr>
</table>
END