X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Ftime.cgi;h=39d71f84257b9c353d9ee884c13d959f5c2ae148;hb=f69446d2fa5fc519c223faeb9506842e191e46ca;hp=639e051e91b4aee05720fd467d02942929bfa197;hpb=ac1cfefab236b73ed52909e14f43eaffc8d6914e;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/html/cgi-bin/time.cgi b/html/cgi-bin/time.cgi index 639e051e9..39d71f842 100644 --- a/html/cgi-bin/time.cgi +++ b/html/cgi-bin/time.cgi @@ -1,17 +1,23 @@ #!/usr/bin/perl -# -# IPCop CGIs -# -# This file is part of the IPCop Project -# -# This code is distributed under the terms of the GPL -# -# (c) Eric Oberlander June 2002 -# -# (c) Darren Critchley June 2003 - added real time clock setting, etc -# -# $Id: time.cgi,v 1.4.2.11 2005/05/28 12:16:18 eoberlander Exp $ -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# 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 # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use strict; @@ -19,7 +25,7 @@ use strict; #use warnings; #use CGI::Carp 'fatalsToBrowser'; -require 'CONFIG_ROOT/general-functions.pl'; +require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; @@ -38,57 +44,10 @@ $timesettings{'UPDATE_METHOD'} = 'manually'; $timesettings{'UPDATE_VALUE'} = '0'; $timesettings{'UPDATE_PERIOD'} = ''; $timesettings{'ENABLECLNTP'} = 'off'; -$timesettings{'SETHOUR'} = ''; -$timesettings{'SETMINUTES'} = ''; -$timesettings{'SETDAY'} = ''; -$timesettings{'SETMONTH'} = ''; -$timesettings{'SETYEAR'} = ''; +$timesettings{'ENABLESETONBOOT'} = 'off'; &Header::getcgihash(\%timesettings); -if ($timesettings{'ACTION'} eq $Lang::tr{'instant update'}) -{ - if ($timesettings{'SETHOUR'} eq '' || $timesettings{'SETHOUR'} < 0 || $timesettings{'SETHOUR'} > 23) { - $errormessage = $Lang::tr{'invalid time entered'}; - goto UPDTERROR; - } - if ($timesettings{'SETMINUTES'} eq '' || $timesettings{'SETMINUTES'} < 0 || $timesettings{'SETMINUTES'} > 59) { - $errormessage = $Lang::tr{'invalid time entered'}; - goto UPDTERROR; - } - if ($timesettings{'SETDAY'} eq '' || $timesettings{'SETDAY'} < 1 || $timesettings{'SETDAY'} > 31) { - $errormessage = $Lang::tr{'invalid date entered'}; - goto UPDTERROR; - } - if ($timesettings{'SETMONTH'} eq '' || $timesettings{'SETMONTH'} < 1 || $timesettings{'SETMONTH'} > 12) { - $errormessage = $Lang::tr{'invalid date entered'}; - goto UPDTERROR; - } - if ($timesettings{'SETYEAR'} eq '' || $timesettings{'SETYEAR'} < 2003 || $timesettings{'SETYEAR'} > 2030) { - $errormessage = $Lang::tr{'invalid date entered'}; - goto UPDTERROR; - } - -UPDTERROR: - if ($errormessage) { - $timesettings{'VALID'} = 'no'; } - else { - $timesettings{'VALID'} = 'yes'; } - - if ($timesettings{'VALID'} eq 'yes') { - # we want date in YYYY-MM-DD HH:MM format for date command - # EAO changed datestring to ISO 6801 format 2003-08-11 - my $datestring = "$timesettings{'SETYEAR'}-$timesettings{'SETMONTH'}-$timesettings{'SETDAY'}"; - my $timestring = "$timesettings{'SETHOUR'}:$timesettings{'SETMINUTES'}"; - # EAO setdate.c also revised for ISO 6801 date format 2003-08-11 - system ('/usr/local/bin/setdate', $datestring, $timestring); - &General::log("$Lang::tr{'time date manually reset'} $datestring $timestring"); - } - unless ($errormessage) { - undef %timesettings; - } -} - if ($timesettings{'ACTION'} eq $Lang::tr{'save'}) { if ($timesettings{'ENABLENTP'} eq 'on') @@ -166,19 +125,20 @@ ERROR: if ($timesettings{'ENABLENTP'} eq 'on' && $timesettings{'VALID'} eq 'yes') { - system ('/bin/touch', "${General::swroot}/time/enable"); + 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; } if ($timesettings{'ENABLECLNTP'} eq 'on') # DPC added to 1.3.1 { - system ('/bin/touch', "${General::swroot}/time/allowclients"); # DPC added to 1.3.1 + 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"; @@ -188,12 +148,13 @@ 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'}) } if (! $errormessage) { - system ('/usr/local/bin/restartntpd'); # DPC added to 1.3.1 + system ('/usr/local/bin/timectrl restart >/dev/null 2>&1'); # DPC added to 1.3.1 } } @@ -202,7 +163,7 @@ ERROR: $timesettings{'ACTION'} = &Header::cleanhtml ($timesettings{'ACTION'}); if ($timesettings{'ACTION'} eq $Lang::tr{'set time now'} && $timesettings{'ENABLENTP'} eq 'on') { - system ('/bin/touch', "${General::swroot}/time/settimenow"); + system ('/usr/bin/touch', "/var/lock/time/settimenow"); } &General::readhash("${General::swroot}/time/settings", \%timesettings); @@ -213,8 +174,9 @@ if ($timesettings{'VALID'} eq '') $timesettings{'UPDATE_METHOD'} = 'manually'; $timesettings{'UPDATE_VALUE'} = '1'; $timesettings{'UPDATE_PERIOD'} = 'daily'; - $timesettings{'NTP_ADDR_1'} = 'pool.ntp.org'; - $timesettings{'NTP_ADDR_2'} = 'pool.ntp.org'; + $timesettings{'NTP_ADDR_1'} = '0.ipfire.pool.ntp.org'; + $timesettings{'NTP_ADDR_2'} = '1.ipfire.pool.ntp.org'; + $timesettings{'ENABLESETONBOOT'} = 'off'; } unless ($errormessage) { @@ -238,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'"; @@ -250,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 = ""; } @@ -267,7 +233,7 @@ if ($errormessage) { print "
\n"; -&Header::openbox('100%', 'left', $Lang::tr{'network time'}); +&Header::openbox('100%', 'left', $Lang::tr{'ntp common settings'}); print < @@ -280,10 +246,12 @@ print <; + close FILE; print $output; } else @@ -304,19 +272,21 @@ print <  $Lang::tr{'clenabled'} - - - - - - + +

$Lang::tr{'update time'}
 $Lang::tr{'set time now help'} $Lang::tr{'Set time on boot'}
+END +; +&Header::closebox(); +&Header::openbox('100%',1,$Lang::tr{'ntp sync'}); +print < - $Lang::tr{'every'}: - + $Lang::tr{'every'} + $Lang::tr{'manually'} + +

$Lang::tr{'update time'} + + +   + $Lang::tr{'set time now help'} + END ; -if ( -e "${General::swroot}/time/settimenow") { +if ( -e "/var/lock/time/settimenow") { print "\n\n"; print "$Lang::tr{'waiting to synchronize clock'}...\n"; } @@ -343,11 +320,8 @@ print < * $Lang::tr{'this field may be blank'} - - - - - + + END @@ -355,34 +329,6 @@ END &Header::closebox(); -&Header::openbox('100%', 'left', $Lang::tr{'update time'}); - -print < - - - - - - - - - - - - - - - -
$Lang::tr{'year'}:  $Lang::tr{'month'}:  $Lang::tr{'day'}:     $Lang::tr{'hours2'}:  $Lang::tr{'minutes'}: 
- - - - -END -; -&Header::closebox(); - print "\n"; &Header::closebigbox();