diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-15 11:40:50 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-15 11:40:50 +0545 |
commit | 42b0c92129b93ca6d182f4904ec92708c9a8c750 (patch) | |
tree | 7d396b83ba7920878bb6e8f42ae5907e9518c003 /usr/local/www/status_ntpd.php | |
parent | c8f1c7bd70cd156f23a59400e5c738ef8bf5281b (diff) | |
download | pfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.zip pfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.tar.gz |
Code style WWW Status
Diffstat (limited to 'usr/local/www/status_ntpd.php')
-rw-r--r-- | usr/local/www/status_ntpd.php | 258 |
1 files changed, 151 insertions, 107 deletions
diff --git a/usr/local/www/status_ntpd.php b/usr/local/www/status_ntpd.php index a5a68ad..44c9733 100644 --- a/usr/local/www/status_ntpd.php +++ b/usr/local/www/status_ntpd.php @@ -44,11 +44,12 @@ require_once("guiconfig.inc"); -if(!isset($config['ntpd']['noquery'])) { - if (isset($config['system']['ipv6allow'])) +if (!isset($config['ntpd']['noquery'])) { + if (isset($config['system']['ipv6allow'])) { $inet_version = ""; - else + } else { $inet_version = " -4"; + } exec("/usr/local/sbin/ntpq -pn $inet_version | /usr/bin/tail +3", $ntpq_output); @@ -116,7 +117,7 @@ if(!isset($config['ntpd']['noquery'])) { $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); $gps_lon = $gps_lon_deg + $gps_lon_min; $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); - }elseif (substr($tmp, 0, 6) == '$GPGGA') { + } elseif (substr($tmp, 0, 6) == '$GPGGA') { $gps_vars = explode(",", $tmp); $gps_ok = $gps_vars[6]; $gps_lat_deg = substr($gps_vars[2], 0, 2); @@ -130,7 +131,7 @@ if(!isset($config['ntpd']['noquery'])) { $gps_alt = $gps_vars[9]; $gps_alt_unit = $gps_vars[10]; $gps_sat = $gps_vars[7]; - }elseif (substr($tmp, 0, 6) == '$GPGLL') { + } elseif (substr($tmp, 0, 6) == '$GPGLL') { $gps_vars = explode(",", $tmp); $gps_ok = ($gps_vars[6] == "A"); $gps_lat_deg = substr($gps_vars[1], 0, 2); @@ -150,9 +151,9 @@ if(!isset($config['ntpd']['noquery'])) { if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board $gpsport = fopen("/dev/gps0", "r+"); - while($gpsport){ + while ($gpsport) { $buffer = fgets($gpsport); - if(substr($buffer, 0, 6)=='$GPGSV'){ + if (substr($buffer, 0, 6)=='$GPGSV') { //echo $buffer."\n"; $gpgsv = explode(',',$buffer); $gps_satview = $gpgsv[3]; @@ -168,108 +169,151 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status ntpd"> -<tr><td><div id="mainarea"> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="heading"> - <tr><td class="listtopic">Network Time Protocol Status</td></tr> - </table> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> - <thead> - <tr> - <th class="listhdrr"><?=gettext("Status"); ?></th> - <th class="listhdrr"><?=gettext("Server"); ?></th> - <th class="listhdrr"><?=gettext("Ref ID"); ?></th> - <th class="listhdrr"><?=gettext("Stratum"); ?></th> - <th class="listhdrr"><?=gettext("Type"); ?></th> - <th class="listhdrr"><?=gettext("When"); ?></th> - <th class="listhdrr"><?=gettext("Poll"); ?></th> - <th class="listhdrr"><?=gettext("Reach"); ?></th> - <th class="listhdrr"><?=gettext("Delay"); ?></th> - <th class="listhdrr"><?=gettext("Offset"); ?></th> - <th class="listhdr"><?=gettext("Jitter"); ?></th> - </tr> - </thead> - <tbody> - <?php if (isset($config['ntpd']['noquery'])): ?> - <tr><td class="listlr" colspan="11" align="center"> - Statistics unavailable because ntpq and ntpdc queries are disabled in the <a href="services_ntpd.php">NTP service settings</a>. - </td></tr> - <?php elseif (count($ntpq_servers) == 0): ?> - <tr><td class="listlr" colspan="11" align="center"> - No peers found, <a href="status_services.php">is the ntp service running?</a>. - </td></tr> - <?php else: ?> - <?php $i = 0; foreach ($ntpq_servers as $server): ?> - <tr> - <td class="listlr nowrap"> - <?=$server['status'];?> - </td> - <td class="listr"> - <?=$server['server'];?> - </td> - <td class="listr"> - <?=$server['refid'];?> - </td> - <td class="listr"> - <?=$server['stratum'];?> - </td> - <td class="listr"> - <?=$server['type'];?> - </td> - <td class="listr"> - <?=$server['when'];?> - </td> - <td class="listr"> - <?=$server['poll'];?> - </td> - <td class="listr"> - <?=$server['reach'];?> - </td> - <td class="listr"> - <?=$server['delay'];?> - </td> - <td class="listr"> - <?=$server['offset'];?> - </td> - <td class="listr"> - <?=$server['jitter'];?> - </td> - </tr> -<?php $i++; endforeach; endif; ?> - </tbody> - </table> -<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)): ?> - <?php $gps_goo_lnk = 2; ?> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="gps status"> - <thead> <tr> - <th class="listhdrr"><?=gettext("Clock Latitude"); ?></th> - <th class="listhdrr"><?=gettext("Clock Longitude"); ?></th> - <?php if (isset($gps_alt)) { echo '<th class="listhdrr">' . gettext("Clock Altitude") . '</th>'; $gps_goo_lnk++;}?> - <?php if (isset($gps_sat) || isset($gps_satview)) { echo '<th class="listhdrr">' . gettext("Satellites") . '</th>'; $gps_goo_lnk++;}?> - </tr> - </thead> - <tbody> - <tr> - <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lat); ?> (<?php echo sprintf("%d", $gps_lat_deg); ?>° <?php echo sprintf("%.5f", $gps_lat_min*60); ?><?php echo $gps_vars[4]; ?>)</td> - <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lon); ?> (<?php echo sprintf("%d", $gps_lon_deg); ?>° <?php echo sprintf("%.5f", $gps_lon_min*60); ?><?php echo $gps_vars[6]; ?>)</td> - <?php if (isset($gps_alt)) { echo '<td class="listlr" align="center">' . $gps_alt . ' ' . $gps_alt_unit . '</td>';}?> - <?php - if (isset($gps_sat) || isset($gps_satview)) { - echo '<td class="listr" align="center">'; - if (isset($gps_satview)) {echo 'in view ' . intval($gps_satview);} - if (isset($gps_sat) && isset($gps_satview)) {echo ', ';} - if (isset($gps_sat)) {echo 'in use ' . $gps_sat;} - echo '</td>'; + <td> + <div id="mainarea"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="heading"> + <tr> + <td class="listtopic">Network Time Protocol Status</td> + </tr> + </table> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> + <thead> + <tr> + <th class="listhdrr"><?=gettext("Status"); ?></th> + <th class="listhdrr"><?=gettext("Server"); ?></th> + <th class="listhdrr"><?=gettext("Ref ID"); ?></th> + <th class="listhdrr"><?=gettext("Stratum"); ?></th> + <th class="listhdrr"><?=gettext("Type"); ?></th> + <th class="listhdrr"><?=gettext("When"); ?></th> + <th class="listhdrr"><?=gettext("Poll"); ?></th> + <th class="listhdrr"><?=gettext("Reach"); ?></th> + <th class="listhdrr"><?=gettext("Delay"); ?></th> + <th class="listhdrr"><?=gettext("Offset"); ?></th> + <th class="listhdr"><?=gettext("Jitter"); ?></th> + </tr> + </thead> + <tbody> +<?php + if (isset($config['ntpd']['noquery'])): +?> + <tr> + <td class="listlr" colspan="11" align="center"> + Statistics unavailable because ntpq and ntpdc queries are disabled in the <a href="services_ntpd.php">NTP service settings</a>. + </td> + </tr> +<?php + elseif (count($ntpq_servers) == 0): +?> + <tr> + <td class="listlr" colspan="11" align="center"> + No peers found, <a href="status_services.php">is the ntp service running?</a>. + </td> + </tr> +<?php + else: + $i = 0; + foreach ($ntpq_servers as $server): +?> + <tr> + <td class="listlr nowrap"> + <?=$server['status'];?> + </td> + <td class="listr"> + <?=$server['server'];?> + </td> + <td class="listr"> + <?=$server['refid'];?> + </td> + <td class="listr"> + <?=$server['stratum'];?> + </td> + <td class="listr"> + <?=$server['type'];?> + </td> + <td class="listr"> + <?=$server['when'];?> + </td> + <td class="listr"> + <?=$server['poll'];?> + </td> + <td class="listr"> + <?=$server['reach'];?> + </td> + <td class="listr"> + <?=$server['delay'];?> + </td> + <td class="listr"> + <?=$server['offset'];?> + </td> + <td class="listr"> + <?=$server['jitter'];?> + </td> + </tr> +<?php + $i++; + endforeach; + endif; +?> + </tbody> + </table> +<?php + if (($gps_ok) && ($gps_lat) && ($gps_lon)): + $gps_goo_lnk = 2; +?> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="gps status"> + <thead> + <tr> + <th class="listhdrr"><?=gettext("Clock Latitude"); ?></th> + <th class="listhdrr"><?=gettext("Clock Longitude"); ?></th> +<?php + if (isset($gps_alt)) { + echo '<th class="listhdrr">' . gettext("Clock Altitude") . '</th>'; + $gps_goo_lnk++; + } + + if (isset($gps_sat) || isset($gps_satview)) { + echo '<th class="listhdrr">' . gettext("Satellites") . '</th>'; + $gps_goo_lnk++; + } +?> + </tr> + </thead> + <tbody> + <tr> + <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lat); ?> (<?php echo sprintf("%d", $gps_lat_deg); ?>° <?php echo sprintf("%.5f", $gps_lat_min*60); ?><?php echo $gps_vars[4]; ?>)</td> + <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lon); ?> (<?php echo sprintf("%d", $gps_lon_deg); ?>° <?php echo sprintf("%.5f", $gps_lon_min*60); ?><?php echo $gps_vars[6]; ?>)</td> +<?php + if (isset($gps_alt)) { + echo '<td class="listlr" align="center">' . $gps_alt . ' ' . $gps_alt_unit . '</td>'; + } + + if (isset($gps_sat) || isset($gps_satview)) { + echo '<td class="listr" align="center">'; + if (isset($gps_satview)) { + echo 'in view ' . intval($gps_satview); } - ?> - </tr> - <tr> - <td class="listlr" colspan="<?php echo $gps_goo_lnk; ?>" align="center"><a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">Google Maps Link</a></td> - </tr> - </tbody> - </table> -<?php endif; ?> -</div></td></tr> + if (isset($gps_sat) && isset($gps_satview)) { + echo ', '; + } + if (isset($gps_sat)) { + echo 'in use ' . $gps_sat; + } + echo '</td>'; + } +?> + </tr> + <tr> + <td class="listlr" colspan="<?php echo $gps_goo_lnk; ?>" align="center"><a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">Google Maps Link</a></td> + </tr> + </tbody> + </table> +<?php + endif; +?> + </div> + </td> + </tr> </table> <?php include("fend.inc"); ?> </body> |