]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/time.cgi
rtl8189fs: add realtek wlan driver
[ipfire-2.x.git] / html / cgi-bin / time.cgi
index caa17181ba90f188c38caf68a2afd344a6562f24..6bf3dcc8431cb20248b711a90b9bea532951ef7a 100644 (file)
@@ -20,6 +20,7 @@
 ###############################################################################
 
 use strict;
+use POSIX qw(strftime);
 
 # enable only the following on debugging purpose
 #use warnings;
@@ -125,8 +126,8 @@ ERROR:
 
        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')
@@ -138,7 +139,7 @@ ERROR:
                }
                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";
@@ -150,11 +151,11 @@ ERROR:
                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
        }
 }
 
@@ -163,7 +164,7 @@ ERROR:
 $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);
@@ -180,11 +181,18 @@ if ($timesettings{'VALID'} eq '')
 }
 
 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/;
 }
@@ -233,13 +241,9 @@ if ($errormessage) {
 
 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>
@@ -267,9 +271,9 @@ print <<END
 </td></tr>
 <tr>
        <td>&nbsp;</td>
-       <td width='25%' class='base'>$Lang::tr{'primary ntp server'}:</td>
+       <td width='25%' class='base'>$Lang::tr{'primary ntp server'}:&nbsp;<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'}: &nbsp;<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>
@@ -281,10 +285,12 @@ print <<END
        <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>
@@ -302,7 +308,7 @@ print <<END
        <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>&nbsp;</td>
@@ -321,10 +327,9 @@ print <<END
 <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'>&nbsp;</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