move new settings to optional area under table, disable ntp server, ntp server fqdn validation

This commit is contained in:
Trevor Paskett - K7FPV 2016-01-08 18:04:25 -07:00
parent c6d02d964a
commit 44ab46bc87
8 changed files with 54 additions and 28 deletions

View File

@ -2,3 +2,4 @@ David Rivenburg <ad5oo@arrl.net>
Conrad Lara - KG6JEI <KG6JEI@amsat.org>
Darryl Quinn - K5DLQ <k5dlq@arrl.net>
Joe Ayers - AE6XE <AE6XE@arrl.net>
Trevor Paskett - K7FPV <tpaskett@paskettfamily.com>

View File

@ -5,6 +5,7 @@ config 'system'
config 'timeserver' 'ntp'
list 'server' '<ntp_server>'
option enable_server 0
option enabled 0
config button
option button 'reset'

View File

@ -5,6 +5,7 @@ config 'system'
config 'timeserver' 'ntp'
list 'server' '<ntp_server>'
option enable_server 0
option enabled 0
config button
option button 'reset'

View File

@ -5,6 +5,7 @@ config 'system'
config 'timeserver' 'ntp'
list 'server' '<ntp_server>'
option enable_server 0
option enabled 0
config button
option button 'reset'

View File

@ -5,6 +5,7 @@ config 'system'
config 'timeserver' 'ntp'
list 'server' '<ntp_server>'
option enable_server 0
option enabled 0
config button
option button 'reset'

View File

@ -5,6 +5,7 @@ config 'system'
config 'timeserver' 'ntp'
list 'server' '<ntp_server>'
option enable_server 0
option enabled 0
config button
option button 'reset'

View File

@ -851,10 +851,19 @@ sub validate_hostname
$host =~ s/^\s+//;
$host =~ s/\s+$//;
return 0 if $host =~ /_/;
return 1 if $host =~ /^[\w\-]+$/;
return 1 if $host =~ /^[\w\-\.]+$/;
return 0;
}
# validate_fqdn from http://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
sub validate_fqdn {
my $testval = shift(@_);
( $testval =~ m/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]+)\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/ )
? return 1
: return 0;
}
sub validate_port
{
my($port) = @_;

View File

@ -412,7 +412,7 @@ if($parms{button_save})
push(@errors, "invalid tactical name");
}
if($ntp_server eq '')
if($ntp_server eq '' || validate_fqdn($ntp_server) == 0)
{
push(@errors, "invalid ntp server");
}
@ -602,30 +602,6 @@ print "</select></td>
<td>Verify Password</td>
<td><input type=password name=passwd2 value='$passwd2' size=8 tabindex=3></td>";
print "<tr><td colspan='4'><hr /></td></tr>";
print "<tr><td align=left>Latitude</td><td><input type=text name=latitude size=10 value='$lat' title='Latitude value (in decimal) (ie. 30.312354)' /></td>";
print "<td align='right' colspan='2'>";
if($pingOk)
{
print "<button type='button' id='hideshowmap' value='show' onClick='toggleMap(this);'>Show Map</button>&nbsp;";
} else {
print "<button disabled type='button' title='The map is only available if this node has internet access'>Show Map</button>&nbsp;";
}
print "<input type=submit name='button_updatelocation' value='Apply Location Settings' title='Immediately use these location settings'>";
print "</td>\n";
print "<tr><td align=left>Longitude</td><td><input type=text name=longitude size=10 value='$lon' title='Longitude value (in decimal) (ie. -95.334454)' /></td>";
print "<td align=left>Grid Square</td><td align='left'><input type=text name=gridsquare maxlength=6 size=6 value='$gridsquare' title='Gridsquare value (ie. AB12cd)' /></td></tr>\n";
print "<tr>
<td>Timezone</td>
<td><select name=time_zone_name tabindex=10>\n";
foreach my $tz (@$tz_db_names) {
selopt($tz, $tz, $time_zone_name);
}
print "</select></td><td align=left>NTP Server</td><td><input type=text name=ntp_server size=20 value='$ntp_server'></td>";
print "
</tr>
</table>
@ -641,7 +617,6 @@ if($config ne "mesh")
print "<tr><td><br>";
print "<div id='map' style='height: 200px; display: none;'></div><br />" if($pingOk);
print "<table cellpadding=5 border=1 width=100%><tr><td valign=top width=33%>\n";
#
@ -797,8 +772,8 @@ else
push @hidden, "<input type=hidden name=wifi_chanbw value='20'>";
push @hidden, "<input type=hidden name=wifi_country value='US'>";
}
print "</table></td>\n";
print "</table></td>\n";
#
# LAN settings
@ -985,6 +960,42 @@ print "</table>
</td></tr>\n";
#
# Optional Settings
#
print "<tr><td align=center>\n";
print "<table cellpadding=5 border=0><tr><th colspan=4>Optional Settings</th></tr>";
print "<tr><td align=left>Latitude</td><td><input type=text name=latitude size=10 value='$lat' title='Latitude value (in decimal) (ie. 30.312354)' /></td>";
print "<td align='right' colspan='2'>";
if($pingOk)
{
print "<button type='button' id='hideshowmap' value='show' onClick='toggleMap(this);'>Show Map</button>&nbsp;";
} else {
print "<button disabled type='button' title='The map is only available if this node has internet access'>Show Map</button>&nbsp;";
}
print "<input type=submit name='button_updatelocation' value='Apply Location Settings' title='Immediately use these location settings'>";
print "</td>\n";
print "<tr><td align=left>Longitude</td><td><input type=text name=longitude size=10 value='$lon' title='Longitude value (in decimal) (ie. -95.334454)' /></td>";
print "<td align=left>Grid Square</td><td align='left'><input type=text name=gridsquare maxlength=6 size=6 value='$gridsquare' title='Gridsquare value (ie. AB12cd)' /></td></tr>\n";
print "<tr>
<td>Timezone</td>
<td><select name=time_zone_name tabindex=10>\n";
foreach my $tz (@$tz_db_names) {
selopt($tz, $tz, $time_zone_name);
}
print "</select></td><td align=left>NTP Server</td><td><input type=text name=ntp_server size=20 value='$ntp_server'></td>";
print "</table></td></tr>";
print "<tr><td colspan=4>";
print "<div id='map' style='height: 200px; display: none;'></div><br />" if($pingOk);
print "</td></tr>";
print "</table>\n";
push @hidden, "<input type=hidden name=oldconfig value='$oldconfig'>";