Commit 14f7dd4b authored by Ad Schellevis's avatar Ad Schellevis Committed by Franco Fichtner

(legacy) refactor services_ntpd.php

(cherry picked from commit 9871f0ba)
parent f0b9bd07
<?php <?php
/* /*
Copyright (C) 2014-2015 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2013 Dagorlad Copyright (C) 2013 Dagorlad
Copyright (C) 2012 Jim Pingle Copyright (C) 2012 Jim Pingle
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, 1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
require_once("guiconfig.inc"); require_once("guiconfig.inc");
...@@ -34,372 +34,376 @@ require_once("services.inc"); ...@@ -34,372 +34,376 @@ require_once("services.inc");
require_once("system.inc"); require_once("system.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
if (!isset($config['ntpd']) || !is_array($config['ntpd'])) if (!isset($config['ntpd']) || !is_array($config['ntpd'])) {
$config['ntpd'] = array(); $config['ntpd'] = array();
if (empty($config['ntpd']['interface'])) {
$pconfig['interface'] = array();
} else {
$pconfig['interface'] = explode(",", $config['ntpd']['interface']);
} }
$a_ntpd = &$config['ntpd'];
if ($_POST) { $copy_fields = array('orphan', 'statsgraph', 'logpeer', 'logsys', 'clockstats', 'loopstats', 'interface',
unset($input_errors); 'peerstats', 'noquery', 'noserve', 'kod', 'nomodify', 'nopeer', 'notrap', 'leapsec');
$pconfig = $_POST; if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array();
if (isset($_POST['interface']) && is_array($_POST['interface']))
$config['ntpd']['interface'] = implode(",", $_POST['interface']);
elseif (isset($config['ntpd']['interface']))
unset($config['ntpd']['interface']);
unset($config['ntpd']['prefer']); foreach ($copy_fields as $fieldname) {
unset($config['ntpd']['noselect']); if (isset($a_ntpd[$fieldname])) {
$timeservers = ''; $pconfig[$fieldname] = $a_ntpd[$fieldname];
for ($i = 0; $i < 10; $i++) { }
$tserver = trim($_POST["server{$i}"]); }
if (!empty($tserver)) {
$timeservers .= "{$tserver} "; // base64 encoded
if (!empty($_POST["servprefer{$i}"])) $config['ntpd']['prefer'] .= "{$tserver} "; $pconfig['leapsec'] = base64_decode(chunk_split($pconfig['leapsec']));
if (!empty($_POST["servselect{$i}"])) $config['ntpd']['noselect'].= "{$tserver} ";
} // array types
} $pconfig['interface'] = !empty($pconfig['interface']) ? explode(",", $pconfig['interface']) : array();
$config['system']['timeservers'] = trim($timeservers);
if (empty($config['system']['timeservers'])) { // parse timeservers
unset($config['system']['timeservers']); $pconfig['timeservers_host'] = array();
$pconfig['timeservers_noselect'] = array();
$pconfig['timeservers_prefer'] = array();;
if (!empty($config['system']['timeservers'])) {
$pconfig['timeservers_noselect'] = !empty($a_ntpd['noselect']) ? explode(' ', $a_ntpd['noselect']) : array();
$pconfig['timeservers_prefer'] = !empty($a_ntpd['prefer']) ? explode(' ', $a_ntpd['prefer']) : array();
$pconfig['timeservers_host'] = explode(' ', $config['system']['timeservers']);
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
$input_errors = array();
if (!empty($pconfig['orphan']) && ($pconfig['orphan'] < 0 || $pconfig['orphan'] > 15 || !is_numeric($pconfig['orphan']))) {
$input_errors[] = gettext("Orphan mode must be a value between 0..15");
}
// swap fields, really stupid field usage which we are not going to change now....
foreach (array('kod', 'nomodify', 'nopeer', 'notrap') as $fieldname) {
$pconfig[$fieldname] = empty($pconfig[$fieldname]);
}
if (count($input_errors) == 0) {
// copy fields
foreach ($copy_fields as $fieldname) {
if (!empty($pconfig[$fieldname])) {
$a_ntpd[$fieldname] = $pconfig[$fieldname];
} elseif (isset($a_ntpd[$fieldname])) {
unset($a_ntpd[$fieldname]);
}
} }
if (!empty($_POST['ntporphan']) && ($_POST['ntporphan'] < 17) && ($_POST['ntporphan'] != '12')) // list types
$config['ntpd']['orphan'] = $_POST['ntporphan']; $config['system']['timeservers'] = trim(implode(' ', $pconfig['timeservers_host']));
elseif (isset($config['ntpd']['orphan'])) $a_ntpd['noselect'] = !empty($pconfig['timeservers_noselect']) ? trim(implode(' ', $pconfig['timeservers_noselect'])) : null;
unset($config['ntpd']['orphan']); $a_ntpd['prefer'] = "";
if (!empty($pconfig['timeservers_prefer'])) {
if (!empty($_POST['logpeer'])) foreach ($pconfig['timeservers_prefer'] as $timeserver) {
$config['ntpd']['logpeer'] = $_POST['logpeer']; if (!in_array($timeserver, $pconfig['timeservers_noselect'])) {
elseif (isset($config['ntpd']['logpeer'])) // a timeserver can't be both preferred and disabled, don't set preferred when disabled
unset($config['ntpd']['logpeer']); $a_ntpd['prefer'] .= $timeserver . " ";
}
if (!empty($_POST['logsys'])) }
$config['ntpd']['logsys'] = $_POST['logsys']; }
elseif (isset($config['ntpd']['logsys'])) $a_ntpd['prefer'] = trim($a_ntpd['prefer']);
unset($config['ntpd']['logsys']); $a_ntpd['interface'] = implode(',', $pconfig['interface']);
if (!empty($_POST['clockstats'])) // unset empty
$config['ntpd']['clockstats'] = $_POST['clockstats']; foreach (array('noselect', 'prefer', 'interface') as $fieldname) {
elseif (isset($config['ntpd']['clockstats'])) if (empty($a_ntpd[$fieldname])) {
unset($config['ntpd']['clockstats']); unset($a_ntpd[$fieldname]);
}
if (!empty($_POST['loopstats'])) }
$config['ntpd']['loopstats'] = $_POST['loopstats']; if (empty($config['system']['timeservers'])) {
elseif (isset($config['ntpd']['loopstats'])) unset($config['system']['timeservers']);
unset($config['ntpd']['loopstats']); }
if (!empty($_POST['peerstats']))
$config['ntpd']['peerstats'] = $_POST['peerstats'];
elseif (isset($config['ntpd']['peerstats']))
unset($config['ntpd']['peerstats']);
if (empty($_POST['kod']))
$config['ntpd']['kod'] = 'on';
elseif (isset($config['ntpd']['kod']))
unset($config['ntpd']['kod']);
if (empty($_POST['nomodify']))
$config['ntpd']['nomodify'] = 'on';
elseif (isset($config['ntpd']['nomodify']))
unset($config['ntpd']['nomodify']);
if (!empty($_POST['noquery']))
$config['ntpd']['noquery'] = $_POST['noquery'];
elseif (isset($config['ntpd']['noquery']))
unset($config['ntpd']['noquery']);
if (!empty($_POST['noserve']))
$config['ntpd']['noserve'] = $_POST['noserve'];
elseif (isset($config['ntpd']['noserve']))
unset($config['ntpd']['noserve']);
if (empty($_POST['nopeer']))
$config['ntpd']['nopeer'] = 'on';
elseif (isset($config['ntpd']['nopeer']))
unset($config['ntpd']['nopeer']);
if (empty($_POST['notrap']))
$config['ntpd']['notrap'] = 'on';
elseif (isset($config['ntpd']['notrap']))
unset($config['ntpd']['notrap']);
if ((empty($_POST['statsgraph'])) != (isset($config['ntpd']['statsgraph'])));
enable_rrd_graphing();
if (!empty($_POST['statsgraph']))
$config['ntpd']['statsgraph'] = $_POST['statsgraph'];
elseif (isset($config['ntpd']['statsgraph']))
unset($config['ntpd']['statsgraph']);
if (!empty($_POST['leaptxt']))
$config['ntpd']['leapsec'] = base64_encode($_POST['leaptxt']);
elseif (isset($config['ntpd']['leapsec']))
unset($config['ntpd']['leapsec']);
if (is_uploaded_file($_FILES['leapfile']['tmp_name']))
$config['ntpd']['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
write_config("Updated NTP Server Settings");
$retval = 0;
$retval = system_ntp_configure();
$savemsg = get_std_save_message();
} if (!empty($a_ntpd['leapsec'])) {
$a_ntpd['leapsec'] = base64_encode($a_ntpd['leapsec']);
} elseif(isset($config['ntpd']['leapsec'])) {
unset($config['ntpd']['leapsec']);
}
$pconfig = &$config['ntpd']; if (is_uploaded_file($_FILES['leapfile']['tmp_name'])) {
if (empty($pconfig['interface'])) { $a_ntpd['leapsec'] = base64_encode(file_get_contents($_FILES['leapfile']['tmp_name']));
$pconfig['interface'] = array(); }
} else { write_config("Updated NTP Server Settings");
$pconfig['interface'] = explode(",", $pconfig['interface']); system_ntp_configure();
header("Location: services_ntpd.php");
exit;
}
} }
$service_hook = 'ntpd'; $service_hook = 'ntpd';
legacy_html_escape_form_data($pconfig);
include("head.inc"); include("head.inc");
?> ?>
<body> <body>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
//Generic show an advanced option function //Generic show an advanced option function
function show_advanced(showboxID, configvalueID) { function show_advanced(showboxID, configvalueID) {
document.getElementById(showboxID).innerHTML=''; document.getElementById(showboxID).innerHTML='';
aodiv = document.getElementById(configvalueID); aodiv = document.getElementById(configvalueID);
aodiv.style.display = "block"; aodiv.style.display = "block";
} }
//Insure only one of two mutually exclusive options are checked
function CheckOffOther(clicked, checkOff) {
if (document.getElementById(clicked).checked) {
document.getElementById(checkOff).checked=false;
}
}
//Show another time server line, limited to 10 servers
function NewTimeServer(add) {
//If the last line has a value
var CheckServer = 'server' + (add - 1);
var LastId = document.getElementById(CheckServer);
if (document.getElementById(CheckServer).value != '') {
if (add < 10) {
var TimeServerID = 'timeserver' + add;
document.getElementById(TimeServerID).style.display = 'block';
//then revise the add another server line
if (add < 9) {
var next = add + 1;
var newdiv = '<a class="btn btn-default btn-xs" title="<?= gettext("Add another Time server");?>" onclick="NewTimeServer(' + next + ')" alt="add" ><span class="glyphicon glyphicon-plus"></span></a>\n';
document.getElementById('addserver').innerHTML=newdiv;
}else{
document.getElementById('addserver').style.display = 'none';
}
}
}
}
//]]> //]]>
</script> </script>
<script type="text/javascript">
$( document ).ready(function() {
/**
* Aliases
*/
function removeRow() {
if ( $('#timeservers_table > tbody > tr').length == 1 ) {
$('#timeservers_table > tbody > tr:last > td > input').each(function(){
$(this).val("");
$(this).prop('checked', false);
});
} else {
$(this).parent().parent().remove();
}
}
// add new detail record
$("#addNew").click(function(){
// copy last row and reset values
$('#timeservers_table > tbody').append('<tr>'+$('#timeservers_table > tbody > tr:last').html()+'</tr>');
$('#timeservers_table > tbody > tr:last > td > input').each(function(){
$(this).val("");
$(this).prop('checked', false);
});
$(".act-removerow").click(removeRow);
});
$(".act-removerow").click(removeRow);
// on submit form, set checkbox values
$("#iform").submit(function(event){
$('#timeservers_table > tbody > tr').each(function(){
var timesrv = $(this).find("td > input:first").val();
$(this).find(".ts_checkbox").each(function(){
$(this).val(timesrv);
});
});
});
});
</script>
<?php include("fbegin.inc"); ?> <?php include("fbegin.inc"); ?>
<section class="page-content-main">
<section class="page-content-main"> <div class="container-fluid">
<div class="container-fluid"> <div class="row">
<div class="row"> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12">
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <div class="tab-content content-box col-xs-12">
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <form method="post" name="iform" id="iform" enctype="multipart/form-data" accept-charset="utf-8">
<div class="table-responsive">
<section class="col-xs-12"> <table class="table table-striped">
<thead>
<div class="tab-content content-box col-xs-12"> <tr>
<td width="22%">
<form action="services_ntpd.php" method="post" name="iform" id="iform" enctype="multipart/form-data" accept-charset="utf-8"> <strong><?=gettext("NTP Server Configuration"); ?></strong>
</td>
<div class="table-responsive"> <td width="78%" align="right">
<table class="table table-striped"> <small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
<tr> &nbsp;&nbsp;
<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP Server Configuration"); ?></td> </td>
</tr> </tr>
<tr> </thead>
<td width="22%" valign="top" class="vncellreq"><?=gettext('Interface(s)') ?></td> <tbody>
<td width="78%" class="vtable"> <tr>
<?php <td><a id="help_for_interfaces" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Interface(s)') ?></td>
$interfaces = get_configured_interface_with_descr(); <td>
$carplist = get_configured_carp_interface_list(); <?php
foreach ($carplist as $cif => $carpip) $interfaces = get_configured_interface_with_descr();
$interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")"; $carplist = get_configured_carp_interface_list();
$aliaslist = get_configured_ip_aliases_list(); foreach ($carplist as $cif => $carpip) {
foreach ($aliaslist as $aliasip => $aliasif) $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
$interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")"; }
$size = (count($interfaces) < 10) ? count($interfaces) : 10; $aliaslist = get_configured_ip_aliases_list();
?> foreach ($aliaslist as $aliasip => $aliasif) {
<select id="interface" name="interface[]" multiple="multiple" class="formselect" size="<?= $size; ?>"> $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
<?php }?>
foreach ($interfaces as $iface => $ifacename) { <select id="interface" name="interface[]" multiple="multiple" class="selectpicker">
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) <?php
continue; foreach ($interfaces as $iface => $ifacename):
echo "<option value='{$iface}'"; if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddr($iface)) {
if (is_array($pconfig['interface'])) continue;
if (in_array($iface, $pconfig['interface'])) echo " selected=\"selected\""; }?>
echo ">" . htmlspecialchars($ifacename) . "</option>\n"; <option value="<?=$iface;?>" <?=in_array($iface, $pconfig['interface']) ?" selected=\"selected\"" : "";?>>
} ?> <?=htmlspecialchars($ifacename);?>
</select> </option>
<br /> <?php
<br /><?= gettext("Interfaces without an IP address will not be shown."); ?> endforeach;?>
<br /> </select>
<br /><?= gettext("Selecting no interfaces will listen on all interfaces with a wildcard."); ?> <div class="hidden" for="help_for_interfaces">
<br /><?= gettext("Selecting all interfaces will explicitly listen on only the interfaces/IPs specified."); ?> <?=gettext("Interfaces without an IP address will not be shown."); ?>
</td> <br />
</tr> <br /><?=gettext("Selecting no interfaces will listen on all interfaces with a wildcard."); ?>
<tr> <br /><?=gettext("Selecting all interfaces will explicitly listen on only the interfaces/IPs specified."); ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext('Time servers') ?></td> </div>
<td width="78%" class="vtable"> </td>
<?php </tr>
$timeservers = explode( ' ', $config['system']['timeservers']); <tr>
for ($i = $j = 0; $i < 10; $i++){ <td><a id="help_for_timeservers" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Time servers') ?></td>
echo "<div id=\"timeserver{$i}\""; <td>
if ((isset($timeservers[$i])) || ($i < 3)) { <table class="table table-striped table-condensed" id="timeservers_table">
$j++; <thead>
}else{ <tr>
echo " style=\"display:none\""; <th></th>
} <th><?=gettext("Network"); ?></th>
echo ">\n"; <th><?=gettext("Prefer"); ?></th>
if (!isset($timeservers[$i])) { <th><?=gettext("Do not use"); ?></th>
$timeserverVal = null; </tr>
} else { </thead>
$timeserverVal =$timeservers[$i]; <tbody>
} <?php
echo "<input name=\"server{$i}\" class=\"formfld unknown\" id=\"server{$i}\" size=\"30\" value=\"{$timeserverVal}\" type=\"text\" />&emsp;"; if (count($pconfig['timeservers_host']) == 0 ) {
echo "\n<input name=\"servprefer{$i}\" class=\"formcheckbox\" id=\"servprefer{$i}\" onclick=\"CheckOffOther('servprefer{$i}', 'servselect{$i}')\" type=\"checkbox\""; $pconfig['timeservers_host'][] = "";
if (!empty($config['ntpd']['prefer']) && !empty($timeserverVal) && substr_count($config['ntpd']['prefer'], $timeserverVal)) echo " checked=\"checked\""; $pconfig['timeservers_prefer'][] = false;
echo " />&nbsp;" . gettext('prefer this server') . "&emsp;"; $pconfig['timeservers_noselect'][] = false;
echo "\n<input name=\"servselect{$i}\" class=\"formcheckbox\" id=\"servselect{$i}\" onclick=\"CheckOffOther('servselect{$i}', 'servprefer{$i}')\" type=\"checkbox\""; }
if (!empty($config['ntpd']['noselect']) && !empty($timeserverVal) && substr_count($config['ntpd']['noselect'], $timeserverVal)) echo " checked=\"checked\""; foreach($pconfig['timeservers_host'] as $item_idx => $timeserver):?>
echo " />&nbsp;" . gettext('do not use this server') . "\n<br />\n</div>\n"; <tr>
} <td>
?> <div style="cursor:pointer;" class="act-removerow btn btn-default btn-xs" alt="remove"><span class="glyphicon glyphicon-minus"></span></div>
<div id="addserver"> </td>
<a class="btn btn-default btn-xs" title="<?= gettext("Add another Time server");?>" onclick="NewTimeServer(<?= $j;?>)" alt="add" ><span class="glyphicon glyphicon-plus"></span> </a> <td>
</div> <input name="timeservers_host[]" type="text" value="<?=$timeserver;?>" />
<br /> </td>
<?= gettext('For best results three to five servers should be configured here.'); ?> <td>
<br /> <input name="timeservers_prefer[]" class="ts_checkbox" type="checkbox" value="<?=$timeserver;?>" <?=in_array($timeserver, $pconfig['timeservers_prefer']) ? " checked=\"checked\"" : "";?> />
<?= sprintf(gettext('The %sprefer%s option indicates that NTP should favor the use of this server more than all others.'),'<i>','</i>') ?> </td>
<br /> <td>
<?= sprintf(gettext('The %snoselect%s option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.'),'<i>','</i>') ?> <input name="timeservers_noselect[]" class="ts_checkbox" type="checkbox" value="<?=$timeserver;?>" <?=in_array($timeserver, $pconfig['timeservers_noselect']) ? " checked=\"checked\"" : "";?> />
</td> </td>
</tr> </tr>
<tr> <?php
<td width="22%" valign="top" class="vncellreq"><?=gettext('Orphan mode') ?></td> endforeach;?>
<td width="78%" class="vtable"> </tbody>
<input name="ntporphan" type="text" class="formfld unknown" id="ntporphan" min="1" max="16" size="20" value="<?=htmlspecialchars(isset($pconfig['orphan']) ? $pconfig['orphan']:"");?>" /><?= gettext("(0-15)");?><br /> <tfoot>
<?= gettext("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)."); ?> <tr>
</td> <td colspan="4">
</tr> <div id="addNew" style="cursor:pointer;" class="btn btn-default btn-xs" alt="add"><span class="glyphicon glyphicon-plus"></span></div>
<tr> </td>
<td width="22%" valign="top" class="vncellreq"><?=gettext('NTP graphs') ?></td> </tr>
<td width="78%" class="vtable"> </tfoot>
<input name="statsgraph" type="checkbox" class="formcheckbox" id="statsgraph" <?php if(!empty($pconfig['statsgraph'])) echo " checked=\"checked\""; ?> /> </table>
<?= gettext("Enable rrd graphs of NTP statistics (default: disabled)."); ?> <div class="hidden" for="help_for_timeservers">
</td> <?=gettext('For best results three to five servers should be configured here.'); ?>
</tr> <br />
<tr> <?= sprintf(gettext('The %sprefer%s option indicates that NTP should favor the use of this server more than all others.'),'<i>','</i>') ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext('Syslog logging') ?></td> <br />
<td width="78%" class="vtable"> <?= sprintf(gettext('The %snoselect%s option indicates that NTP should not use this server for time, but stats for this server will be collected and displayed.'),'<i>','</i>') ?>
<?= gettext("These options enable additional messages from NTP to be written to the System Log");?> (<a href="diag_logs_ntpd.php"><?= gettext("Status > System Logs > NTP"); ?></a>). </div>
<br /><br /> </td>
<input name="logpeer" type="checkbox" class="formcheckbox" id="logpeer"<?php if(!empty($pconfig['logpeer'])) echo " checked=\"checked\""; ?> /> </tr>
<?= gettext("Enable logging of peer messages (default: disabled)."); ?> <tr>
<br /> <td><a id="help_for_orphan" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Orphan mode') ?></td>
<input name="logsys" type="checkbox" class="formcheckbox" id="logsys"<?php if(!empty($pconfig['logsys'])) echo " checked=\"checked\""; ?> /> <td>
<?= gettext("Enable logging of system messages (default: disabled)."); ?> <input name="orphan" type="text" value="<?=$pconfig['orphan']?>" />
</td> <div class="hidden" for="help_for_orphan">
</tr> <?=gettext("(0-15)");?><br />
<tr> <?=gettext("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)."); ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext('Statistics logging') ?></td> </div>
<td width="78%" class="vtable"> </td>
<div id="showstatisticsbox"> </tr>
<input class="btn btn-default btn-xs" type="button" onclick="show_advanced('showstatisticsbox', 'showstatistics')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show statistics logging options");?> <tr>
</div> <td><a id="help_for_statsgraph" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('NTP graphs') ?></td>
<div id="showstatistics" style="display:none"> <td>
<strong><?= gettext("Warning: ")?></strong><?= gettext("these options will create persistant daily log files in /var/log/ntp."); ?> <input name="statsgraph" type="checkbox" id="statsgraph" <?=!empty($pconfig['statsgraph']) ? " checked=\"checked\"" : ""; ?> />
<br /><br /> <div class="hidden" for="help_for_statsgraph">
<input name="clockstats" type="checkbox" class="formcheckbox" id="clockstats"<?php if(!empty($pconfig['clockstats'])) echo " checked=\"checked\""; ?> /> <?=gettext("Enable rrd graphs of NTP statistics (default: disabled)."); ?>
<?= gettext("Enable logging of reference clock statistics (default: disabled)."); ?> </div>
<br /> </td>
<input name="loopstats" type="checkbox" class="formcheckbox" id="loopstats"<?php if(!empty($pconfig['loopstats'])) echo " checked=\"checked\""; ?> /> </tr>
<?= gettext("Enable logging of clock discipline statistics (default: disabled)."); ?> <tr>
<br /> <td><a id="help_for_syslog" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Syslog logging') ?></td>
<input name="peerstats" type="checkbox" class="formcheckbox" id="peerstats"<?php if(!empty($pconfig['peerstats'])) echo " checked=\"checked\""; ?> /> <td>
<?= gettext("Enable logging of NTP peer statistics (default: disabled)."); ?> <input name="logpeer" type="checkbox" <?=!empty($pconfig['logpeer']) ? " checked=\"checked\"" : ""; ?> />
</div> <?=gettext("Enable logging of peer messages (default: disabled)."); ?>
</td> <br />
</tr> <input name="logsys" type="checkbox" <?=!empty($pconfig['logsys']) ? " checked=\"checked\"" : ""; ?> />
<tr> <?=gettext("Enable logging of system messages (default: disabled)."); ?>
<td width="22%" valign="top" class="vncellreq"><?=gettext('Access restrictions') ?></td> <div class="hidden" for="help_for_syslog">
<td width="78%" class="vtable"> <?=gettext("These options enable additional messages from NTP to be written to the System Log");?> (<a href="diag_logs_ntpd.php"><?=gettext("Status > System Logs > NTP"); ?></a>).
<div id="showrestrictbox"> </div>
<input type="button" class="btn btn-default btn-xs" onclick="show_advanced('showrestrictbox', 'showrestrict')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show access restriction options");?> </td>
</div> </tr>
<div id="showrestrict" style="display:none"> <tr>
<?= gettext("these options control access to NTP from the WAN."); ?> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext('Statistics logging') ?></td>
<br /><br /> <td>
<input name="kod" type="checkbox" class="formcheckbox" id="kod"<?php if(empty($pconfig['kod'])) echo " checked=\"checked\""; ?> /> <div id="showstatisticsbox">
<?= gettext("Enable Kiss-o'-death packets (default: enabled)."); ?> <input class="btn btn-default btn-xs" type="button" onclick="show_advanced('showstatisticsbox', 'showstatistics')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show statistics logging options");?>
<br /> </div>
<input name="nomodify" type="checkbox" class="formcheckbox" id="nomodify"<?php if(empty($pconfig['nomodify'])) echo " checked=\"checked\""; ?> /> <div id="showstatistics" style="display:none">
<?= gettext("Deny state modifications (i.e. run time configuration) by ntpq and ntpdc (default: enabled)."); ?> <strong><?=gettext("Warning: ")?></strong><?=gettext("these options will create persistant daily log files in /var/log/ntp."); ?>
<br /> <br /><br />
<input name="noquery" type="checkbox" class="formcheckbox" id="noquery"<?php if(!empty($pconfig['noquery'])) echo " checked=\"checked\""; ?> /> <input name="clockstats" type="checkbox" id="clockstats"<?=!empty($pconfig['clockstats']) ? " checked=\"checked\"" : ""; ?> />
<?= gettext("Disable ntpq and ntpdc queries (default: disabled)."); ?> <?=gettext("Enable logging of reference clock statistics (default: disabled)."); ?>
<br /> <br />
<input name="noserve" type="checkbox" class="formcheckbox" id="noserve"<?php if(!empty($pconfig['noserve'])) echo " checked=\"checked\""; ?> /> <input name="loopstats" type="checkbox" id="loopstats"<?=!empty($pconfig['loopstats']) ? " checked=\"checked\"" : ""; ?> />
<?= gettext("Disable all except ntpq and ntpdc queries (default: disabled)."); ?> <?=gettext("Enable logging of clock discipline statistics (default: disabled)."); ?>
<br /> <br />
<input name="nopeer" type="checkbox" class="formcheckbox" id="nopeer"<?php if(empty($pconfig['nopeer'])) echo " checked=\"checked\""; ?> /> <input name="peerstats" type="checkbox" id="peerstats"<?=!empty($pconfig['peerstats']) ? " checked=\"checked\"" : ""; ?> />
<?= gettext("Deny packets that attempt a peer association (default: enabled)."); ?> <?=gettext("Enable logging of NTP peer statistics (default: disabled)."); ?>
<br /> </div>
<input name="notrap" type="checkbox" class="formcheckbox" id="notrap"<?php if(empty($pconfig['notrap'])) echo " checked=\"checked\""; ?> /> </td>
<?= gettext("Deny mode 6 control message trap service (default: enabled)."); ?> </tr>
</div> <tr>
</td> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext('Access restrictions') ?></td>
</tr> <td>
<tr> <div id="showrestrictbox">
<td width="22%" valign="top" class="vncellreq"><?=gettext('Leap seconds') ?></td> <input type="button" class="btn btn-default btn-xs" onclick="show_advanced('showrestrictbox', 'showrestrict')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show access restriction options");?>
<td width="78%" class="vtable"> </div>
<div id="showleapsecbox"> <div id="showrestrict" style="display:none">
<input type="button" class="btn btn-default btn-xs" onclick="show_advanced('showleapsecbox', 'showleapsec')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Leap second configuration");?> <?=gettext("these options control access to NTP from the WAN."); ?>
</div> <br /><br />
<div id="showleapsec" style="display:none"> <input name="kod" type="checkbox" id="kod"<?=empty($pconfig['kod']) ? " checked=\"checked\"" : ""; ?> />
<?= gettext("A leap second file allows NTP to advertize an upcoming leap second addition or subtraction.");?> <?=gettext("Enable Kiss-o'-death packets (default: enabled)."); ?>
<?= gettext("Normally this is only useful if this server is a stratum 1 time server.");?> <br />
<br /><br /> <input name="nomodify" type="checkbox" id="nomodify"<?=empty($pconfig['nomodify']) ? " checked=\"checked\"" : ""; ?> />
<?= gettext("Enter Leap second configuration as text:");?><br /> <?=gettext("Deny state modifications (i.e. run time configuration) by ntpq and ntpdc (default: enabled)."); ?>
<textarea name="leaptxt" class="formpre" id="leaptxt" cols="65" rows="7"><?php $text = base64_decode(chunk_split(isset($pconfig['leapsec'])?$pconfig['leapsec']:"")); echo $text;?></textarea><br /> <br />
<strong><?= gettext("Or");?></strong>, <?= gettext("select a file to upload:");?> <input name="noquery" type="checkbox" id="noquery"<?=!empty($pconfig['noquery']) ? " checked=\"checked\"" : ""; ?> />
<input type="file" name="leapfile" class="formfld file" id="leapfile" /> <?=gettext("Disable ntpq and ntpdc queries (default: disabled)."); ?>
</div> <br />
</td> <input name="noserve" type="checkbox" id="noserve"<?=!empty($pconfig['noserve']) ? " checked=\"checked\"" : ""; ?> />
</tr> <?=gettext("Disable all except ntpq and ntpdc queries (default: disabled)."); ?>
<tr> <br />
<td width="22%" valign="top">&nbsp;</td> <input name="nopeer" type="checkbox" id="nopeer"<?=empty($pconfig['nopeer']) ? " checked=\"checked\"" : ""; ?> />
<td width="78%"> <?=gettext("Deny packets that attempt a peer association (default: enabled)."); ?>
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" /> <br />
</td> <input name="notrap" type="checkbox" id="notrap"<?=empty($pconfig['notrap']) ? " checked=\"checked\"" : ""; ?> />
</tr> <?=gettext("Deny mode 6 control message trap service (default: enabled)."); ?>
</table> </div>
</div> </td>
</form> </tr>
<tr>
</div> <td><i class="fa fa-info-circle text-muted"></i> <?=gettext('Leap seconds') ?></td>
</section> <td>
</div> <div id="showleapsecbox">
</div> <input type="button" class="btn btn-default btn-xs" onclick="show_advanced('showleapsecbox', 'showleapsec')" value="<?=gettext("Advanced");?>" /> - <?=gettext("Show Leap second configuration");?>
</section> </div>
<?php include("foot.inc"); ?> <div id="showleapsec" style="display:none">
<?=gettext("A leap second file allows NTP to advertize an upcoming leap second addition or subtraction.");?>
<?=gettext("Normally this is only useful if this server is a stratum 1 time server.");?>
<br /><br />
<?=gettext("Enter Leap second configuration as text:");?><br />
<textarea name="leapsec" cols="65" rows="7"><?=$pconfig['leapsec'];?></textarea><br />
<strong><?=gettext("Or");?></strong>, <?=gettext("select a file to upload:");?>
<input type="file" name="leapfile"/>
</div>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
</td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment