]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/time.cgi
Some cosmetic changes on time.cgi
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / time.cgi
index 29bfd2f26ceab09d7cf0ef71d18239edc7caffbc..c68eb999fdef389170db1d10bde7927a575ec636 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+# Copyright (C) 2010  IPFire Team                                             #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -44,6 +44,7 @@ $timesettings{'UPDATE_METHOD'} = 'manually';
 $timesettings{'UPDATE_VALUE'} = '0';
 $timesettings{'UPDATE_PERIOD'} = '';
 $timesettings{'ENABLECLNTP'} = 'off';
+$timesettings{'ENABLESETONBOOT'} = 'off';
 
 &Header::getcgihash(\%timesettings);
 
@@ -127,10 +128,10 @@ ERROR:
                system ('/usr/bin/touch', "${General::swroot}/time/enable");
                system ('/usr/local/bin/timectrl enable >/dev/null 2>&1');
                &General::log($Lang::tr{'ntp syncro enabled'});
-               unlink "${General::swroot}/time/counter";
+               unlink "/var/lock/time/counter";
                if ($timesettings{'UPDATE_METHOD'} eq 'periodically')
                {
-                       open(FILE, ">/${General::swroot}/time/counter") or die "Unable to write counter file";
+                       open(FILE, ">/var/lock/time/counter") or die "Unable to write counter file";
                        flock(FILE, 2);
                        print FILE "$updateperiod\n";
                        close FILE;
@@ -147,7 +148,7 @@ ERROR:
        else
        {
                unlink "${General::swroot}/time/enable";
-               unlink "${General::swroot}/time/settimenow";
+               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::log($Lang::tr{'ntp syncro disabled'})
@@ -162,7 +163,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', "${General::swroot}/time/settimenow");
+       system ('/usr/bin/touch', "/var/lock/time/settimenow");
 }
 
 &General::readhash("${General::swroot}/time/settings", \%timesettings);
@@ -175,6 +176,7 @@ if ($timesettings{'VALID'} eq '')
        $timesettings{'UPDATE_PERIOD'} = 'daily';
        $timesettings{'NTP_ADDR_1'} = 'de.pool.ntp.org';
        $timesettings{'NTP_ADDR_2'} = 'pool.ntp.org';
+       $timesettings{'ENABLESETONBOOT'} = 'off';
 }
 
 unless ($errormessage) {
@@ -198,6 +200,10 @@ $checked{'ENABLECLNTP'}{'off'} = '';
 $checked{'ENABLECLNTP'}{'on'} = '';
 $checked{'ENABLECLNTP'}{$timesettings{'ENABLECLNTP'}} = "checked='checked'";
 
+$checked{'ENABLESETONBOOT'}{'off'} = '';
+$checked{'ENABLESETONBOOT'}{'on'} = '';
+$checked{'ENABLESETONBOOT'}{$timesettings{'ENABLESETONBOOT'}} = "checked='checked'";
+
 $checked{'UPDATE_METHOD'}{'manually'} = '';
 $checked{'UPDATE_METHOD'}{'periodically'} = '';
 $checked{'UPDATE_METHOD'}{$timesettings{'UPDATE_METHOD'}} = "checked='checked'";
@@ -210,7 +216,7 @@ $selected{'UPDATE_PERIOD'}{$timesettings{'UPDATE_PERIOD'}} = "selected='selected
 
 # added to v0.0.4 to refresh screen if syncro event queued 
 my $refresh = '';
-if ( -e "${General::swroot}/time/settimenow") {
+if ( -e "/var/lock/time/settimenow") {
        $refresh = "<meta http-equiv='refresh' content='60;' />";
 }
 
@@ -230,6 +236,10 @@ print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
 &Header::openbox('100%', 'left', $Lang::tr{'network time'});
 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>
@@ -240,10 +250,12 @@ print <<END
 END
 ;
 
-if ( -e "${General::swroot}/time/lastset")
+if ( -e "/var/lock/time/lastset")
 {
        print "$Lang::tr{'clock last synchronized at'}\n";
-       my $output = `cat ${General::swroot}/time/lastset`;
+       open(FILE, "</var/lock/time/lastset") or die "Unable to read lastset";
+       my $output = <FILE>;
+       close FILE;
        print $output;
 }
 else
@@ -264,19 +276,19 @@ print <<END
        <td>&nbsp;</td>
        <td class='base' colspan='4'><input type='checkbox' name='ENABLECLNTP' $checked{'ENABLECLNTP'}{'on'} /> $Lang::tr{'clenabled'}</td>
 </tr>
-</table>
-<table width='100%'>
 <tr>
-       <td colspan='4'><hr /><b>$Lang::tr{'update time'}</b></td>
+       <td>&nbsp;</td>
+       <td class='base' colspan='4'><input type='checkbox' name='ENABLESETONBOOT' $checked{'ENABLESETONBOOT'}{'on'} /> $Lang::tr{'Set time on boot'}</td>
 </tr>
+</table>
+<table width='100%'>
 <tr>
-       <td>&nbsp;</td>
-       <td class='base' colspan='2'>$Lang::tr{'set time now help'}</td>
+       <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='15%'>$Lang::tr{'every'}: </td>
-       <td width='35%'><input type='text' name='UPDATE_VALUE' size='3' maxlength='3' value='$timesettings{'UPDATE_VALUE'}' />
+       <td width='10%'>$Lang::tr{'every'}</td>
+       <td width='45%'><input type='text' name='UPDATE_VALUE' size='3' maxlength='3' value='$timesettings{'UPDATE_VALUE'}' />
        <select name='UPDATE_PERIOD'>
                <option value='hourly' $selected{'UPDATE_PERIOD'}{'hourly'}>$Lang::tr{'hours'}</option>
                <option value='daily' $selected{'UPDATE_PERIOD'}{'daily'}>$Lang::tr{'days'}</option>
@@ -289,10 +301,17 @@ print <<END
        <td class='base'><input type='radio' name='UPDATE_METHOD' value='manually' $checked{'UPDATE_METHOD'}{'manually'} /></td>
        <td colspan='2'>$Lang::tr{'manually'}</td>
 </tr>
+<tr>
+       <td colspan='4'><hr /><strong>$Lang::tr{'update time'}</strong></td>
+</tr>
+<tr>
+       <td>&nbsp;</td>
+       <td class='base' colspan='3'>$Lang::tr{'set time now help'}</td>
+</tr>
 END
 ;
 
-if ( -e "${General::swroot}/time/settimenow") {
+if ( -e "/var/lock/time/settimenow") {
        print "<tr>\n<td align='center'><img src='/images/clock.gif' alt='' /></td>\n";
        print "<td colspan='2'><font color='red'>$Lang::tr{'waiting to synchronize clock'}...</font></td></tr>\n";
 }