array(), 'selected' => array()); $interfaces = get_configured_interface_with_descr(); foreach ($interfaces as $iface => $ifacename) { if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddrv6(get_interface_ipv6($iface))) { continue; } $iflist['options'][$iface] = $ifacename; if (in_array($iface, $pconfig['interface'])) { array_push($iflist['selected'], $iface); } } return($iflist); } $pconfig = &$config['ntpd']; if (empty($pconfig['interface'])) { $pconfig['interface'] = array(); } else { $pconfig['interface'] = explode(",", $pconfig['interface']); } $pgtitle = array(gettext("Services"), gettext("NTP"), gettext("Settings")); $shortcut_section = "ntp"; include("head.inc"); if ($input_errors) { print_input_errors($input_errors); } if ($savemsg) { print_info_box($savemsg, 'success'); } $tab_array = array(); $tab_array[] = array(gettext("Settings"), true, "services_ntpd.php"); $tab_array[] = array(gettext("ACLs"), false, "services_ntpd_acls.php"); $tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php"); $tab_array[] = array(gettext("PPS"), false, "services_ntpd_pps.php"); display_top_tabs($tab_array); $form = new Form; $form->setMultipartEncoding(); // Allow file uploads $section = new Form_Section('NTP Server Configuration'); $iflist = build_interface_list(); $section->addInput(new Form_Select( 'interface', 'Interface', $iflist['selected'], $iflist['options'], true ))->setHelp('Interfaces without an IP address will not be shown.' . '
' . 'Selecting no interfaces will listen on all interfaces with a wildcard.' . '
' . 'Selecting all interfaces will explicitly listen on only the interfaces/IPs specified.'); $timeservers = explode(' ', $config['system']['timeservers']); $maxrows = max(count($timeservers), 1); for ($counter=0; $counter < $maxrows; $counter++) { $group = new Form_Group($counter == 0 ? 'Time Servers':''); $group->addClass('repeatable'); $group->setAttribute('max_repeats', NUMTIMESERVERS); $group->setAttribute('max_repeats_alert', sprintf(gettext('%d is the maximum number of configured servers.'), NUMTIMESERVERS)); $group->add(new Form_Input( 'server' . $counter, null, 'text', $timeservers[$counter], ['placeholder' => 'Hostname'] ))->setWidth(3); $group->add(new Form_Checkbox( 'servprefer' . $counter, null, null, isset($config['ntpd']['prefer']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['prefer'], $timeservers[$counter]) ))->sethelp('Prefer'); $group->add(new Form_Checkbox( 'servselect' . $counter, null, null, isset($config['ntpd']['noselect']) && isset($timeservers[$counter]) && substr_count($config['ntpd']['noselect'], $timeservers[$counter]) ))->sethelp('No Select'); $group->add(new Form_Button( 'deleterow' . $counter, 'Delete', null, 'fa-trash' ))->addClass('btn-warning'); $section->add($group); } $section->addInput(new Form_Button( 'addrow', 'Add', null, 'fa-plus' ))->addClass('btn-success'); $section->addInput(new Form_StaticText( null, $btnaddrow ))->setHelp('For best results three to five servers should be configured here.' . '
' . 'The prefer option indicates that NTP should favor the use of this server more than all others.' . '
' . 'The no select option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.'); $section->addInput(new Form_Input( 'ntporphan', 'Orphan Mode', 'text', $pconfig['orphan'], ['placeholder' => "12"] ))->setHelp('Orphan mode allows the system clock to be used when no other clocks are available. ' . 'The number here specifies the stratum reported during orphan mode and should normally be set to a number high enough ' . 'to insure that any other servers available to clients are preferred over this server (default: 12).'); $section->addInput(new Form_Checkbox( 'statsgraph', 'NTP Graphs', 'Enable RRD graphs of NTP statistics (default: disabled).', $pconfig['statsgraph'] )); $section->addInput(new Form_Checkbox( 'logpeer', 'Logging', 'Log peer messages (default: disabled).', $pconfig['logpeer'] )); $section->addInput(new Form_Checkbox( 'logsys', null, 'Log system messages (default: disabled).', $pconfig['logsys'] ))->setHelp('These options enable additional messages from NTP to be written to the System Log ' . '' . 'Status > System Logs > NTP' . '.'); // Statistics logging section $btnadv = new Form_Button( 'btnadvstats', 'Display Advanced', null, 'fa-cog' ); $btnadv->setAttribute('type','button')->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Statistics Logging', $btnadv ))->setHelp('Warning: These options will create persistent daily log files in /var/log/ntp.'); $section->addInput(new Form_Checkbox( 'clockstats', null, 'Log reference clock statistics (default: disabled).', $pconfig['clockstats'] )); $section->addInput(new Form_Checkbox( 'loopstats', null, 'Log clock discipline statistics (default: disabled).', $pconfig['loopstats'] )); $section->addInput(new Form_Checkbox( 'peerstats', null, 'Log NTP peer statistics (default: disabled).', $pconfig['peerstats'] )); // Leap seconds section $btnadv = new Form_Button( 'btnadvleap', 'Display Advanced', null, 'fa-cog' ); $btnadv->setAttribute('type','button')->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Leap seconds', $btnadv ))->setHelp('A leap second file allows NTP to advertise an upcoming leap second addition or subtraction. ' . 'Normally this is only useful if this server is a stratum 1 time server. '); $section->addInput(new Form_Textarea( 'leaptext', null, base64_decode(chunk_split($pconfig['leapsec'])) ))->setHelp('Enter Leap second configuration as text OR select a file to upload.'); $section->addInput(new Form_Input( 'leapfile', null, 'file' ))->addClass('btn-default'); $form->add($section); print($form); ?>