diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 4de591de5..ff6b78759 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -1405,9 +1405,9 @@ function system_ntp_setup_gps($serialport) symlink($serialport, $gps_device); /* Send the following to the GPS port to initialize the GPS */ - if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['type'])) { + if (isset($config['ntpd']['gps'])) { $gps_init = base64_decode($config['ntpd']['gps']['initcmd']); - }else{ + } else { $gps_init = base64_decode('JFBVQlgsNDAsR1NWLDAsMCwwLDAqNTkNCiRQVUJYLDQwLEdMTCwwLDAsMCwwKjVDDQokUFVCWCw0MCxaREEsMCwwLDAsMCo0NA0KJFBVQlgsNDAsVlRHLDAsMCwwLDAqNUUNCiRQVUJYLDQwLEdTViwwLDAsMCwwKjU5DQokUFVCWCw0MCxHU0EsMCwwLDAsMCo0RQ0KJFBVQlgsNDAsR0dBLDAsMCwwLDANCiRQVUJYLDQwLFRYVCwwLDAsMCwwDQokUFVCWCw0MCxSTUMsMCwwLDAsMCo0Ng0KJFBVQlgsNDEsMSwwMDA3LDAwMDMsNDgwMCwwDQokUFVCWCw0MCxaREEsMSwxLDEsMQ=='); } @@ -1586,16 +1586,6 @@ function system_ntp_configure($start_ntpd = true) $ntpcfg .= $config['ntpd']['gps']['refid']; } $ntpcfg .= "\n"; - }elseif (!empty($config['ntpd']['gpsport']) - && file_exists('/dev/'.$config['ntpd']['gpsport']) - && system_ntp_setup_gps($config['ntpd']['gpsport'])) { - /* This handles a 2.1 and earlier config */ - $ntpcfg .= "# GPS Setup\n"; - $ntpcfg .= "server 127.127.20.0 mode 0 minpoll 4 maxpoll 4 prefer\n"; - $ntpcfg .= "fudge 127.127.20.0 time1 0.155 time2 0.000 flag1 1 flag2 0 flag3 1\n"; - // Fall back to local clock if GPS is out of sync? - $ntpcfg .= "server 127.127.1.0\n"; - $ntpcfg .= "fudge 127.127.1.0 stratum 12\n"; } /* End GPS configuration */ diff --git a/src/www/services_ntpd.php b/src/www/services_ntpd.php index 46c7fec24..0278f5088 100644 --- a/src/www/services_ntpd.php +++ b/src/www/services_ntpd.php @@ -52,11 +52,6 @@ if ($_POST) { elseif (isset($config['ntpd']['interface'])) unset($config['ntpd']['interface']); - if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) - $config['ntpd']['gpsport'] = $_POST['gpsport']; - elseif (isset($config['ntpd']['gpsport'])) - unset($config['ntpd']['gpsport']); - unset($config['ntpd']['prefer']); unset($config['ntpd']['noselect']); $timeservers = ''; diff --git a/src/www/services_ntpd_gps.php b/src/www/services_ntpd_gps.php index 72e57c33d..a4cb7c5f3 100644 --- a/src/www/services_ntpd_gps.php +++ b/src/www/services_ntpd_gps.php @@ -2,8 +2,8 @@ /* Copyright (C) 2014-2015 Deciso B.V. - Copyright (C) 2013 Dagorlad - Copyright (C) 2012 Jim Pingle + Copyright (C) 2013 Dagorlad + Copyright (C) 2012 Jim Pingle All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,38 +33,24 @@ require_once("services.inc"); require_once("system.inc"); require_once("interfaces.inc"); -function set_default_gps() { - global $config; - - if (!isset($config['ntpd']) || !is_array($config['ntpd'])) - $config['ntpd'] = array(); - +if (!isset($config['ntpd']['gps'])) { $config['ntpd']['gps'] = array(); - $config['ntpd']['gps']['type'] = 'Generic'; - /* copy an existing configured GPS port if it exists, the unset may be uncommented post production */ - if (!empty($config['ntpd']['gpsport']) && empty($config['ntpd']['gps']['port'])) { - $config['ntpd']['gps']['port'] = $config['ntpd']['gpsport']; - unset($config['ntpd']['gpsport']); /* this removes the original port config from config.xml */ - $config['ntpd']['gps']['speed'] = 0; - $config['ntpd']['gps']['nmea'] = 0; - } - - write_config("Setting default NTPd settings"); } if ($_POST) { - unset($input_errors); - if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) + if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) { $config['ntpd']['gps']['port'] = $_POST['gpsport']; - /* if port is not set, remove all the gps config */ - else unset($config['ntpd']['gps']); + } else if (isset($config['ntpd']['gps']['port'])) { + unset($config['ntpd']['gps']['port']); + } - if (!empty($_POST['gpstype'])) + if (!empty($_POST['gpstype'])) { $config['ntpd']['gps']['type'] = $_POST['gpstype']; - elseif (isset($config['ntpd']['gps']['type'])) + } elseif (isset($config['ntpd']['gps']['type'])) { unset($config['ntpd']['gps']['type']); + } if (!empty($_POST['gpsspeed'])) $config['ntpd']['gps']['speed'] = $_POST['gpsspeed']; @@ -141,16 +127,13 @@ if ($_POST) { $retval = system_ntp_configure(); $savemsg = get_std_save_message(); -} else { - /* set defaults if they do not already exist */ - if (empty($config['ntpd']['gps']['type'])) { - set_default_gps(); - } } + $closehead = false; $pconfig = &$config['ntpd']['gps']; $pgtitle = array(gettext('Services'), gettext('Network Time'), gettext('GPS')); $shortcut_section = "ntp"; + include("head.inc"); ?> @@ -250,7 +233,7 @@ SureGPS = #Sure Electronics SKG16B var gpsdef = new Object(); //get the text description of the selected type var e = document.getElementById("gpstype"); - var type = e.options[e.selectedIndex].text; + var type = e.options[e.selectedIndex].value; //stuff the JS object as needed for each type switch(type) { @@ -380,14 +363,14 @@ SureGPS = #Sure Electronics SKG16B