#!/usr/local/bin/perl require "./time-lib.pl"; local ($rawdate, $rawhwdate, %system_date, $rawtime, %hw_date, $txt); $txt = ""; &error( $text{ 'acl_error' } ) if( $access{ 'sysdate' } && $access{ 'hwdate' } ); if (!$access{'sysdate'} && !$access{'hwdate'} && $config{'hwtime'}) { $arr = "0,1"; } else { $arr = "0"; } &ui_print_header(undef, $text{ 'index_title' }, "", "index", 1, 1, undef, &help_search_link("date hwclock", "man"), qq(\n), qq(onLoad="F=[$arr];timeInit(F); setTimeout('timeUpdate(F)', 5000);")); if (!$access{'sysdate'} && !&has_command("date")) { print &text( 'error_cnf', "date"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; } if (!$access{'hwdate'} && $config{'hwtime'} && !&has_command("hwclock")) { print &text( 'error_cnf', "hwclock"),"

\n"; &ui_print_footer("/", $text{'index'}); exit; } # Get the system time @tm = &get_system_time(); $system_date{ 'second' } = $tm[0]; $system_date{ 'minute' } = $tm[1]; $system_date{ 'hour' } = $tm[2]; $system_date{ 'date' } = $tm[3]; $system_date{ 'month' } = &number_to_month($tm[4]); $system_date{ 'year' } = $tm[5]+1900; $system_date{ 'day' } = &number_to_weekday($tm[6]); if( !$access{'sysdate'} ) { # Show system time for editing print( "

", &tabletime( &hlink( $text{ 'sys_title' }, "system_time" ), 0, %system_date ), "", $config{'hwtime'} ? " \n" : ""); print "

"; } else { # Just show current time print &tabletime( &hlink( $text{ 'sys_title' }, "system_time" ), 1, %system_date ),"

\n"; } # Get the hardware time if ($config{'hwtime'}) { local @tm = &get_hardware_time(); @tm || &error($get_hardware_time_error || $text{'index_eformat'}); $hw_date{ 'second' } = $tm[0]; $hw_date{ 'minute' } = $tm[1]; $hw_date{ 'hour' } = $tm[2]; $hw_date{ 'date' } = $tm[3]; $hw_date{ 'month' } = &number_to_month($tm[4]); $hw_date{ 'year'} = $tm[5]+1900; $hw_date{ 'day' } = &number_to_weekday($tm[6]); if(!$access{'hwdate'}) { # Allow editing of hardware time if( !$access{ 'sysdate' } ) { $hw_date{ 'second' } = $system_date{ 'second' } if( $hw_date{ 'second' } - $system_date{ 'second' } <= $config{ 'lease' } ); } print( "

", &tabletime( &hlink( $text{ 'hw_title' }, "hardware_time" ), 0, %hw_date ), "", $config{'hwtime'} ? " " : "", "

" ); } else { # Show show the hardware time print "

",&tabletime( &hlink( $text{ 'hw_title' }, "hardware_time" ), 1, %hw_date ),"

\n"; } } if ($access{'timezone'} && &has_timezone()) { print "

\n"; print "\n"; print "\n"; print "
$text{'index_tzheader'}
\n"; @zones = &list_timezones(); $cz = &get_current_timezone(); $found = 0; print "\n"; print "\n"; print "
$text{'index_tz'}
\n"; print "
\n"; } if( ( !$access{ 'sysdate' } && &has_command( "date" ) || !$access{ 'hwdate' } && &has_command( "hwclock" ) ) && $access{'ntp'} ) { # Show time server input print( "

", "", "", "", "", "
", &hlink( $text{ 'index_timeserver' }, "timeserver" ), "
", "", "\n"); # Show hardware time checkbox if ($config{'hwtime'}) { print "\n"; } # Show schedule input &foreign_require("cron", "cron-lib.pl"); $job = &find_cron_job(); print "\n"; printf "\n", $job ? "checked" : "", $text{'index_schedyes'}; print "\n"; print "
",$text{ 'index_addresses' }, "",&p_entry( "timeserver", $config{'timeserver'}, 40 ), "
\n"; printf " %s\n", $config{'timeserver_hardware'} ? "checked" : "", $text{'index_hardware2'}; print "
$text{'index_sched'} %s\n", $job ? "" : "checked", $text{'no'}; printf " %s
\n"; $job ||= { 'mins' => '0', 'hours' => '0', 'days' => '*', 'months' => '*', 'weekdays' => '*' }; &cron::show_times_input($job); print "
\n"; print "
"; } &ui_print_footer( "/", $text{ 'index' } ); # tabletime(label, read-only, &time) sub tabletime { my ( $label, $ro, %src ) = @_, %assoc_day = ( "Mon", $text{ 'day_1' }, "Tue", $text{ 'day_2' }, "Wed", $text{ 'day_3' }, "Thu", $text{ 'day_4' }, "Fri", $text{ 'day_5' }, "Sat", $text{ 'day_6' }, "Sun", $text{ 'day_0' } ), %assoc_month = ( "Jan", $text{ 'month_1' }, "Feb", $text{ 'month_2' }, "Mar", $text{ 'month_3' }, "Apr", $text{ 'month_4' }, "May", $text{ 'month_5' }, "Jun", $text{ 'month_6' }, "Jul", $text{ 'month_7' }, "Aug", $text{ 'month_8' }, "Sep", $text{ 'month_9' }, "Oct", $text{ 'month_10' }, "Nov", $text{ 'month_11' }, "Dec", $text{ 'month_12' } ); $rv = "
". $label. "
\n". "". "". "\n". "\n". "\n". "\n". "\n". "\n"; if (!$ro) { $rv .= "". "\n". "\n". "\n". "\n". "\n". "\n". "
". $text{ 'day' }. "". $text{ 'date' }. "". $text{ 'month' }. "". $text{ 'year' }. "". $text{ 'hour' }. "
". ($assoc_day{ $src{ 'day' } } || $src{'day'})."". &p_select( "date", $src{ 'date' }, ( 1..31 ) ). "". &p_select_wdl( "month", $assoc_month{ $src{ 'month' } }, "01",( $text{ 'month_1' }, "02", $text{ 'month_2' }, "03", $text{ 'month_3' }, "04", $text{ 'month_4' }, "05", $text{ 'month_5' }, "06", $text{ 'month_6' }, "07", $text{ 'month_7' }, "08", $text{ 'month_8' }, "09", $text{ 'month_9' }, "10", $text{ 'month_10' }, "11", $text{ 'month_11' }, "12", $text{ 'month_12' } ) ). "". &p_select( "year", $src{ 'year' }, ( 1969..2037 ) ). "". &p_select( "hour", &zeropad($src{ 'hour' }, 2), ( "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", 10..23 ) ). "\n:". &p_select( "minute", &zeropad($src{ 'minute' }, 2), ( "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", 10..59) ). ":". &p_select( "second", &zeropad($src{ 'second' }, 2), ( "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", 10..59 ) ). "
"; } else { $rv .= "". "".($assoc_day{ $src{ 'day' } } || $src{'day'})."\n". "".$src{'date'}."\n". "".$src{'month'}."\n". "".$src{'year'}."\n". "".$src{'hour'}.":".$src{'minute'}.":".$src{'second'}."\n". "\n"; } return $rv; }