X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Ftime.cgi;h=29bfd2f26ceab09d7cf0ef71d18239edc7caffbc;hb=3961e8317ff6be3eeb27dd8baee6268aaedc0b63;hp=aa96479da47ccf527253c001e7a36693a7b2f56c;hpb=78331e301975a38f952ad9311a7ff3201e5a5e2e;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/time.cgi b/html/cgi-bin/time.cgi index aa96479da4..29bfd2f26c 100644 --- a/html/cgi-bin/time.cgi +++ b/html/cgi-bin/time.cgi @@ -1,17 +1,23 @@ #!/usr/bin/perl -# -# IPFire CGIs -# -# This file is part of the IPFire 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) 2007 Michael Tremer & Christian Schmidt # +# # +# 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,9 @@ $timesettings{'UPDATE_METHOD'} = 'manually'; $timesettings{'UPDATE_VALUE'} = '0'; $timesettings{'UPDATE_PERIOD'} = ''; $timesettings{'ENABLECLNTP'} = 'off'; -$timesettings{'SETHOUR'} = ''; -$timesettings{'SETMINUTES'} = ''; -$timesettings{'SETDAY'} = ''; -$timesettings{'SETMONTH'} = ''; -$timesettings{'SETYEAR'} = ''; &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,7 +124,8 @@ 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"; if ($timesettings{'UPDATE_METHOD'} eq 'periodically') @@ -178,7 +137,7 @@ ERROR: } 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"; @@ -190,10 +149,11 @@ ERROR: unlink "${General::swroot}/time/enable"; unlink "${General::swroot}/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 +162,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', "${General::swroot}/time/settimenow"); } &General::readhash("${General::swroot}/time/settings", \%timesettings); @@ -213,7 +173,7 @@ 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_1'} = 'de.pool.ntp.org'; $timesettings{'NTP_ADDR_2'} = 'pool.ntp.org'; } @@ -345,9 +305,7 @@ print <* $Lang::tr{'this field may be blank'} - - - +   END @@ -355,34 +313,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();